diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f81838b..cd1949b1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,7 @@ jobs: with: generate_release_notes: true files: | - desktop/src-tauri/target/release/bundle/msi/rqbit-desktop_5.0.1_x64_en-US.msi + desktop/src-tauri/target/release/bundle/msi/rqbit-desktop_5.0.2_x64_en-US.msi - name: Build release run: cargo build --profile release-github diff --git a/crates/librqbit/webui/dist/assets/index.js b/crates/librqbit/webui/dist/assets/index.js index fad775bc..41b0f303 100644 --- a/crates/librqbit/webui/dist/assets/index.js +++ b/crates/librqbit/webui/dist/assets/index.js @@ -41,4 +41,4 @@ Error generating stack: `+o.message+` Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r=[],l=0;l=0)&&(n[l]=e[l]);return n}function ca(e){return"default"+e.charAt(0).toUpperCase()+e.substr(1)}function xh(e){var t=Sh(e,"string");return typeof t=="symbol"?t:String(t)}function Sh(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Eh(e,t,n){var r=y.useRef(e!==void 0),l=y.useState(t),o=l[0],i=l[1],u=e!==void 0,s=r.current;return r.current=u,!u&&s&&o!==t&&i(t),[u?e:o,y.useCallback(function(a){for(var m=arguments.length,h=new Array(m>1?m-1:0),d=1;d{o.target===e&&(l(),t(o))},n+r)}function Kh(e){e.offsetHeight}const pa=e=>!e||typeof e=="function"?e:t=>{e.current=t};function Gh(e,t){const n=pa(e),r=pa(t);return l=>{n&&n(l),r&&r(l)}}function ho(e,t){return y.useMemo(()=>Gh(e,t),[e,t])}function Xh(e){return e&&"setState"in e?Tn.findDOMNode(e):e??null}const Yh=we.forwardRef(({onEnter:e,onEntering:t,onEntered:n,onExit:r,onExiting:l,onExited:o,addEndListener:i,children:u,childRef:s,...a},m)=>{const h=y.useRef(null),d=ho(h,s),g=k=>{d(Xh(k))},w=k=>_=>{k&&h.current&&k(h.current,_)},E=y.useCallback(w(e),[e]),L=y.useCallback(w(t),[t]),p=y.useCallback(w(n),[n]),c=y.useCallback(w(r),[r]),v=y.useCallback(w(l),[l]),x=y.useCallback(w(o),[o]),N=y.useCallback(w(i),[i]);return f.jsx(Uh,{ref:m,...a,onEnter:E,onEntered:p,onEntering:L,onExit:c,onExited:x,onExiting:v,addEndListener:N,nodeRef:h,children:typeof u=="function"?(k,_)=>u(k,{..._,ref:g}):we.cloneElement(u,{ref:g})})}),Zh=Yh;function Jh(e){const t=y.useRef(e);return y.useEffect(()=>{t.current=e},[e]),t}function ze(e){const t=Jh(e);return y.useCallback(function(...n){return t.current&&t.current(...n)},[t])}const Jf=e=>y.forwardRef((t,n)=>f.jsx("div",{...t,ref:n,className:M(t.className,e)})),qf=Jf("h4");qf.displayName="DivStyledAsH4";const bf=y.forwardRef(({className:e,bsPrefix:t,as:n=qf,...r},l)=>(t=H(t,"alert-heading"),f.jsx(n,{ref:l,className:M(e,t),...r})));bf.displayName="AlertHeading";const qh=bf;function bh(){return y.useState(null)}function ev(){const e=y.useRef(!0),t=y.useRef(()=>e.current);return y.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),t.current}function tv(e){const t=y.useRef(null);return y.useEffect(()=>{t.current=e}),t.current}const nv=typeof global<"u"&&global.navigator&&global.navigator.product==="ReactNative",rv=typeof document<"u",ma=rv||nv?y.useLayoutEffect:y.useEffect,lv=["as","disabled"];function ov(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function iv(e){return!e||e.trim()==="#"}function Vu({tagName:e,disabled:t,href:n,target:r,rel:l,role:o,onClick:i,tabIndex:u=0,type:s}){e||(n!=null||r!=null||l!=null?e="a":e="button");const a={tagName:e};if(e==="button")return[{type:s||"button",disabled:t},a];const m=d=>{if((t||e==="a"&&iv(n))&&d.preventDefault(),t){d.stopPropagation();return}i==null||i(d)},h=d=>{d.key===" "&&(d.preventDefault(),m(d))};return e==="a"&&(n||(n="#"),t&&(n=void 0)),[{role:o??"button",disabled:void 0,tabIndex:t?void 0:u,href:n,target:e==="a"?r:void 0,"aria-disabled":t||void 0,rel:e==="a"?l:void 0,onClick:m,onKeyDown:h},a]}const uv=y.forwardRef((e,t)=>{let{as:n,disabled:r}=e,l=ov(e,lv);const[o,{tagName:i}]=Vu(Object.assign({tagName:n,disabled:r},l));return f.jsx(i,Object.assign({},l,o,{ref:t}))});uv.displayName="Button";const sv=["onKeyDown"];function av(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function cv(e){return!e||e.trim()==="#"}const ed=y.forwardRef((e,t)=>{let{onKeyDown:n}=e,r=av(e,sv);const[l]=Vu(Object.assign({tagName:"a"},r)),o=ze(i=>{l.onKeyDown(i),n==null||n(i)});return cv(r.href)||r.role==="button"?f.jsx("a",Object.assign({ref:t},r,l,{onKeyDown:o})):f.jsx("a",Object.assign({ref:t},r,{onKeyDown:n}))});ed.displayName="Anchor";const fv=ed,td=y.forwardRef(({className:e,bsPrefix:t,as:n=fv,...r},l)=>(t=H(t,"alert-link"),f.jsx(n,{ref:l,className:M(e,t),...r})));td.displayName="AlertLink";const dv=td,pv={[St]:"show",[Wt]:"show"},nd=y.forwardRef(({className:e,children:t,transitionClasses:n={},onEnter:r,...l},o)=>{const i={in:!1,timeout:300,mountOnEnter:!1,unmountOnExit:!1,appear:!1,...l},u=y.useCallback((s,a)=>{Kh(s),r==null||r(s,a)},[r]);return f.jsx(Zh,{ref:o,addEndListener:Qh,...i,onEnter:u,childRef:t.ref,children:(s,a)=>y.cloneElement(t,{...a,className:M("fade",e,t.props.className,pv[s],n[s])})})});nd.displayName="Fade";const Kl=nd,mv={"aria-label":st.string,onClick:st.func,variant:st.oneOf(["white"])},Wu=y.forwardRef(({className:e,variant:t,"aria-label":n="Close",...r},l)=>f.jsx("button",{ref:l,type:"button",className:M("btn-close",t&&`btn-close-${t}`,e),"aria-label":n,...r}));Wu.displayName="CloseButton";Wu.propTypes=mv;const rd=Wu,ld=y.forwardRef((e,t)=>{const{bsPrefix:n,show:r=!0,closeLabel:l="Close alert",closeVariant:o,className:i,children:u,variant:s="primary",onClose:a,dismissible:m,transition:h=Kl,...d}=kh(e,{show:"onClose"}),g=H(n,"alert"),w=ze(p=>{a&&a(!1,p)}),E=h===!0?Kl:h,L=f.jsxs("div",{role:"alert",...E?void 0:d,ref:t,className:M(i,g,s&&`${g}-${s}`,m&&`${g}-dismissible`),children:[m&&f.jsx(rd,{onClick:w,"aria-label":l,variant:o}),u]});return E?f.jsx(E,{unmountOnExit:!0,...d,ref:void 0,in:r,children:L}):r?L:null});ld.displayName="Alert";const ha=Object.assign(ld,{Link:dv,Heading:qh}),od=y.forwardRef(({as:e,bsPrefix:t,variant:n="primary",size:r,active:l=!1,disabled:o=!1,className:i,...u},s)=>{const a=H(t,"btn"),[m,{tagName:h}]=Vu({tagName:e,disabled:o,...u}),d=h;return f.jsx(d,{...m,...u,ref:s,disabled:o,className:M(i,a,l&&"active",n&&`${a}-${n}`,r&&`${a}-${r}`,u.href&&o&&"disabled")})});od.displayName="Button";const nn=od;function hv(e){const t=y.useRef(e);return t.current=e,t}function id(e){const t=hv(e);y.useEffect(()=>()=>t.current(),[])}function vv(e,t){let n=0;return y.Children.map(e,r=>y.isValidElement(r)?t(r,n++):r)}function yv(e,t){return y.Children.toArray(e).some(n=>y.isValidElement(n)&&n.type===t)}function gv({as:e,bsPrefix:t,className:n,...r}){t=H(t,"col");const l=Vf(),o=Wf(),i=[],u=[];return l.forEach(s=>{const a=r[s];delete r[s];let m,h,d;typeof a=="object"&&a!=null?{span:m,offset:h,order:d}=a:m=a;const g=s!==o?`-${s}`:"";m&&i.push(m===!0?`${t}${g}`:`${t}${g}-${m}`),d!=null&&u.push(`order${g}-${d}`),h!=null&&u.push(`offset${g}-${h}`)}),[{...r,className:M(n,...i,...u)},{as:e,bsPrefix:t,spans:i}]}const ud=y.forwardRef((e,t)=>{const[{className:n,...r},{as:l="div",bsPrefix:o,spans:i}]=gv(e);return f.jsx(l,{...r,ref:t,className:M(n,!i.length&&o)})});ud.displayName="Col";const Qu=ud,sd=y.forwardRef(({bsPrefix:e,fluid:t=!1,as:n="div",className:r,...l},o)=>{const i=H(e,"container"),u=typeof t=="string"?`-${t}`:"-fluid";return f.jsx(n,{ref:o,...l,className:M(r,t?`${i}${u}`:i)})});sd.displayName="Container";const wv=sd;var xv=Function.prototype.bind.call(Function.prototype.call,[].slice);function pn(e,t){return xv(e.querySelectorAll(t))}function va(e,t){if(e.contains)return e.contains(t);if(e.compareDocumentPosition)return e===t||!!(e.compareDocumentPosition(t)&16)}const Sv="data-rr-ui-";function Ev(e){return`${Sv}${e}`}const ad=y.createContext(Qn?window:void 0);ad.Provider;function Ku(){return y.useContext(ad)}const kv={type:st.string,tooltip:st.bool,as:st.elementType},Gu=y.forwardRef(({as:e="div",className:t,type:n="valid",tooltip:r=!1,...l},o)=>f.jsx(e,{...l,ref:o,className:M(t,`${n}-${r?"tooltip":"feedback"}`)}));Gu.displayName="Feedback";Gu.propTypes=kv;const cd=Gu,Cv=y.createContext({}),pt=Cv,fd=y.forwardRef(({id:e,bsPrefix:t,className:n,type:r="checkbox",isValid:l=!1,isInvalid:o=!1,as:i="input",...u},s)=>{const{controlId:a}=y.useContext(pt);return t=H(t,"form-check-input"),f.jsx(i,{...u,ref:s,type:r,id:e||a,className:M(n,t,l&&"is-valid",o&&"is-invalid")})});fd.displayName="FormCheckInput";const dd=fd,pd=y.forwardRef(({bsPrefix:e,className:t,htmlFor:n,...r},l)=>{const{controlId:o}=y.useContext(pt);return e=H(e,"form-check-label"),f.jsx("label",{...r,ref:l,htmlFor:n||o,className:M(t,e)})});pd.displayName="FormCheckLabel";const Xi=pd,md=y.forwardRef(({id:e,bsPrefix:t,bsSwitchPrefix:n,inline:r=!1,reverse:l=!1,disabled:o=!1,isValid:i=!1,isInvalid:u=!1,feedbackTooltip:s=!1,feedback:a,feedbackType:m,className:h,style:d,title:g="",type:w="checkbox",label:E,children:L,as:p="input",...c},v)=>{t=H(t,"form-check"),n=H(n,"form-switch");const{controlId:x}=y.useContext(pt),N=y.useMemo(()=>({controlId:e||x}),[x,e]),k=!L&&E!=null&&E!==!1||yv(L,Xi),_=f.jsx(dd,{...c,type:w==="switch"?"checkbox":w,ref:v,isValid:i,isInvalid:u,disabled:o,as:p});return f.jsx(pt.Provider,{value:N,children:f.jsx("div",{style:d,className:M(h,k&&t,r&&`${t}-inline`,l&&`${t}-reverse`,w==="switch"&&n),children:L||f.jsxs(f.Fragment,{children:[_,k&&f.jsx(Xi,{title:g,children:E}),a&&f.jsx(cd,{type:m,tooltip:s,children:a})]})})})});md.displayName="FormCheck";const Gl=Object.assign(md,{Input:dd,Label:Xi}),hd=y.forwardRef(({bsPrefix:e,type:t,size:n,htmlSize:r,id:l,className:o,isValid:i=!1,isInvalid:u=!1,plaintext:s,readOnly:a,as:m="input",...h},d)=>{const{controlId:g}=y.useContext(pt);return e=H(e,"form-control"),f.jsx(m,{...h,type:t,size:r,ref:d,readOnly:a,id:l||g,className:M(o,s?`${e}-plaintext`:e,n&&`${e}-${n}`,t==="color"&&`${e}-color`,i&&"is-valid",u&&"is-invalid")})});hd.displayName="FormControl";const _v=Object.assign(hd,{Feedback:cd}),vd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"form-floating"),f.jsx(n,{ref:l,className:M(e,t),...r})));vd.displayName="FormFloating";const Nv=vd,yd=y.forwardRef(({controlId:e,as:t="div",...n},r)=>{const l=y.useMemo(()=>({controlId:e}),[e]);return f.jsx(pt.Provider,{value:l,children:f.jsx(t,{...n,ref:r})})});yd.displayName="FormGroup";const gd=yd,wd=y.forwardRef(({as:e="label",bsPrefix:t,column:n=!1,visuallyHidden:r=!1,className:l,htmlFor:o,...i},u)=>{const{controlId:s}=y.useContext(pt);t=H(t,"form-label");let a="col-form-label";typeof n=="string"&&(a=`${a} ${a}-${n}`);const m=M(l,t,r&&"visually-hidden",n&&a);return o=o||s,n?f.jsx(Qu,{ref:u,as:"label",className:m,htmlFor:o,...i}):f.jsx(e,{ref:u,className:m,htmlFor:o,...i})});wd.displayName="FormLabel";const Tv=wd,xd=y.forwardRef(({bsPrefix:e,className:t,id:n,...r},l)=>{const{controlId:o}=y.useContext(pt);return e=H(e,"form-range"),f.jsx("input",{...r,type:"range",ref:l,className:M(t,e),id:n||o})});xd.displayName="FormRange";const jv=xd,Sd=y.forwardRef(({bsPrefix:e,size:t,htmlSize:n,className:r,isValid:l=!1,isInvalid:o=!1,id:i,...u},s)=>{const{controlId:a}=y.useContext(pt);return e=H(e,"form-select"),f.jsx("select",{...u,size:n,ref:s,className:M(r,e,t&&`${e}-${t}`,l&&"is-valid",o&&"is-invalid"),id:i||a})});Sd.displayName="FormSelect";const Lv=Sd,Ed=y.forwardRef(({bsPrefix:e,className:t,as:n="small",muted:r,...l},o)=>(e=H(e,"form-text"),f.jsx(n,{...l,ref:o,className:M(t,e,r&&"text-muted")})));Ed.displayName="FormText";const Ov=Ed,kd=y.forwardRef((e,t)=>f.jsx(Gl,{...e,ref:t,type:"switch"}));kd.displayName="Switch";const Rv=Object.assign(kd,{Input:Gl.Input,Label:Gl.Label}),Cd=y.forwardRef(({bsPrefix:e,className:t,children:n,controlId:r,label:l,...o},i)=>(e=H(e,"form-floating"),f.jsxs(gd,{ref:i,className:M(t,e),controlId:r,...o,children:[n,f.jsx("label",{htmlFor:r,children:l})]})));Cd.displayName="FloatingLabel";const Pv=Cd,Fv={_ref:st.any,validated:st.bool,as:st.elementType},Xu=y.forwardRef(({className:e,validated:t,as:n="form",...r},l)=>f.jsx(n,{...r,ref:l,className:M(e,t&&"was-validated")}));Xu.displayName="Form";Xu.propTypes=Fv;const pe=Object.assign(Xu,{Group:gd,Control:_v,Floating:Nv,Check:Gl,Switch:Rv,Label:Tv,Text:Ov,Range:jv,Select:Lv,FloatingLabel:Pv});var sl;function ya(e){if((!sl&&sl!==0||e)&&Qn){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),sl=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return sl}function Wo(e){e===void 0&&(e=mo());try{var t=e.activeElement;return!t||!t.nodeName?null:t}catch{return e.body}}function Mv(e=document){const t=e.defaultView;return Math.abs(t.innerWidth-e.documentElement.clientWidth)}const ga=Ev("modal-open");class zv{constructor({ownerDocument:t,handleContainerOverflow:n=!0,isRTL:r=!1}={}){this.handleContainerOverflow=n,this.isRTL=r,this.modals=[],this.ownerDocument=t}getScrollbarWidth(){return Mv(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(t){}removeModalAttributes(t){}setContainerStyle(t){const n={overflow:"hidden"},r=this.isRTL?"paddingLeft":"paddingRight",l=this.getElement();t.style={overflow:l.style.overflow,[r]:l.style[r]},t.scrollBarWidth&&(n[r]=`${parseInt(Zt(l,r)||"0",10)+t.scrollBarWidth}px`),l.setAttribute(ga,""),Zt(l,n)}reset(){[...this.modals].forEach(t=>this.remove(t))}removeContainerStyle(t){const n=this.getElement();n.removeAttribute(ga),Object.assign(n.style,t.style)}add(t){let n=this.modals.indexOf(t);return n!==-1||(n=this.modals.length,this.modals.push(t),this.setModalAttributes(t),n!==0)||(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state)),n}remove(t){const n=this.modals.indexOf(t);n!==-1&&(this.modals.splice(n,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(t))}isTopModal(t){return!!this.modals.length&&this.modals[this.modals.length-1]===t}}const Yu=zv,Qo=(e,t)=>Qn?e==null?(t||mo()).body:(typeof e=="function"&&(e=e()),e&&"current"in e&&(e=e.current),e&&("nodeType"in e||e.getBoundingClientRect)?e:null):null;function $v(e,t){const n=Ku(),[r,l]=y.useState(()=>Qo(e,n==null?void 0:n.document));if(!r){const o=Qo(e);o&&l(o)}return y.useEffect(()=>{t&&r&&t(r)},[t,r]),y.useEffect(()=>{const o=Qo(e);o!==r&&l(o)},[e,r]),r}function Iv({children:e,in:t,onExited:n,mountOnEnter:r,unmountOnExit:l}){const o=y.useRef(null),i=y.useRef(t),u=ze(n);y.useEffect(()=>{t?i.current=!0:u(o.current)},[t,u]);const s=ho(o,e.ref),a=y.cloneElement(e,{ref:s});return t?a:l||!i.current&&r?null:a}function Dv({in:e,onTransition:t}){const n=y.useRef(null),r=y.useRef(!0),l=ze(t);return ma(()=>{if(!n.current)return;let o=!1;return l({in:e,element:n.current,initial:r.current,isStale:()=>o}),()=>{o=!0}},[e,l]),ma(()=>(r.current=!1,()=>{r.current=!0}),[]),n}function Av({children:e,in:t,onExited:n,onEntered:r,transition:l}){const[o,i]=y.useState(!t);t&&o&&i(!1);const u=Dv({in:!!t,onTransition:a=>{const m=()=>{a.isStale()||(a.in?r==null||r(a.element,a.initial):(i(!0),n==null||n(a.element)))};Promise.resolve(l(a)).then(m,h=>{throw a.in||i(!0),h})}}),s=ho(u,e.ref);return o&&!t?null:y.cloneElement(e,{ref:s})}function wa(e,t,n){return e?f.jsx(e,Object.assign({},n)):t?f.jsx(Av,Object.assign({},n,{transition:t})):f.jsx(Iv,Object.assign({},n))}function Bv(e){return e.code==="Escape"||e.keyCode===27}const Uv=["show","role","className","style","children","backdrop","keyboard","onBackdropClick","onEscapeKeyDown","transition","runTransition","backdropTransition","runBackdropTransition","autoFocus","enforceFocus","restoreFocus","restoreFocusOptions","renderDialog","renderBackdrop","manager","container","onShow","onHide","onExit","onExited","onExiting","onEnter","onEntering","onEntered"];function Hv(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}let Ko;function Vv(e){return Ko||(Ko=new Yu({ownerDocument:e==null?void 0:e.document})),Ko}function Wv(e){const t=Ku(),n=e||Vv(t),r=y.useRef({dialog:null,backdrop:null});return Object.assign(r.current,{add:()=>n.add(r.current),remove:()=>n.remove(r.current),isTopModal:()=>n.isTopModal(r.current),setDialogRef:y.useCallback(l=>{r.current.dialog=l},[]),setBackdropRef:y.useCallback(l=>{r.current.backdrop=l},[])})}const _d=y.forwardRef((e,t)=>{let{show:n=!1,role:r="dialog",className:l,style:o,children:i,backdrop:u=!0,keyboard:s=!0,onBackdropClick:a,onEscapeKeyDown:m,transition:h,runTransition:d,backdropTransition:g,runBackdropTransition:w,autoFocus:E=!0,enforceFocus:L=!0,restoreFocus:p=!0,restoreFocusOptions:c,renderDialog:v,renderBackdrop:x=K=>f.jsx("div",Object.assign({},K)),manager:N,container:k,onShow:_,onHide:j=()=>{},onExit:B,onExited:P,onExiting:ie,onEnter:Ge,onEntering:Xe,onEntered:un}=e,Kn=Hv(e,Uv);const Oe=Ku(),Ye=$v(k),C=Wv(N),O=ev(),R=tv(n),[I,A]=y.useState(!n),fe=y.useRef(null);y.useImperativeHandle(t,()=>C,[C]),Qn&&!R&&n&&(fe.current=Wo(Oe==null?void 0:Oe.document)),n&&I&&A(!1);const Re=ze(()=>{if(C.add(),an.current=Ql(document,"keydown",vo),sn.current=Ql(document,"focus",()=>setTimeout(Pe),!0),_&&_(),E){var K,Vr;const Yn=Wo((K=(Vr=C.dialog)==null?void 0:Vr.ownerDocument)!=null?K:Oe==null?void 0:Oe.document);C.dialog&&Yn&&!va(C.dialog,Yn)&&(fe.current=Yn,C.dialog.focus())}}),tt=ze(()=>{if(C.remove(),an.current==null||an.current(),sn.current==null||sn.current(),p){var K;(K=fe.current)==null||K.focus==null||K.focus(c),fe.current=null}});y.useEffect(()=>{!n||!Ye||Re()},[n,Ye,Re]),y.useEffect(()=>{I&&tt()},[I,tt]),id(()=>{tt()});const Pe=ze(()=>{if(!L||!O()||!C.isTopModal())return;const K=Wo(Oe==null?void 0:Oe.document);C.dialog&&K&&!va(C.dialog,K)&&C.dialog.focus()}),vt=ze(K=>{K.target===K.currentTarget&&(a==null||a(K),u===!0&&j())}),vo=ze(K=>{s&&Bv(K)&&C.isTopModal()&&(m==null||m(K),K.defaultPrevented||j())}),sn=y.useRef(),an=y.useRef(),Gn=(...K)=>{A(!0),P==null||P(...K)};if(!Ye)return null;const Hr=Object.assign({role:r,ref:C.setDialogRef,"aria-modal":r==="dialog"?!0:void 0},Kn,{style:o,className:l,tabIndex:-1});let Xn=v?v(Hr):f.jsx("div",Object.assign({},Hr,{children:y.cloneElement(i,{role:"document"})}));Xn=wa(h,d,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:B,onExiting:ie,onExited:Gn,onEnter:Ge,onEntering:Xe,onEntered:un,children:Xn});let Bt=null;return u&&(Bt=x({ref:C.setBackdropRef,onClick:vt}),Bt=wa(g,w,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:Bt})),f.jsx(f.Fragment,{children:Tn.createPortal(f.jsxs(f.Fragment,{children:[Bt,Xn]}),Ye)})});_d.displayName="Modal";const Qv=Object.assign(_d,{Manager:Yu});function Kv(e,t){return e.classList?!!t&&e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function Gv(e,t){e.classList?e.classList.add(t):Kv(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function xa(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function Xv(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=xa(e.className,t):e.setAttribute("class",xa(e.className&&e.className.baseVal||"",t))}const mn={FIXED_CONTENT:".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",STICKY_CONTENT:".sticky-top",NAVBAR_TOGGLER:".navbar-toggler"};class Yv extends Yu{adjustAndStore(t,n,r){const l=n.style[t];n.dataset[t]=l,Zt(n,{[t]:`${parseFloat(Zt(n,t))+r}px`})}restore(t,n){const r=n.dataset[t];r!==void 0&&(delete n.dataset[t],Zt(n,{[t]:r}))}setContainerStyle(t){super.setContainerStyle(t);const n=this.getElement();if(Gv(n,"modal-open"),!t.scrollBarWidth)return;const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";pn(n,mn.FIXED_CONTENT).forEach(o=>this.adjustAndStore(r,o,t.scrollBarWidth)),pn(n,mn.STICKY_CONTENT).forEach(o=>this.adjustAndStore(l,o,-t.scrollBarWidth)),pn(n,mn.NAVBAR_TOGGLER).forEach(o=>this.adjustAndStore(l,o,t.scrollBarWidth))}removeContainerStyle(t){super.removeContainerStyle(t);const n=this.getElement();Xv(n,"modal-open");const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";pn(n,mn.FIXED_CONTENT).forEach(o=>this.restore(r,o)),pn(n,mn.STICKY_CONTENT).forEach(o=>this.restore(l,o)),pn(n,mn.NAVBAR_TOGGLER).forEach(o=>this.restore(l,o))}}let Go;function Zv(e){return Go||(Go=new Yv(e)),Go}const Nd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-body"),f.jsx(n,{ref:l,className:M(e,t),...r})));Nd.displayName="ModalBody";const Jv=Nd,qv=y.createContext({onHide(){}}),Td=qv,jd=y.forwardRef(({bsPrefix:e,className:t,contentClassName:n,centered:r,size:l,fullscreen:o,children:i,scrollable:u,...s},a)=>{e=H(e,"modal");const m=`${e}-dialog`,h=typeof o=="string"?`${e}-fullscreen-${o}`:`${e}-fullscreen`;return f.jsx("div",{...s,ref:a,className:M(m,t,l&&`${e}-${l}`,r&&`${m}-centered`,u&&`${m}-scrollable`,o&&h),children:f.jsx("div",{className:M(`${e}-content`,n),children:i})})});jd.displayName="ModalDialog";const Ld=jd,Od=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-footer"),f.jsx(n,{ref:l,className:M(e,t),...r})));Od.displayName="ModalFooter";const bv=Od,e0=y.forwardRef(({closeLabel:e="Close",closeVariant:t,closeButton:n=!1,onHide:r,children:l,...o},i)=>{const u=y.useContext(Td),s=ze(()=>{u==null||u.onHide(),r==null||r()});return f.jsxs("div",{ref:i,...o,children:[l,n&&f.jsx(rd,{"aria-label":e,variant:t,onClick:s})]})}),t0=e0,Rd=y.forwardRef(({bsPrefix:e,className:t,closeLabel:n="Close",closeButton:r=!1,...l},o)=>(e=H(e,"modal-header"),f.jsx(t0,{ref:o,...l,className:M(t,e),closeLabel:n,closeButton:r})));Rd.displayName="ModalHeader";const n0=Rd,r0=Jf("h4"),Pd=y.forwardRef(({className:e,bsPrefix:t,as:n=r0,...r},l)=>(t=H(t,"modal-title"),f.jsx(n,{ref:l,className:M(e,t),...r})));Pd.displayName="ModalTitle";const l0=Pd;function o0(e){return f.jsx(Kl,{...e,timeout:null})}function i0(e){return f.jsx(Kl,{...e,timeout:null})}const Fd=y.forwardRef(({bsPrefix:e,className:t,style:n,dialogClassName:r,contentClassName:l,children:o,dialogAs:i=Ld,"aria-labelledby":u,"aria-describedby":s,"aria-label":a,show:m=!1,animation:h=!0,backdrop:d=!0,keyboard:g=!0,onEscapeKeyDown:w,onShow:E,onHide:L,container:p,autoFocus:c=!0,enforceFocus:v=!0,restoreFocus:x=!0,restoreFocusOptions:N,onEntered:k,onExit:_,onExiting:j,onEnter:B,onEntering:P,onExited:ie,backdropClassName:Ge,manager:Xe,...un},Kn)=>{const[Oe,Ye]=y.useState({}),[C,O]=y.useState(!1),R=y.useRef(!1),I=y.useRef(!1),A=y.useRef(null),[fe,Re]=bh(),tt=ho(Kn,Re),Pe=ze(L),vt=Th();e=H(e,"modal");const vo=y.useMemo(()=>({onHide:Pe}),[Pe]);function sn(){return Xe||Zv({isRTL:vt})}function an($){if(!Qn)return;const cn=sn().getScrollbarWidth()>0,es=$.scrollHeight>mo($).documentElement.clientHeight;Ye({paddingRight:cn&&!es?ya():void 0,paddingLeft:!cn&&es?ya():void 0})}const Gn=ze(()=>{fe&&an(fe.dialog)});id(()=>{Gi(window,"resize",Gn),A.current==null||A.current()});const Hr=()=>{R.current=!0},Xn=$=>{R.current&&fe&&$.target===fe.dialog&&(I.current=!0),R.current=!1},Bt=()=>{O(!0),A.current=Zf(fe.dialog,()=>{O(!1)})},K=$=>{$.target===$.currentTarget&&Bt()},Vr=$=>{if(d==="static"){K($);return}if(I.current||$.target!==$.currentTarget){I.current=!1;return}L==null||L()},Yn=$=>{g?w==null||w($):($.preventDefault(),d==="static"&&Bt())},Vd=($,cn)=>{$&&an($),B==null||B($,cn)},Wd=$=>{A.current==null||A.current(),_==null||_($)},Qd=($,cn)=>{P==null||P($,cn),Yf(window,"resize",Gn)},Kd=$=>{$&&($.style.display=""),ie==null||ie($),Gi(window,"resize",Gn)},Gd=y.useCallback($=>f.jsx("div",{...$,className:M(`${e}-backdrop`,Ge,!h&&"show")}),[h,Ge,e]),bu={...n,...Oe};bu.display="block";const Xd=$=>f.jsx("div",{role:"dialog",...$,style:bu,className:M(t,e,C&&`${e}-static`,!h&&"show"),onClick:d?Vr:void 0,onMouseUp:Xn,"aria-label":a,"aria-labelledby":u,"aria-describedby":s,children:f.jsx(i,{...un,onMouseDown:Hr,className:r,contentClassName:l,children:o})});return f.jsx(Td.Provider,{value:vo,children:f.jsx(Qv,{show:m,ref:tt,backdrop:d,container:p,keyboard:!0,autoFocus:c,enforceFocus:v,restoreFocus:x,restoreFocusOptions:N,onEscapeKeyDown:Yn,onShow:E,onHide:L,onEnter:Vd,onEntering:Qd,onEntered:k,onExit:Wd,onExiting:j,onExited:Kd,manager:sn(),transition:h?o0:void 0,backdropTransition:h?i0:void 0,renderBackdrop:Gd,renderDialog:Xd})})});Fd.displayName="Modal";const ge=Object.assign(Fd,{Body:Jv,Header:n0,Title:l0,Footer:bv,Dialog:Ld,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150}),Sa=1e3;function u0(e,t,n){const r=(e-t)/(n-t)*100;return Math.round(r*Sa)/Sa}function Ea({min:e,now:t,max:n,label:r,visuallyHidden:l,striped:o,animated:i,className:u,style:s,variant:a,bsPrefix:m,...h},d){return f.jsx("div",{ref:d,...h,role:"progressbar",className:M(u,`${m}-bar`,{[`bg-${a}`]:a,[`${m}-bar-animated`]:i,[`${m}-bar-striped`]:i||o}),style:{width:`${u0(t,e,n)}%`,...s},"aria-valuenow":t,"aria-valuemin":e,"aria-valuemax":n,children:l?f.jsx("span",{className:"visually-hidden",children:r}):r})}const Md=y.forwardRef(({isChild:e=!1,...t},n)=>{const r={min:0,max:100,animated:!1,visuallyHidden:!1,striped:!1,...t};if(r.bsPrefix=H(r.bsPrefix,"progress"),e)return Ea(r,n);const{min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:d,className:g,children:w,...E}=r;return f.jsx("div",{ref:n,...E,className:M(g,h),children:w?vv(w,L=>y.cloneElement(L,{isChild:!0})):Ea({min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:d},n)})});Md.displayName="ProgressBar";const s0=Md,zd=y.forwardRef(({bsPrefix:e,className:t,as:n="div",...r},l)=>{const o=H(e,"row"),i=Vf(),u=Wf(),s=`${o}-cols`,a=[];return i.forEach(m=>{const h=r[m];delete r[m];let d;h!=null&&typeof h=="object"?{cols:d}=h:d=h;const g=m!==u?`-${m}`:"";d!=null&&a.push(`${s}${g}-${d}`)}),f.jsx(n,{ref:l,...r,className:M(t,o,...a)})});zd.displayName="Row";const $d=zd,Id=y.forwardRef(({bsPrefix:e,variant:t,animation:n="border",size:r,as:l="div",className:o,...i},u)=>{e=H(e,"spinner");const s=`${e}-${n}`;return f.jsx(l,{ref:u,...i,className:M(o,s,r&&`${s}-${r}`,t&&`text-${t}`)})});Id.displayName="Spinner";const Un=Id,Xl="initializing",Dd="paused",Ad="live",a0="error";function Zu(e,t){let n,r=t;const l=async()=>{if(r=await e(),r==null)throw"asyncCallback returned null or undefined";o()};let o=()=>{n=setTimeout(l,r)};return o(),()=>{clearTimeout(n)}}function c0(e,t){let n;const r=async()=>{await e().then(()=>!1,()=>!0)&&l()};let l=o=>{n=setTimeout(r,o!==void 0?o:t)};return l(0),()=>clearTimeout(n)}const Xo=({onClick:e,disabled:t,color:n,children:r})=>{const l=i=>{i.stopPropagation(),!t&&e()},o=n?`text-${n}`:"";return f.jsx("a",{className:`p-1 ${o}`,onClick:l,href:"#",children:r})},zr=e=>{var r,l,o;let{error:t,remove:n}=e;return t==null?null:f.jsxs(ha,{variant:"danger",onClose:n,dismissible:n!=null,children:[f.jsx(ha.Heading,{children:t.text}),((r=t.details)==null?void 0:r.statusText)&&f.jsx("p",{children:f.jsx("strong",{children:(l=t.details)==null?void 0:l.statusText})}),f.jsx("pre",{children:(o=t.details)==null?void 0:o.text})]})},f0=({id:e,show:t,onHide:n})=>{if(!t)return null;const[r,l]=y.useState(!1),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(Ur),m=y.useContext(on),h=()=>{l(!1),i(null),s(!1),n()},d=()=>{s(!0),(r?m.delete:m.forget)(e).then(()=>{a.refreshTorrents(),h()}).catch(w=>{i({text:`Error deleting torrent id=${e}`,details:w}),s(!1)})};return f.jsxs(ge,{show:t,onHide:h,children:[f.jsx(ge.Header,{closeButton:!0,children:"Delete torrent"}),f.jsxs(ge.Body,{children:[f.jsx(pe,{children:f.jsx(pe.Group,{controlId:"delete-torrent",children:f.jsx(pe.Check,{type:"checkbox",label:"Also delete files",checked:r,onChange:()=>l(!r)})})}),o&&f.jsx(zr,{error:o})]}),f.jsxs(ge.Footer,{children:[u&&f.jsx(Un,{}),f.jsx(nn,{variant:"primary",onClick:d,disabled:u,children:"OK"}),f.jsx(nn,{variant:"secondary",onClick:h,children:"Cancel"})]})]})};var Bd={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ka=we.createContext&&we.createContext(Bd),Mt=globalThis&&globalThis.__assign||function(){return Mt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n{let n=t.state,[r,l]=y.useState(!1),[o,i]=y.useState(!1),u=y.useContext(Bf);const s=n=="live",a=n=="paused"||n=="error",m=y.useContext(Ur),h=y.useContext(on),d=()=>{l(!0),h.start(e).then(()=>{u.refresh()},L=>{m.setCloseableError({text:`Error starting torrent id=${e}`,details:L})}).finally(()=>l(!1))},g=()=>{l(!0),h.pause(e).then(()=>{u.refresh()},L=>{m.setCloseableError({text:`Error pausing torrent id=${e}`,details:L})}).finally(()=>l(!1))},w=()=>{l(!0),i(!0)},E=()=>{l(!1),i(!1)};return f.jsx($d,{children:f.jsxs(Qu,{children:[a&&f.jsx(Xo,{onClick:d,disabled:r,color:"success",children:f.jsx(h0,{})}),s&&f.jsx(Xo,{onClick:g,disabled:r,children:f.jsx(m0,{})}),f.jsx(Xo,{onClick:w,disabled:r,color:"danger",children:f.jsx(v0,{})}),f.jsx(f0,{id:e,show:o,onHide:E})]})})};function qu(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+n[r]}const g0=({statsResponse:e})=>{var t,n;switch(e.state){case Dd:return"Paused";case Xl:return"Checking files";case a0:return"Error"}return e.state!="live"||e.live===null?e.state:f.jsxs(f.Fragment,{children:[!e.finished&&f.jsxs("div",{className:"download-speed",children:["↓ ",(t=e.live.download_speed)==null?void 0:t.human_readable]}),f.jsxs("div",{className:"upload-speed",children:["↑ ",(n=e.live.upload_speed)==null?void 0:n.human_readable,e.live.snapshot.uploaded_bytes>0&&f.jsxs("span",{children:[" ","(",qu(e.live.snapshot.uploaded_bytes),")"]})]})]})},gt=({size:e,label:t,children:n})=>f.jsxs(Qu,{md:e||1,className:"py-3",children:[f.jsx("div",{className:"fw-bold",children:t}),n]});function w0(e){return e.files.filter(n=>n.included).reduce((n,r)=>n.length>r.length?n:r).name}function x0(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60,l=(o,i)=>o>0?`${o}${i}`:"";return t>0?`${l(t,"h")} ${l(n,"m")}`.trim():n>0?`${l(n,"m")} ${l(r,"s")}`.trim():`${l(r,"s")}`.trim()}function S0(e){var n,r,l;let t=(l=(r=(n=e==null?void 0:e.live)==null?void 0:n.time_remaining)==null?void 0:r.duration)==null?void 0:l.secs;return t==null?"N/A":x0(t)}const E0=({id:e,detailsResponse:t,statsResponse:n})=>{const r=(n==null?void 0:n.state)??"",l=n==null?void 0:n.error,o=(n==null?void 0:n.total_bytes)??1,i=(n==null?void 0:n.progress_bytes)??0,u=(n==null?void 0:n.finished)||!1,s=l?100:i/o*100,a=(r==Xl||r==Ad)&&!u,m=l?"Error":`${s.toFixed(2)}%`,h=l?"danger":u?"success":r==Xl?"warning":"primary",d=()=>{var E;let w=(E=n==null?void 0:n.live)==null?void 0:E.snapshot.peer_stats;return w?`${w.live} / ${w.seen}`:""};let g=[];return l?g.push("bg-warning"):e%2==0&&g.push("bg-light"),f.jsxs($d,{className:g.join(" "),children:[f.jsx(gt,{size:3,label:"Name",children:t?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"text-truncate",children:w0(t)}),l&&f.jsxs("p",{className:"text-danger",children:[f.jsx("strong",{children:"Error:"})," ",l]})]}):f.jsx(Un,{})}),n?f.jsxs(f.Fragment,{children:[f.jsx(gt,{label:"Size",children:`${qu(o)} `}),f.jsx(gt,{size:2,label:(r==Dd,"Progress"),children:f.jsx(s0,{now:s,label:m,animated:a,variant:h})}),f.jsx(gt,{size:2,label:"Speed",children:f.jsx(g0,{statsResponse:n})}),f.jsx(gt,{label:"ETA",children:S0(n)}),f.jsx(gt,{size:2,label:"Live / Seen",children:d()}),f.jsx(gt,{label:"Actions",children:f.jsx(y0,{id:e,statsResponse:n})})]}):f.jsx(gt,{label:"Loading stats",size:8,children:f.jsx(Un,{})})]})},k0=({id:e,torrent:t})=>{const[n,r]=y.useState(null),[l,o]=y.useState(null),[i,u]=y.useState(0),s=y.useContext(on),a=()=>{u(i+1)};return y.useEffect(()=>{if(n===null)return c0(async()=>{await s.getTorrentDetails(t.id).then(r)},1e3)},[n]),y.useEffect(()=>Zu(async()=>s.getTorrentStats(t.id).then(g=>(o(g),g)).then(g=>g.state==Xl||g.state==Ad?1e3:1e4,()=>1e4),0),[i]),f.jsx(Bf.Provider,{value:{refresh:a},children:f.jsx(E0,{id:e,detailsResponse:n,statsResponse:l})})},C0=e=>{if(e.torrents===null&&e.loading)return f.jsx(Un,{});if(e.torrents!==null)return e.torrents.length===0?f.jsx("div",{className:"text-center",children:f.jsx("p",{children:"No existing torrents found. Add them through buttons below."})}):f.jsx("div",{style:{fontSize:"smaller"},children:e.torrents.map(t=>f.jsx(k0,{id:t.id,torrent:t},t.id))})},_0=e=>{let{onHide:t,listTorrentResponse:n,listTorrentError:r,listTorrentLoading:l,data:o}=e;const[i,u]=y.useState([]),[s,a]=y.useState(!1),[m,h]=y.useState(null),[d,g]=y.useState(!1),[w,E]=y.useState(""),L=y.useContext(Ur),p=y.useContext(on);y.useEffect(()=>{console.log(n),u(n?n.details.files.map((k,_)=>_):[]),E((n==null?void 0:n.output_folder)||"")},[n]);const c=()=>{t(),u([]),h(null),a(!1)},v=k=>{i.includes(k)?u(i.filter(_=>_!==k)):u([...i,k])},x=async()=>{if(!n)return;a(!0);let k=n.seen_peers?n.seen_peers.slice(0,32):null,_={overwrite:!0,only_files:i,initial_peers:k,output_folder:w};d&&(_.peer_opts={connect_timeout:20,read_write_timeout:60}),p.uploadTorrent(o,_).then(()=>{t(),L.refreshTorrents()},j=>{h({text:"Error starting torrent",details:j})}).finally(()=>a(!1))},N=()=>{if(l)return f.jsx(Un,{});if(r)return f.jsx(zr,{error:r});if(n)return f.jsxs(pe,{children:[f.jsxs("fieldset",{className:"mb-4",children:[f.jsx("legend",{children:"Pick the files to download"}),n.details.files.map((k,_)=>f.jsx(pe.Group,{controlId:`check-${_}`,children:f.jsx(pe.Check,{type:"checkbox",label:`${k.name} (${qu(k.length)})`,checked:i.includes(_),onChange:()=>v(_)})},_))]}),f.jsxs("fieldset",{children:[f.jsx("legend",{children:"Options"}),f.jsxs(pe.Group,{controlId:"output-folder",className:"mb-3",children:[f.jsx(pe.Label,{children:"Output folder"}),f.jsx(pe.Control,{type:"text",value:w,onChange:k=>E(k.target.value)})]}),f.jsxs(pe.Group,{controlId:"unpopular-torrent",className:"mb-3",children:[f.jsx(pe.Check,{type:"checkbox",label:"Increase timeouts",checked:d,onChange:()=>g(!d)}),f.jsx("small",{id:"emailHelp",className:"form-text text-muted",children:"This might be useful for unpopular torrents with few peers. It will slow down fast torrents though."})]})]})]})};return f.jsxs(ge,{show:!0,onHide:c,size:"lg",children:[f.jsx(ge.Header,{closeButton:!0,children:f.jsx(ge.Title,{children:"Add torrent"})}),f.jsxs(ge.Body,{children:[N(),f.jsx(zr,{error:m})]}),f.jsxs(ge.Footer,{children:[s&&f.jsx(Un,{}),f.jsx(nn,{variant:"primary",onClick:x,disabled:l||s||i.length==0,children:"OK"}),f.jsx(nn,{variant:"secondary",onClick:c,children:"Cancel"})]})]})},Hd=({buttonText:e,onClick:t,data:n,resetData:r,variant:l})=>{const[o,i]=y.useState(!1),[u,s]=y.useState(null),[a,m]=y.useState(null),h=y.useContext(on);y.useEffect(()=>{if(n===null)return;let g=setTimeout(async()=>{i(!0);try{const w=await h.uploadTorrent(n,{list_only:!0});s(w)}catch(w){m({text:"Error listing torrent files",details:w})}finally{i(!1)}},0);return()=>clearTimeout(g)},[n]);const d=()=>{r(),m(null),s(null),i(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(nn,{variant:l,onClick:t,className:"m-1",children:e}),n&&f.jsx(_0,{onHide:d,listTorrentError:a,listTorrentResponse:u,data:n,listTorrentLoading:o})]})},N0=({show:e,setUrl:t,cancel:n})=>{let[r,l]=y.useState("");return f.jsxs(ge,{show:e,onHide:n,size:"lg",children:[f.jsx(ge.Header,{closeButton:!0,children:f.jsx(ge.Title,{children:"Add torrent"})}),f.jsx(ge.Body,{children:f.jsx(pe,{children:f.jsxs(pe.Group,{className:"mb-3",controlId:"url",children:[f.jsx(pe.Label,{children:"Enter magnet or HTTP(S) URL to the .torrent"}),f.jsx(pe.Control,{value:r,placeholder:"magnet:?xt=urn:btih:...",onChange:o=>{l(o.target.value)}})]})})}),f.jsxs(ge.Footer,{children:[f.jsx(nn,{variant:"primary",onClick:()=>{t(r),l("")},disabled:r.length==0,children:"OK"}),f.jsx(nn,{variant:"secondary",onClick:n,children:"Cancel"})]})]})},T0=()=>{let[e,t]=y.useState(null),[n,r]=y.useState(!1);return f.jsxs(f.Fragment,{children:[f.jsx(Hd,{variant:"primary",buttonText:"Add Torrent from Magnet / URL",onClick:()=>{r(!0)},data:e,resetData:()=>t(null)}),f.jsx(N0,{show:n,setUrl:l=>{r(!1),t(l)},cancel:()=>{r(!1),t(null)}})]})},j0=()=>{const e=y.useRef(),[t,n]=y.useState(null),r=async()=>{var u;if(!((u=e==null?void 0:e.current)!=null&&u.files))return;const i=e.current.files[0];n(i)},l=()=>{e!=null&&e.current&&(e.current.value="",n(null))},o=()=>{e!=null&&e.current&&e.current.click()};return f.jsxs(f.Fragment,{children:[f.jsx("input",{type:"file",ref:e,accept:".torrent",onChange:r,className:"d-none"}),f.jsx(Hd,{variant:"secondary",buttonText:"Upload .torrent File",onClick:o,data:t,resetData:l})]})},L0=()=>f.jsxs("div",{id:"buttons-container",className:"mt-3",children:[f.jsx(T0,{}),f.jsx(j0,{})]}),O0=e=>{let t=y.useContext(Ur);return f.jsxs(wv,{children:[f.jsx(zr,{error:e.closeableError,remove:()=>t.setCloseableError(null)}),f.jsx(zr,{error:e.otherError}),f.jsx(C0,{torrents:e.torrents,loading:e.torrentsLoading}),f.jsx(L0,{})]})},R0=e=>{const[t,n]=y.useState(null),[r,l]=y.useState(null),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(on),m=async()=>{s(!0);let d=await a.listTorrents().finally(()=>s(!1));i(d.torrents)};y.useEffect(()=>Zu(async()=>m().then(()=>(l(null),5e3),d=>(l({text:"Error refreshing torrents",details:d}),console.error(d),5e3)),0),[]);const h={setCloseableError:n,refreshTorrents:m};return f.jsx(Ur.Provider,{value:h,children:f.jsxs("div",{className:"text-center",children:[f.jsx("h1",{className:"mt-3 mb-4",children:e.title}),f.jsx(O0,{closeableError:t,otherError:r,torrents:o,torrentsLoading:u})]})})},P0=window.origin==="null"||window.origin==="http://localhost:3031"?"http://localhost:3030":"",nt=async(e,t,n)=>{console.log(e,t);const r=P0+t,l={method:e,headers:{Accept:"application/json"},body:n};let o={method:e,path:t,text:""},i;try{i=await fetch(r,l)}catch{return o.text="network error",Promise.reject(o)}if(o.status=i.status,o.statusText=`${i.status} ${i.statusText}`,!i.ok){const s=await i.text();try{const a=JSON.parse(s);o.text=a.human_readable!==void 0?a.human_readable:JSON.stringify(a,null,2)}catch{o.text=s}return Promise.reject(o)}return await i.json()},Ca={listTorrents:()=>nt("GET","/torrents"),getTorrentDetails:e=>nt("GET",`/torrents/${e}`),getTorrentStats:e=>nt("GET",`/torrents/${e}/stats/v1`),uploadTorrent:(e,t)=>{var r,l;let n="/torrents?&overwrite=true";return t!=null&&t.list_only&&(n+="&list_only=true"),(t==null?void 0:t.only_files)!=null&&(n+=`&only_files=${t.only_files.join(",")}`),(r=t==null?void 0:t.peer_opts)!=null&&r.connect_timeout&&(n+=`&peer_connect_timeout=${t.peer_opts.connect_timeout}`),(l=t==null?void 0:t.peer_opts)!=null&&l.read_write_timeout&&(n+=`&peer_read_write_timeout=${t.peer_opts.read_write_timeout}`),t!=null&&t.initial_peers&&(n+=`&initial_peers=${t.initial_peers.join(",")}`),t!=null&&t.output_folder&&(n+=`&output_folder=${t.output_folder}`),typeof e=="string"&&(n+="&is_url=true"),nt("POST",n,e)},pause:e=>nt("POST",`/torrents/${e}/pause`),start:e=>nt("POST",`/torrents/${e}/start`),forget:e=>nt("POST",`/torrents/${e}/forget`),delete:e=>nt("POST",`/torrents/${e}/delete`),getVersion:async()=>(await nt("GET","/")).version},F0=()=>{let[e,t]=y.useState("rqbit web UI");return y.useEffect(()=>Zu(()=>Ca.getVersion().then(r=>{const l=`rqbit web UI - v${r}`;return t(l),document.title=l,1e4},r=>1e3),0),[]),f.jsx(y.StrictMode,{children:f.jsx(on.Provider,{value:Ca,children:f.jsx(R0,{title:e})})})};Yo.createRoot(document.getElementById("app")).render(f.jsx(F0,{})); +*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r=[],l=0;l=0)&&(n[l]=e[l]);return n}function ca(e){return"default"+e.charAt(0).toUpperCase()+e.substr(1)}function xh(e){var t=Sh(e,"string");return typeof t=="symbol"?t:String(t)}function Sh(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Eh(e,t,n){var r=y.useRef(e!==void 0),l=y.useState(t),o=l[0],i=l[1],u=e!==void 0,s=r.current;return r.current=u,!u&&s&&o!==t&&i(t),[u?e:o,y.useCallback(function(a){for(var m=arguments.length,h=new Array(m>1?m-1:0),d=1;d{o.target===e&&(l(),t(o))},n+r)}function Kh(e){e.offsetHeight}const pa=e=>!e||typeof e=="function"?e:t=>{e.current=t};function Gh(e,t){const n=pa(e),r=pa(t);return l=>{n&&n(l),r&&r(l)}}function ho(e,t){return y.useMemo(()=>Gh(e,t),[e,t])}function Xh(e){return e&&"setState"in e?Tn.findDOMNode(e):e??null}const Yh=we.forwardRef(({onEnter:e,onEntering:t,onEntered:n,onExit:r,onExiting:l,onExited:o,addEndListener:i,children:u,childRef:s,...a},m)=>{const h=y.useRef(null),d=ho(h,s),g=k=>{d(Xh(k))},w=k=>_=>{k&&h.current&&k(h.current,_)},E=y.useCallback(w(e),[e]),L=y.useCallback(w(t),[t]),p=y.useCallback(w(n),[n]),c=y.useCallback(w(r),[r]),v=y.useCallback(w(l),[l]),x=y.useCallback(w(o),[o]),N=y.useCallback(w(i),[i]);return f.jsx(Uh,{ref:m,...a,onEnter:E,onEntered:p,onEntering:L,onExit:c,onExited:x,onExiting:v,addEndListener:N,nodeRef:h,children:typeof u=="function"?(k,_)=>u(k,{..._,ref:g}):we.cloneElement(u,{ref:g})})}),Zh=Yh;function Jh(e){const t=y.useRef(e);return y.useEffect(()=>{t.current=e},[e]),t}function ze(e){const t=Jh(e);return y.useCallback(function(...n){return t.current&&t.current(...n)},[t])}const Jf=e=>y.forwardRef((t,n)=>f.jsx("div",{...t,ref:n,className:M(t.className,e)})),qf=Jf("h4");qf.displayName="DivStyledAsH4";const bf=y.forwardRef(({className:e,bsPrefix:t,as:n=qf,...r},l)=>(t=H(t,"alert-heading"),f.jsx(n,{ref:l,className:M(e,t),...r})));bf.displayName="AlertHeading";const qh=bf;function bh(){return y.useState(null)}function ev(){const e=y.useRef(!0),t=y.useRef(()=>e.current);return y.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),t.current}function tv(e){const t=y.useRef(null);return y.useEffect(()=>{t.current=e}),t.current}const nv=typeof global<"u"&&global.navigator&&global.navigator.product==="ReactNative",rv=typeof document<"u",ma=rv||nv?y.useLayoutEffect:y.useEffect,lv=["as","disabled"];function ov(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function iv(e){return!e||e.trim()==="#"}function Vu({tagName:e,disabled:t,href:n,target:r,rel:l,role:o,onClick:i,tabIndex:u=0,type:s}){e||(n!=null||r!=null||l!=null?e="a":e="button");const a={tagName:e};if(e==="button")return[{type:s||"button",disabled:t},a];const m=d=>{if((t||e==="a"&&iv(n))&&d.preventDefault(),t){d.stopPropagation();return}i==null||i(d)},h=d=>{d.key===" "&&(d.preventDefault(),m(d))};return e==="a"&&(n||(n="#"),t&&(n=void 0)),[{role:o??"button",disabled:void 0,tabIndex:t?void 0:u,href:n,target:e==="a"?r:void 0,"aria-disabled":t||void 0,rel:e==="a"?l:void 0,onClick:m,onKeyDown:h},a]}const uv=y.forwardRef((e,t)=>{let{as:n,disabled:r}=e,l=ov(e,lv);const[o,{tagName:i}]=Vu(Object.assign({tagName:n,disabled:r},l));return f.jsx(i,Object.assign({},l,o,{ref:t}))});uv.displayName="Button";const sv=["onKeyDown"];function av(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function cv(e){return!e||e.trim()==="#"}const ed=y.forwardRef((e,t)=>{let{onKeyDown:n}=e,r=av(e,sv);const[l]=Vu(Object.assign({tagName:"a"},r)),o=ze(i=>{l.onKeyDown(i),n==null||n(i)});return cv(r.href)||r.role==="button"?f.jsx("a",Object.assign({ref:t},r,l,{onKeyDown:o})):f.jsx("a",Object.assign({ref:t},r,{onKeyDown:n}))});ed.displayName="Anchor";const fv=ed,td=y.forwardRef(({className:e,bsPrefix:t,as:n=fv,...r},l)=>(t=H(t,"alert-link"),f.jsx(n,{ref:l,className:M(e,t),...r})));td.displayName="AlertLink";const dv=td,pv={[St]:"show",[Wt]:"show"},nd=y.forwardRef(({className:e,children:t,transitionClasses:n={},onEnter:r,...l},o)=>{const i={in:!1,timeout:300,mountOnEnter:!1,unmountOnExit:!1,appear:!1,...l},u=y.useCallback((s,a)=>{Kh(s),r==null||r(s,a)},[r]);return f.jsx(Zh,{ref:o,addEndListener:Qh,...i,onEnter:u,childRef:t.ref,children:(s,a)=>y.cloneElement(t,{...a,className:M("fade",e,t.props.className,pv[s],n[s])})})});nd.displayName="Fade";const Kl=nd,mv={"aria-label":st.string,onClick:st.func,variant:st.oneOf(["white"])},Wu=y.forwardRef(({className:e,variant:t,"aria-label":n="Close",...r},l)=>f.jsx("button",{ref:l,type:"button",className:M("btn-close",t&&`btn-close-${t}`,e),"aria-label":n,...r}));Wu.displayName="CloseButton";Wu.propTypes=mv;const rd=Wu,ld=y.forwardRef((e,t)=>{const{bsPrefix:n,show:r=!0,closeLabel:l="Close alert",closeVariant:o,className:i,children:u,variant:s="primary",onClose:a,dismissible:m,transition:h=Kl,...d}=kh(e,{show:"onClose"}),g=H(n,"alert"),w=ze(p=>{a&&a(!1,p)}),E=h===!0?Kl:h,L=f.jsxs("div",{role:"alert",...E?void 0:d,ref:t,className:M(i,g,s&&`${g}-${s}`,m&&`${g}-dismissible`),children:[m&&f.jsx(rd,{onClick:w,"aria-label":l,variant:o}),u]});return E?f.jsx(E,{unmountOnExit:!0,...d,ref:void 0,in:r,children:L}):r?L:null});ld.displayName="Alert";const ha=Object.assign(ld,{Link:dv,Heading:qh}),od=y.forwardRef(({as:e,bsPrefix:t,variant:n="primary",size:r,active:l=!1,disabled:o=!1,className:i,...u},s)=>{const a=H(t,"btn"),[m,{tagName:h}]=Vu({tagName:e,disabled:o,...u}),d=h;return f.jsx(d,{...m,...u,ref:s,disabled:o,className:M(i,a,l&&"active",n&&`${a}-${n}`,r&&`${a}-${r}`,u.href&&o&&"disabled")})});od.displayName="Button";const nn=od;function hv(e){const t=y.useRef(e);return t.current=e,t}function id(e){const t=hv(e);y.useEffect(()=>()=>t.current(),[])}function vv(e,t){let n=0;return y.Children.map(e,r=>y.isValidElement(r)?t(r,n++):r)}function yv(e,t){return y.Children.toArray(e).some(n=>y.isValidElement(n)&&n.type===t)}function gv({as:e,bsPrefix:t,className:n,...r}){t=H(t,"col");const l=Vf(),o=Wf(),i=[],u=[];return l.forEach(s=>{const a=r[s];delete r[s];let m,h,d;typeof a=="object"&&a!=null?{span:m,offset:h,order:d}=a:m=a;const g=s!==o?`-${s}`:"";m&&i.push(m===!0?`${t}${g}`:`${t}${g}-${m}`),d!=null&&u.push(`order${g}-${d}`),h!=null&&u.push(`offset${g}-${h}`)}),[{...r,className:M(n,...i,...u)},{as:e,bsPrefix:t,spans:i}]}const ud=y.forwardRef((e,t)=>{const[{className:n,...r},{as:l="div",bsPrefix:o,spans:i}]=gv(e);return f.jsx(l,{...r,ref:t,className:M(n,!i.length&&o)})});ud.displayName="Col";const Qu=ud,sd=y.forwardRef(({bsPrefix:e,fluid:t=!1,as:n="div",className:r,...l},o)=>{const i=H(e,"container"),u=typeof t=="string"?`-${t}`:"-fluid";return f.jsx(n,{ref:o,...l,className:M(r,t?`${i}${u}`:i)})});sd.displayName="Container";const wv=sd;var xv=Function.prototype.bind.call(Function.prototype.call,[].slice);function pn(e,t){return xv(e.querySelectorAll(t))}function va(e,t){if(e.contains)return e.contains(t);if(e.compareDocumentPosition)return e===t||!!(e.compareDocumentPosition(t)&16)}const Sv="data-rr-ui-";function Ev(e){return`${Sv}${e}`}const ad=y.createContext(Qn?window:void 0);ad.Provider;function Ku(){return y.useContext(ad)}const kv={type:st.string,tooltip:st.bool,as:st.elementType},Gu=y.forwardRef(({as:e="div",className:t,type:n="valid",tooltip:r=!1,...l},o)=>f.jsx(e,{...l,ref:o,className:M(t,`${n}-${r?"tooltip":"feedback"}`)}));Gu.displayName="Feedback";Gu.propTypes=kv;const cd=Gu,Cv=y.createContext({}),pt=Cv,fd=y.forwardRef(({id:e,bsPrefix:t,className:n,type:r="checkbox",isValid:l=!1,isInvalid:o=!1,as:i="input",...u},s)=>{const{controlId:a}=y.useContext(pt);return t=H(t,"form-check-input"),f.jsx(i,{...u,ref:s,type:r,id:e||a,className:M(n,t,l&&"is-valid",o&&"is-invalid")})});fd.displayName="FormCheckInput";const dd=fd,pd=y.forwardRef(({bsPrefix:e,className:t,htmlFor:n,...r},l)=>{const{controlId:o}=y.useContext(pt);return e=H(e,"form-check-label"),f.jsx("label",{...r,ref:l,htmlFor:n||o,className:M(t,e)})});pd.displayName="FormCheckLabel";const Xi=pd,md=y.forwardRef(({id:e,bsPrefix:t,bsSwitchPrefix:n,inline:r=!1,reverse:l=!1,disabled:o=!1,isValid:i=!1,isInvalid:u=!1,feedbackTooltip:s=!1,feedback:a,feedbackType:m,className:h,style:d,title:g="",type:w="checkbox",label:E,children:L,as:p="input",...c},v)=>{t=H(t,"form-check"),n=H(n,"form-switch");const{controlId:x}=y.useContext(pt),N=y.useMemo(()=>({controlId:e||x}),[x,e]),k=!L&&E!=null&&E!==!1||yv(L,Xi),_=f.jsx(dd,{...c,type:w==="switch"?"checkbox":w,ref:v,isValid:i,isInvalid:u,disabled:o,as:p});return f.jsx(pt.Provider,{value:N,children:f.jsx("div",{style:d,className:M(h,k&&t,r&&`${t}-inline`,l&&`${t}-reverse`,w==="switch"&&n),children:L||f.jsxs(f.Fragment,{children:[_,k&&f.jsx(Xi,{title:g,children:E}),a&&f.jsx(cd,{type:m,tooltip:s,children:a})]})})})});md.displayName="FormCheck";const Gl=Object.assign(md,{Input:dd,Label:Xi}),hd=y.forwardRef(({bsPrefix:e,type:t,size:n,htmlSize:r,id:l,className:o,isValid:i=!1,isInvalid:u=!1,plaintext:s,readOnly:a,as:m="input",...h},d)=>{const{controlId:g}=y.useContext(pt);return e=H(e,"form-control"),f.jsx(m,{...h,type:t,size:r,ref:d,readOnly:a,id:l||g,className:M(o,s?`${e}-plaintext`:e,n&&`${e}-${n}`,t==="color"&&`${e}-color`,i&&"is-valid",u&&"is-invalid")})});hd.displayName="FormControl";const _v=Object.assign(hd,{Feedback:cd}),vd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"form-floating"),f.jsx(n,{ref:l,className:M(e,t),...r})));vd.displayName="FormFloating";const Nv=vd,yd=y.forwardRef(({controlId:e,as:t="div",...n},r)=>{const l=y.useMemo(()=>({controlId:e}),[e]);return f.jsx(pt.Provider,{value:l,children:f.jsx(t,{...n,ref:r})})});yd.displayName="FormGroup";const gd=yd,wd=y.forwardRef(({as:e="label",bsPrefix:t,column:n=!1,visuallyHidden:r=!1,className:l,htmlFor:o,...i},u)=>{const{controlId:s}=y.useContext(pt);t=H(t,"form-label");let a="col-form-label";typeof n=="string"&&(a=`${a} ${a}-${n}`);const m=M(l,t,r&&"visually-hidden",n&&a);return o=o||s,n?f.jsx(Qu,{ref:u,as:"label",className:m,htmlFor:o,...i}):f.jsx(e,{ref:u,className:m,htmlFor:o,...i})});wd.displayName="FormLabel";const Tv=wd,xd=y.forwardRef(({bsPrefix:e,className:t,id:n,...r},l)=>{const{controlId:o}=y.useContext(pt);return e=H(e,"form-range"),f.jsx("input",{...r,type:"range",ref:l,className:M(t,e),id:n||o})});xd.displayName="FormRange";const jv=xd,Sd=y.forwardRef(({bsPrefix:e,size:t,htmlSize:n,className:r,isValid:l=!1,isInvalid:o=!1,id:i,...u},s)=>{const{controlId:a}=y.useContext(pt);return e=H(e,"form-select"),f.jsx("select",{...u,size:n,ref:s,className:M(r,e,t&&`${e}-${t}`,l&&"is-valid",o&&"is-invalid"),id:i||a})});Sd.displayName="FormSelect";const Lv=Sd,Ed=y.forwardRef(({bsPrefix:e,className:t,as:n="small",muted:r,...l},o)=>(e=H(e,"form-text"),f.jsx(n,{...l,ref:o,className:M(t,e,r&&"text-muted")})));Ed.displayName="FormText";const Ov=Ed,kd=y.forwardRef((e,t)=>f.jsx(Gl,{...e,ref:t,type:"switch"}));kd.displayName="Switch";const Rv=Object.assign(kd,{Input:Gl.Input,Label:Gl.Label}),Cd=y.forwardRef(({bsPrefix:e,className:t,children:n,controlId:r,label:l,...o},i)=>(e=H(e,"form-floating"),f.jsxs(gd,{ref:i,className:M(t,e),controlId:r,...o,children:[n,f.jsx("label",{htmlFor:r,children:l})]})));Cd.displayName="FloatingLabel";const Pv=Cd,Fv={_ref:st.any,validated:st.bool,as:st.elementType},Xu=y.forwardRef(({className:e,validated:t,as:n="form",...r},l)=>f.jsx(n,{...r,ref:l,className:M(e,t&&"was-validated")}));Xu.displayName="Form";Xu.propTypes=Fv;const pe=Object.assign(Xu,{Group:gd,Control:_v,Floating:Nv,Check:Gl,Switch:Rv,Label:Tv,Text:Ov,Range:jv,Select:Lv,FloatingLabel:Pv});var sl;function ya(e){if((!sl&&sl!==0||e)&&Qn){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),sl=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return sl}function Wo(e){e===void 0&&(e=mo());try{var t=e.activeElement;return!t||!t.nodeName?null:t}catch{return e.body}}function Mv(e=document){const t=e.defaultView;return Math.abs(t.innerWidth-e.documentElement.clientWidth)}const ga=Ev("modal-open");class zv{constructor({ownerDocument:t,handleContainerOverflow:n=!0,isRTL:r=!1}={}){this.handleContainerOverflow=n,this.isRTL=r,this.modals=[],this.ownerDocument=t}getScrollbarWidth(){return Mv(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(t){}removeModalAttributes(t){}setContainerStyle(t){const n={overflow:"hidden"},r=this.isRTL?"paddingLeft":"paddingRight",l=this.getElement();t.style={overflow:l.style.overflow,[r]:l.style[r]},t.scrollBarWidth&&(n[r]=`${parseInt(Zt(l,r)||"0",10)+t.scrollBarWidth}px`),l.setAttribute(ga,""),Zt(l,n)}reset(){[...this.modals].forEach(t=>this.remove(t))}removeContainerStyle(t){const n=this.getElement();n.removeAttribute(ga),Object.assign(n.style,t.style)}add(t){let n=this.modals.indexOf(t);return n!==-1||(n=this.modals.length,this.modals.push(t),this.setModalAttributes(t),n!==0)||(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state)),n}remove(t){const n=this.modals.indexOf(t);n!==-1&&(this.modals.splice(n,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(t))}isTopModal(t){return!!this.modals.length&&this.modals[this.modals.length-1]===t}}const Yu=zv,Qo=(e,t)=>Qn?e==null?(t||mo()).body:(typeof e=="function"&&(e=e()),e&&"current"in e&&(e=e.current),e&&("nodeType"in e||e.getBoundingClientRect)?e:null):null;function $v(e,t){const n=Ku(),[r,l]=y.useState(()=>Qo(e,n==null?void 0:n.document));if(!r){const o=Qo(e);o&&l(o)}return y.useEffect(()=>{t&&r&&t(r)},[t,r]),y.useEffect(()=>{const o=Qo(e);o!==r&&l(o)},[e,r]),r}function Iv({children:e,in:t,onExited:n,mountOnEnter:r,unmountOnExit:l}){const o=y.useRef(null),i=y.useRef(t),u=ze(n);y.useEffect(()=>{t?i.current=!0:u(o.current)},[t,u]);const s=ho(o,e.ref),a=y.cloneElement(e,{ref:s});return t?a:l||!i.current&&r?null:a}function Dv({in:e,onTransition:t}){const n=y.useRef(null),r=y.useRef(!0),l=ze(t);return ma(()=>{if(!n.current)return;let o=!1;return l({in:e,element:n.current,initial:r.current,isStale:()=>o}),()=>{o=!0}},[e,l]),ma(()=>(r.current=!1,()=>{r.current=!0}),[]),n}function Av({children:e,in:t,onExited:n,onEntered:r,transition:l}){const[o,i]=y.useState(!t);t&&o&&i(!1);const u=Dv({in:!!t,onTransition:a=>{const m=()=>{a.isStale()||(a.in?r==null||r(a.element,a.initial):(i(!0),n==null||n(a.element)))};Promise.resolve(l(a)).then(m,h=>{throw a.in||i(!0),h})}}),s=ho(u,e.ref);return o&&!t?null:y.cloneElement(e,{ref:s})}function wa(e,t,n){return e?f.jsx(e,Object.assign({},n)):t?f.jsx(Av,Object.assign({},n,{transition:t})):f.jsx(Iv,Object.assign({},n))}function Bv(e){return e.code==="Escape"||e.keyCode===27}const Uv=["show","role","className","style","children","backdrop","keyboard","onBackdropClick","onEscapeKeyDown","transition","runTransition","backdropTransition","runBackdropTransition","autoFocus","enforceFocus","restoreFocus","restoreFocusOptions","renderDialog","renderBackdrop","manager","container","onShow","onHide","onExit","onExited","onExiting","onEnter","onEntering","onEntered"];function Hv(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}let Ko;function Vv(e){return Ko||(Ko=new Yu({ownerDocument:e==null?void 0:e.document})),Ko}function Wv(e){const t=Ku(),n=e||Vv(t),r=y.useRef({dialog:null,backdrop:null});return Object.assign(r.current,{add:()=>n.add(r.current),remove:()=>n.remove(r.current),isTopModal:()=>n.isTopModal(r.current),setDialogRef:y.useCallback(l=>{r.current.dialog=l},[]),setBackdropRef:y.useCallback(l=>{r.current.backdrop=l},[])})}const _d=y.forwardRef((e,t)=>{let{show:n=!1,role:r="dialog",className:l,style:o,children:i,backdrop:u=!0,keyboard:s=!0,onBackdropClick:a,onEscapeKeyDown:m,transition:h,runTransition:d,backdropTransition:g,runBackdropTransition:w,autoFocus:E=!0,enforceFocus:L=!0,restoreFocus:p=!0,restoreFocusOptions:c,renderDialog:v,renderBackdrop:x=K=>f.jsx("div",Object.assign({},K)),manager:N,container:k,onShow:_,onHide:j=()=>{},onExit:B,onExited:P,onExiting:ie,onEnter:Ge,onEntering:Xe,onEntered:un}=e,Kn=Hv(e,Uv);const Oe=Ku(),Ye=$v(k),C=Wv(N),O=ev(),R=tv(n),[I,A]=y.useState(!n),fe=y.useRef(null);y.useImperativeHandle(t,()=>C,[C]),Qn&&!R&&n&&(fe.current=Wo(Oe==null?void 0:Oe.document)),n&&I&&A(!1);const Re=ze(()=>{if(C.add(),an.current=Ql(document,"keydown",vo),sn.current=Ql(document,"focus",()=>setTimeout(Pe),!0),_&&_(),E){var K,Vr;const Yn=Wo((K=(Vr=C.dialog)==null?void 0:Vr.ownerDocument)!=null?K:Oe==null?void 0:Oe.document);C.dialog&&Yn&&!va(C.dialog,Yn)&&(fe.current=Yn,C.dialog.focus())}}),tt=ze(()=>{if(C.remove(),an.current==null||an.current(),sn.current==null||sn.current(),p){var K;(K=fe.current)==null||K.focus==null||K.focus(c),fe.current=null}});y.useEffect(()=>{!n||!Ye||Re()},[n,Ye,Re]),y.useEffect(()=>{I&&tt()},[I,tt]),id(()=>{tt()});const Pe=ze(()=>{if(!L||!O()||!C.isTopModal())return;const K=Wo(Oe==null?void 0:Oe.document);C.dialog&&K&&!va(C.dialog,K)&&C.dialog.focus()}),vt=ze(K=>{K.target===K.currentTarget&&(a==null||a(K),u===!0&&j())}),vo=ze(K=>{s&&Bv(K)&&C.isTopModal()&&(m==null||m(K),K.defaultPrevented||j())}),sn=y.useRef(),an=y.useRef(),Gn=(...K)=>{A(!0),P==null||P(...K)};if(!Ye)return null;const Hr=Object.assign({role:r,ref:C.setDialogRef,"aria-modal":r==="dialog"?!0:void 0},Kn,{style:o,className:l,tabIndex:-1});let Xn=v?v(Hr):f.jsx("div",Object.assign({},Hr,{children:y.cloneElement(i,{role:"document"})}));Xn=wa(h,d,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:B,onExiting:ie,onExited:Gn,onEnter:Ge,onEntering:Xe,onEntered:un,children:Xn});let Bt=null;return u&&(Bt=x({ref:C.setBackdropRef,onClick:vt}),Bt=wa(g,w,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:Bt})),f.jsx(f.Fragment,{children:Tn.createPortal(f.jsxs(f.Fragment,{children:[Bt,Xn]}),Ye)})});_d.displayName="Modal";const Qv=Object.assign(_d,{Manager:Yu});function Kv(e,t){return e.classList?!!t&&e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function Gv(e,t){e.classList?e.classList.add(t):Kv(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function xa(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function Xv(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=xa(e.className,t):e.setAttribute("class",xa(e.className&&e.className.baseVal||"",t))}const mn={FIXED_CONTENT:".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",STICKY_CONTENT:".sticky-top",NAVBAR_TOGGLER:".navbar-toggler"};class Yv extends Yu{adjustAndStore(t,n,r){const l=n.style[t];n.dataset[t]=l,Zt(n,{[t]:`${parseFloat(Zt(n,t))+r}px`})}restore(t,n){const r=n.dataset[t];r!==void 0&&(delete n.dataset[t],Zt(n,{[t]:r}))}setContainerStyle(t){super.setContainerStyle(t);const n=this.getElement();if(Gv(n,"modal-open"),!t.scrollBarWidth)return;const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";pn(n,mn.FIXED_CONTENT).forEach(o=>this.adjustAndStore(r,o,t.scrollBarWidth)),pn(n,mn.STICKY_CONTENT).forEach(o=>this.adjustAndStore(l,o,-t.scrollBarWidth)),pn(n,mn.NAVBAR_TOGGLER).forEach(o=>this.adjustAndStore(l,o,t.scrollBarWidth))}removeContainerStyle(t){super.removeContainerStyle(t);const n=this.getElement();Xv(n,"modal-open");const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";pn(n,mn.FIXED_CONTENT).forEach(o=>this.restore(r,o)),pn(n,mn.STICKY_CONTENT).forEach(o=>this.restore(l,o)),pn(n,mn.NAVBAR_TOGGLER).forEach(o=>this.restore(l,o))}}let Go;function Zv(e){return Go||(Go=new Yv(e)),Go}const Nd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-body"),f.jsx(n,{ref:l,className:M(e,t),...r})));Nd.displayName="ModalBody";const Jv=Nd,qv=y.createContext({onHide(){}}),Td=qv,jd=y.forwardRef(({bsPrefix:e,className:t,contentClassName:n,centered:r,size:l,fullscreen:o,children:i,scrollable:u,...s},a)=>{e=H(e,"modal");const m=`${e}-dialog`,h=typeof o=="string"?`${e}-fullscreen-${o}`:`${e}-fullscreen`;return f.jsx("div",{...s,ref:a,className:M(m,t,l&&`${e}-${l}`,r&&`${m}-centered`,u&&`${m}-scrollable`,o&&h),children:f.jsx("div",{className:M(`${e}-content`,n),children:i})})});jd.displayName="ModalDialog";const Ld=jd,Od=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-footer"),f.jsx(n,{ref:l,className:M(e,t),...r})));Od.displayName="ModalFooter";const bv=Od,e0=y.forwardRef(({closeLabel:e="Close",closeVariant:t,closeButton:n=!1,onHide:r,children:l,...o},i)=>{const u=y.useContext(Td),s=ze(()=>{u==null||u.onHide(),r==null||r()});return f.jsxs("div",{ref:i,...o,children:[l,n&&f.jsx(rd,{"aria-label":e,variant:t,onClick:s})]})}),t0=e0,Rd=y.forwardRef(({bsPrefix:e,className:t,closeLabel:n="Close",closeButton:r=!1,...l},o)=>(e=H(e,"modal-header"),f.jsx(t0,{ref:o,...l,className:M(t,e),closeLabel:n,closeButton:r})));Rd.displayName="ModalHeader";const n0=Rd,r0=Jf("h4"),Pd=y.forwardRef(({className:e,bsPrefix:t,as:n=r0,...r},l)=>(t=H(t,"modal-title"),f.jsx(n,{ref:l,className:M(e,t),...r})));Pd.displayName="ModalTitle";const l0=Pd;function o0(e){return f.jsx(Kl,{...e,timeout:null})}function i0(e){return f.jsx(Kl,{...e,timeout:null})}const Fd=y.forwardRef(({bsPrefix:e,className:t,style:n,dialogClassName:r,contentClassName:l,children:o,dialogAs:i=Ld,"aria-labelledby":u,"aria-describedby":s,"aria-label":a,show:m=!1,animation:h=!0,backdrop:d=!0,keyboard:g=!0,onEscapeKeyDown:w,onShow:E,onHide:L,container:p,autoFocus:c=!0,enforceFocus:v=!0,restoreFocus:x=!0,restoreFocusOptions:N,onEntered:k,onExit:_,onExiting:j,onEnter:B,onEntering:P,onExited:ie,backdropClassName:Ge,manager:Xe,...un},Kn)=>{const[Oe,Ye]=y.useState({}),[C,O]=y.useState(!1),R=y.useRef(!1),I=y.useRef(!1),A=y.useRef(null),[fe,Re]=bh(),tt=ho(Kn,Re),Pe=ze(L),vt=Th();e=H(e,"modal");const vo=y.useMemo(()=>({onHide:Pe}),[Pe]);function sn(){return Xe||Zv({isRTL:vt})}function an($){if(!Qn)return;const cn=sn().getScrollbarWidth()>0,es=$.scrollHeight>mo($).documentElement.clientHeight;Ye({paddingRight:cn&&!es?ya():void 0,paddingLeft:!cn&&es?ya():void 0})}const Gn=ze(()=>{fe&&an(fe.dialog)});id(()=>{Gi(window,"resize",Gn),A.current==null||A.current()});const Hr=()=>{R.current=!0},Xn=$=>{R.current&&fe&&$.target===fe.dialog&&(I.current=!0),R.current=!1},Bt=()=>{O(!0),A.current=Zf(fe.dialog,()=>{O(!1)})},K=$=>{$.target===$.currentTarget&&Bt()},Vr=$=>{if(d==="static"){K($);return}if(I.current||$.target!==$.currentTarget){I.current=!1;return}L==null||L()},Yn=$=>{g?w==null||w($):($.preventDefault(),d==="static"&&Bt())},Vd=($,cn)=>{$&&an($),B==null||B($,cn)},Wd=$=>{A.current==null||A.current(),_==null||_($)},Qd=($,cn)=>{P==null||P($,cn),Yf(window,"resize",Gn)},Kd=$=>{$&&($.style.display=""),ie==null||ie($),Gi(window,"resize",Gn)},Gd=y.useCallback($=>f.jsx("div",{...$,className:M(`${e}-backdrop`,Ge,!h&&"show")}),[h,Ge,e]),bu={...n,...Oe};bu.display="block";const Xd=$=>f.jsx("div",{role:"dialog",...$,style:bu,className:M(t,e,C&&`${e}-static`,!h&&"show"),onClick:d?Vr:void 0,onMouseUp:Xn,"aria-label":a,"aria-labelledby":u,"aria-describedby":s,children:f.jsx(i,{...un,onMouseDown:Hr,className:r,contentClassName:l,children:o})});return f.jsx(Td.Provider,{value:vo,children:f.jsx(Qv,{show:m,ref:tt,backdrop:d,container:p,keyboard:!0,autoFocus:c,enforceFocus:v,restoreFocus:x,restoreFocusOptions:N,onEscapeKeyDown:Yn,onShow:E,onHide:L,onEnter:Vd,onEntering:Qd,onEntered:k,onExit:Wd,onExiting:j,onExited:Kd,manager:sn(),transition:h?o0:void 0,backdropTransition:h?i0:void 0,renderBackdrop:Gd,renderDialog:Xd})})});Fd.displayName="Modal";const ge=Object.assign(Fd,{Body:Jv,Header:n0,Title:l0,Footer:bv,Dialog:Ld,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150}),Sa=1e3;function u0(e,t,n){const r=(e-t)/(n-t)*100;return Math.round(r*Sa)/Sa}function Ea({min:e,now:t,max:n,label:r,visuallyHidden:l,striped:o,animated:i,className:u,style:s,variant:a,bsPrefix:m,...h},d){return f.jsx("div",{ref:d,...h,role:"progressbar",className:M(u,`${m}-bar`,{[`bg-${a}`]:a,[`${m}-bar-animated`]:i,[`${m}-bar-striped`]:i||o}),style:{width:`${u0(t,e,n)}%`,...s},"aria-valuenow":t,"aria-valuemin":e,"aria-valuemax":n,children:l?f.jsx("span",{className:"visually-hidden",children:r}):r})}const Md=y.forwardRef(({isChild:e=!1,...t},n)=>{const r={min:0,max:100,animated:!1,visuallyHidden:!1,striped:!1,...t};if(r.bsPrefix=H(r.bsPrefix,"progress"),e)return Ea(r,n);const{min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:d,className:g,children:w,...E}=r;return f.jsx("div",{ref:n,...E,className:M(g,h),children:w?vv(w,L=>y.cloneElement(L,{isChild:!0})):Ea({min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:d},n)})});Md.displayName="ProgressBar";const s0=Md,zd=y.forwardRef(({bsPrefix:e,className:t,as:n="div",...r},l)=>{const o=H(e,"row"),i=Vf(),u=Wf(),s=`${o}-cols`,a=[];return i.forEach(m=>{const h=r[m];delete r[m];let d;h!=null&&typeof h=="object"?{cols:d}=h:d=h;const g=m!==u?`-${m}`:"";d!=null&&a.push(`${s}${g}-${d}`)}),f.jsx(n,{ref:l,...r,className:M(t,o,...a)})});zd.displayName="Row";const $d=zd,Id=y.forwardRef(({bsPrefix:e,variant:t,animation:n="border",size:r,as:l="div",className:o,...i},u)=>{e=H(e,"spinner");const s=`${e}-${n}`;return f.jsx(l,{ref:u,...i,className:M(o,s,r&&`${s}-${r}`,t&&`text-${t}`)})});Id.displayName="Spinner";const Un=Id,Xl="initializing",Dd="paused",Ad="live",a0="error";function Zu(e,t){let n,r=t;const l=async()=>{if(r=await e(),r==null)throw"asyncCallback returned null or undefined";o()};let o=()=>{n=setTimeout(l,r)};return o(),()=>{clearTimeout(n)}}function c0(e,t){let n;const r=async()=>{await e().then(()=>!1,()=>!0)&&l()};let l=o=>{n=setTimeout(r,o!==void 0?o:t)};return l(0),()=>clearTimeout(n)}const Xo=e=>{const{onClick:t,disabled:n,color:r,children:l,className:o,...i}=e,u=a=>{a.stopPropagation(),!n&&t()},s=r?`text-${r}`:"";return f.jsx("a",{className:`p-1 ${s} ${o}`,onClick:u,href:"#",...i,children:l})},zr=e=>{var r,l,o;let{error:t,remove:n}=e;return t==null?null:f.jsxs(ha,{variant:"danger",onClose:n,dismissible:n!=null,children:[f.jsx(ha.Heading,{children:t.text}),((r=t.details)==null?void 0:r.statusText)&&f.jsx("p",{children:f.jsx("strong",{children:(l=t.details)==null?void 0:l.statusText})}),f.jsx("pre",{children:(o=t.details)==null?void 0:o.text})]})},f0=({id:e,show:t,onHide:n})=>{if(!t)return null;const[r,l]=y.useState(!1),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(Ur),m=y.useContext(on),h=()=>{l(!1),i(null),s(!1),n()},d=()=>{s(!0),(r?m.delete:m.forget)(e).then(()=>{a.refreshTorrents(),h()}).catch(w=>{i({text:`Error deleting torrent id=${e}`,details:w}),s(!1)})};return f.jsxs(ge,{show:t,onHide:h,children:[f.jsx(ge.Header,{closeButton:!0,children:"Delete torrent"}),f.jsxs(ge.Body,{children:[f.jsx(pe,{children:f.jsx(pe.Group,{controlId:"delete-torrent",children:f.jsx(pe.Check,{type:"checkbox",label:"Also delete files",checked:r,onChange:()=>l(!r)})})}),o&&f.jsx(zr,{error:o})]}),f.jsxs(ge.Footer,{children:[u&&f.jsx(Un,{}),f.jsx(nn,{variant:"primary",onClick:d,disabled:u,children:"OK"}),f.jsx(nn,{variant:"secondary",onClick:h,children:"Cancel"})]})]})};var Bd={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ka=we.createContext&&we.createContext(Bd),Mt=globalThis&&globalThis.__assign||function(){return Mt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n{let n=t.state,[r,l]=y.useState(!1),[o,i]=y.useState(!1),u=y.useContext(Bf);const s=n=="live",a=n=="paused"||n=="error",m=y.useContext(Ur),h=y.useContext(on),d=()=>{l(!0),h.start(e).then(()=>{u.refresh()},L=>{m.setCloseableError({text:`Error starting torrent id=${e}`,details:L})}).finally(()=>l(!1))},g=()=>{l(!0),h.pause(e).then(()=>{u.refresh()},L=>{m.setCloseableError({text:`Error pausing torrent id=${e}`,details:L})}).finally(()=>l(!1))},w=()=>{l(!0),i(!0)},E=()=>{l(!1),i(!1)};return f.jsx($d,{children:f.jsxs(Qu,{children:[a&&f.jsx(Xo,{onClick:d,disabled:r,color:"success",children:f.jsx(h0,{})}),s&&f.jsx(Xo,{onClick:g,disabled:r,children:f.jsx(m0,{})}),f.jsx(Xo,{onClick:w,disabled:r,color:"danger",children:f.jsx(v0,{})}),f.jsx(f0,{id:e,show:o,onHide:E})]})})};function qu(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+n[r]}const g0=({statsResponse:e})=>{var t,n;switch(e.state){case Dd:return"Paused";case Xl:return"Checking files";case a0:return"Error"}return e.state!="live"||e.live===null?e.state:f.jsxs(f.Fragment,{children:[!e.finished&&f.jsxs("div",{className:"download-speed",children:["↓ ",(t=e.live.download_speed)==null?void 0:t.human_readable]}),f.jsxs("div",{className:"upload-speed",children:["↑ ",(n=e.live.upload_speed)==null?void 0:n.human_readable,e.live.snapshot.uploaded_bytes>0&&f.jsxs("span",{children:[" ","(",qu(e.live.snapshot.uploaded_bytes),")"]})]})]})},gt=({size:e,label:t,children:n})=>f.jsxs(Qu,{md:e||1,className:"py-3",children:[f.jsx("div",{className:"fw-bold",children:t}),n]});function w0(e){return e.files.filter(n=>n.included).reduce((n,r)=>n.length>r.length?n:r).name}function x0(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60,l=(o,i)=>o>0?`${o}${i}`:"";return t>0?`${l(t,"h")} ${l(n,"m")}`.trim():n>0?`${l(n,"m")} ${l(r,"s")}`.trim():`${l(r,"s")}`.trim()}function S0(e){var n,r,l;let t=(l=(r=(n=e==null?void 0:e.live)==null?void 0:n.time_remaining)==null?void 0:r.duration)==null?void 0:l.secs;return t==null?"N/A":x0(t)}const E0=({id:e,detailsResponse:t,statsResponse:n})=>{const r=(n==null?void 0:n.state)??"",l=n==null?void 0:n.error,o=(n==null?void 0:n.total_bytes)??1,i=(n==null?void 0:n.progress_bytes)??0,u=(n==null?void 0:n.finished)||!1,s=l?100:i/o*100,a=(r==Xl||r==Ad)&&!u,m=l?"Error":`${s.toFixed(2)}%`,h=l?"danger":u?"success":r==Xl?"warning":"primary",d=()=>{var E;let w=(E=n==null?void 0:n.live)==null?void 0:E.snapshot.peer_stats;return w?`${w.live} / ${w.seen}`:""};let g=[];return l?g.push("bg-warning"):e%2==0&&g.push("bg-light"),f.jsxs($d,{className:g.join(" "),children:[f.jsx(gt,{size:3,label:"Name",children:t?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"text-truncate",children:w0(t)}),l&&f.jsxs("p",{className:"text-danger",children:[f.jsx("strong",{children:"Error:"})," ",l]})]}):f.jsx(Un,{})}),n?f.jsxs(f.Fragment,{children:[f.jsx(gt,{label:"Size",children:`${qu(o)} `}),f.jsx(gt,{size:2,label:(r==Dd,"Progress"),children:f.jsx(s0,{now:s,label:m,animated:a,variant:h})}),f.jsx(gt,{size:2,label:"Speed",children:f.jsx(g0,{statsResponse:n})}),f.jsx(gt,{label:"ETA",children:S0(n)}),f.jsx(gt,{size:2,label:"Live / Seen",children:d()}),f.jsx(gt,{label:"Actions",children:f.jsx(y0,{id:e,statsResponse:n})})]}):f.jsx(gt,{label:"Loading stats",size:8,children:f.jsx(Un,{})})]})},k0=({id:e,torrent:t})=>{const[n,r]=y.useState(null),[l,o]=y.useState(null),[i,u]=y.useState(0),s=y.useContext(on),a=()=>{u(i+1)};return y.useEffect(()=>{if(n===null)return c0(async()=>{await s.getTorrentDetails(t.id).then(r)},1e3)},[n]),y.useEffect(()=>Zu(async()=>s.getTorrentStats(t.id).then(g=>(o(g),g)).then(g=>g.state==Xl||g.state==Ad?1e3:1e4,()=>1e4),0),[i]),f.jsx(Bf.Provider,{value:{refresh:a},children:f.jsx(E0,{id:e,detailsResponse:n,statsResponse:l})})},C0=e=>{if(e.torrents===null&&e.loading)return f.jsx(Un,{});if(e.torrents!==null)return e.torrents.length===0?f.jsx("div",{className:"text-center",children:f.jsx("p",{children:"No existing torrents found. Add them through buttons below."})}):f.jsx("div",{style:{fontSize:"smaller"},children:e.torrents.map(t=>f.jsx(k0,{id:t.id,torrent:t},t.id))})},_0=e=>{let{onHide:t,listTorrentResponse:n,listTorrentError:r,listTorrentLoading:l,data:o}=e;const[i,u]=y.useState([]),[s,a]=y.useState(!1),[m,h]=y.useState(null),[d,g]=y.useState(!1),[w,E]=y.useState(""),L=y.useContext(Ur),p=y.useContext(on);y.useEffect(()=>{console.log(n),u(n?n.details.files.map((k,_)=>_):[]),E((n==null?void 0:n.output_folder)||"")},[n]);const c=()=>{t(),u([]),h(null),a(!1)},v=k=>{i.includes(k)?u(i.filter(_=>_!==k)):u([...i,k])},x=async()=>{if(!n)return;a(!0);let k=n.seen_peers?n.seen_peers.slice(0,32):null,_={overwrite:!0,only_files:i,initial_peers:k,output_folder:w};d&&(_.peer_opts={connect_timeout:20,read_write_timeout:60}),p.uploadTorrent(o,_).then(()=>{t(),L.refreshTorrents()},j=>{h({text:"Error starting torrent",details:j})}).finally(()=>a(!1))},N=()=>{if(l)return f.jsx(Un,{});if(r)return f.jsx(zr,{error:r});if(n)return f.jsxs(pe,{children:[f.jsxs("fieldset",{className:"mb-4",children:[f.jsx("legend",{children:"Pick the files to download"}),n.details.files.map((k,_)=>f.jsx(pe.Group,{controlId:`check-${_}`,children:f.jsx(pe.Check,{type:"checkbox",label:`${k.name} (${qu(k.length)})`,checked:i.includes(_),onChange:()=>v(_)})},_))]}),f.jsxs("fieldset",{children:[f.jsx("legend",{children:"Options"}),f.jsxs(pe.Group,{controlId:"output-folder",className:"mb-3",children:[f.jsx(pe.Label,{children:"Output folder"}),f.jsx(pe.Control,{type:"text",value:w,onChange:k=>E(k.target.value)})]}),f.jsxs(pe.Group,{controlId:"unpopular-torrent",className:"mb-3",children:[f.jsx(pe.Check,{type:"checkbox",label:"Increase timeouts",checked:d,onChange:()=>g(!d)}),f.jsx("small",{id:"emailHelp",className:"form-text text-muted",children:"This might be useful for unpopular torrents with few peers. It will slow down fast torrents though."})]})]})]})};return f.jsxs(ge,{show:!0,onHide:c,size:"lg",children:[f.jsx(ge.Header,{closeButton:!0,children:f.jsx(ge.Title,{children:"Add torrent"})}),f.jsxs(ge.Body,{children:[N(),f.jsx(zr,{error:m})]}),f.jsxs(ge.Footer,{children:[s&&f.jsx(Un,{}),f.jsx(nn,{variant:"primary",onClick:x,disabled:l||s||i.length==0,children:"OK"}),f.jsx(nn,{variant:"secondary",onClick:c,children:"Cancel"})]})]})},Hd=({buttonText:e,onClick:t,data:n,resetData:r,variant:l})=>{const[o,i]=y.useState(!1),[u,s]=y.useState(null),[a,m]=y.useState(null),h=y.useContext(on);y.useEffect(()=>{if(n===null)return;let g=setTimeout(async()=>{i(!0);try{const w=await h.uploadTorrent(n,{list_only:!0});s(w)}catch(w){m({text:"Error listing torrent files",details:w})}finally{i(!1)}},0);return()=>clearTimeout(g)},[n]);const d=()=>{r(),m(null),s(null),i(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(nn,{variant:l,onClick:t,className:"m-1",children:e}),n&&f.jsx(_0,{onHide:d,listTorrentError:a,listTorrentResponse:u,data:n,listTorrentLoading:o})]})},N0=({show:e,setUrl:t,cancel:n})=>{let[r,l]=y.useState("");return f.jsxs(ge,{show:e,onHide:n,size:"lg",children:[f.jsx(ge.Header,{closeButton:!0,children:f.jsx(ge.Title,{children:"Add torrent"})}),f.jsx(ge.Body,{children:f.jsx(pe,{children:f.jsxs(pe.Group,{className:"mb-3",controlId:"url",children:[f.jsx(pe.Label,{children:"Enter magnet or HTTP(S) URL to the .torrent"}),f.jsx(pe.Control,{value:r,placeholder:"magnet:?xt=urn:btih:...",onChange:o=>{l(o.target.value)}})]})})}),f.jsxs(ge.Footer,{children:[f.jsx(nn,{variant:"primary",onClick:()=>{t(r),l("")},disabled:r.length==0,children:"OK"}),f.jsx(nn,{variant:"secondary",onClick:n,children:"Cancel"})]})]})},T0=()=>{let[e,t]=y.useState(null),[n,r]=y.useState(!1);return f.jsxs(f.Fragment,{children:[f.jsx(Hd,{variant:"primary",buttonText:"Add Torrent from Magnet / URL",onClick:()=>{r(!0)},data:e,resetData:()=>t(null)}),f.jsx(N0,{show:n,setUrl:l=>{r(!1),t(l)},cancel:()=>{r(!1),t(null)}})]})},j0=()=>{const e=y.useRef(),[t,n]=y.useState(null),r=async()=>{var u;if(!((u=e==null?void 0:e.current)!=null&&u.files))return;const i=e.current.files[0];n(i)},l=()=>{e!=null&&e.current&&(e.current.value="",n(null))},o=()=>{e!=null&&e.current&&e.current.click()};return f.jsxs(f.Fragment,{children:[f.jsx("input",{type:"file",ref:e,accept:".torrent",onChange:r,className:"d-none"}),f.jsx(Hd,{variant:"secondary",buttonText:"Upload .torrent File",onClick:o,data:t,resetData:l})]})},L0=()=>f.jsxs("div",{id:"buttons-container",className:"mt-3",children:[f.jsx(T0,{}),f.jsx(j0,{})]}),O0=e=>{let t=y.useContext(Ur);return f.jsxs(wv,{children:[f.jsx(zr,{error:e.closeableError,remove:()=>t.setCloseableError(null)}),f.jsx(zr,{error:e.otherError}),f.jsx(C0,{torrents:e.torrents,loading:e.torrentsLoading}),f.jsx(L0,{})]})},R0=e=>{const[t,n]=y.useState(null),[r,l]=y.useState(null),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(on),m=async()=>{s(!0);let d=await a.listTorrents().finally(()=>s(!1));i(d.torrents)};y.useEffect(()=>Zu(async()=>m().then(()=>(l(null),5e3),d=>(l({text:"Error refreshing torrents",details:d}),console.error(d),5e3)),0),[]);const h={setCloseableError:n,refreshTorrents:m};return f.jsx(Ur.Provider,{value:h,children:f.jsxs("div",{className:"text-center",children:[f.jsx("h1",{className:"mt-3 mb-4",children:e.title}),f.jsx(O0,{closeableError:t,otherError:r,torrents:o,torrentsLoading:u})]})})},P0=window.origin==="null"||window.origin==="http://localhost:3031"?"http://localhost:3030":"",nt=async(e,t,n)=>{console.log(e,t);const r=P0+t,l={method:e,headers:{Accept:"application/json"},body:n};let o={method:e,path:t,text:""},i;try{i=await fetch(r,l)}catch{return o.text="network error",Promise.reject(o)}if(o.status=i.status,o.statusText=`${i.status} ${i.statusText}`,!i.ok){const s=await i.text();try{const a=JSON.parse(s);o.text=a.human_readable!==void 0?a.human_readable:JSON.stringify(a,null,2)}catch{o.text=s}return Promise.reject(o)}return await i.json()},Ca={listTorrents:()=>nt("GET","/torrents"),getTorrentDetails:e=>nt("GET",`/torrents/${e}`),getTorrentStats:e=>nt("GET",`/torrents/${e}/stats/v1`),uploadTorrent:(e,t)=>{var r,l;let n="/torrents?&overwrite=true";return t!=null&&t.list_only&&(n+="&list_only=true"),(t==null?void 0:t.only_files)!=null&&(n+=`&only_files=${t.only_files.join(",")}`),(r=t==null?void 0:t.peer_opts)!=null&&r.connect_timeout&&(n+=`&peer_connect_timeout=${t.peer_opts.connect_timeout}`),(l=t==null?void 0:t.peer_opts)!=null&&l.read_write_timeout&&(n+=`&peer_read_write_timeout=${t.peer_opts.read_write_timeout}`),t!=null&&t.initial_peers&&(n+=`&initial_peers=${t.initial_peers.join(",")}`),t!=null&&t.output_folder&&(n+=`&output_folder=${t.output_folder}`),typeof e=="string"&&(n+="&is_url=true"),nt("POST",n,e)},pause:e=>nt("POST",`/torrents/${e}/pause`),start:e=>nt("POST",`/torrents/${e}/start`),forget:e=>nt("POST",`/torrents/${e}/forget`),delete:e=>nt("POST",`/torrents/${e}/delete`),getVersion:async()=>(await nt("GET","/")).version},F0=()=>{let[e,t]=y.useState("rqbit web UI");return y.useEffect(()=>Zu(()=>Ca.getVersion().then(r=>{const l=`rqbit web UI - v${r}`;return t(l),document.title=l,1e4},r=>1e3),0),[]),f.jsx(y.StrictMode,{children:f.jsx(on.Provider,{value:Ca,children:f.jsx(R0,{title:e})})})};Yo.createRoot(document.getElementById("app")).render(f.jsx(F0,{})); diff --git a/crates/librqbit/webui/dist/manifest.json b/crates/librqbit/webui/dist/manifest.json index 4b6db055..07371437 100644 --- a/crates/librqbit/webui/dist/manifest.json +++ b/crates/librqbit/webui/dist/manifest.json @@ -4,7 +4,7 @@ "src": "assets/logo.svg" }, "index.html": { - "file": "assets/index-8d982016.js", + "file": "assets/index-b673c0d1.js", "isEntry": true, "src": "index.html" } diff --git a/crates/upnp/src/lib.rs b/crates/upnp/src/lib.rs index 93a3c5dc..77eed8a1 100644 --- a/crates/upnp/src/lib.rs +++ b/crates/upnp/src/lib.rs @@ -67,12 +67,12 @@ async fn forward_port( - + - {} + {port} TCP - {} - {} + {port} + {local_ip} 1 rust UPnP {} @@ -80,10 +80,6 @@ async fn forward_port( "#, - SERVICE_TYPE_WAN_IP_CONNECTION, - port, - port, - local_ip, lease_duration.as_secs() ); diff --git a/desktop/src-tauri/Cargo.lock b/desktop/src-tauri/Cargo.lock index 8c5004a3..d4403aed 100644 --- a/desktop/src-tauri/Cargo.lock +++ b/desktop/src-tauri/Cargo.lock @@ -3011,7 +3011,7 @@ dependencies = [ [[package]] name = "rqbit-desktop" -version = "5.0.1" +version = "5.0.2" dependencies = [ "anyhow", "base64 0.21.5", diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index e66cd110..4620672d 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rqbit-desktop" -version = "5.0.1" +version = "5.0.2" description = "rqbit torrent client" authors = ["you"] license = "" diff --git a/desktop/src/api.tsx b/desktop/src/api.tsx index 07c07396..6cbb11e9 100644 --- a/desktop/src/api.tsx +++ b/desktop/src/api.tsx @@ -24,7 +24,7 @@ function errorToUIError( let reason: ErrorDetails = { method: "INVOKE", path: path, - text: e.human_readable, + text: e.human_readable ?? e.toString(), status: e.status, statusText: e.status_text, }; diff --git a/desktop/src/configure.tsx b/desktop/src/configure.tsx index 9bedb4dc..872e1f17 100644 --- a/desktop/src/configure.tsx +++ b/desktop/src/configure.tsx @@ -9,7 +9,7 @@ const FormCheck: React.FC<{ label: string; name: string; checked: boolean; - onChange: (e: any) => void; + onChange: React.ChangeEventHandler; disabled?: boolean; help?: string; }> = ({ label, name, checked, onChange, disabled, help }) => { @@ -35,7 +35,7 @@ const FormInput: React.FC<{ name: string; value: string | number; inputType: string; - onChange: (e: any) => void; + onChange: React.ChangeEventHandler; disabled?: boolean; help?: string; }> = ({ label, name, value, inputType, onChange, disabled, help }) => { @@ -76,9 +76,13 @@ export const ConfigModal: React.FC<{ const [error, setError] = useState(null); - const handleInputChange = (e: any) => { + const handleInputChange: React.ChangeEventHandler = (e) => { const name: string = e.target.name; - const value: any = e.target.value; + let value: string | number = e.target.value; + if (e.target.type == "number") { + value = e.target.valueAsNumber; + } + console.log(value, typeof value); const [mainField, subField] = name.split(".", 2); if (subField) { @@ -97,7 +101,9 @@ export const ConfigModal: React.FC<{ } }; - const handleToggleChange = (e: any) => { + const handleToggleChange: React.ChangeEventHandler = ( + e + ) => { const name: string = e.target.name; const [mainField, subField] = name.split(".", 2);