UNPKG

flood

Version:

A modern Web UI for various torrent clients with multi-user and multi-client support

1 lines 86.6 kB
"use strict";(globalThis.webpackChunkflood=globalThis.webpackChunkflood||[]).push([[179],{179:(e,t,i)=>{i.r(t),i.d(t,{default:()=>di});var l=i(6488),n=i(2618),r=i(4015),a=i(9679),s=i(3160),d=i(6540),o=i(6565),c=i(9075),h=i(2412);const u=({start:e,destination:t,tags:i,tab:l})=>{const n={};null!=e&&(n.startTorrentsOnLoad=e),null!=t&&""!==t&&(null==n.torrentDestinations&&(n.torrentDestinations=h.A.floodSettings.torrentDestinations||{}),"string"==typeof i?.[0]?n.torrentDestinations[i[0]]=t:n.torrentDestinations[""]=t),null!=l&&(n.UITorrentsAddTab=l),c.A.saveSettings(n)};var _=i(3537),m=i(4930),g=i(2445);const f=e=>{const{actions:t}=e,i=t.map(((e,t)=>{let i=()=>{};return e.triggerDismiss&&(i=()=>{m.A.setActiveModal(null)}),"checkbox"===e.type?(0,g.Y)(o.Sc,{defaultChecked:e.checked,id:e.id,onClick:t=>{null!=e.clickHandler&&e.clickHandler(t),i()},children:e.content},t):(0,g.Y)(o.$n,{isLoading:e.isLoading,onClick:t=>{null!=e.clickHandler&&e.clickHandler(t),i()},priority:e.type,type:e.submit?"submit":"button",children:e.content},t)})),l=(0,g.Y)("div",{className:"modal__button-group",children:i});return(0,g.Y)("div",{className:"modal__actions",children:l})},p=({isAddingTorrents:e,onAddTorrentsClick:t})=>{const{i18n:i}=(0,s.uB)();return(0,g.Y)(f,{actions:[{checked:Boolean(h.A.floodSettings.startTorrentsOnLoad),clickHandler:null,content:i._("torrents.add.start.label"),id:"start",triggerDismiss:!1,type:"checkbox"},{clickHandler:null,content:i._("button.cancel"),triggerDismiss:!0,type:"tertiary"},{clickHandler:t,content:i._("torrents.add.button.add"),isLoading:e,submit:!0,triggerDismiss:!1,type:"primary"}]})};var b=i(8221),Y=i.n(b),v=i(5162),y=i(942),x=i(7437),k=i(3863),N=i(9844),D=i(2114),S=i(8851),w=i(2592);const A="#5E728C",F={name:"1pkdvdx",styles:"padding:3px 9px"},C=(0,x.AH)({borderBottom:`1px solid ${(0,k.a)(.43,A)}`,marginBottom:"3px",paddingBottom:"3px",opacity:.75,"&:last-child":{marginBottom:0}},"",""),T=(0,x.AH)({opacity:.5,transition:"color 0.25s",whiteSpace:"nowrap",button:[F,{width:"100%",height:"100%",padding:"3px 9px",textAlign:"left","&:disabled":{pointerEvents:"none"}}]},"",""),R=(0,x.AH)({color:(0,k.Ih)(.1,(0,k.e$)(.15,A)),background:(0,k.B3)(A,.1),button:{":focus":{outline:"none",WebkitTapHighlightColor:"transparent"}}},"",""),P=(0,x.AH)({opacity:1,cursor:"pointer",transition:"background 0.25s, color 0.25s",userSelect:"none","&:hover":R,"&:focus-within":R},"",""),M={EACCES:"filesystem.error.eacces",ENOENT:"filesystem.error.enoent"};var j={name:"kol7nt",styles:"transform:scale(0.75) rotate(180deg)"},I={name:"1089mxj",styles:"white-space:pre-wrap"},V={name:"1ityoz",styles:"font-weight:lighter"};const L=(0,d.memo)((({directory:e,selectable:t,onItemSelection:i,onYieldFocus:l})=>{const[n,r]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),[c,h]=(0,d.useState)(e.includes("/")?"/":"\\"),[u,_]=(0,d.useState)(null),[m,f]=(0,d.useState)(null),p=(0,d.useRef)(null),b=e.lastIndexOf(c)+1,Y=b>0?e.substr(0,b):e,v=e.substr(b);(0,d.useEffect)((()=>{Y&&(r(null),_(null),f(null),S.A.fetchDirectoryList(Y).then((({files:e,directories:t,separator:i})=>{_(t),f(e),h(i),o(null)})).catch((({response:e})=>{o(e)})))}),[Y]),(0,d.useEffect)((()=>{if(null!=p.current&&null!=n){const e=p.current.children[n]?.children[0];0===e?.tabIndex?e.focus():r(Array.from(p.current.children).findIndex((e=>0===e.children[0].tabIndex)))}}),[n]),(0,D.A)("ArrowUp",(e=>{e.preventDefault(),r((e=>null==e||e-1<0?(l?.(),null):e-1))})),(0,D.A)("ArrowDown",(e=>{e.preventDefault(),r((e=>null!=e?e+1:0))}));let k=null,R=[];if((null==u&&"directories"===t||null==m&&"files"===t)&&(k="filesystem.fetching"),a&&a.data&&a.data.code&&(k=M[a.data.code]||"filesystem.error.unknown"),e){const e=`${Y.split(c).slice(0,-2).join(c)}${c}`,l=(0,g.Y)("li",{css:[T,P,{"@media (max-width: 720px)":C},"",""],children:(0,g.FD)("button",{type:"button",onClick:()=>i?.(e,!0),children:[(0,g.Y)(y.i3,{css:j}),".."]})},e),n="files"!==t,r=v?(0,w.A)(u,(e=>e),v):[],a=r.includes(v)||"directories"!==t||!v||k?[]:(()=>{const e=`${Y}${v}${c}`;return[(0,g.Y)("li",{css:[T,P,"font-weight:bold;@media (max-width: 720px){display:none;}",""],children:(0,g.FD)("button",{type:"button",onClick:()=>i?.(e,!1),children:[(0,g.Y)(y.N7,{}),(0,g.Y)("span",{css:I,children:v}),(0,g.FD)("em",{css:V,children:[" - ",(0,g.Y)(s.x6,{id:"filesystem.error.enoent"})]})]})},e)]})(),d=u?.length&&(0,N.di)(u.slice()).desc((e=>r.includes(e))).map((e=>{const t=`${Y}${e}${c}`;return(0,g.Y)("li",{css:[T,n?P:void 0,r.includes(e)?{fontWeight:"bold"}:void 0,"",""],children:(0,g.FD)("button",{type:"button",disabled:!n,tabIndex:n?0:-1,onClick:n?()=>i?.(t,!0):void 0,children:[(0,g.Y)(y.Ah,{}),e]})},t)}))||[],o="directories"!==t,h=v?(0,w.A)(m,(e=>e),v):[],_=m?.length&&(0,N.di)(m.slice()).desc((e=>h.includes(e))).map((e=>{const t=`${Y}${e}`;return(0,g.Y)("li",{css:[T,o?P:void 0,h.includes(e)?{fontWeight:"bold"}:void 0,"",""],children:(0,g.FD)("button",{type:"button",disabled:!o,tabIndex:o?0:-1,onClick:o?()=>i?.(t,!1):void 0,children:[(0,g.Y)(y.ZH,{}),e]})},t)}))||[];0!==d.length||0!==_.length||k||(k="filesystem.empty.directory"),R=[l,...a,...d,..._]}else k="filesystem.error.no.input";return(0,g.FD)("div",{css:(0,x.AH)({color:A,listStyle:"none",padding:"3px 0px",".icon":{fill:"currentColor",height:"14px",width:"14px",marginRight:"5px",marginTop:"-3px",verticalAlign:"middle"}},"",""),children:[Y&&(0,g.FD)("li",{css:[T,C,F,"white-space:pre-wrap;word-break:break-all;.icon{transform:scale(0.9);margin-top:-2px !important;}@media (max-width: 720px){display:none;}",""],children:[(0,g.Y)(y.gx,{}),Y]}),(0,g.Y)("ul",{ref:p,children:R}),k&&(0,g.Y)("div",{css:[T,F,"opacity:1;",""],children:(0,g.Y)("em",{children:(0,g.Y)(s.x6,{id:k})})})]})}));L.defaultProps={selectable:void 0,onItemSelection:void 0,onYieldFocus:void 0};const $=L,B=(0,d.forwardRef)((({id:e,label:t,selectable:i,suggested:l,showBasePathToggle:n,showCompletedToggle:r,showSequentialToggle:a,onChange:c},u)=>{const[_,m]=(0,d.useState)(l||h.A.floodSettings.torrentDestinations?.[""]||h.A.clientSettings?.directoryDefault||""),[f,p]=(0,d.useState)(!1),b=(0,d.useRef)(null),x=(0,v.A)(u),{i18n:k}=(0,s.uB)();(0,d.useEffect)((()=>{const e=()=>{p(!1)},t=t=>{b.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 n&&N.push((0,g.Y)(o.Sc,{grow:!1,id:"isBasePath",children:(0,g.Y)(s.x6,{id:"torrents.destination.base_path"})},"isBasePath")),r&&N.push((0,g.Y)(o.Sc,{grow:!1,id:"isCompleted",children:(0,g.Y)(s.x6,{id:"torrents.destination.completed"})},"isCompleted")),a&&N.push((0,g.Y)(o.Sc,{grow:!1,id:"isSequential",children:(0,g.Y)(s.x6,{id:"torrents.destination.sequential"})},"isSequential")),(0,g.FD)(o.eW,{ref:b,children:[(0,g.Y)(o.fh,{children:(0,g.FD)(o.Rj,{autoComplete:f?"off":void 0,addonPlacement:"after",defaultValue:_,id:e,label:t,onChange:Y()((()=>{if(null==x.current)return;const e=x.current.value;c&&c(e),m(e)}),100,{leading:!0}),onClick:e=>e.nativeEvent.stopImmediatePropagation(),placeholder:k._("torrents.add.destination.placeholder"),ref:x,children:[(0,g.Y)(o.t0,{onClick:()=>{null!=x.current&&m(x.current.value),p(!f)},children:(0,g.Y)(y.vj,{})}),(0,g.Y)(o.ZL,{children:(0,g.Y)(o.tz,{isIn:f,onClick:e=>e.nativeEvent.stopImmediatePropagation(),overlayProps:{isInteractive:!1},padding:!1,triggerRef:x,children:(0,g.Y)($,{directory:_,selectable:i,onItemSelection:(e,t=!0)=>{null!=x.current&&(x.current.value=e),p(t),m(e)},onYieldFocus:()=>{x.current?.focus()}})})})]})}),N.length>0?(0,g.Y)(o.fh,{children:N}):null]})}));B.defaultProps={label:void 0,selectable:void 0,suggested:void 0,showBasePathToggle:!1,showCompletedToggle:!1,showSequentialToggle:!1,onChange:void 0};const E=B;var O=i(6942),H=i.n(O),U=i(9399);const z=({defaultValue:e,placeholder:t,id:i,label:l,onTagSelected:n})=>{const[r,c]=(0,d.useState)(!1),[u,_]=(0,d.useState)(e??[]),m=(0,d.useRef)(null),f=(0,d.useRef)(null),p=(0,d.useRef)(null),b=H()("select form__element",{"select--is-open":r});return(0,a.A)("Escape",(e=>{e.preventDefault(),c(!1)})),(0,d.useEffect)((()=>{const e=e=>{m.current?.contains(e.target)||c(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}}),[]),(0,d.useEffect)((()=>{null!=p.current&&(p.current.value=u.join()),n&&n(u)}),[u,n]),(0,g.Y)(o.ci,{ref:m,children:(0,g.Y)("div",{className:b,children:(0,g.FD)(o.Rj,{autoComplete:r?"off":void 0,id:i||"tags",addonPlacement:"after",defaultValue:e,label:l,onChange:()=>{if(null!=p.current){let e=p.current.value.split(",").map((e=>e.trim())).filter((e=>e.length>0));p.current.value.trimEnd().endsWith(",")&&(e.push(""),e=[...new Set(e)]),_(e)}},placeholder:t,ref:p,children:[(0,g.Y)(o.t0,{onClick:()=>{c(!r)},className:"select__indicator",children:(0,g.Y)(y.cL,{})}),(0,g.Y)(o.ZL,{children:(0,g.Y)(o.tz,{isIn:r,onClick:e=>{"single"!==h.A.floodSettings.UITagSelectorMode&&e.nativeEvent.stopImmediatePropagation()},overlayProps:{isInteractive:!1},ref:f,triggerRef:p,children:[...new Set(["untagged",...(0,N.di)(Object.keys(U.A.taxonomy.tagCounts)).asc(),...u])].reduce(((e,t)=>(""===t||e.push((0,g.Y)(o.eb,{id:t,isSelected:u.includes(t),onClick:()=>{"untagged"===t?_([]):u.includes(t)?_(u.filter((e=>e!==t&&""!==e))):_([...u.filter((e=>""!==e)),t])},children:"untagged"===t?(0,g.Y)(s.x6,{id:"filter.untagged"}):t},t)),e)),[])})})]})})})};z.defaultProps={id:"tags",label:void 0,defaultValue:void 0,placeholder:void 0,onTagSelected:void 0};const q=z,W=(e,t)=>Object.keys(e).reduce(((i,l)=>{if(l.startsWith(t)){const t=e[l];null!=t&&i.push(t)}return i}),[]),G=({defaultValues:e,id:t,label:i,placeholder:l})=>{const n=(0,d.useRef)(0),[r,a]=(0,d.useState)(e??[{id:0,value:""}]);return(0,g.Y)(o.eW,{children:r.map(((e,s)=>{let d=null;return s>0&&(d=(0,g.Y)(o.t0,{onClick:()=>{const e=r.slice();e.splice(s,1),a(e)},children:(0,g.Y)(y._B,{})})),(0,g.Y)(o.fh,{children:(0,g.FD)(o.Rj,{addonPlacement:"after",id:`${t}-${e.id}`,defaultValue:e.value,label:0===s&&i,placeholder:l,wrapperClassName:"textbox-repeater",children:[(0,g.Y)(o.t0,{onClick:()=>{n.current+=1;const e=r.slice();e.splice(s+1,0,{id:n.current,value:""}),a(e)},children:(0,g.Y)(y.Fx,{})}),d]})},e.id)}))})};G.defaultProps={defaultValues:void 0,label:void 0,placeholder:void 0};const Z=G,Q=()=>{const e=(0,d.useRef)(null),{i18n:t}=(0,s.uB)(),[i,l]=(0,d.useState)(!1);return(0,g.FD)(o.lV,{className:"inverse",ref:e,children:[(0,g.Y)(E,{id:"sourcePath",label:t._("torrents.create.source.path.label")}),(0,g.Y)(Z,{id:"trackers",label:t._("torrents.create.trackers.label"),placeholder:t._("torrents.create.tracker.input.placeholder"),defaultValues:[{id:0,value:""}]}),(0,g.Y)(o.fh,{children:(0,g.Y)(o.Rj,{id:"name",label:t._("torrents.create.base.name.label"),placeholder:t._("torrents.create.base.name.input.placeholder")})}),(0,g.Y)(o.fh,{children:(0,g.Y)(o.Rj,{id:"comment",label:t._("torrents.create.comment.label"),placeholder:t._("torrents.create.comment.input.placeholder")})}),(0,g.Y)(o.fh,{children:(0,g.Y)(o.Rj,{id:"infoSource",label:t._("torrents.create.info.source.label"),placeholder:t._("torrents.create.info.source.input.placeholder")})}),(0,g.Y)(o.fh,{children:(0,g.Y)(o.Sc,{grow:!1,id:"isPrivate",children:t._("torrents.create.is.private.label")})}),(0,g.Y)(o.fh,{children:(0,g.Y)(q,{id:"tags",label:t._("torrents.add.tags"),placeholder:t._("torrents.create.tags.input.placeholder")})}),(0,g.Y)(p,{onAddTorrentsClick:()=>{if(null==e.current)return;const t=e.current.getFormData();l(!0),null!=t.sourcePath&&(_.A.createTorrent({name:t.name,sourcePath:t.sourcePath,trackers:W(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((()=>{m.A.setActiveModal(null)})),u({start:t.start,destination:t.sourcePath,tab:"by-creation"}))},isAddingTorrents:i})]})};var J=i(4802);const K=({initialFiles:e,onFilesChanged:t})=>{const[i,l]=(0,d.useState)(e??[]);return(0,d.useEffect)((()=>{t(i)}),[i,t]),(0,g.FD)(o.ci,{children:[(0,g.Y)("span",{className:"form__element__label",children:(0,g.Y)(s.x6,{id:"torrents.add.torrents.label"})}),i.length>0?(0,g.Y)("div",{onClick:e=>{e.stopPropagation()},role:"none",children:(0,g.Y)("ul",{className:"dropzone__selected-files interactive-list",children:i.map(((e,t)=>(0,g.FD)("li",{className:"dropzone__selected-files__file interactive-list__item",title:e.name,children:[(0,g.Y)("span",{className:"interactive-list__icon",children:(0,g.Y)(y.ZH,{})}),(0,g.Y)("span",{className:"interactive-list__label",children:e.name}),(0,g.Y)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>{const e=i.slice();e.splice(t,1),l(e)},children:(0,g.Y)(y.bm,{})})]},e.name)))})}):null,(0,g.Y)(J.Ay,{onDrop:e=>{const t=[];e.forEach((n=>{const r=new FileReader;r.onload=r=>{null!=r.target?.result&&"string"==typeof r.target.result&&t.push({name:n.name,data:r.target.result.split("base64,")[1]}),t.length===e.length&&l(i.concat(t))},r.readAsDataURL(n)}))},children:({getRootProps:e,getInputProps:t,isDragActive:i})=>(0,g.FD)("div",{...e(),className:"form__dropzone dropzone interactive-list "+(i?"dropzone--is-dragging":""),children:[(0,g.Y)("input",{...t()}),(0,g.FD)("div",{className:"dropzone__copy",children:[(0,g.Y)("div",{className:"dropzone__icon",children:(0,g.Y)(y.sv,{})}),(0,g.Y)(s.x6,{id:"torrents.add.tab.file.drop"})," ",(0,g.Y)("span",{className:"dropzone__browse-button",children:(0,g.Y)(s.x6,{id:"torrents.add.tab.file.browse"})}),"."]})]})})]})},X=()=>{const e=(0,d.useRef)([]),t=(0,d.useRef)(null),i=(0,d.useRef)(null),[l,n]=(0,d.useState)(!1),{i18n:r}=(0,s.uB)();return(0,g.FD)(o.lV,{className:"inverse",ref:t,children:[(0,g.Y)(o.fh,{children:(0,g.Y)(K,{initialFiles:"add-torrents"===m.A.activeModal?.id&&"by-file"===m.A.activeModal?.tab&&m.A.activeModal?.files||[],onFilesChanged:t=>{e.current=t}})}),(0,g.Y)(o.fh,{children:(0,g.Y)(q,{label:r._("torrents.add.tags"),id:"tags",onTagSelected:e=>{if(null!=i.current){const t=h.A.floodSettings.torrentDestinations?.[e[0]];"string"==typeof t&&null!=i.current&&(i.current.value=t,i.current.dispatchEvent(new Event("input",{bubbles:!0})))}}})}),(0,g.Y)(E,{id:"destination",label:r._("torrents.add.destination.label"),ref:i,selectable:"directories",showBasePathToggle:!0,showCompletedToggle:!0,showSequentialToggle:!0}),(0,g.Y)(p,{onAddTorrentsClick:()=>{if(null==t.current)return;const i=t.current?.getFormData();n(!0);const{destination:l,start:r,tags:a,isBasePath:s,isCompleted:d,isSequential:o}=i,c=[];if(e.current.forEach((e=>{c.push(e.data)})),0===c.length||null==l)return void n(!1);const h=null!=a?a.split(",").filter((e=>e.length>0)):void 0;_.A.addTorrentsByFiles({files:c,destination:l,tags:h,isBasePath:s,isCompleted:d,isSequential:o,start:r}).then((()=>{m.A.setActiveModal(null)})),u({start:r,destination:l,tags:h,tab:"by-file"})},isAddingTorrents:l})]})};var ee=i(9550);var te={name:"izrr19",styles:"float:right;:focus{outline:none;-webkit-tap-highlight-color:transparent;}:focus-visible{outline:dashed;}"},ie={name:"1rawn5e",styles:"font-size:0.8em"};const le=()=>{const e=(0,d.useRef)(null),t=(0,d.useRef)(null),[i,l]=(0,d.useState)(!1),{i18n:n}=(0,s.uB)();return(0,g.FD)(o.lV,{className:"inverse",ref:e,children:[(0,g.Y)(Z,{id:"urls",label:(0,g.FD)("div",{children:[n._("torrents.add.torrents.label"),"function"==typeof navigator.registerProtocolHandler&&(0,g.Y)("button",{css:te,type:"button",onClick:()=>{"function"==typeof navigator.registerProtocolHandler&&navigator.registerProtocolHandler("magnet",`${ee.A.baseURI}?action=add-urls&url=%s`)},children:(0,g.Y)("em",{css:ie,children:n._("torrents.add.tab.url.register.magnet.handler")})})]}),placeholder:n._("torrents.add.tab.url.input.placeholder"),defaultValues:"add-torrents"===m.A.activeModal?.id&&"by-url"===m.A.activeModal?.tab&&m.A.activeModal?.urls||[{id:0,value:""}]}),(0,g.Y)(Z,{id:"cookies",label:n._("torrents.add.cookies.label"),placeholder:n._("torrents.add.cookies.input.placeholder")}),(0,g.Y)(o.fh,{children:(0,g.Y)(q,{id:"tags",label:n._("torrents.add.tags"),onTagSelected:e=>{if(null!=t.current){const i=h.A.floodSettings.torrentDestinations?.[e[0]];"string"==typeof i&&null!=t.current&&(t.current.value=i,t.current.dispatchEvent(new Event("input",{bubbles:!0})))}}})}),(0,g.Y)(E,{id:"destination",label:n._("torrents.add.destination.label"),ref:t,selectable:"directories",showBasePathToggle:!0,showCompletedToggle:!0,showSequentialToggle:!0}),(0,g.Y)(p,{onAddTorrentsClick:()=>{if(null==e.current)return;const t=e.current.getFormData();l(!0);const i=W(t,"urls").filter((e=>""!==e));if(0===i.length||null==t.destination)return void l(!1);const n=W(t,"cookies"),r=i[0].startsWith("http")&&i[0].split("/")[2],a=r?{[r]:n}:void 0,s=null!=t.tags?t.tags.split(",").filter((e=>e.length>0)):void 0;_.A.addTorrentsByUrls({urls:i,cookies:a,destination:t.destination,isBasePath:t.isBasePath,isCompleted:t.isCompleted,isSequential:t.isSequential,start:t.start,tags:s}).then((()=>{m.A.setActiveModal(null)})),u({start:t.start,destination:t.destination,tags:s,tab:"by-url"})},isAddingTorrents:i})]})};var ne={name:"1gxvag8",styles:":focus{outline:none;-webkit-tap-highlight-color:transparent;}:focus-visible{outline:dashed;}"};const re=e=>{const{activeTabId:t,tabs:i={},onTabChange:l}=e;return(0,g.Y)("ul",{className:"modal__tabs",children:Object.keys(i).map((e=>{const n=i[e];n.id=e;const r=H()("modal__tab",{"is-active":e===t});return(0,g.Y)("li",{className:r,children:(0,g.Y)("button",{css:ne,type:"button",onClick:()=>{l&&l(n)},children:n.label})},e)}))})};re.defaultProps={tabs:{}};const ae=re,se=e=>{const{alignment:t,size:i,orientation:l,tabsInBody:n,inverse:r,initialTabId:a,className:s,content:o,heading:c,tabs:h,actions:u}=e,_=H()("modal__content__wrapper",`modal--align-${t}`,`modal--size-${i}`,{"modal--horizontal":"horizontal"===l,"modal--vertical":"vertical"===l,"modal--tabs-in-header":!n,"modal--tabs-in-body":n,inverse:r},s);let m=o;const p=c,b=H()("modal__header",{"has-tabs":h});let Y,v,y;const[x,k]=(0,d.useState)(a??Object.keys(h||{})[0]);if(h){const e=h[x],t=H()("modal__content",e.modalContentClasses),i=e.content,l=e.props,r=(0,g.Y)(ae,{activeTabId:x,onTabChange:e=>{null!=e.id&&k(e.id)},tabs:h},"modal-tabs");n?Y=r:y=r,m=[Y,(0,g.Y)("div",{className:t,children:(0,g.Y)(i,{...l})},"modal-content")]}return u&&(v=(0,g.Y)("div",{className:"modal__footer",children:(0,g.Y)(f,{actions:u})})),(0,g.FD)("div",{className:_,children:[(0,g.FD)("div",{className:b,children:[p,y]}),(0,g.FD)("div",{className:"modal__body",children:[m,v]})]})};se.defaultProps={alignment:"left",className:null,inverse:!0,size:"medium",orientation:"horizontal",tabsInBody:!1,content:void 0,actions:void 0,tabs:void 0,initialTabId:void 0};const de=se,oe=()=>{const{i18n:e}=(0,s.uB)(),t={"by-url":{content:le,label:e._("torrents.add.tab.url.title")},"by-file":{content:X,label:e._("torrents.add.tab.file.title")},"by-creation":{content:Q,label:e._("torrents.add.tab.create.title")}};return"add-torrents"!==m.A.activeModal?.id?null:(0,g.Y)(de,{heading:e._("torrents.add.heading"),tabs:t,initialTabId:m.A.activeModal.tab??h.A.floodSettings.UITorrentsAddTab??"by-url"})},ce=(0,r.PA)((()=>{if("confirm"!==m.A.activeModal?.id)return null;const{actions:e,content:t,heading:i}=m.A.activeModal||{};return(0,g.Y)(de,{actions:e,content:(0,g.Y)("div",{className:"modal__content",children:t}),heading:i})}));var he=i(1083),ue=i(7813);const _e=new class{feeds=[];rules=[];items=[];constructor(){(0,ue.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:me}=ee.A,ge={addFeed:e=>he.A.put(`${me}api/feed-monitor/feeds`,e).then((()=>ge.fetchFeedMonitors())),modifyFeed:(e,t)=>he.A.patch(`${me}api/feed-monitor/feeds/${e}`,t).then((()=>ge.fetchFeedMonitors())),addRule:e=>he.A.put(`${me}api/feed-monitor/rules`,e).then((()=>ge.fetchFeedMonitors())),fetchFeedMonitors:()=>he.A.get(`${me}api/feed-monitor`).then((({data:e})=>{_e.handleFeedMonitorsFetchSuccess(e)}),(()=>{})),fetchItems:({id:e,search:t})=>he.A.get(`${me}api/feed-monitor/feeds/${e}/items`,{params:{search:t}}).then((({data:e})=>{_e.handleItemsFetchSuccess(e)}),(()=>{})),removeFeedMonitor:e=>he.A.delete(`${me}api/feed-monitor/${e}`).then((()=>ge.fetchFeedMonitors()),(()=>{}))},fe=ge,pe=/^(?:https?|ftp):\/\/.{1,}\.{1}.{1,}/,be=e=>null!=e&&""!==e,Ye=e=>{try{new RegExp(e)}catch(e){return!1}return!0},ve=({rule:e,isSubmitting:t,isPatternMatched:i,onCancel:l})=>{const{feeds:n}=_e,{i18n:r}=(0,s.uB)();return(0,g.FD)(o.eW,{children:[(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{id:"label",label:r._("feeds.label"),defaultValue:e.label}),(0,g.Y)(o.l6,{disabled:!n.length,id:"feedID",label:r._("feeds.applicable.feed"),defaultID:e.feedIDs?.[0],children:0===n.length?[(0,g.Y)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,g.Y)("em",{children:(0,g.Y)(s.x6,{id:"feeds.no.feeds.available"})})},"empty")]:n.reduce(((e,t)=>e.concat((0,g.Y)(o.eb,{id:`${t._id}`,children:t.label},t._id))),[(0,g.Y)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,g.Y)("em",{children:(0,g.Y)(s.x6,{id:"feeds.select.feed"})})},"select-feed")])})]}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{id:"match",label:r._("feeds.match.pattern"),placeholder:r._("feeds.regEx"),defaultValue:e.match,width:"three-eighths"}),(0,g.Y)(o.Rj,{id:"exclude",label:r._("feeds.exclude.pattern"),placeholder:r._("feeds.regEx"),defaultValue:e.exclude,width:"three-eighths"})]}),(0,g.Y)(o.fh,{children:(0,g.Y)(o.Rj,{addonPlacement:"after",id:"check",label:r._("feeds.test.match"),placeholder:r._("feeds.check"),children:i&&(0,g.Y)(o.t0,{children:(0,g.Y)(y.H4,{})})})}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.ci,{children:(0,g.Y)(E,{id:"destination",label:r._("feeds.torrent.destination"),selectable:"directories",suggested:e.destination,showBasePathToggle:!0})}),(0,g.Y)(q,{id:"tags",label:r._("feeds.apply.tags"),placeholder:r._("feeds.tags"),defaultValue:e.tags})]}),(0,g.FD)(o.fh,{align:"end",justify:"end",children:[(0,g.Y)("br",{}),(0,g.Y)(o.Sc,{id:"startOnLoad",defaultChecked:e.startOnLoad,matchTextboxHeight:!0,children:(0,g.Y)(s.x6,{id:"feeds.start.on.load"})}),(0,g.Y)(o.$n,{onClick:l,children:(0,g.Y)(s.x6,{id:"button.cancel"})}),(0,g.Y)(o.$n,{type:"submit",isLoading:t,children:(0,g.Y)(s.x6,{id:"button.save.feed"})})]})]})},ye=({children:e})=>(0,g.Y)("h2",{className:"h4",children:e}),xe=(0,r.PA)((({currentRule:e,onSelect:t,onRemove:i})=>{const{rules:l}=_e;return 0===l.length?(0,g.Y)("ul",{className:"interactive-list",children:(0,g.Y)("li",{className:"interactive-list__item",children:(0,g.Y)(s.x6,{id:"feeds.no.rules.defined"})})}):(0,g.Y)("ul",{className:"interactive-list",children:l.map((l=>{const n=l.count||0;let r=null,a=null;if(l.exclude&&(r=(0,g.FD)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",children:[(0,g.Y)(s.x6,{id:"feeds.exclude"}),": ",l.exclude]})),l.tags&&l.tags.length>0){const e=l.tags.map((e=>(0,g.Y)("span",{className:"tag",children:e},e)));a=(0,g.FD)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",children:[(0,g.Y)(s.x6,{id:"feeds.tags"}),": ",e]})}return(0,g.FD)("li",{className:"interactive-list__item interactive-list__item--stacked-content",children:[(0,g.FD)("div",{className:"interactive-list__label",children:[(0,g.FD)("ul",{className:"interactive-list__detail-list",children:[(0,g.Y)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:l.label}),(0,g.Y)("li",{className:"interactive-list__detail-list__item interactive-list__detail-list__item--overflow interactive-list__detail interactive-list__detail--secondary",children:(0,g.Y)(s.x6,{id:"feeds.match.count",values:{count:n}})}),l===e&&(0,g.Y)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:"Modifying"})]}),(0,g.FD)("ul",{className:"interactive-list__detail-list",children:[(0,g.FD)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",style:{maxWidth:"50%",overflow:"hidden",textOverflow:"ellipsis"},children:[(0,g.Y)(s.x6,{id:"feeds.match"}),": ",l.match]}),(0,g.Y)("div",{style:{width:"100%"}}),r,a]})]}),(0,g.Y)("button",{className:"interactive-list__icon interactive-list__icon--action",type:"button",onClick:()=>t(l),children:(0,g.Y)(y.ff,{})}),(0,g.Y)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>i(l),children:(0,g.Y)(y.bm,{})})]},l._id)}))})})),ke={label:"",feedIDs:[],match:"",exclude:"",tags:[],destination:"",startOnLoad:!1},Ne={destination:{isValid:be,error:"feeds.validation.must.specify.destination"},feedID:{isValid:e=>be(e)&&"placeholder"!==e,error:"feeds.validation.must.select.feed"},label:{isValid:be,error:"feeds.validation.must.specify.label"},match:{isValid:e=>be(e)&&Ye(e),error:"feeds.validation.invalid.regular.expression"},exclude:{isValid:e=>!be(e)||Ye(e),error:"feeds.validation.invalid.regular.expression"}},De=(e,t)=>Ne[e]?.isValid(t)?void 0:Ne[e]?.error,Se=()=>{const e=(0,d.useRef)(null),{i18n:t}=(0,s.uB)(),[i,l]=(0,d.useState)(null),[n,r]=(0,d.useState)({}),[a,c]=(0,d.useState)(!1),[h,u]=(0,d.useState)(!1),[_,m]=(0,d.useState)(!1),[f,p]=(0,d.useState)(!1);return(0,g.FD)(o.lV,{className:"inverse",onChange:({event:e,formData:t})=>{const i=e.target.name,l=t;r({...n,[i]:De(i,l[i])}),p((()=>{const{check:e,match:t="",exclude:i=""}=l;if(be(e)&&Ye(t)&&Ye(i)){const l=new RegExp(t,"gi").test(e),n=""!==i&&new RegExp(i,"gi").test(e);return l&&!n}return!1})()),m(!0)},onSubmit:async()=>{if(null==e.current)return;const t=e.current.getFormData(),n=Object.keys(Ne).reduce(((e,i)=>{const l=i;return{...e,[l]:De(l,t[l])}}),{});r(n);const a=Object.keys(n).every((e=>void 0===n[e]));_&&a&&(u(!0),null!=i?._id&&await fe.removeFeedMonitor(i._id),await fe.addRule({label:t.label??ke.label,feedIDs:[t.feedID??""],field:t.field,match:t.match??ke.match,exclude:t.exclude??ke.exclude,destination:t.destination??ke.destination,tags:t.tags?.split(",")??ke.tags,startOnLoad:t.startOnLoad??ke.startOnLoad,isBasePath:t.isBasePath??!1}).then((()=>{e.current?.resetForm(),r({}),l(null),c(!1)}),(()=>{r({backend:"general.error.unknown"})})),u(!1))},ref:e,children:[(0,g.Y)(ye,{children:(0,g.Y)(s.x6,{id:"feeds.existing.rules"})}),Object.keys(n).reduce(((e,i)=>(null!=n[i]&&e.push((0,g.Y)(o.fh,{children:(0,g.Y)(o.jQ,{children:t._(n?.[i])})},`error-${i}`)),e)),[]),(0,g.Y)(o.fh,{children:(0,g.Y)(o.ci,{children:(0,g.Y)(xe,{currentRule:i,onSelect:e=>{l(e),c(!0)},onRemove:e=>{null!=e._id&&fe.removeFeedMonitor(e._id),e===i&&(l(null),c(!1))}})})}),a?(0,g.Y)(ve,{rule:i??ke,isPatternMatched:f,isSubmitting:h,onCancel:()=>{l(null),c(!1)}},i?._id||"initial"):(0,g.FD)(o.fh,{align:"end",justify:"end",children:[(0,g.Y)("br",{}),(0,g.Y)(o.$n,{onClick:()=>{c(!0)},children:(0,g.Y)(s.x6,{id:"button.new"})})]})]})},we=({currentFeed:e,defaultFeed:t,intervalMultipliers:i,isSubmitting:l,onCancel:n})=>{const{i18n:r}=(0,s.uB)(),a=e?.interval??t.interval;let d=a,c=1;return i.forEach((e=>{const t=e.value;a%t==0&&(d=a/t,c=t)})),(0,g.FD)(o.eW,{children:[(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{id:"label",label:r._("feeds.label"),placeholder:r._("feeds.label"),defaultValue:e?.label??t.label}),(0,g.Y)(o.Rj,{id:"interval",label:r._("feeds.select.interval"),placeholder:r._("feeds.interval"),defaultValue:d,width:"one-eighth"}),(0,g.Y)(o.l6,{labelOffset:!0,defaultID:c,id:"intervalMultiplier",width:"one-eighth",children:i.map((e=>(0,g.Y)(o.eb,{id:e.value,children:r._(e.message)},e.value)))})]}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{id:"url",label:r._("feeds.url"),placeholder:r._("feeds.url"),defaultValue:e?.url??t?.url}),(0,g.Y)(o.$n,{labelOffset:!0,onClick:n,children:(0,g.Y)(s.x6,{id:"button.cancel"})}),(0,g.Y)(o.$n,{labelOffset:!0,type:"submit",isLoading:l,children:(0,g.Y)(s.x6,{id:"button.save.feed"})})]})]})},Ae=(0,r.PA)((({selectedFeedID:e})=>{const{items:t}=_e,i=[];if(e){const e={};t.forEach(((t,l)=>{let{title:n}=t;const r=e[n];null==r?e[n]=2:(n=`${n} #${r}`,e[n]+=1),i.push((0,g.FD)("li",{className:"interactive-list__item interactive-list__item--stacked-content feed-list__feed",children:[(0,g.Y)("div",{className:"interactive-list__label feed-list__feed-label",children:n}),(0,g.Y)(o.Sc,{id:`${l}`})]},n))}))}return(0,g.Y)(o.fh,{children:0===i.length?(0,g.Y)("ul",{className:"interactive-list",children:(0,g.Y)("li",{className:"interactive-list__item",children:(0,g.Y)("div",{className:"interactive-list__label",children:(0,g.Y)(s.x6,{id:"feeds.no.items.matching"})})})}):(0,g.Y)("ul",{className:"interactive-list feed-list",children:i})})})),Fe=(0,r.PA)((()=>{const{i18n:e}=(0,s.uB)(),t=(0,d.useRef)(null),[i,l]=(0,d.useState)(null),{feeds:n}=_e;return null!=i&&(n.some((e=>e._id===i))||l(null)),(0,g.FD)(o.lV,{className:"inverse",onChange:({event:e,formData:t})=>{const i=t;"checkbox"!==e.target.type&&(l(i.feedID),fe.fetchItems({id:i.feedID,search:i.search}))},onSubmit:()=>{if(null==t.current)return;const e=t.current.getFormData(),i=_e.items.filter(((t,i)=>e[i])).map(((e,t)=>({id:t,value:e.urls[0]})));m.A.setActiveModal({id:"add-torrents",tab:"by-url",urls:i})},ref:t,children:[(0,g.Y)(ye,{children:(0,g.Y)(s.x6,{id:"feeds.browse.feeds"})}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.l6,{disabled:!n.length,grow:!1,id:"feedID",label:e._("feeds.select.feed"),width:"three-eighths",children:n.length?n.reduce(((e,t)=>null==t._id?e:e.concat((0,g.Y)(o.eb,{id:t._id,children:t.label},t._id))),[(0,g.Y)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,g.Y)("em",{children:(0,g.Y)(s.x6,{id:"feeds.select.feed"})})},"select-feed")]):[(0,g.Y)(o.eb,{id:"placeholder",isPlaceholder:!0,children:(0,g.Y)("em",{children:(0,g.Y)(s.x6,{id:"feeds.no.feeds.available"})})},"empty")]}),i&&(0,g.Y)(o.Rj,{id:"search",label:e._("feeds.search.term"),placeholder:e._("feeds.search")}),i&&(0,g.Y)(o.$n,{type:"submit",labelOffset:!0,children:(0,g.Y)(s.x6,{id:"button.download"})},"button")]}),i&&(0,g.Y)(Ae,{selectedFeedID:i})]})})),Ce=(0,r.PA)((({currentFeed:e,intervalMultipliers:t,onSelect:i,onRemove:l})=>{const{feeds:n}=_e,{i18n:r}=(0,s.uB)();return 0===n.length?(0,g.Y)("ul",{className:"interactive-list",children:(0,g.Y)("li",{className:"interactive-list__item",children:(0,g.Y)(s.x6,{id:"feeds.no.feeds.defined"})})}):(0,g.Y)("ul",{className:"interactive-list feed-list",children:n.map((n=>{const a=n.count||0;let d=`${n.interval}`,o=t[0].message;return t.forEach((e=>{n.interval%e.value==0&&(d=""+n.interval/e.value,o=e.message)})),(0,g.FD)("li",{className:"interactive-list__item interactive-list__item--stacked-content feed-list__feed",children:[(0,g.FD)("div",{className:"interactive-list__label",children:[(0,g.FD)("ul",{className:"interactive-list__detail-list",children:[(0,g.Y)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:n.label}),(0,g.Y)("li",{className:"interactive-list__detail-list__item interactive-list__detail-list__item--overflow interactive-list__detail interactive-list__detail--secondary",children:(0,g.Y)(s.x6,{id:"feeds.match.count",values:{count:a}})}),n===e&&(0,g.Y)("li",{className:"interactive-list__detail-list__item interactive-list__detail--primary",children:"Modifying"})]}),(0,g.FD)("ul",{className:"interactive-list__detail-list",children:[(0,g.Y)("li",{className:"interactive-list__detail-list__item interactive-list__detail interactive-list__detail--tertiary",children:`${d} ${r._(o)}`}),(0,g.Y)("li",{className:"interactive-list__detail-list__item interactive-list__detail-list__item--overflow interactive-list__detail interactive-list__detail--tertiary",children:(0,g.Y)("a",{href:n.url,rel:"noopener noreferrer",target:"_blank",children:n.url})})]})]}),(0,g.Y)("button",{className:"interactive-list__icon interactive-list__icon--action",type:"button",onClick:()=>i(n),children:(0,g.Y)(y.ff,{})}),(0,g.Y)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>l(n),children:(0,g.Y)(y.bm,{})})]},n._id)}))})})),Te={url:{isValid:e=>null!=e&&""!==e&&null!==e.match(pe),error:"feeds.validation.must.specify.valid.feed.url"},label:{isValid:be,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"}},Re=(e,t)=>Te[e]?.isValid(t)?void 0:Te[e]?.error,Pe=[{message:"feeds.time.min",value:1},{message:"feeds.time.hr",value:60},{message:"feeds.time.day",value:1440}],Me={label:"",interval:5,url:""},je=()=>{const e=(0,d.useRef)(null),{i18n:t}=(0,s.uB)(),[i,l]=(0,d.useState)(null),[n,r]=(0,d.useState)({}),[a,c]=(0,d.useState)(!1),[h,u]=(0,d.useState)(!1);return(0,g.FD)("div",{children:[(0,g.FD)(o.lV,{className:"inverse",onChange:({event:e,formData:t})=>{const i=e.target.name,l=t;r({...n,[i]:Re(i,l[i])})},onSubmit:async()=>{const t=e.current?.getFormData();if(null==e.current||null==t)return;u(!0);const n=Object.keys(Te).reduce(((e,i)=>{const l=i;return{...e,[l]:Re(l,t[l])}}),{});r(n);if(Object.keys(n).every((e=>void 0===n[e]))){const n={label:t.label,url:t.url,interval:Number(t.interval)*Number(t.intervalMultiplier)};let a=!0;try{null===i?await fe.addFeed(n):null!=i?._id&&await fe.modifyFeed(i._id,n)}catch{a=!1}a?(e.current.resetForm(),r({}),l(null),c(!1)):r({backend:"general.error.unknown"})}u(!1)},ref:e,children:[(0,g.Y)(ye,{children:(0,g.Y)(s.x6,{id:"feeds.existing.feeds"})}),Object.keys(n).reduce(((e,i)=>(null!=n[i]&&e.push((0,g.Y)(o.fh,{children:(0,g.Y)(o.jQ,{children:t._(n?.[i])})},`error-${i}`)),e)),[]),(0,g.Y)(o.fh,{children:(0,g.Y)(o.ci,{children:(0,g.Y)(Ce,{currentFeed:i,intervalMultipliers:Pe,onSelect:e=>{l(e),c(!0)},onRemove:e=>{e===i&&(a&&(r({}),c(!1)),l(null)),null!=e._id&&fe.removeFeedMonitor(e._id)}})})}),a?(0,g.Y)(we,{currentFeed:i,defaultFeed:Me,intervalMultipliers:Pe,isSubmitting:h,onCancel:()=>{r({}),c(!1),l(null)}},i?._id||"initial"):(0,g.FD)(o.fh,{children:[(0,g.Y)(o.ci,{width:"auto"}),(0,g.Y)(o.$n,{onClick:()=>{c(!0)},children:(0,g.Y)(s.x6,{id:"button.new"})})]})]}),(0,g.Y)(Fe,{})]})},Ie=()=>{const{i18n:e}=(0,s.uB)();(0,d.useEffect)((()=>{fe.fetchFeedMonitors()}),[]);const t={feeds:{content:je,label:e._("feeds.tabs.feeds")},downloadRules:{content:Se,label:e._("feeds.tabs.download.rules")}};return(0,g.Y)(de,{heading:e._("feeds.tabs.heading"),orientation:"horizontal",size:"large",tabs:t})};var Ve=i(484);let Le=function(e){return e[e.HTTP=1]="HTTP",e[e.UDP=2]="UDP",e[e.DHT=3]="DHT",e}({});const $e=(e,t)=>{let i=`magnet:?xt=urn:btih:${e}`;return t?.length&&t.forEach((e=>{i=`${i}&tr=${encodeURI(e)}`})),i},Be=()=>{const e=(0,d.useRef)(null),t=(0,d.useRef)(null),{i18n:i}=(0,s.uB)(),[l,n]=(0,d.useState)(!1),[r,a]=(0,d.useState)(!1),[c,h]=(0,d.useState)({isLoadingTrackers:!0,magnetTrackersLink:""});(0,d.useEffect)((()=>{_.A.fetchTorrentTrackers(Ve.A.selectedTorrents[0]).then((e=>{null!=e&&h({isLoadingTrackers:!1,magnetTrackersLink:$e(Ve.A.selectedTorrents[0],e.filter((e=>e.type!==Le.DHT)).map((e=>e.url)))})}))}),[]);const u=$e(Ve.A.selectedTorrents[0]);return(0,g.Y)(de,{heading:i._("torrents.generate.magnet.heading"),content:(0,g.Y)("div",{className:"modal__content inverse",children:(0,g.FD)(o.lV,{children:[Ve.A.torrents[Ve.A.selectedTorrents[0]]?.isPrivate?(0,g.Y)(o.fh,{children:(0,g.Y)(o.jQ,{children:i._("torrents.generate.magnet.private.torrent")})}):null,(0,g.Y)(o.fh,{children:(0,g.Y)(o.Rj,{id:"magnet",ref:e,addonPlacement:"after",label:i._("torrents.generate.magnet.magnet"),defaultValue:u,readOnly:!0,children:(0,g.Y)(o.t0,{onClick:()=>{"function"==typeof navigator.clipboard?.writeText?navigator.clipboard.writeText(u).then((()=>{n(!0)})):null!=e.current&&(e.current?.select(),document.execCommand("copy"),n(!0))},children:l?(0,g.Y)(y.H4,{}):(0,g.Y)(y.B0,{})})})}),(0,g.Y)(o.fh,{children:c.isLoadingTrackers?(0,g.Y)(o.Rj,{id:"loading",label:i._("torrents.generate.magnet.magnet.with.trackers"),placeholder:i._("torrents.generate.magnet.loading.trackers"),disabled:!0}):(0,g.Y)(o.Rj,{id:"magnet-trackers",ref:t,addonPlacement:"after",label:i._("torrents.generate.magnet.magnet.with.trackers"),defaultValue:c.magnetTrackersLink,readOnly:!0,children:(0,g.Y)(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,g.Y)(y.H4,{}):(0,g.Y)(y.B0,{})})})})]})}),actions:[{clickHandler:null,content:i._("button.close"),triggerDismiss:!0,type:"tertiary"}]})},Ee=e=>{let t="";for(let i=0;i<e[0].length;i+=1)for(let l=1;l<e.length;l+=1)e[0][i]!==e[l][i]&&(t=e[0].slice(0,i));for(let e=t.length-1;e>=0;e-=1)if("/"===t[e])return t.slice(0,e+1)},Oe=()=>{const{i18n:e}=(0,s.uB)(),[t,i]=(0,d.useState)(!1);return(0,g.Y)(de,{heading:e._("torrents.move.heading"),content:(0,g.Y)("div",{className:"modal__content",children:(0,g.FD)(o.lV,{className:"inverse",onSubmit:({formData:e})=>{const t=Ve.A.selectedTorrents;t.length>0&&(i(!0),_.A.moveTorrents({hashes:t,destination:e.destination,isBasePath:e.isBasePath,moveFiles:e.moveFiles,isCheckHash:e.isCheckHash}).then((()=>{m.A.setActiveModal(null),i(!1)})))},children:[(0,g.Y)(E,{id:"destination",selectable:"directories",suggested:Ee(Ve.A.selectedTorrents.map((e=>Ve.A.torrents[e].directory))),showBasePathToggle:!0}),(0,g.Y)(f,{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"}]})]})})})},He=()=>{const{i18n:e}=(0,s.uB)(),[t,i]=(0,d.useState)(!1),{selectedTorrents:l}=Ve.A;return 0===l.length?(0,g.Y)(de,{heading:e._("torrents.remove"),content:(0,g.Y)("div",{className:"modal__content inverse",children:(0,g.Y)(o.lV,{children:(0,g.Y)(o.fh,{children:(0,g.Y)(s.x6,{id:"torrents.remove.error.no.torrents.selected"})})})}),actions:[{clickHandler:null,content:e._("button.ok"),triggerDismiss:!0,type:"primary"}]}):(0,g.Y)(de,{heading:e._("torrents.remove"),content:(0,g.Y)("div",{className:"modal__content",children:(0,g.FD)(o.lV,{className:"inverse",onSubmit:({formData:e})=>{i(!0);const t=e.deleteData;_.A.deleteTorrents({hashes:Ve.A.selectedTorrents,deleteData:t}).then((()=>{i(!1),(({deleteData:e})=>{null!=e&&c.A.saveSetting("deleteTorrentData",e)})({deleteData:t}),m.A.setActiveModal(null)}))},children:[(0,g.Y)(o.fh,{children:(0,g.Y)(s.x6,{id:"torrents.remove.are.you.sure",values:{count:l.length}})}),(0,g.Y)(f,{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"}]})]})})})},Ue=()=>{const e=(0,d.useRef)(null),{i18n:t}=(0,s.uB)(),[i,l]=(0,d.useState)(!1);return(0,g.Y)(de,{heading:t._("torrents.set.tags.heading"),content:(0,g.Y)("div",{className:"modal__content inverse",children:(0,g.Y)(o.lV,{ref:e,children:(0,g.Y)(o.fh,{children:(0,g.Y)(q,{defaultValue:Ve.A.selectedTorrents.map((e=>Ve.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}=Ve.A,i=e.current.getFormData(),n=i.tags?i.tags.split(",").filter((e=>!!e)):[];l(!0),t?.length>0&&_.A.setTags({hashes:t,tags:n})},isLoading:i,triggerDismiss:!1,type:"primary"}]})},ze=()=>{const e=(0,d.useRef)(null),{i18n:t}=(0,s.uB)(),[i,l]=(0,d.useState)(!1),[n,r]=(0,d.useState)({isLoadingTrackers:!0,trackerURLs:[]});return(0,d.useEffect)((()=>{_.A.fetchTorrentTrackers(Ve.A.selectedTorrents[0]).then((e=>{null!=e&&r({isLoadingTrackers:!1,trackerURLs:e.filter((e=>e.type!==Le.DHT)).map((e=>e.url))})}))}),[]),(0,g.Y)(de,{heading:t._("torrents.set.trackers.heading"),content:(0,g.Y)("div",{className:"modal__content inverse",children:(0,g.Y)(o.lV,{ref:e,children:n.isLoadingTrackers?(0,g.Y)(o.fh,{children:(0,g.Y)(o.Rj,{id:"loading",placeholder:t._("torrents.set.trackers.loading.trackers"),disabled:!0})}):(0,g.Y)(Z,{id:"trackers",placeholder:t._("torrents.set.trackers.enter.tracker"),defaultValues:0===n.trackerURLs.length?void 0:n.trackerURLs.map(((e,t)=>({id:t,value:e})))})})}),actions:[{clickHandler:null,content:t._("button.cancel"),triggerDismiss:!0,type:"tertiary"},{clickHandler:()=>{if(null==e.current||i||n.isLoadingTrackers)return;l(!0);const t=e.current.getFormData(),r=W(t,"trackers").filter((e=>""!==e));_.A.setTrackers({hashes:Ve.A.selectedTorrents,trackers:r}).then((()=>{l(!1),m.A.setActiveModal(null)}))},content:t._("torrents.set.trackers.button.set"),isLoading:i||n.isLoadingTrackers,triggerDismiss:!1,type:"primary"}]})};var qe=i(9849);const We="4.9.5",Ge="https://github.com/jesec/flood",Ze="# Flood <FloodVersion />\n\n[![Latest release badge](https://img.shields.io/npm/v/flood?label=Latest%20Release)](https://www.npmjs.com/flood) <CommitBadge />\n\n[![Github Actions build status badge](https://github.com/jesec/flood/workflows/Build/badge.svg?branch=master&event=push)](https://github.com/jesec/flood/actions) [![Crowdin](https://badges.crowdin.net/flood/localized.svg)](https://crowdin.com/project/flood) [![Discord server badge](https://img.shields.io/discord/418267176873623553.svg?style=flat-square)](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 />",We).replaceAll("<CommitBadge />",We.length>8?`![${Ge}]("https://img.shields.io/npm/v/@jesec/flood?label=HEAD" "Latest version of rolling build")`:`![${Ge}](https://img.shields.io/github/commits-since/jesec/flood/v${We} "Commits since user's version")`),Qe=()=>(0,g.Y)(d.Suspense,{fallback:null,children:(0,g.Y)(qe.o,{children:Ze})});var Je=i(5767),Ke=i(7230),Xe=i(9119),et=i(8045);const tt=(0,r.PA)((()=>{const e=(0,d.useRef)(null),t=(0,d.useRef)(null),[i,r]=(0,d.useState)(null),[a,c]=(0,d.useState)(!1),[h,u]=(0,d.useState)(!1),{i18n:_}=(0,s.uB)();if((0,d.useEffect)((()=>{Ke.A.currentUser.isAdmin&&Je.A.fetchUsers().then((()=>{c(!0)}))}),[]),!Ke.A.currentUser.isAdmin)return(0,g.FD)(o.lV,{children:[(0,g.Y)(ye,{children:(0,g.Y)(s.x6,{id:"auth.user.accounts"})}),(0,g.Y)(o.fh,{children:(0,g.Y)(o.jQ,{children:(0,g.Y)(s.x6,{id:"auth.message.not.admin"})})})]});const m=!a&&0===Ke.A.users.length,f=H()("interactive-list",{"interactive-list--loading":m});return(0,g.FD)(o.lV,{onSubmit:()=>{if(null==e.current||null==t.current)return;const i=e.current.getFormData();if(null==i.username||""===i.username)r("auth.error.username.empty");else if(null==i.password||""===i.password)r("auth.error.password.empty");else{u(!0);const l=t.current;if(null==l)return r("connection.settings.error.empty"),void u(!1);Je.A.createUser({username:i.username,password:i.password,client:l,level:!0===i.isAdmin?Xe.h.ADMINISTRATOR:Xe.h.USER}).then((()=>{null!=e.current&&e.current.resetForm(),r(null),u(!1)}),(()=>{r("general.error.unknown"),u(!1)})).then(Je.A.fetchUsers)}},ref:e,children:[(0,g.Y)(ye,{children:(0,g.Y)(s.x6,{id:"auth.user.accounts"})}),(0,g.Y)(o.fh,{children:(0,g.Y)(o.ci,{children:(0,g.FD)("ul",{className:f,children:[(0,g.Y)(n.A,{children:m&&(0,g.Y)(l.A,{classNames:"interactive-list__loading-indicator",timeout:{enter:250,exit:250},children:(0,g.Y)("div",{className:"interactive-list__loading-indicator",children:(0,g.Y)(o.hg,{})},"loading-indicator")})}),Ke.A.users.slice().sort(((e,t)=>e.username.localeCompare(t.username))).map((e=>{const t=e.username===Ke.A.currentUser.username;let i=null,l=null;t?i=(0,g.Y)("span",{className:"interactive-list__label__tag tag",children:(0,g.Y)(s.x6,{id:"auth.current.user"})}):l=(0,g.Y)("button",{className:"interactive-list__icon interactive-list__icon--action interactive-list__icon--action--warning",type:"button",onClick:()=>Je.A.deleteUser(e.username).then(Je.A.fetchUsers),children:(0,g.Y)(y.bm,{})});const n=H()("interactive-list__item",{"interactive-list__item--disabled":t});return(0,g.FD)("li",{className:n,children:[(0,g.FD)("span",{className:"interactive-list__label",children:[(0,g.Y)("div",{className:"interactive-list__label__text",children:e.username}),i]}),l]},e.username)}))]})})}),(0,g.Y)(ye,{children:(0,g.Y)(s.x6,{id:"auth.add.user"})}),i&&(0,g.Y)(o.fh,{children:(0,g.Y)(o.jQ,{children:_._(i)})}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{id:"username",label:(0,g.Y)(s.x6,{id:"auth.username"}),placeholder:_._("auth.username"),autoComplete:"username"}),(0,g.Y)(o.Rj,{id:"password",label:(0,g.Y)(s.x6,{id:"auth.password"}),placeholder:_._("auth.password"),autoComplete:"new-password"}),(0,g.Y)(o.Sc,{grow:!1,id:"isAdmin",labelOffset:!0,matchTextboxHeight:!0,children:(0,g.Y)(s.x6,{id:"auth.admin"})})]}),(0,g.Y)(et.A,{onSettingsChange:e=>{t.current=e}}),(0,g.Y)("p",{}),(0,g.Y)(o.fh,{justify:"end",children:(0,g.Y)(o.$n,{isLoading:h,priority:"primary",type:"submit",children:(0,g.Y)(s.x6,{id:"button.add"})})})]})})),it=(e,t)=>null!=e[t]?e[t]:h.A.clientSettings?.[t],lt=e=>{const t=e.target,i=t.name,{value:l,type:n,checked:r}=t;let a={};return a="checkbox"===n?{[i]:r}:{[i]:l},a},nt=e=>{if(e&&0!==e.length)return e.join(", ")},rt=(e="")=>""===e?[]:e.replace(/\s/g,"").split(",").map((e=>Number(e))),at=({onSettingsChange:e,onClientSettingsChange:t})=>{const[i,l]=(0,d.useState)({});return(0,g.FD)(o.lV,{onChange:({event:n,formData:r})=>{const a=n.target;if("dropdownPresetDownload"===a.name||"dropdownPresetUpload"===a.name)return void e({speedLimits:{download:rt(r.dropdownPresetDownload),upload:rt(r.dropdownPresetUpload)}});const s={...i,...lt(n)};l(s),t(s)},children:[(0,g.Y)(ye,{children:(0,g.Y)(s.x6,{id:"settings.bandwidth.transferrate.heading"})}),(0,g.Y)(o.fh,{children:(0,g.Y)(o.Rj,{defaultValue:null!=h.A.floodSettings.speedLimits?nt(h.A.floodSettings.speedLimits.download):0,label:(0,g.Y)(s.x6,{id:"settings.bandwidth.transferrate.dropdown.preset.download.label"}),id:"dropdownPresetDownload"})}),(0,g.Y)(o.fh,{children:(0,g.Y)(o.Rj,{defaultValue:null!=h.A.floodSettings.speedLimits?nt(h.A.floodSettings.speedLimits.upload):0,label:(0,g.Y)(s.x6,{id:"settings.bandwidth.transferrate.dropdown.preset.upload.label"}),id:"dropdownPresetUpload"})}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{defaultValue:it(i,"throttleGlobalDownSpeed"),label:(0,g.Y)(s.x6,{id:"settings.bandwidth.transferrate.global.throttle.download"}),id:"throttleGlobalDownSpeed"}),(0,g.Y)(o.Rj,{defaultValue:it(i,"throttleGlobalUpSpeed"),label:(0,g.Y)(s.x6,{id:"settings.bandwidth.transferrate.global.throttle.upload"}),id:"throttleGlobalUpSpeed"})]}),(0,g.Y)(ye,{children:(0,g.Y)(s.x6,{id:"settings.bandwidth.slots.heading"})}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{defaultValue:it(i,"throttleMaxUploads"),label:(0,g.Y)(s.x6,{id:"settings.bandwidth.slots.upload.label"}),id:"throttleMaxUploads"}),(0,g.Y)(o.Rj,{defaultValue:it(i,"throttleMaxUploadsGlobal"),label:(0,g.Y)(s.x6,{id:"settings.bandwidth.slots.upload.global.label"}),id:"throttleMaxUploadsGlobal"})]}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{defaultValue:it(i,"throttleMaxDownloads"),label:(0,g.Y)(s.x6,{id:"settings.bandwidth.slots.download.label"}),id:"throttleMaxDownloads"}),(0,g.Y)(o.Rj,{defaultValue:it(i,"throttleMaxDownloadsGlobal"),label:(0,g.Y)(s.x6,{id:"settings.bandwidth.slots.download.global.label"}),id:"throttleMaxDownloadsGlobal"})]})]})},st=({onClientSettingsChange:e})=>{const[t,i]=(0,d.useState)({});return(0,g.FD)(o.lV,{onChange:({event:l})=>{const n={...t,...lt(l)};i(n),e(n)},children:[(0,g.Y)(ye,{children:(0,g.Y)(s.x6,{id:"settings.connectivity.incoming.heading"})}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{defaultValue:it(t,"networkPortRange"),id:"networkPortRange",label:(0,g.Y)(s.x6,{id:"settings.connectivity.port.range.label"}),width:"one-quarter"}),(0,g.Y)(o.Sc,{defaultChecked:it(t,"networkPortRandom"),grow:!1,id:"networkPortRandom",labelOffset:!0,matchTextboxHeight:!0,children:(0,g.Y)(s.x6,{id:"settings.connectivity.port.randomize.label"})}),(0,g.Y)(o.Sc,{defaultChecked:it(t,"networkPortOpen"),grow:!1,id:"networkPortOpen",labelOffset:!0,matchTextboxHeight:!0,children:(0,g.Y)(s.x6,{id:"settings.connectivity.port.open.label"})})]}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{defaultValue:it(t,"networkLocalAddress"),id:"networkLocalAddress",label:(0,g.Y)(s.x6,{id:"settings.connectivity.ip.hostname.label"})}),(0,g.Y)(o.Rj,{defaultValue:it(t,"networkHttpMaxOpen"),id:"networkHttpMaxOpen",label:(0,g.Y)(s.x6,{id:"settings.connectivity.max.http.connections"})})]}),(0,g.Y)(ye,{children:(0,g.Y)(s.x6,{id:"settings.connectivity.dpd.heading"})}),(0,g.FD)(o.fh,{children:[(0,g.Y)(o.Rj,{defaultValue:it(t,"dhtPort"),id:"dhtPort",label:(0,g.Y)(s.x6,{id:"settings.connectivity.dht.port.label"}),width:"one-quarter"}),(0,g.Y)(o.Sc,{defaultChecked:it(t,"dht"),grow:!1,id:"dht",labelOffset:!0,matchTextboxHeight:!0,children:(0,g.Y)(s.x6,{id:"settings.connectivity.dht.label"})}),(0,g.