@jesec/flood 0.0.0-master.1d7ec6a → 0.0.0-master.1da2260
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/assets/index.html +1 -1
- package/dist/assets/static/js/{179.30908bfc.chunk.js → 179.c81c7db0.chunk.js} +1 -1
- package/dist/assets/static/js/{704.7c6c6361.chunk.js → 704.0a13f61a.chunk.js} +1 -1
- package/dist/assets/static/js/{main.9fcba1be.js → main.fe549a05.js} +1 -1
- package/dist/index.js +1029 -1039
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -10,12 +10,12 @@ Flood is a monitoring service for various torrent clients. It's a Node.js servic
|
|
|
10
10
|
|
|
11
11
|
#### Supported Clients
|
|
12
12
|
|
|
13
|
-
| Client | Support
|
|
14
|
-
| --------------------------------------------------------------- |
|
|
15
|
-
| [rTorrent](https://github.com/rakshasa/rtorrent) | :white_check_mark: ([tested](https://github.com/jesec/flood/blob/master/server/.
|
|
16
|
-
| [qBittorrent](https://github.com/qbittorrent/qBittorrent) v4.1+ | :white_check_mark: ([tested](https://github.com/jesec/flood/blob/master/server/.
|
|
17
|
-
| [Transmission](https://github.com/transmission/transmission) | :white_check_mark: ([tested](https://github.com/jesec/flood/blob/master/server/.
|
|
18
|
-
| [Deluge](https://github.com/deluge-torrent/deluge) v2+ | :alembic: Experimental
|
|
13
|
+
| Client | Support |
|
|
14
|
+
| --------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| [rTorrent](https://github.com/rakshasa/rtorrent) | :white_check_mark: ([tested](https://github.com/jesec/flood/blob/master/server/.vitest/rtorrent.setup.ts)) |
|
|
16
|
+
| [qBittorrent](https://github.com/qbittorrent/qBittorrent) v4.1+ | :white_check_mark: ([tested](https://github.com/jesec/flood/blob/master/server/.vitest/qbittorrent.setup.ts)) |
|
|
17
|
+
| [Transmission](https://github.com/transmission/transmission) | :white_check_mark: ([tested](https://github.com/jesec/flood/blob/master/server/.vitest/transmission.setup.ts)) |
|
|
18
|
+
| [Deluge](https://github.com/deluge-torrent/deluge) v2+ | :alembic: Experimental |
|
|
19
19
|
|
|
20
20
|
##### RTorrent Notes
|
|
21
21
|
|
package/dist/assets/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/><meta http-equiv="Pragma" content="no-cache"/><meta http-equiv="Expires" content="0"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/><meta name="theme-color" content="#000000"/><meta name="apple-mobile-web-app-title" content="Flood"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="default"/><link rel="manifest" href="manifest.json"/><link rel="shortcut icon" href="favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="icon_maskable_180x180.png"/><title>Flood</title><script defer="defer" src="static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/><meta http-equiv="Pragma" content="no-cache"/><meta http-equiv="Expires" content="0"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/><meta name="theme-color" content="#000000"/><meta name="apple-mobile-web-app-title" content="Flood"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="default"/><link rel="manifest" href="manifest.json"/><link rel="shortcut icon" href="favicon.ico"/><link rel="apple-touch-icon" sizes="180x180" href="icon_maskable_180x180.png"/><title>Flood</title><script defer="defer" src="static/js/main.fe549a05.js"></script><link href="static/css/main.3c84774255bf82939749.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="app"></div></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(globalThis.webpackChunk_jesec_flood=globalThis.webpackChunk_jesec_flood||[]).push([[179],{179:(e,t,s)=>{s.r(t),s.d(t,{default:()=>Bt});var i=s(6488),l=s(2618),n=s(6540),r=s(3443),a=s(9679),d=s(9161),o=s(6565),c=s(9075),h=s(2412);const u=({start:e,destination:t,tags:s,tab:i})=>{const l={};null!=e&&(l.startTorrentsOnLoad=e),null!=t&&""!==t&&(null==l.torrentDestinations&&(l.torrentDestinations=h.A.floodSettings.torrentDestinations||{}),"string"==typeof s?.[0]?l.torrentDestinations[s[0]]=t:l.torrentDestinations[""]=t),null!=i&&(l.UITorrentsAddTab=i),c.A.saveSettings(l)};var x=s(3537),_=s(4930),m=s(4848);const j=e=>{const{actions:t}=e,s=t.map((e,t)=>{let s=()=>{};return e.triggerDismiss&&(s=()=>{_.A.setActiveModal(null)}),"checkbox"===e.type?(0,m.jsx)(o.Sc,{defaultChecked:e.checked,id:e.id,onClick:t=>{null!=e.clickHandler&&e.clickHandler(t),s()},children:e.content},t):(0,m.jsx)(o.$n,{isLoading:e.isLoading,onClick:t=>{null!=e.clickHandler&&e.clickHandler(t),s()},priority:e.type,type:e.submit?"submit":"button",children:e.content},t)}),i=(0,m.jsx)("div",{className:"modal__button-group",children:s});return(0,m.jsx)("div",{className:"modal__actions",children:i})},g=({isAddingTorrents:e,onAddTorrentsClick:t})=>{const{i18n:s}=(0,d.uB)();return(0,m.jsx)(j,{actions:[{checked:Boolean(h.A.floodSettings.startTorrentsOnLoad),clickHandler:null,content:s._("torrents.add.start.label"),id:"start",triggerDismiss:!1,type:"checkbox"},{clickHandler:null,content:s._("button.cancel"),triggerDismiss:!0,type:"tertiary"},{clickHandler:t,content:s._("torrents.add.button.add"),isLoading:e,submit:!0,triggerDismiss:!1,type:"primary"}]})};var f=s(8221),p=s.n(f),b=s(5162),v=s(942),y=s(9475),k=s(9844),N=s(2114),A=s(8851),S=s(2592);const w=y.AH.raw({padding:"3px 9px"}),C=y.AH.raw({borderBottom:"1px solid #dde2e8",marginBottom:"3px",paddingBottom:"3px",opacity:.75,_last:{marginBottom:0}}),T=y.AH.raw({transition:"color 0.25s",whiteSpace:"nowrap","& button":{width:"100%",height:"100%",textAlign:"left",_disabled:{pointerEvents:"none"},...w}}),R=(0,y.AH)({opacity:.5,...T}),D=y.AH.raw({color:"#374c66",background:"rgba(94, 114, 140, 0.1)","& button:focus":{outline:"none",WebkitTapHighlightColor:"transparent"}}),M=(0,y.AH)({opacity:1,cursor:"pointer",transition:"background 0.25s, color 0.25s",userSelect:"none",_hover:D,_focusWithin:D,...T}),P={EACCES:"filesystem.error.eacces",ENOENT:"filesystem.error.enoent"},I=(0,n.memo)(({directory:e,selectable:t,onItemSelection:s,onYieldFocus:i})=>{const[l,r]=(0,n.useState)(null),[a,o]=(0,n.useState)(null),[c,h]=(0,n.useState)(e.includes("/")?"/":"\\"),[u,x]=(0,n.useState)(null),[_,j]=(0,n.useState)(null),g=(0,n.useRef)(null),f=e.lastIndexOf(c)+1,p=f>0?e.substr(0,f):e,b=e.substr(f);(0,n.useEffect)(()=>{p&&(r(null),x(null),j(null),A.A.fetchDirectoryList(p).then(({files:e,directories:t,separator:s})=>{x(t),j(e),h(s),o(null)}).catch(({response:e})=>{o(e)}))},[p]),(0,n.useEffect)(()=>{if(null!=g.current&&null!=l){const e=g.current.children[l]?.children[0];0===e?.tabIndex?e.focus():r(Array.from(g.current.children).findIndex(e=>0===e.children[0].tabIndex))}},[l]),(0,N.A)("ArrowUp",e=>{e.preventDefault(),r(e=>null==e||e-1<0?(i?.(),null):e-1)}),(0,N.A)("ArrowDown",e=>{e.preventDefault(),r(e=>null!=e?e+1:0)});let T=null,D=[];if((null==u&&"directories"===t||null==_&&"files"===t)&&(T="filesystem.fetching"),a&&a.data&&a.data.code&&(T=P[a.data.code]||"filesystem.error.unknown"),e){const e=`${p.split(c).slice(0,-2).join(c)}${c}`,i=(0,m.jsx)("li",{className:`${M} ${(0,y.AH)({"@media (max-width: 720px)":C})}`,children:(0,m.jsxs)("button",{type:"button",onClick:()=>s?.(e,!0),children:[(0,m.jsx)(v.i3,{className:(0,y.AH)({transform:"scale(0.75) rotate(180deg)"})}),".."]})},e),l="files"!==t,n=b?(0,S.A)(u,e=>e,b):[],r=n.includes(b)||"directories"!==t||!b||T?[]:(()=>{const e=`${p}${b}${c}`;return[(0,m.jsx)("li",{className:`${M} ${(0,y.AH)({"@media (max-width: 720px)":{display:"none"}})}`,style:{fontWeight:"bold"},children:(0,m.jsxs)("button",{type:"button",onClick:()=>s?.(e,!1),children:[(0,m.jsx)(v.N7,{}),(0,m.jsx)("span",{style:{whiteSpace:"pre-wrap"},children:b}),(0,m.jsxs)("em",{style:{fontWeight:"lighter"},children:[" - ",(0,m.jsx)(d.x6,{id:"filesystem.error.enoent"})]})]})},e)]})(),a=u?.length&&(0,k.di)(u.slice()).desc(e=>n.includes(e)).map(e=>{const t=`${p}${e}${c}`;return(0,m.jsx)("li",{className:l?M:R,style:n.includes(e)?{fontWeight:"bold"}:void 0,children:(0,m.jsxs)("button",{type:"button",disabled:!l,tabIndex:l?0:-1,onClick:l?()=>s?.(t,!0):void 0,children:[(0,m.jsx)(v.Ah,{}),e]})},t)})||[],o="directories"!==t,h=b?(0,S.A)(_,e=>e,b):[],x=_?.length&&(0,k.di)(_.slice()).desc(e=>h.includes(e)).map(e=>{const t=`${p}${e}`;return(0,m.jsx)("li",{className:o?M:R,style:h.includes(e)?{fontWeight:"bold"}:void 0,children:(0,m.jsxs)("button",{type:"button",disabled:!o,tabIndex:o?0:-1,onClick:o?()=>s?.(t,!1):void 0,children:[(0,m.jsx)(v.ZH,{}),e]})},t)})||[];0!==a.length||0!==x.length||T||(T="filesystem.empty.directory"),D=[i,...r,...a,...x]}else T="filesystem.error.no.input";return(0,m.jsxs)("div",{className:(0,y.AH)({color:"#5E728C",listStyle:"none",padding:"3px 0px","& .icon":{fill:"currentColor",height:"14px",width:"14px",marginRight:"5px",marginTop:"-3px",verticalAlign:"middle"}}),children:[p&&(0,m.jsxs)("li",{className:`${R} ${(0,y.AH)(C,w,{whiteSpace:"pre-wrap",wordBreak:"break-all","& .icon":{transform:"scale(0.9)",marginTop:"-2px !important"},"@media (max-width: 720px)":{display:"none"}})}`,children:[(0,m.jsx)(v.gx,{}),p]}),(0,m.jsx)("ul",{ref:g,children:D}),T&&(0,m.jsx)("div",{className:`${R} ${(0,y.AH)(w)}`,style:{opacity:1},children:(0,m.jsx)("em",{children:(0,m.jsx)(d.x6,{id:T})})})]})}),$=(0,n.forwardRef)(({id:e,label:t,selectable:s,suggested:i,showBasePathToggle:l=!1,showCompletedToggle:r=!1,showSequentialToggle:a=!1,onChange:c},u)=>{const[x,_]=(0,n.useState)(i||h.A.floodSettings.torrentDestinations?.[""]||h.A.clientSettings?.directoryDefault||""),[j,g]=(0,n.useState)(!1),f=(0,n.useRef)(null),y=(0,b.A)(u),{i18n:k}=(0,d.uB)();(0,n.useEffect)(()=>{const e=()=>{g(!1)},t=t=>{f.current?.contains(t.target)||e()};return document.addEventListener("click",t),window.addEventListener("resize",e),()=>{document.removeEventListener("click",t),window.removeEventListener("resize",e)}},[]);const N=[];return l&&N.push((0,m.jsx)(o.Sc,{grow:!1,id:"isBasePath",children:(0,m.jsx)(d.x6,{id:"torrents.destination.base_path"})},"isBasePath")),r&&N.push((0,m.jsx)(o.Sc,{grow:!1,id:"isCompleted",children:(0,m.jsx)(d.x6,{id:"torrents.destination.completed"})},"isCompleted")),a&&N.push((0,m.jsx)(o.Sc,{grow:!1,id:"isSequential",children:(0,m.jsx)(d.x6,{id:"torrents.destination.sequential"})},"isSequential")),(0,m.jsxs)(o.eW,{ref:f,children:[(0,m.jsx)(o.fh,{children:(0,m.jsxs)(o.Rj,{autoComplete:j?"off":void 0,addonPlacement:"after",defaultValue:x,id:e,label:t,onChange:p()(()=>{if(null==y.current)return;const e=y.current.value;c&&c(e),_(e)},100,{leading:!0}),onClick:e=>e.nativeEvent.stopImmediatePropagation(),placeholder:k._("torrents.add.destination.placeholder"),ref:y,children:[(0,m.jsx)(o.t0,{onClick:()=>{null!=y.current&&_(y.current.value),g(!j)},children:(0,m.jsx)(v.vj,{})}),(0,m.jsx)(o.ZL,{children:(0,m.jsx)(o.tz,{isIn:j,onClick:e=>e.nativeEvent.stopImmediatePropagation(),overlayProps:{isInteractive:!1},padding:!1,triggerRef:y,children:(0,m.jsx)(I,{directory:x,selectable:s,onItemSelection:(e,t=!0)=>{null!=y.current&&(y.current.value=e),g(t),_(e)},onYieldFocus:()=>{y.current?.focus()}})})})]})}),N.length>0?(0,m.jsx)(o.fh,{children:N}):null]})});var V=s(6942),L=s.n(V),H=s(9399);const F=({defaultValue:e,placeholder:t,id:s="tags",label:i,onTagSelected:l})=>{const[r,c]=(0,n.useState)(!1),[u,x]=(0,n.useState)(e??[]),_=(0,n.useRef)(null),j=(0,n.useRef)(null),g=(0,n.useRef)(null),f=L()("select form__element",{"select--is-open":r});return(0,a.A)("Escape",e=>{e.preventDefault(),c(!1)}),(0,n.useEffect)(()=>{const e=e=>{_.current?.contains(e.target)||c(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[]),(0,n.useEffect)(()=>{null!=g.current&&(g.current.value=u.join()),l&&l(u)},[u,l]),(0,m.jsx)(o.ci,{ref:_,children:(0,m.jsx)("div",{className:f,children:(0,m.jsxs)(o.Rj,{autoComplete:r?"off":void 0,id:s||"tags",addonPlacement:"after",defaultValue:e,label:i,onChange:()=>{if(null!=g.current){let e=g.current.value.split(",").map(e=>e.trim()).filter(e=>e.length>0);g.current.value.trimEnd().endsWith(",")&&(e.push(""),e=[...new Set(e)]),x(e)}},placeholder:t,ref:g,children:[(0,m.jsx)(o.t0,{onClick:()=>{c(!r)},className:"select__indicator",children:(0,m.jsx)(v.cL,{})}),(0,m.jsx)(o.ZL,{children:(0,m.jsx)(o.tz,{isIn:r,onClick:e=>{"single"!==h.A.floodSettings.UITagSelectorMode&&e.nativeEvent.stopImmediatePropagation()},overlayProps:{isInteractive:!1},ref:j,triggerRef:g,children:[...new Set(["untagged",...(0,k.di)(Object.keys(H.A.taxonomy.tagCounts)).asc(),...u])].reduce((e,t)=>(""===t||e.push((0,m.jsx)(o.eb,{id:t,isSelected:u.includes(t),onClick:()=>{"untagged"===t?x([]):u.includes(t)?x(u.filter(e=>e!==t&&""!==e)):x([...u.filter(e=>""!==e),t])},children:"untagged"===t?(0,m.jsx)(d.x6,{id:"filter.untagged"}):t},t)),e),[])})})]})})})},E=(e,t)=>Object.keys(e).reduce((s,i)=>{if(i.startsWith(t)){const t=e[i];null!=t&&s.push(t)}return s},[]),B=({defaultValues:e,id:t,label:s,placeholder:i})=>{const l=(0,n.useRef)(0),[r,a]=(0,n.useState)(e??[{id:0,value:""}]);return(0,m.jsx)(o.eW,{children:r.map((e,n)=>{let d=null;return n>0&&(d=(0,m.jsx)(o.t0,{onClick:()=>{const e=r.slice();e.splice(n,1),a(e)},children:(0,m.jsx)(v._B,{})})),(0,m.jsx)(o.fh,{children:(0,m.jsxs)(o.Rj,{addonPlacement:"after",id:`${t}-${e.id}`,defaultValue:e.value,label:0===n&&s,placeholder:i,wrapperClassName:"textbox-repeater",children:[(0,m.jsx)(o.t0,{onClick:()=>{l.current+=1;const e=r.slice();e.splice(n+1,0,{id:l.current,value:""}),a(e)},children:(0,m.jsx)(v.Fx,{})}),d]})},e.id)})})},O=()=>{const e=(0,n.useRef)(null),{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(!1);return(0,m.jsxs)(o.lV,{className:"inverse",ref:e,children:[(0,m.jsx)($,{id:"sourcePath",label:t._("torrents.create.source.path.label")}),(0,m.jsx)(B,{id:"trackers",label:t._("torrents.create.trackers.label"),placeholder:t._("torrents.create.tracker.input.placeholder"),defaultValues:[{id:0,value:""}]}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{id:"name",label:t._("torrents.create.base.name.label"),placeholder:t._("torrents.create.base.name.input.placeholder")})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{id:"comment",label:t._("torrents.create.comment.label"),placeholder:t._("torrents.create.comment.input.placeholder")})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{id:"infoSource",label:t._("torrents.create.info.source.label"),placeholder:t._("torrents.create.info.source.input.placeholder")})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Sc,{grow:!1,id:"isPrivate",children:t._("torrents.create.is.private.label")})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(F,{id:"tags",label:t._("torrents.add.tags"),placeholder:t._("torrents.create.tags.input.placeholder")})}),(0,m.jsx)(g,{onAddTorrentsClick:()=>{if(null==e.current)return;const t=e.current.getFormData();i(!0),null!=t.sourcePath&&(x.A.createTorrent({name:t.name,sourcePath:t.sourcePath,trackers:E(t,"trackers"),comment:t.comment,infoSource:t.infoSource,isPrivate:t.isPrivate||!1,start:t.start||!1,tags:null!=t.tags?t.tags.split(","):void 0}).then(()=>{_.A.setActiveModal(null)}),u({start:t.start,destination:t.sourcePath,tab:"by-creation"}))},isAddingTorrents:s})]})};var U=s(6386);const z=({initialFiles:e,onFilesChanged:t})=>{const[s,i]=(0,n.useState)(e??[]);return(0,n.useEffect)(()=>{t(s)},[s,t]),(0,m.jsxs)(o.ci,{children:[(0,m.jsx)("span",{className:"form__element__label",children:(0,m.jsx)(d.x6,{id:"torrents.add.torrents.label"})}),s.length>0?(0,m.jsx)("div",{onClick:e=>{e.stopPropagation()},role:"none",children:(0,m.jsx)("ul",{className:"dropzone__selected-files interactive-list",children:s.map((e,t)=>(0,m.jsxs)("li",{className:"dropzone__selected-files__file interactive-list__item",title:e.name,children:[(0,m.jsx)("span",{className:"interactive-list__icon",children:(0,m.jsx)(v.ZH,{})}),(0,m.jsx)("span",{className:"interactive-list__label",children:e.name}),(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>{const e=s.slice();e.splice(t,1),i(e)},children:(0,m.jsx)(v.bm,{})})]},e.name))})}):null,(0,m.jsx)(U.Ay,{onDrop:e=>{const t=[];e.forEach(l=>{const n=new FileReader;n.onload=n=>{null!=n.target?.result&&"string"==typeof n.target.result&&t.push({name:l.name,data:n.target.result.split("base64,")[1]}),t.length===e.length&&i(s.concat(t))},n.readAsDataURL(l)})},children:({getRootProps:e,getInputProps:t,isDragActive:s})=>(0,m.jsxs)("div",{...e(),className:"form__dropzone dropzone interactive-list "+(s?"dropzone--is-dragging":""),children:[(0,m.jsx)("input",{...t()}),(0,m.jsxs)("div",{className:"dropzone__copy",children:[(0,m.jsx)("div",{className:"dropzone__icon",children:(0,m.jsx)(v.sv,{})}),(0,m.jsx)(d.x6,{id:"torrents.add.tab.file.drop"})," ",(0,m.jsx)("span",{className:"dropzone__browse-button",children:(0,m.jsx)(d.x6,{id:"torrents.add.tab.file.browse"})}),"."]})]})})]})},W=()=>{const e=(0,n.useRef)([]),t=(0,n.useRef)(null),s=(0,n.useRef)(null),[i,l]=(0,n.useState)(!1),{i18n:r}=(0,d.uB)();return(0,m.jsxs)(o.lV,{className:"inverse",ref:t,children:[(0,m.jsx)(o.fh,{children:(0,m.jsx)(z,{initialFiles:"add-torrents"===_.A.activeModal?.id&&"by-file"===_.A.activeModal?.tab&&_.A.activeModal?.files||[],onFilesChanged:t=>{e.current=t}})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(F,{label:r._("torrents.add.tags"),id:"tags",onTagSelected:e=>{if(null!=s.current){const t=h.A.floodSettings.torrentDestinations?.[e[0]];"string"==typeof t&&null!=s.current&&(s.current.value=t,s.current.dispatchEvent(new Event("input",{bubbles:!0})))}}})}),(0,m.jsx)($,{id:"destination",label:r._("torrents.add.destination.label"),ref:s,selectable:"directories",showBasePathToggle:!0,showCompletedToggle:!0,showSequentialToggle:!0}),(0,m.jsx)(g,{onAddTorrentsClick:()=>{if(null==t.current)return;const s=t.current?.getFormData();l(!0);const{destination:i,start:n,tags:r,isBasePath:a,isCompleted:d,isSequential:o}=s,c=[];if(e.current.forEach(e=>{c.push(e.data)}),0===c.length||null==i)return void l(!1);const h=null!=r?r.split(",").filter(e=>e.length>0):void 0;x.A.addTorrentsByFiles({files:c,destination:i,tags:h,isBasePath:a,isCompleted:d,isSequential:o,start:n}).then(()=>{_.A.setActiveModal(null)}),u({start:n,destination:i,tags:h,tab:"by-file"})},isAddingTorrents:i})]})};var q=s(9550);const G=()=>{const e=(0,n.useRef)(null),t=(0,n.useRef)(null),[s,i]=(0,n.useState)(!1),{i18n:l}=(0,d.uB)();return(0,m.jsxs)(o.lV,{className:"inverse",ref:e,children:[(0,m.jsx)(B,{id:"urls",label:(0,m.jsxs)("div",{children:[l._("torrents.add.torrents.label"),"function"==typeof navigator.registerProtocolHandler&&(0,m.jsx)("button",{className:(0,y.AH)({float:"right",_focus:{outline:"none",WebkitTapHighlightColor:"transparent"},_focusVisible:{outline:"dashed"}}),type:"button",onClick:()=>{"function"==typeof navigator.registerProtocolHandler&&navigator.registerProtocolHandler("magnet",`${q.A.baseURI}?action=add-urls&url=%s`)},children:(0,m.jsx)("em",{className:(0,y.AH)({fontSize:"0.8em"}),children:l._("torrents.add.tab.url.register.magnet.handler")})})]}),placeholder:l._("torrents.add.tab.url.input.placeholder"),defaultValues:"add-torrents"===_.A.activeModal?.id&&"by-url"===_.A.activeModal?.tab&&_.A.activeModal?.urls||[{id:0,value:""}]}),(0,m.jsx)(B,{id:"cookies",label:l._("torrents.add.cookies.label"),placeholder:l._("torrents.add.cookies.input.placeholder")}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(F,{id:"tags",label:l._("torrents.add.tags"),onTagSelected:e=>{if(null!=t.current){const s=h.A.floodSettings.torrentDestinations?.[e[0]];"string"==typeof s&&null!=t.current&&(t.current.value=s,t.current.dispatchEvent(new Event("input",{bubbles:!0})))}}})}),(0,m.jsx)($,{id:"destination",label:l._("torrents.add.destination.label"),ref:t,selectable:"directories",showBasePathToggle:!0,showCompletedToggle:!0,showSequentialToggle:!0}),(0,m.jsx)(g,{onAddTorrentsClick:()=>{if(null==e.current)return;const t=e.current.getFormData();i(!0);const s=E(t,"urls").filter(e=>""!==e);if(0===s.length||null==t.destination)return void i(!1);const l=E(t,"cookies"),n=s[0].startsWith("http")&&s[0].split("/")[2],r=n?{[n]:l}:void 0,a=null!=t.tags?t.tags.split(",").filter(e=>e.length>0):void 0;x.A.addTorrentsByUrls({urls:s,cookies:r,destination:t.destination,isBasePath:t.isBasePath,isCompleted:t.isCompleted,isSequential:t.isSequential,start:t.start,tags:a}).then(()=>{_.A.setActiveModal(null)}),u({start:t.start,destination:t.destination,tags:a,tab:"by-url"})},isAddingTorrents:s})]})},Z=({activeTabId:e,tabs:t={},onTabChange:s})=>(0,m.jsx)("ul",{className:"modal__tabs",children:Object.keys(t).map(i=>{const l=t[i];l.id=i;const n=L()("modal__tab",{"is-active":i===e});return(0,m.jsx)("li",{className:n,children:(0,m.jsx)("button",{className:(0,y.AH)({_focus:{outline:"none",WebkitTapHighlightColor:"transparent"},_focusVisible:{outline:"dashed"}}),type:"button",onClick:()=>{s&&s(l)},children:l.label})},i)})}),Q=({alignment:e="left",size:t="medium",orientation:s="horizontal",tabsInBody:i=!1,inverse:l=!0,initialTabId:r,className:a=null,content:d,heading:o,tabs:c,actions:h})=>{const u=L()("modal__content__wrapper",`modal--align-${e}`,`modal--size-${t}`,{"modal--horizontal":"horizontal"===s,"modal--vertical":"vertical"===s,"modal--tabs-in-header":!i,"modal--tabs-in-body":i,inverse:l},a);let x=d;const _=o,g=L()("modal__header",{"has-tabs":c});let f,p,b;const[v,y]=(0,n.useState)(r??Object.keys(c||{})[0]);if(c){const e=c[v],t=L()("modal__content",e.modalContentClasses),s=e.content,l=e.props,n=(0,m.jsx)(Z,{activeTabId:v,onTabChange:e=>{null!=e.id&&y(e.id)},tabs:c},"modal-tabs");i?f=n:b=n,x=[f,(0,m.jsx)("div",{className:t,children:(0,m.jsx)(s,{...l})},"modal-content")]}return h&&(p=(0,m.jsx)("div",{className:"modal__footer",children:(0,m.jsx)(j,{actions:h})})),(0,m.jsxs)("div",{className:u,children:[(0,m.jsxs)("div",{className:g,children:[_,b]}),(0,m.jsxs)("div",{className:"modal__body",children:[x,p]})]})},J=()=>{const{i18n:e}=(0,d.uB)(),t={"by-url":{content:G,label:e._("torrents.add.tab.url.title")},"by-file":{content:W,label:e._("torrents.add.tab.file.title")},"by-creation":{content:O,label:e._("torrents.add.tab.create.title")}};return"add-torrents"!==_.A.activeModal?.id?null:(0,m.jsx)(Q,{heading:e._("torrents.add.heading"),tabs:t,initialTabId:_.A.activeModal.tab??h.A.floodSettings.UITorrentsAddTab??"by-url"})},Y=(0,r.PA)(()=>{if("confirm"!==_.A.activeModal?.id)return null;const{actions:e,content:t,heading:s}=_.A.activeModal||{};return(0,m.jsx)(Q,{actions:e,content:(0,m.jsx)("div",{className:"modal__content",children:t}),heading:s})});var K=s(1083),X=s(7813);const ee=new class{feeds=[];rules=[];items=[];constructor(){(0,X.l_)(this)}setFeeds(e){this.feeds=null!=e?[...e].sort((e,t)=>e.label.localeCompare(t.label)):[]}setRules(e){this.rules=null!=e?[...e].sort((e,t)=>e.label.localeCompare(t.label)):[]}handleFeedMonitorsFetchSuccess(e){this.setFeeds(e.feeds),this.setRules(e.rules)}handleItemsFetchSuccess(e){this.items=e}},{baseURI:te}=q.A,se={addFeed:e=>K.A.put(`${te}api/feed-monitor/feeds`,e).then(()=>se.fetchFeedMonitors()),modifyFeed:(e,t)=>K.A.patch(`${te}api/feed-monitor/feeds/${e}`,t).then(()=>se.fetchFeedMonitors()),addRule:e=>K.A.put(`${te}api/feed-monitor/rules`,e).then(()=>se.fetchFeedMonitors()),fetchFeedMonitors:()=>K.A.get(`${te}api/feed-monitor`).then(({data:e})=>{ee.handleFeedMonitorsFetchSuccess(e)},()=>{}),fetchItems:({id:e,search:t})=>K.A.get(`${te}api/feed-monitor/feeds/${e}/items`,{params:{search:t}}).then(({data:e})=>{ee.handleItemsFetchSuccess(e)},()=>{}),removeFeedMonitor:e=>K.A.delete(`${te}api/feed-monitor/${e}`).then(()=>se.fetchFeedMonitors(),()=>{})},ie=se,le=/^(?:https?|ftp):\/\/.{1,}\.{1}.{1,}/,ne=e=>null!=e&&""!==e,re=e=>{try{new RegExp(e)}catch{return!1}return!0},ae=({rule:e,isSubmitting:t,isPatternMatched:s,onCancel:i})=>{const{feeds:l}=ee,{i18n:n}=(0,d.uB)();return(0,m.jsxs)(o.eW,{children:[(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{id:"label",label:n._("feeds.label"),defaultValue:e.label}),(0,m.jsx)(o.l6,{disabled:!l.length,id:"feedID",label:n._("feeds.applicable.feed"),defaultID:e.feedIDs?.[0],children:0===l.length?[(0,m.jsx)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,m.jsx)("em",{children:(0,m.jsx)(d.x6,{id:"feeds.no.feeds.available"})})},"empty")]:l.reduce((e,t)=>e.concat((0,m.jsx)(o.eb,{id:`${t._id}`,children:t.label},t._id)),[(0,m.jsx)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,m.jsx)("em",{children:(0,m.jsx)(d.x6,{id:"feeds.select.feed"})})},"select-feed")])})]}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{id:"match",label:n._("feeds.match.pattern"),placeholder:n._("feeds.regEx"),defaultValue:e.match,width:"three-eighths"}),(0,m.jsx)(o.Rj,{id:"exclude",label:n._("feeds.exclude.pattern"),placeholder:n._("feeds.regEx"),defaultValue:e.exclude,width:"three-eighths"})]}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{addonPlacement:"after",id:"check",label:n._("feeds.test.match"),placeholder:n._("feeds.check"),children:s&&(0,m.jsx)(o.t0,{children:(0,m.jsx)(v.H4,{})})})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.ci,{children:(0,m.jsx)($,{id:"destination",label:n._("feeds.torrent.destination"),selectable:"directories",suggested:e.destination,showBasePathToggle:!0})}),(0,m.jsx)(F,{id:"tags",label:n._("feeds.apply.tags"),placeholder:n._("feeds.tags"),defaultValue:e.tags})]}),(0,m.jsxs)(o.fh,{align:"end",justify:"end",children:[(0,m.jsx)("br",{}),(0,m.jsx)(o.Sc,{id:"startOnLoad",defaultChecked:e.startOnLoad,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"feeds.start.on.load"})}),(0,m.jsx)(o.$n,{onClick:i,children:(0,m.jsx)(d.x6,{id:"button.cancel"})}),(0,m.jsx)(o.$n,{type:"submit",isLoading:t,children:(0,m.jsx)(d.x6,{id:"button.save.feed"})})]})]})},de=({children:e})=>(0,m.jsx)("h2",{className:"h4",children:e}),oe=(0,r.PA)(({currentRule:e,onSelect:t,onRemove:s})=>{const{rules:i}=ee;return 0===i.length?(0,m.jsx)("ul",{className:"interactive-list",children:(0,m.jsx)("li",{className:"interactive-list__item",children:(0,m.jsx)(d.x6,{id:"feeds.no.rules.defined"})})}):(0,m.jsx)("ul",{className:"interactive-list",children:i.map(i=>{const l=i.count||0;let n=null,r=null;if(i.exclude&&(n=(0,m.jsxs)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",children:[(0,m.jsx)(d.x6,{id:"feeds.exclude"}),": ",i.exclude]})),i.tags&&i.tags.length>0){const e=i.tags.map(e=>(0,m.jsx)("span",{className:"tag",children:e},e));r=(0,m.jsxs)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",children:[(0,m.jsx)(d.x6,{id:"feeds.tags"}),": ",e]})}return(0,m.jsxs)("li",{className:"interactive-list__item interactive-list__item--stacked-content",children:[(0,m.jsxs)("div",{className:"interactive-list__label",children:[(0,m.jsxs)("ul",{className:"interactive-list__detail-list",children:[(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:i.label}),(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail-list__item--overflow interactive-list__detail interactive-list__detail--secondary",children:(0,m.jsx)(d.x6,{id:"feeds.match.count",values:{count:l}})}),i===e&&(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:"Modifying"})]}),(0,m.jsxs)("ul",{className:"interactive-list__detail-list",children:[(0,m.jsxs)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",style:{maxWidth:"50%",overflow:"hidden",textOverflow:"ellipsis"},children:[(0,m.jsx)(d.x6,{id:"feeds.match"}),": ",i.match]}),(0,m.jsx)("div",{style:{width:"100%"}}),n,r]})]}),(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action",type:"button",onClick:()=>t(i),children:(0,m.jsx)(v.ff,{})}),(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>s(i),children:(0,m.jsx)(v.bm,{})})]},i._id)})})}),ce={label:"",feedIDs:[],match:"",exclude:"",tags:[],destination:"",startOnLoad:!1},he={destination:{isValid:ne,error:"feeds.validation.must.specify.destination"},feedID:{isValid:e=>ne(e)&&"placeholder"!==e,error:"feeds.validation.must.select.feed"},label:{isValid:ne,error:"feeds.validation.must.specify.label"},match:{isValid:e=>ne(e)&&re(e),error:"feeds.validation.invalid.regular.expression"},exclude:{isValid:e=>!ne(e)||re(e),error:"feeds.validation.invalid.regular.expression"}},ue=(e,t)=>he[e]?.isValid(t)?void 0:he[e]?.error,xe=()=>{const e=(0,n.useRef)(null),{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(null),[l,r]=(0,n.useState)({}),[a,c]=(0,n.useState)(!1),[h,u]=(0,n.useState)(!1),[x,_]=(0,n.useState)(!1),[j,g]=(0,n.useState)(!1);return(0,m.jsxs)(o.lV,{className:"inverse",onChange:({event:e,formData:t})=>{const s=e.target.name,i=t;r({...l,[s]:ue(s,i[s])}),g((()=>{const{check:e,match:t="",exclude:s=""}=i;if(ne(e)&&re(t)&&re(s)){const i=new RegExp(t,"gi").test(e),l=""!==s&&new RegExp(s,"gi").test(e);return i&&!l}return!1})()),_(!0)},onSubmit:async()=>{if(null==e.current)return;const t=e.current.getFormData(),l=Object.keys(he).reduce((e,s)=>{const i=s;return{...e,[i]:ue(i,t[i])}},{});r(l);const n=Object.keys(l).every(e=>void 0===l[e]);x&&n&&(u(!0),null!=s?._id&&await ie.removeFeedMonitor(s._id),await ie.addRule({label:t.label??ce.label,feedIDs:[t.feedID??""],field:t.field,match:t.match??ce.match,exclude:t.exclude??ce.exclude,destination:t.destination??ce.destination,tags:t.tags?.split(",")??ce.tags,startOnLoad:t.startOnLoad??ce.startOnLoad,isBasePath:t.isBasePath??!1}).then(()=>{e.current?.resetForm(),r({}),i(null),c(!1)},()=>{r({backend:"general.error.unknown"})}),u(!1))},ref:e,children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"feeds.existing.rules"})}),Object.keys(l).reduce((e,s)=>(null!=l[s]&&e.push((0,m.jsx)(o.fh,{children:(0,m.jsx)(o.jQ,{children:t._(l?.[s])})},`error-${s}`)),e),[]),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.ci,{children:(0,m.jsx)(oe,{currentRule:s,onSelect:e=>{i(e),c(!0)},onRemove:e=>{null!=e._id&&ie.removeFeedMonitor(e._id),e===s&&(i(null),c(!1))}})})}),a?(0,m.jsx)(ae,{rule:s??ce,isPatternMatched:j,isSubmitting:h,onCancel:()=>{i(null),c(!1)}},s?._id||"initial"):(0,m.jsxs)(o.fh,{align:"end",justify:"end",children:[(0,m.jsx)("br",{}),(0,m.jsx)(o.$n,{onClick:()=>{c(!0)},children:(0,m.jsx)(d.x6,{id:"button.new"})})]})]})},_e=({currentFeed:e,defaultFeed:t,intervalMultipliers:s,isSubmitting:i,onCancel:l})=>{const{i18n:n}=(0,d.uB)(),r=e?.interval??t.interval;let a=r,c=1;return s.forEach(e=>{const t=e.value;r%t===0&&(a=r/t,c=t)}),(0,m.jsxs)(o.eW,{children:[(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{id:"label",label:n._("feeds.label"),placeholder:n._("feeds.label"),defaultValue:e?.label??t.label}),(0,m.jsx)(o.Rj,{id:"interval",label:n._("feeds.select.interval"),placeholder:n._("feeds.interval"),defaultValue:a,width:"one-eighth"}),(0,m.jsx)(o.l6,{labelOffset:!0,defaultID:c,id:"intervalMultiplier",width:"one-eighth",children:s.map(e=>(0,m.jsx)(o.eb,{id:e.value,children:n._(e.message)},e.value))})]}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{id:"url",label:n._("feeds.url"),placeholder:n._("feeds.url"),defaultValue:e?.url??t?.url}),(0,m.jsx)(o.$n,{labelOffset:!0,onClick:l,children:(0,m.jsx)(d.x6,{id:"button.cancel"})}),(0,m.jsx)(o.$n,{labelOffset:!0,type:"submit",isLoading:i,children:(0,m.jsx)(d.x6,{id:"button.save.feed"})})]})]})},me=(0,r.PA)(({selectedFeedID:e})=>{const{items:t}=ee,s=[];if(e){const e={};t.forEach((t,i)=>{let{title:l}=t;const n=e[l];null==n?e[l]=2:(l=`${l} #${n}`,e[l]+=1),s.push((0,m.jsxs)("li",{className:"interactive-list__item interactive-list__item--stacked-content feed-list__feed",children:[(0,m.jsx)("div",{className:"interactive-list__label feed-list__feed-label",children:l}),(0,m.jsx)(o.Sc,{id:`${i}`})]},l))})}return(0,m.jsx)(o.fh,{children:0===s.length?(0,m.jsx)("ul",{className:"interactive-list",children:(0,m.jsx)("li",{className:"interactive-list__item",children:(0,m.jsx)("div",{className:"interactive-list__label",children:(0,m.jsx)(d.x6,{id:"feeds.no.items.matching"})})})}):(0,m.jsx)("ul",{className:"interactive-list feed-list",children:s})})}),je=(0,r.PA)(()=>{const{i18n:e}=(0,d.uB)(),t=(0,n.useRef)(null),[s,i]=(0,n.useState)(null),{feeds:l}=ee;return null!=s&&(l.some(e=>e._id===s)||i(null)),(0,m.jsxs)(o.lV,{className:"inverse",onChange:({event:e,formData:t})=>{const s=t;"checkbox"!==e.target.type&&(i(s.feedID),ie.fetchItems({id:s.feedID,search:s.search}))},onSubmit:()=>{if(null==t.current)return;const e=t.current.getFormData(),s=ee.items.filter((t,s)=>e[s]).map((e,t)=>({id:t,value:e.urls[0]}));_.A.setActiveModal({id:"add-torrents",tab:"by-url",urls:s})},ref:t,children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"feeds.browse.feeds"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.l6,{disabled:!l.length,grow:!1,id:"feedID",label:e._("feeds.select.feed"),width:"three-eighths",children:l.length?l.reduce((e,t)=>null==t._id?e:e.concat((0,m.jsx)(o.eb,{id:t._id,children:t.label},t._id)),[(0,m.jsx)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,m.jsx)("em",{children:(0,m.jsx)(d.x6,{id:"feeds.select.feed"})})},"select-feed")]):[(0,m.jsx)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,m.jsx)("em",{children:(0,m.jsx)(d.x6,{id:"feeds.no.feeds.available"})})},"empty")]}),s&&(0,m.jsx)(o.Rj,{id:"search",label:e._("feeds.search.term"),placeholder:e._("feeds.search")}),s&&(0,m.jsx)(o.$n,{type:"submit",labelOffset:!0,children:(0,m.jsx)(d.x6,{id:"button.download"})},"button")]}),s&&(0,m.jsx)(me,{selectedFeedID:s})]})}),ge=(0,r.PA)(({currentFeed:e,intervalMultipliers:t,onSelect:s,onRemove:i})=>{const{feeds:l}=ee,{i18n:n}=(0,d.uB)();return 0===l.length?(0,m.jsx)("ul",{className:"interactive-list",children:(0,m.jsx)("li",{className:"interactive-list__item",children:(0,m.jsx)(d.x6,{id:"feeds.no.feeds.defined"})})}):(0,m.jsx)("ul",{className:"interactive-list feed-list",children:l.map(l=>{const r=l.count||0;let a=`${l.interval}`,o=t[0].message;return t.forEach(e=>{l.interval%e.value===0&&(a=""+l.interval/e.value,o=e.message)}),(0,m.jsxs)("li",{className:"interactive-list__item interactive-list__item--stacked-content feed-list__feed",children:[(0,m.jsxs)("div",{className:"interactive-list__label",children:[(0,m.jsxs)("ul",{className:"interactive-list__detail-list",children:[(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:l.label}),(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail-list__item--overflow interactive-list__detail interactive-list__detail--secondary",children:(0,m.jsx)(d.x6,{id:"feeds.match.count",values:{count:r}})}),l===e&&(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:"Modifying"})]}),(0,m.jsxs)("ul",{className:"interactive-list__detail-list",children:[(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",children:`${a} ${n._(o)}`}),(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail-list__item--overflow interactive-list__detail interactive-list__detail--tertiary",children:(0,m.jsx)("a",{href:l.url,rel:"noopener noreferrer",target:"_blank",children:l.url})})]})]}),(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action",type:"button",onClick:()=>s(l),children:(0,m.jsx)(v.ff,{})}),(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>i(l),children:(0,m.jsx)(v.bm,{})})]},l._id)})})}),fe={url:{isValid:e=>null!=e&&""!==e&&null!==e.match(le),error:"feeds.validation.must.specify.valid.feed.url"},label:{isValid:ne,error:"feeds.validation.must.specify.label"},interval:{isValid:e=>{if(null===e||""===e)return!1;const t=parseInt(`${e}`,10);return!Number.isNaN(t)&&t>0},error:"feeds.validation.interval.not.positive"}},pe=(e,t)=>fe[e]?.isValid(t)?void 0:fe[e]?.error,be=[{message:"feeds.time.min",value:1},{message:"feeds.time.hr",value:60},{message:"feeds.time.day",value:1440}],ve={label:"",interval:5,url:""},ye=()=>{const e=(0,n.useRef)(null),{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(null),[l,r]=(0,n.useState)({}),[a,c]=(0,n.useState)(!1),[h,u]=(0,n.useState)(!1);return(0,m.jsxs)("div",{children:[(0,m.jsxs)(o.lV,{className:"inverse",onChange:({event:e,formData:t})=>{const s=e.target.name,i=t;r({...l,[s]:pe(s,i[s])})},onSubmit:async()=>{const t=e.current?.getFormData();if(null==e.current||null==t)return;u(!0);const l=Object.keys(fe).reduce((e,s)=>{const i=s;return{...e,[i]:pe(i,t[i])}},{});r(l);if(Object.keys(l).every(e=>void 0===l[e])){const l={label:t.label,url:t.url,interval:Number(t.interval)*Number(t.intervalMultiplier)};let n=!0;try{null===s?await ie.addFeed(l):null!=s?._id&&await ie.modifyFeed(s._id,l)}catch{n=!1}n?(e.current.resetForm(),r({}),i(null),c(!1)):r({backend:"general.error.unknown"})}u(!1)},ref:e,children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"feeds.existing.feeds"})}),Object.keys(l).reduce((e,s)=>(null!=l[s]&&e.push((0,m.jsx)(o.fh,{children:(0,m.jsx)(o.jQ,{children:t._(l?.[s])})},`error-${s}`)),e),[]),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.ci,{children:(0,m.jsx)(ge,{currentFeed:s,intervalMultipliers:be,onSelect:e=>{i(e),c(!0)},onRemove:e=>{e===s&&(a&&(r({}),c(!1)),i(null)),null!=e._id&&ie.removeFeedMonitor(e._id)}})})}),a?(0,m.jsx)(_e,{currentFeed:s,defaultFeed:ve,intervalMultipliers:be,isSubmitting:h,onCancel:()=>{r({}),c(!1),i(null)}},s?._id||"initial"):(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.ci,{width:"auto"}),(0,m.jsx)(o.$n,{onClick:()=>{c(!0)},children:(0,m.jsx)(d.x6,{id:"button.new"})})]})]}),(0,m.jsx)(je,{})]})},ke=()=>{const{i18n:e}=(0,d.uB)();(0,n.useEffect)(()=>{ie.fetchFeedMonitors()},[]);const t={feeds:{content:ye,label:e._("feeds.tabs.feeds")},downloadRules:{content:xe,label:e._("feeds.tabs.download.rules")}};return(0,m.jsx)(Q,{heading:e._("feeds.tabs.heading"),orientation:"horizontal",size:"large",tabs:t})};var Ne=s(484);let Ae=function(e){return e[e.HTTP=1]="HTTP",e[e.UDP=2]="UDP",e[e.DHT=3]="DHT",e}({});const Se=(e,t)=>{let s=`magnet:?xt=urn:btih:${e}`;return t?.length&&t.forEach(e=>{s=`${s}&tr=${encodeURI(e)}`}),s},we=()=>{const e=(0,n.useRef)(null),t=(0,n.useRef)(null),{i18n:s}=(0,d.uB)(),[i,l]=(0,n.useState)(!1),[r,a]=(0,n.useState)(!1),[c,h]=(0,n.useState)({isLoadingTrackers:!0,magnetTrackersLink:""});(0,n.useEffect)(()=>{x.A.fetchTorrentTrackers(Ne.A.selectedTorrents[0]).then(e=>{null!=e&&h({isLoadingTrackers:!1,magnetTrackersLink:Se(Ne.A.selectedTorrents[0],e.filter(e=>e.type!==Ae.DHT).map(e=>e.url))})})},[]);const u=Se(Ne.A.selectedTorrents[0]);return(0,m.jsx)(Q,{heading:s._("torrents.generate.magnet.heading"),content:(0,m.jsx)("div",{className:"modal__content inverse",children:(0,m.jsxs)(o.lV,{children:[Ne.A.torrents[Ne.A.selectedTorrents[0]]?.isPrivate?(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.jQ,{children:s._("torrents.generate.magnet.private.torrent")})}):null,(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{id:"magnet",ref:e,addonPlacement:"after",label:s._("torrents.generate.magnet.magnet"),defaultValue:u,readOnly:!0,children:(0,m.jsx)(o.t0,{onClick:()=>{"function"==typeof navigator.clipboard?.writeText?navigator.clipboard.writeText(u).then(()=>{l(!0)}):null!=e.current&&(e.current?.select(),document.execCommand("copy"),l(!0))},children:i?(0,m.jsx)(v.H4,{}):(0,m.jsx)(v.B0,{})})})}),(0,m.jsx)(o.fh,{children:c.isLoadingTrackers?(0,m.jsx)(o.Rj,{id:"loading",label:s._("torrents.generate.magnet.magnet.with.trackers"),placeholder:s._("torrents.generate.magnet.loading.trackers"),disabled:!0}):(0,m.jsx)(o.Rj,{id:"magnet-trackers",ref:t,addonPlacement:"after",label:s._("torrents.generate.magnet.magnet.with.trackers"),defaultValue:c.magnetTrackersLink,readOnly:!0,children:(0,m.jsx)(o.t0,{onClick:()=>{"function"==typeof navigator.clipboard?.writeText?navigator.clipboard.writeText(c.magnetTrackersLink).then(()=>{a(!0)}):null!=t.current&&(t.current?.select(),document.execCommand("copy"),a(!0))},children:r?(0,m.jsx)(v.H4,{}):(0,m.jsx)(v.B0,{})})})})]})}),actions:[{clickHandler:null,content:s._("button.close"),triggerDismiss:!0,type:"tertiary"}]})},Ce=e=>{let t="";for(let s=0;s<e[0].length;s+=1)for(let i=1;i<e.length;i+=1)e[0][s]!==e[i][s]&&(t=e[0].slice(0,s));for(let e=t.length-1;e>=0;e-=1)if("/"===t[e])return t.slice(0,e+1)},Te=()=>{const{i18n:e}=(0,d.uB)(),[t,s]=(0,n.useState)(!1);return(0,m.jsx)(Q,{heading:e._("torrents.move.heading"),content:(0,m.jsx)("div",{className:"modal__content",children:(0,m.jsxs)(o.lV,{className:"inverse",onSubmit:({formData:e})=>{const t=Ne.A.selectedTorrents;t.length>0&&(s(!0),x.A.moveTorrents({hashes:t,destination:e.destination,isBasePath:e.isBasePath,moveFiles:e.moveFiles,isCheckHash:e.isCheckHash}).then(()=>{_.A.setActiveModal(null),s(!1)}))},children:[(0,m.jsx)($,{id:"destination",selectable:"directories",suggested:Ce(Ne.A.selectedTorrents.map(e=>Ne.A.torrents[e].directory)),showBasePathToggle:!0}),(0,m.jsx)(j,{actions:[{checked:!0,content:e._("torrents.move.data.label"),id:"moveFiles",type:"checkbox"},{checked:!1,content:e._("torrents.move.check_hash.label"),id:"isCheckHash",type:"checkbox"},{content:e._("button.cancel"),triggerDismiss:!0,type:"tertiary"},{content:e._("torrents.move.button.set.location"),isLoading:t,submit:!0,type:"primary"}]})]})})})},Re=()=>{const{i18n:e}=(0,d.uB)(),[t,s]=(0,n.useState)(!1),{selectedTorrents:i}=Ne.A;return 0===i.length?(0,m.jsx)(Q,{heading:e._("torrents.remove"),content:(0,m.jsx)("div",{className:"modal__content inverse",children:(0,m.jsx)(o.lV,{children:(0,m.jsx)(o.fh,{children:(0,m.jsx)(d.x6,{id:"torrents.remove.error.no.torrents.selected"})})})}),actions:[{clickHandler:null,content:e._("button.ok"),triggerDismiss:!0,type:"primary"}]}):(0,m.jsx)(Q,{heading:e._("torrents.remove"),content:(0,m.jsx)("div",{className:"modal__content",children:(0,m.jsxs)(o.lV,{className:"inverse",onSubmit:({formData:e})=>{s(!0);const t=e.deleteData;x.A.deleteTorrents({hashes:Ne.A.selectedTorrents,deleteData:t}).then(()=>{s(!1),(({deleteData:e})=>{null!=e&&c.A.saveSetting("deleteTorrentData",e)})({deleteData:t}),_.A.setActiveModal(null)})},children:[(0,m.jsx)(o.fh,{children:(0,m.jsx)(d.x6,{id:"torrents.remove.are.you.sure",values:{count:i.length}})}),(0,m.jsx)(j,{actions:[{checked:h.A.floodSettings.deleteTorrentData,content:e._("torrents.remove.delete.data"),id:"deleteData",type:"checkbox"},{content:e._("button.no"),triggerDismiss:!0,type:"tertiary"},{content:e._("button.yes"),isLoading:t,submit:!0,type:"primary"}]})]})})})},De=()=>{const e=(0,n.useRef)(null),{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(!1);return(0,m.jsx)(Q,{heading:t._("torrents.set.tags.heading"),content:(0,m.jsx)("div",{className:"modal__content inverse",children:(0,m.jsx)(o.lV,{ref:e,children:(0,m.jsx)(o.fh,{children:(0,m.jsx)(F,{defaultValue:Ne.A.selectedTorrents.map(e=>Ne.A.torrents[e].tags)[0].slice(),id:"tags",placeholder:t._("torrents.set.tags.enter.tags")})})})}),actions:[{content:t._("button.cancel"),clickHandler:null,triggerDismiss:!0,type:"tertiary"},{content:t._("torrents.set.tags.button.set"),clickHandler:()=>{if(null==e.current)return;const{selectedTorrents:t}=Ne.A,s=e.current.getFormData(),l=s.tags?s.tags.split(",").filter(e=>!!e):[];i(!0),t?.length>0&&x.A.setTags({hashes:t,tags:l})},isLoading:s,triggerDismiss:!1,type:"primary"}]})},Me=()=>{const e=(0,n.useRef)(null),{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(!1),[l,r]=(0,n.useState)({isLoadingTrackers:!0,trackerURLs:[]});return(0,n.useEffect)(()=>{x.A.fetchTorrentTrackers(Ne.A.selectedTorrents[0]).then(e=>{null!=e&&r({isLoadingTrackers:!1,trackerURLs:e.filter(e=>e.type!==Ae.DHT).map(e=>e.url)})})},[]),(0,m.jsx)(Q,{heading:t._("torrents.set.trackers.heading"),content:(0,m.jsx)("div",{className:"modal__content inverse",children:(0,m.jsx)(o.lV,{ref:e,children:l.isLoadingTrackers?(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{id:"loading",placeholder:t._("torrents.set.trackers.loading.trackers"),disabled:!0})}):(0,m.jsx)(B,{id:"trackers",placeholder:t._("torrents.set.trackers.enter.tracker"),defaultValues:0===l.trackerURLs.length?void 0:l.trackerURLs.map((e,t)=>({id:t,value:e}))})})}),actions:[{clickHandler:null,content:t._("button.cancel"),triggerDismiss:!0,type:"tertiary"},{clickHandler:()=>{if(null==e.current||s||l.isLoadingTrackers)return;i(!0);const t=e.current.getFormData(),n=E(t,"trackers").filter(e=>""!==e);x.A.setTrackers({hashes:Ne.A.selectedTorrents,trackers:n}).then(()=>{i(!1),_.A.setActiveModal(null)})},content:t._("torrents.set.trackers.button.set"),isLoading:s||l.isLoadingTrackers,triggerDismiss:!1,type:"primary"}]})};var Pe=s(8334);const Ie=JSON.parse('{"rE":"0.0.0-master.1d7ec6a"}'),$e="https://github.com/jesec/flood",Ve="# Flood <FloodVersion />\n\n[](https://www.npmjs.com/flood) <CommitBadge />\n\n[](https://github.com/jesec/flood/actions/workflows/build.yml) [](https://crowdin.com/project/flood) [](https://discord.gg/Z7yR5Uf)\n\nFlood is a monitoring service for various torrent clients. It's a Node.js service that communicates with your favorite torrent client and serves a decent web UI for administration. This project is based on the [original Flood project](https://github.com/Flood-UI/flood).\n\n#### Feedback\n\nIf you have a specific issue or bug, please file a [GitHub issue](https://github.com/jesec/flood/issues). Please join the [Flood Discord server](https://discord.gg/Z7yR5Uf) to discuss feature requests and implementation details.\n\n#### More Information\n\nCheck out the [Wiki](https://github.com/jesec/flood/wiki) for more information.\n".replaceAll("<FloodVersion />",Ie.rE).replaceAll("<CommitBadge />",Ie.rE.length>8?``:``),Le=()=>(0,m.jsx)(n.Suspense,{fallback:null,children:(0,m.jsx)(Pe.oz,{children:Ve})});var He=s(5767),Fe=s(7230),Ee=s(9119),Be=s(8045);const Oe=(0,r.PA)(()=>{const e=(0,n.useRef)(null),t=(0,n.useRef)(null),[s,r]=(0,n.useState)(null),[a,c]=(0,n.useState)(!1),[h,u]=(0,n.useState)(!1),{i18n:x}=(0,d.uB)();if((0,n.useEffect)(()=>{Fe.A.currentUser.isAdmin&&He.A.fetchUsers().then(()=>{c(!0)})},[]),!Fe.A.currentUser.isAdmin)return(0,m.jsxs)(o.lV,{children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"auth.user.accounts"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.jQ,{children:(0,m.jsx)(d.x6,{id:"auth.message.not.admin"})})})]});const _=!a&&0===Fe.A.users.length,j=L()("interactive-list",{"interactive-list--loading":_});return(0,m.jsxs)(o.lV,{onSubmit:()=>{if(null==e.current||null==t.current)return;const s=e.current.getFormData();if(null==s.username||""===s.username)r("auth.error.username.empty");else if(null==s.password||""===s.password)r("auth.error.password.empty");else{u(!0);const i=t.current;if(null==i)return r("connection.settings.error.empty"),void u(!1);He.A.createUser({username:s.username,password:s.password,client:i,level:!0===s.isAdmin?Ee.h.ADMINISTRATOR:Ee.h.USER}).then(()=>{null!=e.current&&e.current.resetForm(),r(null),u(!1)},()=>{r("general.error.unknown"),u(!1)}).then(He.A.fetchUsers)}},ref:e,children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"auth.user.accounts"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.ci,{children:(0,m.jsxs)("ul",{className:j,children:[(0,m.jsx)(l.A,{children:_&&(0,m.jsx)(i.A,{classNames:"interactive-list__loading-indicator",timeout:{enter:250,exit:250},children:(0,m.jsx)("div",{className:"interactive-list__loading-indicator",children:(0,m.jsx)(o.hg,{})},"loading-indicator")})}),Fe.A.users.slice().sort((e,t)=>e.username.localeCompare(t.username)).map(e=>{const t=e.username===Fe.A.currentUser.username;let s=null,i=null;t?s=(0,m.jsx)("span",{className:"interactive-list__label__tag tag",children:(0,m.jsx)(d.x6,{id:"auth.current.user"})}):i=(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>He.A.deleteUser(e.username).then(He.A.fetchUsers),children:(0,m.jsx)(v.bm,{})});const l=L()("interactive-list__item",{"interactive-list__item--disabled":t});return(0,m.jsxs)("li",{className:l,children:[(0,m.jsxs)("span",{className:"interactive-list__label",children:[(0,m.jsx)("div",{className:"interactive-list__label__text",children:e.username}),s]}),i]},e.username)})]})})}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"auth.add.user"})}),s&&(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.jQ,{children:x._(s)})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{id:"username",label:(0,m.jsx)(d.x6,{id:"auth.username"}),placeholder:x._("auth.username"),autoComplete:"username"}),(0,m.jsx)(o.Rj,{id:"password",label:(0,m.jsx)(d.x6,{id:"auth.password"}),placeholder:x._("auth.password"),autoComplete:"new-password"}),(0,m.jsx)(o.Sc,{grow:!1,id:"isAdmin",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"auth.admin"})})]}),(0,m.jsx)(Be.A,{onSettingsChange:e=>{t.current=e}}),(0,m.jsx)("p",{}),(0,m.jsx)(o.fh,{justify:"end",children:(0,m.jsx)(o.$n,{isLoading:h,priority:"primary",type:"submit",children:(0,m.jsx)(d.x6,{id:"button.add"})})})]})}),Ue=(e,t)=>null!=e[t]?e[t]:h.A.clientSettings?.[t],ze=e=>{const t=e.target,s=t.name,{value:i,type:l,checked:n}=t;let r={};return r="checkbox"===l?{[s]:n}:{[s]:i},r},We=e=>{if(e&&0!==e.length)return e.join(", ")},qe=(e="")=>""===e?[]:e.replace(/\s/g,"").split(",").map(e=>Number(e)),Ge=({onSettingsChange:e,onClientSettingsChange:t})=>{const[s,i]=(0,n.useState)({});return(0,m.jsxs)(o.lV,{onChange:({event:l,formData:n})=>{const r=l.target;if("dropdownPresetDownload"===r.name||"dropdownPresetUpload"===r.name)return void e({speedLimits:{download:qe(n.dropdownPresetDownload),upload:qe(n.dropdownPresetUpload)}});const a={...s,...ze(l)};i(a),t(a)},children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.bandwidth.transferrate.heading"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{defaultValue:null!=h.A.floodSettings.speedLimits?We(h.A.floodSettings.speedLimits.download):0,label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.transferrate.dropdown.preset.download.label"}),id:"dropdownPresetDownload"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{defaultValue:null!=h.A.floodSettings.speedLimits?We(h.A.floodSettings.speedLimits.upload):0,label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.transferrate.dropdown.preset.upload.label"}),id:"dropdownPresetUpload"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleGlobalDownSpeed"),label:(0,m.jsxs)("div",{children:[(0,m.jsx)(d.x6,{id:"settings.bandwidth.transferrate.global.throttle.download"})," ",(0,m.jsx)("em",{className:"unit",children:"(B/s)"})]}),id:"throttleGlobalDownSpeed"}),(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleGlobalUpSpeed"),label:(0,m.jsxs)("div",{children:[(0,m.jsx)(d.x6,{id:"settings.bandwidth.transferrate.global.throttle.upload"})," ",(0,m.jsx)("em",{className:"unit",children:"(B/s)"})]}),id:"throttleGlobalUpSpeed"})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.bandwidth.slots.heading"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleMaxUploads"),label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.slots.upload.label"}),id:"throttleMaxUploads"}),(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleMaxUploadsGlobal"),label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.slots.upload.global.label"}),id:"throttleMaxUploadsGlobal"})]}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleMaxDownloads"),label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.slots.download.label"}),id:"throttleMaxDownloads"}),(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleMaxDownloadsGlobal"),label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.slots.download.global.label"}),id:"throttleMaxDownloadsGlobal"})]})]})},Ze=({onClientSettingsChange:e})=>{const[t,s]=(0,n.useState)({});return(0,m.jsxs)(o.lV,{onChange:({event:i})=>{const l={...t,...ze(i)};s(l),e(l)},children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.connectivity.incoming.heading"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"networkPortRange"),id:"networkPortRange",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.port.range.label"}),width:"one-quarter"}),(0,m.jsx)(o.Sc,{defaultChecked:Ue(t,"networkPortRandom"),grow:!1,id:"networkPortRandom",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"settings.connectivity.port.randomize.label"})}),(0,m.jsx)(o.Sc,{defaultChecked:Ue(t,"networkPortOpen"),grow:!1,id:"networkPortOpen",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"settings.connectivity.port.open.label"})})]}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"networkLocalAddress"),id:"networkLocalAddress",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.ip.hostname.label"})}),(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"networkHttpMaxOpen"),id:"networkHttpMaxOpen",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.max.http.connections"})})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.connectivity.dpd.heading"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"dhtPort"),id:"dhtPort",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.dht.port.label"}),width:"one-quarter"}),(0,m.jsx)(o.Sc,{defaultChecked:Ue(t,"dht"),grow:!1,id:"dht",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"settings.connectivity.dht.label"})}),(0,m.jsx)(o.Sc,{defaultChecked:Ue(t,"protocolPex"),grow:!1,id:"protocolPex",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"settings.connectivity.peer.exchange.label"})})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.heading"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"throttleMinPeersNormal"),id:"throttleMinPeersNormal",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.min.label"})}),(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"throttleMaxPeersNormal"),id:"throttleMaxPeersNormal",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.max.label"})})]}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"throttleMinPeersSeed"),id:"throttleMinPeersSeed",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.seeding.min.label"})}),(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"throttleMaxPeersSeed"),id:"throttleMaxPeersSeed",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.seeding.max.label"})})]}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"trackersNumWant"),id:"trackersNumWant",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.desired.label"}),width:"one-half"})})]})};var Qe=s(8440),Je=s(6816),Ye=s(3627),Ke=s(3375),Xe=s(8831),et=s(4979);const tt=e=>{const{children:t,id:s,disabled:i}=e,{attributes:l,setNodeRef:n,listeners:r,transform:a,transition:d,isDragging:o}=(0,Ye.gl)({id:s,disabled:i}),c={transform:et.Ks.Transform.toString(a),transition:d};return(0,m.jsxs)("div",{className:L()("sortable-list__item",{"sortable-list__item--is-dragging":o,"sortable-list__item--is-locked":i}),ref:n,style:c,...l,...r,children:[i?(0,m.jsx)(v.LM,{}):null,t]})},st=({className:e,items:t,lockedIDs:s,renderItem:i,onMouseDown:l,onDrop:r})=>{const[a,d]=(0,n.useState)(t),o=L()("sortable-list",e),c=(0,Ke.MS)(Ke.uN),h=(0,Ke.MS)(Ke.cA,{activationConstraint:{distance:10}}),u=(0,Ke.MS)(Ke.IG,{activationConstraint:{distance:10}});return(0,m.jsx)("div",{className:(0,y.AH)({width:"100%",touchAction:"none"}),role:"none",onMouseDown:e=>{l&&l(e)},children:(0,m.jsx)(Ke.Mp,{sensors:[c,h,u],onDragEnd:({active:e,over:s})=>{if(null==s)return;if(e.id===s.id)return;const i=(0,Ye.be)(t,t.findIndex(t=>t===e.id),t.findIndex(e=>e===s.id));d(i),r&&r(i)},modifiers:[Xe.FN,Xe.gj],autoScroll:!1,children:(0,m.jsx)(Ye.gB,{items:a,strategy:Ye._G,children:(0,m.jsx)("ul",{className:o,children:a.map((e,t)=>(0,m.jsx)(tt,{id:e,disabled:s.includes(e),children:i(e,t)},e))})})})})},it=({onSettingsChange:e})=>{const[t,s]=(0,n.useState)((()=>{const{mountPoints:e}=h.A.floodSettings,t=Object.assign({},...Je.A.disks.map(e=>({[e.target]:e})));return e.filter(e=>e in t).map(e=>({id:e,visible:!0})).concat(Object.keys(t).filter(t=>!e.includes(t)).map(e=>({id:e,visible:!1})))})()),i=t.reduce((e,{id:t,visible:s})=>(e[t]=s,e),{});return(0,m.jsx)(st,{className:"sortable-list--disks",items:t.map(({id:e})=>e),lockedIDs:[],onDrop:e=>{s(e.map(e=>({id:e,visible:i[e]})))},renderItem:l=>{const n=(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--secondary",children:(0,m.jsx)(o.Sc,{defaultChecked:i[l],id:l,onClick:n=>{i[l]=n.target.checked;const r=t.map(e=>e.id===l?{...e,visible:n.target.checked}:e);e({mountPoints:r.filter(e=>e.visible).map(e=>e.id)}),s(r)},children:(0,m.jsx)(d.x6,{id:"settings.diskusage.show"})})});return(0,m.jsxs)("div",{className:"sortable-list__content sortable-list__content__wrapper",children:[(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--primary",children:(0,m.jsx)("div",{children:l})}),n]})}})},lt=({onSettingsChange:e})=>(0,m.jsxs)(o.lV,{children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.diskusage.mount.points"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(it,{onSettingsChange:e})})]}),nt=({onClientSettingsChange:e})=>{const[t,s]=(0,n.useState)({});return(0,m.jsxs)(o.lV,{onChange:({event:i})=>{const l={...t,...ze(i)};s(l),e(l)},children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.resources.disk.heading"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"directoryDefault"),id:"directoryDefault",label:(0,m.jsx)(d.x6,{id:"settings.resources.disk.download.location.label"})})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"networkMaxOpenFiles"),id:"networkMaxOpenFiles",label:(0,m.jsx)(d.x6,{id:"settings.resources.max.open.files"}),width:"one-half"}),(0,m.jsx)(o.Sc,{defaultChecked:Ue(t,"piecesHashOnCompletion"),grow:!1,id:"piecesHashOnCompletion",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"settings.resources.disk.check.hash.label"})})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.resources.memory.heading"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"piecesMemoryMax"),id:"piecesMemoryMax",label:(0,m.jsxs)("div",{children:[(0,m.jsx)(d.x6,{id:"settings.resources.memory.max.label"})," ",(0,m.jsx)("em",{className:"unit",children:"(MB)"})]}),width:"one-half"})})]})};var rt=s(4455);const at=({className:e,checkboxLabel:t,items:s})=>(0,m.jsx)("div",{className:(0,y.AH)({width:"100%"}),role:"none",children:(0,m.jsx)("ul",{className:L()("sortable-list",e,(0,y.AH)({"& .sortable-list__item":{cursor:"default"}})),children:s.map(e=>{const{id:s,label:i,isLocked:l=!1,defaultChecked:n,onClick:r}=e;return(0,m.jsxs)("li",{className:L()("sortable-list__item",{"sortable-list__item--is-locked":l}),children:[l?(0,m.jsx)(v.LM,{}):null,(0,m.jsxs)("div",{className:"sortable-list__content sortable-list__content__wrapper",children:[(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--primary",children:(0,m.jsx)(d.x6,{id:i})}),l?null:(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--secondary",children:(0,m.jsx)(o.Sc,{defaultChecked:n,id:s,onClick:e=>r?.(e.target.checked),children:t&&(0,m.jsx)(d.x6,{id:t})})})]})]},s||i)})})}),dt=({onSettingsChange:e})=>{const t=(0,n.useRef)(h.A.floodSettings.UIPageTitleSpeedEnabled);return(0,m.jsx)(at,{items:[{label:"settings.ui.page.title.speed",defaultChecked:t.current,onClick:()=>{t.current=!t.current,e({UIPageTitleSpeedEnabled:t.current})}}]})};var ot=s(1693),ct=s(3675);const ht=({onSettingsChange:e})=>{const t=(0,n.useRef)(ct.A.torrentContextMenuActions.map(({id:e,visible:t})=>({id:e,visible:h.A.floodSettings.torrentContextMenuActions.find(t=>t.id===e)?.visible??t})));return(0,m.jsx)(at,{checkboxLabel:"settings.ui.torrent.context.menu.items.show",items:Object.keys(ot.A).map(s=>({label:ot.A[s],isLocked:"start"===s||"stop"===s||"setTaxonomy"===s||"torrentDetails"===s,defaultChecked:t.current.some(e=>e.id===s&&e.visible),onClick:()=>{const i=t.current.find(e=>e.id===s);null!=i&&(i.visible=!i.visible),e({torrentContextMenuActions:t.current})}}))})};var ut=s(2607),xt=s(2189);const _t=({torrentListViewSize:e,onSettingsChange:t})=>{const s=(0,n.useRef)(null),[i,l]=(0,n.useState)([...h.A.floodSettings.torrentListColumns.filter(e=>null!=ut.A[e.id]).slice(),...Object.keys(ut.A).filter(e=>h.A.floodSettings.torrentListColumns.every(t=>t.id!==e)).map(e=>({id:e,visible:!1}))]),r=i.reduce((e,{id:t,visible:s})=>(e[t]=s,e),{}),a="expanded"===e?["name","eta","downRate","percentComplete","downTotal","upRate"]:[];return(0,m.jsx)(st,{className:"sortable-list--torrent-details",items:i.map(({id:e})=>e),lockedIDs:a,onMouseDown:()=>{s.current?.dismissTooltip()},onDrop:e=>{const s=e.map(e=>({id:e,visible:r[e]}));t({torrentListColumns:s}),l(s)},renderItem:(n,c)=>{let h=null,u=null;if(a.includes(n)||(h=(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--secondary",children:(0,m.jsx)(o.Sc,{defaultChecked:r[n],id:n,onClick:e=>{r[n]=e.target.checked;const s=i.map(t=>({id:t.id,visible:t.id===n?e.target.checked:t.visible}));l(s),t({torrentListColumns:s})},children:(0,m.jsx)(d.x6,{id:"settings.ui.torrent.details.enabled"})})})),"tags"===n&&"expanded"===e&&c<i.length-1){const e=(0,m.jsx)(d.x6,{id:"settings.ui.torrent.details.tags.placement"});u=(0,m.jsx)(xt.A,{className:"tooltip tooltip--is-error",content:e,offset:-5,ref:s,width:200,wrapperClassName:"sortable-list__content sortable-list__content--secondary tooltip__wrapper",wrapText:!0,children:(0,m.jsx)(v.$D,{})})}return(0,m.jsxs)("div",{className:"sortable-list__content sortable-list__content__wrapper",children:[u,(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--primary",children:(0,m.jsx)(d.x6,{id:ut.A[n]})}),h]})}})},mt=({onSettingsChange:e})=>{const{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(h.A.floodSettings.torrentListViewSize),[l,r]=(0,n.useState)(h.A.floodSettings.language),[a,c]=(0,n.useState)(h.A.floodSettings.UITagSelectorMode);return(0,m.jsxs)(o.lV,{onChange:({event:t,formData:l})=>{const n=t.target;if("radio"===n.type&&(i(l["ui-torrent-size"]),c(l["ui-tag-selector-mode"]),e({torrentListViewSize:s,UITagSelectorMode:a})),"language"===n.name){const t=l.language;r(t),e({language:t})}},children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.language"})},"locale-header"),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.l6,{defaultID:l,id:"language",children:Object.keys(rt.A).map(e=>(0,m.jsx)(o.eb,{id:e,children:"auto"===e?t._(rt.A[e].id):rt.A[e]},e))})},"locale-selection"),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.tag.selector.mode"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.sx,{defaultChecked:"single"===a,groupID:"ui-tag-selector-mode",id:"single",width:"auto",children:(0,m.jsx)(d.x6,{id:"settings.ui.tag.selector.mode.single"})}),(0,m.jsx)(o.sx,{defaultChecked:"multi"===a,groupID:"ui-tag-selector-mode",id:"multi",width:"auto",children:(0,m.jsx)(d.x6,{id:"settings.ui.tag.selector.mode.multi"})})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.torrent.list"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.sx,{defaultChecked:"expanded"===s,groupID:"ui-torrent-size",id:"expanded",width:"auto",children:(0,m.jsx)(d.x6,{id:"settings.ui.torrent.size.expanded"})}),(0,m.jsx)(o.sx,{defaultChecked:"condensed"===s,groupID:"ui-torrent-size",id:"condensed",width:"auto",children:(0,m.jsx)(d.x6,{id:"settings.ui.torrent.size.condensed"})})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.displayed.details"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(_t,{torrentListViewSize:s,onSettingsChange:e})}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.displayed.context.menu.items"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(ht,{onSettingsChange:e})}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.misc"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(dt,{onSettingsChange:e})})]})},jt=(0,r.PA)(()=>{const{i18n:e}=(0,d.uB)(),[t,s]=(0,n.useState)({}),[i,l]=(0,n.useState)({}),[r,a]=(0,n.useState)(!1),o=e=>{s({...t,...e})},h=e=>{l({...i,...e})},u={bandwidth:{content:Ge,props:{onClientSettingsChange:o,onSettingsChange:h},label:e._("settings.tabs.bandwidth")},connectivity:{content:Ze,props:{onClientSettingsChange:o},label:e._("settings.tabs.connectivity")},resources:{content:nt,props:{onClientSettingsChange:o},label:e._("settings.tabs.resources")},..."none"!==q.A.authMethod?{authentication:{content:Oe,label:e._("settings.tabs.authentication")}}:{},ui:{content:mt,label:e._("settings.tabs.userinterface"),props:{onSettingsChange:h}},diskusage:{content:lt,label:e._("settings.tabs.diskusage"),props:{onSettingsChange:h}},about:{content:Le,label:e._("settings.tabs.about")}};return(0,m.jsx)(Q,{actions:[{clickHandler:null,content:e._("button.cancel"),triggerDismiss:!0,type:"tertiary"},{clickHandler:()=>{a(!0),Promise.all([c.A.saveSettings(i,{alert:!0}),Qe.A.saveSettings(t,{alert:!0})]).then(()=>{a(!1),_.A.setActiveModal(null)})},isLoading:r,content:e._("button.save"),triggerDismiss:!1,type:"primary"}],size:"large",heading:e._("settings.tabs.heading"),orientation:q.A.isSmallScreen?"horizontal":"vertical",tabs:u})}),gt=()=>{const{i18n:e}=(0,d.uB)(),t=(0,n.useRef)(K.A.CancelToken.source()),s=(0,n.useRef)(null),[i,l]=(0,n.useState)(null),[r,a]=(0,n.useState)(null),[c,h]=(0,n.useState)(!0),[u,j]=(0,n.useState)(!1);(0,n.useEffect)(()=>{const{current:e}=t;return"torrent-details"===_.A.activeModal?.id&&x.A.fetchMediainfo(_.A.activeModal?.hash,t.current.token).then(e=>{l(e.output),h(!1)},e=>{K.A.isCancel(e)||(a(e.response.data),h(!1))}),()=>{e.cancel()}},[]);let g="mediainfo.heading";return c?g="mediainfo.fetching":r&&(g="mediainfo.execError"),(0,m.jsxs)("div",{className:"torrent-details__section mediainfo modal__content--nested-scroll__content",children:[(0,m.jsxs)("div",{className:"mediainfo__toolbar",children:[(0,m.jsx)("div",{className:"mediainfo__toolbar__item",children:(0,m.jsx)("span",{className:"torrent-details__table__heading--tertiary",children:(0,m.jsx)(d.x6,{id:g})})}),i&&(0,m.jsx)(xt.A,{content:e._(u?"general.clipboard.copied":"general.clipboard.copy"),wrapperClassName:"tooltip__wrapper mediainfo__toolbar__item",children:(0,m.jsx)(o.$n,{priority:"tertiary",onClick:()=>{null!=i&&("function"==typeof navigator.clipboard?.writeText?navigator.clipboard.writeText(i).then(()=>{j(!0)}):null!=s.current&&(s.current.value=i,s.current.select(),document.execCommand("copy"),j(!0)))},children:u?(0,m.jsx)(v.MG,{}):(0,m.jsx)(v.B0,{})})})]}),(0,m.jsx)("input",{ref:s,style:{width:"0.1px",height:"1px",position:"absolute",right:0}}),r?(0,m.jsx)("pre",{className:"mediainfo__output mediainfo__output--error",children:r.message}):(0,m.jsx)("pre",{className:"mediainfo__output",children:i})]})},ft=(e,t)=>({...e,...null!=e.directories?{directories:Object.assign({},...Object.keys(e.directories).map(s=>null!=e.directories?{[s]:ft(e.directories[s],t)}:{}))}:{},...null!=e.files?{files:Object.assign({},...Object.keys(e.files).map(s=>null!=e.files?{[s]:{...e.files[s],isSelected:t}}:{}))}:{},isSelected:t}),pt=(e,t,s=0)=>{const{depth:i,path:l,select:n,type:r}=t,a=l[s];if(s===i-1){if("file"===r&&null!=e.files?.[a]){const t={...e.files,[a]:{...e.files[a],isSelected:n}};return{...e,files:t,isSelected:Object.values(t).every(({isSelected:e})=>e)&&(null==e.directories||Object.values(e.directories).every(({isSelected:e})=>e))}}if("directory"===r&&null!=e.directories){const t={...e.directories,[a]:ft(e.directories[a],n)};return{...e,directories:t,isSelected:Object.values(t).every(({isSelected:e})=>e)&&(null==e.files||Object.values(e.files).every(({isSelected:e})=>e))}}return e}if(null!=e.directories){const i=e.directories;return Object.keys(i).forEach(e=>{e===a&&(i[e]=pt(i[e],t,s+1))}),{...e,directories:i,isSelected:Object.values(i).every(({isSelected:e})=>e)}}return e},bt=e=>{const t=[];if(null!=e.files){const{files:s}=e;Object.keys(s).forEach(e=>{const i=s[e];i.isSelected&&t.push(i.index)})}if(null!=e.directories){const{directories:s}=e;Object.keys(s).forEach(e=>{t.push(...bt(s[e]))})}return t},vt={selectAll:ft,applySelection:pt,getSelectedItems:bt,getSelectionTree:(e,t=!1)=>{const s={isSelected:t};return e.forEach(e=>{const i=e.path.split("/");let l=s;for(;i.length-1;){const e=i.shift();null==l.directories&&(l.directories={}),null==l.directories[e]&&(l.directories[e]={isSelected:t}),l=l.directories[e]}null==l.files&&(l.files={}),l.files[e.filename]={...e,isSelected:t}}),s}};var yt=s(9689),kt=s(7189);const Nt=({depth:e,items:t,hash:s,path:i,onItemSelect:l})=>{const[r,a]=(0,n.useState)(null),d=(0,n.useRef)({});if(null==t)return null;const c=Object.values(t).sort((e,t)=>e.filename.localeCompare(t.filename)).map(n=>{const c=t&&t[n.filename]&&t[n.filename].isSelected||!1,h=L()("directory-tree__node file","directory-tree__node--file directory-tree__node--selectable",{"directory-tree__node--selected":c});return(0,m.jsxs)("div",{className:h,title:n.filename,children:[(0,m.jsxs)("div",{className:"file__label file__detail",children:[(0,m.jsxs)("div",{className:"file__checkbox directory-tree__checkbox",children:[(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--checkbox",children:(0,m.jsx)(o.Sc,{checked:c,id:`${n.index}`,onClick:()=>l({type:"file",depth:e,path:[...i,n.filename],select:!c})})}),(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--icon",children:(0,m.jsx)(v.ZH,{})})]}),(0,m.jsx)("div",{className:"file__name",children:(0,m.jsx)("a",{href:`${q.A.baseURI}api/torrents/${s}/contents/${n.index}/data`,style:{textDecoration:"none"},target:"_blank",rel:"noreferrer",children:n.filename})})]}),(0,m.jsx)("div",{className:"file__detail file__detail--secondary",children:(0,m.jsx)(kt.A,{value:n.sizeBytes,precision:1})}),(0,m.jsxs)("div",{className:"file__detail file__detail--secondary",children:[Math.trunc(n.percentComplete),"%"]}),(0,m.jsx)("div",{className:"file__detail file__detail--secondary file__detail--priority",children:(0,m.jsx)(yt.A,{level:n.priority,id:n.index,maxLevel:2,onChange:(e,t)=>x.A.setFilePriority(s,{indices:[Number(e)],priority:t}),priorityType:"file"},`${n.index}-${n.filename}`)}),"function"==typeof navigator.clipboard?.writeText&&(0,m.jsx)("button",{className:"file__detail file__detail--secondary file__detail--clipboard",type:"button",onClick:()=>{const e=e=>{""!==e&&("function"==typeof navigator.share?navigator.share({title:n.filename,url:e}).then(()=>a(n.index)):navigator.clipboard.writeText(e).then(()=>a(n.index)))},t=d.current[n.index];null!=t?e(t):(d.current[n.index]="",x.A.getTorrentContentsDataPermalink(s,[n.index]).then(t=>{d.current[n.index]=t,e(t)},()=>{d.current[n.index]=null}))},children:r===n.index?(0,m.jsx)(v.MG,{}):(0,m.jsx)(v.B0,{})})]},n.filename)});return(0,m.jsx)("div",{className:"directory-tree__node directory-tree__node--file-list",children:c})},At=({depth:e,directoryName:t,id:s,itemsTree:i,hash:l,path:r,isSelected:a,onItemSelect:d})=>{const[c,h]=(0,n.useState)(!1),u=[...r,t];return(0,m.jsxs)("div",{className:L()("directory-tree__branch",`directory-tree__branch--depth-${e}`,{"directory-tree__node--selected":a}),children:[(0,m.jsx)("button",{className:L()("directory-tree__node","directory-tree__node--selectable directory-tree__node--directory",(0,y.AH)({width:"100%",textAlign:"left",_focus:{outline:"none",WebkitTapHighlightColor:"transparent"},_focusVisible:{outline:"dashed"}}),{"is-expanded":c}),type:"button",onClick:()=>h(!c),title:t,children:(0,m.jsxs)("div",{className:"file__label",children:[(0,m.jsxs)("div",{className:"file__checkbox directory-tree__checkbox",children:[(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--checkbox",children:(0,m.jsx)(o.Sc,{checked:a,id:s,onClick:()=>d({type:"directory",depth:e,path:u,select:!a})})}),(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--icon",children:c?(0,m.jsx)(v.gx,{}):(0,m.jsx)(v.Ah,{})})]}),(0,m.jsx)("div",{className:"file__name",children:t})]})}),c?(0,m.jsx)("div",{className:"directory-tree__node directory-tree__node--group",children:(0,m.jsx)(St,{depth:e,hash:l,onItemSelect:d,path:u,itemsTree:i},`${c}-${e}`)}):null]})},St=e=>{const{depth:t=0,itemsTree:s,hash:i,path:l,onItemSelect:n}=e,{files:r,directories:a}=s,d=t+1,o=null!=a?Object.keys(a).sort((e,t)=>e.localeCompare(t)).map((e,t)=>{const r=s.directories&&s.directories[e],a=`${t}${d}${e}`,o=r&&r.isSelected||!1;return null==r?null:(0,m.jsx)(At,{depth:d,directoryName:e,hash:i,id:a,isSelected:o,itemsTree:r,onItemSelect:n,path:l},a)}):[],c=null!=r&&Object.keys(r).length>0?(0,m.jsx)(Nt,{depth:d,hash:i,onItemSelect:n,path:l,items:s.files},`files-${d}`):null;return(0,m.jsx)("div",{className:"directory-tree__tree",children:o.concat(c)})},wt=(0,r.PA)(()=>{const[e,t]=(0,n.useState)([]),[s,i]=(0,n.useState)({}),[l,r]=(0,n.useState)([]),{i18n:a}=(0,d.uB)();if((0,n.useEffect)(()=>{"torrent-details"===_.A.activeModal?.id&&x.A.fetchTorrentContents(_.A.activeModal?.hash).then(e=>{null!=e&&(t(e),i(vt.getSelectionTree(e)))})},[]),"torrent-details"!==_.A.activeModal?.id)return null;const{hash:c}=_.A.activeModal;let h=null,u=null,j=!1;e?.length>0?(j=l.length>=e.length,h=(0,m.jsxs)("div",{className:"file__checkbox directory-tree__checkbox",children:[(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--checkbox",children:(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Sc,{checked:j,id:"select-all",onClick:()=>{const t=vt.getSelectionTree(e,l.length<e.length);i(t),r(vt.getSelectedItems(t))}})})}),(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--icon",children:(0,m.jsx)(v.my,{})})]}),u=(0,m.jsx)(St,{depth:0,onItemSelect:e=>{const t=vt.applySelection(s,e);i(t),r(vt.getSelectedItems(t))},hash:c,path:[],itemsTree:s})):(h=(0,m.jsx)(v.my,{}),u=(0,m.jsx)("div",{className:"directory-tree__node directory-tree__node--file",children:(0,m.jsx)(d.x6,{id:"torrents.details.files.loading"})}));const g=L()("directory-tree__node","directory-tree__parent-directory torrent-details__section__heading",{"directory-tree__node--selected":j}),f=(0,m.jsx)("div",{className:g,children:(0,m.jsxs)("div",{className:"file__label",children:[h,(0,m.jsx)("div",{className:"file__name",children:Ne.A.torrents?.[c].directory})]})}),p=L()("inverse directory-tree__wrapper",{"directory-tree__wrapper--toolbar-visible":l.length>0});return(0,m.jsxs)(o.lV,{className:p,onChange:({event:e})=>{if(null!=e.target&&"file-priority"===e.target.name){const t=e.target;t.value&&x.A.setFilePriority(c,{indices:l,priority:Number(t.value)})}},children:[(0,m.jsx)("div",{className:"directory-tree__selection-toolbar",children:(0,m.jsxs)(o.fh,{align:"center",children:[(0,m.jsx)(o.ci,{width:"one-quarter",grow:!1,shrink:!1,children:(0,m.jsx)(d.x6,{id:"torrents.details.selected.files",values:{count:l.length,countElement:(0,m.jsx)("span",{className:"directory-tree__selection-toolbar__item-count",children:l.length})}})}),(0,m.jsx)(o.$n,{onClick:e=>{e.preventDefault();const{baseURI:t}=q.A,s=document.createElement("a");s.download="",s.href=`${t}api/torrents/${c}/contents/${l.join(",")}/data`,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)},grow:!1,shrink:!1,children:(0,m.jsx)(d.x6,{id:"torrents.details.files.download.file",values:{count:l.length}})}),(0,m.jsxs)(o.l6,{id:"file-priority",persistentPlaceholder:!0,shrink:!1,defaultID:"",children:[(0,m.jsx)(o.eb,{id:-1,isPlaceholder:!0,children:(0,m.jsx)(d.x6,{id:"torrents.details.selected.files.set.priority"})}),(0,m.jsx)(o.eb,{id:0,children:a._("priority.dont.download")}),(0,m.jsx)(o.eb,{id:1,children:a._("priority.normal")}),(0,m.jsx)(o.eb,{id:2,children:a._("priority.high")})]})]})}),(0,m.jsxs)("div",{className:"directory-tree torrent-details__section torrent-details__section--file-tree modal__content--nested-scroll__content",children:[f,u]})]})}),Ct=wt;const Tt=({text:e,className:t})=>{const s=e.split(/([ \n])/).map((e,t)=>"\n"===e?(0,m.jsx)("br",{},t):function(e){let t;try{t=new URL(e)}catch{return!1}return"http:"===t.protocol||"https:"===t.protocol}(e)?(0,m.jsx)("a",{href:e.trimEnd(),target:"_blank",rel:"noopener noreferrer",children:e},t):e);return(0,m.jsx)("span",{className:t,children:s})},Rt=(0,r.PA)(()=>{const{i18n:e}=(0,d.uB)();if("torrent-details"!==_.A.activeModal?.id)return null;const t=Ne.A.torrents[_.A.activeModal.hash];if(null==t)return null;const s=(0,m.jsx)("span",{className:"not-available",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.none"})});return(0,m.jsx)("div",{className:"torrent-details__section torrent-details__section--general",children:(0,m.jsx)("table",{className:"torrent-details__table table",children:(0,m.jsxs)("tbody",{children:[(0,m.jsx)("tr",{className:"torrent-details__table__heading",children:(0,m.jsx)("td",{className:"torrent-details__table__heading--tertiary",colSpan:2,children:(0,m.jsx)(d.x6,{id:"torrents.details.general.heading.general"})})}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--dateAdded",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.date.added"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.dateAdded>0?e.date(new Date(1e3*t.dateAdded),{year:"numeric",month:"long",day:"2-digit",hour:"numeric",minute:"numeric"}):s})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--location",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.location"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.directory})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--tags",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.tags"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.tags.length?(i=t.tags,i.map(e=>(0,m.jsx)("span",{className:"tag",children:e},e))):s})]}),(0,m.jsx)("tr",{className:"torrent-details__table__heading",children:(0,m.jsx)("td",{className:"torrent-details__table__heading--tertiary",colSpan:2,children:(0,m.jsx)(d.x6,{id:"torrents.details.general.heading.transfer"})})}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--dateFinished",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.date.finished"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.dateFinished>0?e.date(new Date(1e3*t.dateFinished),{year:"numeric",month:"long",day:"2-digit",hour:"numeric",minute:"numeric"}):s})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--downloaded",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.downloaded"})}),(0,m.jsxs)("td",{className:"torrent-details__detail__value",children:[e.number(t.percentComplete),(0,m.jsx)("em",{className:"unit",children:"%"})]})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--peers",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.peers"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.connected",values:{connectedCount:t.peersConnected,connected:e.number(t.peersConnected),total:e.number(t.peersTotal)}})})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--seeds",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.seeds"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.connected",values:{connectedCount:t.seedsConnected,connected:e.number(t.seedsConnected),total:e.number(t.seedsTotal)}})})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--dateActive",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.date.active"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:0===t.dateActive?s:-1===t.dateActive?e._("torrents.details.general.date.active.now"):e.date(new Date(1e3*t.dateActive),{year:"numeric",month:"long",day:"2-digit",hour:"numeric",minute:"numeric"})})]}),(0,m.jsx)("tr",{className:"torrent-details__table__heading",children:(0,m.jsx)("td",{className:"torrent-details__table__heading--tertiary",colSpan:2,children:(0,m.jsx)(d.x6,{id:"torrents.details.general.heading.torrent"})})}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--created",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.date.created"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.dateCreated>0?e.date(new Date(1e3*t.dateCreated),{year:"numeric",month:"long",day:"2-digit",hour:"numeric",minute:"numeric"}):s})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--hash",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.hash"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.hash})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--size",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.size"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:(0,m.jsx)(kt.A,{value:t.sizeBytes})})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--type",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.type"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.isPrivate?e._("torrents.details.general.type.private"):e._("torrents.details.general.type.public")})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--comment",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.comment"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.comment?(0,m.jsx)(Tt,{text:t.comment.trim()}):s})]}),(0,m.jsx)("tr",{className:"torrent-details__table__heading",children:(0,m.jsx)("td",{className:"torrent-details__table__heading--tertiary",colSpan:2,children:(0,m.jsx)(d.x6,{id:"torrents.details.general.heading.tracker"})})}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--tracker-message",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.tracker.message"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.message?t.message:s})]})]})})});var i});var Dt=s(2471),Mt=s(3230),Pt=s(1915);const It=(0,r.PA)(()=>{const{i18n:e}=(0,d.uB)(),t="torrent-details"===_.A.activeModal?.id?Ne.A.torrents[_.A.activeModal.hash]:void 0,[s,i]=(0,n.useState)("stop");if((0,n.useEffect)(()=>{t?.status.includes("stopped")?i("stop"):i("start")},[t?.status]),null==t)return null;const l=(0,Dt.$)({status:t.status,upRate:t.upRate,downRate:t.downRate},"torrent-details__header");return(0,m.jsxs)("div",{className:l,children:[(0,m.jsx)("h1",{className:"torrent-details__heading torrent-details--name",children:t.name}),(0,m.jsxs)("div",{className:"torrent-details__sub-heading",children:[(0,m.jsxs)("ul",{className:"torrent-details__sub-heading__secondary",children:[(0,m.jsxs)("li",{className:"torrent-details__sub-heading__tertiary torrent-details__sub-heading__tertiary--download",children:[(0,m.jsx)(v.Cx,{}),(0,m.jsx)(kt.A,{value:t.downRate,isSpeed:!0})," — ",(0,m.jsx)(kt.A,{value:t.bytesDone})]}),(0,m.jsxs)("li",{className:"torrent-details__sub-heading__tertiary torrent-details__sub-heading__tertiary--upload",children:[(0,m.jsx)(v.NM,{}),(0,m.jsx)(kt.A,{value:t.upRate,isSpeed:!0})," — ",(0,m.jsx)(kt.A,{value:t.upTotal})]}),(0,m.jsxs)("li",{className:"torrent-details__sub-heading__tertiary",children:[(0,m.jsx)(v.wj,{}),e.number(t.ratio)]}),(0,m.jsxs)("li",{className:"torrent-details__sub-heading__tertiary",children:[(0,m.jsx)(v.zD,{}),(0,m.jsx)(Mt.A,{value:t.eta})]})]}),(0,m.jsxs)("ul",{className:"torrent-details__sub-heading__secondary",children:[(0,m.jsx)("li",{className:"torrent-details__sub-heading__tertiary",children:(0,m.jsx)(yt.A,{id:t.hash,level:t.priority,maxLevel:3,priorityType:"torrent",onChange:(e,t)=>{x.A.setPriority({hashes:[`${e}`],priority:t})}})},"priority-meter"),(0,m.jsx)("li",{className:"torrent-details__sub-heading__tertiary",children:(0,m.jsxs)("button",{className:L()("torrent-details__action",{"is-active":"start"===s}),type:"button",onClick:()=>{i("start"),x.A.startTorrents({hashes:[t.hash]})},children:[(0,m.jsx)(v.fe,{}),(0,m.jsx)(d.x6,{id:"torrents.details.actions.start"})]})},"start"),(0,m.jsx)("li",{className:"torrent-details__sub-heading__tertiary",children:(0,m.jsxs)("button",{className:L()("torrent-details__action",{"is-active":"stop"===s}),type:"button",onClick:()=>{i("stop"),x.A.stopTorrents({hashes:[t.hash]})},children:[(0,m.jsx)(v.VG,{}),(0,m.jsx)(d.x6,{id:"torrents.details.actions.stop"})]})},"stop")]})]}),(0,m.jsx)(Pt.A,{percent:(0,X.EW)(()=>Math.ceil(t.percentComplete)).get(),status:(0,X.EW)(()=>(0,Dt.s)(t.status)).get()})]})});var $t=s(940),Vt=s(6541);const Lt=()=>{const[e,t]=(0,n.useState)([]),[s,i]=(0,n.useState)(null),l=()=>{i(null),"torrent-details"===_.A.activeModal?.id&&x.A.fetchTorrentPeers(_.A.activeModal?.hash).then(e=>{null!=e&&t(e)}),i(q.A.pollInterval)};return(0,n.useEffect)(()=>l(),[]),(0,$t.A)(()=>l(),s),(0,m.jsx)("div",{className:"torrent-details__section torrent-details__section--peers",children:(0,m.jsxs)("table",{className:`torrent-details__table table ${(0,y.AH)({"& td":{maxWidth:"140px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}})}`,children:[(0,m.jsx)("thead",{className:"torrent-details__table__heading",children:(0,m.jsxs)("tr",{children:[(0,m.jsxs)("th",{className:"torrent-details__table__heading--primary",children:[(0,m.jsx)(d.x6,{id:"torrents.details.peers"}),(0,m.jsx)(Vt.A,{children:e.length})]}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"DL"}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"UL"}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"%"}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"Client"}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"Enc"}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"In"})]})}),(0,m.jsx)("tbody",{children:e.map(e=>{const{country:t}=e,s=e.isEncrypted?(0,m.jsx)(v.LM,{}):null,i=e.isIncoming?(0,m.jsx)(v.H4,{}):null;return(0,m.jsxs)("tr",{children:[(0,m.jsxs)("td",{children:[(0,m.jsxs)("span",{className:"peers-list__flag",children:[(0,m.jsx)(n.Suspense,{fallback:(0,m.jsx)(v.y$,{}),children:(0,m.jsx)(v.J9,{countryCode:t})}),(0,m.jsx)("span",{className:"peers-list__flag__text",children:t})]}),e.address]}),(0,m.jsx)("td",{children:(0,m.jsx)(kt.A,{value:e.downloadRate,isSpeed:!0})}),(0,m.jsx)("td",{children:(0,m.jsx)(kt.A,{value:e.uploadRate,isSpeed:!0})}),(0,m.jsx)("td",{children:`${Math.ceil(e.completedPercent)}%`}),(0,m.jsx)("td",{children:e.clientVersion}),(0,m.jsx)("td",{className:"peers-list__encryption",children:s}),(0,m.jsx)("td",{className:"peers-list__incoming",children:i})]},e.address)})})]})})},Ht=()=>{const[e,t]=(0,n.useState)([]),s=e.length,i=["http","udp","dht"],l=e.map(e=>(0,m.jsxs)("tr",{children:[(0,m.jsx)("td",{className:"torrent-details__trackers--url",children:e.url}),(0,m.jsx)("td",{children:i[e.type-1]})]},e.url));return(0,n.useEffect)(()=>{"torrent-details"===_.A.activeModal?.id&&x.A.fetchTorrentTrackers(_.A.activeModal?.hash).then(e=>{null!=e&&t(e)})},[]),(0,m.jsx)("div",{className:"torrent-details__trackers torrent-details__section",children:(0,m.jsxs)("table",{className:"torrent-details__table table",children:[(0,m.jsx)("thead",{className:"torrent-details__table__heading",children:(0,m.jsxs)("tr",{children:[(0,m.jsxs)("th",{className:"torrent-details__table__heading--primary",children:[(0,m.jsx)(d.x6,{id:"torrents.details.trackers"}),(0,m.jsx)(Vt.A,{children:s})]}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:(0,m.jsx)(d.x6,{id:"torrents.details.trackers.type"})})]})}),(0,m.jsx)("tbody",{children:l})]})})},Ft=(0,r.PA)(()=>{const{i18n:e}=(0,d.uB)(),{isSmallScreen:t}=q.A,s={"torrent-details":{content:Rt,label:e._("torrents.details.details")},"torrent-contents":{content:Ct,label:e._("torrents.details.files"),modalContentClasses:"modal__content--nested-scroll"},"torrent-peers":{content:Lt,label:e._("torrents.details.peers")},"torrent-trackers":{content:Ht,label:e._("torrents.details.trackers")},"torrent-mediainfo":{content:gt,label:e._("torrents.details.mediainfo"),modalContentClasses:"modal__content--nested-scroll"}};return(0,m.jsx)(Q,{heading:(0,m.jsx)(It,{},"torrent-heading"),size:"large",tabs:s,orientation:t?"horizontal":"vertical",tabsInBody:!t})}),Et=e=>{switch(e){case"add-torrents":return(0,m.jsx)(J,{});case"confirm":return(0,m.jsx)(Y,{});case"feeds":return(0,m.jsx)(ke,{});case"generate-magnet":return(0,m.jsx)(we,{});case"move-torrents":return(0,m.jsx)(Te,{});case"remove-torrents":return(0,m.jsx)(Re,{});case"set-taxonomy":return(0,m.jsx)(De,{});case"set-trackers":return(0,m.jsx)(Me,{});case"settings":return(0,m.jsx)(jt,{});case"torrent-details":return(0,m.jsx)(Ft,{});default:return null}},Bt=(0,r.PA)(()=>{const{id:e}=_.A.activeModal||{};let t;return(0,a.A)("Escape",()=>_.A.setActiveModal(null)),null!=e&&(t=(0,m.jsx)(i.A,{classNames:"modal__animation",timeout:{enter:500,exit:500},children:(0,m.jsxs)("div",{className:"modal",children:[(0,m.jsx)("div",{className:"modal__overlay",role:"none",onClick:()=>{_.A.setActiveModal(null)}}),Et(e)]})},e)),(0,m.jsx)(l.A,{children:t})})}}]);
|
|
1
|
+
"use strict";(globalThis.webpackChunk_jesec_flood=globalThis.webpackChunk_jesec_flood||[]).push([[179],{179:(e,t,s)=>{s.r(t),s.d(t,{default:()=>Bt});var i=s(6488),l=s(2618),n=s(6540),r=s(3443),a=s(9679),d=s(9161),o=s(6565),c=s(9075),h=s(2412);const u=({start:e,destination:t,tags:s,tab:i})=>{const l={};null!=e&&(l.startTorrentsOnLoad=e),null!=t&&""!==t&&(null==l.torrentDestinations&&(l.torrentDestinations=h.A.floodSettings.torrentDestinations||{}),"string"==typeof s?.[0]?l.torrentDestinations[s[0]]=t:l.torrentDestinations[""]=t),null!=i&&(l.UITorrentsAddTab=i),c.A.saveSettings(l)};var x=s(3537),_=s(4930),m=s(4848);const j=e=>{const{actions:t}=e,s=t.map((e,t)=>{let s=()=>{};return e.triggerDismiss&&(s=()=>{_.A.setActiveModal(null)}),"checkbox"===e.type?(0,m.jsx)(o.Sc,{defaultChecked:e.checked,id:e.id,onClick:t=>{null!=e.clickHandler&&e.clickHandler(t),s()},children:e.content},t):(0,m.jsx)(o.$n,{isLoading:e.isLoading,onClick:t=>{null!=e.clickHandler&&e.clickHandler(t),s()},priority:e.type,type:e.submit?"submit":"button",children:e.content},t)}),i=(0,m.jsx)("div",{className:"modal__button-group",children:s});return(0,m.jsx)("div",{className:"modal__actions",children:i})},g=({isAddingTorrents:e,onAddTorrentsClick:t})=>{const{i18n:s}=(0,d.uB)();return(0,m.jsx)(j,{actions:[{checked:Boolean(h.A.floodSettings.startTorrentsOnLoad),clickHandler:null,content:s._("torrents.add.start.label"),id:"start",triggerDismiss:!1,type:"checkbox"},{clickHandler:null,content:s._("button.cancel"),triggerDismiss:!0,type:"tertiary"},{clickHandler:t,content:s._("torrents.add.button.add"),isLoading:e,submit:!0,triggerDismiss:!1,type:"primary"}]})};var f=s(8221),p=s.n(f),b=s(5162),v=s(942),y=s(8344),k=s(9844),N=s(2114),A=s(8851),S=s(2592);const w=y.AH.raw({padding:"3px 9px"}),C=y.AH.raw({borderBottom:"1px solid #dde2e8",marginBottom:"3px",paddingBottom:"3px",opacity:.75,_last:{marginBottom:0}}),T=y.AH.raw({transition:"color 0.25s",whiteSpace:"nowrap","& button":{width:"100%",height:"100%",textAlign:"left",_disabled:{pointerEvents:"none"},...w}}),R=(0,y.AH)({opacity:.5,...T}),D=y.AH.raw({color:"#374c66",background:"rgba(94, 114, 140, 0.1)","& button:focus":{outline:"none",WebkitTapHighlightColor:"transparent"}}),M=(0,y.AH)({opacity:1,cursor:"pointer",transition:"background 0.25s, color 0.25s",userSelect:"none",_hover:D,_focusWithin:D,...T}),P={EACCES:"filesystem.error.eacces",ENOENT:"filesystem.error.enoent"},I=(0,n.memo)(({directory:e,selectable:t,onItemSelection:s,onYieldFocus:i})=>{const[l,r]=(0,n.useState)(null),[a,o]=(0,n.useState)(null),[c,h]=(0,n.useState)(e.includes("/")?"/":"\\"),[u,x]=(0,n.useState)(null),[_,j]=(0,n.useState)(null),g=(0,n.useRef)(null),f=e.lastIndexOf(c)+1,p=f>0?e.substr(0,f):e,b=e.substr(f);(0,n.useEffect)(()=>{p&&(r(null),x(null),j(null),A.A.fetchDirectoryList(p).then(({files:e,directories:t,separator:s})=>{x(t),j(e),h(s),o(null)}).catch(({response:e})=>{o(e)}))},[p]),(0,n.useEffect)(()=>{if(null!=g.current&&null!=l){const e=g.current.children[l]?.children[0];0===e?.tabIndex?e.focus():r(Array.from(g.current.children).findIndex(e=>0===e.children[0].tabIndex))}},[l]),(0,N.A)("ArrowUp",e=>{e.preventDefault(),r(e=>null==e||e-1<0?(i?.(),null):e-1)}),(0,N.A)("ArrowDown",e=>{e.preventDefault(),r(e=>null!=e?e+1:0)});let T=null,D=[];if((null==u&&"directories"===t||null==_&&"files"===t)&&(T="filesystem.fetching"),a&&a.data&&a.data.code&&(T=P[a.data.code]||"filesystem.error.unknown"),e){const e=`${p.split(c).slice(0,-2).join(c)}${c}`,i=(0,m.jsx)("li",{className:`${M} ${(0,y.AH)({"@media (max-width: 720px)":C})}`,children:(0,m.jsxs)("button",{type:"button",onClick:()=>s?.(e,!0),children:[(0,m.jsx)(v.i3,{className:(0,y.AH)({transform:"scale(0.75) rotate(180deg)"})}),".."]})},e),l="files"!==t,n=b?(0,S.A)(u,e=>e,b):[],r=n.includes(b)||"directories"!==t||!b||T?[]:(()=>{const e=`${p}${b}${c}`;return[(0,m.jsx)("li",{className:`${M} ${(0,y.AH)({"@media (max-width: 720px)":{display:"none"}})}`,style:{fontWeight:"bold"},children:(0,m.jsxs)("button",{type:"button",onClick:()=>s?.(e,!1),children:[(0,m.jsx)(v.N7,{}),(0,m.jsx)("span",{style:{whiteSpace:"pre-wrap"},children:b}),(0,m.jsxs)("em",{style:{fontWeight:"lighter"},children:[" - ",(0,m.jsx)(d.x6,{id:"filesystem.error.enoent"})]})]})},e)]})(),a=u?.length&&(0,k.di)(u.slice()).desc(e=>n.includes(e)).map(e=>{const t=`${p}${e}${c}`;return(0,m.jsx)("li",{className:l?M:R,style:n.includes(e)?{fontWeight:"bold"}:void 0,children:(0,m.jsxs)("button",{type:"button",disabled:!l,tabIndex:l?0:-1,onClick:l?()=>s?.(t,!0):void 0,children:[(0,m.jsx)(v.Ah,{}),e]})},t)})||[],o="directories"!==t,h=b?(0,S.A)(_,e=>e,b):[],x=_?.length&&(0,k.di)(_.slice()).desc(e=>h.includes(e)).map(e=>{const t=`${p}${e}`;return(0,m.jsx)("li",{className:o?M:R,style:h.includes(e)?{fontWeight:"bold"}:void 0,children:(0,m.jsxs)("button",{type:"button",disabled:!o,tabIndex:o?0:-1,onClick:o?()=>s?.(t,!1):void 0,children:[(0,m.jsx)(v.ZH,{}),e]})},t)})||[];0!==a.length||0!==x.length||T||(T="filesystem.empty.directory"),D=[i,...r,...a,...x]}else T="filesystem.error.no.input";return(0,m.jsxs)("div",{className:(0,y.AH)({color:"#5E728C",listStyle:"none",padding:"3px 0px","& .icon":{fill:"currentColor",height:"14px",width:"14px",marginRight:"5px",marginTop:"-3px",verticalAlign:"middle"}}),children:[p&&(0,m.jsxs)("li",{className:`${R} ${(0,y.AH)(C,w,{whiteSpace:"pre-wrap",wordBreak:"break-all","& .icon":{transform:"scale(0.9)",marginTop:"-2px !important"},"@media (max-width: 720px)":{display:"none"}})}`,children:[(0,m.jsx)(v.gx,{}),p]}),(0,m.jsx)("ul",{ref:g,children:D}),T&&(0,m.jsx)("div",{className:`${R} ${(0,y.AH)(w)}`,style:{opacity:1},children:(0,m.jsx)("em",{children:(0,m.jsx)(d.x6,{id:T})})})]})}),$=(0,n.forwardRef)(({id:e,label:t,selectable:s,suggested:i,showBasePathToggle:l=!1,showCompletedToggle:r=!1,showSequentialToggle:a=!1,onChange:c},u)=>{const[x,_]=(0,n.useState)(i||h.A.floodSettings.torrentDestinations?.[""]||h.A.clientSettings?.directoryDefault||""),[j,g]=(0,n.useState)(!1),f=(0,n.useRef)(null),y=(0,b.A)(u),{i18n:k}=(0,d.uB)();(0,n.useEffect)(()=>{const e=()=>{g(!1)},t=t=>{f.current?.contains(t.target)||e()};return document.addEventListener("click",t),window.addEventListener("resize",e),()=>{document.removeEventListener("click",t),window.removeEventListener("resize",e)}},[]);const N=[];return l&&N.push((0,m.jsx)(o.Sc,{grow:!1,id:"isBasePath",children:(0,m.jsx)(d.x6,{id:"torrents.destination.base_path"})},"isBasePath")),r&&N.push((0,m.jsx)(o.Sc,{grow:!1,id:"isCompleted",children:(0,m.jsx)(d.x6,{id:"torrents.destination.completed"})},"isCompleted")),a&&N.push((0,m.jsx)(o.Sc,{grow:!1,id:"isSequential",children:(0,m.jsx)(d.x6,{id:"torrents.destination.sequential"})},"isSequential")),(0,m.jsxs)(o.eW,{ref:f,children:[(0,m.jsx)(o.fh,{children:(0,m.jsxs)(o.Rj,{autoComplete:j?"off":void 0,addonPlacement:"after",defaultValue:x,id:e,label:t,onChange:p()(()=>{if(null==y.current)return;const e=y.current.value;c&&c(e),_(e)},100,{leading:!0}),onClick:e=>e.nativeEvent.stopImmediatePropagation(),placeholder:k._("torrents.add.destination.placeholder"),ref:y,children:[(0,m.jsx)(o.t0,{onClick:()=>{null!=y.current&&_(y.current.value),g(!j)},children:(0,m.jsx)(v.vj,{})}),(0,m.jsx)(o.ZL,{children:(0,m.jsx)(o.tz,{isIn:j,onClick:e=>e.nativeEvent.stopImmediatePropagation(),overlayProps:{isInteractive:!1},padding:!1,triggerRef:y,children:(0,m.jsx)(I,{directory:x,selectable:s,onItemSelection:(e,t=!0)=>{null!=y.current&&(y.current.value=e),g(t),_(e)},onYieldFocus:()=>{y.current?.focus()}})})})]})}),N.length>0?(0,m.jsx)(o.fh,{children:N}):null]})});var V=s(6942),L=s.n(V),H=s(9399);const F=({defaultValue:e,placeholder:t,id:s="tags",label:i,onTagSelected:l})=>{const[r,c]=(0,n.useState)(!1),[u,x]=(0,n.useState)(e??[]),_=(0,n.useRef)(null),j=(0,n.useRef)(null),g=(0,n.useRef)(null),f=L()("select form__element",{"select--is-open":r});return(0,a.A)("Escape",e=>{e.preventDefault(),c(!1)}),(0,n.useEffect)(()=>{const e=e=>{_.current?.contains(e.target)||c(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[]),(0,n.useEffect)(()=>{null!=g.current&&(g.current.value=u.join()),l&&l(u)},[u,l]),(0,m.jsx)(o.ci,{ref:_,children:(0,m.jsx)("div",{className:f,children:(0,m.jsxs)(o.Rj,{autoComplete:r?"off":void 0,id:s||"tags",addonPlacement:"after",defaultValue:e,label:i,onChange:()=>{if(null!=g.current){let e=g.current.value.split(",").map(e=>e.trim()).filter(e=>e.length>0);g.current.value.trimEnd().endsWith(",")&&(e.push(""),e=[...new Set(e)]),x(e)}},placeholder:t,ref:g,children:[(0,m.jsx)(o.t0,{onClick:()=>{c(!r)},className:"select__indicator",children:(0,m.jsx)(v.cL,{})}),(0,m.jsx)(o.ZL,{children:(0,m.jsx)(o.tz,{isIn:r,onClick:e=>{"single"!==h.A.floodSettings.UITagSelectorMode&&e.nativeEvent.stopImmediatePropagation()},overlayProps:{isInteractive:!1},ref:j,triggerRef:g,children:[...new Set(["untagged",...(0,k.di)(Object.keys(H.A.taxonomy.tagCounts)).asc(),...u])].reduce((e,t)=>(""===t||e.push((0,m.jsx)(o.eb,{id:t,isSelected:u.includes(t),onClick:()=>{"untagged"===t?x([]):u.includes(t)?x(u.filter(e=>e!==t&&""!==e)):x([...u.filter(e=>""!==e),t])},children:"untagged"===t?(0,m.jsx)(d.x6,{id:"filter.untagged"}):t},t)),e),[])})})]})})})},E=(e,t)=>Object.keys(e).reduce((s,i)=>{if(i.startsWith(t)){const t=e[i];null!=t&&s.push(t)}return s},[]),B=({defaultValues:e,id:t,label:s,placeholder:i})=>{const l=(0,n.useRef)(0),[r,a]=(0,n.useState)(e??[{id:0,value:""}]);return(0,m.jsx)(o.eW,{children:r.map((e,n)=>{let d=null;return n>0&&(d=(0,m.jsx)(o.t0,{onClick:()=>{const e=r.slice();e.splice(n,1),a(e)},children:(0,m.jsx)(v._B,{})})),(0,m.jsx)(o.fh,{children:(0,m.jsxs)(o.Rj,{addonPlacement:"after",id:`${t}-${e.id}`,defaultValue:e.value,label:0===n&&s,placeholder:i,wrapperClassName:"textbox-repeater",children:[(0,m.jsx)(o.t0,{onClick:()=>{l.current+=1;const e=r.slice();e.splice(n+1,0,{id:l.current,value:""}),a(e)},children:(0,m.jsx)(v.Fx,{})}),d]})},e.id)})})},O=()=>{const e=(0,n.useRef)(null),{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(!1);return(0,m.jsxs)(o.lV,{className:"inverse",ref:e,children:[(0,m.jsx)($,{id:"sourcePath",label:t._("torrents.create.source.path.label")}),(0,m.jsx)(B,{id:"trackers",label:t._("torrents.create.trackers.label"),placeholder:t._("torrents.create.tracker.input.placeholder"),defaultValues:[{id:0,value:""}]}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{id:"name",label:t._("torrents.create.base.name.label"),placeholder:t._("torrents.create.base.name.input.placeholder")})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{id:"comment",label:t._("torrents.create.comment.label"),placeholder:t._("torrents.create.comment.input.placeholder")})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{id:"infoSource",label:t._("torrents.create.info.source.label"),placeholder:t._("torrents.create.info.source.input.placeholder")})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Sc,{grow:!1,id:"isPrivate",children:t._("torrents.create.is.private.label")})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(F,{id:"tags",label:t._("torrents.add.tags"),placeholder:t._("torrents.create.tags.input.placeholder")})}),(0,m.jsx)(g,{onAddTorrentsClick:()=>{if(null==e.current)return;const t=e.current.getFormData();i(!0),null!=t.sourcePath&&(x.A.createTorrent({name:t.name,sourcePath:t.sourcePath,trackers:E(t,"trackers"),comment:t.comment,infoSource:t.infoSource,isPrivate:t.isPrivate||!1,start:t.start||!1,tags:null!=t.tags?t.tags.split(","):void 0}).then(()=>{_.A.setActiveModal(null)}),u({start:t.start,destination:t.sourcePath,tab:"by-creation"}))},isAddingTorrents:s})]})};var U=s(6386);const z=({initialFiles:e,onFilesChanged:t})=>{const[s,i]=(0,n.useState)(e??[]);return(0,n.useEffect)(()=>{t(s)},[s,t]),(0,m.jsxs)(o.ci,{children:[(0,m.jsx)("span",{className:"form__element__label",children:(0,m.jsx)(d.x6,{id:"torrents.add.torrents.label"})}),s.length>0?(0,m.jsx)("div",{onClick:e=>{e.stopPropagation()},role:"none",children:(0,m.jsx)("ul",{className:"dropzone__selected-files interactive-list",children:s.map((e,t)=>(0,m.jsxs)("li",{className:"dropzone__selected-files__file interactive-list__item",title:e.name,children:[(0,m.jsx)("span",{className:"interactive-list__icon",children:(0,m.jsx)(v.ZH,{})}),(0,m.jsx)("span",{className:"interactive-list__label",children:e.name}),(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>{const e=s.slice();e.splice(t,1),i(e)},children:(0,m.jsx)(v.bm,{})})]},e.name))})}):null,(0,m.jsx)(U.Ay,{onDrop:e=>{const t=[];e.forEach(l=>{const n=new FileReader;n.onload=n=>{null!=n.target?.result&&"string"==typeof n.target.result&&t.push({name:l.name,data:n.target.result.split("base64,")[1]}),t.length===e.length&&i(s.concat(t))},n.readAsDataURL(l)})},children:({getRootProps:e,getInputProps:t,isDragActive:s})=>(0,m.jsxs)("div",{...e(),className:"form__dropzone dropzone interactive-list "+(s?"dropzone--is-dragging":""),children:[(0,m.jsx)("input",{...t()}),(0,m.jsxs)("div",{className:"dropzone__copy",children:[(0,m.jsx)("div",{className:"dropzone__icon",children:(0,m.jsx)(v.sv,{})}),(0,m.jsx)(d.x6,{id:"torrents.add.tab.file.drop"})," ",(0,m.jsx)("span",{className:"dropzone__browse-button",children:(0,m.jsx)(d.x6,{id:"torrents.add.tab.file.browse"})}),"."]})]})})]})},W=()=>{const e=(0,n.useRef)([]),t=(0,n.useRef)(null),s=(0,n.useRef)(null),[i,l]=(0,n.useState)(!1),{i18n:r}=(0,d.uB)();return(0,m.jsxs)(o.lV,{className:"inverse",ref:t,children:[(0,m.jsx)(o.fh,{children:(0,m.jsx)(z,{initialFiles:"add-torrents"===_.A.activeModal?.id&&"by-file"===_.A.activeModal?.tab&&_.A.activeModal?.files||[],onFilesChanged:t=>{e.current=t}})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(F,{label:r._("torrents.add.tags"),id:"tags",onTagSelected:e=>{if(null!=s.current){const t=h.A.floodSettings.torrentDestinations?.[e[0]];"string"==typeof t&&null!=s.current&&(s.current.value=t,s.current.dispatchEvent(new Event("input",{bubbles:!0})))}}})}),(0,m.jsx)($,{id:"destination",label:r._("torrents.add.destination.label"),ref:s,selectable:"directories",showBasePathToggle:!0,showCompletedToggle:!0,showSequentialToggle:!0}),(0,m.jsx)(g,{onAddTorrentsClick:()=>{if(null==t.current)return;const s=t.current?.getFormData();l(!0);const{destination:i,start:n,tags:r,isBasePath:a,isCompleted:d,isSequential:o}=s,c=[];if(e.current.forEach(e=>{c.push(e.data)}),0===c.length||null==i)return void l(!1);const h=null!=r?r.split(",").filter(e=>e.length>0):void 0;x.A.addTorrentsByFiles({files:c,destination:i,tags:h,isBasePath:a,isCompleted:d,isSequential:o,start:n}).then(()=>{_.A.setActiveModal(null)}),u({start:n,destination:i,tags:h,tab:"by-file"})},isAddingTorrents:i})]})};var q=s(9550);const G=()=>{const e=(0,n.useRef)(null),t=(0,n.useRef)(null),[s,i]=(0,n.useState)(!1),{i18n:l}=(0,d.uB)();return(0,m.jsxs)(o.lV,{className:"inverse",ref:e,children:[(0,m.jsx)(B,{id:"urls",label:(0,m.jsxs)("div",{children:[l._("torrents.add.torrents.label"),"function"==typeof navigator.registerProtocolHandler&&(0,m.jsx)("button",{className:(0,y.AH)({float:"right",_focus:{outline:"none",WebkitTapHighlightColor:"transparent"},_focusVisible:{outline:"dashed"}}),type:"button",onClick:()=>{"function"==typeof navigator.registerProtocolHandler&&navigator.registerProtocolHandler("magnet",`${q.A.baseURI}?action=add-urls&url=%s`)},children:(0,m.jsx)("em",{className:(0,y.AH)({fontSize:"0.8em"}),children:l._("torrents.add.tab.url.register.magnet.handler")})})]}),placeholder:l._("torrents.add.tab.url.input.placeholder"),defaultValues:"add-torrents"===_.A.activeModal?.id&&"by-url"===_.A.activeModal?.tab&&_.A.activeModal?.urls||[{id:0,value:""}]}),(0,m.jsx)(B,{id:"cookies",label:l._("torrents.add.cookies.label"),placeholder:l._("torrents.add.cookies.input.placeholder")}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(F,{id:"tags",label:l._("torrents.add.tags"),onTagSelected:e=>{if(null!=t.current){const s=h.A.floodSettings.torrentDestinations?.[e[0]];"string"==typeof s&&null!=t.current&&(t.current.value=s,t.current.dispatchEvent(new Event("input",{bubbles:!0})))}}})}),(0,m.jsx)($,{id:"destination",label:l._("torrents.add.destination.label"),ref:t,selectable:"directories",showBasePathToggle:!0,showCompletedToggle:!0,showSequentialToggle:!0}),(0,m.jsx)(g,{onAddTorrentsClick:()=>{if(null==e.current)return;const t=e.current.getFormData();i(!0);const s=E(t,"urls").filter(e=>""!==e);if(0===s.length||null==t.destination)return void i(!1);const l=E(t,"cookies"),n=s[0].startsWith("http")&&s[0].split("/")[2],r=n?{[n]:l}:void 0,a=null!=t.tags?t.tags.split(",").filter(e=>e.length>0):void 0;x.A.addTorrentsByUrls({urls:s,cookies:r,destination:t.destination,isBasePath:t.isBasePath,isCompleted:t.isCompleted,isSequential:t.isSequential,start:t.start,tags:a}).then(()=>{_.A.setActiveModal(null)}),u({start:t.start,destination:t.destination,tags:a,tab:"by-url"})},isAddingTorrents:s})]})},Z=({activeTabId:e,tabs:t={},onTabChange:s})=>(0,m.jsx)("ul",{className:"modal__tabs",children:Object.keys(t).map(i=>{const l=t[i];l.id=i;const n=L()("modal__tab",{"is-active":i===e});return(0,m.jsx)("li",{className:n,children:(0,m.jsx)("button",{className:(0,y.AH)({_focus:{outline:"none",WebkitTapHighlightColor:"transparent"},_focusVisible:{outline:"dashed"}}),type:"button",onClick:()=>{s&&s(l)},children:l.label})},i)})}),Q=({alignment:e="left",size:t="medium",orientation:s="horizontal",tabsInBody:i=!1,inverse:l=!0,initialTabId:r,className:a=null,content:d,heading:o,tabs:c,actions:h})=>{const u=L()("modal__content__wrapper",`modal--align-${e}`,`modal--size-${t}`,{"modal--horizontal":"horizontal"===s,"modal--vertical":"vertical"===s,"modal--tabs-in-header":!i,"modal--tabs-in-body":i,inverse:l},a);let x=d;const _=o,g=L()("modal__header",{"has-tabs":c});let f,p,b;const[v,y]=(0,n.useState)(r??Object.keys(c||{})[0]);if(c){const e=c[v],t=L()("modal__content",e.modalContentClasses),s=e.content,l=e.props,n=(0,m.jsx)(Z,{activeTabId:v,onTabChange:e=>{null!=e.id&&y(e.id)},tabs:c},"modal-tabs");i?f=n:b=n,x=[f,(0,m.jsx)("div",{className:t,children:(0,m.jsx)(s,{...l})},"modal-content")]}return h&&(p=(0,m.jsx)("div",{className:"modal__footer",children:(0,m.jsx)(j,{actions:h})})),(0,m.jsxs)("div",{className:u,children:[(0,m.jsxs)("div",{className:g,children:[_,b]}),(0,m.jsxs)("div",{className:"modal__body",children:[x,p]})]})},J=()=>{const{i18n:e}=(0,d.uB)(),t={"by-url":{content:G,label:e._("torrents.add.tab.url.title")},"by-file":{content:W,label:e._("torrents.add.tab.file.title")},"by-creation":{content:O,label:e._("torrents.add.tab.create.title")}};return"add-torrents"!==_.A.activeModal?.id?null:(0,m.jsx)(Q,{heading:e._("torrents.add.heading"),tabs:t,initialTabId:_.A.activeModal.tab??h.A.floodSettings.UITorrentsAddTab??"by-url"})},Y=(0,r.PA)(()=>{if("confirm"!==_.A.activeModal?.id)return null;const{actions:e,content:t,heading:s}=_.A.activeModal||{};return(0,m.jsx)(Q,{actions:e,content:(0,m.jsx)("div",{className:"modal__content",children:t}),heading:s})});var K=s(1083),X=s(7813);const ee=new class{feeds=[];rules=[];items=[];constructor(){(0,X.l_)(this)}setFeeds(e){this.feeds=null!=e?[...e].sort((e,t)=>e.label.localeCompare(t.label)):[]}setRules(e){this.rules=null!=e?[...e].sort((e,t)=>e.label.localeCompare(t.label)):[]}handleFeedMonitorsFetchSuccess(e){this.setFeeds(e.feeds),this.setRules(e.rules)}handleItemsFetchSuccess(e){this.items=e}},{baseURI:te}=q.A,se={addFeed:e=>K.A.put(`${te}api/feed-monitor/feeds`,e).then(()=>se.fetchFeedMonitors()),modifyFeed:(e,t)=>K.A.patch(`${te}api/feed-monitor/feeds/${e}`,t).then(()=>se.fetchFeedMonitors()),addRule:e=>K.A.put(`${te}api/feed-monitor/rules`,e).then(()=>se.fetchFeedMonitors()),fetchFeedMonitors:()=>K.A.get(`${te}api/feed-monitor`).then(({data:e})=>{ee.handleFeedMonitorsFetchSuccess(e)},()=>{}),fetchItems:({id:e,search:t})=>K.A.get(`${te}api/feed-monitor/feeds/${e}/items`,{params:{search:t}}).then(({data:e})=>{ee.handleItemsFetchSuccess(e)},()=>{}),removeFeedMonitor:e=>K.A.delete(`${te}api/feed-monitor/${e}`).then(()=>se.fetchFeedMonitors(),()=>{})},ie=se,le=/^(?:https?|ftp):\/\/.{1,}\.{1}.{1,}/,ne=e=>null!=e&&""!==e,re=e=>{try{new RegExp(e)}catch{return!1}return!0},ae=({rule:e,isSubmitting:t,isPatternMatched:s,onCancel:i})=>{const{feeds:l}=ee,{i18n:n}=(0,d.uB)();return(0,m.jsxs)(o.eW,{children:[(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{id:"label",label:n._("feeds.label"),defaultValue:e.label}),(0,m.jsx)(o.l6,{disabled:!l.length,id:"feedID",label:n._("feeds.applicable.feed"),defaultID:e.feedIDs?.[0],children:0===l.length?[(0,m.jsx)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,m.jsx)("em",{children:(0,m.jsx)(d.x6,{id:"feeds.no.feeds.available"})})},"empty")]:l.reduce((e,t)=>e.concat((0,m.jsx)(o.eb,{id:`${t._id}`,children:t.label},t._id)),[(0,m.jsx)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,m.jsx)("em",{children:(0,m.jsx)(d.x6,{id:"feeds.select.feed"})})},"select-feed")])})]}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{id:"match",label:n._("feeds.match.pattern"),placeholder:n._("feeds.regEx"),defaultValue:e.match,width:"three-eighths"}),(0,m.jsx)(o.Rj,{id:"exclude",label:n._("feeds.exclude.pattern"),placeholder:n._("feeds.regEx"),defaultValue:e.exclude,width:"three-eighths"})]}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{addonPlacement:"after",id:"check",label:n._("feeds.test.match"),placeholder:n._("feeds.check"),children:s&&(0,m.jsx)(o.t0,{children:(0,m.jsx)(v.H4,{})})})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.ci,{children:(0,m.jsx)($,{id:"destination",label:n._("feeds.torrent.destination"),selectable:"directories",suggested:e.destination,showBasePathToggle:!0})}),(0,m.jsx)(F,{id:"tags",label:n._("feeds.apply.tags"),placeholder:n._("feeds.tags"),defaultValue:e.tags})]}),(0,m.jsxs)(o.fh,{align:"end",justify:"end",children:[(0,m.jsx)("br",{}),(0,m.jsx)(o.Sc,{id:"startOnLoad",defaultChecked:e.startOnLoad,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"feeds.start.on.load"})}),(0,m.jsx)(o.$n,{onClick:i,children:(0,m.jsx)(d.x6,{id:"button.cancel"})}),(0,m.jsx)(o.$n,{type:"submit",isLoading:t,children:(0,m.jsx)(d.x6,{id:"button.save.feed"})})]})]})},de=({children:e})=>(0,m.jsx)("h2",{className:"h4",children:e}),oe=(0,r.PA)(({currentRule:e,onSelect:t,onRemove:s})=>{const{rules:i}=ee;return 0===i.length?(0,m.jsx)("ul",{className:"interactive-list",children:(0,m.jsx)("li",{className:"interactive-list__item",children:(0,m.jsx)(d.x6,{id:"feeds.no.rules.defined"})})}):(0,m.jsx)("ul",{className:"interactive-list",children:i.map(i=>{const l=i.count||0;let n=null,r=null;if(i.exclude&&(n=(0,m.jsxs)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",children:[(0,m.jsx)(d.x6,{id:"feeds.exclude"}),": ",i.exclude]})),i.tags&&i.tags.length>0){const e=i.tags.map(e=>(0,m.jsx)("span",{className:"tag",children:e},e));r=(0,m.jsxs)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",children:[(0,m.jsx)(d.x6,{id:"feeds.tags"}),": ",e]})}return(0,m.jsxs)("li",{className:"interactive-list__item interactive-list__item--stacked-content",children:[(0,m.jsxs)("div",{className:"interactive-list__label",children:[(0,m.jsxs)("ul",{className:"interactive-list__detail-list",children:[(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:i.label}),(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail-list__item--overflow interactive-list__detail interactive-list__detail--secondary",children:(0,m.jsx)(d.x6,{id:"feeds.match.count",values:{count:l}})}),i===e&&(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:"Modifying"})]}),(0,m.jsxs)("ul",{className:"interactive-list__detail-list",children:[(0,m.jsxs)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",style:{maxWidth:"50%",overflow:"hidden",textOverflow:"ellipsis"},children:[(0,m.jsx)(d.x6,{id:"feeds.match"}),": ",i.match]}),(0,m.jsx)("div",{style:{width:"100%"}}),n,r]})]}),(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action",type:"button",onClick:()=>t(i),children:(0,m.jsx)(v.ff,{})}),(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>s(i),children:(0,m.jsx)(v.bm,{})})]},i._id)})})}),ce={label:"",feedIDs:[],match:"",exclude:"",tags:[],destination:"",startOnLoad:!1},he={destination:{isValid:ne,error:"feeds.validation.must.specify.destination"},feedID:{isValid:e=>ne(e)&&"placeholder"!==e,error:"feeds.validation.must.select.feed"},label:{isValid:ne,error:"feeds.validation.must.specify.label"},match:{isValid:e=>ne(e)&&re(e),error:"feeds.validation.invalid.regular.expression"},exclude:{isValid:e=>!ne(e)||re(e),error:"feeds.validation.invalid.regular.expression"}},ue=(e,t)=>he[e]?.isValid(t)?void 0:he[e]?.error,xe=()=>{const e=(0,n.useRef)(null),{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(null),[l,r]=(0,n.useState)({}),[a,c]=(0,n.useState)(!1),[h,u]=(0,n.useState)(!1),[x,_]=(0,n.useState)(!1),[j,g]=(0,n.useState)(!1);return(0,m.jsxs)(o.lV,{className:"inverse",onChange:({event:e,formData:t})=>{const s=e.target.name,i=t;r({...l,[s]:ue(s,i[s])}),g((()=>{const{check:e,match:t="",exclude:s=""}=i;if(ne(e)&&re(t)&&re(s)){const i=new RegExp(t,"gi").test(e),l=""!==s&&new RegExp(s,"gi").test(e);return i&&!l}return!1})()),_(!0)},onSubmit:async()=>{if(null==e.current)return;const t=e.current.getFormData(),l=Object.keys(he).reduce((e,s)=>{const i=s;return{...e,[i]:ue(i,t[i])}},{});r(l);const n=Object.keys(l).every(e=>void 0===l[e]);x&&n&&(u(!0),null!=s?._id&&await ie.removeFeedMonitor(s._id),await ie.addRule({label:t.label??ce.label,feedIDs:[t.feedID??""],field:t.field,match:t.match??ce.match,exclude:t.exclude??ce.exclude,destination:t.destination??ce.destination,tags:t.tags?.split(",")??ce.tags,startOnLoad:t.startOnLoad??ce.startOnLoad,isBasePath:t.isBasePath??!1}).then(()=>{e.current?.resetForm(),r({}),i(null),c(!1)},()=>{r({backend:"general.error.unknown"})}),u(!1))},ref:e,children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"feeds.existing.rules"})}),Object.keys(l).reduce((e,s)=>(null!=l[s]&&e.push((0,m.jsx)(o.fh,{children:(0,m.jsx)(o.jQ,{children:t._(l?.[s])})},`error-${s}`)),e),[]),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.ci,{children:(0,m.jsx)(oe,{currentRule:s,onSelect:e=>{i(e),c(!0)},onRemove:e=>{null!=e._id&&ie.removeFeedMonitor(e._id),e===s&&(i(null),c(!1))}})})}),a?(0,m.jsx)(ae,{rule:s??ce,isPatternMatched:j,isSubmitting:h,onCancel:()=>{i(null),c(!1)}},s?._id||"initial"):(0,m.jsxs)(o.fh,{align:"end",justify:"end",children:[(0,m.jsx)("br",{}),(0,m.jsx)(o.$n,{onClick:()=>{c(!0)},children:(0,m.jsx)(d.x6,{id:"button.new"})})]})]})},_e=({currentFeed:e,defaultFeed:t,intervalMultipliers:s,isSubmitting:i,onCancel:l})=>{const{i18n:n}=(0,d.uB)(),r=e?.interval??t.interval;let a=r,c=1;return s.forEach(e=>{const t=e.value;r%t===0&&(a=r/t,c=t)}),(0,m.jsxs)(o.eW,{children:[(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{id:"label",label:n._("feeds.label"),placeholder:n._("feeds.label"),defaultValue:e?.label??t.label}),(0,m.jsx)(o.Rj,{id:"interval",label:n._("feeds.select.interval"),placeholder:n._("feeds.interval"),defaultValue:a,width:"one-eighth"}),(0,m.jsx)(o.l6,{labelOffset:!0,defaultID:c,id:"intervalMultiplier",width:"one-eighth",children:s.map(e=>(0,m.jsx)(o.eb,{id:e.value,children:n._(e.message)},e.value))})]}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{id:"url",label:n._("feeds.url"),placeholder:n._("feeds.url"),defaultValue:e?.url??t?.url}),(0,m.jsx)(o.$n,{labelOffset:!0,onClick:l,children:(0,m.jsx)(d.x6,{id:"button.cancel"})}),(0,m.jsx)(o.$n,{labelOffset:!0,type:"submit",isLoading:i,children:(0,m.jsx)(d.x6,{id:"button.save.feed"})})]})]})},me=(0,r.PA)(({selectedFeedID:e})=>{const{items:t}=ee,s=[];if(e){const e={};t.forEach((t,i)=>{let{title:l}=t;const n=e[l];null==n?e[l]=2:(l=`${l} #${n}`,e[l]+=1),s.push((0,m.jsxs)("li",{className:"interactive-list__item interactive-list__item--stacked-content feed-list__feed",children:[(0,m.jsx)("div",{className:"interactive-list__label feed-list__feed-label",children:l}),(0,m.jsx)(o.Sc,{id:`${i}`})]},l))})}return(0,m.jsx)(o.fh,{children:0===s.length?(0,m.jsx)("ul",{className:"interactive-list",children:(0,m.jsx)("li",{className:"interactive-list__item",children:(0,m.jsx)("div",{className:"interactive-list__label",children:(0,m.jsx)(d.x6,{id:"feeds.no.items.matching"})})})}):(0,m.jsx)("ul",{className:"interactive-list feed-list",children:s})})}),je=(0,r.PA)(()=>{const{i18n:e}=(0,d.uB)(),t=(0,n.useRef)(null),[s,i]=(0,n.useState)(null),{feeds:l}=ee;return null!=s&&(l.some(e=>e._id===s)||i(null)),(0,m.jsxs)(o.lV,{className:"inverse",onChange:({event:e,formData:t})=>{const s=t;"checkbox"!==e.target.type&&(i(s.feedID),ie.fetchItems({id:s.feedID,search:s.search}))},onSubmit:()=>{if(null==t.current)return;const e=t.current.getFormData(),s=ee.items.filter((t,s)=>e[s]).map((e,t)=>({id:t,value:e.urls[0]}));_.A.setActiveModal({id:"add-torrents",tab:"by-url",urls:s})},ref:t,children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"feeds.browse.feeds"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.l6,{disabled:!l.length,grow:!1,id:"feedID",label:e._("feeds.select.feed"),width:"three-eighths",children:l.length?l.reduce((e,t)=>null==t._id?e:e.concat((0,m.jsx)(o.eb,{id:t._id,children:t.label},t._id)),[(0,m.jsx)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,m.jsx)("em",{children:(0,m.jsx)(d.x6,{id:"feeds.select.feed"})})},"select-feed")]):[(0,m.jsx)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,m.jsx)("em",{children:(0,m.jsx)(d.x6,{id:"feeds.no.feeds.available"})})},"empty")]}),s&&(0,m.jsx)(o.Rj,{id:"search",label:e._("feeds.search.term"),placeholder:e._("feeds.search")}),s&&(0,m.jsx)(o.$n,{type:"submit",labelOffset:!0,children:(0,m.jsx)(d.x6,{id:"button.download"})},"button")]}),s&&(0,m.jsx)(me,{selectedFeedID:s})]})}),ge=(0,r.PA)(({currentFeed:e,intervalMultipliers:t,onSelect:s,onRemove:i})=>{const{feeds:l}=ee,{i18n:n}=(0,d.uB)();return 0===l.length?(0,m.jsx)("ul",{className:"interactive-list",children:(0,m.jsx)("li",{className:"interactive-list__item",children:(0,m.jsx)(d.x6,{id:"feeds.no.feeds.defined"})})}):(0,m.jsx)("ul",{className:"interactive-list feed-list",children:l.map(l=>{const r=l.count||0;let a=`${l.interval}`,o=t[0].message;return t.forEach(e=>{l.interval%e.value===0&&(a=""+l.interval/e.value,o=e.message)}),(0,m.jsxs)("li",{className:"interactive-list__item interactive-list__item--stacked-content feed-list__feed",children:[(0,m.jsxs)("div",{className:"interactive-list__label",children:[(0,m.jsxs)("ul",{className:"interactive-list__detail-list",children:[(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:l.label}),(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail-list__item--overflow interactive-list__detail interactive-list__detail--secondary",children:(0,m.jsx)(d.x6,{id:"feeds.match.count",values:{count:r}})}),l===e&&(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:"Modifying"})]}),(0,m.jsxs)("ul",{className:"interactive-list__detail-list",children:[(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",children:`${a} ${n._(o)}`}),(0,m.jsx)("li",{className:"interactive-list__detail-list__item interactive-list__detail-list__item--overflow interactive-list__detail interactive-list__detail--tertiary",children:(0,m.jsx)("a",{href:l.url,rel:"noopener noreferrer",target:"_blank",children:l.url})})]})]}),(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action",type:"button",onClick:()=>s(l),children:(0,m.jsx)(v.ff,{})}),(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>i(l),children:(0,m.jsx)(v.bm,{})})]},l._id)})})}),fe={url:{isValid:e=>null!=e&&""!==e&&null!==e.match(le),error:"feeds.validation.must.specify.valid.feed.url"},label:{isValid:ne,error:"feeds.validation.must.specify.label"},interval:{isValid:e=>{if(null===e||""===e)return!1;const t=parseInt(`${e}`,10);return!Number.isNaN(t)&&t>0},error:"feeds.validation.interval.not.positive"}},pe=(e,t)=>fe[e]?.isValid(t)?void 0:fe[e]?.error,be=[{message:"feeds.time.min",value:1},{message:"feeds.time.hr",value:60},{message:"feeds.time.day",value:1440}],ve={label:"",interval:5,url:""},ye=()=>{const e=(0,n.useRef)(null),{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(null),[l,r]=(0,n.useState)({}),[a,c]=(0,n.useState)(!1),[h,u]=(0,n.useState)(!1);return(0,m.jsxs)("div",{children:[(0,m.jsxs)(o.lV,{className:"inverse",onChange:({event:e,formData:t})=>{const s=e.target.name,i=t;r({...l,[s]:pe(s,i[s])})},onSubmit:async()=>{const t=e.current?.getFormData();if(null==e.current||null==t)return;u(!0);const l=Object.keys(fe).reduce((e,s)=>{const i=s;return{...e,[i]:pe(i,t[i])}},{});r(l);if(Object.keys(l).every(e=>void 0===l[e])){const l={label:t.label,url:t.url,interval:Number(t.interval)*Number(t.intervalMultiplier)};let n=!0;try{null===s?await ie.addFeed(l):null!=s?._id&&await ie.modifyFeed(s._id,l)}catch{n=!1}n?(e.current.resetForm(),r({}),i(null),c(!1)):r({backend:"general.error.unknown"})}u(!1)},ref:e,children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"feeds.existing.feeds"})}),Object.keys(l).reduce((e,s)=>(null!=l[s]&&e.push((0,m.jsx)(o.fh,{children:(0,m.jsx)(o.jQ,{children:t._(l?.[s])})},`error-${s}`)),e),[]),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.ci,{children:(0,m.jsx)(ge,{currentFeed:s,intervalMultipliers:be,onSelect:e=>{i(e),c(!0)},onRemove:e=>{e===s&&(a&&(r({}),c(!1)),i(null)),null!=e._id&&ie.removeFeedMonitor(e._id)}})})}),a?(0,m.jsx)(_e,{currentFeed:s,defaultFeed:ve,intervalMultipliers:be,isSubmitting:h,onCancel:()=>{r({}),c(!1),i(null)}},s?._id||"initial"):(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.ci,{width:"auto"}),(0,m.jsx)(o.$n,{onClick:()=>{c(!0)},children:(0,m.jsx)(d.x6,{id:"button.new"})})]})]}),(0,m.jsx)(je,{})]})},ke=()=>{const{i18n:e}=(0,d.uB)();(0,n.useEffect)(()=>{ie.fetchFeedMonitors()},[]);const t={feeds:{content:ye,label:e._("feeds.tabs.feeds")},downloadRules:{content:xe,label:e._("feeds.tabs.download.rules")}};return(0,m.jsx)(Q,{heading:e._("feeds.tabs.heading"),orientation:"horizontal",size:"large",tabs:t})};var Ne=s(484);let Ae=function(e){return e[e.HTTP=1]="HTTP",e[e.UDP=2]="UDP",e[e.DHT=3]="DHT",e}({});const Se=(e,t)=>{let s=`magnet:?xt=urn:btih:${e}`;return t?.length&&t.forEach(e=>{s=`${s}&tr=${encodeURI(e)}`}),s},we=()=>{const e=(0,n.useRef)(null),t=(0,n.useRef)(null),{i18n:s}=(0,d.uB)(),[i,l]=(0,n.useState)(!1),[r,a]=(0,n.useState)(!1),[c,h]=(0,n.useState)({isLoadingTrackers:!0,magnetTrackersLink:""});(0,n.useEffect)(()=>{x.A.fetchTorrentTrackers(Ne.A.selectedTorrents[0]).then(e=>{null!=e&&h({isLoadingTrackers:!1,magnetTrackersLink:Se(Ne.A.selectedTorrents[0],e.filter(e=>e.type!==Ae.DHT).map(e=>e.url))})})},[]);const u=Se(Ne.A.selectedTorrents[0]);return(0,m.jsx)(Q,{heading:s._("torrents.generate.magnet.heading"),content:(0,m.jsx)("div",{className:"modal__content inverse",children:(0,m.jsxs)(o.lV,{children:[Ne.A.torrents[Ne.A.selectedTorrents[0]]?.isPrivate?(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.jQ,{children:s._("torrents.generate.magnet.private.torrent")})}):null,(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{id:"magnet",ref:e,addonPlacement:"after",label:s._("torrents.generate.magnet.magnet"),defaultValue:u,readOnly:!0,children:(0,m.jsx)(o.t0,{onClick:()=>{"function"==typeof navigator.clipboard?.writeText?navigator.clipboard.writeText(u).then(()=>{l(!0)}):null!=e.current&&(e.current?.select(),document.execCommand("copy"),l(!0))},children:i?(0,m.jsx)(v.H4,{}):(0,m.jsx)(v.B0,{})})})}),(0,m.jsx)(o.fh,{children:c.isLoadingTrackers?(0,m.jsx)(o.Rj,{id:"loading",label:s._("torrents.generate.magnet.magnet.with.trackers"),placeholder:s._("torrents.generate.magnet.loading.trackers"),disabled:!0}):(0,m.jsx)(o.Rj,{id:"magnet-trackers",ref:t,addonPlacement:"after",label:s._("torrents.generate.magnet.magnet.with.trackers"),defaultValue:c.magnetTrackersLink,readOnly:!0,children:(0,m.jsx)(o.t0,{onClick:()=>{"function"==typeof navigator.clipboard?.writeText?navigator.clipboard.writeText(c.magnetTrackersLink).then(()=>{a(!0)}):null!=t.current&&(t.current?.select(),document.execCommand("copy"),a(!0))},children:r?(0,m.jsx)(v.H4,{}):(0,m.jsx)(v.B0,{})})})})]})}),actions:[{clickHandler:null,content:s._("button.close"),triggerDismiss:!0,type:"tertiary"}]})},Ce=e=>{let t="";for(let s=0;s<e[0].length;s+=1)for(let i=1;i<e.length;i+=1)e[0][s]!==e[i][s]&&(t=e[0].slice(0,s));for(let e=t.length-1;e>=0;e-=1)if("/"===t[e])return t.slice(0,e+1)},Te=()=>{const{i18n:e}=(0,d.uB)(),[t,s]=(0,n.useState)(!1);return(0,m.jsx)(Q,{heading:e._("torrents.move.heading"),content:(0,m.jsx)("div",{className:"modal__content",children:(0,m.jsxs)(o.lV,{className:"inverse",onSubmit:({formData:e})=>{const t=Ne.A.selectedTorrents;t.length>0&&(s(!0),x.A.moveTorrents({hashes:t,destination:e.destination,isBasePath:e.isBasePath,moveFiles:e.moveFiles,isCheckHash:e.isCheckHash}).then(()=>{_.A.setActiveModal(null),s(!1)}))},children:[(0,m.jsx)($,{id:"destination",selectable:"directories",suggested:Ce(Ne.A.selectedTorrents.map(e=>Ne.A.torrents[e].directory)),showBasePathToggle:!0}),(0,m.jsx)(j,{actions:[{checked:!0,content:e._("torrents.move.data.label"),id:"moveFiles",type:"checkbox"},{checked:!1,content:e._("torrents.move.check_hash.label"),id:"isCheckHash",type:"checkbox"},{content:e._("button.cancel"),triggerDismiss:!0,type:"tertiary"},{content:e._("torrents.move.button.set.location"),isLoading:t,submit:!0,type:"primary"}]})]})})})},Re=()=>{const{i18n:e}=(0,d.uB)(),[t,s]=(0,n.useState)(!1),{selectedTorrents:i}=Ne.A;return 0===i.length?(0,m.jsx)(Q,{heading:e._("torrents.remove"),content:(0,m.jsx)("div",{className:"modal__content inverse",children:(0,m.jsx)(o.lV,{children:(0,m.jsx)(o.fh,{children:(0,m.jsx)(d.x6,{id:"torrents.remove.error.no.torrents.selected"})})})}),actions:[{clickHandler:null,content:e._("button.ok"),triggerDismiss:!0,type:"primary"}]}):(0,m.jsx)(Q,{heading:e._("torrents.remove"),content:(0,m.jsx)("div",{className:"modal__content",children:(0,m.jsxs)(o.lV,{className:"inverse",onSubmit:({formData:e})=>{s(!0);const t=e.deleteData;x.A.deleteTorrents({hashes:Ne.A.selectedTorrents,deleteData:t}).then(()=>{s(!1),(({deleteData:e})=>{null!=e&&c.A.saveSetting("deleteTorrentData",e)})({deleteData:t}),_.A.setActiveModal(null)})},children:[(0,m.jsx)(o.fh,{children:(0,m.jsx)(d.x6,{id:"torrents.remove.are.you.sure",values:{count:i.length}})}),(0,m.jsx)(j,{actions:[{checked:h.A.floodSettings.deleteTorrentData,content:e._("torrents.remove.delete.data"),id:"deleteData",type:"checkbox"},{content:e._("button.no"),triggerDismiss:!0,type:"tertiary"},{content:e._("button.yes"),isLoading:t,submit:!0,type:"primary"}]})]})})})},De=()=>{const e=(0,n.useRef)(null),{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(!1);return(0,m.jsx)(Q,{heading:t._("torrents.set.tags.heading"),content:(0,m.jsx)("div",{className:"modal__content inverse",children:(0,m.jsx)(o.lV,{ref:e,children:(0,m.jsx)(o.fh,{children:(0,m.jsx)(F,{defaultValue:Ne.A.selectedTorrents.map(e=>Ne.A.torrents[e].tags)[0].slice(),id:"tags",placeholder:t._("torrents.set.tags.enter.tags")})})})}),actions:[{content:t._("button.cancel"),clickHandler:null,triggerDismiss:!0,type:"tertiary"},{content:t._("torrents.set.tags.button.set"),clickHandler:()=>{if(null==e.current)return;const{selectedTorrents:t}=Ne.A,s=e.current.getFormData(),l=s.tags?s.tags.split(",").filter(e=>!!e):[];i(!0),t?.length>0&&x.A.setTags({hashes:t,tags:l})},isLoading:s,triggerDismiss:!1,type:"primary"}]})},Me=()=>{const e=(0,n.useRef)(null),{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(!1),[l,r]=(0,n.useState)({isLoadingTrackers:!0,trackerURLs:[]});return(0,n.useEffect)(()=>{x.A.fetchTorrentTrackers(Ne.A.selectedTorrents[0]).then(e=>{null!=e&&r({isLoadingTrackers:!1,trackerURLs:e.filter(e=>e.type!==Ae.DHT).map(e=>e.url)})})},[]),(0,m.jsx)(Q,{heading:t._("torrents.set.trackers.heading"),content:(0,m.jsx)("div",{className:"modal__content inverse",children:(0,m.jsx)(o.lV,{ref:e,children:l.isLoadingTrackers?(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{id:"loading",placeholder:t._("torrents.set.trackers.loading.trackers"),disabled:!0})}):(0,m.jsx)(B,{id:"trackers",placeholder:t._("torrents.set.trackers.enter.tracker"),defaultValues:0===l.trackerURLs.length?void 0:l.trackerURLs.map((e,t)=>({id:t,value:e}))})})}),actions:[{clickHandler:null,content:t._("button.cancel"),triggerDismiss:!0,type:"tertiary"},{clickHandler:()=>{if(null==e.current||s||l.isLoadingTrackers)return;i(!0);const t=e.current.getFormData(),n=E(t,"trackers").filter(e=>""!==e);x.A.setTrackers({hashes:Ne.A.selectedTorrents,trackers:n}).then(()=>{i(!1),_.A.setActiveModal(null)})},content:t._("torrents.set.trackers.button.set"),isLoading:s||l.isLoadingTrackers,triggerDismiss:!1,type:"primary"}]})};var Pe=s(8334);const Ie=JSON.parse('{"rE":"0.0.0-master.1da2260"}'),$e="https://github.com/jesec/flood",Ve="# Flood <FloodVersion />\n\n[](https://www.npmjs.com/flood) <CommitBadge />\n\n[](https://github.com/jesec/flood/actions/workflows/build.yml) [](https://crowdin.com/project/flood) [](https://discord.gg/Z7yR5Uf)\n\nFlood is a monitoring service for various torrent clients. It's a Node.js service that communicates with your favorite torrent client and serves a decent web UI for administration. This project is based on the [original Flood project](https://github.com/Flood-UI/flood).\n\n#### Feedback\n\nIf you have a specific issue or bug, please file a [GitHub issue](https://github.com/jesec/flood/issues). Please join the [Flood Discord server](https://discord.gg/Z7yR5Uf) to discuss feature requests and implementation details.\n\n#### More Information\n\nCheck out the [Wiki](https://github.com/jesec/flood/wiki) for more information.\n".replaceAll("<FloodVersion />",Ie.rE).replaceAll("<CommitBadge />",Ie.rE.length>8?``:``),Le=()=>(0,m.jsx)(n.Suspense,{fallback:null,children:(0,m.jsx)(Pe.oz,{children:Ve})});var He=s(5767),Fe=s(7230),Ee=s(9119),Be=s(8045);const Oe=(0,r.PA)(()=>{const e=(0,n.useRef)(null),t=(0,n.useRef)(null),[s,r]=(0,n.useState)(null),[a,c]=(0,n.useState)(!1),[h,u]=(0,n.useState)(!1),{i18n:x}=(0,d.uB)();if((0,n.useEffect)(()=>{Fe.A.currentUser.isAdmin&&He.A.fetchUsers().then(()=>{c(!0)})},[]),!Fe.A.currentUser.isAdmin)return(0,m.jsxs)(o.lV,{children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"auth.user.accounts"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.jQ,{children:(0,m.jsx)(d.x6,{id:"auth.message.not.admin"})})})]});const _=!a&&0===Fe.A.users.length,j=L()("interactive-list",{"interactive-list--loading":_});return(0,m.jsxs)(o.lV,{onSubmit:()=>{if(null==e.current||null==t.current)return;const s=e.current.getFormData();if(null==s.username||""===s.username)r("auth.error.username.empty");else if(null==s.password||""===s.password)r("auth.error.password.empty");else{u(!0);const i=t.current;if(null==i)return r("connection.settings.error.empty"),void u(!1);He.A.createUser({username:s.username,password:s.password,client:i,level:!0===s.isAdmin?Ee.h.ADMINISTRATOR:Ee.h.USER}).then(()=>{null!=e.current&&e.current.resetForm(),r(null),u(!1)},()=>{r("general.error.unknown"),u(!1)}).then(He.A.fetchUsers)}},ref:e,children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"auth.user.accounts"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.ci,{children:(0,m.jsxs)("ul",{className:j,children:[(0,m.jsx)(l.A,{children:_&&(0,m.jsx)(i.A,{classNames:"interactive-list__loading-indicator",timeout:{enter:250,exit:250},children:(0,m.jsx)("div",{className:"interactive-list__loading-indicator",children:(0,m.jsx)(o.hg,{})},"loading-indicator")})}),Fe.A.users.slice().sort((e,t)=>e.username.localeCompare(t.username)).map(e=>{const t=e.username===Fe.A.currentUser.username;let s=null,i=null;t?s=(0,m.jsx)("span",{className:"interactive-list__label__tag tag",children:(0,m.jsx)(d.x6,{id:"auth.current.user"})}):i=(0,m.jsx)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>He.A.deleteUser(e.username).then(He.A.fetchUsers),children:(0,m.jsx)(v.bm,{})});const l=L()("interactive-list__item",{"interactive-list__item--disabled":t});return(0,m.jsxs)("li",{className:l,children:[(0,m.jsxs)("span",{className:"interactive-list__label",children:[(0,m.jsx)("div",{className:"interactive-list__label__text",children:e.username}),s]}),i]},e.username)})]})})}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"auth.add.user"})}),s&&(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.jQ,{children:x._(s)})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{id:"username",label:(0,m.jsx)(d.x6,{id:"auth.username"}),placeholder:x._("auth.username"),autoComplete:"username"}),(0,m.jsx)(o.Rj,{id:"password",label:(0,m.jsx)(d.x6,{id:"auth.password"}),placeholder:x._("auth.password"),autoComplete:"new-password"}),(0,m.jsx)(o.Sc,{grow:!1,id:"isAdmin",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"auth.admin"})})]}),(0,m.jsx)(Be.A,{onSettingsChange:e=>{t.current=e}}),(0,m.jsx)("p",{}),(0,m.jsx)(o.fh,{justify:"end",children:(0,m.jsx)(o.$n,{isLoading:h,priority:"primary",type:"submit",children:(0,m.jsx)(d.x6,{id:"button.add"})})})]})}),Ue=(e,t)=>null!=e[t]?e[t]:h.A.clientSettings?.[t],ze=e=>{const t=e.target,s=t.name,{value:i,type:l,checked:n}=t;let r={};return r="checkbox"===l?{[s]:n}:{[s]:i},r},We=e=>{if(e&&0!==e.length)return e.join(", ")},qe=(e="")=>""===e?[]:e.replace(/\s/g,"").split(",").map(e=>Number(e)),Ge=({onSettingsChange:e,onClientSettingsChange:t})=>{const[s,i]=(0,n.useState)({});return(0,m.jsxs)(o.lV,{onChange:({event:l,formData:n})=>{const r=l.target;if("dropdownPresetDownload"===r.name||"dropdownPresetUpload"===r.name)return void e({speedLimits:{download:qe(n.dropdownPresetDownload),upload:qe(n.dropdownPresetUpload)}});const a={...s,...ze(l)};i(a),t(a)},children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.bandwidth.transferrate.heading"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{defaultValue:null!=h.A.floodSettings.speedLimits?We(h.A.floodSettings.speedLimits.download):0,label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.transferrate.dropdown.preset.download.label"}),id:"dropdownPresetDownload"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{defaultValue:null!=h.A.floodSettings.speedLimits?We(h.A.floodSettings.speedLimits.upload):0,label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.transferrate.dropdown.preset.upload.label"}),id:"dropdownPresetUpload"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleGlobalDownSpeed"),label:(0,m.jsxs)("div",{children:[(0,m.jsx)(d.x6,{id:"settings.bandwidth.transferrate.global.throttle.download"})," ",(0,m.jsx)("em",{className:"unit",children:"(B/s)"})]}),id:"throttleGlobalDownSpeed"}),(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleGlobalUpSpeed"),label:(0,m.jsxs)("div",{children:[(0,m.jsx)(d.x6,{id:"settings.bandwidth.transferrate.global.throttle.upload"})," ",(0,m.jsx)("em",{className:"unit",children:"(B/s)"})]}),id:"throttleGlobalUpSpeed"})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.bandwidth.slots.heading"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleMaxUploads"),label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.slots.upload.label"}),id:"throttleMaxUploads"}),(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleMaxUploadsGlobal"),label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.slots.upload.global.label"}),id:"throttleMaxUploadsGlobal"})]}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleMaxDownloads"),label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.slots.download.label"}),id:"throttleMaxDownloads"}),(0,m.jsx)(o.Rj,{defaultValue:Ue(s,"throttleMaxDownloadsGlobal"),label:(0,m.jsx)(d.x6,{id:"settings.bandwidth.slots.download.global.label"}),id:"throttleMaxDownloadsGlobal"})]})]})},Ze=({onClientSettingsChange:e})=>{const[t,s]=(0,n.useState)({});return(0,m.jsxs)(o.lV,{onChange:({event:i})=>{const l={...t,...ze(i)};s(l),e(l)},children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.connectivity.incoming.heading"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"networkPortRange"),id:"networkPortRange",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.port.range.label"}),width:"one-quarter"}),(0,m.jsx)(o.Sc,{defaultChecked:Ue(t,"networkPortRandom"),grow:!1,id:"networkPortRandom",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"settings.connectivity.port.randomize.label"})}),(0,m.jsx)(o.Sc,{defaultChecked:Ue(t,"networkPortOpen"),grow:!1,id:"networkPortOpen",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"settings.connectivity.port.open.label"})})]}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"networkLocalAddress"),id:"networkLocalAddress",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.ip.hostname.label"})}),(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"networkHttpMaxOpen"),id:"networkHttpMaxOpen",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.max.http.connections"})})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.connectivity.dpd.heading"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"dhtPort"),id:"dhtPort",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.dht.port.label"}),width:"one-quarter"}),(0,m.jsx)(o.Sc,{defaultChecked:Ue(t,"dht"),grow:!1,id:"dht",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"settings.connectivity.dht.label"})}),(0,m.jsx)(o.Sc,{defaultChecked:Ue(t,"protocolPex"),grow:!1,id:"protocolPex",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"settings.connectivity.peer.exchange.label"})})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.heading"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"throttleMinPeersNormal"),id:"throttleMinPeersNormal",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.min.label"})}),(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"throttleMaxPeersNormal"),id:"throttleMaxPeersNormal",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.max.label"})})]}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"throttleMinPeersSeed"),id:"throttleMinPeersSeed",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.seeding.min.label"})}),(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"throttleMaxPeersSeed"),id:"throttleMaxPeersSeed",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.seeding.max.label"})})]}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"trackersNumWant"),id:"trackersNumWant",label:(0,m.jsx)(d.x6,{id:"settings.connectivity.peers.desired.label"}),width:"one-half"})})]})};var Qe=s(8440),Je=s(6816),Ye=s(3627),Ke=s(3375),Xe=s(8831),et=s(4979);const tt=e=>{const{children:t,id:s,disabled:i}=e,{attributes:l,setNodeRef:n,listeners:r,transform:a,transition:d,isDragging:o}=(0,Ye.gl)({id:s,disabled:i}),c={transform:et.Ks.Transform.toString(a),transition:d};return(0,m.jsxs)("div",{className:L()("sortable-list__item",{"sortable-list__item--is-dragging":o,"sortable-list__item--is-locked":i}),ref:n,style:c,...l,...r,children:[i?(0,m.jsx)(v.LM,{}):null,t]})},st=({className:e,items:t,lockedIDs:s,renderItem:i,onMouseDown:l,onDrop:r})=>{const[a,d]=(0,n.useState)(t),o=L()("sortable-list",e),c=(0,Ke.MS)(Ke.uN),h=(0,Ke.MS)(Ke.cA,{activationConstraint:{distance:10}}),u=(0,Ke.MS)(Ke.IG,{activationConstraint:{distance:10}});return(0,m.jsx)("div",{className:(0,y.AH)({width:"100%",touchAction:"none"}),role:"none",onMouseDown:e=>{l&&l(e)},children:(0,m.jsx)(Ke.Mp,{sensors:[c,h,u],onDragEnd:({active:e,over:s})=>{if(null==s)return;if(e.id===s.id)return;const i=(0,Ye.be)(t,t.findIndex(t=>t===e.id),t.findIndex(e=>e===s.id));d(i),r&&r(i)},modifiers:[Xe.FN,Xe.gj],autoScroll:!1,children:(0,m.jsx)(Ye.gB,{items:a,strategy:Ye._G,children:(0,m.jsx)("ul",{className:o,children:a.map((e,t)=>(0,m.jsx)(tt,{id:e,disabled:s.includes(e),children:i(e,t)},e))})})})})},it=({onSettingsChange:e})=>{const[t,s]=(0,n.useState)((()=>{const{mountPoints:e}=h.A.floodSettings,t=Object.assign({},...Je.A.disks.map(e=>({[e.target]:e})));return e.filter(e=>e in t).map(e=>({id:e,visible:!0})).concat(Object.keys(t).filter(t=>!e.includes(t)).map(e=>({id:e,visible:!1})))})()),i=t.reduce((e,{id:t,visible:s})=>(e[t]=s,e),{});return(0,m.jsx)(st,{className:"sortable-list--disks",items:t.map(({id:e})=>e),lockedIDs:[],onDrop:e=>{s(e.map(e=>({id:e,visible:i[e]})))},renderItem:l=>{const n=(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--secondary",children:(0,m.jsx)(o.Sc,{defaultChecked:i[l],id:l,onClick:n=>{i[l]=n.target.checked;const r=t.map(e=>e.id===l?{...e,visible:n.target.checked}:e);e({mountPoints:r.filter(e=>e.visible).map(e=>e.id)}),s(r)},children:(0,m.jsx)(d.x6,{id:"settings.diskusage.show"})})});return(0,m.jsxs)("div",{className:"sortable-list__content sortable-list__content__wrapper",children:[(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--primary",children:(0,m.jsx)("div",{children:l})}),n]})}})},lt=({onSettingsChange:e})=>(0,m.jsxs)(o.lV,{children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.diskusage.mount.points"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(it,{onSettingsChange:e})})]}),nt=({onClientSettingsChange:e})=>{const[t,s]=(0,n.useState)({});return(0,m.jsxs)(o.lV,{onChange:({event:i})=>{const l={...t,...ze(i)};s(l),e(l)},children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.resources.disk.heading"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"directoryDefault"),id:"directoryDefault",label:(0,m.jsx)(d.x6,{id:"settings.resources.disk.download.location.label"})})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"networkMaxOpenFiles"),id:"networkMaxOpenFiles",label:(0,m.jsx)(d.x6,{id:"settings.resources.max.open.files"}),width:"one-half"}),(0,m.jsx)(o.Sc,{defaultChecked:Ue(t,"piecesHashOnCompletion"),grow:!1,id:"piecesHashOnCompletion",labelOffset:!0,matchTextboxHeight:!0,children:(0,m.jsx)(d.x6,{id:"settings.resources.disk.check.hash.label"})})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.resources.memory.heading"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Rj,{defaultValue:Ue(t,"piecesMemoryMax"),id:"piecesMemoryMax",label:(0,m.jsxs)("div",{children:[(0,m.jsx)(d.x6,{id:"settings.resources.memory.max.label"})," ",(0,m.jsx)("em",{className:"unit",children:"(MB)"})]}),width:"one-half"})})]})};var rt=s(4455);const at=({className:e,checkboxLabel:t,items:s})=>(0,m.jsx)("div",{className:(0,y.AH)({width:"100%"}),role:"none",children:(0,m.jsx)("ul",{className:L()("sortable-list",e,(0,y.AH)({"& .sortable-list__item":{cursor:"default"}})),children:s.map(e=>{const{id:s,label:i,isLocked:l=!1,defaultChecked:n,onClick:r}=e;return(0,m.jsxs)("li",{className:L()("sortable-list__item",{"sortable-list__item--is-locked":l}),children:[l?(0,m.jsx)(v.LM,{}):null,(0,m.jsxs)("div",{className:"sortable-list__content sortable-list__content__wrapper",children:[(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--primary",children:(0,m.jsx)(d.x6,{id:i})}),l?null:(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--secondary",children:(0,m.jsx)(o.Sc,{defaultChecked:n,id:s,onClick:e=>r?.(e.target.checked),children:t&&(0,m.jsx)(d.x6,{id:t})})})]})]},s||i)})})}),dt=({onSettingsChange:e})=>{const t=(0,n.useRef)(h.A.floodSettings.UIPageTitleSpeedEnabled);return(0,m.jsx)(at,{items:[{label:"settings.ui.page.title.speed",defaultChecked:t.current,onClick:()=>{t.current=!t.current,e({UIPageTitleSpeedEnabled:t.current})}}]})};var ot=s(1693),ct=s(3675);const ht=({onSettingsChange:e})=>{const t=(0,n.useRef)(ct.A.torrentContextMenuActions.map(({id:e,visible:t})=>({id:e,visible:h.A.floodSettings.torrentContextMenuActions.find(t=>t.id===e)?.visible??t})));return(0,m.jsx)(at,{checkboxLabel:"settings.ui.torrent.context.menu.items.show",items:Object.keys(ot.A).map(s=>({label:ot.A[s],isLocked:"start"===s||"stop"===s||"setTaxonomy"===s||"torrentDetails"===s,defaultChecked:t.current.some(e=>e.id===s&&e.visible),onClick:()=>{const i=t.current.find(e=>e.id===s);null!=i&&(i.visible=!i.visible),e({torrentContextMenuActions:t.current})}}))})};var ut=s(2607),xt=s(2189);const _t=({torrentListViewSize:e,onSettingsChange:t})=>{const s=(0,n.useRef)(null),[i,l]=(0,n.useState)([...h.A.floodSettings.torrentListColumns.filter(e=>null!=ut.A[e.id]).slice(),...Object.keys(ut.A).filter(e=>h.A.floodSettings.torrentListColumns.every(t=>t.id!==e)).map(e=>({id:e,visible:!1}))]),r=i.reduce((e,{id:t,visible:s})=>(e[t]=s,e),{}),a="expanded"===e?["name","eta","downRate","percentComplete","downTotal","upRate"]:[];return(0,m.jsx)(st,{className:"sortable-list--torrent-details",items:i.map(({id:e})=>e),lockedIDs:a,onMouseDown:()=>{s.current?.dismissTooltip()},onDrop:e=>{const s=e.map(e=>({id:e,visible:r[e]}));t({torrentListColumns:s}),l(s)},renderItem:(n,c)=>{let h=null,u=null;if(a.includes(n)||(h=(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--secondary",children:(0,m.jsx)(o.Sc,{defaultChecked:r[n],id:n,onClick:e=>{r[n]=e.target.checked;const s=i.map(t=>({id:t.id,visible:t.id===n?e.target.checked:t.visible}));l(s),t({torrentListColumns:s})},children:(0,m.jsx)(d.x6,{id:"settings.ui.torrent.details.enabled"})})})),"tags"===n&&"expanded"===e&&c<i.length-1){const e=(0,m.jsx)(d.x6,{id:"settings.ui.torrent.details.tags.placement"});u=(0,m.jsx)(xt.A,{className:"tooltip tooltip--is-error",content:e,offset:-5,ref:s,width:200,wrapperClassName:"sortable-list__content sortable-list__content--secondary tooltip__wrapper",wrapText:!0,children:(0,m.jsx)(v.$D,{})})}return(0,m.jsxs)("div",{className:"sortable-list__content sortable-list__content__wrapper",children:[u,(0,m.jsx)("span",{className:"sortable-list__content sortable-list__content--primary",children:(0,m.jsx)(d.x6,{id:ut.A[n]})}),h]})}})},mt=({onSettingsChange:e})=>{const{i18n:t}=(0,d.uB)(),[s,i]=(0,n.useState)(h.A.floodSettings.torrentListViewSize),[l,r]=(0,n.useState)(h.A.floodSettings.language),[a,c]=(0,n.useState)(h.A.floodSettings.UITagSelectorMode);return(0,m.jsxs)(o.lV,{onChange:({event:t,formData:l})=>{const n=t.target;if("radio"===n.type&&(i(l["ui-torrent-size"]),c(l["ui-tag-selector-mode"]),e({torrentListViewSize:s,UITagSelectorMode:a})),"language"===n.name){const t=l.language;r(t),e({language:t})}},children:[(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.language"})},"locale-header"),(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.l6,{defaultID:l,id:"language",children:Object.keys(rt.A).map(e=>(0,m.jsx)(o.eb,{id:e,children:"auto"===e?t._(rt.A[e].id):rt.A[e]},e))})},"locale-selection"),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.tag.selector.mode"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.sx,{defaultChecked:"single"===a,groupID:"ui-tag-selector-mode",id:"single",width:"auto",children:(0,m.jsx)(d.x6,{id:"settings.ui.tag.selector.mode.single"})}),(0,m.jsx)(o.sx,{defaultChecked:"multi"===a,groupID:"ui-tag-selector-mode",id:"multi",width:"auto",children:(0,m.jsx)(d.x6,{id:"settings.ui.tag.selector.mode.multi"})})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.torrent.list"})}),(0,m.jsxs)(o.fh,{children:[(0,m.jsx)(o.sx,{defaultChecked:"expanded"===s,groupID:"ui-torrent-size",id:"expanded",width:"auto",children:(0,m.jsx)(d.x6,{id:"settings.ui.torrent.size.expanded"})}),(0,m.jsx)(o.sx,{defaultChecked:"condensed"===s,groupID:"ui-torrent-size",id:"condensed",width:"auto",children:(0,m.jsx)(d.x6,{id:"settings.ui.torrent.size.condensed"})})]}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.displayed.details"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(_t,{torrentListViewSize:s,onSettingsChange:e})}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.displayed.context.menu.items"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(ht,{onSettingsChange:e})}),(0,m.jsx)(de,{children:(0,m.jsx)(d.x6,{id:"settings.ui.misc"})}),(0,m.jsx)(o.fh,{children:(0,m.jsx)(dt,{onSettingsChange:e})})]})},jt=(0,r.PA)(()=>{const{i18n:e}=(0,d.uB)(),[t,s]=(0,n.useState)({}),[i,l]=(0,n.useState)({}),[r,a]=(0,n.useState)(!1),o=e=>{s({...t,...e})},h=e=>{l({...i,...e})},u={bandwidth:{content:Ge,props:{onClientSettingsChange:o,onSettingsChange:h},label:e._("settings.tabs.bandwidth")},connectivity:{content:Ze,props:{onClientSettingsChange:o},label:e._("settings.tabs.connectivity")},resources:{content:nt,props:{onClientSettingsChange:o},label:e._("settings.tabs.resources")},..."none"!==q.A.authMethod?{authentication:{content:Oe,label:e._("settings.tabs.authentication")}}:{},ui:{content:mt,label:e._("settings.tabs.userinterface"),props:{onSettingsChange:h}},diskusage:{content:lt,label:e._("settings.tabs.diskusage"),props:{onSettingsChange:h}},about:{content:Le,label:e._("settings.tabs.about")}};return(0,m.jsx)(Q,{actions:[{clickHandler:null,content:e._("button.cancel"),triggerDismiss:!0,type:"tertiary"},{clickHandler:()=>{a(!0),Promise.all([c.A.saveSettings(i,{alert:!0}),Qe.A.saveSettings(t,{alert:!0})]).then(()=>{a(!1),_.A.setActiveModal(null)})},isLoading:r,content:e._("button.save"),triggerDismiss:!1,type:"primary"}],size:"large",heading:e._("settings.tabs.heading"),orientation:q.A.isSmallScreen?"horizontal":"vertical",tabs:u})}),gt=()=>{const{i18n:e}=(0,d.uB)(),t=(0,n.useRef)(K.A.CancelToken.source()),s=(0,n.useRef)(null),[i,l]=(0,n.useState)(null),[r,a]=(0,n.useState)(null),[c,h]=(0,n.useState)(!0),[u,j]=(0,n.useState)(!1);(0,n.useEffect)(()=>{const{current:e}=t;return"torrent-details"===_.A.activeModal?.id&&x.A.fetchMediainfo(_.A.activeModal?.hash,t.current.token).then(e=>{l(e.output),h(!1)},e=>{K.A.isCancel(e)||(a(e.response.data),h(!1))}),()=>{e.cancel()}},[]);let g="mediainfo.heading";return c?g="mediainfo.fetching":r&&(g="mediainfo.execError"),(0,m.jsxs)("div",{className:"torrent-details__section mediainfo modal__content--nested-scroll__content",children:[(0,m.jsxs)("div",{className:"mediainfo__toolbar",children:[(0,m.jsx)("div",{className:"mediainfo__toolbar__item",children:(0,m.jsx)("span",{className:"torrent-details__table__heading--tertiary",children:(0,m.jsx)(d.x6,{id:g})})}),i&&(0,m.jsx)(xt.A,{content:e._(u?"general.clipboard.copied":"general.clipboard.copy"),wrapperClassName:"tooltip__wrapper mediainfo__toolbar__item",children:(0,m.jsx)(o.$n,{priority:"tertiary",onClick:()=>{null!=i&&("function"==typeof navigator.clipboard?.writeText?navigator.clipboard.writeText(i).then(()=>{j(!0)}):null!=s.current&&(s.current.value=i,s.current.select(),document.execCommand("copy"),j(!0)))},children:u?(0,m.jsx)(v.MG,{}):(0,m.jsx)(v.B0,{})})})]}),(0,m.jsx)("input",{ref:s,style:{width:"0.1px",height:"1px",position:"absolute",right:0}}),r?(0,m.jsx)("pre",{className:"mediainfo__output mediainfo__output--error",children:r.message}):(0,m.jsx)("pre",{className:"mediainfo__output",children:i})]})},ft=(e,t)=>({...e,...null!=e.directories?{directories:Object.assign({},...Object.keys(e.directories).map(s=>null!=e.directories?{[s]:ft(e.directories[s],t)}:{}))}:{},...null!=e.files?{files:Object.assign({},...Object.keys(e.files).map(s=>null!=e.files?{[s]:{...e.files[s],isSelected:t}}:{}))}:{},isSelected:t}),pt=(e,t,s=0)=>{const{depth:i,path:l,select:n,type:r}=t,a=l[s];if(s===i-1){if("file"===r&&null!=e.files?.[a]){const t={...e.files,[a]:{...e.files[a],isSelected:n}};return{...e,files:t,isSelected:Object.values(t).every(({isSelected:e})=>e)&&(null==e.directories||Object.values(e.directories).every(({isSelected:e})=>e))}}if("directory"===r&&null!=e.directories){const t={...e.directories,[a]:ft(e.directories[a],n)};return{...e,directories:t,isSelected:Object.values(t).every(({isSelected:e})=>e)&&(null==e.files||Object.values(e.files).every(({isSelected:e})=>e))}}return e}if(null!=e.directories){const i=e.directories;return Object.keys(i).forEach(e=>{e===a&&(i[e]=pt(i[e],t,s+1))}),{...e,directories:i,isSelected:Object.values(i).every(({isSelected:e})=>e)}}return e},bt=e=>{const t=[];if(null!=e.files){const{files:s}=e;Object.keys(s).forEach(e=>{const i=s[e];i.isSelected&&t.push(i.index)})}if(null!=e.directories){const{directories:s}=e;Object.keys(s).forEach(e=>{t.push(...bt(s[e]))})}return t},vt={selectAll:ft,applySelection:pt,getSelectedItems:bt,getSelectionTree:(e,t=!1)=>{const s={isSelected:t};return e.forEach(e=>{const i=e.path.split("/");let l=s;for(;i.length-1;){const e=i.shift();null==l.directories&&(l.directories={}),null==l.directories[e]&&(l.directories[e]={isSelected:t}),l=l.directories[e]}null==l.files&&(l.files={}),l.files[e.filename]={...e,isSelected:t}}),s}};var yt=s(9689),kt=s(7189);const Nt=({depth:e,items:t,hash:s,path:i,onItemSelect:l})=>{const[r,a]=(0,n.useState)(null),d=(0,n.useRef)({});if(null==t)return null;const c=Object.values(t).sort((e,t)=>e.filename.localeCompare(t.filename)).map(n=>{const c=t&&t[n.filename]&&t[n.filename].isSelected||!1,h=L()("directory-tree__node file","directory-tree__node--file directory-tree__node--selectable",{"directory-tree__node--selected":c});return(0,m.jsxs)("div",{className:h,title:n.filename,children:[(0,m.jsxs)("div",{className:"file__label file__detail",children:[(0,m.jsxs)("div",{className:"file__checkbox directory-tree__checkbox",children:[(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--checkbox",children:(0,m.jsx)(o.Sc,{checked:c,id:`${n.index}`,onClick:()=>l({type:"file",depth:e,path:[...i,n.filename],select:!c})})}),(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--icon",children:(0,m.jsx)(v.ZH,{})})]}),(0,m.jsx)("div",{className:"file__name",children:(0,m.jsx)("a",{href:`${q.A.baseURI}api/torrents/${s}/contents/${n.index}/data`,style:{textDecoration:"none"},target:"_blank",rel:"noreferrer",children:n.filename})})]}),(0,m.jsx)("div",{className:"file__detail file__detail--secondary",children:(0,m.jsx)(kt.A,{value:n.sizeBytes,precision:1})}),(0,m.jsxs)("div",{className:"file__detail file__detail--secondary",children:[Math.trunc(n.percentComplete),"%"]}),(0,m.jsx)("div",{className:"file__detail file__detail--secondary file__detail--priority",children:(0,m.jsx)(yt.A,{level:n.priority,id:n.index,maxLevel:2,onChange:(e,t)=>x.A.setFilePriority(s,{indices:[Number(e)],priority:t}),priorityType:"file"},`${n.index}-${n.filename}`)}),"function"==typeof navigator.clipboard?.writeText&&(0,m.jsx)("button",{className:"file__detail file__detail--secondary file__detail--clipboard",type:"button",onClick:()=>{const e=e=>{""!==e&&("function"==typeof navigator.share?navigator.share({title:n.filename,url:e}).then(()=>a(n.index)):navigator.clipboard.writeText(e).then(()=>a(n.index)))},t=d.current[n.index];null!=t?e(t):(d.current[n.index]="",x.A.getTorrentContentsDataPermalink(s,[n.index]).then(t=>{d.current[n.index]=t,e(t)},()=>{d.current[n.index]=null}))},children:r===n.index?(0,m.jsx)(v.MG,{}):(0,m.jsx)(v.B0,{})})]},n.filename)});return(0,m.jsx)("div",{className:"directory-tree__node directory-tree__node--file-list",children:c})},At=({depth:e,directoryName:t,id:s,itemsTree:i,hash:l,path:r,isSelected:a,onItemSelect:d})=>{const[c,h]=(0,n.useState)(!1),u=[...r,t];return(0,m.jsxs)("div",{className:L()("directory-tree__branch",`directory-tree__branch--depth-${e}`,{"directory-tree__node--selected":a}),children:[(0,m.jsx)("button",{className:L()("directory-tree__node","directory-tree__node--selectable directory-tree__node--directory",(0,y.AH)({width:"100%",textAlign:"left",_focus:{outline:"none",WebkitTapHighlightColor:"transparent"},_focusVisible:{outline:"dashed"}}),{"is-expanded":c}),type:"button",onClick:()=>h(!c),title:t,children:(0,m.jsxs)("div",{className:"file__label",children:[(0,m.jsxs)("div",{className:"file__checkbox directory-tree__checkbox",children:[(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--checkbox",children:(0,m.jsx)(o.Sc,{checked:a,id:s,onClick:()=>d({type:"directory",depth:e,path:u,select:!a})})}),(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--icon",children:c?(0,m.jsx)(v.gx,{}):(0,m.jsx)(v.Ah,{})})]}),(0,m.jsx)("div",{className:"file__name",children:t})]})}),c?(0,m.jsx)("div",{className:"directory-tree__node directory-tree__node--group",children:(0,m.jsx)(St,{depth:e,hash:l,onItemSelect:d,path:u,itemsTree:i},`${c}-${e}`)}):null]})},St=e=>{const{depth:t=0,itemsTree:s,hash:i,path:l,onItemSelect:n}=e,{files:r,directories:a}=s,d=t+1,o=null!=a?Object.keys(a).sort((e,t)=>e.localeCompare(t)).map((e,t)=>{const r=s.directories&&s.directories[e],a=`${t}${d}${e}`,o=r&&r.isSelected||!1;return null==r?null:(0,m.jsx)(At,{depth:d,directoryName:e,hash:i,id:a,isSelected:o,itemsTree:r,onItemSelect:n,path:l},a)}):[],c=null!=r&&Object.keys(r).length>0?(0,m.jsx)(Nt,{depth:d,hash:i,onItemSelect:n,path:l,items:s.files},`files-${d}`):null;return(0,m.jsx)("div",{className:"directory-tree__tree",children:o.concat(c)})},wt=(0,r.PA)(()=>{const[e,t]=(0,n.useState)([]),[s,i]=(0,n.useState)({}),[l,r]=(0,n.useState)([]),{i18n:a}=(0,d.uB)();if((0,n.useEffect)(()=>{"torrent-details"===_.A.activeModal?.id&&x.A.fetchTorrentContents(_.A.activeModal?.hash).then(e=>{null!=e&&(t(e),i(vt.getSelectionTree(e)))})},[]),"torrent-details"!==_.A.activeModal?.id)return null;const{hash:c}=_.A.activeModal;let h=null,u=null,j=!1;e?.length>0?(j=l.length>=e.length,h=(0,m.jsxs)("div",{className:"file__checkbox directory-tree__checkbox",children:[(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--checkbox",children:(0,m.jsx)(o.fh,{children:(0,m.jsx)(o.Sc,{checked:j,id:"select-all",onClick:()=>{const t=vt.getSelectionTree(e,l.length<e.length);i(t),r(vt.getSelectedItems(t))}})})}),(0,m.jsx)("div",{className:"directory-tree__checkbox__item directory-tree__checkbox__item--icon",children:(0,m.jsx)(v.my,{})})]}),u=(0,m.jsx)(St,{depth:0,onItemSelect:e=>{const t=vt.applySelection(s,e);i(t),r(vt.getSelectedItems(t))},hash:c,path:[],itemsTree:s})):(h=(0,m.jsx)(v.my,{}),u=(0,m.jsx)("div",{className:"directory-tree__node directory-tree__node--file",children:(0,m.jsx)(d.x6,{id:"torrents.details.files.loading"})}));const g=L()("directory-tree__node","directory-tree__parent-directory torrent-details__section__heading",{"directory-tree__node--selected":j}),f=(0,m.jsx)("div",{className:g,children:(0,m.jsxs)("div",{className:"file__label",children:[h,(0,m.jsx)("div",{className:"file__name",children:Ne.A.torrents?.[c].directory})]})}),p=L()("inverse directory-tree__wrapper",{"directory-tree__wrapper--toolbar-visible":l.length>0});return(0,m.jsxs)(o.lV,{className:p,onChange:({event:e})=>{if(null!=e.target&&"file-priority"===e.target.name){const t=e.target;t.value&&x.A.setFilePriority(c,{indices:l,priority:Number(t.value)})}},children:[(0,m.jsx)("div",{className:"directory-tree__selection-toolbar",children:(0,m.jsxs)(o.fh,{align:"center",children:[(0,m.jsx)(o.ci,{width:"one-quarter",grow:!1,shrink:!1,children:(0,m.jsx)(d.x6,{id:"torrents.details.selected.files",values:{count:l.length,countElement:(0,m.jsx)("span",{className:"directory-tree__selection-toolbar__item-count",children:l.length})}})}),(0,m.jsx)(o.$n,{onClick:e=>{e.preventDefault();const{baseURI:t}=q.A,s=document.createElement("a");s.download="",s.href=`${t}api/torrents/${c}/contents/${l.join(",")}/data`,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)},grow:!1,shrink:!1,children:(0,m.jsx)(d.x6,{id:"torrents.details.files.download.file",values:{count:l.length}})}),(0,m.jsxs)(o.l6,{id:"file-priority",persistentPlaceholder:!0,shrink:!1,defaultID:"",children:[(0,m.jsx)(o.eb,{id:-1,isPlaceholder:!0,children:(0,m.jsx)(d.x6,{id:"torrents.details.selected.files.set.priority"})}),(0,m.jsx)(o.eb,{id:0,children:a._("priority.dont.download")}),(0,m.jsx)(o.eb,{id:1,children:a._("priority.normal")}),(0,m.jsx)(o.eb,{id:2,children:a._("priority.high")})]})]})}),(0,m.jsxs)("div",{className:"directory-tree torrent-details__section torrent-details__section--file-tree modal__content--nested-scroll__content",children:[f,u]})]})}),Ct=wt;const Tt=({text:e,className:t})=>{const s=e.split(/([ \n])/).map((e,t)=>"\n"===e?(0,m.jsx)("br",{},t):function(e){let t;try{t=new URL(e)}catch{return!1}return"http:"===t.protocol||"https:"===t.protocol}(e)?(0,m.jsx)("a",{href:e.trimEnd(),target:"_blank",rel:"noopener noreferrer",children:e},t):e);return(0,m.jsx)("span",{className:t,children:s})},Rt=(0,r.PA)(()=>{const{i18n:e}=(0,d.uB)();if("torrent-details"!==_.A.activeModal?.id)return null;const t=Ne.A.torrents[_.A.activeModal.hash];if(null==t)return null;const s=(0,m.jsx)("span",{className:"not-available",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.none"})});return(0,m.jsx)("div",{className:"torrent-details__section torrent-details__section--general",children:(0,m.jsx)("table",{className:"torrent-details__table table",children:(0,m.jsxs)("tbody",{children:[(0,m.jsx)("tr",{className:"torrent-details__table__heading",children:(0,m.jsx)("td",{className:"torrent-details__table__heading--tertiary",colSpan:2,children:(0,m.jsx)(d.x6,{id:"torrents.details.general.heading.general"})})}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--dateAdded",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.date.added"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.dateAdded>0?e.date(new Date(1e3*t.dateAdded),{year:"numeric",month:"long",day:"2-digit",hour:"numeric",minute:"numeric"}):s})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--location",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.location"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.directory})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--tags",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.tags"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.tags.length?(i=t.tags,i.map(e=>(0,m.jsx)("span",{className:"tag",children:e},e))):s})]}),(0,m.jsx)("tr",{className:"torrent-details__table__heading",children:(0,m.jsx)("td",{className:"torrent-details__table__heading--tertiary",colSpan:2,children:(0,m.jsx)(d.x6,{id:"torrents.details.general.heading.transfer"})})}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--dateFinished",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.date.finished"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.dateFinished>0?e.date(new Date(1e3*t.dateFinished),{year:"numeric",month:"long",day:"2-digit",hour:"numeric",minute:"numeric"}):s})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--downloaded",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.downloaded"})}),(0,m.jsxs)("td",{className:"torrent-details__detail__value",children:[e.number(t.percentComplete),(0,m.jsx)("em",{className:"unit",children:"%"})]})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--peers",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.peers"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.connected",values:{connectedCount:t.peersConnected,connected:e.number(t.peersConnected),total:e.number(t.peersTotal)}})})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--seeds",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.seeds"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.connected",values:{connectedCount:t.seedsConnected,connected:e.number(t.seedsConnected),total:e.number(t.seedsTotal)}})})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--dateActive",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.date.active"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:0===t.dateActive?s:-1===t.dateActive?e._("torrents.details.general.date.active.now"):e.date(new Date(1e3*t.dateActive),{year:"numeric",month:"long",day:"2-digit",hour:"numeric",minute:"numeric"})})]}),(0,m.jsx)("tr",{className:"torrent-details__table__heading",children:(0,m.jsx)("td",{className:"torrent-details__table__heading--tertiary",colSpan:2,children:(0,m.jsx)(d.x6,{id:"torrents.details.general.heading.torrent"})})}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--created",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.date.created"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.dateCreated>0?e.date(new Date(1e3*t.dateCreated),{year:"numeric",month:"long",day:"2-digit",hour:"numeric",minute:"numeric"}):s})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--hash",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.hash"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.hash})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--size",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.size"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:(0,m.jsx)(kt.A,{value:t.sizeBytes})})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--type",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.type"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.isPrivate?e._("torrents.details.general.type.private"):e._("torrents.details.general.type.public")})]}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--comment",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.comment"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.comment?(0,m.jsx)(Tt,{text:t.comment.trim()}):s})]}),(0,m.jsx)("tr",{className:"torrent-details__table__heading",children:(0,m.jsx)("td",{className:"torrent-details__table__heading--tertiary",colSpan:2,children:(0,m.jsx)(d.x6,{id:"torrents.details.general.heading.tracker"})})}),(0,m.jsxs)("tr",{className:"torrent-details__detail torrent-details__detail--tracker-message",children:[(0,m.jsx)("td",{className:"torrent-details__detail__label",children:(0,m.jsx)(d.x6,{id:"torrents.details.general.tracker.message"})}),(0,m.jsx)("td",{className:"torrent-details__detail__value",children:t.message?t.message:s})]})]})})});var i});var Dt=s(2471),Mt=s(3230),Pt=s(1915);const It=(0,r.PA)(()=>{const{i18n:e}=(0,d.uB)(),t="torrent-details"===_.A.activeModal?.id?Ne.A.torrents[_.A.activeModal.hash]:void 0,[s,i]=(0,n.useState)("stop");if((0,n.useEffect)(()=>{t?.status.includes("stopped")?i("stop"):i("start")},[t?.status]),null==t)return null;const l=(0,Dt.$)({status:t.status,upRate:t.upRate,downRate:t.downRate},"torrent-details__header");return(0,m.jsxs)("div",{className:l,children:[(0,m.jsx)("h1",{className:"torrent-details__heading torrent-details--name",children:t.name}),(0,m.jsxs)("div",{className:"torrent-details__sub-heading",children:[(0,m.jsxs)("ul",{className:"torrent-details__sub-heading__secondary",children:[(0,m.jsxs)("li",{className:"torrent-details__sub-heading__tertiary torrent-details__sub-heading__tertiary--download",children:[(0,m.jsx)(v.Cx,{}),(0,m.jsx)(kt.A,{value:t.downRate,isSpeed:!0})," — ",(0,m.jsx)(kt.A,{value:t.bytesDone})]}),(0,m.jsxs)("li",{className:"torrent-details__sub-heading__tertiary torrent-details__sub-heading__tertiary--upload",children:[(0,m.jsx)(v.NM,{}),(0,m.jsx)(kt.A,{value:t.upRate,isSpeed:!0})," — ",(0,m.jsx)(kt.A,{value:t.upTotal})]}),(0,m.jsxs)("li",{className:"torrent-details__sub-heading__tertiary",children:[(0,m.jsx)(v.wj,{}),e.number(t.ratio)]}),(0,m.jsxs)("li",{className:"torrent-details__sub-heading__tertiary",children:[(0,m.jsx)(v.zD,{}),(0,m.jsx)(Mt.A,{value:t.eta})]})]}),(0,m.jsxs)("ul",{className:"torrent-details__sub-heading__secondary",children:[(0,m.jsx)("li",{className:"torrent-details__sub-heading__tertiary",children:(0,m.jsx)(yt.A,{id:t.hash,level:t.priority,maxLevel:3,priorityType:"torrent",onChange:(e,t)=>{x.A.setPriority({hashes:[`${e}`],priority:t})}})},"priority-meter"),(0,m.jsx)("li",{className:"torrent-details__sub-heading__tertiary",children:(0,m.jsxs)("button",{className:L()("torrent-details__action",{"is-active":"start"===s}),type:"button",onClick:()=>{i("start"),x.A.startTorrents({hashes:[t.hash]})},children:[(0,m.jsx)(v.fe,{}),(0,m.jsx)(d.x6,{id:"torrents.details.actions.start"})]})},"start"),(0,m.jsx)("li",{className:"torrent-details__sub-heading__tertiary",children:(0,m.jsxs)("button",{className:L()("torrent-details__action",{"is-active":"stop"===s}),type:"button",onClick:()=>{i("stop"),x.A.stopTorrents({hashes:[t.hash]})},children:[(0,m.jsx)(v.VG,{}),(0,m.jsx)(d.x6,{id:"torrents.details.actions.stop"})]})},"stop")]})]}),(0,m.jsx)(Pt.A,{percent:(0,X.EW)(()=>Math.ceil(t.percentComplete)).get(),status:(0,X.EW)(()=>(0,Dt.s)(t.status)).get()})]})});var $t=s(940),Vt=s(6541);const Lt=()=>{const[e,t]=(0,n.useState)([]),[s,i]=(0,n.useState)(null),l=()=>{i(null),"torrent-details"===_.A.activeModal?.id&&x.A.fetchTorrentPeers(_.A.activeModal?.hash).then(e=>{null!=e&&t(e)}),i(q.A.pollInterval)};return(0,n.useEffect)(()=>l(),[]),(0,$t.A)(()=>l(),s),(0,m.jsx)("div",{className:"torrent-details__section torrent-details__section--peers",children:(0,m.jsxs)("table",{className:`torrent-details__table table ${(0,y.AH)({"& td":{maxWidth:"140px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}})}`,children:[(0,m.jsx)("thead",{className:"torrent-details__table__heading",children:(0,m.jsxs)("tr",{children:[(0,m.jsxs)("th",{className:"torrent-details__table__heading--primary",children:[(0,m.jsx)(d.x6,{id:"torrents.details.peers"}),(0,m.jsx)(Vt.A,{children:e.length})]}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"DL"}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"UL"}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"%"}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"Client"}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"Enc"}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:"In"})]})}),(0,m.jsx)("tbody",{children:e.map(e=>{const{country:t}=e,s=e.isEncrypted?(0,m.jsx)(v.LM,{}):null,i=e.isIncoming?(0,m.jsx)(v.H4,{}):null;return(0,m.jsxs)("tr",{children:[(0,m.jsxs)("td",{children:[(0,m.jsxs)("span",{className:"peers-list__flag",children:[(0,m.jsx)(n.Suspense,{fallback:(0,m.jsx)(v.y$,{}),children:(0,m.jsx)(v.J9,{countryCode:t})}),(0,m.jsx)("span",{className:"peers-list__flag__text",children:t})]}),e.address]}),(0,m.jsx)("td",{children:(0,m.jsx)(kt.A,{value:e.downloadRate,isSpeed:!0})}),(0,m.jsx)("td",{children:(0,m.jsx)(kt.A,{value:e.uploadRate,isSpeed:!0})}),(0,m.jsx)("td",{children:`${Math.ceil(e.completedPercent)}%`}),(0,m.jsx)("td",{children:e.clientVersion}),(0,m.jsx)("td",{className:"peers-list__encryption",children:s}),(0,m.jsx)("td",{className:"peers-list__incoming",children:i})]},e.address)})})]})})},Ht=()=>{const[e,t]=(0,n.useState)([]),s=e.length,i=["http","udp","dht"],l=e.map(e=>(0,m.jsxs)("tr",{children:[(0,m.jsx)("td",{className:"torrent-details__trackers--url",children:e.url}),(0,m.jsx)("td",{children:i[e.type-1]})]},e.url));return(0,n.useEffect)(()=>{"torrent-details"===_.A.activeModal?.id&&x.A.fetchTorrentTrackers(_.A.activeModal?.hash).then(e=>{null!=e&&t(e)})},[]),(0,m.jsx)("div",{className:"torrent-details__trackers torrent-details__section",children:(0,m.jsxs)("table",{className:"torrent-details__table table",children:[(0,m.jsx)("thead",{className:"torrent-details__table__heading",children:(0,m.jsxs)("tr",{children:[(0,m.jsxs)("th",{className:"torrent-details__table__heading--primary",children:[(0,m.jsx)(d.x6,{id:"torrents.details.trackers"}),(0,m.jsx)(Vt.A,{children:s})]}),(0,m.jsx)("th",{className:"torrent-details__table__heading--secondary",children:(0,m.jsx)(d.x6,{id:"torrents.details.trackers.type"})})]})}),(0,m.jsx)("tbody",{children:l})]})})},Ft=(0,r.PA)(()=>{const{i18n:e}=(0,d.uB)(),{isSmallScreen:t}=q.A,s={"torrent-details":{content:Rt,label:e._("torrents.details.details")},"torrent-contents":{content:Ct,label:e._("torrents.details.files"),modalContentClasses:"modal__content--nested-scroll"},"torrent-peers":{content:Lt,label:e._("torrents.details.peers")},"torrent-trackers":{content:Ht,label:e._("torrents.details.trackers")},"torrent-mediainfo":{content:gt,label:e._("torrents.details.mediainfo"),modalContentClasses:"modal__content--nested-scroll"}};return(0,m.jsx)(Q,{heading:(0,m.jsx)(It,{},"torrent-heading"),size:"large",tabs:s,orientation:t?"horizontal":"vertical",tabsInBody:!t})}),Et=e=>{switch(e){case"add-torrents":return(0,m.jsx)(J,{});case"confirm":return(0,m.jsx)(Y,{});case"feeds":return(0,m.jsx)(ke,{});case"generate-magnet":return(0,m.jsx)(we,{});case"move-torrents":return(0,m.jsx)(Te,{});case"remove-torrents":return(0,m.jsx)(Re,{});case"set-taxonomy":return(0,m.jsx)(De,{});case"set-trackers":return(0,m.jsx)(Me,{});case"settings":return(0,m.jsx)(jt,{});case"torrent-details":return(0,m.jsx)(Ft,{});default:return null}},Bt=(0,r.PA)(()=>{const{id:e}=_.A.activeModal||{};let t;return(0,a.A)("Escape",()=>_.A.setActiveModal(null)),null!=e&&(t=(0,m.jsx)(i.A,{classNames:"modal__animation",timeout:{enter:500,exit:500},children:(0,m.jsxs)("div",{className:"modal",children:[(0,m.jsx)("div",{className:"modal__overlay",role:"none",onClick:()=>{_.A.setActiveModal(null)}}),Et(e)]})},e)),(0,m.jsx)(l.A,{children:t})})}}]);
|