1"use strict";(self.webpackChunk_aiostreams_frontend=self.webpackChunk_aiostreams_frontend||[]).push([["268"],{9823(e,t,s){s.d(t,{router:()=>N0});var a,r=s(81172),n=s(48348),l=s(31265),i=s(49793),o=s(49435),d=s(49342),c=s(15445),u=s(50405),m=s(31531),h=s(70851),p=s(83455);function x(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,p.QP)((0,h.$)(t))}let g={toaster:(0,c.F)(["group toaster z-[150]"]),toast:(0,c.F)(["group/toast","pointer-events-auto","select-none cursor-default","group-[.toaster]:py-4 group-[.toaster]:px-6 group-[.toaster]:gap-3","group-[.toaster]:text-sm group-[.toaster]:font-medium","group-[.toaster]:rounded-xl group-[.toaster]:border group-[.toaster]:backdrop-blur-sm","group-[.toaster]:transition-all group-[.toaster]:duration-200","group-[.toaster]:bg-gradient-to-br","group-[.toaster]:from-gray-900/95 group-[.toaster]:to-gray-800/60","group-[.toaster]:text-[--foreground] group-[.toaster]:border-[--border]","group-[.toaster]:ring-[--border]","group-[.toaster]:data-[type=success]:bg-gradient-to-br","group-[.toaster]:data-[type=success]:from-emerald-950/95 group-[.toaster]:data-[type=success]:to-emerald-900/60","group-[.toaster]:data-[type=success]:text-emerald-100","group-[.toaster]:data-[type=success]:border-emerald-800/50","group-[.toaster]:data-[type=success]:ring-emerald-700/40","group-[.toaster]:data-[type=warning]:bg-gradient-to-br","group-[.toaster]:data-[type=warning]:from-amber-950/95 group-[.toaster]:data-[type=warning]:to-amber-900/60","group-[.toaster]:data-[type=warning]:text-amber-100","group-[.toaster]:data-[type=warning]:border-amber-800/50","group-[.toaster]:data-[type=warning]:ring-amber-700/40","group-[.toaster]:data-[type=error]:bg-gradient-to-br","group-[.toaster]:data-[type=error]:from-red-700/95 group-[.toaster]:data-[type=error]:to-red-600/60","group-[.toaster]:data-[type=error]:text-red-100","group-[.toaster]:data-[type=error]:border-red-500/50","group-[.toaster]:data-[type=error]:ring-red-500/40","group-[.toaster]:data-[type=info]:bg-gradient-to-br","group-[.toaster]:data-[type=info]:from-blue-700/95 group-[.toaster]:data-[type=info]:to-blue-500/60","group-[.toaster]:data-[type=info]:text-blue-100","group-[.toaster]:data-[type=info]:border-blue-500/50","group-[.toaster]:data-[type=info]:ring-blue-500/40"]),description:(0,c.F)(["group/toast:text-xs group/toast:font-normal group/toast:mt-1","group/toast:opacity-80","group-data-[type=success]/toast:text-emerald-300","group-data-[type=warning]/toast:text-amber-300","group-data-[type=error]/toast:text-red-300","group-data-[type=info]/toast:text-blue-300","cursor-default"]),actionButton:(0,c.F)(["group/toast:bg-[--subtle] group/toast:text-[--foreground]","group/toast:rounded-lg group/toast:px-3 group/toast:py-1.5","group/toast:text-xs group/toast:font-medium","group/toast:transition-colors group/toast:hover:bg-[--subtle-hover]","group/toast:ring-1 group/toast:ring-[--border]/20"]),cancelButton:(0,c.F)(["group/toast:bg-transparent group/toast:text-[--muted]","group/toast:rounded-lg group/toast:px-3 group/toast:py-1.5","group/toast:text-xs group/toast:font-medium","group/toast:transition-colors group/toast:hover:bg-[--subtle]","group/toast:ring-1 group/toast:ring-transparent group/toast:hover:ring-[--border]/20"])},f=e=>{let{position:t="top-center",...s}=e,a=u.useMemo(()=>({position:t,visibleToasts:4,className:x(g.toaster()),toastOptions:{classNames:{toast:x(g.toast()),description:x(g.description()),actionButton:x(g.actionButton()),cancelButton:x(g.cancelButton())}},...s}),[]);return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(m.l$,{theme:"dark",...a})})};f.displayName="Toaster";let b={root:(0,c.F)(["UI-Button__root","whitespace-nowrap font-medium rounded-lg","inline-flex items-center text-white text-center justify-center","focus-visible:outline-none focus-visible:ring-1 ring-offset-1 ring-offset-[--background] focus-visible:ring-white/40","disabled:opacity-50 disabled:pointer-events-none disabled:transform-none"],{variants:{intent:{primary:"text-white border bg-brand-500 border-brand-400/20 active:bg-opacity-100 dark:bg-opacity-70 dark:hover:bg-opacity-90","primary-outline":"text-[--brand] border border-brand-500/40 bg-transparent hover:bg-brand-500/10 active:bg-brand-500/20 dark:border-brand-400/30 dark:hover:bg-brand-500/15 dark:active:bg-brand-500/25","primary-subtle":"text-[--brand] border bg-brand-50 border-transparent --border-brand-300/10 hover:bg-brand-100 active:bg-brand-200 dark:bg-opacity-10 dark:hover:bg-opacity-20","primary-link":"text-[--brand] border border-transparent bg-transparent hover:underline active:text-brand-700 dark:active:text-brand-300","primary-basic":"text-[--brand] border border-transparent bg-transparent hover:bg-brand-100 active:bg-brand-200 dark:hover:bg-opacity-10 dark:active:text-brand-300",warning:"text-white border bg-orange-500 border-orange-400/20 active:bg-opacity-100 dark:bg-opacity-85 dark:hover:bg-opacity-90","warning-outline":"text-[--orange] border border-orange-500/40 bg-transparent hover:bg-orange-500/10 active:bg-orange-500/20 dark:border-orange-400/30 dark:hover:bg-orange-500/15 dark:active:bg-orange-500/25","warning-subtle":"text-[--orange] border bg-orange-50 border-transparent --border-orange-300/10 hover:bg-orange-100 active:bg-orange-200 dark:bg-opacity-10 dark:hover:bg-opacity-20","warning-link":"text-[--orange] border border-transparent bg-transparent hover:underline active:text-orange-700 dark:active:text-orange-300","warning-basic":"text-[--orange] border border-transparent bg-transparent hover:bg-orange-100 active:bg-orange-200 dark:hover:bg-opacity-10 dark:active:text-orange-300",success:"text-white border bg-green-500 border-green-400/20 active:bg-opacity-100 dark:bg-opacity-85 dark:hover:bg-opacity-90","success-outline":"text-[--green] border border-green-500/40 bg-transparent hover:bg-green-500/10 active:bg-green-500/20 dark:border-green-400/30 dark:hover:bg-green-500/15 dark:active:bg-green-500/25","success-subtle":"text-[--green] border bg-green-50 border-transparent --border-green-300/10 hover:bg-green-100 active:bg-green-200 dark:bg-opacity-10 dark:hover:bg-opacity-20","success-link":"text-[--green] border border-transparent bg-transparent hover:underline active:text-green-700 dark:active:text-green-300","success-basic":"text-[--green] border border-transparent bg-transparent hover:bg-green-100 active:bg-green-200 dark:hover:bg-opacity-10 dark:active:text-green-300",alert:"text-white border bg-red-500 border-red-400/20 active:bg-opacity-100 dark:bg-opacity-85 dark:hover:bg-opacity-90","alert-outline":"text-[--red] border border-red-500/40 bg-transparent hover:bg-red-500/10 active:bg-red-500/20 dark:border-red-400/30 dark:hover:bg-red-500/15 dark:active:bg-red-500/25","alert-subtle":"text-[--red] border bg-red-50 border-transparent --border-red-300/10 hover:bg-red-100 active:bg-red-200 dark:bg-opacity-10 dark:hover:bg-opacity-20","alert-link":"text-[--red] border border-transparent bg-transparent hover:underline active:text-red-700 dark:active:text-red-300","alert-basic":"text-[--red] border border-transparent bg-transparent hover:bg-red-100 active:bg-red-200 dark:hover:bg-opacity-10 dark:active:text-red-300",gray:"bg-gray-500 hover:bg-gray-600 active:bg-gray-700 border border-transparent","gray-outline":"text-gray-600 border border-gray-500/30 bg-transparent hover:bg-gray-500/10 active:bg-gray-500/20 dark:text-gray-300 dark:border-gray-400/20 dark:hover:bg-gray-500/15 dark:active:bg-gray-500/25","gray-subtle":"text-[--gray] border bg-gray-100 border-transparent --border-gray-500/20 hover:bg-gray-200 active:bg-gray-300 dark:text-gray-100 dark:bg-opacity-10 dark:hover:bg-opacity-20","gray-link":"text-[--gray] border border-transparent bg-transparent hover:underline active:text-gray-700 dark:text-gray-300 dark:active:text-gray-200","gray-basic":"text-[--gray] border border-transparent bg-transparent hover:bg-gray-100 active:bg-gray-200 dark:active:bg-opacity-20 dark:text-gray-200 dark:hover:bg-opacity-10 dark:active:text-gray-200",white:"text-[#000] bg-white hover:bg-gray-200 active:bg-gray-300 border border-transparent","white-outline":"text-white border border-white/30 bg-transparent hover:bg-white/10 active:bg-white/20","white-subtle":"text-white bg-white bg-opacity-15 hover:bg-opacity-20 border border-transparent --border-white/10 active:bg-opacity-25","white-link":"text-white border border-transparent bg-transparent hover:underline active:text-gray-200","white-basic":"text-white border border-transparent bg-transparent hover:bg-white hover:bg-opacity-15 active:bg-opacity-20 active:text-white-300"},rounded:{true:"rounded-full",false:null},contentWidth:{true:"w-fit",false:null},size:{xs:"text-sm h-6 px-2",sm:"text-sm h-8 px-3",md:"text-sm h-10 px-4",lg:"h-12 px-6 text-lg",xl:"text-2xl h-14 px-8"}},defaultVariants:{intent:"primary",size:"md"}}),icon:(0,c.F)(["UI-Button__icon","inline-flex self-center flex-shrink-0"])},v=u.forwardRef((e,t)=>
1{let{children:s,size:a,className:r,rounded:n=!1,contentWidth:l=!1,intent:o,leftIcon:d,rightIcon:c,iconSpacing:u="0.5rem",loading:m,iconClass:h,disabled:p,hideTextOnSmallScreen:g,hideTextOnLargeScreen:f,...v}=e;return(0,i.jsx)("button",{type:"button",className:x(b.root({size:a,intent:o,rounded:n,contentWidth:l}),r),disabled:p||m,"aria-disabled":p,...v,ref:t,children:m?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("svg",{width:"15",height:"15",fill:"currentColor",className:"animate-spin",viewBox:"0 0 1792 1792",xmlns:"http://www.w3.org/2000/svg",style:{marginInlineEnd:g?0:u},children:(0,i.jsx)("path",{d:"M526 1394q0 53-37.5 90.5t-90.5 37.5q-52 0-90-38t-38-90q0-53 37.5-90.5t90.5-37.5 90.5 37.5 37.5 90.5zm498 206q0 53-37.5 90.5t-90.5 37.5-90.5-37.5-37.5-90.5 37.5-90.5 90.5-37.5 90.5 37.5 37.5 90.5zm-704-704q0 53-37.5 90.5t-90.5 37.5-90.5-37.5-37.5-90.5 37.5-90.5 90.5-37.5 90.5 37.5 37.5 90.5zm1202 498q0 52-38 90t-90 38q-53 0-90.5-37.5t-37.5-90.5 37.5-90.5 90.5-37.5 90.5 37.5 37.5 90.5zm-964-996q0 66-47 113t-113 47-113-47-47-113 47-113 113-47 113 47 47 113zm1170 498q0 53-37.5 90.5t-90.5 37.5-90.5-37.5-37.5-90.5 37.5-90.5 90.5-37.5 90.5 37.5 37.5 90.5zm-640-704q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm530 206q0 93-66 158.5t-158 65.5q-93 0-158.5-65.5t-65.5-158.5q0-92 65.5-158t158.5-66q92 0 158 66t66 158z"})}),s]}):(0,i.jsxs)(i.Fragment,{children:[d&&(0,i.jsx)("span",{className:x(b.icon(),h),style:{marginInlineEnd:g?0:u},children:d}),(0,i.jsx)("span",{className:x(g&&x("hidden",d&&"pl-[0.5rem]",c&&"pr-[0.5rem]"),f?"inline-block lg:hidden":"md:inline-block"),children:s}),c&&(0,i.jsx)("span",{className:x(b.icon(),h),style:{marginInlineStart:g?0:u},children:c})]})})});v.displayName="Button";let y=u.forwardRef((e,t)=>{let{className:s,icon:a,...r}=e;return(0,i.jsx)(w,{type:"button",intent:"gray-basic",size:"sm",className:x("rounded-full text-2xl flex-none",s),icon:a||(0,i.jsx)("span",{children:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor",children:(0,i.jsx)("path",{d:"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"})})}),...r,ref:t})});y.displayName="CloseButton";let j={root:(0,c.F)("UI-IconButton__root p-0 flex-none",{variants:{size:{xs:"text-xl h-6 w-6",sm:"text-xl h-8 w-8",md:"text-2xl h-10 w-10",lg:"text-3xl h-12 w-12",xl:"text-4xl h-14 w-14"}},defaultVariants:{size:"md"}})},w=u.forwardRef((e,t)=>{let{className:s,icon:a,size:r,loading:n,...l}=e;return(0,i.jsx)(v,{className:x(j.root({size:r}),s),loading:n,iconSpacing:"0",...l,ref:t,children:!n&&a})});w.displayName="IconButton";let N=e=>{let{children:t,reset:s,className:a,title:r="Oops!",showRefreshButton:n=!1,...l}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)("div",{"data-luffy-error":!0,className:x("w-full flex flex-col items-center mt-10 space-y-4",a),children:[(0,i.jsx)("div",{"data-luffy-error-image-container":!0,className:"size-[8rem] mx-auto flex-none rounded-[--radius-md] object-cover object-center relative overflow-hidden",children:(0,i.jsx)("img",{"data-luffy-error-image":!0,src:"/logo.png",alt:"",className:"absolute inset-0 w-full h-full object-contain object-top"})}),(0,i.jsxs)("div",{"data-luffy-error-content":!0,className:"text-center space-y-4",children:[!!r&&(0,i.jsx)("h3",{"data-luffy-error-title":!0,children:r}),(0,i.jsx)("div",{"data-luffy-error-content-children":!0,children:t}),(0,i.jsxs)("div",{"data-luffy-error-content-buttons":!0,children:[n&&!s&&(0,i.jsx)(v,{"data-luffy-error-content-button-refresh":!0,intent:"warning-subtle",onClick:()=>window.location.reload(),children:"Retry"}),!!s&&(0,i.jsx)(v,{"data-luffy-error-content-button-reset":!0,intent:"warning-subtle",onClick:s,children:"Retry"})]})]})]})})},k={container:(0,c.F)(["UI-LoadingSpinner__container","flex flex-col w-full items-center h-24 justify-center"]),icon:(0,c.F)(["UI-LoadingSpinner__icon","inline w-10 h-10 mr-2 animate-spin","text-gray-200 dark:text-gray-600 fill-brand-500"]),title:(0,c.F)(["UI-LoadingSpinner__title","text-base font-medium text-[--foreground] py-2"])},S=u.forwardRef((e,t)=>
1{let{children:s,className:a,containerClass:r,iconClass:n,spinner:l,title:o,...d}=e;return(0,i.jsxs)("div",{className:x(k.container(),r),...d,ref:t,children:[l||(0,i.jsx)(C,{className:n}),o&&(0,i.jsx)("p",{className:k.title(),children:o})]})});S.displayName="LoadingSpinner";let C=u.forwardRef((e,t)=>{let{children:s,className:a,...r}=e;return(0,i.jsxs)("svg",{"aria-hidden":"true",className:x(k.icon(),a),viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,...r,children:[(0,i.jsx)("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),(0,i.jsx)("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})}),_={overlay:(0,c.F)(["UI-LoadingOverlay__overlay","absolute bg-[--background]/50 w-full h-full z-10 inset-0 pt-4 flex flex-col items-center justify-center backdrop-blur-sm","!mt-0"])},A=u.forwardRef((e,t)=>{let{children:s,hide:a=!1,showSpinner:r=!0,className:n,...l}=e;return a?null:(0,i.jsxs)("div",{ref:t,className:x(_.overlay(),n),...l,children:[r&&(0,i.jsx)(S,{className:"justify-auto"}),s]})});A.displayName="LoadingOverlay";let R=(0,r.hy)()({component:function(){return(0,i.jsxs)(d.N,{attribute:"class",defaultTheme:"dark",forcedTheme:"dark",children:[(0,i.jsx)(f,{swipeDirections:["top","right"]}),(0,i.jsx)(o.s,{}),null]})},notFoundComponent:function(){return(0,i.jsx)(A,{showSpinner:!1,children:(0,i.jsx)(N,{title:"Page not found",showRefreshButton:!1,children:(0,i.jsx)("p",{children:"The page you are looking for does not exist."})})})}});var T=s(84121),I=s(85989),E=s(98427);let M={root:(0,c.F)(["UI-Popover__root","z-50 w-72 rounded-[--radius] border bg-[--background] p-4 text-base shadow-sm outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0","data-[state=open]:fade-in-50 data-[state=closed]:zoom-out-100 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"])},P=u.forwardRef((e,t)=>{let{trigger:s,triggerProps:a,defaultOpen:r,open:n,onOpenChange:l,modal:o=!0,className:d,align:c="center",sideOffset:u=8,...m}=e;return(0,i.jsxs)(E.bL,{defaultOpen:r,open:n,onOpenChange:l,modal:o,children:[(0,i.jsx)(E.l9,{asChild:!0,...a,children:s}),(0,i.jsx)(E.ZL,{children:(0,i.jsx)(E.UC,{ref:t,align:c,sideOffset:u,className:x(M.root(),d),onOpenAutoFocus:e=>e.preventDefault(),...m})})]})});P.displayName="Popover";let $={fieldLabel:(0,c.F)(["UI-BasicField__fieldLabel","text-base w-fit font-semibold self-start","data-[error=true]:text-red-500"]),fieldAsterisk:(0,c.F)("UI-BasicField__fieldAsterisk ml-1 text-red-500 text-sm"),fieldDetails:(0,c.F)("UI-BasicField__fieldDetails"),field:(0,c.F)("UI-BasicField__field relative w-full space-y-1"),fieldHelpText:(0,c.F)("UI-BasicField__fieldHelpText text-sm text-[--muted]"),fieldErrorText:(0,c.F)("UI-BasicField__fieldErrorText text-sm text-red-500")};function D(e,t){let{name:s,label:a,labelProps:r,help:n,moreHelp:l,error:i,required:o,disabled:d=!1,readonly:c=!1,fieldDetailsClass:u,fieldLabelClass:m,fieldAsteriskClass:h,fieldClass:p,fieldErrorTextClass:x,fieldHelpTextClass:g,id:f,...b}=e;return[b,{id:f||t,name:s,label:a,help:n,moreHelp:l,error:i,disabled:d,required:o,readonly:c,fieldAsteriskClass:h,fieldErrorTextClass:x,fieldHelpTextClass:g,fieldDetail
1sClass:u,fieldLabelClass:m,fieldClass:p,labelProps:r}]}let L=u.memo(u.forwardRef((e,t)=>{let{children:s,className:a,labelProps:r,id:n,label:l,error:o,help:d,moreHelp:c,disabled:u,readonly:m,required:h,fieldClass:p,fieldDetailsClass:g,fieldLabelClass:f,fieldAsteriskClass:b,fieldErrorTextClass:v,fieldHelpTextClass:y,...j}=e;return(0,i.jsxs)("div",{className:x($.field(),a,p),...j,ref:t,children:[!!l&&(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsxs)("label",{htmlFor:u?void 0:n,className:x($.fieldLabel(),f),"data-error":!!o,...r,children:[l,h&&(0,i.jsx)("span",{className:x($.fieldAsterisk(),b),children:"*"})]}),!!c&&(0,i.jsx)(P,{className:"text-sm",trigger:(0,i.jsx)(I.ExT,{className:"transition-opacity opacity-45 hover:opacity-90"}),children:c})]}),s,(!!d||!!o)&&(0,i.jsxs)("div",{className:x($.fieldDetails(),g),children:[!!d&&(0,i.jsx)("div",{className:x($.fieldHelpText(),y),children:d}),!!o&&(0,i.jsx)("div",{className:x($.fieldErrorText(),v),children:o})]})]})}));L.displayName="BasicField";let O={root:(0,c.F)(["UI-Input__root","flex items-center","w-full rounded-[--radius]","bg-[--paper] border border-[--border] placeholder-gray-400 dark:placeholder-gray-500","disabled:cursor-not-allowed","data-[disable=true]:shadow-none data-[disable=true]:opacity-50","focus:border-brand focus:ring-1 focus:ring-[--ring]","outline-0","transition duration-150","shadow-sm"],{variants:{size:{sm:"h-8 px-2 py-1 text-sm",md:"h-10 px-3",lg:"h-12 px-4 py-3 text-md"},intent:{basic:"hover:border-gray-300 dark:hover:border-gray-600",filled:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700 border-transparent focus:bg-white dark:focus:bg-gray-900 shadow-none",unstyled:"bg-transparent hover:bg-transparent border-0 shadow-none focus:ring-0 rounded-none p-0 text-base"},hasError:{false:null,true:"border-red-500 hover:border-red-200 dark:border-red-500"},isDisabled:{false:null,true:"shadow-none pointer-events-none opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-800"},isReadonly:{false:null,true:"pointer-events-none cursor-not-allowed shadow-sm"},hasLeftAddon:{true:null,false:null},hasRightAddon:{true:null,false:null},hasLeftIcon:{true:null,false:null},hasRightIcon:{true:null,false:null}},compoundVariants:[{hasLeftAddon:!0,className:"border-l-transparent hover:border-l-transparent rounded-l-none"},{hasRightAddon:!0,className:"border-r-transparent hover:border-r-transparent rounded-r-none"},{hasLeftAddon:!1,hasLeftIcon:!0,size:"sm",className:"pl-10"},{hasLeftAddon:!1,hasLeftIcon:!0,size:"md",className:"pl-10"},{hasLeftAddon:!1,hasLeftIcon:!0,size:"lg",className:"pl-12"},{hasRightAddon:!1,hasRightIcon:!0,size:"sm",className:"pr-10"},{hasRightAddon:!1,hasRightIcon:!0,size:"md",className:"pr-10"},{hasRightAddon:!1,hasRightIcon:!0,size:"lg",className:"pr-12"}],defaultVariants:{size:"md",intent:"basic",hasError:!1,isDisabled:!1,hasLeftIcon:!1,hasRightIcon:!1,hasLeftAddon:!1,hasRightAddon:!1}})},U=x("appearance-none absolute bottom-0 border-0 w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap [clip:rect(0px,0px,0px,0px)] [overflow-wrap:normal]");(0,c.F)(["UI-Input__inputContainer","flex relative"]);let F=e=>{let{className:t,children:s}=e;return(0,i.jsx)("div",{className:x("UI-Input__inputContainer flex relative",t),children:s})},z={icon:(0,c.F)(["UI-Input__addons--icon","pointer-events-none absolute inset-y-0 grid place-content-center text-gray-500","dark:text-gray-300 !z-[1]"],{variants:{size:{sm:"w-10 text-md",md:"w-12 text-lg",lg:"w-14 text-2xl"},isLeftIcon:{true:"left-0",false:null},isRightIcon:{true:"right-0",false:null}},defaultVariants:{size:"md",isLeftIcon:!1,isRightIcon:!1}}),addon:(0,c.F)(["UI-Input__addons--addon","bg-gray-50 inline-flex items-center flex-none px-3 border border-gray-300 text-gray-800 shadow-sm text-sm sm:text-md","dark:bg-[--paper] dark:border-[--border] dark:text-gray-300"],{variants:{size:{sm:"text-sm",md:"text-md",lg:"text-lg"},isLeftAddon:{true:"rounded-l-md border-r-0",false:null},isRightAddon:{true:"rounded-r-md border-l-0",false:null},hasLeftIcon:{true:null,false:null},hasRightIcon:{true:null,false:null}},compoundVariants:[{size:"sm",hasLeftIcon:!0,isLeftAddon:!0,className:"pl-10"},{size:"sm",hasRightIcon:!0,isRightAddon:!0,className:"pr-10"},{size:"md",hasLeftIcon:!0,isLeftAddon:!0,className:"pl-10"},{size:"md",hasRightIcon:!0,isRightAddon:!0,className:"pr-10"},{size:"lg",hasLeftIcon:!0,isLeftAddon:!0,className:"pl-12"},{size:"lg",hasRightIcon:!0,isRightAddon:!0,className:"pr-12"}],defaultVariants:{size:"md",isLeftAddon:!1,isRightAddon:!1,hasLeftIcon:!1,hasRightIcon:!1}})},V=e=>{let{icon:t,size:s="md",side:a,props:r,className:n}=e;return t?(0,i.jsx)("span",{className:x(z.icon({isRightIcon:"right"===a,isLeftIcon:"left"===a,size:s}),n),...r,children:t}):null},q=e=>{let{addon:t,leftIcon:s,rightIcon:a,size:r="md",side:n,props:l,className:o}=e;return t?(0,i.jsx)("span",{className:x(z.addon({isRightAddon:"right"===n,isLeftAddon:"left"===n,hasRightIcon:!!a,hasLeftIcon:!!s,size:r}),o),...l,children:t}):null};function B(e){let{size:t,leftAddon:s,leftIcon:a,rightAddon:r,rightIcon:n,inputContainerClass:l,iconClass:i,addonClass:o,...d}=e;return[{size:t,leftAddon:s,leftIcon:a,rightAddon:r,rightIcon:n,...d},{inputContainerProps:{className:l}
1,leftAddonProps:{addon:s,leftIcon:a,rightIcon:n,size:t,side:"left",className:o},rightAddonProps:{addon:r,leftIcon:a,rightIcon:n,size:t,side:"right",className:o},leftIconProps:{icon:a,size:t,side:"left",className:i},rightIconProps:{icon:n,size:t,side:"right",className:i}}]}let K=u.forwardRef((e,t)=>{let[s,a]=D(e,u.useId()),[{size:r,intent:n,leftAddon:l,leftIcon:o,rightAddon:d,rightIcon:c,className:m,onValueChange:h,onChange:p,...g},{inputContainerProps:f,leftAddonProps:b,leftIconProps:v,rightAddonProps:y,rightIconProps:j}]=B({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),w=u.useCallback(e=>{null==h||h(e.target.value),null==p||p(e)},[h,p]);return(0,i.jsx)(L,{...a,children:(0,i.jsxs)(F,{...f,children:[(0,i.jsx)(q,{...b}),(0,i.jsx)(V,{...v}),(0,i.jsx)("input",{id:a.id,name:a.name,className:x("form-input",O.root({size:r,intent:n,hasError:!!a.error,isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!d,hasRightIcon:!!c,hasLeftAddon:!!l,hasLeftIcon:!!o}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,onChange:w,...g,ref:t}),(0,i.jsx)(q,{...y}),(0,i.jsx)(V,{...j})]})})});K.displayName="TextInput";var H=s(36603),W=s(34038);let G=u.forwardRef((e,t)=>{let[s,a]=D(e,u.useId()),[{size:r,intent:n,leftAddon:l,leftIcon:o,rightAddon:d,rightIcon:c,className:m,onValueChange:h,onChange:p,autoComplete:g="
1current-password",...f},{inputContainerProps:b,leftAddonProps:v,leftIconProps:y,rightAddonProps:j,rightIconProps:w}]=B({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),N=u.useCallback(e=>{null==h||h(e.target.value),null==p||p(e)},[h,p]);return(0,i.jsx)(L,{...a,children:(0,i.jsxs)(F,{...b,children:[(0,i.jsx)(q,{...v}),(0,i.jsx)(V,{...y}),(0,i.jsx)("div",{className:"relative flex-1",children:(0,i.jsxs)(H.bL,{children:[(0,i.jsx)(H.pd,{id:a.id,name:a.name,className:x("form-input",O.root({size:r,intent:n,hasError:!!a.error,isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!d,hasRightIcon:!!c,hasLeftAddon:!!l,hasLeftIcon:!!o}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,onChange:N,autoComplete:g,...f,ref:t}),(0,i.jsx)(H.lM,{className:x("absolute right-0 top-0 h-full px-3","text-muted-foreground hover:text-foreground","focus:outline-none focus:ring-0","disabled:opacity-50 disabled:pointer-events-none","bg-transparent"),children:(0,i.jsx)(H.In,{visible:(0,i.jsx)(W.ZT8,{className:"h-6 w-6"}),hidden:(0,i.jsx)(W.Fnz,{className:"h-6 w-6"})})})]})}),(0,i.jsx)(q,{...j}),(0,i.jsx)(V,{...w})]})})});G.displayName="PasswordInput";let Y={root:(0,c.F)(["UI-Card__root","rounded-xl border bg-[--paper] shadow-sm"]),header:(0,c.F)(["UI-Card__header","flex flex-col space-y-1.5 p-4"]),title:(0,c.F)(["UI-Card__title","text-2xl font-semibold leading-none tracking-tight"]),description:(0,c.F)(["UI-Card__description","text-sm text-[--muted]"]),content:(0,c.F)(["UI-Card__content","p-4 pt-0"]),footer:(0,c.F)(["UI-Card__footer","flex items-center p-4 pt-0"])},J=u.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,i.jsx)("div",{ref:t,className:x(Y.root(),s),...a})});J.displayName="Card";let Z=u.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,i.jsx)("div",{ref:t,className:x(Y.header(),s),...a})});Z.displayName="CardHeader";let Q=u.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,i.jsx)("h3",{ref:t,className:x(Y.title(),s),...a})});Q.displayName="CardTitle";let X=u.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,i.jsx)("div",{ref:t,className:x(Y.description(),s),...a})});X.displayName="CardDescription";let ee=u.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,i.jsx)("div",{ref:t,className:x(Y.content(),s),...a})});ee.displayName="CardContent",u.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,i.jsx)("div",{ref:t,className:x(Y.footer(),s),...a})}).displayName="CardFooter";var et=s(57215);class es extends Error{is(e){return this.code===e}constructor(e,t,s,a=null,r){super(s),(0,et._)(this,"status",void 0),(0,et._)(this,"code",void 0),(0,et._)(this,"detail",void 0),(0,et._)(this,"issues",void 0),this.name="APIError",this.status=e,this.code=t,this.detail=a,this.issues=r}}async function ea(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{body:s,...a}=t,[r,n]=e.includes(" /")?e.split(" /"):["GET",e.slice(1)],l=`/api/v1/${n}`,i=new Headers(a.headers),o={method:r,credentials:"include",...a,headers:i};void 0!==s&&(s instanceof FormData||"string"==typeof s?o.body=s:(i.set("Content-Type","application/json"),o.body=JSON.stringify(s)));let d=await fetch(l,o);if(204===d.status)return null;let c=d.headers.get("Content-Type")??"";if(!c.includes("application/json")){if(d.url.includes("/login")){let e=encodeURIComponent(window.location.pathname+window.location.search);window.location.href=`/login?next=${e}`,await new Promise(()=>{})}throw Error(`Expected JSON response but got ${c} response of ${d.status} ${d.statusText}`)}let u=await d.json();if(!u.success){var m,h,p;let e=(null==(m=u.error)?void 0:m.code)||"UNKNOWN_ERROR",t=(null==(h=u.error)?void 0:h.message)||"An unknown error occurred",s=u.detail,a=null==(p=u.error)?void 0:p.issues;throw new es(d.status,e,t,s,a)}return u.data}async function er(e,t){return ea("POST /auth/login",{body:{username:e,password:t}})}async function en(){return ea("POST /auth/logout")}async function el(){return ea("/auth/me")}function ei(e,t){let s=new TextEncoder().encode(`${e}:${t}`),a="";for(let e of s)a+=String.fromCharCode(e);return`Basic ${btoa(a)}`}function eo(e,t){return null===t?{}:{headers:{Authorization:ei(e,t)}}}function ed(){return!("u"<typeof document)&&document.cookie.split(";").some(e=>e.trim().startsWith("aiostreams.has-config-session="))}async function ec(e,t,s){return ea("POST /user/session",{body:{remember:s}
1,headers:{Authorization:ei(e,t)}})}async function eu(){return ea("DELETE /user/session")}async function em(){return ea("DELETE /user/sessions")}async function eh(e,t){return ea("GET /user?raw=true",eo(e,t))}async function ep(){return ea("GET /user?raw=true")}async function ex(e,t){return ea("POST /user",{body:{config:e,password:t}})}async function eg(e,t,s){return ea("PUT /user",{body:{config:t},...eo(e,s)})}async function ef(e,t){return ea("GET /user/client-agents",eo(e,t))}async function eb(e,t,s){return ea("POST /user/variants/evaluate",{body:s,...eo(e,t)})}async function ev(e,t,s){return ea("POST /user/health-checks/test",{body:s,...eo(e,t)})}async function ey(e,t){return ea("POST /user/verify",{headers:{Authorization:ei(e,t)}})}async function ej(e,t){return ea("DELETE /user",{headers:{Authorization:ei(e,t)}})}async function ew(e,t,s){return ea("POST /user/password",{body:{newPassword:s},headers:{Authorization:ei(e,t)}})}async function eN(){return ea("/profiles")}async function ek(e,t,s){return ea("POST /profiles",{body:{uuid:e,password:t,label:s}})}async function eS(e,t){return ea(`PATCH /profiles/${e}`,{body:t})}async function eC(e){return ea(`DELETE /profiles/${e}`)}async function e_(e){return ea(`POST /profiles/${e}/open`)}async function eA(e,t){return ea("POST /sync/resolve",{body:{regexUrls:e.regexUrls,selUrls:e.selUrls,uuid:null==t?void 0:t.uuid,password:null==t?void 0:t.password}})}async function eR(e,t){let s=await eA({regexUrls:e},t);return{patterns:s.patterns||[],errors:s.errors}}async function eT(e,t){let s=await eA({selUrls:e},t);return{expressions:s.expressions||[],errors:s.errors}}async function eI(e){return ea("POST /catalogs",{body:{userData:e}})}async function eE(e){return ea("POST /oauth/exchange/gdrive",{body:{code:e}})}async function eM(){return ea("GET /templates")}async function eP(e,t,s){return ea(`GET /user/analytics?range=${s}`,eo(e,t))}function e$(e){return eo(e.uuid,e.password)}async function eD(e){return ea("GET /linked-accounts/platforms",e$(e))}async function eL(e){return ea("GET /linked-accounts",e$(e))}async function eO(e){return ea(`GET /community/${e}s`)}async function eU(e){return ea("GET /community/mine",e$(e))}async function eF(e,t){return ea("POST /community/formatters",{...e$(e),body:t})}async function ez(e,t){return ea("POST /community/templates",{...e$(e),body:{template:t}})}async function eV(e,t,s){return ea(`PUT /community/items/${encodeURIComponent(t)}`,{...e$(e),body:s})}async function eq(e,t){return ea(`DELETE /community/items/${encodeURIComponent(t)}/draft`,e$(e))}async function eB(e,t){return ea(`DELETE /community/items/${encodeURIComponent(t)}`,e$(e))}async function eK(e,t){return ea(`POST /community/items/${encodeURIComponent(t)}/like`,e$(e))}async function eH(e,t,s){return ea("POST /linked-accounts/probe",{...e$(e),body:{platform:t,instanceUrl:s}})}async function eW(e,t){return ea("POST /linked-accounts",{...e$(e),body:t})}async function eG(e,t,s){return ea(`PATCH /linked-accounts/${t}`,{...e$(e),body:s})}async function eY(e,t){return ea(`DELETE /linked-accounts/${t}`,e$(e))}async function eJ(e,t){return ea(`POST /linked-accounts/${t}/push`,e$(e))}async function eZ(e){return ea("POST /linked-accounts/push",e$(e))}async function eQ(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch manifest: ${t.status} ${t.statusText}`);return t.json()}async function eX(e){return ea("GET /user/watch-state",e$(e))}async function e0(e,t,s,a){return ea("POST /jellyfin/quickconnect/approve",{...e$(e),body:{code:t,...s?{persona:s}:{},...a?{pin:a}:{}}})}async function e1(e,t){return ea("POST /jellyfin/api-keys/token",{...e$(e),body:{id:t}})}async function e2(e,t){return ea(`GET /jellyfin/quickconnect/pending?code=${encodeURIComponent(t)}`,e$(e))}var e3=s(51650),e5=s(19217),e4=s(83620);let e6="https://docs.aiostreams.viren070.me",e9=`${e6}/changelog`,e8=/^\d{4}\.\d{2}\.\d{2}\.\d{4}-nightly$/;function e7(e){let[t,s]=e.replace(/^v/,"").split(".");return`${t}.${s}`}function te(e,t){let s=e7(t);return e.find(e=>e.version&&e7(e.version)===s)}function tt(e){return e.url.startsWith("http")?e.url:`${e6}${e.url}`}async function ts(){let e=await fetch(`${e6}/api/changelog.json`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return Array.isArray(t)?t:[]}async function ta(e){let t=await fetch(`https://api.github.com/repos/viren070/aiostreams/releases?per_page=100&page=${e}`);if(!t.ok)throw Error(403===t.status?"GitHub rate limit reached. Try again in a little while.":`HTTP ${t.status}`);let s=await t.json(),a=t.headers.get("link");return{releases:s,hasNextPage:!!a&&a.includes('rel="next"')}}let tr="aiostreams-last-seen-version",tn=["aiostreams-first-time","aiostreams-mode","aiostreams-template-inputs","aiostreams-custom-templates"],tl=/stremio\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/.*\/configure/;function ti(e){try{localStorage.setItem(tr,e)}catch{}}let to=(0,e4.j)({queryKey:["session"],queryFn:el,staleTime:6e4,retry:!1}),td=(0,e4.j)({queryKey:["status"],queryFn:()=>ea("/status"),staleTime:6e4,retry:!1}),tc=(0,e4.j)({queryKey:["docs-changelog"],queryFn:ts,staleTime:1/0}),tu=(0,e4.j)({queryKey:["config-profiles"],queryFn:eN,staleTime:3e4,retry:!1}),tm=e=>(0,e4.j)({queryKey:["linked-accounts",(null==e?void 0:e.uuid)??null],queryFn:()=>e?eL(e):Promise.resolve([]),enabled:!!e,staleTime:3e4,retry:!1}),th=["linked-accounts"],tp=["watch-state-trackers"],tx=e=>(0,e4.j)({queryKey:[...tp,(null==e?void 0:e.uuid)??null],queryFn:()=>e?eX(e):Promise.resolve({push:!1,pull:!1,trackers:[],available:[]}),enabled:!!e,staleTime:3e4,retry:!1}),tg=e=>(0,e4.j)({queryKey:["linked-account-platforms"],queryFn:()=>e?eD(e):Promise.resolve([]),enabled:!!e,staleTime:1/0,retry:!1}),tf=["community"],tb=["community-mine"],tv=e=>(0,e4.j)({queryKey:[...tb,(null==e?void 0:e.uuid)??null],queryFn:()=>e?eU(e):Promise.resolve([]),enabled:!!e,staleTime:15e3,retry:!1});var ty=s(9503);function tj(){let{data:e,isLoading:t,error:s}=(0,ty.I)(td);return{status:e??null,loading:t,error:s?s.message:null}}function tw(e){if(!e)return"/dashboard/";try{let t=decodeURIComponent(e);
1if(t.startsWith("/")&&!t.startsWith("//")&&!t.startsWith("/\\"))return t}catch{}return"/dashboard/"}let tN={forbidden:{title:"Your account does not have admin access.",description:"Sign in with an admin account to continue."},oidc_disabled:{title:"SSO login is not enabled on this instance."},oidc_not_configured:{title:"SSO is not fully configured.",description:"The instance owner needs to set the issuer and client ID."},oidc_discovery_failed:{title:"Could not reach the SSO provider.",description:"It may be down or the issuer URL may be wrong."},oidc_state_invalid:{title:"That login attempt expired.",description:"Please try signing in again."},oidc_denied:{title:"The SSO provider denied the login request."},oidc_exchange_failed:{title:"The SSO provider rejected the login.",description:"Check the client ID, secret, and redirect URI."},oidc_claims_invalid:{title:"The SSO provider did not return the expected user details.",description:"Check the configured username claim."},oidc_username_conflict:{title:"That SSO username collides with a local account.",description:"The instance owner needs to set an SSO username prefix."},oidc_no_permissions:{title:"Your account is not mapped to any permissions.",description:"Ask the instance owner to map one of your groups."}};var tk=s(86505);let tS={root:(0,c.F)(["UI-AppLayout__root appLayout","flex w-full group/appLayout"],{variants:{withSidebar:{true:"flex-row with-sidebar",false:"flex-col"},sidebarSize:{slim:"sidebar-slim",sm:"sidebar-sm",md:"sidebar-md",lg:"sidebar-lg",xl:"sidebar-xl"}},defaultVariants:{withSidebar:!1,sidebarSize:"md"},compoundVariants:[{withSidebar:!0,sidebarSize:"slim",className:"lg:[&>.appLayout]:pl-20"},{withSidebar:!0,sidebarSize:"sm",className:"lg:[&>.appLayout]:pl-48"},{withSidebar:!0,sidebarSize:"md",className:"lg:[&>.appLayout]:pl-64"},{withSidebar:!0,sidebarSize:"lg",className:"lg:[&>.appLayout]:pl-[20rem]"},{withSidebar:!0,sidebarSize:"xl",className:"lg:[&>.appLayout]:pl-[25rem]"}]})},tC={root:(0,c.F)(["UI-AppLayoutHeader__root","relative w-full"])},t_={root:(0,c.F)(["UI-AppLayoutSidebar__root z-50","hidden lg:fixed lg:inset-y-0 lg:flex lg:flex-col grow-0 shrink-0 basis-0","group-[.sidebar-slim]/appLayout:w-20","group-[.sidebar-sm]/appLayout:w-48","group-[.sidebar-md]/appLayout:w-64","group-[.sidebar-lg]/appLayout:w-[20rem]","group-[.sidebar-xl]/appLayout:w-[25rem]"])},tA={root:(0,c.F)(["UI-AppLayoutContent__root","relative"])},tR={root:(0,c.F)(["UI-AppLayoutFooter__root","relative"])},tT={root:(0,c.F)(["UI-AppLayoutStack__root","relative"],{variants:{spacing:{sm:"space-y-2",md:"space-y-4",lg:"space-y-8",xl:"space-y-10"}},defaultVariants:{spacing:"md"}})},tI={root:(0,c.F)(["UI-AppLayoutGrid__root","relative flex flex-col"],{variants:{breakBelow:{sm:"sm:grid sm:space-y-0",md:"md:grid md:space-y-0",lg:"lg:grid lg:space-y-0",xl:"xl:grid xl:space-y-0"},spacing:{sm:"gap-2",md:"gap-4",lg:"gap-8",xl:"gap-10"},cols:{1:null,2:null,3:null,4:null,5:null,6:null}},defaultVariants:{breakBelow:"xl",spacing:"md",cols:3},compoundVariants:[{breakBelow:"sm",cols:1,className:"sm:grid-cols-1"},{breakBelow:"sm",cols:2,className:"sm:grid-cols-2"},{breakBelow:"sm",cols:3,className:"sm:grid-cols-3"},{breakBelow:"sm",cols:4,className:"sm:grid-cols-4"},{breakBelow:"sm",cols:5,className:"sm:grid-cols-5"},{breakBelow:"sm",cols:6,className:"sm:grid-cols-6"},{breakBelow:"md",cols:1,className:"md:grid-cols-1"},{breakBelow:"md",cols:2,className:"md:grid-cols-2"},{breakBelow:"md",cols:3,className:"md:grid-cols-3"},{breakBelow:"md",cols:4,className:"md:grid-cols-4"},{breakBelow:"md",cols:5,className:"md:grid-cols-5"},{breakBelow:"md",cols:6,className:"md:grid-cols-6"},{breakBelow:"lg",cols:1,className:"lg:grid-cols-1"},{breakBelow:"lg",cols:2,className:"lg:grid-cols-2"},{breakBelow:"lg",cols:3,className:"lg:grid-cols-3"},{breakBelow:"lg",cols:4,className:"lg:grid-cols-4"},{breakBelow:"lg",cols:5,className:"lg:grid-cols-5"},{breakBelow:"lg",cols:6,className:"lg:grid-cols-6"},{breakBelow:"xl",cols:1,className:"xl:grid-cols-1"},{breakBelow:"xl",cols:2,className:"xl:grid-cols-2"},{breakBelow:"xl",cols:3,className:"xl:grid-cols-3"},{breakBelow:"xl",cols:4,className:"xl:grid-cols-4"},{breakBelow:"xl",cols:5,className:"xl:grid-cols-5"},{breakBelow:"xl",cols:6,className:"xl:grid-cols-6"}]})},tE=u.forwardRef((e,t)=>
1{let{children:s,className:a,withSidebar:r=!1,sidebarSize:n,...l}=e,o=u.useContext(tV);return(0,i.jsx)("div",{ref:t,className:x(tS.root({withSidebar:r,sidebarSize:o.size||n}),!1,a),...l,children:s})});tE.displayName="AppLayout",u.forwardRef((e,t)=>{let{children:s,className:a,...r}=e;return(0,i.jsx)("header",{ref:t,className:x(tC.root(),a),...r,children:s})}).displayName="AppLayoutHeader";let tM=u.forwardRef((e,t)=>{let{children:s,className:a,...r}=e;return(0,i.jsx)("aside",{ref:t,className:x(t_.root(),a),...r,children:s})});tM.displayName="AppLayoutSidebar";let tP=u.forwardRef((e,t)=>{let{children:s,className:a,...r}=e;return(0,i.jsx)("main",{ref:t,className:x(tA.root(),a),...r,children:s})});tP.displayName="AppLayoutContent",u.forwardRef((e,t)=>{let{children:s,className:a,breakBelow:r,cols:n,spacing:l,...o}=e;return(0,i.jsx)("section",{ref:t,className:x(tI.root({breakBelow:r,cols:n,spacing:l}),a),...o,children:s})}).displayName="AppLayoutGrid",u.forwardRef((e,t)=>{let{children:s,className:a,...r}=e;return(0,i.jsx)("footer",{ref:t,className:x(tR.root(),a),...r,children:s})}).displayName="AppLayoutFooter",u.forwardRef((e,t)=>{let{children:s,className:a,spacing:r,...n}=e;return(0,i.jsx)("div",{ref:t,className:x(tT.root({spacing:r}),a),...n,children:s})}).displayName="AppLayoutStack";var t$=s(95045),tD=s(59484);function tL(e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}}let tO=e=>[Object,Array].includes((e||{}).constructor)&&!Object.entries(e||{}).length;function tU(e){return e instanceof Element&&!!e.closest("[data-sonner-toast], [data-modal-passthrough]")}let tF={overlay:(0,c.F)(["UI-Drawer__overlay","fixed inset-0 w-screen z-[50] bg-black/80","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"]),content:(0,c.F)(["UI-Drawer__content","fixed z-50 w-full gap-4 bg-[--background] p-6 shadow-lg overflow-y-auto","transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-500 data-[state=open]:duration-500","focus:outline-none focus-visible:outline-none",!1],{variants:{side:{mangaReader:"w-full inset-x-0 top-0 border data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",top:"w-full lg:w-[calc(100%_-_20px)] inset-x-0 top-0 border data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"w-full lg:w-[calc(100%_-_20px)] inset-x-0 bottom-0 border data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full lg:h-[calc(100%_-_20px)] border data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",right:"inset-y-0 right-0 h-full lg:h-[calc(100%_-_20px)] border data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right"},size:{sm:null,md:null,lg:null,xl:null,full:null}},defaultVariants:{side:"right",size:"md"},compoundVariants:[{size:"sm",side:"left",className:"sm:max-w-sm"},{size:"sm",side:"right",className:"sm:max-w-sm"},{size:"md",side:"left",className:"sm:max-w-md"},{size:"md",side:"right",className:"sm:max-w-md"},{size:"lg",side:"left",className:"sm:max-w-2xl"},{size:"lg",side:"right",className:"sm:max-w-2xl"},{size:"xl",side:"left",className:"sm:max-w-5xl"},{size:"xl",side:"right",className:"sm:max-w-5xl"},{size:"full",side:"top",className:"h-dvh"},{size:"full",side:"bottom",className:"h-dvh"}]}),close:(0,c.F)(["UI-Drawer__close","absolute right-4 top-4"]),header:(0,c.F)(["UI-Drawer__header","flex flex-col space-y-1.5 text-center sm:text-left"]),footer:(0,c.F)(["UI-Drawer__footer","flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2"]),title:(0,c.F)(["UI-Drawer__title","text-xl font-semibold leading-none tracking-tight"]),description:(0,c.F)(["UI-Drawer__description","text-sm text-[--muted]"])};function tz(e){let{allowOutsideInteraction:t=!1,trigger:s,title:a,footer:r,description:n,children:l,closeButton:o,overlayClass:d,contentClass:c,closeClass:m,headerClass:h,footerClass:p,titleClass:g,descriptionClass:f,hideCloseButton:b,side:v="right",size:j,open:w,onOpenAutoFocus:N,onCloseAutoFocus:k,onEscapeKeyDown:S,onPointerDownCapture:C,onInteractOutside:_,portalContainer:A,mangaReader:R,...T}=e;return!function(e,t){let[s,a]=(0,u.useState)([]);u.useEffect(()=>{if(document.querySelector("body"))return t?a(t=>[...t,e]):a(t=>t.filter(t=>t!==e)),()=>{a(t=>t.filter(t=>t!==e))}},[t])}(u.useId(),w),(0,i.jsxs)(t$.bL,{modal:!t,open:w,...T,children:[s&&(0,i.jsx)(t$.l9,{asChild:!0,children:s}),(0,i.jsxs)(t$.ZL,{container:A,children:[(0,i.jsx)(t$.hJ,{className:x(tF.overlay(),d)}),(0,i.jsxs)(t$.UC,{className:x(tF.content({size:j,side:R?"mangaReader":v}),!R&&"lg:m-[10px] rounded-[--radius]",c),style:{marginTop:void 0,height:void 0},onOpenAutoFocus:N,onCloseAutoFocus:k,onEscapeKeyDown:S,onPointerDownCapture:C,onInteractOutside:e=>{tU(e.target)?e.preventDefault():null==_||_(e)}
1,tabIndex:-1,children:[a||n?(0,i.jsxs)("div",{className:x(tF.header(),h),children:[(0,i.jsx)(t$.hE,{className:x(tF.title(),!1,g),children:a}),n&&(0,i.jsx)(t$.VY,{className:x(tF.description(),f),children:n})]}):(0,i.jsx)(tD.s6,{children:(0,i.jsx)(t$.hE,{children:"Drawer"})}),l,r&&(0,i.jsx)("div",{className:x(tF.footer(),p),children:r}),!b&&(0,i.jsx)(t$.bm,{className:x(tF.close(),m),asChild:!0,children:o||(0,i.jsx)(y,{})})]})]})]})}tz.displayName="Drawer";let tV=u.createContext({open:!1,setOpen:()=>{},setSize:()=>{},size:"md",isBelowBreakpoint:!1});function tq(){let e=u.useContext(tV);if(!e)throw Error("useAppSidebarContext must be used within a AppSidebarProvider");return e}let tB={sidebar:(0,c.F)(["UI-AppSidebar__sidebar","flex flex-grow flex-col overflow-y-auto border-r border-transparent bg-[--background]"])},tK={trigger:(0,c.F)(["UI-AppSidebarTrigger__trigger","block lg:hidden","items-center justify-center rounded-[--radius] p-2 text-[--muted] hover:bg-[--subtle] hover:text-[--foreground] transition-colors","focus:outline-none focus:ring-2 focus:ring-inset focus:ring-[--ring]"])},tH=u.forwardRef((e,t)=>{let{children:s,className:a,...r}=e,n=u.useContext(tV);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{ref:t,className:x(tB.sidebar(),a),...r,children:s}),(0,i.jsx)(tz,{open:n.open,onOpenChange:e=>n.setOpen(e),side:"left",children:s})]})});tH.displayName="AppSidebar";let tW=u.forwardRef((e,t)=>{let{children:s,className:a,...r}=e,n=u.useContext(tV);return(0,i.jsxs)("button",{ref:t,className:x(tK.trigger(),a),onClick:()=>n.setOpen(!n.open),...r,children:[(0,i.jsx)("span",{className:"sr-only",children:"Open main menu"}),n.open?(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"block h-6 w-6",children:[(0,i.jsx)("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),(0,i.jsx)("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]}):(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"block h-6 w-6",children:[(0,i.jsx)("line",{x1:"4",x2:"20",y1:"12",y2:"12"}),(0,i.jsx)("line",{x1:"4",x2:"20",y1:"6",y2:"6"}),(0,i.jsx)("line",{x1:"4",x2:"20",y1:"18",y2:"18"})]})]})});tW.displayName="AppSidebarTrigger";let tG=e=>{let{children:t,onOpenChange:s,onSizeChange:a}=e,[r,n]=u.useState(!1),[l,o]=u.useState(void 0),[d,c]=u.useState(!1);return u.useEffect(()=>{let e=()=>c(window.innerWidth<1024);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[d]),(0,i.jsx)(tV.Provider,{value:{open:r,setOpen:e=>{null==s||s(e),n(e)},setSize:e=>{null==a||a(e),o(e)},size:l,isBelowBreakpoint:d},children:t})};tG.displayName="AppSidebarProvider";var tY=s(5976);let tJ={item:(0,c.F)(["UI-Disclosure__item"]),contentContainer:(0,c.F)(["UI-Disclosure__contentContainer","overflow-hidden transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"]),content:(0,c.F)(["UI-Disclosure__content"])},tZ=u.createContext({}),tQ=u.forwardRef((e,t)=>{let{contentContainerClass:s,contentClass:a,itemClass:r,...n}=e;return(0,i.jsx)(tZ.Provider,{value:{itemClass:r,contentContainerClass:s,contentClass:a},children:(0,i.jsx)(tY.bL,{ref:t,...n})})});tQ.displayName="Disclosure";let tX=u.forwardRef((e,t)=>{let{className:s,...a}=e,{itemClass:r}=u.useContext(tZ);return(0,i.jsx)(tY.q7,{ref:t,className:x(tJ.item(),r,s),...a}
1)});tX.displayName="DisclosureItem";let t0=u.forwardRef((e,t)=>(0,i.jsx)(tY.Y9,{asChild:!0,children:(0,i.jsx)(tY.l9,{ref:t,asChild:!0,...e})}));t0.displayName="DisclosureTrigger";let t1=u.forwardRef((e,t)=>{let{className:s,contentContainerClass:a,children:r,...n}=e,{contentContainerClass:l,contentClass:o}=u.useContext(tZ);return(0,i.jsx)(tY.UC,{ref:t,className:x(tJ.contentContainer(),l,a),...n,children:(0,i.jsx)("div",{className:x(tJ.content(),o,s),children:r})})});t1.displayName="DisclosureContent";var t2=s(15191);let t3={root:(0,c.F)(["UI-Tooltip__root","z-50 overflow-hidden rounded-xl px-3 py-1.5 text-sm shadow-md animate-in fade-in-50","bg-gray-900 border text-white","data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1","data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1"])},t5=u.forwardRef((e,t)=>{let{children:s,className:a,trigger:r,delayDuration:n=50,disableHoverableContent:l,defaultOpen:o,open:d,onOpenChange:c,...u}=e;return(0,i.jsx)(t4,{children:(0,i.jsxs)(t2.bL,{delayDuration:n,disableHoverableContent:l,defaultOpen:o,open:d,onOpenChange:c,children:[(0,i.jsx)(t2.l9,{asChild:!0,children:r}),(0,i.jsx)(t2.ZL,{children:(0,i.jsx)(t2.UC,{ref:t,className:x(t3.root(),a),...u,children:s})})]})})});t5.displayName="Tooltip";let t4=t2.Kq;var t6=s(32248);let t9={root:(0,c.F)(["UI-HoverCard__root","z-50 w-64 rounded-xl text-sm border bg-[--paper] p-4 shadow-sm outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0","data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-100 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"])},t8=u.forwardRef((e,t)=>{let{className:s,align:a="center",sideOffset:r=8,openDelay:n=1e3,closeDelay:l=0,trigger:o,...d}=e;return(0,i.jsxs)(t6.bL,{openDelay:n,closeDelay:l,children:[(0,i.jsx)(t6.l9,{asChild:!0,children:o}),(0,i.jsx)(t6.ZL,{children:(0,i.jsx)(t6.UC,{ref:t,align:a,sideOffset:r,className:x(t9.root(),s),...d})})]})});t8.displayName="HoverCard";var t7=s(15591),se=s(68364);let st={root:(0,c.F)(["UI-VerticalMenu__root","flex flex-col gap-1"]),item:(0,c.F)(["UI-VerticalMenu__item","group/verticalMenu_item relative flex flex-none truncate items-center w-full font-medium rounded-[--radius] transition cursor-pointer","hover:text-[--foreground]","focus-visible:bg-[--subtle] outline-none text-[--muted]","data-[current=true]:bg-[--subtle] data-[current=true]:text-[--foreground]"],{variants:{collapsed:{true:"justify-center",false:null},isSidebar:{true:"rounded-full",false:"hover:bg-[--subtle]"}},defaultVariants:{collapsed:!1,isSidebar:!1}}),itemContent:(0,c.F)(["UI-VerticalMenu__itemContent","w-full flex items-center relative"],{variants:{size:{sm:"px-3 h-8 text-sm",md:"px-3 h-10 text-sm",lg:"px-3 h-12 text-base"},collapsed:{true:"justify-center",false:null},isSidebar:{true:"",false:null}},defaultVariants:{size:"md",collapsed:!1,isSidebar:!1}}),parentItem:(0,c.F)(["UI-VerticalMenu__parentItem","group/verticalMenu_parentItem","cursor-pointer w-full"]),itemChevron:(0,c.F)(["UI-VerticalMenu__itemChevron","size-4 absolute transition-transform group-data-[state=open]/verticalMenu_parentItem:rotate-90"],{variants:{size:{sm:"right-3",md:"right-3",lg:"right-3"},collapsed:{true:"top-1 left-1 size-3",false:null}},defaultVariants:{size:"md",collapsed:!1}}),itemIcon:(0,c.F)(["UI-VerticalMenu__itemIcon","flex-shrink-0 mr-3 transition","text-[--muted] text-xl","group-hover/verticalMenu_item:text-[--foreground]","group-data-[current=true]/verticalMenu_item:text-[--foreground]"],{variants:{size:{sm:"size-5",md:"size-6",lg:"size-7"},collapsed:{true:"mr-0",false:null},isSidebar:{true:"group-hover/verticalMenu_item:scale-[1.05] group-hover/verticalMenu_item:-rotate-2",false:null}},defaultVariants:{size:"md",isSidebar:!1}}),subContent:(0,c.F)(["UI-VerticalMenu__subContent","border-b py-1"])},ss=u.createContext({}),sa=u.forwardRef((e,t)=>{let{children:s,size:a="md",collapsed:r,onItemSelect:n,itemClass:l,itemIconClass:o,parentItemClass:d,subContentClass:c,itemChevronClass:m,itemContentClass:h,itemTooltipProps:p,className:g,items:f,isSidebar:b,...v}=e,{onItemSelect:y,collapsed:j,isSidebar:w}=(0,u.useContext)(ss),N=r??j??!1,k=b??w??!1,S=e=>t=>{var s;null==n||n(e),null==y||y(e),null==(s=e.onClick)||s.call(e,t)},C=u.useCallback(e=>N?e.flyout?(0,i.jsx)(t8,{trigger:e.children,side:"right",align:"center",openDelay:120,closeDelay:120,className:"w-auto border-0 bg-transparent p-0 shadow-none",children:e.flyout}):(0,i.jsx)(t5,{trigger:e.children,side:"right",...p,children:e.name}):e.children,[N,p]),_=u.useCallback(e=>(0,i.jsx)(C,{name:e.name,flyout:e.flyout,children:(0,i.jsxs)("div",{"data-vertical-menu-item":e.name,className:x(st.itemContent({size:a,c
1ollapsed:N,isSidebar:k}),h),children:[e.iconType&&(0,i.jsx)(e.iconType,{className:x(st.itemIcon({size:a,collapsed:N,isSidebar:k}),o),"aria-hidden":"true","data-current":e.isCurrent}),!N&&(0,i.jsx)("span",{children:e.name}),e.addon]})}),[N,a,h,o,k]);return(0,i.jsx)("nav",{ref:t,className:x(st.root(),g),role:"navigation",...v,children:(0,i.jsx)(ss.Provider,{value:{onItemSelect:n,collapsed:r??!1,isSidebar:b??!1},children:f.map((e,t)=>(0,i.jsx)(u.Fragment,{children:e.subItems&&e.subItems.length>0?(0,i.jsxs)("div",{className:x("flex flex-col",k&&e.expanded&&"gap-1 rounded-3xl border border-[--border] bg-[--paper] p-1 shadow-sm"),children:[(0,i.jsx)("button",{className:x(st.item({collapsed:N,isSidebar:k}),l),"data-current":e.isCurrent,"data-name":e.id,onClick:S(e),"data-vertical-menu-item-button":e.name,children:(0,i.jsx)(_,{...e})}),(0,i.jsx)(t7.N,{initial:!1,children:e.expanded&&(0,i.jsx)(se.P.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"flex flex-col gap-1 overflow-hidden",children:e.subItems.map((e,t)=>(0,i.jsx)("button",{className:x(st.item({collapsed:N,isSidebar:k}),l),"data-current":e.isCurrent,"data-name":e.id,onClick:S(e),"data-vertical-menu-item-button":e.name,children:(0,i.jsx)(_,{...e})},e.name+t))},"subitems")})]}):e.subContent?(0,i.jsx)(tQ,{type:"multiple",children:(0,i.jsxs)(tX,{value:e.name,children:[(0,i.jsx)(t0,{children:(0,i.jsxs)("button",{className:x(st.item({collapsed:N,isSidebar:k}),l,st.parentItem(),d),"aria-current":e.isCurrent?"page":void 0,"data-current":e.isCurrent,"data-name":e.id,onClick:S(e),children:[(0,i.jsx)(_,{...e}),(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(st.itemChevron({size:a,collapsed:N}),m),children:(0,i.jsx)("polyline",{points:"9 18 15 12 9 6"})})]})}),(0,i.jsx)(t1,{className:x(st.subContent(),c),children:e.subContent})]})}):(0,i.jsx)("button",{className:x(st.item({collapsed:N,isSidebar:k}),l),"aria-current":e.isCurrent?"page":void 0,"data-current":e.isCurrent,"data-name":e.id,onClick:S(e),"data-vertical-menu-item-button":e.name,children:(0,i.jsx)(_,{...e})})},e.name+t))})})});function sr(e){let{header:t,items:s,belowItems:a,footerItems:r,footer:n,onItemSelect:l,onFooterItemSelect:o,className:d}=e,c=tq(),u=!c.isBelowBreakpoint;return(0,i.jsxs)(tH,{className:x("h-full flex flex-col justify-between w-full",!c.isBelowBreakpoint&&"bg-transparent",d),children:[(0,i.jsxs)("div",{children:[t,(0,i.jsx)(sa,{className:"px-4",collapsed:u,isSidebar:!0,itemClass:"relative",items:s,onItemSelect:e=>{null==l||l(e),c.setOpen(!1)}}),a]}),((null==r?void 0:r.length)||n)&&(0,i.jsxs)("div",{className:"p-4 gap-2 flex flex-col",children:[r&&r.length>0&&(0,i.jsx)(sa,{collapsed:u,isSidebar:!0,itemClass:"relative",items:r,onItemSelect:e=>{null==o||o(e),c.setOpen(!1)}}),n]})]})}sa.displayName="VerticalMenu";let sn={overlay:(0,c.F)(["UI-Modal__overlay","fixed inset-0 w-screen z-50 bg-black/80","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"]),content:(0,c.F)(["UI-Modal__content","z-50 grid relative w-full w-full shadow-xl border border-[rgb(255_255_255_/_5%)] max-w-lg gap-4 bg-[--paper] p-6 duration-200","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","sm:rounded-2xl"]),close:(0,c.F)(["UI-Modal__close","absolute right-4 top-4 !mt-0"]),header:(0,c.F)(["UI-Modal__header","flex flex-col space-y-1.5 min-w-0 text-center sm:text-left"]),footer:(0,c.F)(["UI-Modal__footer","flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"]),title:(0,c.F)(["UI-Modal__title","text-xl font-semibold leading-snug tracking-tight break-words"]),description:(0,c.F)(["UI-Modal__description","text-sm text-[--muted]"])};function sl(e){let{allowOutsideInteraction:t=!1,trigger:s,title:a,footer:r,description:n,children:l,closeButton:o,overlayClass:d,contentClass:c,closeClass:m,headerClass:h,footerClass:p,titleClass:g,descriptionClass:f,hideCloseButton:b,onOpenAutoFocus:v,onCloseAutoFocus:j,onEscapeKeyDown:w,onPointerDownCapture:N,onInteractOutside:k,...S}=e,C={},_={};for(let[e,t]of Object.entries(S))(e.startsWith("data-")?_:C)[e]=t;let A=u.useRef(!1);return(0,i.jsxs)(t$.bL,{modal:!t,...C,children:[s&&(0,i.jsx)(t$.l9,{asChild:!0,children:s}
1),(0,i.jsxs)(t$.ZL,{children:[(0,i.jsx)(si,{targetRef:A}),(0,i.jsx)(t$.hJ,{className:x(sn.overlay(),d),children:(0,i.jsx)("div",{className:x("overflow-y-auto absolute inset-0 grid place-items-center p-0 md:p-4",!1),children:(0,i.jsxs)(t$.UC,{..._,className:x(sn.content(),c),onOpenAutoFocus:v,onCloseAutoFocus:j,onEscapeKeyDown:w,onPointerDownCapture:N,onInteractOutside:e=>{if(tU(e.target))return void e.preventDefault();if(A.current){A.current=!1,e.preventDefault();return}null==k||k(e)},children:[a||n?(0,i.jsxs)("div",{className:x(sn.header(),h),children:[(0,i.jsx)(t$.hE,{className:x(sn.title(),g),children:a}),n&&(0,i.jsx)(t$.VY,{className:x(sn.description(),f),children:n})]}):(0,i.jsx)(tD.s6,{children:(0,i.jsx)(t$.hE,{children:"Dialog"})}),l,r&&(0,i.jsx)("div",{className:x(sn.footer(),p),children:r}),!b&&(0,i.jsx)(t$.bm,{className:x(sn.close(),m),asChild:!0,children:o||(0,i.jsx)(y,{})})]})})})]})]})}function si(e){let{targetRef:t}=e;return u.useEffect(()=>{let e=e=>{t.current=!!document.querySelector('[role="listbox"][data-state="open"],[role="menu"][data-state="open"],[data-radix-popper-content-wrapper]:not(:has([role="tooltip"]))')||e.target instanceof Element&&!!e.target.closest('[role="dialog"], [role="alertdialog"]')};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[t]),null}function so(e,t){let[s,a]=(0,u.useState)(e),r=()=>{if(!s){var e;a(!0),null==t||null==(e=t.onOpen)||e.call(t)}},n=()=>
1{if(s){var e;a(!1),null==t||null==(e=t.onClose)||e.call(t)}};return{isOpen:s,open:r,close:n,toggle:()=>{s?n():r()}}}function sd(e){return{...so(!1),...e}}sl.displayName="Modal";let sc=e=>{let{isOpen:t,close:s,onConfirm:a,title:r,description:n="Are you sure you want to continue?",actionText:l="Confirm",actionIntent:o="alert-subtle"}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(sl,{title:r,titleClass:"text-center",open:t,onOpenChange:s,children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)("p",{className:"text-center break-words",children:n}),(0,i.jsxs)("div",{className:"flex gap-2 justify-center items-center",children:[(0,i.jsx)(v,{intent:o,onClick:()=>{a(),s()},children:l}),(0,i.jsx)(v,{intent:"white",onClick:s,children:"Cancel"})]})]})})})};function su(){let e=(0,e3.jE)(),{data:t,isLoading:s}=(0,ty.I)(to),a=(0,u.useCallback)(async()=>{await e.invalidateQueries({queryKey:to.queryKey})},[e]),{mutateAsync:r}=(0,e5.n)({mutationFn:en,onSettled:()=>{e.removeQueries({queryKey:to.queryKey})}});return{user:t??null,loading:s,refresh:a,signOut:(0,u.useCallback)(async()=>{await r()},[r])}}var sm=s(28368);function sh(){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{"data-layout-header-background":!0,className:x("bg-[#000] opacity-50 bg-contain bg-center bg-repeat z-[-2] w-full h-[20rem] absolute bottom-0")}),(0,i.jsx)("div",{"data-layout-header-background-gradient":!0,className:"w-full absolute bottom-0 h-[8rem] bg-gradient-to-t from-[--background] to-transparent z-[-2]"})]})}let sp=[{id:"library",label:"Library",icon:sm.X6x},{id:"stats",label:"Stats",icon:sm.yWU},{id:"providers",label:"Providers",icon:sm.nmg}],sx=[{id:"sources",label:"Sources",icon:sm.Azn},{id:"publishing",label:"Publishing",icon:sm.K0Y},{id:"entries",label:"Entries",icon:sm.XfR}],sg=[{id:"active",label:"Active",icon:sm.U2S},{id:"history",label:"History",icon:sm.grf},{id:"bandwidth",label:"Bandwidth",icon:sm.yWU},{id:"bans",label:"Blocks",icon:sm.PLI}],sf=[{id:"pending",label:"Review queue",icon:sm.FOv},{id:"published",label:"Published",icon:sm.By1},{id:"blocks",label:"Blocks",icon:sm.PLI}],sb=[{label:"Overview",href:"/dashboard",icon:sm.fiy},{label:"Analytics",href:"/dashboard/analytics",icon:sm.yWU,desc:"User & request trends"},{label:"Logs",href:"/dashboard/logs",icon:sm.XfR,desc:"Live log stream"},{label:"System",href:"/dashboard/system",icon:sm.nmg,desc:"CPU, memory & lifecycle"},{label:"Users",href:"/dashboard/users",icon:sm.hTi,desc:"Accounts & their configs"},{label:"Tasks",href:"/dashboard/tasks",icon:sm.bZV,desc:"Scheduled & manual work"},{label:"Cache",href:"/dashboard/cache",icon:sm.Wwx,desc:"Cache stats & flush"},{label:"Streams",href:"/dashboard/streams",icon:sm.U2S,desc:"Active, history & bandwidth"},{label:"Usenet",href:"/dashboard/usenet",icon:sm.hQe,desc:"Library, providers & stats"},{label:"Blocklists",href:"/dashboard/blocklist",icon:sm.PLI,desc:"Sources, entries & publishing"},{label:"Community",href:"/dashboard/community",icon:sm.e7V,desc:"Shared formatters & templates"},{label:"Settings",href:"/dashboard/settings",icon:sm.nMM,desc:"Runtime configuration"}],sv={"/dashboard/streams":sg,"/dashboard/usenet":sp,"/dashboard/blocklist":sx,"/dashboard/community":sf};function sy(){let[e,t]=(0,u.useState)(!1),s=(0,u.useCallback)(()=>t(!0),[]),a=(0,u.useCallback)(()=>t(!1),[]),r=(0,u.useCallback)(()=>t(e=>!e),[]);return(0,u.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&("k"===e.key||"K"===e.key)&&(e.preventDefault(),t(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),{isOpen:e,open:s,close:a,toggle:r}}let sj=(0,u.createContext)({isOpen:!1,open:()=>{},close:()=>{},toggle:()=>{}});function sw(e){let{children:t}=e,s=sy();return(0,i.jsx)(sj.Provider,{value:s,children:t})}let sN=()=>(0,u.useContext)(sj);var sk=s(5838);let sS={root:(0,c.F)(["UI-Command__root","flex h-full w-full flex-col overflow-hidden rounded-[--radius-md] bg-[--paper] text-[--foreground]"]),inputContainer:(0,c.F)(["UI-Command__input","flex items-center px-3 py-2","cmdk-input-wrapper"]),inputIcon:(0,c.F)(["UI-Command__inputIcon","mr-2 h-5 w-5 shrink-0 opacity-50"]),list:(0,c.F)(["UI-Command__list","max-h-[300px] overflow-y-auto overflow-x-hidden"]),empty:(0,c.F)(["UI-Command__empty","py-6 text-center text-base text-[--muted]"]),group:(0,c.F)(["UI-Command__group","overflow-hidden p-1 text-[--foreground]","[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-sm [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-[--muted]"]),separator:(0,
1c.F)(["UI-Command__separator","-mx-1 h-px bg-[--border]"]),item:(0,c.F)(["UI-Command__item","relative flex cursor-default select-none items-center rounded-[--radius] px-2 py-1.5 text-base outline-none","aria-selected:bg-[--subtle] data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"]),itemIconContainer:(0,c.F)(["UI-Command__itemIconContainer","mr-2 text-base shrink-0 w-4"]),shortcut:(0,c.F)(["UI-Command__shortcut","ml-auto text-xs tracking-widest text-[--muted]"])},sC={content:(0,c.F)(["UI-CommandDialog__content","overflow-hidden p-0"]),command:(0,c.F)(["UI-CommandDialog__command","[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-[--muted]","[&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pb-2 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5","[&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-2 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-5"])},s_=u.createContext({}),sA=u.forwardRef((e,t)=>{let{className:s,inputContainerClass:a,inputIconClass:r,listClass:n,emptyClass:l,groupClass:o,separatorClass:d,itemClass:c,itemIconContainerClass:u,shortcutClass:m,loop:h=!0,...p}=e;return(0,i.jsx)(s_.Provider,{value:{inputContainerClass:a,inputIconClass:r,listClass:n,emptyClass:l,groupClass:o,separatorClass:d,itemClass:c,itemIconContainerClass:u,shortcutClass:m},children:(0,i.jsx)(sk.uB,{ref:t,className:x(sS.root(),s),loop:h,...p})})});sA.displayName=sk.uB.displayName;let sR=u.forwardRef((e,t)=>{let{className:s,inputContainerClass:a,inputIconClass:r,...n}=e,{inputContainerClass:l,inputIconClass:o}=u.useContext(s_);return(0,i.jsxs)("div",{className:x(sS.inputContainer(),l,a),"cmdk-input-wrapper":"",children:[(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(sS.inputIcon(),o,r),children:[(0,i.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,i.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,i.jsx)(sk.uB.Input,{ref:t,className:x(O.root({intent:"unstyled",size:"sm",isDisabled:n.disabled}),s),...n})]})});sR.displayName="CommandInput";let sT=u.forwardRef((e,t)=>{let{className:s,...a}=e,{listClass:r}=u.useContext(s_);return(0,i.jsx)(sk.uB.List,{ref:t,className:x(sS.list(),r,s),...a}
1)});sT.displayName="CommandList";let sI=u.forwardRef((e,t)=>{let{className:s,...a}=e,{emptyClass:r}=u.useContext(s_);return(0,i.jsx)(sk.uB.Empty,{ref:t,className:x(sS.empty(),r,s),...a})});sI.displayName="CommandEmpty";let sE=u.forwardRef((e,t)=>{let{className:s,...a}=e,{groupClass:r}=u.useContext(s_);return(0,i.jsx)(sk.uB.Group,{ref:t,className:x(sS.group(),r,s),...a})});sE.displayName="CommandGroup",u.forwardRef((e,t)=>{let{className:s,...a}=e,{separatorClass:r}=u.useContext(s_);return(0,i.jsx)(sk.uB.Separator,{ref:t,className:x(sS.separator(),r,s),...a})}).displayName="CommandSeparator";let sM=u.forwardRef((e,t)=>{let{className:s,itemIconContainerClass:a,leftIcon:r,children:n,...l}=e,{itemClass:o,itemIconContainerClass:d}=u.useContext(s_),c=u.useRef(null);u.useEffect(()=>{let e=c.current;if(!e)return;let t=new MutationObserver(t=>{t.forEach(t=>{"aria-selected"===t.attributeName&&"true"===e.getAttribute("aria-selected")&&e.scrollIntoView({block:"nearest"})})});return t.observe(e,{attributes:!0}),()=>t.disconnect()},[]);let m=u.useCallback(e=>{c.current=e,t&&"function"==typeof t&&t(e)},[t]);return(0,i.jsxs)(sk.uB.Item,{ref:m,className:x(sS.item(),o,s),...l,"data-cmdkvalue":l.id,children:[r&&(0,i.jsx)("span",{className:x(sS.itemIconContainer(),d,a),children:r}),n]})});sM.displayName="CommandItem";let sP=u.forwardRef((e,t)=>{let{className:s,...a}=e,{shortcutClass:r}=u.useContext(s_);return(0,i.jsx)("span",{ref:t,className:x(sS.shortcut(),r,s),...a}
1)});sP.displayName="CommandShortcut";let s$=e=>{let{children:t,commandClass:s,contentClass:a,commandProps:r,...n}=e;return(0,i.jsx)(sl,{...n,contentClass:x(sC.content(),a),children:(0,i.jsx)(sA,{shouldFilter:!1,className:x(sC.command(),s),...r,children:t})})};s$.displayName="CommandDialog";let sD=u.createContext(void 0),sL="aiostreams-mode",sO="aiostreams-first-time";function sU(e){let{children:t}=e,[s,a]=u.useState(()=>"u">typeof window&&localStorage.getItem(sL)||"noob"),[r,n]=u.useState(()=>!("u">typeof window)||null===localStorage.getItem(sO)),l=u.useCallback(e=>{a(e),"u">typeof window&&localStorage.setItem(sL,e)},[]),o=u.useCallback(e=>{n(e),"u">typeof window&&!e&&localStorage.setItem(sO,"false")},[]);return(0,i.jsx)(sD.Provider,{value:{mode:s,setMode:l,isFirstTime:r,setIsFirstTime:o},children:t})}function sF(){let e=u.useContext(sD);if(void 0===e)throw Error("useMode must be used within a ModeProvider");return e}let sz={excludedResolutions:{label:"Excluded Resolutions",group:"filters",type:"list",menu:"filters",subTab:"resolution"},includedResolutions:{label:"Included Resolutions",group:"filters",type:"list",menu:"filters",subTab:"resolution"},requiredResolutions:{label:"Required Resolutions",group:"filters",type:"list",menu:"filters",subTab:"resolution"},preferredResolutions:{label:"Preferred Resolutions",group:"filters",type:"list",menu:"filters",subTab:"resolution"},excludedQualities:{label:"Excluded Qualities",group:"filters",type:"list",menu:"filters",subTab:"qual
1ity"},includedQualities:{label:"Included Qualities",group:"filters",type:"list",menu:"filters",subTab:"quality"},requiredQualities:{label:"Required Qualities",group:"filters",type:"list",menu:"filters",subTab:"quality"},preferredQualities:{label:"Preferred Qualities",group:"filters",type:"list",menu:"filters",subTab:"quality"},excludedLanguages:{label:"Excluded Languages",group:"filters",type:"list",menu:"filters",subTab:"language"},includedLanguages:{label:"Included Languages",group:"filters",type:"list",menu:"filters",subTab:"language"},requiredLanguages:{label:"Required Languages",group:"filters",type:"list",menu:"filters",subTab:"language"},preferredLanguages:{label:"Preferred Languages",group:"filters",type:"list",menu:"filters",subTab:"language"},excludedSubtitles:{label:"Excluded Subtitles",group:"filters",type:"list",menu:"filters",subTab:"subtitle",keywords:["subs"]},includedSubtitles:{label:"Included Subtitles",group:"filters",type:"list",menu:"filters",subTab:"subtitle",keywords:["subs"]},requiredSubtitles:{label:"Required Subtitles",group:"filters",type:"list",menu:"filters",subTab:"subtitle",keywords:["subs"]},preferredSubtitles:{label:"Preferred Subtitles",group:"filters",type:"list",menu:"filters",subTab:"subtitle",keywords:["subs"]},excludedVisualTags:{label:"Excluded Visual Tags",group:"filters",type:"list",menu:"filters",subTab:"visual-tag",keywords:["hdr","dolby vision","dv"]},includedVisualTags:{label:"Included Visual Tags",group:"filters",type:"list",menu:"filters",subTab:"visual-tag",keywords:["hdr","dolby vision","dv"]},requiredVisualTags:{label:"Required Visual Tags",group:"filters",type:"list",menu:"filters",subTab:"visual-tag",keywords:["hdr","dolby vision","dv"]},preferredVisualTags:{label:"Preferred Visual Tags",group:"filters",type:"list",menu:"filters",subTab:"visual-tag",keywords:["hdr","dolby vision","dv"]},excludedAudioTags:{label:"Excluded Audio Tags",group:"filters",type:"list",menu:"filters",subTab:"audio-tag",keywords:["atmos","dts","truehd"]},includedAudioTags:{label:"Included Audio Tags",group:"filters",type:"list",menu:"filters",subTab:"audio-tag",keywords:["atmos","dts","truehd"]},requiredAudioTags:{label:"Required Audio Tags",group:"filters",type:"list",menu:"filters",subTab:"audio-tag",keywords:["atmos","dts","truehd"]},preferredAudioTags:{label:"Preferred Audio Tags",group:"filters",type:"list",menu:"filters",subTab:"audio-tag",keywords:["atmos","dts","truehd"]},excludedAudioChannels:{label:"Excluded Audio Channels",group:"filters",type:"list",menu:"filters",subTab:"audio-channel"},includedAudioChannels:{label:"Included Audio Channels",group:"filters",type:"list",menu:"filters",subTab:"audio-channel"},requiredAudioChannels:{label:"Required Audio Channels",group:"filters",type:"list",menu:"filters",subTab:"audio-channel"},preferredAudioChannels:{label:"Preferred Audio Channels",group:"filters",type:"list",menu:"filters",subTab:"audio-channel"},excludedStreamTypes:{label:"Excluded Stream Types",group:"filters",type:"list",menu:"filters",subTab:"stream-type"},includedStreamTypes:{label:"Included Stream Types",group:"filters",type:"list",menu:"filters",subTab:"stream-type"},requiredStreamTypes:{label:"Required Stream Types",group:"filters",type:"list",menu:"filters",subTab:"stream-type"},preferredStreamTypes:{label:"Preferred Stream Types",group:"filters",type:"list",menu:"filters",subTab:"stream-type"},excludedEncodes:{label:"Excluded Encodes",group:"filters",type:"list",menu:"filters",subTab:"encode"},includedEncodes:{label:"Included Encodes",group:"filters",type:"list",menu:"filters",subTab:"encode"},requiredEncodes:{label:"Required Encodes",group:"filters",type:"list",menu:"filters",subTab:"encode"},preferredEncodes:{label:"Preferred Encodes",group:"filters",type:"list",menu:"filters",subTab:"encode"},excludedKeywords:{label:"Excluded Keywords",group:"filters",type:"list",menu:"filters",subTab:"keyword"},includedKeywords:{label:"Included Keywords",group:"filters",type:"list",menu:"filters",subTab:"keyword"},requiredKeywords:{label:"Required Keywords",group:"filters",type:"list",menu:"filters",subTab:"keyword"},preferredKeywords:{label:"Preferred Keywords",group:"filters",type:"list",menu:"filters",subTab:"keyword"},excludedReleaseGroups:{label:"Excluded Release Groups",group:"filters",type:"list",menu:"filters",subTab:"release-group"},includedReleaseGroups:{label:"Included Release Groups",group:"filters",type:"list",menu:"filters",subTab:"release-group"},requiredReleaseGroups:{label:"Required Release Groups",group:"filters",type:"list",menu:"filters",subTab:"release-group"},preferredReleaseGroups:{label:"Preferred Release Groups",group:"filters",type:"list",menu:"filters",subTab:"release-group"},excludedRegexPatterns:{label:"Excluded Regex Patterns",group:"filters",type:"list",menu:"filters",subTab:"regex"},includedRegexPatterns:{label:"Included Regex Patterns",group:"filters",type:"list",menu:"filters",subTab:"regex"},requiredRegexPatterns:{label:"Required Regex Patterns",group:"filters",type:"list",menu:"filters",subTab:"regex"},preferredRegexPatterns:{label:"Preferred Regex Patterns",group:"filters",type:"list",identityKey:"pattern",menu:"filters",subTab:"regex"},rankedRegexPatterns:{label:"Ranked Regex Patterns",group:"filters",type:"list",identityKey:"pattern",menu:"filters",subTab:"regex"},regexOverrides:{label:"Regex Overrides",group:"filters",type:"list",identityKey:"pattern",menu:"filters",subTab:"regex"},syncedExcludedRegexUrls:{label:"Synced Excluded Regex URLs",group:"filters",type:"list",menu:"filters",subTab:"regex"},syncedIncludedRegexUrls:{label:"Synced Included Regex URLs",group:"filters",type:"list",menu:"filters",subTab:"regex"},syncedRequiredRegexUrls:{label:"Synced Required Regex URLs",group:"filters",type:"list",menu:"filters",subTab:"regex"},syncedPreferredRegexUrls:{label:"Synced Preferred Regex URLs",group:"filters",type:"list",menu:"filters",subTab:"regex"},syncedRankedRegexUrls:{label:"Synced Ranked Regex URLs",group:"filters",type:"list",menu:"filters",subTab:"regex"},excludedStreamExpressions:{label:"Excluded Stream Expressions",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression",keywords:["sel"]},includedStreamExpressions:{label:"Included Stream Expressions",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression",keywords:["sel"]},requiredStreamExpressions:{label:"Required Stream Expressions",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression",keywords:["sel"]},preferredStreamExpressions:{label:"Preferred Stream Expressions",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression",keywords:["sel"]},rankedStreamExpressions:{label:"Ranked Stream Expressions",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression",keywords:["sel"]},selOverrides:{label:"Stream Expression Overrides",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression"},syncedExcludedStreamExpressionUrls:{label:"Synced Excluded Expression URLs",group:"filters",type:"list",menu:"filters",subTab:"stream-expression"},syncedIncludedStreamExpressionUrls:{label:"Synced Included Expression URLs",group:"filters",type:"list",menu:"filters",subTab:"stream-expression"},syncedRequiredStreamExpressionUrls:{label:"Synced Required Expression URLs",group:"filters",type:"list",menu:"filters",subTab:"stream-expression"},syncedPreferredStreamExpressionUrls:{label:"Synced Preferred Expression URLs",group:"filters",type:"list",menu:"filters",subTab:"stream-expression"},syncedRankedStreamExpressionUrls:{label:"Synced Ranked Expression URLs",group:"filters",type:"list",menu:"filters",subTab:"stream-expression"},enableSeadex:{label:"SeaDex",group:"filters",type:"scalar",menu:"filters",subTab:"miscellaneous",keywords:["anime","releases.moe"]},remuxDb:{label:"RemuxDB",group:"filters",type:"scalar",menu:"filters",subTab:"miscellaneous",keywords:["probe","media info"]},excludeSeasonPacks:{label:"Exclude Season Packs",group:"filters",type:"scalar",menu:"filters",subTab:"miscellaneous",
1ignoreForCommandPalette:!0},excludeCached:{label:"Exclude Cached Streams",group:"filters",type:"scalar",menu:"filters",subTab:"cache"},excludeCachedFromAddons:{label:"Exclude Cached â From Addons",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeCached"},excludeCachedFromServices:{label:"Exclude Cached â From Services",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeCached"},excludeCachedFromStreamTypes:{label:"Exclude Cached â Stream Types",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeCached"},excludeCachedMode:{label:"Exclude Cached Mode",group:"filters",type:"scalar",menu:"filters",subTab:"cache",sectionId:"excludeCached"},excludeUncached:{label:"Exclude Uncached Streams",group:"filters",type:"scalar",menu:"filters",subTab:"cache"},excludeUncachedFromAddons:{label:"Exclude Uncached â From Addons",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeUncached"},excludeUncachedFromServices:{label:"Exclude Uncached â From Services",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeUncached"},excludeUncachedFromStreamTypes:{label:"Exclude Uncached â Stream Types",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeUncached"},excludeUncachedMode:{label:"Exclude Uncached Mode",group:"filters",type:"scalar",menu:"filters",subTab:"cache",sectionId:"excludeUncached"},excludeSeederRange:{label:"Exclude Seeder Range",group:"filters",type:"scalar",menu:"filters",subTab:"seeders"},includeSeederRange:{label:"Include Seeder Range",group:"filters",type:"scalar",menu:"filters",subTab:"seeders"},requiredSeederRange:{label:"Required Seeder Range",group:"filters",type:"scalar",menu:"filters",subTab:"seeders"},seederRangeTypes:{label:"Seeder Range Types",group:"filters",type:"list",menu:"filters",subTab:"seeders"},excludeAgeRange:{label:"Exclude Age Range",group:"filters",type:"scalar",menu:"filters",subTab:"age"},includeAgeRange:{label:"Include Age Range",group:"filters",type:"scalar",menu:"filters",subTab:"age"},requiredAgeRange:{label:"Required Age Range",group:"filters",type:"scalar",menu:"filters",subTab:"age"},ageRangeTypes:{label:"Age Range Types",group:"filters",type:"list",menu:"filters",subTab:"age"},digitalReleaseFilter:{label:"Digital Release Filter",group:"filters",type:"scalar",menu:"filters",subTab:"miscellaneous"},size:{label:"Size Filter",group:"filters",type:"scalar",menu:"filters",subTab:"size"},bitrate:{label:"Bitrate Filter",group:"filters",type:"scalar",menu:"filters",subTab:"bitrate"},titleMatching:{label:"Title Matching",group:"filters",type:"scalar",menu:"filters",subTab:"matching"},yearMatching:{label:"Year Matching",group:"filters",type:"scalar",menu:"filters",subTab:"matching"},seasonEpisodeMatching:{label:"Season/Episode Matching",group:"filters",type:"scalar",menu:"filters",subTab:"matching"},episodeTitleMatching:{label:"Episode Title Matching",group:"filters",type:"scalar",menu:"filters",subTab:"matching"},languageInference:{label:"Language Inference",group:"filters",type:"scalar",menu:"filters",subTab:"matching"},sortCriteria:{label:"Sort Criteria",group:"sorting",type:"scalar",menu:"sorting"},deduplicator:{label:"Deduplicator",group:"sorting",type:"scalar",menu:"filters",subTab:"deduplicator"},resultLimits:{label:"Result Limits",group:"sorting",type:"scalar",menu:"filters",subTab:"limit"},formatter:{label:"Formatter",group:"formatter",type:"scalar",menu:"formatter"},proxy:{label:"Proxy",group:"proxy",type:"scalar",menu:"proxy"},tmdbApiKey:{label:"TMDB API Key",group:"metadata",type:"scalar",menu:"services",subTab:"metadata",sectionId:"tmdb"},tmdbAccessToken:{label:"TMDB Access Token",group:"metadata",type:"scalar",menu:"services",subTab:"metadata",sectionId:"tmdb"},tvdbApiKey:{label:"TVDB API Key",group:"metadata",type:"scalar",menu:"services",subTab:"metadata"},pmdbApiKey:{label:"PublicMetaDB API Key",group:"metadata",type:"scalar",menu:"save-install",sectionId:"jellyfin",keywords:["pmdb","publicmetadb","skip intro","segments"]},rpdbApiKey:{label:"RPDB API Key",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},topPosterApiKey:{label:"TopPoster API Key",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},aioratingsApiKey:{label:"AIOratings API Key",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},aioratingsProfileId:{label:"AIOratings Profile ID",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},openposterdbApiKey:{label:"OpenPosterDB API Key",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},openposterdbUrl:{label:"OpenPosterDB URL",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},openposterdbParameters:{label:"OpenPosterDB Custom Parameters",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},posterService:{label:"Poster Service",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},usePosterRedirectApi:{label:"Use Poster Redirect API",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},usePosterServiceForMeta:{label:"Use Poster Service for Meta",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},autoPlay:{label:"Auto Play",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"playback"},areYouStillThere:{label:"Are You Still There?",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"playback"},statistics:{label:"Statistics",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"display"},hideErrors:{label:"Hide Errors",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"display"},hideErrorsForResources:{label:"Hide Errors for Resources",group:"misc",type:"list",menu:"miscellaneous",subTab:"display",sectionId:"hideErrors"},externalDownloads:{label:"External Downloads",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"display"},preloadStreams:{label:"Preload Streams",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"background"},precacheSelector:{label:"Precache Selector",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"background"},precacheSingleStream:{label:"Precache Single Stream",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"background"},dynamicAddonFetching:{label:"Dynamic Addon Fetching",group:"misc",type:"scalar",menu:"addons",subTab:"addons",sectionId:"fetchStrategy",keywords:["exit condition","dynamic fetching","fetch strategy"]},addonCategoryColors:{label:"Addon Category Colors",group:"misc",type:"scalar",menu:"addons",subTab:"addons"},catalogModifications:{label:"Catalog Modifications",group:"misc",type:"scalar",menu:"addons",subTab:"catalogs"},newCatalogsDisabled:{label:"New Catalogs Disabled",group:"misc",type:"scalar",menu:"addons",subTab:"catalogs"},upstreamCatalogOrder:{label:"Upstream Catalog Order",group:"misc",type:"scalar",menu:"addons",subTab:"catalogs"},mergedCatalogs:{label:"Merged Catalogs",group:"misc",type:"scalar",menu:"addons",subTab:"catalogs"},failover:{label:"Failover",group:"misc",type:"scalar",menu:"services",subTab:"builtin"},serviceWrap:{label:"Service Wrap",group:"misc",type:"scalar",menu:"services",subTab:"builtin"},cacheAndPlay:{label:"Cache and Play",group:"misc",type:"scalar",menu:"services",subTab:"builtin"},jellyfin:{label:"Jellyfin",group:"misc",type:"scalar",menu:"save-install",keywords:["jellyfin","swiftfin","streamyfin","findroid","infuse","kodi"]},autoRemoveDownloads:{label:"Auto Remove Downloads",group:"misc",type:"scalar",menu:"services",subTab:"builtin"},checkOwned:{label:"Check Owned",group:"misc",type:"scalar",menu:"services",subTab:"builtin"},accessKey:{label:"Config Access Key",group:"misc",type:"scalar",menu:"save-install"},showChanges:{label:"Show Changes",group:"misc",type:"scalar",menu:"save-install"},manifestNotice:{label:"Manifest Change Notices",group:"misc",type:"scalar",menu:"save-install",keywords:["reinstall","notice","diff"]}
1,linkedAccounts:{label:"Linked Accounts",group:"misc",type:"scalar",menu:"save-install",keywords:["sync","stremio","aiomanager","push"]},addonName:{label:"Addon Name",group:"branding",type:"scalar",menu:"about",keywords:["branding"]},addonLogo:{label:"Addon Logo",group:"branding",type:"scalar",menu:"about",keywords:["branding"]},addonBackground:{label:"Addon Background",group:"branding",type:"scalar",menu:"about",keywords:["branding"]},addonDescription:{label:"Addon Description",group:"branding",type:"scalar",menu:"about",keywords:["branding"]},presets:{label:"Addons",group:"misc",type:"list",identityKey:"instanceId",menu:"addons",subTab:"addons",keywords:["addons","presets"],ignoreForParentConfig:!0},services:{label:"Services",group:"misc",type:"list",identityKey:"id",menu:"services",subTab:"services",ignoreForParentConfig:!0},parentConfig:{label:"Parent Config",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"parent",sectionId:"parentConfig",keywords:["inherit","link","parent"],ignoreForParentConfig:!0},variants:{label:"Variants",group:"misc",type:"list",identityKey:"id",menu:"miscellaneous",subTab:"variants",sectionId:"variants",keywords:["variant","sub-profile","cel","config expression","override"],ignoreForParentConfig:!0},groups:{label:"Groups",group:"misc",type:"scalar",menu:"addons",subTab:"addons",keywords:["groupings"],ignoreForParentConfig:!0,sectionId:"fetchStrategy"},healthChecks:{label:"Health Checks",group:"misc",type:"list",identityKey:"id",menu:"miscellaneous",subTab:"health-checks",sectionId:"healthChecks",keywords:["health","uptime","status","variant","conditional"],ignoreForParentConfig:!0}};s(8963).Buffer.from("WC1BSU9TdHJlYW1zLUludGVybmFsLVNlY3JldA==","base64").toString("utf8");let sV="count(cached(streams)) == 0 ? uncached(streams) : []",sq=["usenet"],sB=["languages","subtitles","library","seadex","sizes","idMatched"],sK="gdrive",sH="lightgdrive",sW="minimalisticgdrive",sG="torrentio",sY="torbox",sJ="prism",sZ="tamtaro",sQ="custom",sX={[sK]:{id:sK,name:"Google Drive",description:"Uses the formatting from the Stremio GDrive addon"},[sJ]:{id:sJ,name:"Prism",description:"An aesthetic formatter with every detail within 5 lines."},[sZ]:{id:sZ,name:"Tamtaro",description:"From Tamtaro's setup. Smartly detects status for cached (â¡/â³), proxied (â/â), library (âï¸/â), season packs (â/â) and HDR/DV (â¦/â§). The last line in sá´á´ÊÊ á´á´á´s displays your preferred language options, Usenet's health (â É´á´¢Ê), SeaDex (á´Êá´/Êá´sá´ Êá´Êá´á´sá´), networks, special editions and attributes via ranked stream expressions."},[sH]:{id:sH,name:"Light Google Drive",description:"A lighter version of the GDrive formatter, focused on asthetics"},[sW]:{id:sW,name:"Minimalistic",description:"A minimalistic formatter which shows only the bare minimum"},[sG]:{id:sG,name:"Torrentio",description:"Uses the formatting from the Torrentio addon"},[sY]:{id:sY,name:"Torbox",description:"Uses the formatting from the TorBox Stremio addon"},[sQ]:{id:sQ,name:"Custom",description:"Define your own formatter"}},s0="realdebrid",s1="debridlink",s2="premiumize",s3="alldebrid",s5="torbox",s4="easydebrid",s6="debrider",s9="putio",s8="pikpak",s7="offcloud",ae="seedr",at="easynews",as="nzbdav",aa="altmount",ar="stremio_nntp",an="stremthru_newz",al="aiostreams",ai="torrin",ao=[s0,s1,s2,s3,s5,s4,s6,s9,s8,s7,ae,at,as,aa,ar,an,al,ai],ad=[s0,s1,s2,s3,s5,s4,s6,s8,s7,as,aa,ar,at,an,al,ai],ac="mediaflow",au="stremthru",am="builtin",ah={[am]:{id:am,name:"Builtin Proxy",description:"A proxy service that is built into the core of AIOStreams",credentialDescription:"A valid username:password pair for this AIOStreams instance, defined in the `AIOSTREAMS_AUTH` environment variable."},[au]:{id:au,name:"StremThru",description:"[StremThru](https://github.com/MunifTanjim/stremthru) is a feature packed companion to Stremio which also offers a HTTP proxy, written in Go.",credentialDescription:"A valid username:password pair for your StremThru instance, defined in the `STREMTHRU_PROXY_AUTH` environment variable."},[ac]:{id:ac,name:"MediaFlow Proxy",description:"[MediaFlow Proxy](https://github.com/mhdzumair/mediaflow-proxy) is a high performance proxy server which supports HTTP, HLS, and more.",credentialDescription:"The value of your MediaFlow Proxy instance `API_PASSWORD` environment variable."}},ap={[s0]:{id:s0,name:"Real-Debrid",shortName:"RD",knownNames:["RD","Real Debrid","RealDebrid","Real-Debrid"],signUpText:"Don't have an account? [Sign up here](https://real-debrid.com/?id=9483829)",credentials:[{id:"apiKey",name:"API Key",description:"The API key for the Real-Debrid service. Obtain it from [here](https://real-debrid.com/apitoken)",type:"password",required:!0}]},[s3]:{id:s3,name:"AllDebrid",shortName:"AD",knownNames:["AD","All Debrid","AllDebrid","All-Debrid"],signUpText:"Don't have an account? [Sign up here](https://alldebrid.com/?uid=3n8qa&lang=en)",credentials:[{id:"apiKey",name:"API Key",description:"The API key for the All-Debrid service. Create one [here](https://alldebrid.com/apikeys)",type:"password",required:!0}]},[s2]:{id:s2,name:"Premiumize",shortName:"PM",knownNames:["PM","Premiumize"],signUpText:"Don't have an account? [Sign up here](https://www.premiumize.me/register)",credentials:[{id:"apiKey",name:"API Key",description:"Your Premiumize API key. Obtain it from [here](https://www.premiumize.me/account)",type:"password",required:!0}]},[s1]:{id:s1,name:"Debrid-Link",shortName:"DL",knownNames:["DL","Debrid Link","DebridLink","Debrid-Link"],signUpText:"Don't have an account? [Sign up here](https://debrid-link.com/id/EY0JO)",credentials:[{id:"apiKey",name:"API Key",description:"Your Debrid-Link API key. Obtain it from [here](https://debrid-link.com/webapp/apikey)",type:"password",required:!0}]},[s5]:{id:s5,name:"TorBox",shortName:"TB",knownNames:["TB","TorBox","Torbox","TRB"],signUpText:"Don't have an account? [Sign up here](https://torbox.app/subscription?referral=9ca21adb-dbcb-4fb0-9195-412a5f3519bc) or use my referral code `9ca21adb-dbcb-4fb0-9195-412a5f3519bc`.",credentials:[{id:"apiKey",name:"API Key",description:"Your Torbox API key. Obtain it from [here](https://torbox.app/settings)",type:"password",required:!0}]},[ar]:{id:ar,name:"Stremio NNTP",shortName:"SN",knownNames:["SN","Stremio NNTP","StremioNntp","Stremio-NNTP"],signUpText:"Stream usenet directly from your provider via Stremio's NNTP client.",credentials:[{id:"note",name:"",description:"This is a new Stremio feature that allows Stremio to connect directly to Usenet NNTP servers you provide. It is currently [only supported on Stremio V5 Desktop](https://blog.stremio.com/stremio-new-stream-sources-usenet-rar-zip-ftp-and-more/).",type:"alert",intent:"warning"},{id:"servers",name:"NNTP Servers",description:"Provide your Usenet NNTP server addresses",type:"custom-nntp-servers",required:!0}]},[as]:{id:as,name:"NzbDAV",shortName:"ND",knownNames:["ND"],signUpText:"Stream usenet directly from your provider via Nzb DAV.",credentials:[{id:"note",name:"Configuration Help",description:`**URL:** Use internal URL for local setups (e.g., http://nzbdav:3000), otherwise use a public URL. 2 3**Public URL:** Only needed if URL is local but streams need to be publicly accessible. Leave blank if URL is public or using a proxy. 4 5**Security Note:** WebDAV credentials are exposed in stream URLs unless proxied. To proxy, provide the Auth Token below (built-in proxy only). 6 7For detailed setup instructions, see the [Usenet guide](https://docs.aiostreams.viren070.me/guides/usenet#nzbdav-altmount-and-stremthru-newz).`,type:"alert",intent:"info",required:!1},{id:"url",name:"NzbDAV URL",description:"The base URL of your NZB DAV instance. E.g., http://nzbdav:3000",type:"string",required:!0},{id:"publicUrl",name:"Public NzbDAV URL (Optional)",description:"The public URL of your NzbDAV instance. Optional, see note above for details.",type:"string",required:!1},{id:"apiKey",name:"NzbDAV API Key",description:"Your Nzb DAV API Key, found in the SABnzbd section in settings.",type:"password",required:!0},{id:"username",name:"NzbDAV WebDAV Username",description:"Your Nzb DAV WebDAV Username. Found in the WebDAV section in settings.",type:"string",required:!1},{id:"password",name:"NzbDAV WebDAV Password",description:"Your NzbDAV WebDAV Password. Found in the WebDAV section in settings.",type:"password",required:!1}
7,{id:"aiostreamsAuth",name:"AIOStreams Auth Token (Optional)",description:"If you would like to proxy your NzbDAV streams, you will need to provide a username:password pair for your AIOStreams instance, defined in the `AIOSTREAMS_AUTH` environment variable. **Other proxies will not work and you must define it here only**",type:"password",required:!1}]},[al]:{id:al,name:"AIOStreams",shortName:"AIO",knownNames:["AIO","AIO Usenet","NZB","Usenet","Native Usenet"],signUpText:"Stream directly from your own NNTP providers via the built-in usenet engine. Providers are configured globally by the administrator.",credentials:[{id:"note",name:"Configuration Help",description:"NNTP providers for this engine are configured **globally by the administrator** (Settings â Usenet), not here.\n\nTo authorise streaming through the built-in engine, provide an AIOStreams Auth Token below: a `username:password` pair defined in the `AIOSTREAMS_AUTH` environment variable.",type:"alert",intent:"info",required:!1},{id:"aiostreamsAuth",name:"AIOStreams Auth Token",description:"A `username:password` pair for your AIOStreams instance, defined in the `AIOSTREAMS_AUTH` environment variable. Required to authorise streaming through the built-in usenet engine.",type:"password",required:!0}]},[aa]:{id:aa,name:"AltMount",shortName:"AM",knownNames:["AM"],signUpText:"Stream usenet directly from your provider via AltMount.",credentials:[{id:"note",name:"Configuration Help",description:`**URL:** Use internal URL for local setups (e.g., http://altmount:8000), otherwise use a public URL. 8 9**Public URL:** Only needed if URL is local but streams need to be publicly accessible. Leave blank if URL is public or using a proxy. 10 11**Security Note:** WebDAV credentials are exposed in stream URLs unless proxied. To proxy, provide the Auth Token below (built-in proxy only). 12 13For detailed setup instructions, see the [Usenet guide](https://docs.aiostreams.viren070.me/guides/usenet#nzbdav-altmount-and-stremthru-newz).`,type:"alert",intent:"info",required:!1},{id:"url",name:"Altmount URL",description:"The base URL of your AltMount instance used for requests. e.g., http://altmount:8080",type:"string",required:!0},{id:"publicUrl",name:"Public Altmount URL",description:"The public URL of your AltMount instance. Optional, see note above for details.",type:"string",required:!1},{id:"apiKey",name:"AltMount API Key",description:"Your AltMount API Key, found at `Configuration -> System` in the AltMount Web UI.",type:"password",required:!0},{id:"username",name:"AltMount WebDAV Username",description:"Your AltMount WebDAV Username, found at `Configuration -> WebDAV Server` in the AltMount Web UI.",type:"string",required:!0},{id:"password",name:"AltMount WebDAV Password",description:"Your AltMount WebDAV Password, found at `Configuration -> WebDAV Server` in the AltMount Web UI.",type:"password",required:!0},{id:"aiostreamsAuth",name:"AIOStreams Auth Token (Optional)",description:"If you would like to proxy your AltMount streams, you will need to provide a username:password pair for your AIOStreams instance, defined in the `AIOSTREAMS_AUTH` environment variable. **Other proxies will not work and you must define it here only**",type:"password",required:!1}]},[s7]:{id:s7,name:"Offcloud",shortName:"OC",knownNames:["OC","Offcloud"],signUpText:"Don't have an account? [Sign up here](https://offcloud.com/?=06202a3d)",credentials:[{id:"apiKey",name:"API Key",description:"Your Offcloud API key. Obtain it from [here](https://offcloud.com/#/account) on the `API Key` tab. ",type:"password",required:!0},{id:"email",name:"Email",description:"Your Offcloud email. (These credentials are necessary for some addons)",type:"password",required:!0},{id:"password",name:"Password",description:"Your Offcloud password. (These credentials are necessary for some addons)",type:"password",required:!0}]},[s9]:{id:s9,name:"put.io",shortName:"P.IO",knownNames:["PO","put.io","putio"],signUpText:"Don't have an account? [Sign up here](https://put.io/)",credentials:[{id:"clientId",name:"Client ID",description:"Your put.io Client ID. Obtain it from [here](https://app.put.io/oauth)",type:"password",required:!0},{id:"token",name:"Token",description:"Your put.io Token. Obtain it from [here](https://app.put.io/oauth)",type:"password",required:!0}]}
13,[at]:{id:at,name:"Easynews",shortName:"EN",knownNames:["EN","Easynews"],signUpText:"Don't have an account? [Sign up here](https://www.easynews.com/)",credentials:[{id:"username",name:"Username",description:"Your Easynews username",type:"password",required:!0},{id:"password",name:"Password",description:"Your Easynews password",type:"password",required:!0}]},[s4]:{id:s4,name:"EasyDebrid",shortName:"ED",knownNames:["ED","EasyDebrid"],signUpText:"Don't have an account? [Sign up here](https://paradise-cloud.com/products/easydebrid)",credentials:[{id:"apiKey",name:"API Key",description:"Your EasyDebrid API key. Obtain it from [here](https://paradise-cloud.com/dashboard/)",type:"password",required:!0}]},[s6]:{id:s6,name:"Debrider",shortName:"DR",knownNames:["DBD","DR","DER","DB","Debrider"],signUpText:"Don't have an account? [Sign up here](https://debrider.app/)",credentials:[{id:"apiKey",name:"API Key",description:"Your Debrider API key. Obtain it from [here](https://debrider.app/dashboard/account)",type:"password",required:!0}]},[s8]:{id:s8,name:"PikPak",shortName:"PKP",knownNames:["PP","PikPak","PKP"],signUpText:"Don't have an account? [Sign up here](https://mypikpak.com/drive/activity/invited?invitation-code=72822731)",credentials:[{id:"email",name:"Email",description:"Your PikPak email address",type:"password",required:!0},{id:"password",name:"Password",description:"Your PikPak password",type:"password",required:!0}]},[ae]:{id:ae,name:"Seedr",shortName:"SDR",knownNames:["SR","Seedr","SDR"],signUpText:"Don't have an account? [Sign up here](https://www.seedr.cc/?r=6542079)",credentials:[{id:"encodedToken",name:"Encoded Token",description:"Please authorise at MediaFusion and copy the token into here.",type:"password",required:!0}]},[an]:{id:an,name:"StremThru Newz",shortName:"ST",knownNames:["ST","StremThru Newz","StremThruNewz"],signUpText:"Stream usenet content via [StremThru](https://github.com/MunifTanjim/stremthru).",credentials:[{id:"url",name:"StremThru URL",description:"The base URL of your StremThru instance used for requests e.g. http://stremthru:8080 or https://stremthru.mydomain.com",type:"string",required:!0},{id:"authToken",name:"Auth Token",description:"Your StremThru authentication token from `STREMTHRU_AUTH`",type:"password",required:!0},{id:"note",name:"Tip",description:"If you are self-hosting both StremThru and AIOStreams, consider using the internal URL of StremThru (e.g., http://stremthru:8080) to avoid potential network issues. Your playback URLs generated by StremThru will use the `STREMTHRU_BASE_URL` environment variable.",type:"alert",intent:"info"}]},[ai]:{id:ai,name:"Torrin",shortName:"TR",knownNames:["TR","TI","TRN","Torrin"],signUpText:"Don't have an account? [Sign up here](https://torrin.app). Torrin is an open-source debrid service.",credentials:[{id:"apiKey",name:"API Key",description:"Your Torrin API key (begins with `tr_`). Obtain it from [torrin.app/app/settings](https://torrin.app/app/settings).",type:"password",required:!0}]}},ax={tmdbApiKey:{name:"TMDB API Key",type:"password",description:"Get your free API key from [here](https://www.themoviedb.org/settings/api). Make sure to copy the 32 character API Key and not the Read Access Token."},tmdbAccessToken:{name:"TMDB Access Token",type:"password",description:"Get your free access token from [here](https://www.themoviedb.org/settings/api). Make sure to copy the Read Access Token and not the 32 character API Key."},rpdbApiKey:{name:"RPDB API Key",type:"password",description:"Get your free API key from [here](https://ratingposterdb.com/api-key/) for posters with ratings."},topPosterApiKey:{name:"TOP Posters API Key",type:"password",description:"Get your free API key from [here](https://api.top-posters.com/user/register) for posters with ratings."},tvdbApiKey:{name:"TVDB API Key",type:"password",description:"Sign up for a free API Key at [TVDB](https://www.thetvdb.com/api-information) and then get it from your [dashboard](https://www.thetvdb.com/dashboard/account/apikeys)."},aioratingsApiKey:{name:"AIOratings API Key",type:"password",description:"Get your API key from [here](https://aioratings.com) for custom posters with ratings."},aioratingsProfileId:{name:"AIOratings Profile ID",type:"string",description:'Use "default" for the default profile, or enter a custom profile UUID from your AIOratings dashboard.'},openposterdbApiKey:{name:"OpenPosterDB API Key",type:"password",description:"Get your API key from [here](https://
13openposterdb.com) for posters with ratings. Use `t0-free-rpdb` for the free public instance."},openposterdbUrl:{name:"OpenPosterDB URL",type:"url",description:"Custom base URL for a self-hosted OpenPosterDB instance. Leave empty to use the default public instance."},openposterdbParameters:{name:"OpenPosterDB Custom Parameters",type:"string",description:"Optional query string (without the leading `?`) appended to every poster to customise it, e.g. `ratings_limit=2&badge_size=l&position=br`."},pmdbApiKey:{name:"PublicMetaDB API Key",type:"password",description:"Create one under Settings â API on [PublicMetaDB](https://publicmetadb.com). Used for skip intro and credits markers in the Jellyfin API."}},ag=["filename","infoHash","smartDetect"],af=["torrent_seeders","usenet_age"],ab=["size","bitrate","resolution","quality","encode","releaseGroup","edition","remastered","network","container","visualTags","audioTags","audioChannels","languages","repack","proper","country"],av=["size","resolution","quality","visualTags","audioTags","audioChannels","languages","encode","edition","network","remastered","releaseGroup"],ay=["service","cached","addon","proxied","resolution","quality","encode","audioTags","visualTags","languages","releaseGroup","type","infoHash","size"],aj=["resolution","quality","releaseGroup"],aw=["matchingFile","matchingIndex","firstFile"],aN={matchingFile:{name:"Matching File",description:"Auto-play the stream that matches the (customisable) attributes of the previous episode."},matchingIndex:{name:"Matching Index",description:"Auto-play the stream in the same position in the result list (assuming it exists) i.e. if you play the second stream, the second stream for the next episode will also be played."},firstFile:{name:"First File",description:"Always auto-play the first stream in the result list."}},ak=["2160p","1440p","1080p","720p","576p","480p","360p","240p","144p","Unknown"],aS=["BluRay REMUX","BluRay","WEB-DL","WEBRip","HDRip","HC HD-Rip","DVD REMUX","DVDRip","HDTV","CAM","TS","TC","SCR","Unknown"],aC=["HDR+DV","DV Only","HDR Only","HDR10+","HDR10","DV","HDR","HLG","10bit","3D","IMAX","AI","Upscaled","SDR","H-OU","H-SBS","Unknown"],a_=["Atmos","DD+","DD","DTS:X","DTS-HD MA","DTS-HD","DTS-ES","DTS","TrueHD","PCM","OPUS","FLAC","AAC","Unknown"],aA=["2.0","5.1","6.1","7.1","Unknown"],aR=["AV1","HEVC","AVC","VC-1","XviD","DivX","MPEG-4","Unknown"],aT=["quality","resolution","language","subtitle","visualTag","audioTag","audioChannel","streamType","encode","size","service","seeders","private","age","addon","regexPatterns","cached","library","keyword","streamExpressionMatched","streamExpressionScore","regexScore","seadex","bitrate","releaseGroup"],aI={quality:{name:"Quality",description:"Sort by the quality of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred quality list are preferred",descendingDescription:"Streams that are in your preferred quality list are preferred"},resolution:{name:"Resolution",description:"Sort by the resolution of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred resolution list are preferred",descendingDescription:"Streams that are in your preferred resolution list are preferred"},language:{name:"Language",description:"Sort by the language of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred language list are preferred",descendingDescription:"Streams that are in your preferred language list are preferred"},subtitle:{name:"Subtitle",description:"Sort by the subtitle of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred subtitle list are preferred",descendingDescription:"Streams that are in your preferred subtitle list are preferred"},visualTag:{name:"Visual Tag",description:"Sort by the visual tags of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred visual tag list are preferred",descendingDescription:"Streams that are in your preferred visual tag list are preferred"},audioTag:{name:"Audio Tag",description:"Sort by the audio tags of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred audio tag list are preferred",descendingDescription:"Streams that are in y
13our preferred audio tag list are preferred"},audioChannel:{name:"Audio Channel",description:"Sort by the audio channels of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred audio channel list are preferred",descendingDescription:"Streams that are in your preferred audio channel list are preferred"},streamType:{name:"Stream Type",description:"Whether the stream is of a preferred stream type",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred stream type list are preferred",descendingDescription:"Streams that are in your preferred stream type list are preferred"},encode:{name:"Encode",description:"Whether the stream is of a preferred encode",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred encode list are preferred",descendingDescription:"Streams that are in your preferred encode list are preferred"},size:{name:"Size",description:"Sort by the size of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are smaller are sorted first",descendingDescription:"Streams that are larger are sorted first"},service:{name:"Service",description:"Sort by the service order",defaultDirection:"desc",ascendingDescription:"Streams without a service are preferred",descendingDescription:"Streams are ordered by the order of your service list, with non-service streams at the bottom"},seeders:{name:"Seeders",description:"Sort by the number of seeders",defaultDirection:"desc",ascendingDescription:"Streams with fewer seeders are preferred",descendingDescription:"Streams with more seeders are preferred"},private:{name:"Private",description:"Whether the stream is from a private tracker or not",defaultDirection:"desc",ascendingDescription:"Streams that are not from private trackers are preferred",descendingDescription:"Streams that are from private trackers are preferred"},age:{name:"Age",description:"Sort by the age of the stream",defaultDirection:"desc",ascendingDescription:"Newer streams are preferred",descendingDescription:"Older streams are preferred"},addon:{name:"Addon",description:"Sort by the addon order",defaultDirection:"desc",ascendingDescription:"Streams are sorted by the order of your addon list",descendingDescription:"Streams are sorted by the order of your addon list"},regexPatterns:{name:"Regex Patterns",description:"Whether the stream matches any of your preferred regex patterns",defaultDirection:"desc",ascendingDescription:"Streams that do not match your preferred regex patterns are preferred",descendingDescription:"Streams that match your preferred regex patterns are preferred"},cached:{name:"Cached",defaultDirection:"desc",description:"Whether the stream is cached or not",ascendingDescription:"Streams that are not cached are preferred",descendingDescription:"Streams that are cached are preferred"},library:{name:"Library",defaultDirection:"desc",description:"Whether the stream is in your library (e.g. debrid account) or not",ascendingDescription:"Streams that are not in your library are preferred",descendingDescription:"Streams that are in your library are preferred"},keyword:{name:"Keyword",defaultDirection:"desc",description:"Sort by the keyword of the stream",ascendingDescription:"Streams that do not match any of your keywords are preferred",descendingDescription:"Streams that match any of your keywords are preferred"},streamExpressionMatched:{name:"Stream Expressions",defaultDirection:"desc",description:"Whether the stream matches any of your preferred stream expressions",ascendingDescription:"Streams that do not match your preferred stream expressions are preferred while the ones that do are ranked by the order of your preferred stream expressions",descendingDescription:"Streams that match your preferred stream expressions are preferred and ranked by the order of your preferred stream expressions"},seadex:{name:"SeaDex",defaultDirection:"desc",description:"Whether the stream is a SeaDex release (curated best anime releases from releases.moe)",ascendingDescription:"Streams that are not listed on SeaDex are preferred",descendingDescription:"Streams that are marked as the Best release on SeaDex are preferred, followed by the Alternative release"},bitrate:{name:"Bitrate (Estimate)",defaultDirection:"desc",description:"Sort by the bitrate of the stream",ascendingDescription:"Streams with lower bitrate are preferred",descendingDescription:"Streams with higher bitrate are preferred"},regexScore:{name:"Ranked Regex Score",defaultDirection:"desc",description:"Sort by the computed score from ranked regex patterns",ascendingDescription:"Streams with lower regex scores are preferred",descendingDescription:"Streams with higher regex scores are preferred"},streamExpressionScore:{name:"Stream Expression Score",defaultDirection:"desc",description:"Sort by the computed score from ranked stream expressions",ascendingDescription:"Streams with lower expression scores are preferred",descendingDescription:"Streams with higher expression scores are preferred"},releaseGroup:{name:"Release Group",defaultDirection:"desc",description:"Sort by the release group of the stream",ascendingDescription:"Streams that are not in your preferred release group list are preferred",descendingDescription:"Streams that are in y
13our preferred release group list are preferred"}},aE=["p2p","live","stremio-usenet","archive","usenet","debrid","http","external","youtube","error","statistic","info"],aM="movie",aP="series",a$="channel",aD="anime",aL=[aM,aP,a$,"tv",aD],aO={[aM]:"Movie",[aP]:"Series",[a$]:"Channel",tv:"TV",[aD]:"Anime"},aU=["stream","subtitles","catalog","meta","addon_catalog","watch_state"],aF=["English","Japanese","Chinese","Russian","Arabic","Portuguese","Portuguese (Brazil)","Spanish","French","German","Italian","Korean","Hindi","Bengali","Punjabi","Marathi","Gujarati","Tamil","Telugu","Kannada","Malayalam","Thai","Vietnamese","Indonesian","Turkish","Hebrew","Persian","Ukrainian","Greek","Lithuanian","Latvian","Estonian","Polish","Czech","Slovak","Hungarian","Romanian","Bulgarian","Serbian","Croatian","Slovenian","Dutch","Danish","Finnish","Swedish","Norwegian","Malay","Latino","Dual Audio","Dubbed","Multi","Original","Unknown"],az=[{name:"Resolution",description:'The resolution, falling back to "Unknown" when unavailable.',value:"{stream.resolution::default('Unknown')}"},{name:"Title & Year",description:"Title in Title Case, with the year in brackets when known.",value:"{stream.title::title}{? ({stream.year})?}"},{name:"Season & Episode",description:"Season and episode (S01 E05). Hidden for movies.",value:"{?{stream.seasonEpisode::join(' ')}?}"},{name:"Quality",description:"Source quality (BluRay, WEB-DL, â¦). Hidden when unknown.",value:"{?\uD83C\uDFA5 {stream.quality}?}"},{name:"File Size",description:"File size, with the folder size appended when present.",value:"{?\uD83D\uDCE6 {stream.size::sbytes}?}{? / {stream.folderSize::sbytes}?}"},{name:"Bitrate",description:"Bitrate. Hidden when unavailable.",value:"{?\uD83D\uDCCA {stream.bitrate::sbitrate}?}"},{name:"Duration",description:"Runtime.",value:"{?â±ï¸ {stream.duration::time}?}"},{name:"Seeders",description:"Seeder count. Hidden for non-torrents.",value:"{?\uD83D\uDC64 {stream.seeders}?}"},{name:"Age",description:"How long ago the release was posted.",value:"{?\uD83D\uDCC5 {stream.age}?}"},{name:"HDR / Visual Tags",description:"Visual tags such as HDR, DV and IMAX.",value:"{?\uD83D\uDCFA {stream.visualTags::join(' | ')}?}"},{name:"Audio",description:"Audio codecs and channel layouts.",value:"{?\uD83D\uDD0A {stream.audioTags::join(' | ')}?}{?\uD83C\uDF9Aï¸ {stream.audioChannels::join(' | ')}?}"},{name:"Languages",description:"Language flags. Tip: use stream.languageCodes for text codes instead.",value:"{?\uD83C\uDF10 {stream.languageEmojis::join(' / ')}?}"},{name:"Subtitles",description:"Subtitle language flags.",value:"{?\uD83D\uDCDD {stream.subtitleEmojis::join(' / ')}?}"},{name:"Encode / Codec",description:"Video codec (x265, AV1, â¦).",value:"{?\uD83C\uDF9Eï¸ {stream.encode}?}"},{name:"Release Group",description:"The release group.",value:"{?\uD83C\uDFF7ï¸ {stream.releaseGroup}?}"},{name:"Episode Title",description:"The episode title parsed from the release name.",value:"{?\uD83D\uDCFA {stream.episodeTitle}?}"},{name:"Indexer",description:"The indexer or tracker the result came from.",value:"{?âï¸ {stream.indexer}?}"},{name:"Service & Cached",description:"Debrid service, with a cached (â¡) / uncached (â³) badge.",value:'{?[{service.shortName}]?}{service.cached[" â¡"||" â³"||""]}'},{name:"P2P Marker",description:"Adds a [P2P] marker for torrent streams.",value:'{stream.type::=p2p["[P2P] "||""]}'},{name:"Message",description:"Any status message on the stream.",value:"{?â¹ï¸ {stream.message}?}"},{name:"New Line",description:"Forces a line break. Useful inside modifier arguments.",value:"{tools.newLine}"}];function aV(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function aq(e){return null==e||Array.isArray(e)&&0===e.length||aV(e)&&0===Object.keys(e).length}function aB(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=[],r=new Set(["uuid","trusted","encryptedPassword","showChanges","ip","accessToken"]);if(null==e&&null==t||aq(e)&&aq(t))return a;if(Array.isArray(e)&&Array.isArray(t)){if(e===t)return[];try{if(JSON.stringify(e)===JSON.stringify(t))return[]}catch(e){console.warn("Fast array comparison failed:",e)}let r=s.length>0?s[s.length-1]:"",n="presets"===r,l="catalogModifications"===r,i=e=>{if(!aV(e))return String(e);if(l&&e.id&&e.type)return`${e.id}_${e.type}`;if(e.instanceId)return e.instanceId;if(e.id)return e.id;if(e.pattern)return e.pattern;if(e.condition&&Array.isArray(e.addons))try{return`grouping:${e.condition}:${JSON.stringify(e.addons)}`}catch{return e.condition}if(e.condition)return e.condition;if(e.expression)return e.expression;if(Array.isArray(e.addons))try{return`addons:${JSON.stringify(e.addons)}`}catch{return null}return e.key?e.key:e.name?e.name:null},o=e.map(i),d=t.map(i);if(o.every(e=>null!==e)&&d.every(e=>null!==e)&&new Set(o).size===e.length&&new Set(d).size===t.length){let r=new Map,o=[];
13e.forEach(e=>{let t=i(e);r.set(t,e),o.push(t)});let d=new Map,c=[];t.forEach(e=>{let t=i(e);d.set(t,e),c.push(t)});let u=e=>{var t;let s=d.get(e)||r.get(e);if((null==s?void 0:s.expression)&&(null==s?void 0:s.score)!==void 0)return`${s.expression} (Score: ${s.score})`;if((null==s?void 0:s.addons)&&Array.isArray(s.addons)){let e=s.addons[0]||"",t=s.addons.length,a=e?` (${e}${t>1?` +${t-1}`:""})`:"";return`Group: ${s.condition||"true"}${a}`}return(null==s?void 0:s.name)?l&&s.type?`${s.name} (${s.type})`:s.name:(null==s||null==(t=s.options)?void 0:t.name)||(null==s?void 0:s.instanceId)||(null==s?void 0:s.id)||e};r.forEach((t,r)=>{if(!d.has(r)){let l=e.findIndex(e=>i(e)===r);a.push({path:[...s,`[${l}]`],type:"REMOVE",oldValue:n?`Deleted: ${u(r)}`:t})}}),d.forEach((e,n)=>{let l=t.findIndex(e=>i(e)===n);if(r.has(n)){let t=r.get(n);a.push(...aB(t,e,[...s,`[${l}]`]))}else a.push({path:[...s,`[${l}]`],type:"ADD",newValue:e})});let m=o.filter(e=>c.includes(e)),h=c.filter(e=>o.includes(e));return(m.length!==h.length||m.some((e,t)=>e!==h[t]))&&a.push({path:[...s],type:"CHANGE",oldValue:o.map(u),newValue:c.map(u)}),a}let c=0,u=0;for(;c<e.length||u<t.length;){if(c>=e.length){a.push({path:[...s,`[${u}]`],type:"ADD",newValue:t[u]}),u++;continue}if(u>=t.length){a.push({path:[...s,`[${c}]`],type:"REMOVE",oldValue:e[c]}),c++;continue}let r=aB(e[c],t[u],[...s,`[${u}]`]);if(0===r.length){c++,u++;continue}let n=!1;c+1<e.length&&0===aB(e[c+1],t[u],[]).length&&(n=!0);let l=!1;u+1<t.length&&0===aB(e[c],t[u+1],[]).length&&(l=!0),n&&!l?(a.push({path:[...s,`[${c}]`],type:"REMOVE",oldValue:e[c]}),c++):(l&&!n?a.push({path:[...s,`[${u}]`],type:"ADD",newValue:t[u]}):(a.push(...r),c++),u++)}return a}if(!aV(e)||!aV(t)){if(e===t)return a;try{if(JSON.stringify(e)===JSON.stringify(t))return a}catch{}return[{path:s,type:"CHANGE",oldValue:e,newValue:t}]}let n=Object.keys(e),l=Object.keys(t);for(let l of n)if(!r.has(l))if(Object.prototype.hasOwnProperty.call(t,l))a.push(...aB(e[l],t[l],[...s,l]));else{if(null==e[l]||aq(e[l]))continue;a.push({path:[...s,l],type:"REMOVE",oldValue:e[l]})}for(let n of l)if(!r.has(n)&&!Object.prototype.hasOwnProperty.call(e,n)){if(null==t[n]||aq(t[n]))continue;a.push({path:[...s,n],type:"ADD",newValue:t[n]})}return a}function aK(e){var t;if(!e)return e;let s={...e};return delete s.ip,delete s.uuid,delete s.accessToken,delete s.trusted,delete s.encryptedPassword,delete s.showChanges,delete s.activeVariants,delete s.autoVariants,delete s.healthResults,(null==(t=s.parentConfig)?void 0:t.password)&&(s.parentConfig={...s.parentConfig,password:"[hidden]"}),function e(t){return Array.isArray(t)?t.map(e):aV(t)?Object.keys(t).sort().reduce((s,a)=>(s[a]=e(t[a]),s),{}):t}(s)}function aH(e,t){if(!e||!e.groups)return e;let s={...e,groups:{...e.groups}};return s.groups.groupings&&(s.groups.groupings=s.groups.groupings.map(e=>Array.isArray(e.addons)?{...e,addons:e.addons.map(e=>{var s;let a=null==t?void 0:t.find(t=>{var s;return t.instanceId===e||(null==(s=t.options)?void 0:s.id)===e});return(null==a||null==(s=a.options)?void 0:s.name)||e})}:e)),s}function aW(e,t){let s=[...(null==e?void 0:e.presets)??[],...(null==t?void 0:t.presets)??[]],a=aK(e),r=aK(t),n=aH(a,s),l=aH(r,s);return{diffs:aB(n,l),processedOld:n,processedNew:l}}let aG="aiostreams-draft-session",aY="aiostreams-draft:",aJ="aiostreams-draft-opt-out",aZ="aiostreams-user-data";function aQ(e){return`${aY}${e??"anon"}`}function aX(e,t){try{return e.getItem(t)}catch{return null}}function a0(e,t,s){try{e.setItem(t,s)}catch{}}function a1(e,t){try{e.removeItem(t)}catch{}}function a2(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||1!==t.v||"number"!=typeof t.savedAt||!t.data)return null;return t}catch{return null}}function a3(e,t,s){return JSON.stringify({v:1,savedAt:Date.now(),uuid:t,addonName:s,data:e})}function a5(){return"1"===aX(localStorage,aJ)}function a4(){return a2(aX(sessionStorage,aG))}function a6(e){a1(sessionStorage,aG),a1(localStorage,aQ(e))}function a9(e){let t,s,a=a4();return a&&a.uuid===e?a:!(s=a2(aX(localStorage,t=aQ(e))))||Date.now()-s.savedAt>6048e5?(a1(localStorage,t),null):s}function a8(e){var t,s,a,r;if(e&&void 0!==e.addonPassword&&void 0===e.accessToken&&(e.accessToken=e.add
13onPassword),e&&void 0!==e.addonPassword&&delete e.addonPassword,e&&void 0!==e.accessToken&&void 0===e.accessKey&&(e.accessKey=e.accessToken),e&&void 0!==e.accessToken&&delete e.accessToken,e.deduplicator&&"string"==typeof e.deduplicator.multiGroupBehaviour)switch(e.deduplicator.multiGroupBehaviour){case"remove_uncached":e.deduplicator.multiGroupBehaviour="aggressive";break;case"remove_uncached_same_service":e.deduplicator.multiGroupBehaviour="conservative";break;case"remove_nothing":e.deduplicator.multiGroupBehaviour="keep_all"}if("boolean"==typeof e.digitalReleaseFilter){let t=e.digitalReleaseFilter;e.digitalReleaseFilter={enabled:t,tolerance:0,requestTypes:["movie","series","anime"],addons:[]}}(null==(t=e.titleMatching)?void 0:t.matchYear)&&(e.yearMatching={enabled:!0,tolerance:e.titleMatching.yearTolerance?e.titleMatching.yearTolerance:1,requestTypes:e.titleMatching.requestTypes??[],addons:e.titleMatching.addons??[]},delete e.titleMatching.matchYear),Array.isArray(e.groups)&&(e.groups={enabled:!e.disableGroups,groupings:e.groups,behaviour:"parallel"}),(e.showStatistics||e.statisticsPosition)&&(e.statistics={enabled:e.showStatistics??!1,position:e.statisticsPosition??"bottom",statsToShow:["addon","filter","timing"],...e.statistics??{}},delete e.showStatistics,delete e.statisticsPosition);let n=t=>{Array.isArray(e[t+"Encodes"])&&(e[t+"Encodes"]=e[t+"Encodes"].filter(s=>"H-OU"!==s&&"H-SBS"!==s||(e[t+"VisualTags"]=[...e[t+"VisualTags"]??[],s],!1)))};n("preferred"),n("required"),n("excluded"),n("included");let l=e=>{if("string"!=typeof e)return e;let t=e.replace(/queryType\s*==\s*(["'])anime\1/g,"(queryType == 'anime.series' or queryType == 'anime.movie')");return(t=(t=t.replace(/(["'])anime\1\s*==\s*queryType/g,"(queryType == 'anime.series' or queryType == 'anime.movie')")).replace(/queryType\s*!=\s*(["'])anime\1/g,"(queryType != 'anime.series' and queryType != 'anime.movie')")).replace(/(["'])anime\1\s*!=\s*queryType/g,"(queryType != 'anime.series' and queryType != 'anime.movie')")};for(let t of["excludedStreamExpressions","requiredStreamExpressions","includedStreamExpressions","preferredStreamExpressions"])Array.isArray(e[t])&&(e[t]=e[t].map(e=>"string"==typeof e?l(e):"object"==typeof e&&null!==e&&"expression"in e?{...e,expression:l(e.expression)}:e));if((null==(s=e.dynamicAddonFetching)?void 0:s.condition)&&(e.dynamicAddonFetching.condition=l(e.dynamicAddonFetching.condition)),(null==(a=e.groups)?void 0:a.groupings)&&(e.groups.groupings=e.groups.groupings.map(e=>({...e,condition:l(e.condition)}))),void 0!==e.rpdbUseRedirectApi&&void 0===e.usePosterRedirectApi&&(e.usePosterRedirectApi=e.rpdbUseRedirectApi,delete e.rpdbUseRedirectApi),Array.isArray(e.catalogModifications))for(let t of e.catalogModifications)void 0===t.usePosterService&&!0===t.rpdb&&(t.usePosterService=!0),delete t.rpdb;for(let t of(void 0===e.precacheSelector&&e.precacheNextEpisode&&(void 0!==e.precacheCondition?e.precacheSelector=`${e.precacheCondition} ? uncached(streams) : []`:e.precacheSelector=!0===e.alwaysPrecache?"true ? uncached(streams) : []":sV),delete e.alwaysPrecache,delete e.precacheCondition,void 0!==e.p2pWrap&&void 0===e.serviceWrap&&(e.serviceWrap=e.p2pWrap,delete e.p2pWrap),void 0===e.failover&&void 0!==e.nzbFailover&&(e.failover={enabled:e.nzbFailover.enabled,maxAttempts:e.nzbFailover.count,position:e.nzbFailover.position,contentTypes:[...sq],allowCrossType:!1,parallel:1}),delete e.nzbFailover,e.failover&&void 0!==e.failover.count&&((r=e.failover).maxAttempts??(r.maxAttempts=e.failover.count),delete e.failover.count),["excludedStreamExpressions","requiredStreamExpressions","preferredStreamExpressions","includedStreamExpressions"]))Array.isArray(e[t])&&e[t].some(e=>"string"==typeof e)&&(e[t]=e[t].map(e=>"string"==typeof e?{expression:e,enabled:!0}:e));if(e.presets&&Array.isArray(e.presets)&&(e.presets=e.presets.map(e=>{var t;return(null==(t=e.options)?void 0:t.forceToTop)===!0&&void 0===e.options.pinPosition?(delete e.options.forceToTop,{...e,options:{...e.options,pinPosition:"top"}}):e})),e.presets&&Array.isArray(e.presets)){let t={newznab:["newznabUrl","apiKey"],torznab:["torznabUrl","apiKey"],nzbhydra:["nzbhydraUrl","nzbhydraApiKey",!0]};e.presets=e.presets.map(e=>{let s=t[e.type];if(!s||!e.options||void 0!==e.options.api)return e;let[a,r,n]=s,{[a]:l,[r]:i,apiPath:o,...d}=e.options;if(void 0===l&&void 0===i&&void 0===o)return e;let c={};if("string"==typeof l&&l.trim()){let e=l.trim().replace(/\/+$/,"");if(n)c.url=e;else{let t=(void 0===o?"/api":String(o).trim()).replace(/^\/+|\/+$/g,"");c.url=e+(t?`/${t}`:"")}}return void 0!==i&&(c.apiKey=i),{...e,options:{...d,api:c}}})}return e.formatter&&e.formatter.definition&&(e.formatter.definitions={...e.formatter.definitions??{},custom:e.formatter.definition},delete e.formatter.definition),e}function a7(e){var t,s,a,r,n,l,i,o;let d=null==(t=e.presets)?void 0:t.map(e=>e.instanceId);return e.proxy&&(e.proxy.proxiedAddons=null==(r=e.proxy.proxiedAddons)?void 0:r.filter(e=>null==d?void 0:d.includes(e))),e.yearMatching&&(e.yearMatching.addons=null==(n=e.yearMatching.addons)?void 0:n.filter(e=>null==d?void 0:d.includes(e))),e.titleMatching&&(e.titleMatching.addons=null==(l=e.titleMatching.addons)?void 0:l.filter(e=>null==d?void 0:d.includes(e))),e.seasonEpisodeMatching&&(e.seasonEpisodeMatching.addons=null==(i=e.seasonEpisodeMatching.addons)?void 0:i.filter(e=>null==d?void 0:d.includes(e))),e.episodeTitleMatching&&(e.episodeTitleMatching.addons=null==(o=e.episodeTitleMatching.addons)?void 0:o.filter(e=>null==d?void 0:d.includes(e))),(null==(s=e.groups)?void 0:s.groupings)&&(e.groups.groupings=e.groups.groupings.map(e=>{var t;return{...e,addons:null==(t=e.addons)?void 0:t.filter(e=>null==d?void 0:d.includes(e))}}
13)),(null==(a=e.serviceWrap)?void 0:a.presets)&&(e.serviceWrap.presets=e.serviceWrap.presets.filter(e=>null==d?void 0:d.includes(e))),e}let re={services:Object.values(ap).map(e=>({id:e.id,enabled:!1,credentials:{}})),presets:[],formatter:{id:"gdrive"},preferredQualities:Object.values(aS),preferredResolutions:Object.values(ak),excludedQualities:["CAM","SCR","TS","TC"],excludedVisualTags:["3D"],sortCriteria:{global:[{key:"cached",direction:"desc"},{key:"library",direction:"desc"},{key:"resolution",direction:"desc"},{key:"quality",direction:"desc"},{key:"streamExpressionScore",direction:"desc"},{key:"regexPatterns",direction:"desc"},{key:"streamType",direction:"desc"},{key:"visualTag",direction:"desc"},{key:"audioTag",direction:"desc"},{key:"audioChannel",direction:"desc"},{key:"encode",direction:"desc"},{key:"language",direction:"desc"},{key:"subtitle",direction:"desc"},{key:"size",direction:"desc"}]},posterService:"rpdb",deduplicator:{enabled:!0,keys:["filename","infoHash"],multiGroupBehaviour:"aggressive",cached:"single_result",uncached:"per_service",p2p:"single_result",http:"disabled",live:"disabled",youtube:"disabled",external:"disabled",smartDetectAttributes:av,smartDetectRounding:10,libraryBehaviour:"ignore"},autoPlay:{enabled:!0,method:"matchingFile",attributes:["resolution","quality","releaseGroup"]},cacheAndPlay:{enabled:!1,streamTypes:["usenet"]},statistics:{enabled:!1,position:"bottom",statsToShow:["addon","filter","timing"],showFilterStatsOnNoStreams:!0},digitalReleaseFilter:{enabled:!1,tolerance:0,requestTypes:[],addons:[],showInfoOnFilter:!0},ageRangeTypes:["usenet"],seasonEpisodeMatching:{addons:[],requestTypes:[]},episodeTitleMatching:{addons:[],requestTypes:[]},languageInference:{enabled:!0,sources:[]},yearMatching:{addons:[],requestTypes:[]},titleMatching:{addons:[],requestTypes:[]},precacheNextEpisode:!1,precacheSingleStream:!0,precacheSelector:sV,enableSeadex:!0,regexOverrides:[],checkOwned:!0};function rt(e,t,s){let a=t.settings.forced.proxy,r=s?t.settings.defaults.proxy:void 0,n=t.settings.services,l=e.proxy,i={...e};return i.proxy={...l,enabled:a.enabled??(null==l?void 0:l.enabled)??(null==r?void 0:r.enabled)??void 0,id:a.id??(null==l?void 0:l.id)??(null==r?void 0:r.id)??(s?"builtin":void 0),url:a.url??(null==l?void 0:l.url)??(null==r?void 0:r.url)??void 0,publicUrl:a.publicUrl??(null==l?void 0:l.publicUrl)??(null==r?void 0:r.publicUrl)??void 0,publicIp:a.publicIp??(null==l?void 0:l.publicIp)??(null==r?void 0:r.publicIp)??void 0,credentials:a.credentials??(null==l?void 0:l.credentials)??(null==r?void 0:r.credentials)??void 0,proxiedServices:a.proxiedServices??(null==l?void 0:l.proxiedServices)??(null==r?void 0:r.proxiedServices)??(s?[]:void 0)},i.services=(e.services??[]).map(e=>{let t=n[e.id];if(!t)return e;let a={...e.credentials};return t.credentials.forEach(e=>{e.forced?a[e.id]=e.forced:s&&e.default&&void 0===a[e.id]&&(a[e.id]=e.default)}),{...e,credentials:a,enabled:s?t.credentials.every(e=>e.forced||e.default||void 0!==a[e.id]):e.enabled}}),i}function rs(e,t){let s=a8(structuredClone(e.data));return t?rt(s,t,!1):s}function ra(e,t){return 0===aW(e,t).diffs.length}function rr(e){return(e.presets??[]).length>0||(e.services??[]).some(e=>e.enabled)}let rn=u.createContext(void 0);function rl(e){let{children:t}=e,{status:s}=tj(),[a]=u.useState(()=>{!function(e){let t=aX(localStorage,aZ);if(null!==t&&(a1(localStorage,aZ),!a5()))try{let s=JSON.parse(t);if(!s||!e(s))return;a0(localStorage,aQ(null),a3(s,null))}catch{}}(rr);try{for(let e=localStorage.length-1;e>=0;e--){let t=localStorage.key(e);if(!(null==t?void 0:t.startsWith(aY)))continue;let s=a2(aX(localStorage,t));(!s||Date.now()-s.savedAt>6048e5)&&a1(localStorage,t)}}catch{}let e=a4();if(e&&null===e.uuid)try{return{initial:a8(e.data),pending:null}}catch{}return{initial:re,pending:a9(null)}}),[r,n]=u.useState(a.initial),[l,o]=u.useState(a.pending),[d,c]=u.useState(null),[m,h]=u.useState(null),[p,x]=u.useState(null),g=u.useRef(re),f=u.useRef(re),[b,v]=u.useState(!1),[y,j]=u.useState(0),w=u.useCallback(e=>{g.current=e,j(e=>e+1)},[]),N=u.useRef(!1);u.useEffect(()=>{if(!s||N.current)return;N.current=!0;let e=rt(re,s,!0),t=t=>t===re?e:rt(t,s,!1);f.current=e,g.current=t(g.current),n(t),v(!0)},[s]);let k=u.useRef(null);u.useEffect(()=>{if(k.current===d)return;k.current=d;let e=a9(d),t=!1;try{t=!!e&&!ra(rs(e,s),r)}catch{}o(t?e:null)},[d]),u.useEffect(()=>{if(!b)return;let e=setTimeout(()=>{var e;ra(r,g.current)?a6(d):(a0(sessionStorage,aG,a3(r,d,r.addonName)),e=r.addonName,a5()||a0(localStorage,aQ(d),a3(r,d,e)))},400);return()=>clearTimeout(e)}
13,[r,d,b,y]);let S=u.useCallback(()=>{o(e=>{if(e)try{let t=rs(e,s);n(()=>t)}catch{}return null})},[s]),C=u.useCallback(()=>{o(e=>(e&&a6(e.uuid),null))},[]),_=l&&l.uuid===d?l:null,A=u.useCallback(()=>{a0(localStorage,aJ,"1"),function(){try{let e=[];for(let t=0;t<localStorage.length;t++){let s=localStorage.key(t);(null==s?void 0:s.startsWith(aY))&&e.push(s)}e.forEach(e=>a1(localStorage,e))}catch{}}(),o(e=>(e&&a6(e.uuid),null))},[]),R=u.useCallback(e=>{let t=()=>(g.current=f.current,f.current);null===e?n(t):n(s=>{let a=e(s);return null===a?t():a})},[]),T=u.useMemo(()=>({userData:r,setUserData:R,uuid:d,setUuid:c,password:m,setPassword:h,encryptedPassword:p,setEncryptedPassword:x,setBaseline:w,pendingDraft:_,restoreDraft:S,discardDraft:C,disableDrafts:A}),[r,R,d,m,p,w,_,S,C,A]);return(0,i.jsx)(rn.Provider,{value:T,children:t})}function ri(){let e=u.useContext(rn);if(void 0===e)throw Error("useUserData must be used within a UserDataProvider");return e}function ro(){let{userData:e}=ri(),t=null==e?void 0:e.parentConfig,s=null==t?void 0:t.mergeStrategies;return{hasParent:!!t,parentUuid:null==t?void 0:t.uuid,isInherited:function(e){return!!t&&"inherit"===((null==s?void 0:s[e])??"inherit")}}}let rd=["about","services","addons","filters","sorting","formatter","proxy","miscellaneous","stats","save-install"],rc=["sorting"],ru=(0,u.createContext)({selectedMenu:"about",setSelectedMenu:()=>{},nextMenu:()=>{},previousMenu:()=>{},firstMenu:"about",lastMenu:"save-install"});function rm(e){let{children:t}=e,{mode:s}=sF(),{status:a}=tj(),r=ri(),n=(null==a?void 0:a.settings.userAnalyticsEnabled)===!0&&!!(r.uuid&&r.password),l=(0,u.useMemo)(()=>{let e=rd;return"noob"===s&&(e=e.filter(e=>!rc.includes(e))),n||(e=e.filter(e=>"stats"!==e)),e},[s,n]),o=(()=>{if("u">typeof window){let e=new URL(window.location.href).searchParams.get("menu");if(e&&l.includes(e))return e}return"about"})(),[d,c]=(0,u.useState)(o),m=e=>{window.scrollTo(0,0),c(e)},h=l[0],p=l[l.length-1];return(0,u.useEffect)(()=>{let e=new URL(window.location.href);"about"!==d?e.searchParams.set("menu",d):e.searchParams.delete("menu"),window.history.replaceState({},"",e.toString())},[d]),(0,i.jsx)(ru.Provider,{value:{selectedMenu:d,setSelectedMenu:m,nextMenu:()=>{let e=(l.indexOf(d)+1)%l.length;m(l[e])},previousMenu:()=>{let e=(l.indexOf(d)-1+l.length)%l.length;m(l[e])},firstMenu:h,lastMenu:p},children:t})}let rh=()=>(0,u.useContext)(ru),rp={filters:"filter",miscellaneous:"misc-tab",services:"service-tab",addons:"addons-tab"},rx={filters:"cache",miscellaneous:"background",services:"services",addons:"addons"},rg=(0,u.createContext)({subTabs:{},setSubTab:()=>{},getUrlKey:()=>void 0});function rf(){let e={...rx};if("u"<typeof window)return e;let t=new URL(window.location.href);for(let[s,a]of Object.entries(rp)){let r=t.searchParams.get(a);r&&(e[s]=r)}return e}function rb(e){let{children:t}=e,[s,a]=(0,u.useState)(rf),r=(0,u.useCallback)((e,t)=>{if(a(s=>({...s,[e]:t})),"u">typeof window){let s=rp[e];if(s){let e=new URL(window.location.href);e.searchParams.set(s,t),window.history.replaceState({},"",e.toString())}}},[]),n=(0,u.useCallback)(e=>rp[e],[]);(0,u.useEffect)(()=>{let e=()=>a(rf());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let l=(0,u.useMemo)(()=>({subTabs:s,setSubTab:r,getUrlKey:n}),[s,r,n]);return(0,i.jsx)(rg.Provider,{value:l,children:t})}function rv(e){let t=(0,u.useContext)(rg);return{tab:t.subTabs[e]??rx[e]??"",setTab:(0,u.useCallback)(s=>t.setSubTab(e,s),[t,e])}}let ry=null,rj=null;function rw(e){let t=performance.now(),s=null,a=0,r=-1,n=-1,l=0,i=()=>{var o,d;let c=performance.now();if(!s){if(!(s=function(e){for(let t of e)for(let e of document.querySelectorAll(`#${CSS.escape(t)}`))if(null!==e.offsetParent&&!e.closest("[inert]"))return e;return null}(e))){c-t<3e3&&requestAnimationFrame(i);return}a=c,o=s,ry&&ry.removeAttribute("data-command-target"),null!==rj&&window.clearTimeout(rj),o.setAttribute("data-command-target","true"),ry=o,rj=window.setTimeout(()=>{o.removeAttribute("data-command-target"),ry=null,rj=null},1600)}let u=document.documentElement.scrollHeight;u!==n?(n=u,l=0):l++;let m=Math.min(Math.max(0,function(e){let t=0,s=e;for(;s;)t+=s.offsetTop,s=s.offsetParent;return t}(d=s)-Math.max(0,(window.innerHeight-d.offsetHeight)/2)),Math.max(0,u-window.innerHeight));Math.abs(m-r)>1&&(r=m,window.scrollTo({top:m,behavior:"smooth"}));let h=c-a;!(l>=3&&h>=120)&&h<1500&&requestAnimationFrame(i)};requestAnimationFrame(i)}let rN=(0,u.createContext)({isOpen:!1,open:()=>{},close:()=>{},toggle:()=>{},navigate:()=>{}});function rk(e){let{children:t}=e,{isOpen:s,open:a,close:r,toggle:n}=sy(),{selectedMenu:l,setSelectedMenu:o}=rh(),{setSubTab:d}=(0,u.useContext)(rg),c=(0,u.useCallback)(e=>{e.subTab&&d(e.menu,e.subTab),l!==e.menu&&o(e.menu),r();let t=[e.sectionId,...e.fallbackSectionIds??[]].filter(e=>!!e);t.length>0&&rw(t)},[l,o,d,r]);return(0,i.jsx)(rN.Provider,{value:{isOpen:s,open:a,close:r,toggle:n,navigate:c},children:t})}let rS=()=>(0,u.useContext)(rN),rC=(0,u.createContext)({actions:[],register:()=>()=>{}});function r_(e){let{children:t}=e,[,s]=(0,u.useState)(0),a=(0,u.useRef)(new Map),r=(0,u.useCallback)(e=>(a.current.set(e.id,e),s(e=>e+1),()=>{a.current.delete(e.id),s(e=>e+1)}),[]),n=(0,u.useMemo)(()=>({actions:Array.from(a.current.values()),register:r}
13),[r,a.current.size,...Array.from(a.current.keys())]);return(0,i.jsx)(rC.Provider,{value:n,children:t})}let rA=()=>(0,u.useContext)(rC);function rR(e,t){let{register:s}=rA();(0,u.useEffect)(()=>{if(e)return s(e)},t)}function rT(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function rI(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=e=>{let t=[];for(let s of e){if(!s)continue;let e=rT(s);e&&t.push(e)}return t};return{primary:s(e),secondary:s(t)}}function rE(e){let t=rT(e);return{phrase:t,terms:t?t.split(" "):[]}}function rM(e,t,s){let a=0;for(let r of e){let e=function(e,t,s){if(!t||!e)return 0;if(e===t)return 100;if(e.startsWith(t))return 90;if(e.includes(t))return 75;let a=e.split(" ");if(a.some(e=>e.startsWith(t)))return 65;if(a.some(e=>e.includes(t)))return 55;if(!s)return 0;let r=0;for(let s=0;s<e.length&&r<t.length;s++)e[s]===t[r]&&r++;return r===t.length?10+Math.floor(t.length/e.length*30):0}(r,t,s);e>a&&(a=e)}return a}function rP(e,t){let{phrase:s,terms:a}=t;if(!a.length)return 0;let r=1===a.length&&s.length>=3,n=t=>Math.max(rM(e.primary,t,r),.5*rM(e.secondary,t,!1)),l=0;for(let e of a){let t=n(e);if(0===t)return 0;l+=t}return Math.max(l/a.length,a.length>1?n(s):0)}function r$(e){let{open:t,onClose:s,label:a,placeholder:r,emptyHint:n,query:l,onQueryChange:o,isIdle:d,results:c,idleGroup:u}=e;return(0,i.jsxs)(s$,{open:t,onOpenChange:e=>{e||s()},hideCloseButton:!0,contentClass:"max-w-2xl p-0",commandProps:{shouldFilter:!1,label:a},children:[(0,i.jsx)(sR,{placeholder:r,autoFocus:!0,value:l,onValueChange:o}),(0,i.jsxs)(sT,{className:"max-h-[60vh]",children:[(0,i.jsx)(sI,{children:d?n:"No matches."}),d?u:c.length>0&&(0,i.jsx)(sE,{children:c.slice(0,50).map(e=>(0,i.jsxs)(sM,{value:e.id,leftIcon:e.icon,onSelect:e.onSelect,children:[(0,i.jsx)("span",{children:e.label}),(0,i.jsx)("span",{className:"ml-auto text-xs text-[--muted] capitalize",children:e.trail}),e.shortcut&&(0,i.jsx)(sP,{children:e.shortcut})]},e.id))})]})]})}let rD=[{id:"about",label:"About",icon:(0,i.jsx)(sm.wfp,{})},{id:"services",label:"Services",icon:(0,i.jsx)(sm.V0M,{})},{id:"addons",label:"Addons",icon:(0,i.jsx)(sm.DT2,{})},{id:"filters",label:"Filters",icon:(0,i.jsx)(sm.Jw7,{})},{id:"sorting",label:"Sorting",icon:(0,i.jsx)(sm.MFA,{}),proOnly:!0},{id:"formatter",label:"Formatter",icon:(0,i.jsx)(sm.fSy,{})},{id:"proxy",label:"Proxy",icon:(0,i.jsx)(sm.nmg,{})},{id:"miscellaneous",label:"Miscellaneous",icon:(0,i.jsx)(sm.nMM,{})},{id:"stats",label:"Stats",icon:(0,i.jsx)(sm.yWU,{}),requiresStats:!0},{id:"save-install",label:"Save & Install",icon:(0,i.jsx)(sm.Ruw,{})}],rL={about:"About",services:"Services",addons:"Addons",filters:"Filters",sorting:"Sorting",stats:"Stats",formatter:"Formatter",proxy:"Proxy",miscellaneous:"Miscellaneous","save-install":"Save & Install"};function rO(e){return e.replace(/-/g," ")}let rU=Object.entries(sz).filter(e=>{let[,t]=e;return!t.ignoreForCommandPalette}).map(e=>{let[t,s]=e,a=void 0!==s.subTab?`${rO(s.menu)} â ${rO(s.subTab)}`:rL[s.menu]??rO(s.menu),r="filters"===s.menu&&s.subTab?[`filter-tab-${s.subTab}`]:void 0;return{key:t,label:s.label,trail:a,sectionId:s.sectionId??t,menu:s.menu,subTab:s.subTab,fallbackSectionIds:r,haystack:rI([s.label,t,s.menu,s.subTab,...s.keywords??[]])}}),rF=[{id:"cache",label:"Cache"},{id:"resolution",label:"Resolution"},{id:"quality",label:"Quality"},{id:"encode",label:"Encode"},{id:"stream-type",label:"Stream Type"},{id:"visual-tag",label:"Visual Tag"},{id:"audio-tag",label:"Audio Tag"},{id:"audio-channel",label:"Audio Channel"},{id:"language",label:"Language"},{id:"subtitle",label:"Subtitle"},{id:"seeders",label:"Seeders"},{id:"age",label:"Age"},{id:"matching",label:"Matching"},{id:"keyword",label:"Keyword"},{id:"release-group",label:"Release Group"},{id:"stream-expression",label:"Stream Expression"},{id:"regex",label:"Regex"},{id:"size",label:"Size"},{id:"bitrate",label:"Bitrate"},{id:"limit",label:"Result Limits"},{id:"deduplicator",label:"Deduplicator"},{id:"miscellaneous",label:"Miscellaneous (Filters)"}].map(e=>({...e,haystack:rI(["filter tab",e.label,e.id])}));function rz(){let{isOpen:e,close:t,navigate:s}=rS(),{actions:a}=rA(),{mode:r}=sF(),{status:n}=tj(),l=ri(),o=(null==n?void 0:n.settings.userAnalyticsEnabled)===!0&&!!(l.uuid&&l.password),[d,c]=(0,u.useState)(""),m=(0,u.useDeferredValue)(d),h=0===m.trim().length,p=(0,u.useMemo)(()=>rD.filter(e=>("pro"===r||!e.proOnly)&&(!e.requiresStats||o)).map(e=>({...e,haystack:rI([e.label,e.id])})),[r,o]),x=(0,u.useMemo)(()=>a.map(e=>({action:e,haystack:rI([e.label,...e.keywords??[]],[e.description])})),[a]),g=(0,u.useMemo)(()=>
13{if(h)return[];let e=rE(m),a=[];for(let{action:s,haystack:r}of x){let n=rP(r,e);n>0&&a.push({id:`action-${s.id}`,label:s.label,trail:"Action",icon:s.icon,score:n,shortcut:s.shortcut,onSelect:()=>{t(),c(""),s.onSelect()}})}for(let t of p){let r=rP(t.haystack,e);r>0&&a.push({id:`menu-${t.id}`,label:t.label,trail:"Page",icon:t.icon,score:r,onSelect:()=>{c(""),s({menu:t.id})}})}for(let t of rF){let r=rP(t.haystack,e);r>0&&a.push({id:`filter-tab-${t.id}`,label:`Filters â ${t.label}`,trail:"Filter Tab",icon:(0,i.jsx)(sm.Jw7,{}),score:r,onSelect:()=>{c(""),s({menu:"filters",subTab:t.id,sectionId:`filter-tab-${t.id}`})}})}for(let t of rU){let r=rP(t.haystack,e);r>0&&a.push({id:t.key,label:t.label,trail:t.trail,score:r,onSelect:()=>{c(""),s({menu:t.menu,subTab:t.subTab,sectionId:t.sectionId,fallbackSectionIds:t.fallbackSectionIds})}})}return a.sort((e,t)=>t.score-e.score)},[m,h,x,p,s,t]);return(0,i.jsx)(r$,{open:e,onClose:()=>{t(),c("")},label:"Settings search",placeholder:"Search settings, pages, actionsâ¦",emptyHint:"Enter a setting to search forâ¦",query:d,onQueryChange:c,isIdle:h,results:g,idleGroup:a.length>0&&(0,i.jsx)(sE,{heading:"Quick actions",children:a.map(e=>(0,i.jsxs)(sM,{value:`action-${e.id}`,leftIcon:e.icon,onSelect:()=>{t(),c(""),e.onSelect()},children:[(0,i.jsx)("span",{children:e.label}),e.shortcut&&(0,i.jsx)(sP,{children:e.shortcut})]},e.id))})})}let rV={key:"usenet.recheck.scope",not:"off"},rq={key:"shares.fuse.enabled",equals:!0},rB={key:"shares.nfs.enabled",equals:!0},rK={general:{label:"General",icon:sm.nMM,group:"General",order:10,sections:["api","templates","linkedAccounts"]},branding:{label:"Branding",icon:sm.pFm,group:"General",order:20},logging:{label:"Logging",icon:sm.XfR,group:"General",order:30},oidc:{label:"SSO / OIDC",icon:sm.$_m,group:"General",order:35},retention:{label:"Data & Retention",icon:sm.Wwx,group:"General",order:40,sections:["tasks","analytics"]},presets:{label:"Presets",icon:sm.Z_P,group:"Core",order:110},community:{label:"Community",icon:sm.e7V,group:"Core",order:115},builtins:{label:"Built-ins",icon:sm.oNA,group:"Core",order:120},resources:{label:"Addon Resources",icon:sm.z2t,group:"Core",order:130},metadata:{label:"Metadata",icon:sm.wfp,group:"Core",order:140,sections:["metadata","poster"]},releaseBlocklist:{label:"Blocklists",icon:sm.PLI,group:"Core",order:150},usenet:{fieldVisibility:{"usenet.recheck.schedule":rV,"usenet.recheck.window":rV,"usenet.recheck.depth":rV,"usenet.recheck.concurrency":rV,"usenet.recheck.batchSize":rV,"usenet.recheck.sampleSegments":[rV,{key:"usenet.recheck.depth",equals:"sample"}],"usenet.arrCensusHoldTimeout":{key:"usenet.arrWaitForCensus",equals:!0}},label:"Usenet",icon:sm.hQe,group:"Usenet",order:160,cards:[{title:"Performance",note:"Pick a profile and the values below are filled in for you â that is all most setups need. Editing any of the values switches the profile to **custom**.",keys:["usenet.performanceProfile","usenet.prefetchSegments","usenet.maxConcurrentDownloads","usenet.segmentDiskCacheBytes","usenet.segmentCacheBytes"]},{title:"Connections & timeouts",keys:["usenet.streamingPriority","usenet.segmentTimeout","usenet.segmentStallTimeout","usenet.dialTimeout","usenet.idleConnection","usenet.streamIdleTimeout"]},{title:"Reliability",keys:["usenet.circuitBreakerThreshold","usenet.circuitBreakerCooldown"]},{title:"Archive handling",keys:["usenet.lazyRarResolution","usenet.strictArchiveMembership"]},{title:"Verification",note:"When something is imported, AIOStreams checks that it can actually be downloaded from your providers â so broken or incomplete releases are caught up front instead of failing mid-playback. The checks run alongside the import, so they normally add no waiting time: badly damaged releases are rejected, slightly damaged ones are recorded as âdegradedâ, and the damage policy decides whether those are still offered as streams. Any checking that did not finish during the import simply continues in the background, and a stream that is already playing is never interrupted by these verdicts. Content verification goes one step further than reachability: it reads the start of each media file and checks it really is the container it claims to be, which catches a release whose articles all exist but were assembled wrong.",keys:["usenet.verifyMode","usenet.verifyBudgetMs","usenet.verifyContent","usenet.verifyArticleCrc","usenet.damagePolicy","usenet.matroskaHoleFill","usenet.censusShadowConcurrency","usenet.censusMaxLifetime"]},{title:"Import & API",keys:["usenet.maxNzbSize","usenet.maxConcurrentInspects","usenet.sabnzbdApiEnabled","usenet.arrWaitForCensus","usenet.arrCensusHoldTimeout"]},{title:"Library recheck",note:"Re-verifies entries against your providers on a
13schedule keyed to how old the post is, so a release that gets taken down after it was added flips to **failed** instead of sitting in the library looking playable. Small damage follows the damage policy above; only a release that is really gone is marked failed and, when a linked Sonarr/Radarr grabbed it, replaced.",keys:["usenet.recheck.scope","usenet.recheck.schedule","usenet.recheck.window","usenet.recheck.depth","usenet.recheck.sampleSegments","usenet.recheck.concurrency","usenet.recheck.batchSize"]}]},shares:{label:"Shares",icon:sm.uwC,group:"Usenet",order:170,fieldVisibility:{"shares.fuse.mountPath":rq,"shares.fuse.allowOther":rq,"shares.fuse.owner":rq,"shares.nfs.port":rB,"shares.nfs.bindAddress":rB,"shares.nfs.allowedClients":rB,"shares.nfs.owner":rB},editors:["shares.fuse","shares.connect"],cards:[{title:"Mount it here",note:`The library is one folder tree; everything below is a different way to reach it. Pick the row that matches your setup. 14* **One Linux host, or one Docker stack** â turn the local mount on here and you are done. 15* **Sonarr, Radarr or the media server on another Linux machine** â leave this off, switch on the NFS server, and mount that from the other machine. 16* **Windows or macOS, or a host you would rather not give mount privileges** â leave this off, keep the WebDAV server on, and mount it there with rclone. 17* **Only want to browse or play the files** â point Infuse, VLC or a file manager straight at the WebDAV share; nothing needs mounting at all.`,keys:["shares.fuse.enabled","shares.fuse.mountPath","shares.fuse.allowOther","shares.fuse.owner"]},{editor:"shares.fuse"},{title:"WebDAV server",keys:["shares.webdav.enabled"]},{title:"NFS server",keys:["shares.nfs.enabled","shares.nfs.port","shares.nfs.bindAddress","shares.nfs.allowedClients","shares.nfs.owner"]},{title:"Keeping an rclone mount fresh",note:"Only needed if you mount the WebDAV share with rclone yourself, wherever that mount runs. Left empty, a finished download stays invisible to that mount until its `--dir-cache-time` expires.",keys:["shares.rclone.rcUrl","shares.rclone.rcUser","shares.rclone.rcPass"]},{editor:"shares.connect"}]},arr:{label:"Sonarr / Radarr",icon:sm.Ah9,group:"Usenet",order:180,editors:["arr.instances","arr.queueCleanup.rules"]},userDefaults:{label:"User Defaults",icon:sm.jlq,group:"Users",order:210,sections:["services","proxy.default","proxy.force"]},userLimits:{label:"User Limits",icon:sm.hTi,group:"Users",order:220},rateLimits:{label:"Rate Limits",icon:sm.I2B,group:"Users",order:230,sections:["rateLimits","recursion"]},http:{label:"Outbound Requests",icon:sm.IS1,group:"Traffic",order:310},proxy:{label:"Proxy",icon:sm.koG,group:"Traffic",order:320,sections:["proxy.encryption","proxy.ip"]},streams:{label:"Streams",icon:sm.U2S,group:"Traffic",order:330},jellyfin:{label:"Media server",icon:sm.sED,group:"Integrations",order:410},watchState:{label:"Watch State",icon:sm.grf,group:"Integrations",order:420},remuxdb:{label:"RemuxDB",icon:sm.M8H,group:"Integrations",order:430}},rH=new Map(Object.entries(rK).flatMap(e=>{let[t,s]=e;return(s.sections??[t]).map(e=>[e,t])}));function rW(e){let t=e.split(".");for(let e=t.length-1;e>=1;e--){let s=rH.get(t.slice(0,e).join("."));if(s)return s}return t[0]}function rG(e,t){var s;let a=null==(s=rK[e])?void 0:s.sections;if(!a)return 0;let r=t.split(".");for(let e=r.length-1;e>=1;e--){let t=a.indexOf(r.slice(0,e).join("."));if(-1!==t)return t}return a.length}let rY=sm.Wwx,rJ={api:"API",url:"URL",uri:"URI",id:"ID",ip:"IP",ui:"UI",ux:"UX",sel:"SEL",ssl:"SSL",tls:"TLS",tcp:"TCP",udp:"UDP",http:"HTTP",https:"HTTPS",nzb:"NZB",rd:"RD",ad:"AD",pm:"PM",dl:"DL",tb:"TB",bitmagnet:"Bitmagnet",jackett:"Jackett",zilean:"Zilean",prowlarr:"Prowlarr",torrentio:"Torrentio",mediafusion:"MediaFusion",comet:"Comet",seadex:"SeaDex",stremthru:"StremThru",easynews:"Easynews",debridio:"Debridio",torbox:"TorBox",putio:"Put.io",offcloud:"Offcloud",tmdb:"TMDB",rpdb:"RPDB",oauth:"OAuth",oidc:"OIDC",sso:"SSO",gdrive:"GDrive",sqlite:"SQLite",postgres:"Postgres",redis:"Redis"};function rZ(e){return e?e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s\-_]+/).filter(
17Boolean).map(e=>{let t=e.toLowerCase();return rJ[t]?rJ[t]:t.charAt(0).toUpperCase()+t.slice(1)}).join(" "):""}let rQ=["dashboard","settings"],rX=["dashboard"];function r0(e){return(0,ty.I)({queryKey:rQ,queryFn:()=>ea("/dashboard/settings"),staleTime:1e4,enabled:(null==e?void 0:e.enabled)??!0})}let r1=["dashboard","shares","fuse"],r2=["dashboard","arr","instances"],r3=["dashboard","arr","queue-rules"];async function r5(){return ea("GET /dashboard/settings/export")}let r4=[...sb.map(e=>({id:`page-${e.href}`,label:e.label,trail:"Page",icon:u.createElement(e.icon),target:{kind:"page",href:e.href},haystack:rI([e.label,e.href])})),...Object.entries(sv).flatMap(e=>{let[t,s]=e,a=sb.find(e=>e.href===t);return s.map(e=>({id:`section-${t}-${e.id}`,label:e.label,trail:(null==a?void 0:a.label)??t,icon:u.createElement(e.icon),target:{kind:"page",href:`${t}/${e.id}`},haystack:rI([e.label,e.id,null==a?void 0:a.label,`${null==a?void 0:a.label} ${e.label}`])}))}),...Object.entries(rK).map(e=>{let[t,s]=e;return{id:`settings-${t}`,label:s.label,trail:`Settings â ${s.group}`,icon:u.createElement(s.icon),target:{kind:"settings",tab:t},haystack:rI([s.label,t,s.group])}})];function r6(){let{isOpen:e,close:t}=sN(),s=(0,T.Z)(),[a,r]=(0,u.useState)(""),n=(0,u.useDeferredValue)(a),l=0===n.trim().length,{data:o}=r0({enabled:e}),d=(0,u.useMemo)(()=>((null==o?void 0:o.keys)??[]).map(e=>{let t=e.key.split("."),s=t[0],a=rW(e.key),r=rK[a],n=(null==r?void 0:r.label)??rZ(s),l=t.slice(1,-1).map(rZ).join(" â "),i=`Settings â ${n}`;return{id:`field-${e.key}`,label:e.label,trail:l?`${i} â ${l}`:i,icon:u.createElement((null==r?void 0:r.icon)??sm.nMM),target:{kind:"settings",tab:a,field:e.key},haystack:rI([e.label,e.key,e.env,n,l,`${n} ${e.label}`,...t.slice(1)],[e.description])}}),[null==o?void 0:o.keys]),c=e=>{switch(t(),r(""),e.kind){case"page":s({to:e.href});break;case"settings":s({to:"/dashboard/settings",search:{tab:e.tab,field:e.field},resetScroll:!1})}},m=(0,u.useMemo)(()=>{if(l)return[];let e=rE(n),t=[];for(let s of[...r4,...d]){let a=rP(s.haystack,e);a>0&&t.push({id:s.id,label:s.label,trail:s.trail,icon:s.icon,score:a,onSelect:()=>c(s.target)})}return t.sort((e,t)=>t.score-e.score)},[n,l,d]);return(0,i.jsx)(r$,{open:e,onClose:()=>{t(),r("")},label:"Dashboard search",placeholder:"Search dashboard pages, sections, settingsâ¦",emptyHint:"Enter a page or section to search forâ¦",query:a,onQueryChange:r,isIdle:l,results:m})}let r9="u"<typeof navigator?"":(null==(a=navigator.userAgentData)?void 0:a.platform)||navigator.platform||"",r8=/mac|ios|iphone|ipad|ipod/i.test(r9)?"âK":"Ctrl K",r7="flex items-center rounded-md border border-[--border] bg-[--subtle]/50 hover:bg-[--subtle] text-[--muted] hover:text-[--foreground] transition-colors";function ne(e){let{label:t,onOpen:s}=e,a=tq(),r=!a.isBelowBreakpoint,n=()=>{s(),a.setOpen(!1)};return(0,i.jsx)("div",{className:x("mb-3",r?"flex justify-center":"px-4"),children:r?(0,i.jsxs)(t5,{side:"right",trigger:(0,i.jsx)("button",{type:"button",onClick:n,"aria-label":t,className:x(r7,"w-11 h-10 justify-center"),children:(0,i.jsx)(sm.iyI,{className:"text-base shrink-0"})}),children:[t," (",r8,")"]}):(0,i.jsxs)("button",{type:"button",onClick:n,"aria-label":t,className:x(r7,"w-full h-9 gap-2 px-3 text-sm"),children:[(0,i.jsx)(sm.iyI,{className:"text-base shrink-0"}),(0,i.jsxs)("span",{className:"flex-1 text-left",children:[t,"â¦"]}),(0,i.jsx)("kbd",{className:"font-mono text-xs px-1.5 py-0.5 rounded border border-[--border] bg-[--background] text-[--muted] leading-none",children:r8})]})})}function nt(e){let{label:t,onOpen:s}=e;return(0,i.jsxs)("button",{type:"button",onClick:s,"aria-label":t,className:x(r7,"flex-1 h-9 gap-2 px-3 text-sm truncate"),children:[(0,i.jsx)(sm.iyI,{className:"text-base shrink-0"}),(0,i.jsxs)("span",{className:"flex-1 text-left",children:[t,"â¦"]})]})}function ns(){let{open:e}=sN();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"mb-4 p-4 pb-0 flex flex-col items-center w-full",children:[(0,i.jsx)("img",{src:"/logo.png",alt:"AIOStreams",className:"max-w-[90px] max-h-[60px] object-contain p-4"}),(0,i.jsx)("span",{className:"text-xs text-gray-500 mb-3",children:"Dashboard"})]}),(0,i.jsx)(ne,{label:"Search dashboard",onOpen:e})]})}function na(){let{open:e}=sN();return(0,i.jsx)(nt,{label:"Search dashboard",onOpen:e})}var nr=s(79620),nn=s(49877);let nl={root:(0,c.F)(["UI-Switch__root","peer inline-flex shrink-0 cursor-pointer items-center rounded-full border transition-colors","disabled:cursor-not-allowed data-[disabled=true]:opacity-50","outline-none focus-visible:outline-none focus-visible:ring-1 ring-offset-1 ring-offset-[--background] focus-visible:ring-white/40","data-[state=unchecked]:bg-gray-200 dark:data-[state=unchecked]:bg-gray-900","data-[state=unchecked]:hover:bg-gray-300 dark:data-[state=unchecked]:hover:bg-gray-800","data-[state=checked]:bg-brand","data-[error=true]:border-red-500"],{variants:{size:{sm:"h-[1.02rem] w-8",md:"h-[1.3rem] w-9",lg:"h-7 w-14"}},defaultVariants:{size:"md"}}),container:(0,c.F)(["UI-Switch__container","inline-flex gap-2 items-center"],{variants:{side:{left:"",right:"w-full flex-row-reverse"}},defaultVariants:{side:"left"}}),thumb:(0,c.F)(["UI-Switch__thumb","pointer-events-none block rounded-full data-[state=checked]:bg-white shadow-lg ring-0 transition-transform","data-[state=unchecked]:translate-x-[0.15rem] data-[state=unchecked]:bg-white/50"],{variants:{size:{sm:"h-3 w-3 data-[state=checked]:translate-x-[1.05rem]",md:"h-4 w-4 data-[state=checked]:translate-x-[1.05rem]",lg:"h-5 w-5 data-[state=checked]:translate-x-[1.9rem]"}},defaultVariants:{size:"md"}}),label:(0,c.F)(["UI-Switch__label","relative font-normal text-sm","data-[disabled=true]:text-gray-300 cursor-pointer user-select-none select-none"])},ni=u.forwardRef((e,t)=>
17{let[{size:s,value:a,className:r,onValueChange:n,labelClass:l,containerClass:o,thumbClass:d,defaultValue:c,inputRef:m,side:h,...p},{label:g,moreHelp:f,...b}]=D(e,u.useId()),v=u.useRef(!0),y=u.useRef(null),[j,w]=u.useState(a??c??!1),N=u.useCallback(e=>{w(e),null==n||n(e)},[n]);return u.useEffect(()=>{c&&v.current||w(a),v.current=!1},[a]),(0,i.jsx)(L,{...b,id:b.id,fieldClass:x("w-fit","right"===h&&"w-full group/switch hover:bg-white/5 rounded-[--radius] p-2 w-[calc(100%_+_1rem)] -ml-2"),fieldHelpTextClass:x(""),children:(0,i.jsxs)("div",{className:x(nl.container({side:h}),o),children:[(0,i.jsx)(nn.bL,{ref:tL([y,t]),id:b.id,className:x(nl.root({size:s}),r),disabled:b.disabled||b.readonly,"data-disabled":b.disabled,"data-readonly":b.readonly,"data-error":!!b.error,checked:j,onCheckedChange:N,defaultChecked:c,...p,children:(0,i.jsx)(nn.zi,{className:x(nl.thumb({size:s}),d)})}),(0,i.jsx)("div",{className:"flex flex-1"}),!!g&&(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)("label",{className:x(nl.label(),l,"right"===h&&"font-semibold transition-transform __group-hover/switch:-translate-y-0.5"),htmlFor:b.id,"data-disabled":b.disabled,children:g}),f&&(0,i.jsx)(P,{className:"text-sm",trigger:(0,i.jsx)(I.ExT,{className:"transition-opacity opacity-45 hover:opacity-90"}),children:f})]}),(0,i.jsx)("input",{ref:m,type:"checkbox",name:b.name,className:U,value:j?"on":"off",checked:!b.required||j,"aria-hidden":"true",required:void 0===a&&b.required,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=y.current)?void 0:e.focus()}})]})})});ni.displayName="Switch";var no=s(45748);let nd={root:(0,c.F)(["UI-Select__root","inline-flex items-center justify-between relative whitespace-nowrap truncate"]),chevronIcon:(0,c.F)(["UI-Combobox__chevronIcon","ml-2 h-4 w-4 shrink-0 opacity-50"]),scrollButton:(0,c.F)(["UI-Select__scrollButton","flex items-center justify-center h-[25px] bg-[--paper] text-base cursor-default"]),content:(0,c.F)(["UI-Select__content","w-full overflow-hidden rounded-[--radius] shadow-md bg-[--paper] border leading-none z-50"]),viewport:(0,c.F)(["UI-Select__viewport","p-1 z-10"]),item:(0,c.F)(["UI-Select__item","text-base leading-none rounded-[--radius] flex items-center h-8 pr-2 pl-8 relative","select-none disabled:opacity-50 disabled:pointer-events-none","data-highlighted:outline-none data-highlighted:bg-[--subtle]","data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none"]),checkIcon:(0,c.F)(["UI-Select__checkIcon","absolute left-2 w-4 inline-flex items-center justify-center"])},nc=u.forwardRef((e,t)=>{let[s,a]=D(e,u.useId()),[{size:r,intent:n,leftAddon:l,leftIcon:o,rightAddon:d,rightIcon:c,className:m,placeholder:h,options:p,chevronIconClass:g,scrollButtonClass:f,contentClass:b,viewportClass:v,checkIconClass:y,itemClass:j,dir:w,value:N,onValueChange:k,onOpenChange:S,defaultValue:C,inputRef:_,...A},{inputContainerProps:R,leftAddonProps:T,leftIconProps:I,rightAddonProps:E,rightIconProps:M}]=B({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),P=u.useRef(!0),$=u.useRef(null),[z,K]=u.useState(N??C),H=u.useCallback(e=>{if("__placeholder__"===e){K(""),null==k||k("");return}K(e),null==k||k(e)},[k]);return u.useEffect(()=>{C&&P.current||K(N),P.current=!1},[N]),(0,i.jsx)(L,{...a,children:(0,i.jsxs)(F,{...R,children:[(0,i.jsx)(q,{...T}),(0,i.jsx)(V,{...I}),(0,i.jsxs)(no.bL,{dir:w,value:z,onValueChange:H,onOpenChange:S,defaultValue:C,children:[(0,i.jsxs)(no.l9,{ref:tL([$,t]),id:a.id,className:x(O.root({size:r,intent:n,hasError:!!a.error,
17isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!d,hasRightIcon:!!c,hasLeftAddon:!!l,hasLeftIcon:!!o}),nd.root(),m),"aria-label":a.name||"Select",...A,children:[(0,i.jsx)(no.WT,{placeholder:h}),(0,i.jsx)(no.In,{className:x(!!c&&"hidden"),children:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(nd.chevronIcon(),g),children:(0,i.jsx)("path",{d:"m6 9 6 6 6-6"})})})]}),(0,i.jsx)(no.ZL,{children:(0,i.jsxs)(no.UC,{className:x(nd.content(),b),children:[(0,i.jsx)(no.PP,{className:x(nd.scrollButton(),f),children:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(nd.chevronIcon(),"rotate-180",g),children:(0,i.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,i.jsxs)(no.LM,{className:x(nd.viewport(),v),children:[!!h&&!a.required&&(0,i.jsx)(no.q7,{className:x(nd.item(),j),value:"__placeholder__",children:(0,i.jsx)(no.p4,{className:"flex-none whitespace-nowrap truncate",children:h})}),null==p?void 0:p.map(e=>(0,i.jsxs)(no.q7,{className:x(nd.item(),j),value:e.value,disabled:e.disabled,"data-disabled":e.disabled,children:[(0,i.jsx)(no.p4,{className:"flex-none whitespace-nowrap truncate",children:e.label}),(0,i.jsx)(no.VF,{asChild:!0,children:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(nd.checkIcon(),y),children:(0,i.jsx)("path",{d:"M20 6 9 17l-5-5"})})})]},e.value))]}),(0,i.jsx)(no.wn,{className:x(nd.scrollButton(),f),children:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(nd.chevronIcon(),g),children:(0,i.jsx)("path",{d:"m6 9 6 6 6-6"})})})]})})]}),(0,i.jsxs)("select",{ref:_,name:a.name,className:U,"aria-hidden":"true",required:a.required,disabled:a.disabled,value:z,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=$.current)?void 0:e.focus()},children:[(0,i.jsx)("option",{value:""}),null==p?void 0:p.map(e=>(0,i.jsx)("option",{value:e.value,disabled:e.disabled},e.value))]}),(0,i.jsx)(q,{...E}),(0,i.jsx)(V,{...M})]})})});function nu(e,t){let s={};try{s=JSON.parse(t)}catch{return{seq:e,time:"",level:"info",msg:t,raw:t,obj:{}}}let{level:a,time:r,module:n,msg:l,...i}=s;return{seq:e,time:"string"==typeof r?r:"",level:"string"==typeof a?a:"info",module:"string"==typeof n?n:void 0,msg:"string"==typeof l?l:"",raw:t,obj:i}}function nm(e){let t=new URLSearchParams;return e.q.trim()&&t.set("q",e.q.trim()),e.q.trim()&&e.regex&&t.set("regex","true"),e.levels.length&&t.set("level",e.levels.join(",")),e.module&&t.set("module",e.module),t.toString()}function nh(e,t){let s=nm(e);return`/api/v1/dashboard/logs/export?format=${t}${s?`&${s}`:""}`}function np(e,t){let[s,a]=(0,u.useState)(e);return(0,u.useEffect)(()=>{let s=setTimeout(()=>a(e),t||500);return()=>{clearTimeout(s)}},[e,t]),s}nc.displayName="Select";let nx={initial:{opacity:0,y:60},animate:{opacity:1,y:0},exit:{opacity:0,y:60},transition:{type:"spring",damping:20,stiffness:100}};function ng(e){let{children:t,className:s,...a}=e;return(0,i.jsx)("div",{"data-page-wrapper-container":!0,children:(0,i.jsx)(se.P.div,{"data-page-wrapper":!0,...nx,...a,className:x("z-[5] relative",s),children:t})})}async function nf(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{onSuccess:s,onError:a}=t;if(navigator.clipboard&&navigator.clipboard.writeText)try{await Promise.race([navigator.clipboard.writeText(e),new Promise((e,t)=>setTimeout(()=>t(Error("timed out")),500))]),null==s||s();return}catch(e){}let r=null,n=null,l=null,i=null;try{if(r=function(){var e;let t=document.getSelection();if(!t||0===t.rangeCount)return()=>{};let s=document.activeElement,a=[];for(let e=0;e<t.rangeCount;e++)a.push(t.getRangeAt(e));switch(null==s||null==(e=s.tagName)?void 0:e.toUpperCase()){case"INPUT":case"TEXTAREA":s.blur();break;default:s=null}return t.removeAllRanges(),()=>{"Caret"===t.type&&t.removeAllRanges(),0===t.rangeCount&&a.forEach(e
17=>t.addRange(e)),s&&s.focus()}}(),n=document.createRange(),!(l=document.getSelection()))throw Error("Unable to get document selection");if((i=document.createElement("span")).textContent=e,i.setAttribute("aria-hidden","true"),i.style.all="unset",i.style.position="fixed",i.style.top="0",i.style.clip="rect(0, 0, 0, 0)",i.style.whiteSpace="pre",i.style.userSelect="text",i.style.MozUserSelect="text",i.style.msUserSelect="text",i.style.userSelect="text",i.addEventListener("copy",e=>{e.stopPropagation()}),document.body.appendChild(i),n.selectNodeContents(i),l.addRange(n),!document.execCommand("copy"))throw Error("copy command was unsuccessful")}catch(t){try{window.clipboardData.setData("text",e)}catch(r){let t=(/mac os x/i.test(navigator.userAgent)?"â":"Ctrl")+"+C";window.prompt(`Copy to clipboard: ${t}, Enter`,e);let s=Error("Copy failed - user prompt shown");null==a||a(s);return}}finally{l&&("function"==typeof l.removeRange&&n?l.removeRange(n):l.removeAllRanges()),i&&document.body.removeChild(i),null==r||r()}null==s||s()}let nb=["B","KB","MB","GB","TB","PB"],nv=["bps","Kbps","Mbps","Gbps","Tbps"];function ny(e){let{placeholder:t="â"}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null==e||!Number.isFinite(e))return t;if(0===e)return"0 B";let s=Math.min(nb.length-1,Math.max(0,Math.floor(Math.log(Math.abs(e))/Math.log(1e3))));return`${(e/1e3**s).toFixed(+(0!==s))} ${nb[s]}`}function nj(e,t){return null!=e&&Number.isFinite(e)?`${ny(e,t)}/s`:ny(e,t)}function nw(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Number.isFinite(e)||e<=0)return"0 bps";let s=Math.min(nv.length-1,Math.max(0,Math.floor(Math.log(e)/Math.log(1e3)))),a=e/1e3**s,r=t?Math.round(a):parseFloat(a.toFixed(1));return`${r} ${nv[s]}`}function nN(e){return Number.isFinite(e)?`${(100*e).toFixed(e>0&&e<.001?2:1)}%`:"0%"}let nk=[["w",604800],["d",86400],["h",3600],["m",60],["s",1]];function nS(e){if(!Number.isFinite(e))return"0s";let t=Math.max(0,Math.round(e));if(t<1)return"0s";if(t<60)return`${t}s`;for(let e=0;e<nk.length;e++){let[s,a]=nk[e],r=Math.floor(t/a);if(r>0){let n=t-r*a,l=nk[e+1];if(l&&n>0){let e=Math.floor(n/l[1]);if(e>0)return`${r}${s} ${e}${l[0]}`}return`${r}${s}`}}return"0s"}let nC={ms:1,s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function n_(e){let t,s=e.trim();if(""===s)return null;if(/^-?\d+(\.\d+)?$/.test(s)){let e=Number(s);return Number.isFinite(e)&&e>=0?Math.round(e):null}let a=s.replace(/\s+/g,"").toLowerCase(),r=/(\d+(?:\.\d+)?)(ms|w|d|h|m|s)/g,n=0,l=0;for(;null!==(t=r.exec(a));)n+=parseFloat(t[1])*nC[t[2]],l+=t[0].length;return 0===l||l!==a.length?null:Math.round(n)}function nA(e){if(!Number.isFinite(e)||e<0)return"";if(0===e)return"0ms";if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${parseFloat(t.toFixed(2))}s`;let s=Math.round(t),a=[];for(let[e,t]of[["w",604800],["d",86400],["h",3600],["m",60],["s",1]])s>=t&&(a.push(`${Math.floor(s/t)}${e}`),s%=t);return a.slice(0,2).join(" ")}function nR(e){let t=Math.max(0,Math.floor(e/1e3)),s=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60,n=e=>String(e).padStart(2,"0");return s>0?`${s}:${n(a)}:${n(r)}`:`${a}:${n(r)}`}function nT(e){if(!Number.isFinite(e))return"0";let t=Math.abs(e);if(t<1e3)return e.toLocaleString();for(let s of[{v:1e9,s:"B"},{v:1e6,s:"M"},{v:1e3,s:"K"}])if(t>=s.v){let t=e/s.v,a=+(100>Math.abs(t)),r=t.toFixed(a);return r.endsWith(".0")&&(r=r.slice(0,-2)),r+s.s}return e.toLocaleString()}function nI(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function nE(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),s=Math.max(0,Math.round((t-e)/1e3));return s<1?"just now":s<10?"moments ago":s<60?`${s}s ago`:s<3600?`${Math.round(s/60)}m ago`:s<86400?`${Math.round(s/3600)}h ago`:`${Math.round(s/86400)}d ago`}let nM=["trace","debug","info","warn","error","fatal"],nP={trace:"text-[--muted]",debug:"text-sky-500",info:"text-emerald-500",warn:"text-amber-500",error:"text-red-400",fatal:"text-red-400 font-bold"},n$={trace:"bg-gray-400",debug:"bg-sky-500",info:"bg-emerald-500",warn:"bg-amber-500",error:"bg-red-400",fatal:"bg-red-400"},nD="__all__",nL="aiostreams.logs.prefs";function nO(){try{let e=localStorage.getItem(nL);if(e)return{...nU,...JSON.parse(e)}}catch{}return nU}let nU={autoscroll:!0,wrap:!1,levels:[]};function nF(e){let{row:t,wrap:s,expanded:a,onToggle:r}=e,n=nI(t.time),l=Object.keys(t.obj).length>0,[o,d]=(0,u.useState)(!1),c=a?JSON.stringify(JSON.parse(t.raw)):[n,t.level,t.module?`[${t.module}]`:"",t.msg,l?Object.entries(t.obj).map(e=>{let[t,s]=e;return`${t}=${"object"==typeof s?JSON.stringify(s):s}`}
17).join(" "):""].filter(Boolean).join(" ");return(0,i.jsxs)("div",{className:x("relative px-3 py-1.5 border-b border-[--border] cursor-pointer hover:bg-[--subtle] font-mono text-xs leading-relaxed group",s?"whitespace-pre-wrap break-words":"whitespace-pre"),onClick:r,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[(0,i.jsx)("span",{className:"inline-block px-2 py-0.5 rounded-full bg-brand/15 text-brand font-medium tabular-nums",children:n})," ",(0,i.jsx)("span",{className:x("inline-block w-2 h-2 rounded-full align-middle",n$[t.level]??"bg-[--muted]"),title:t.level})," ",t.module&&(0,i.jsxs)("span",{className:"text-[--muted-highlight]",children:["[",t.module,"]"]})," ",(0,i.jsx)("span",{className:"text-[--foreground]",children:t.msg}),l&&!a&&(0,i.jsxs)("span",{className:"text-[--muted]",children:[" ",Object.entries(t.obj).map(e=>{let[t,s]=e;return`${t}=${"object"==typeof s?"{â¦}":s}`}).join(" ")]}),a&&(0,i.jsx)("pre",{className:"mt-1 p-2 rounded bg-[--subtle] text-[--foreground] whitespace-pre-wrap break-all",children:JSON.stringify(JSON.parse(t.raw),null,2)}),o&&(0,i.jsx)("button",{type:"button","aria-label":"Copy log line",className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded text-[--muted] hover:text-[--foreground] hover:bg-[--paper] transition-colors",onClick:e=>{e.stopPropagation(),nf(c,{onSuccess:()=>m.oR.success("Copied log line"),onError(e){m.oR.error("Failed to copy: "+e),console.error("Failed to copy log line:",e)}})},children:(0,i.jsx)(sm.Xpf,{className:"text-sm"})})]})}var nz=s(90730),nV=s(89623),nq=s(82436),nB=s(53366),nK=s(33017);let nH={root:(0,c.F)(["UI-Tabs__root"]),list:(0,c.F)(["UI-Tabs__list","inline-flex h-12 items-center justify-center w-full"]),trigger:(0,c.F)(["UI-Tabs__trigger appearance-none shadow-none","inline-flex h-full items-center justify-center whitespace-nowrap px-3 py-1.5 text-sm text-[--muted] font-medium ring-offset-[--background]","transition-all focus-visible:outline-none focus-visible:ring-1 ring-offset-1 ring-offset-[--background] focus-visible:ring-white/40","disabled:pointer-events-none disabled:opacity-50","border-transparent border-b-2 -mb-px","data-[state=active]:border-[--brand] data-[state=active]:text-[--foreground]"]),content:(0,c.F)(["UI-Tabs__content","ring-offset-[--background]","focus-visible:outline-none focus-visible:ring-1 ring-offset-1 ring-offset-[--background] focus-visible:ring-white/40"])},nW=u.createContext({}),nG=u.forwardRef((e,t)=>{let{className:s,listClass:a,triggerClass:r,contentClass:n,variant:l="underline",indicatorClass:o,animated:d=!0,value:c,defaultValue:m,onValueChange:h,...p}=e,[g,f]=u.useState(c??m);u.useEffect(()=>{void 0!==c&&f(c)},[c]);let b=u.useCallback(e=>{void 0===c&&f(e),null==h||h(e)},[h,c]),v=u.useId(),y=u.useMemo(()=>d?`tab-indicator-${v.replace(/:/g,"")}`:void 0,[v,d]);return(0,i.jsx)(nW.Provider,{value:{listClass:a,triggerClass:r,contentClass:n,activeTab:g,layoutId:y,variant:l,indicatorClass:o},children:(0,i.jsx)(nB.bL,{ref:t,value:c,defaultValue:m,onValueChange:b,className:x(nH.root(),s),...p})})});nG.displayName="Tabs";let nY=u.forwardRef((e,t)=>{let{className:s,...a}=e,{listClass:r}=u.useContext(nW);return(0,i.jsx)(nB.B8,{ref:t,className:x(nH.list(),r,s),...a}
17)});nY.displayName="TabsList";let nJ=u.forwardRef((e,t)=>{let{className:s,children:a,...r}=e,{triggerClass:n,activeTab:l,layoutId:o,variant:d,indicatorClass:c}=u.useContext(nW),m=(0,nK.I)(),h=l===r.value,p=!m&&!!o,g=p?"pill"===d?"data-[state=active]:bg-transparent":"data-[state=active]:border-transparent":"";return(0,i.jsxs)(nB.l9,{ref:t,className:x(nH.trigger(),n,s,g,p&&"relative z-0"),...r,children:[a,p&&h&&(0,i.jsx)(se.P.span,{layoutId:o,transition:{type:"spring",stiffness:500,damping:38},className:x("pill"===d?"absolute inset-0 -z-10 rounded-[inherit] bg-[--subtle]":"absolute bottom-0 left-0 right-0 h-0.5 bg-[--brand]",c)})]})});nJ.displayName="TabsTrigger";let nZ=u.forwardRef((e,t)=>{let{className:s,...a}=e,{contentClass:r}=u.useContext(nW);return(0,i.jsx)(nB.UC,{ref:t,className:x(nH.content(),r,s),...a})});nZ.displayName="TabsContent";let nQ={root:(0,c.F)(["UI-StaticTabs__root","flex w-full overflow-hidden overflow-x-auto gap-2 py-1"]),trigger:(0,c.F)(["UI-StaticTabs__trigger","group/staticTabs__trigger inline-flex flex-none shrink-0 basis-auto items-center font-medium text-sm transition outline-none min-w-0 justify-center","text-[--muted] hover:text-[--foreground]","h-10 px-4 rounded-xl border border-transparent","data-[current=true]:font-semibold data-[current=true]:text-white","focus-visible:bg-[--subtle]"]),icon:(0,c.F)(["UI-StaticTabs__icon","-ml-0.5 mr-2 h-4 w-4"])},nX=u.forwardRef((e,t)=>{let{children:s,className:a,triggerClass:r,iconClass:n,items:l,pillClass:o,...d}=e,c=(0,nK.I)(),m=u.useId(),h=`static-tab-indicator-${m.replace(/:/g,"")}`,p=!c,g=e=>p&&e?(0,i.jsx)(se.P.span,{layoutId:h,transition:{type:"spring",stiffness:500,damping:38},className:x("absolute inset-0 -z-10 rounded-[inherit] bg-[--subtle]",o)}):null;return(0,i.jsx)("nav",{ref:t,className:x(nQ.root(),a),role:"navigation",...d,children:l.map(e=>e.href?(0,i.jsxs)("a",{href:e.href??"#",className:x("cursor-pointer",nQ.trigger(),r,p?"relative z-0":"data-[current=true]:bg-[--subtle]"),"aria-current":e.isCurrent?"page":void 0,"data-current":e.isCurrent,children:[g(!!e.isCurrent),e.iconType&&(0,i.jsx)(e.iconType,{className:x(nQ.icon(),n),"aria-hidden":"true","data-current":e.isCurrent}),(0,i.jsx)("span",{children:e.name})]},e.name):(0,i.jsxs)("div",{className:x(nQ.trigger(),"cursor-pointer",r,p?"relative z-0":"data-[current=true]:bg-[--subtle]"),"aria-current":e.isCurrent?"page":void 0,"data-current":e.isCurrent,onClick:e.onClick,children:[g(!!e.isCurrent),e.iconType&&(0,i.jsx)(e.iconType,{className:x(nQ.icon(),n),"aria-hidden":"true","data-current":e.isCurrent}),(0,i.jsx)("span",{children:e.name})]},e.name))})});nX.displayName="StaticTabs";var n0=s(52979);function n1(e){return Object.fromEntries(Object.entries(e.shape).map(e=>{let[t,s]=e;return s instanceof nV.Xi?[t,s.parse(void 0)]:[t,void 0]}))}let n2=u.createContext(void 0),n3=e=>{let{mode:t="onSubmit",resolver:s,reValidateMode:a,shouldFocusError:r,shouldUnregister:n,shouldUseNativeValidation:l,criteriaMode:o,delayError:d,schema:c,defaultValues:m,onChange:h,onSubmit:p,onError:g,formRef:f,children:b,mRef:v,stackClass:y,...j}=e,w=u.useMemo(()=>{if(!(tO(n1(c))&&tO(m)))return{...n1(c),...m}},[]),N=(0,nq.mN)({mode:t,resolver:(0,n0.u)(c),defaultValues:w,reValidateMode:a,shouldFocusError:r,shouldUnregister:n,shouldUseNativeValidation:l,criteriaMode:o,delayError:d}),{handleSubmit:k}=N;return u.useImperativeHandle(v,()=>N,[v,N]),u.useEffect(()=>{let e;return h&&(e=N.watch(h)),()=>null==e?void 0:e.unsubscribe()},[N,h]),(0,i.jsx)(nq.Op,{...N,children:(0,i.jsx)(n2.Provider,{value:{schema:c,shape:c.shape},children:(0,i.jsx)("form",{ref:f,onSubmit:k(p,g),...j,children:(0,i.jsx)("div",{className:x("w-full space-y-3",y),children:function(e){for(var t=arguments.length,s=Array(t>1?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];return"function"==typeof e?e(...s):e}(b,N)})})})})};n3.displayName="Form";var n5=s(5070),n4=s(27680),n6=s(55807);let n9={root:(0,c.F)(["UI-Autocomplete__root"]),popover:(0,c.F)(["UI-Autocomplete__popover","w-[--radix-popover-trigger-width] p-0"]),checkIcon:(0,c.F)(["UI-Autocomplete__checkIcon","h-4 w-4","data-[selected=true]:opacity-100 data-[selected=false]:opacity-0"]),container:(0,c.F)(["UI-Autocomplete__container","relative w-full"]),command:(0,c.F)(["UI-Autocomplete__command","focus-within:ring-2 ring-[--ring] transition"])},n8=u.forwardRef((e,t)=>
17{let[s,a]=D(e,u.useId()),[{size:r,intent:n,leftAddon:l,leftIcon:o,rightAddon:d,rightIcon:c,className:m,popoverClass:h,checkIconClass:p,containerClass:g,commandClass:f,commandProps:b,options:v,emptyMessage:y,placeholder:j,value:w,onValueChange:N,onTextChange:k,onChange:S,defaultValue:C,autoFilter:_=!0,isFetching:A,type:R,...T},{inputContainerProps:I,leftAddonProps:E,leftIconProps:M,rightAddonProps:$,rightIconProps:z}]=B({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),K=u.useRef(!0),H=u.useRef(!1),W=u.useRef((null==w?void 0:w.label)||(null==C?void 0:C.label)||""),[G,Y]=u.useState((null==w?void 0:w.label)||(null==C?void 0:C.label)||""),J=u.useDeferredValue(G);W.current=G;let Z=u.useRef(w||C||void 0),[Q,X]=u.useState(w||C||void 0),[ee,et]=u.useState(!1),es=u.useMemo(()=>_?v.filter(e=>e.label.toLowerCase().includes(J.toLowerCase())):v,[_,v,J]),ea=!!y||v.length>0&&es.length>0,er=u.useCallback((e,t)=>e.toLowerCase()===t.toLowerCase(),[]),en=u.useRef(null),el=u.useRef(null);u.useEffect(()=>{H.current||(C&&K.current||(Y((null==w?void 0:w.label)??""),X(w),eu(w)),K.current=!1)},[w]);let ei=u.useCallback(e=>{a.disabled||a.readonly||0===v.length&&e||(W.current!==G||!e||0!==es.length)&&(et(e),e||u.startTransition(()=>{var e;null==(e=en.current)||e.focus()}))},[v,G,a.disabled,a.readonly]),eo=u.useCallback(e=>{H.current=!0,null==S||S(e),Y(e.target.value),_&&es.length>0&&et(!0)},[es]);u.useEffect(()=>{let e=v.find(e=>er(e.label,J));e?ed(e):J.length>0?ed({value:null,label:J}):0===J.length&&ed(void 0),H.current=!1},[J,_]);let ed=u.useCallback(e=>{X(e),null==N||N(e),null==k||k((null==e?void 0:e.label)??""),eu(e)},[N,k]),ec=u.useCallback(e=>{if(ee||et(!0),"ArrowDown"===e.key){var t;e.preventDefault(),null==(t=el.current)||t.focus()}},[ee]),eu=u.useCallback(e=>{((null==e?void 0:e.value)||void 0===e)&&(Z.current=e)},[]),em=u.useCallback(()=>{"options"===R&&u.startTransition(()=>{Z.current?Y(Z.current.label):Y("")})},[]);return(0,i.jsx)(L,{...a,children:(0,i.jsxs)(F,{...I,children:[(0,i.jsx)(q,{...E}),(0,i.jsx)(V,{...M}),(0,i.jsx)(P,{open:ee&&ea,onOpenChange:ei,className:x(n9.popover(),h),onOpenAutoFocus:e=>e.preventDefault(),trigger:(0,i.jsx)("div",{className:x(n9.container(),g),children:(0,i.jsx)("input",{ref:tL([en,t]),id:a.id,name:a.name,value:G,onChange:eo,onBlur:em,placeholder:j,className:x(O.root({size:r,intent:n,hasError:!!a.error,
17isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!d,hasRightIcon:!!c,hasLeftAddon:!!l,hasLeftIcon:!!o}),n9.root()),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-error":!!a.error,"aria-readonly":a.readonly,"data-readonly":a.readonly,onKeyDown:ec,required:a.required,...T})}),children:(0,i.jsxs)(sA,{className:x(n9.command(),f),inputContainerClass:"py-1",shouldFilter:_,...b,children:[A&&G.length>0&&(0,i.jsx)("div",{className:"w-full absolute top-0 left-0 px-1",children:(0,i.jsx)("div",{className:"h-1 w-full bg-[--subtle] overflow-hidden relative rounded-full",children:(0,i.jsx)("div",{className:"animate-indeterminate-progress absolute left-0 w-full h-full bg-brand origin-left-right"})})}),(0,i.jsx)(sR,{value:G,onValueChange:Y,inputContainerClass:U,"aria-hidden":"true",ref:el}),(0,i.jsxs)(sT,{children:[!!y&&(0,i.jsx)(sI,{children:y}),(0,i.jsx)(sE,{children:v.map(e=>(0,i.jsx)(sM,{value:e.label,onSelect:e=>{let t=v.find(t=>er(t.label,e));t&&((null==Q?void 0:Q.value)===t.value?(ed(void 0),Y("")):(ed(t),Y(t.label))),u.startTransition(()=>{var e;null==(e=en.current)||e.focus()})},leftIcon:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(n9.checkIcon(),p),"data-selected":er(e.label,G),children:(0,i.jsx)("path",{d:"M20 6 9 17l-5-5"})}),children:e.label},e.value))})]})]})}),(0,i.jsx)(q,{...$}),(0,i.jsx)(V,{...z})]})})});n8.displayName="Autocomplete";var n7=s(10251);let le={container:(0,c.F)("UI-Checkbox__container inline-flex gap-2 items-center"),root:(0,c.F)(["UI-Checkbox__root","appearance-none peer block relative overflow-hidden transition h-5 w-5 shrink-0 text-white rounded-[--radius-md] ring-offset-1 border ring-offset-[--background]","border-gray-300 dark:border-gray-700","outline-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/40 disabled:cursor-not-allowed data-[disabled=true]:opacity-50","data-[state=unchecked]:bg-white dark:data-[state=unchecked]:bg-gray-700","data-[state=unchecked]:hover:bg-gray-100 dark:data-[state=unchecked]:hover:bg-gray-600","data-[state=checked]:bg-brand dark:data-[state=checked]:bg-brand data-[state=checked]:border-brand","data-[state=indeterminate]:bg-[--muted] dark:data-[state=indeterminate]:bg-gray-700 data-[state=indeterminate]:text-white data-[state=indeterminate]:border-transparent","data-[error=true]:border-red-500 data-[error=true]:dark:border-red-500 data-[error=true]:data-[state=checked]:border-red-500 data-[error=true]:dark:data-[state=checked]:border-red-500"],{variants:{size:{sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"}},defaultVariants:{size:"md"}}),label:(0,c.F)(["UI-Checkbox__label","font-normal","data-[disabled=true]:opacity-50"],{variants:{size:{sm:"text-sm",md:"text-md",lg:"text-lg"}},defaultVariants:{size:"md"}}),indicator:(0,c.F)(["UI-Checkbox__indicator","flex h-full w-full items-center justify-center relative"]),checkIcon:(0,c.F)("UI-Checkbox__checkIcon absolute",{variants:{size:{sm:"h-3 w-3",md:"h-4 w-4",lg:"h-5 w-5"}},defaultVariants:{size:"md"}})},lt=u.forwardRef((e,t)=>{let[{className:s,hideError:a,containerClass:r,checkIconClass:n,labelClass:l,indicatorClass:o,onValueChange:d,defaultValue:c,value:m,size:h,inputRef:p,...g},{label:f,...b}]=D(e,u.useId()),v=u.useContext(ls),y=(null==v?void 0:v.group_size)??h,j=u.useRef(!0),w=u.useRef(null),[N,k]=u.useState(m??c??!1),S=u.useCallback(e=>{k(e),null==d||d(e)},[d]);return u.useEffect(()=>{c&&j.current||k(m??!1),j.current=!1},[m]),(0,i.jsx)(L,{fieldClass:"flex gap-2",...b,error:a?void 0:b.error,children:(0,i.jsxs)("label",{className:x(le.container(),r),htmlFor:b.id,children:[(0,i.jsx)(n7.bL,{ref:tL([w,t]),id:b.id,className:x(le.root({size:y}),s),disabled:b.disabled||b.readonly,"data-error":!!b.error,"data-disabled":b.disabled,"aria-readonly":b.readonly,"data-readonly":b.readonly,checked:N,onCheckedChange:S,...g,children:(0,i.jsxs)(n7.P7,{className:x(le.indicator(),o),children:["indeterminate"!==N&&(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",stroke:"currentColor",fill:"
17currentColor",className:x(le.checkIcon({size:y}),n),children:(0,i.jsx)("path",{d:"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"})}),"indeterminate"===N&&(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",className:x(le.checkIcon({size:y}),n),children:(0,i.jsx)("line",{x1:"5",x2:"19",y1:"12",y2:"12"})})]})}),!!f&&(0,i.jsx)("label",{className:x(le.label({size:y}),l),htmlFor:b.id,"data-disabled":b.disabled,"data-checked":!0===N,children:f}),(0,i.jsx)("input",{ref:p,type:"checkbox",name:b.name,className:U,value:"indeterminate"===N?"indeterminate":N?"on":"off",checked:!b.required||!0===N,"aria-hidden":"true",required:void 0===m&&b.required,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=w.current)?void 0:e.focus()}})]})})});lt.displayName="Checkbox";let ls=u.createContext(null),la=u.forwardRef((e,t)=>{let[{value:s,defaultValue:a=[],onValueChange:r,stackClass:n,itemLabelClass:l,itemClass:o,itemContainerClass:d,itemCheckIconClass:c,options:m,size:h},p]=D(e,u.useId()),[g,f]=u.useState(s??a),b=u.useCallback(e=>t=>{f(s=>{let a=!0===t?[...s,...s.includes(e)?[]:[e]]:!1===t?s.filter(t=>t!==e):[...s];return null==r||r(a),a})},[r]);return u.useEffect(()=>{void 0!==s&&f(s)},[s]),(0,i.jsx)(ls.Provider,{value:{group_size:h},children:(0,i.jsxs)(L,{...p,children:[(0,i.jsx)("div",{className:x("UI-CheckboxGroup__stack space-y-1",n),children:m.map(e=>(0,i.jsx)(lt,{label:e.label,value:g.includes(e.value),onValueChange:b(e.value),hideError:!0,error:p.error,className:o,labelClass:l,containerClass:x("flex w-fit",d),checkIconClass:c,disabled:p.disabled||e.disabled,readonly:p.readonly||e.readonly,tabIndex:0},e.value))}),(0,i.jsx)("input",{ref:t,type:"text",id:p.name,name:p.name,className:U,value:p.required?g.length?JSON.stringify(g):"":JSON.stringify(g),"aria-hidden":"true",required:p.required,tabIndex:-1,onChange:()=>{}})]})})});la.displayName="CheckboxGroup";var lr=s(67371),ln=s.n(lr);let ll={root:(0,c.F)(["UI-Combobox__root","justify-between h-auto"],{variants:{size:{sm:"min-h-8 px-2 py-1 text-sm",md:"min-h-10 px-3 py-2 ",lg:"min-h-12 px-4 py-3 text-md"}},defaultVariants:{size:"md"}}),popover:(0,c.F)(["UI-Combobox__popover","w-[--radix-popover-trigger-width] p-0"]),checkIcon:(0,c.F)(["UI-Combobox__checkIcon","h-4 w-4","data-[selected=true]:opacity-100 data-[selected=false]:opacity-0"]),item:(0,c.F)(["UI-Combobox__item","flex gap-1 items-center flex-none truncate bg-gray-100 dark:bg-gray-800 px-2 pr-1 rounded-[--radius] max-w-96"]),placeholder:(0,c.F)(["UI-Combobox__placeholder","text-[--muted] truncate"]),inputValuesContainer:(0,c.F)(["UI-Combobox__inputValuesContainer","grow flex overflow-hidden gap-2 flex-wrap"]),chevronIcon:(0,c.F)(["UI-Combobox__chevronIcon","ml-2 h-4 w-4 shrink-0 opacity-50"]),removeItemButton:(0,c.F)(["UI-Badge__removeItemButton","text-lg cursor-pointer transition ease-in hover:opacity-60"])},li=u.forwardRef((e,t)=>{let[s,a]=D(e,u.useId()),[{size:r,intent:n,leftAddon:l,leftIcon:o,rightAddon:d,rightIcon:c,className:m,popoverClass:h,checkIconClass:p,itemClass:g,placeholderClass:f,inputValuesContainerClass:b,chevronIconClass:v,removeItemButtonClass:y,commandProps:j,options:w,emptyMessage:N,placeholder:k,value:S,onValueChange:C,onTextChange:_,multiple:A=!1,defaultValue:R,inputRef:T,keepOpenOnSelect:I=!0,maxItems:E,maxDisplayedItems:M,...$},{inputContainerProps:z,leftAddonProps:K,leftIconProps:H,rightAddonProps:W,rightIconProps:G}]=B({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),Y=u.useRef(null),J=u.useRef(S||R||[]),[Z,Q]=u.useState(S||R||[]),[X,ee]=u.useState(!1),et=u.useCallback(e=>{Q(e),J.current=e},[]);u.useEffect(()=>{void 0===S||ln()(S,J.current)||et(S)},[S]);let es=e=>{et(e),null==C||C(e)},ea={},er=w.map(e=>{var t,s;let a=(null==(t=e.textValue||e.value)?void 0:t.trim())||"Unnamed",r="string"==typeof e.label?(null==(s=e.label)?void 0:s.trim())||"Unnamed":e.label;return ea[a]=(ea[a]||0)+1,{...e,label:ea[a]>1?`${r} (${ea[a]})`:r,textValue:ea[a]>1?`${a} (${ea[a]})`:a}}),en=er.filter(e=>Z.includes(e.value)),el=A&&"number"==typeof E&&Z.length>=E,ei=A&&"number"==typeof M?en.slice(0,Math.max(0,M)):en,eo=en.length-ei.length,ed=Z.length&&en.length?A?(0,i.jsxs)(i.Fragment,{children:[ei.map(e=>(0,i.jsxs)("div",{className:x(ll.item(),g),children:[(0,i.jsx)("span",{className:"truncate",children:e.textValue||e.value}),(0,i.jsx)("span",{className:x(ll.removeItemButton(),"rounded-full",y),onClick:t=>{t.preventDefault(),es(Z.filter(t=>t!==e.value)),ee(!1)},children:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor",children:(0,i.jsx)("path",{d:"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"})})})]},e.value)),eo>0&&(0,i.jsxs)("div",{className:x(ll.item(),"text-[--muted] pr-2",g),children:["+",eo," more"]})]}):(0,i.jsx)("span",{className:"truncate",children:en[0].label}):(0,i.jsx)("span",{className:x(ll.placeholder(),f),children:k});return(0,i.jsx)(L,{...a,children:(0,i.jsxs)(F,{...z,children:[(0,i.jsx)(q,{...
17K}),(0,i.jsx)(V,{...H}),(0,i.jsx)(P,{open:X,onOpenChange:ee,className:x(ll.popover(),h),trigger:(0,i.jsxs)("button",{ref:tL([Y,t]),id:a.id,role:"combobox","aria-expanded":X,className:x(O.root({size:r,intent:n,hasError:!!a.error,isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!d,hasRightIcon:!!c,hasLeftAddon:!!l,hasLeftIcon:!!o}),ll.root({size:r})),...$,children:[(0,i.jsx)("div",{className:x(ll.inputValuesContainer()),children:ed}),(0,i.jsxs)("div",{className:"flex items-center",children:[!!Z.length&&!!en.length&&!A&&(0,i.jsx)("span",{className:x(ll.removeItemButton(),y),onClick:e=>{e.preventDefault(),es([]),ee(I)},children:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor",children:(0,i.jsx)("path",{d:"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"})})}),(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(ll.chevronIcon(),v),children:[(0,i.jsx)("path",{d:"m7 15 5 5 5-5"}),(0,i.jsx)("path",{d:"m7 9 5-5 5 5"})]})]})]}),children:(0,i.jsxs)(sA,{inputContainerClass:"py-1",...j,children:[(0,i.jsx)(sR,{placeholder:k,onValueChange:_}),(0,i.jsxs)(sT,{children:[(0,i.jsx)(sI,{children:N}),(0,i.jsx)(sE,{children:er.map(e=>{let t=el&&!Z.includes(e.value);return(0,i.jsx)(sM,{value:e.textValue||e.value,disabled:t,className:x(t&&"opacity-50 cursor-not-allowed pointer-events-none"),onSelect:e=>{let t=er.find(t=>(t.textValue||t.value).toLowerCase()===e.toLowerCase());t&&(A?es(Z.includes(t.value)?Z.filter(e=>e!==t.value):[...Z,t.value]):es(Z.includes(t.value)?[]:[t.value])),ee(I)},leftIcon:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(ll.checkIcon(),p),"data-selected":Z.includes(e.value),children:(0,i.jsx)("path",{d:"M20 6 9 17l-5-5"})}),children:e.label},e.value)})})]})]})}),(0,i.jsx)("input",{ref:T,type:"text",name:a.name,className:U,value:a.required?Z.length?JSON.stringify(Z):"":JSON.stringify(Z),"aria-hidden":"true",required:a.required,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=Y.current)?void 0:e.focus()}}),(0,i.jsx)(q,{...W}),(0,i.jsx)(V,{...G})]})})});li.displayName="Combobox";let lo=u.forwardRef((e,t)=>{let[s,a]=D(e,u.useId()),[{size:r,intent:n,leftAddon:l,leftIcon:o,rightAddon:d,rightIcon:c,className:m,placeholder:h,options:p,...g},{inputContainerProps:f,leftAddonProps:b,leftIconProps:v,rightAddonProps:y,rightIconProps:j}]=B({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon});return(0,i.jsx)(L,{...a,children:(0,i.jsxs)(F,{...f,children:[(0,i.jsx)(q,{...b}),(0,i.jsx)(V,{...v}),(0,i.jsxs)("select",{id:a.id,name:a.name,className:x("form-select",O.root({size:r,intent:n,hasError:!!a.error,
17isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!d,hasRightIcon:!!c,hasLeftAddon:!!l,hasLeftIcon:!!o}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,...g,ref:t,children:[h&&(0,i.jsx)("option",{value:"",children:h}),null==p?void 0:p.map(e=>(0,i.jsx)("option",{value:e.value,children:e.label??e.value},e.value))]}),(0,i.jsx)(q,{...y}),(0,i.jsx)(V,{...j,className:x(j.className,d?null:"mr-8")})]})})});lo.displayName="NativeSelect";var ld=s(63121),lc=s(82523);let lu={root:(0,c.F)(["UI-NumberInput__root","z-[2]"],{variants:{hideControls:{true:!1,false:"border-r border-r-transparent hover:border-r-[--border]"},size:{sm:null,md:null,lg:null},intent:{basic:null,filled:null,unstyled:"border-r-0 hover:border-r-transparent"}},defaultVariants:{hideControls:!1}}),control:(0,c.F)(["UI-NumberInput__control","rounded-none h-[50%] ring-inset"]),controlsContainer:(0,c.F)(["UI-NumberInput__controlsContainer","form-input w-auto p-0 flex flex-col items-stretch justify-center overflow-hidden max-h-full","border-l-0 relative z-[1]","shadow-xs"],{variants:{size:{sm:"h-8",md:"h-10",lg:"h-12"},intent:{basic:null,filled:"hover:bg-gray-100",unstyled:null},hasRightAddon:{true:"border-r-0",false:null}}}),chevronIcon:(0,c.F)(["UI-Combobox__chevronIcon","h-4 w-4 shrink-0"])},lm=u.forwardRef((e,t)=>{let[s,a]=D(e,u.useId()),[{controlClass:r,controlsContainerClass:n,chevronIconClass:l,className:o,children:d,size:c,intent:m,leftAddon:h,leftIcon:p,rightAddon:g,rightIcon:f,placeholder:b,onValueChange:v,hideControls:y,value:j,min:N=0,max:k,step:S,allowMouseWheel:C=!0,formatOptions:_={maximumFractionDigits:2},clampValueOnBlur:A=!0,allowEmpty:R=!1,translations:T,locale:I,dir:E,defaultValue:M,...P},{inputContainerProps:$,leftAddonProps:U,leftIconProps:z,rightAddonProps:K,rightIconProps:H}]=B({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),W=null==j||""===j,G=(0,lc.zl)(ld.Aq,{id:a.id,name:a.name,disabled:a.disabled,readOnly:a.readonly,value:R&&W?"":null!=j?String(j):null!=M?String(M):void 0,min:N,max:k,step:S,allowMouseWheel:C,formatOptions:_,clampValueOnBlur:!R&&A,translations:T,locale:I,dir:E,onValueChange:e=>{(W||""===e.value||e.valueAsNumber!==Number(j))&&(null==v||v(e.valueAsNumber,e.value))}}),Y=ld.Ng(G,lc._B),J=u.useRef(!0);return u.useEffect(()=>{J.current||(R&&W?Y.clearValue():"string"!=typeof j||isNaN(Number(j))?"number"==typeof j?Y.setValue(j):void 0===j&&Y.setValue(N):Y.setValue(Number(j))),J.current=!1},[j]),(0,i.jsx)(L,{...a,id:Y.getInputProps().id,children:(0,i.jsxs)(F,{...$,children:[(0,i.jsx)(q,{...U}),(0,i.jsx)(V,{...z}),(0,i.jsx)("input",{ref:t,type:"number",name:a.name,className:x("form-input",O.root({size:c,intent:m,hasError:!!a.error,
17isDisabled:!!a.disabled,hasRightAddon:!!g||!y,hasRightIcon:!!f,hasLeftAddon:!!h,hasLeftIcon:!!p}),lu.root({hideControls:y,intent:m,size:c}),o),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,...Y.getInputProps(),...P,placeholder:b}),!y&&(0,i.jsxs)("div",{className:x(O.root({size:c,intent:m,hasError:!!a.error,isDisabled:!!a.disabled,hasRightAddon:!!g,hasRightIcon:!!f,hasLeftAddon:!0}),lu.controlsContainer({size:c,intent:m,hasRightAddon:!!g}),n),children:[(0,i.jsx)(w,{intent:"gray-basic",size:"sm",className:x(lu.control(),r),...Y.getIncrementTriggerProps(),"data-readonly":a.readonly,"data-disabled":a.disabled||Y.getIncrementTriggerProps().disabled,disabled:a.disabled||a.readonly||Y.getIncrementTriggerProps().disabled,tabIndex:0,icon:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(lu.chevronIcon(),"rotate-180",l),children:(0,i.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,i.jsx)(w,{intent:"gray-basic",size:"sm",className:x(lu.control(),r),...Y.getDecrementTriggerProps(),"data-readonly":a.readonly,"data-disabled":a.disabled||Y.getDecrementTriggerProps().disabled,disabled:a.disabled||a.readonly||Y.getDecrementTriggerProps().disabled,tabIndex:0,icon:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(lu.chevronIcon(),l),children:(0,i.jsx)("path",{d:"m6 9 6 6 6-6"})})})]}),(0,i.jsx)(q,{...K}),(0,i.jsx)(V,{...H,className:x("z-3",H.className,g?null:"mr-6")})]})})});lm.displayName="NumberInput";var lh=s(37403);let lp={root:(0,c.F)(["UI-RadioGroup__root"]),item:(0,c.F)(["UI-RadioGroup__item","block aspect-square rounded-full border text-brand ring-offset-1 ring-offset-[--background]","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/40","disabled:cursor-not-allowed data-[disabled=true]:opacity-50 data-[readonly=true]:cursor-not-allowed","data-[state=unchecked]:bg-white dark:data-[state=unchecked]:bg-gray-700","data-[state=unchecked]:hover:bg-gray-100 dark:data-[state=unchecked]:hover:bg-gray-600","data-[state=checked]:bg-brand data-[state=checked]:border-transparent","data-[error=true]:border-red-500 data-[error=true]:dark:border-red-500 data-[error=true]:data-[state=checked]:border-red-500 data-[error=true]:dark:data-[state=checked]:border-red-500"],{variants:{size:{sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"}},defaultVariants:{size:"md"}}),itemIndicator:(0,c.F)(["UI-RadioGroup__itemIndicator","flex items-center justify-center"]),itemLabel:(0,c.F)(["UI-RadioGroup__itemLabel","font-normal block","data-[disabled=true]:opacity-50"],{variants:{size:{md:"text-md",lg:"text-lg"}},defaultVariants:{size:"md"}}),itemContainer:(0,c.F)(["UI-RadioGroup__itemContainer","flex gap-2 items-center relative"]),itemCheckIcon:(0,c.F)(["UI-RadioGroup__itemCheckIcon","text-white"],{variants:{size:{sm:"h-4 w-4",md:"h-4 w-4",lg:"h-5 w-5"}},defaultVariants:{size:"md"}})},lx=u.forwardRef((e,t)=>{let s=u.useId(),[{size:a,className:r,stackClass:n,value:l,onValueChange:o,options:d,inputRef:c,defaultValue:m,itemClass:h,itemIndicatorClass:p,itemLabelClass:g,itemContainerClass:f,itemCheckIcon:b,itemCheckIconClass:v},y]=D(e,s),j=u.useRef(!0),w=u.useRef(null),[N,k]=u.useState(l??m),S=u.useCallback(e=>{k(e),null==o||o(e)},[o]);return u.useEffect(()=>{m&&j.current||k(l),j.current=!1},[l]),(0,i.jsxs)(L,{...y,children:[(0,i.jsx)(lh.bL,{value:N,onValueChange:S,defaultValue:m,className:x(lp.root(),r),disabled:y.disabled||y.readonly,"data-error":!!y.error,"data-disabled":y.disabled,"data-readonly":y.readonly,"aria-readonly":y.readonly,loop:!0,children:(0,i.jsx)("div",{className:x("UI-RadioGroup__stack space-y-1",n),children:d.map(e=>(0,i.jsxs)("label",{className:x(lp.itemContainer(),f),htmlFor:s+e.value,"data-error":!!y.error,"data-disabled":y.disabled||e.disabled,"data-readonly":y.readonly||e.readonly,"data-state":N===e.value?"checked":"unchecked",children:[(0,i.jsx)(lh.q7,{ref:tL([w,t]),id:s+e.value,value:e.value,disabled:y.disabled||y.readonly||e.disabled||e.readonly,"data-error":!!y.error,"data-disabled":y.disabled||e.disabled,"data-readonly":y.readonly||e.readonly,className:x(lp.item({size:a}),h),children:(0,i.jsx)(lh.C1,{className:x(lp.itemIndicator(),p),"data-error":!!y.error,"data-disabled":y.disabled||e.disabled,"data-readonly":y.readonly||e.readonly,children:b||(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",stroke:"currentColor",fill:"
17currentColor",className:x(lp.itemCheckIcon({size:a}),v),children:(0,i.jsx)("path",{d:"M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z"})})})},e.value),(0,i.jsx)("label",{className:x(lp.itemLabel(),g),htmlFor:s+e.value,"aria-disabled":e.disabled,"data-error":!!y.error,"data-disabled":y.disabled||e.disabled||e.disabled,"data-readonly":y.readonly||e.readonly,"data-state":N===e.value?"checked":"unchecked",children:e.label??e.value})]},e.value))})}),(0,i.jsx)("input",{ref:c,type:"radio",name:y.name,className:U,value:N??"",checked:!!N,"aria-hidden":"true",required:y.required,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=w.current)?void 0:e.focus()}})]})});lx.displayName="RadioGroup";var lg=s(1628);let lf={root:(0,c.F)(["UI-SimpleDropzone__root","appearance-none w-full mb-2 cursor-pointer hover:text-[--foreground] flex items-center justify-center p-4 border rounded-[--radius] border-dashed","gap-3 text-sm sm:text-base","outline-none focus-visible:outline-none focus-visible:ring-1 ring-offset-1 ring-offset-[--background] focus-visible:ring-white/40","text-[--muted] transition ease-in-out hover:border-[--foreground]","data-[drag-active=true]:border-brand-500","data-[drag-reject=true]:border-[--red]"]),list:(0,c.F)(["UI-SimpleDropzone__list","flex rounded-[--radius-md] flex-wrap divide-y divide-[--border]"]),listItem:(0,c.F)(["UI-SimpleDropzone__listItem","flex items-center justify-space-between relative p-1 hover:bg-[--subtle] w-full overflow-hidden"]),listItemDetailsContainer:(0,c.F)(["UI-SimpleDropzone__listItemDetailsContainer","flex items-center gap-2 truncate w-full"]),listItemTitle:(0,c.F)(["UI-SimpleDropzone__listItemTitle","truncate max-w-[180px] text-[.9rem]"]),listItemSize:(0,c.F)(["UI-SimpleDropzone__listItemSize","text-xs uppercase text-center font-semibold align-center text-[--muted]"]),listItemRemoveButton:(0,c.F)(["UI-SimpleDropzone__listItemRemoveButton","ml-2 rounded-full"]),imagePreviewGrid:(0,c.F)(["UI-SimpleDropzone__imagePreviewGrid","flex gap-2 flex-wrap place-content-center pt-4"]),imagePreviewContainer:(0,c.F)(["UI-SimpleDropzone__imagePreviewContainer","col-span-1 row-span-1 aspect-square w-36 h-auto"]),imagePreview:(0,c.F)(["UI-SimpleDropzone__imagePreview","relative bg-transparent border h-full bg-center bg-no-repeat bg-contain rounded-[--radius-md] overflow-hidden","col-span-1 row-span-1"]),imagePreviewRemoveButton:(0,c.F)(["UI-SimpleDropzone__imagePreviewRemoveButton","absolute top-1 right-1"]),fileIcon:(0,c.F)(["UI-SimpleDropzone__fileIcon","w-5 h-5 flex-none"]),maxSizeText:(0,c.F)(["UI-SimpleDropzone__maxSizeText","text-sm text-[--muted] font-medium"])},lb=u.forwardRef((e,t)=>{let[{children:s,className:a,listClass:r,listItemClass:n,listItemDetailsContainerClass:l,listItemRemoveButtonClass:o,listItemSizeClass:d,listItemTitleClass:c,imagePreviewGridClass:m,imagePreviewContainerClass:h,imagePreviewRemoveButtonClass:p,imagePreviewClass:g,maxSizeTextClass:f,fileIconClass:b,onValueChange:v,withImagePreview:j,dropzoneText:N,accept:k,minSize:S,maxSize:C,maxFiles:_,preventDropOnDocument:A,noClick:R,noDrag:T,onError:I,onDropRejected:E,validator:M,multiple:P,value:$,...O},F]=D(e,u.useId()),z=u.useRef(null),[V,q]=u.useState([]),B=u.useCallback(e=>{q(e.map(e=>Object.assign(e,{preview:URL.createObjectURL(e)})))},[]),K=u.useCallback(e=>{q(t=>t.toSpliced(e,1))},[]);u.useEffect(()=>{null==v||v(V)},[V]),u.useEffect(()=>()=>
17{V.forEach(e=>URL.revokeObjectURL(e.preview))},[V]);let{getRootProps:H,getInputProps:W,isDragActive:G,isDragReject:Y}=(0,lg.VB)({onDrop:B,multiple:P,minSize:S,maxSize:C,maxFiles:_,preventDropOnDocument:A,noClick:R,noDrag:T,validator:M,accept:k,onError:I,onDropRejected:E});return(0,i.jsxs)(L,{...F,children:[(0,i.jsxs)("button",{ref:z,className:x(lf.root(),a),"data-drag-active":G,"data-drag-reject":Y,...H(),tabIndex:0,children:[(0,i.jsx)("input",{ref:t,id:F.id,name:F.name??"files",value:"",onFocusCapture:()=>{var e;return null==(e=z.current)?void 0:e.focus()},"aria-hidden":"true",...W(),...O,className:x("block",U),style:{display:"block"}}),(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-5 h-5",children:[(0,i.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,i.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,i.jsx)("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}),(0,i.jsx)("span",{children:N??"Click or drag file to this area to upload"})]}),C&&(0,i.jsxs)("div",{className:x(lf.maxSizeText(),f),children:["â¤"," ",ny(C)]}),!j&&(0,i.jsx)("div",{className:x(lf.list(),r),children:null==V?void 0:V.map((e,t)=>{let s;return s=["image/jpeg","image/png","image/jpg","image/webm"].includes(e.type)?(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(lf.fileIcon(),b),children:[(0,i.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,i.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,i.jsx)("circle",{cx:"10",cy:"13",r:"2"}),(0,i.jsx)("path",{d:"m20 17-1.09-1.09a2 2 0 0 0-2.82 0L10 22"})]}):e.type.includes("video")?(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(lf.fileIcon(),b),children:[(0,i.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,i.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,i.jsx)("path",{d:"m10 11 5 3-5 3v-6Z"})]}):e.type.includes("audio")?(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(lf.fileIcon(),b),children:[(0,i.jsx)("path",{d:"M17.5 22h.5c.5 0 1-.2 1.4-.6.4-.4.6-.9.6-1.4V7.5L14.5 2H6c-.5 0-1 .2-1.4.6C4.2 3 4 3.5 4 4v3"}),(0,i.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,i.jsx)("path",{d:"M10 20v-1a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0Z"}),(0,i.jsx)("path",{d:"M6 20v-1a2 2 0 1 0-4 0v1a2 2 0 1 0 4 0Z"}),(0,i.jsx)("path",{d:"M2 19v-3a6 6 0 0 1 12 0v3"})]}):e.type.includes("pdf")||e.type.includes("document")||e.type.includes("txt")||e.type.includes("text")?(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(lf.fileIcon(),b),children:[(0,i.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,i.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,i.jsx)("line",{x1:"16",x2:"8",y1:"13",y2:"13"}),(0,i.jsx)("line",{x1:"16",x2:"8",y1:"17",y2:"17"}),(0,i.jsx)("line",{x1:"10",x2:"8",y1:"9",y2:"9"})]}):e.type.includes("compressed")||e.type.includes("zip")||e.type.includes("archive")?(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(lf.fileIcon(),b),children:[(0,i.jsx)("path",{d:"M22 20V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2h6"}),(0,i.jsx)("circle",{cx:"16",cy:"19",r:"2"}),(0,i.jsx)("path",{d:"M16 11v-1"}),(0,i.jsx)("path",{d:"M16 17v-2"})]}):(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(lf.fileIcon(),b),children:[(0,i.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,i.jsx)("polyline",{points:"14 2 14 8 20 8"})]}),(0,i.jsxs)("div",{className:x(lf.listItem(),n),children:[(0,i.jsxs)("div",{className:x(lf.listItemDetailsContainer(),l),children:[s,(0,i.jsx)("p",{className:x(lf.listItemTitle(),c),children:e.name}),(0,i.jsx)("p",{className:x(lf.listItemSize(),d),children:ny(e.size)})]}),(0,i.jsx)(w,{size:"xs",intent:"gray-basic",icon:(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-4 h-4",children:[(0,i.jsx)("path",{d:"M3 6h18"}),(0,i.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}
17),(0,i.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),(0,i.jsx)("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),(0,i.jsx)("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]}),className:x(lf.listItemRemoveButton(),o),onClick:()=>K(t)})]},e.name)})}),j&&!!V.length&&(0,i.jsx)("div",{className:x(lf.imagePreviewGrid(),m),children:null==V?void 0:V.map((e,t)=>(0,i.jsxs)("div",{className:x(lf.imagePreviewContainer(),h),children:[(0,i.jsx)("div",{className:x(lf.imagePreview(),g),style:{backgroundImage:e?`url(${e.preview})`:void 0},children:(0,i.jsx)(y,{intent:"alert",size:"xs",className:x(lf.imagePreviewRemoveButton(),p),onClick:()=>K(t)})}),(0,i.jsxs)("div",{className:x(lf.listItemDetailsContainer(),l),children:[(0,i.jsx)("p",{className:x(lf.listItemTitle(),c),children:e.name}),(0,i.jsx)("p",{className:x(lf.listItemSize(),d),children:ny(e.size)})]})]},e.name))})]})});lb.displayName="SimpleDropzone";let lv={root:(0,c.F)(["UI-Textarea__root","w-full p-2"],{variants:{size:{sm:"h-20",md:"h-32",lg:"h-64"}},defaultVariants:{size:"md"}})},ly=u.forwardRef((e,t)=>{let[s,a]=D(e,u.useId()),[{size:r,intent:n,leftAddon:l,leftIcon:o,rightAddon:d,rightIcon:c,className:m,onValueChange:h,onChange:p,...g},{inputContainerProps:f,leftAddonProps:b,leftIconProps:v,rightAddonProps:y,rightIconProps:j}]=B({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),w=u.useCallback(e=>{null==h||h(e.target.value),null==p||p(e)},[h,p]);return(0,i.jsx)(L,{...a,children:(0,i.jsxs)(F,{...f,children:[(0,i.jsx)(q,{...b}),(0,i.jsx)(V,{...v}),(0,i.jsx)("textarea",{id:a.id,name:a.name,className:x("form-textarea",O.root({size:r,intent:n,hasError:!!a.error,
17isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!d,hasRightIcon:!!c,hasLeftAddon:!!l,hasLeftIcon:!!o}),lv.root({size:r}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,onChange:w,...g,ref:t}),(0,i.jsx)(q,{...y}),(0,i.jsx)(V,{...j})]})})});ly.displayName="Textarea";let lj=u.forwardRef((e,t)=>{let{children:s,loading:a,disabled:r,role:n="save",disableOnSuccess:l="create"===n,disableIfInvalid:o=!1,showLoadingOverlayOnSuccess:d=!1,showLoadingOverlayOnCreate:c=!0,loadingOverlay:u,...m}=e,{formState:h}=(0,nq.xW)(),p=!!l&&h.isSubmitSuccessful,x=!!o&&!h.isValid;return(0,i.jsxs)(i.Fragment,{children:[d&&u&&(0,i.jsx)(A,{hide:!h.isSubmitSuccessful}),"create"===n&&u&&(0,i.jsx)(A,{hide:!h.isSubmitSuccessful}),(0,i.jsx)(v,{type:"submit",loading:h.isSubmitting||a,disabled:x||r||p,ref:t,...m,children:s})]})});function lw(e){return(0,u.forwardRef)((t,s)=>{let{control:a,formState:r,...n}=(0,nq.xW)(),{shape:l}=u.useContext(n2);return(0,u.useMemo)(()=>{var e,s;return!!(0,nq.Jt)(l,t.name)&&!(null==(e=(0,nq.Jt)(l,t.name))?void 0:e.isOptional())&&!(null==(s=(0,nq.Jt)(l,t.name))?void 0:s.isNullable())},[l]),(0,i.jsx)(nq.xI,{name:t.name,control:a,rules:{required:t.required},render:a=>{var n;let{field:{ref:l,...o}}=a;return(0,i.jsx)(e,{value:o.value,onChange:lO(t.onChange,o.onChange),onBlur:lO(t.onBlur,o.onBlur),...t,error:null==(n=lL(o.name,r))?void 0:n.message,ref:function(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,u.useMemo)(()=>(function(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return e=>{t.forEach(t=>{!function(e,t){if(null!=e){if("function"==typeof e)return e(t);try{e.current=t}catch(s){throw Error(`Cannot assign value '${t}' to ref '${e}'`)}}}(t,e)})}})(...t),t)}(s,l)})}})})}let lN=u.memo(lw((0,u.forwardRef)((e,t)=>(0,i.jsx)(K,{...e,value:e.value??"",ref:t})))),lk=u.memo(lw((0,u.forwardRef)((e,t)=>(0,i.jsx)(G,{...e,value:e.value??"",ref:t})))),lS=u.memo(lw((0,u.forwardRef)((e,t)=>(0,i.jsx)(ly,{...e,value:e.value??"",ref:t})))),lC=u.memo(lw((0,u.forwardRef)((e,t)=>{let s=(0,nq.xW)(),a=(0,nq.as)({name:e.name});return u.useEffect(()=>{if(!(0,nq.Jt)(s.formState.defaultValues,e.name)&&!a.field.value&&!e.placeholder){var t,r;a.field.onChange(null==(r=e.options)||null==(t=r[0])?void 0:t.value)}},[]),(0,i.jsx)(lo,{...e,ref:t})}))),l_=u.memo(lw((0,u.forwardRef)((e,t)=>{let s=(0,nq.xW)(),a=(0,nq.as)({name:e.name}),r=u.useRef("#000"),[n,l]=u.useState((0,nq.Jt)(s.formState.defaultValues,e.name)||"#000"),o=np(n,200),d=u.useRef(n);u.useEffect(()=>{a.field.onChange(o),(0,n5.Mj)(o).isValid()&&(r.current=o)},[o]);let c=u.useCallback(()=>{(0,n5.Mj)(n).isValid()?l(n):l(r.current),d.current=n},[r.current,n]);return(0,n6.A)(()=>{a.field.value!==d.current&&(l(a.field.value),d.current=a.field.value)},[a.field.value]),(0,i.jsx)(K,{...e,ref:t,value:n,onValueChange:l,onBlur:c,rightAddon:(0,i.jsx)(P,{className:"flex justify-center",trigger:(0,i.jsx)("div",{className:"cursor-pointer size-7 rounded-[--radius-md]",style:{backgroundColor:n}}),children:(0,i.jsx)(n4.jI,{color:n,onChange:e=>{l(e)}})}),className:"w-full"})}))),lA=u.memo(lw((0,u.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,i.jsx)(nc,{...a,onValueChange:s,ref:t})}))),lR=u.memo(lw((0,u.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,i.jsx)(lm,{...a,onValueChange:s,ref:t})}))),lT=u.memo(lw((0,u.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,i.jsx)(li,{...a,onValueChange:s,ref:t})}))),lI=u.memo(lw((0,u.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,i.jsx)(ni,{...a,onValueChange:s,ref:t})}))),lE=u.memo(lw((0,u.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,i.jsx)(lt,{...a,onValueChange:s,ref:t})}))),lM=u.memo(lw((0,u.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,i.jsx)(la,{...a,onValueChange:s,ref:t})}))),lP=u.memo(lw((0,u.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,i.jsx)(lx,{...a,onValueChange:s,ref:t})}))),l$=u.memo(lw((0,u.forwardRef)((e,t)=>{let{onChange:s,itemContainerClass:a,itemClass:r,radioGroupStackClass:n,...l}=e;return(0,i.jsx)(lx,{itemContainerClass:x("items-start cursor-pointer transition border-transparent roun
17ded-[--radius] p-3 w-full md:w-fit","bg-transparent dark:hover:bg-gray-900 dark:bg-transparent","data-[state=checked]:bg-brand-500/5 dark:data-[state=checked]:bg-gray-900","focus:ring-2 ring-brand-100 dark:ring-brand-900 ring-offset-1 ring-offset-[--background] focus-within:ring-transparent transition","dark:border dark:data-[state=checked]:border-[--border] data-[state=checked]:ring-offset-0",a),itemClass:x("border-transparent absolute top-2 right-2 bg-transparent dark:bg-transparent dark:data-[state=unchecked]:bg-transparent","data-[state=unchecked]:bg-transparent data-[state=unchecked]:hover:bg-transparent dark:data-[state=unchecked]:hover:bg-transparent","focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:ring-offset-transparent",r),itemIndicatorClass:"hidden",itemLabelClass:"font-medium flex flex-col items-center data-[state=unchecked]:hover:text-[--foreground] data-[state=checked]:text-[--brand] text-[--muted] cursor-pointer",...l,onValueChange:s,stackClass:x("flex flex-col md:flex-row gap-2 space-y-0",n),ref:t})}))),lD={Text:lN,Password:lk,Textarea:lS,Select:lA,NativeSelect:lC,Switch:lI,Checkbox:lE,CheckboxGroup:lM,RadioGroup:lP,Number:lR,Combobox:lT,Autocomplete:u.memo(lw((0,u.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,i.jsx)(n8,{...a,onValueChange:s,ref:t})}))),SimpleDropzone:u.memo(lw((0,u.forwardRef)((e,t)=>{let{onChange:s,value:a,...r}=e,n=(0,nq.as)({name:r.name});return u.useEffect(()=>{n.field.onChange([])},[]),(0,i.jsx)(lb,{...r,onValueChange:s,ref:t})}))),ColorPicker:l_,RadioCards:l$,Submit:lj};lD.displayName="Field";let lL=(e,t)=>(0,nq.Jt)(t.errors,e);function lO(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(e){t.some(t=>(null==t||t(e),null==e?void 0:e.defaultPrevented))}}function lU(e){let{children:t}=e;return(0,i.jsx)("div",{className:"pb-4",children:t})}function lF(e){let{title:t,description:s,children:a,className:r}=e;return(0,i.jsxs)(J,{className:x("group/settings-card relative lg:bg-gray-950/5 dark:lg:bg-gray-950/40 rounded-xl transition-colors",r),children:[t&&(0,i.jsxs)("div",{className:"p-0 pb-2 flex flex-col lg:flex-row items-start lg:items-center gap-0 mx-3 mt-3 space-y-0",children:[(0,i.jsx)("span",{className:x("font-semibold text-[1rem] tracking-wide px-4 py-1 border w-fit rounded-xl flex-none","bg-gray-800/10 dark:bg-gray-800/40 transition-colors duration-300","group-hover/settings-card:bg-brand-500/10 group-hover/settings-card:text-white"),children:t}),s&&(0,i.jsx)("span",{className:"px-4 py-2 lg:py-0 w-fit text-sm text-[--muted]",children:s})]}),(0,i.jsx)("div",{className:x(!t&&"pt-4","p-4 space-y-4"),children:a})]})}function lz(e){let{title:t,description:s,icon:a,size:r="lg"}=e,n="lg"===r;return(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-brand-500/10 to-purple-500/10 border border-brand-500/15",children:(0,i.jsx)(a,{className:x("text-brand-600 dark:text-brand-400",n?"text-2xl":"text-xl")})}),(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:x("font-semibold",n?"text-xl":"text-lg"),children:t}),(0,i.jsx)("p",{className:x("text-[--muted]",n?"text-base":"text-sm"),children:s})]})]})}nV.Yj().min(2).trim(),nV.Yj().min(1),nV.YO(nV.Yj()),nV.YO(nV.Yj()),nV.Ik({label:nV.Yj(),value:nV.Yj().nullable()}),nV.Ik({label:nV.Yj(),value:nV.Yj({error:"Invalid address"})}),nV.Ik({hour:nV.ai().min(0).max(23),minute:nV.ai().min(0).max(59)}),nV.Yj().min(10,"Invalid phone number"),nV.YO(nV.Ie()).refine(e=>e.every(e=>e instanceof File),{message:"Expected a file"}),nV.YO(nV.Ie()).min(0).refine(e=>e.every(e=>e instanceof File),{message:"Expected a file"}),nV.Ik({from:nV.p6(),to:nV.p6()}),nV.p6(),(0,c.F)(["UI-DangerZone__root","p-4 flex flex-col sm:flex-row gap-2 text-center sm:text-left rounded-[--radius-md] border border-dashed"]),(0,c.F)(["UI-DangerZone__icon","place-self-center sm:place-self-start text-[--red] w-4 mt-2"]),(0,c.F)(["UI-DangerZone__title","text-lg text-[--red] font-semibold"]),(0,c.F)(["UI-DangerZone__dialogTitle","text-lg font-medium leading-6"]),(0,c.F)(["UI-DangerZone__dialogBody","mt-2 text-base text-[--muted]"]),(0,c.F)(["UI-DangerZone__dialogAction","mt-2 flex gap-2 justify-end"]);var lV=s(43356);let lq={root:(0,c.F)(["UI-Alert__root","py-3 px-4 flex justify-between rounded-xl border text-sm transition-colors duration-200"],{variants:{intent:{info:"bg-blue-500/10 border-blue-500/20 text-gray-900 dark:bg-blue-900/70 dark:border-[--border] dark:text-gray-200",success:"bg-green-500/10 border-green-500/20 text-gray-900 dark:bg-green-900/70 dark:border-[--border] dark:text-gray-200",warning:"bg-orange-500/10 border-orange-500/20 text-gray-900 dark:bg-orange-900/70 dark:border-[--border] dark:text-gray-200",alert:"bg-red-500/10 border-red-500/20 text-gray-900 dark:bg-red-900/70 dark:border-[--border] dark:text-gray-200","info-basic":"bg-white text-gray-800 border-gray-200 dark:bg-gray-900/50 dark:border-[--border] dark:text-gray-200","success-basic":"bg-white text-gray-800 border-gray-200 dark:bg-gray-900/50 dark:border-[--border] dark:text-gray-200","warning-basic":"bg-white text-gray-800 border-gray-200 dark:bg-gray-900/50 dark:border-[--border] dark:text-gray-200","alert-basic":"bg-white text-gray-800 border-gray-200 dark:bg-gray-900/50 dark:border-[--border] dark:text-gray-200"}},defaultVariants:{intent:"info"}}),detailsContainer:(0,c.F)(["UI-Alert__detailsContainer","flex w-full items-start"]),textContainer:(0,c.F)(["UI-Alert__textContainer","flex flex-col self-start ml-3 gap-0.5"]),title:(0,c.F)(["UI-Alert__title","font-semibold text-gray-900 dark:text-[--foreground] mb-0.5"]),description:(0,c.F)(["UI-Alert__description","text-xs md:text-sm text-[--muted] dark:text-gray-200"]),icon:(0,c.F)(["UI-Alert__icon","text-xl content-evenly flex-none self-start mt-0.5"],{variants:{intent:{"info-basic":"text-blue-500 dark:text-blue-400","success-basic":"text-green-500 dark:text-green-400","warning-basic":"text-orange-500 dark:text-orange-400","alert-basic":"text-red-500 dark:text-red-400",info:"text-blue-600 dar
17k:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-orange-600 dark:text-orange-400",alert:"text-red-600 dark:text-red-400"}},defaultVariants:{intent:"info-basic"}}),closeButton:(0,c.F)(["UI-Alert__closeButton","flex-none self-start text-lg hover:opacity-80 active:opacity-100 transition-opacity duration-150 cursor-pointer h-5 w-5 ml-4 opacity-50 dark:text-gray-400 dark:hover:text-gray-200"])},lB=u.forwardRef((e,t)=>{let{children:s,className:a,title:r,description:n,isClosable:l,onClose:o,intent:d="info-basic",iconClass:c,detailsContainerClass:u,textContainerClass:m,titleClass:h,descriptionClass:p,closeButtonClass:g,icon:f,...b}=e,v=null;return"info-basic"===d||"info"===d?v=(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("path",{d:"M12 16v-4"}),(0,i.jsx)("path",{d:"M12 8h.01"})]}):"alert-basic"===d||"alert"===d?v=(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),(0,i.jsx)("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}):"warning-basic"===d||"warning"===d?v=(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),(0,i.jsx)("line",{x1:"12",x2:"12",y1:"9",y2:"13"}),(0,i.jsx)("line",{x1:"12",x2:"12.01",y1:"17",y2:"17"})]}):("success-basic"===d||"success"===d)&&(v=(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z"}),(0,i.jsx)("path",{d:"m9 12 2 2 4-4"})]})),(0,i.jsxs)("div",{className:x(lq.root({intent:d}),a),...b,ref:t,children:[(0,i.jsxs)("div",{className:x(lq.detailsContainer(),!r&&"items-center",u),children:[f||(0,i.jsx)("div",{className:x(lq.icon({intent:d}),c),children:v&&v}),(0,i.jsxs)("div",{className:x(lq.textContainer(),!r&&"self-center",m),children:[!!r&&(0,i.jsx)("span",{className:x(lq.title(),h),children:r}),!!(n||s)&&(0,i.jsx)("div",{className:x(lq.description(),p),children:n||s})]})]}),o&&(0,i.jsx)("button",{className:x(lq.closeButton(),g),onClick:o,children:(0,i.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),(0,i.jsx)("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]})})]})});function lK(e){let{isPending:t}=e,{isDirty:s}=(0,nq.lN)();return(0,i.jsx)(lD.Submit,{role:"save",size:"md",className:x("text-md group",s&&"animate-pulse"),intent:"primary",rounded:!0,loading:t,leftIcon:(0,i.jsx)(lV.Bc_,{}),children:"Save"})}function lH(e){let{isPending:t,className:s}=e,{isDirty:a,isSubmitting:r,isValidating:n}=(0,nq.lN)(),{reset:l}=(0,nq.xW)();return a?(0,i.jsx)(lB,{intent:"info",detailsContainerClass:"items-center",className:x("fixed z-[50] h-auto p-4 !mt-0 rounded-xl bg-[--background] border shadow-2xl","inset-x-4 bottom-4 w-auto animate-in slide-in-from-bottom-4 duration-300","lg:inset-x-auto lg:bottom-auto lg:right-4 lg:top-[2rem] lg:w-fit","lg:slide-in-from-top-2",s),children:(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("span",{className:"flex-1 text-sm lg:flex-none",children:"You have unsaved changes."}),(0,i.jsx)(v,{size:"sm",intent:"gray-link",onClick:()=>l(),leftIcon:(0,i.jsx)(lV.cO3,{}),children:"Reset"}),(0,i.jsx)(lD.Submit,{role:"save",size:"sm",intent:"primary-link",disabled:r||n,loading:t,leftIcon:(0,i.jsx)(lV.Bc_,{}),children:"Save"})]})}):null}lB.displayName="Alert";var lW=s(11627),lG=s(57320),lY=s(69788),lJ=s(15920),lZ=s(5524);let lQ="flex items-center justify-end gap-2 md:contents",lX="shrink-0 mr-auto md:mr-0",l0="flex gap-1 justify-end md:order-last";function l1(e,t){let s=(0,u.useRef)(e);s.current=e;let a=(0,u.useRef)([]),r=(0,u.useRef)(0);for(;a.current.length<e.length;)a.current.push(`row-${r.current++}`);a.current.length=e.length;let[n,l]=(0,u.useState)(!1),i=(0,lW.FR)((0,lW.MS)(lW.AN),(0,lW.MS)(lW.IG,{activationConstraint:{delay:150,tolerance:8}}));(0,u.useEffect)(()=>
17{if(!n)return;let e=e=>e.preventDefault();return document.body.addEventListener("touchmove",e,{passive:!1}),()=>document.body.removeEventListener("touchmove",e)},[n]);let o=(0,u.useCallback)((e,r)=>{a.current=(0,lG.be)(a.current,e,r),t((0,lG.be)(s.current,e,r))},[t]),d=(0,u.useCallback)(e=>{a.current=a.current.filter((t,s)=>s!==e),t(s.current.filter((t,s)=>s!==e))},[t]),c=(0,u.useCallback)(e=>{l(!1);let{active:t,over:s}=e;if(!s||t.id===s.id)return;let r=a.current.indexOf(String(t.id)),n=a.current.indexOf(String(s.id));-1!==r&&-1!==n&&o(r,n)},[o]);return{count:e.length,keyAt:e=>a.current[e],sortableIds:[...a.current],move:o,removeAt:d,dndProps:{sensors:i,modifiers:[lY.FN],onDragStart:()=>l(!0),onDragEnd:c}}}function l2(e){let{rows:t,children:s}=e;return(0,i.jsx)(lW.Mp,{...t.dndProps,children:(0,i.jsx)(lG.gB,{items:t.sortableIds,strategy:lG._G,children:(0,i.jsx)("div",{className:"space-y-2",children:s})})})}function l3(e){let{id:t,children:s}=e,{attributes:a,listeners:r,setNodeRef:n,transform:l,transition:o,isDragging:d}=(0,lG.gl)({id:t}),c={transform:lJ.Ks.Transform.toString(l),transition:o,opacity:d?.5:1};return(0,i.jsx)("div",{ref:n,style:c,children:(0,i.jsxs)("div",{className:"px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 relative",children:[(0,i.jsx)("div",{className:"rounded-full w-6 h-auto bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move shrink-0",...a,...r}),(0,i.jsx)("div",{className:"flex-1 min-w-0 flex flex-col md:flex-row gap-2 md:items-center",children:s})]})})}function l5(e){let{rows:t,index:s}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,icon:(0,i.jsx)(lZ.uCC,{}),intent:"primary-subtle","aria-label":"Move up",disabled:0===s,onClick:e=>t.move(s,e.shiftKey?0:s-1)}),children:"Move up (shift to move to top)"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,icon:(0,i.jsx)(lZ.$TP,{}),intent:"primary-subtle","aria-label":"Move down",disabled:s===t.count-1,onClick:e=>t.move(s,e.shiftKey?t.count-1:s+1)}),children:"Move down (shift to move to bottom)"}),(0,i.jsx)(w,{size:"sm",rounded:!0,icon:(0,i.jsx)(lZ.H8h,{}),intent:"alert-subtle","aria-label":"Remove",onClick:()=>t.removeAt(s)})]})}function l4(e,t){let s=/(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\([^\)]+\))/g,a=e.split(s),r=e.match(s)||[],n=0;return a.map((e,s)=>{if(s===a.length-1&&""===e)return null;if(s%2==0)return e;{let e=r[n++];if(!e)return null;if(e.startsWith("**")&&e.endsWith("**"))return(0,i.jsx)("strong",{className:"font-semibold",children:e.slice(2,-2)},s);{if(e.startsWith("*")&&e.endsWith("*")&&!e.startsWith("**"))return(0,i.jsx)("em",{className:"italic",children:e.slice(1,-1)},s);if(e.startsWith("`")&&e.endsWith("`"))return(0,i.jsx)("code",{onClick:async s=>{t&&s.stopPropagation(),await nf(e.slice(1,-1),{onSuccess:()=>m.oR.success("Copied to clipboard"),onError:()=>m.oR.error("Failed to copy to clipboard")})},className:"bg-muted px-1 py-0.5 rounded text-[--brand] font-mono text-xs break-all cursor-pointer",children:e.slice(1,-1)},s);let a=e.match(/\[([^\]]+)\]\(([^\)]+)\)/);if(a){let[,e,r]=a;return(0,i.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",onClick:e=>t&&e.stopPropagation(),children:e},s)}}return e}})}let l6=e=>{let t,{children:s,className:a,stopPropagation:r=!1}=e;if(!s)return null;t=s.includes("\\n")?s.split("\\n"):s.split("\n");let n=[],l=0;for(;l<t.length;){let e=t[l],s=e.trim(),a=s.match(/^(#{1,3})\s+(.+)$/),o=s.startsWith("* ")&&!s.startsWith("**");if(a){let e=a[1].length,t=a[2],s=["text-base font-bold mt-3 mb-1","text-sm font-semibold mt-2.5 mb-1","text-sm font-medium mt-2 mb-0.5"],i=1===e?"h1":2===e?"h2":"h3";n.push(u.createElement(i,{key:`h-${l}`,className:s[e-1]},l4(t,r))),l++}else if(o){let e=[];for(;l<t.length&&t[l].trim().startsWith("* ")&&!t[l].trim().startsWith("**");)e.push(t[l]),l++;n.push((0,i.jsx)("ul",{className:"list-none space-y-1 mt-2 mb-1",children:e.map((e,t)=>(0,i.jsxs)("li",{className:"flex items-start gap-2",children:[(0,i.jsx)("span",{className:"text-gray-400",children:"â¢"}),(0,i.jsx)("span",{children:l4(e.slice(2),r)})]},t))},`bullets-${l}`))}else l>0&&n.push((0,i.jsx)("br",{},`br-${l}`)),n.push(l4(e,r)),l++}return(0,i.jsx)("span",{className:a,children:n})},l9="\0CLEAR\0",l8=e=>e?(0,i.jsx)(l6,{children:e}):void 0;function l7(e){let{value:t,disabled:s,onValueChange:a}=e,r="number"==typeof t?t:Number(t??0)||0,[n,l]=u.useState(()=>id(r)),[o,d]=u.useState(!1);return u.useEffect(()=>{ic(n)!==r&&(l(id(r)),d(!1))},[r]),(0,i.jsx)(K,{value:n,disabled:s,placeholder:'e.g. "500GB"',error:o?"Invalid size":void 0,onValueChange:e=>{l(e);let t=ic(e);d(null==t),null!=t&&a(t)}})}function ie(e){let{name:t,label:s,help:a,disabled:r,valueKind:n="str
17ing",width:l="equal",min:o=0}=e,{control:d}=(0,nq.xW)(),{field:c}=(0,nq.as)({name:t,control:d}),m=u.useCallback(()=>{let e=c.value;return e&&"object"==typeof e&&!Array.isArray(e)?Object.entries(e):[]},[c.value]),[h,p]=u.useState(m);u.useEffect(()=>{let e=m(),t={};for(let[e,s]of h)e&&(t[e]=s);let s=Object.fromEntries(e);JSON.stringify(t)!==JSON.stringify(s)&&p(e)},[c.value]);let x=e=>{p(e);let t={};for(let[s,a]of e)s&&(t[s]=a);c.onChange(t)},g=(e,t,s)=>{x(h.map((a,r)=>r===e?[t,s]:a))},f="wide-key"===l?"basis-2/3 grow shrink-0":"wide-value"===l?"basis-1/3 grow shrink-0":"basis-1/2 grow shrink-0",b="wide-value"===l?"basis-2/3 grow shrink-0":"wide-key"===l?"basis-1/3 grow shrink-0":"basis-1/2 grow shrink-0";return(0,i.jsx)(L,{label:s,help:l8(a),children:(0,i.jsxs)("div",{className:"space-y-2",children:[0===h.length&&(0,i.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No entries."}),h.map((e,t)=>{let[s,a]=e;return(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{placeholder:"key",value:s,disabled:r,onValueChange:e=>g(t,e,a),className:f}),(0,i.jsx)("span",{className:"text-[--muted]",children:"="}),(0,i.jsx)("div",{className:b,children:"boolean"===n?(0,i.jsx)(ni,{value:!!a,disabled:r,onValueChange:e=>g(t,s,e)}):"size"===n?(0,i.jsx)(l7,{value:a,disabled:r,onValueChange:e=>g(t,s,e)}):"number"===n?(0,i.jsx)(lm,{value:"number"==typeof a?a:Number(a)||0,disabled:r,onValueChange:e=>g(t,s,e),min:o}):(0,i.jsx)(K,{placeholder:"value",value:null==a?"":String(a),disabled:r,onValueChange:e=>{let a=e;"numberOrBool"===n&&("true"===e?a=!0:"false"===e?a=!1:/^\d+$/.test(e)&&(a=Number(e))),g(t,s,a)}})}),(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),disabled:r,onClick:()=>x(h.filter((e,s)=>s!==t)),"aria-label":"Remove entry"})]},t)}),(0,i.jsx)(w,{size:"sm",intent:"primary-subtle",rounded:!0,icon:(0,i.jsx)(sm.Ca6,{}),disabled:r,onClick:()=>x([...h,["","boolean"!==n&&("number"===n||"size"===n?0:"")]]),"aria-label":"Add entry"})]})})}function it(e){let{name:t,label:s,help:a,disabled:r}=e,{control:n}=(0,nq.xW)(),{field:l}=(0,nq.as)({name:t,control:n}),o=u.useCallback(()=>Array.isArray(l.value)?[...l.value]:[],[l.value]),[d,c]=u.useState(o);u.useEffect(()=>{let e=o();JSON.stringify(d)!==JSON.stringify(e)&&c(e)},[l.value]);let m=e=>{c(e),l.onChange(e)};return(0,i.jsx)(L,{label:s,help:l8(a),children:(0,i.jsxs)("div",{className:"space-y-2",children:[0===d.length&&(0,i.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No entries."}),d.map((e,t)=>(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{value:e,disabled:r,onValueChange:e=>m(d.map((s,a)=>a===t?e:s)),className:"flex-1"}),(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),disabled:r,onClick:()=>m(d.filter((e,s)=>s!==t)),"aria-label":"Remove"})]},t)),(0,i.jsx)(w,{size:"sm",intent:"primary-subtle",rounded:!0,icon:(0,i.jsx)(sm.Ca6,{}),disabled:r,onClick:()=>m([...d,""]),"aria-label":"Add"})]})})}function is(e){let{name:t,label:s,help:a,disabled:r}=e,{control:n}=(0,nq.xW)(),{field:l}=(0,nq.as)({name:t,control:n}),o=l.value,d=Array.isArray(o),c="boolean"==typeof o,[m,h]=u.useState(d);return u.useEffect(()=>{d&&h(!0)},[d]),(0,i.jsx)(L,{label:s,help:l8(a),children:(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)(ni,{value:!!d||!!o,disabled:r,onValueChange:e=>{m?l.onChange(!!e&&(d?o:[])):l.onChange(e)}}),(0,i.jsx)("button",{type:"button",disabled:r,className:"text-xs text-[--muted] underline-offset-2 hover:underline",onClick:()=>{let e=!m;h(e),e&&!d&&l.onChange([]),!e&&d&&l.onChange(o.length>0)},children:m?"Use simple toggle":"Use allow-list"})]}),m&&(0,i.jsx)(it,{name:t,label:"",help:void 0,disabled:r||!Array.isArray(l.value)}),!m&&c&&(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:o?"Enabled for everything.":"Disabled."})]})})}function ia(e){return!Number.isFinite(e)||e<0?"":0===e?"0s":nA(1e3*Math.round(e))}function ir(e){let t=e.trim();if(""===t)return null;if(/^-?\d+$/.test(t))return Number(t);if(!/[a-z]/i.test(t))return null;let s=n_(t);return null==s?null:Math.round(s/1e3)}function il(e){let{name:t,label:s,help:a,disabled:r}
17=e,{control:n}=(0,nq.xW)(),{field:l}=(0,nq.as)({name:t,control:n}),o="number"==typeof l.value?l.value:Number(l.value??0)||0,[d,c]=u.useState(()=>ia(o)),[m,h]=u.useState(null);return u.useEffect(()=>{ir(d)!==o&&(c(ia(o)),h(null))},[o]),(0,i.jsx)(L,{label:s,help:l8(a),error:m??void 0,children:(0,i.jsx)(K,{value:d,disabled:r,placeholder:'e.g. "30m", "1h", "1d"',onValueChange:e=>{c(e);let t=ir(e);null==t?h("Invalid duration. Use e.g. 30s, 5m, 1h, 1d, 2w."):(h(null),l.onChange(t))}})})}function ii(e){let{name:t,label:s,help:a,disabled:r,secretSet:n}=e,{control:l}=(0,nq.xW)(),{field:o}=(0,nq.as)({name:t,control:l}),d=o.value===l9,c=d?`${a?a+" \xb7 ":""}Will be cleared on save.`:a;return(0,i.jsxs)(L,{label:s,help:l8(c),children:[n&&(0,i.jsx)("div",{className:"flex justify-end mb-1",children:(0,i.jsx)(v,{size:"sm",intent:d?"gray-subtle":"alert-subtle",leftIcon:(0,i.jsx)(sm.id1,{}),onClick:()=>o.onChange(d?"":l9),disabled:r,children:d?"Cancel clear":"Clear value"})}),(0,i.jsx)(ly,{value:d||null==o.value?"":String(o.value),disabled:r||d,placeholder:d?"(will be cleared on save)":n?"(value set â type to replace)":void 0,rows:6,className:"font-mono text-xs",onValueChange:e=>o.onChange(e)})]})}let io=[["TB",1e12],["GB",1e9],["MB",1e6],["KB",1e3],["B",1]];function id(e){if(!Number.isFinite(e)||e<0)return"";if(0===e)return"0B";for(let[t,s]of io)if(e>=s){let a=e/s;return`${Number.isInteger(a)?a:a.toFixed(1)}${t}`}return`${e}B`}function ic(e){let t=e.trim();if(""===t)return null;if(/^\d+$/.test(t))return Number(t);let s=t.match(/^(\d+(?:\.\d+)?)\s*([kmgt]?b)?$/i);return s?Math.floor(Number(s[1])*({b:1,kb:1e3,mb:1e6,gb:1e9,tb:1e12})[(s[2]||"b").toLowerCase()]):null}function iu(e){let{name:t,label:s,help:a,disabled:r}=e,{control:n}=(0,nq.xW)(),{field:l}=(0,nq.as)({name:t,control:n}),o="number"==typeof l.value?l.value:Number(l.value??0)||0,[d,c]=u.useState(()=>id(o)),[m,h]=u.useState(null);return u.useEffect(()=>{ic(d)!==o&&(c(id(o)),h(null))},[o]),(0,i.jsx)(L,{label:s,help:l8(a),error:m??void 0,children:(0,i.jsx)(K,{value:d,disabled:r,placeholder:'e.g. "20MB", "1GB", "500KB"',onValueChange:e=>{c(e);let t=ic(e);null==t?h("Invalid size. Use e.g. 500KB, 20MB, 1GB."):(h(null),l.onChange(t))}})})}function im(e){let{name:t,label:s,help:a,disabled:r}=e,{control:n}=(0,nq.xW)(),{field:l}=(0,nq.as)({name:t,control:n}),[o,d]=u.useState(()=>JSON.stringify(l.value??null,null,2)),[c,m]=u.useState(null);return u.useEffect(()=>{d(JSON.stringify(l.value??null,null,2)),m(null)},[l.value]),(0,i.jsx)(L,{label:s,help:l8(a),error:c??void 0,children:(0,i.jsx)(ly,{value:o,disabled:r,rows:4,className:"font-mono text-xs",onValueChange:e=>{d(e);try{l.onChange(JSON.parse(e)),m(null)}catch{m("Invalid JSON")}}})})}function ih(e){let{name:t,label:s,help:a,disabled:r,options:n,orderable:l}=e,{control:o}=(0,nq.xW)(),{field:d}=(0,nq.as)({name:t,control:o}),c=u.useMemo(()=>Array.isArray(d.value)?d.value.filter(e=>n.includes(e)):[],[d.value,n]),m=n.filter(e=>!c.includes(e)),h=l1(c,e=>d.onChange(e));return l?(0,i.jsx)(L,{label:s,help:l8(a),children:(0,i.jsxs)("div",{className:"space-y-2",children:[0===c.length&&(0,i.jsx)("p",{className:"text-xs text-[--muted] italic",children:"None selected."}),(0,i.jsx)(l2,{rows:h,children:c.map((e,t)=>(0,i.jsxs)(l3,{id:h.keyAt(t),children:[(0,i.jsx)("span",{className:"flex-1 truncate text-sm",children:e}),(0,i.jsx)("div",{className:l0,children:(0,i.jsx)(l5,{rows:h,index:t})})]},h.keyAt(t)))}),m.length>0&&(0,i.jsx)("div",{className:"flex flex-wrap gap-2 pt-1",children:m.map(e=>(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",rounded:!0,leftIcon:(0,i.jsx)(sm.Ca6,{}),disabled:r,onClick:()=>d.onChange([...c,e]),children:e},e))})]})}):(0,i.jsx)(la,{label:s,help:l8(a),disabled:r,options:n.map(e=>({value:e,label:e})),value:c,onValueChange:e=>d.onChange(e)})}let ip=e=>e.replace(/\./g,"--");function ix(e){let{name:t,label:s,help:a,secretSet:r,disabled:n}=e,{setValue:l,watch:o}=(0,nq.xW)(),d=o(t),c=d===l9;return(0,i.jsx)(L,{label:s,help:l8(c?`${a?a+" \xb7 ":""}Will be cleared on save.`:a),children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(G,{autoComplete:"new-password",value:c?"":d??"",placeholder:c?"(will be cleared)":r?"â¢â¢â¢â¢â¢â¢â¢â¢ (unchanged)":"",disabled:n||c,onValueChange:e=>l(t,e,{shouldDirty:!0})})}),r&&!n&&(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:c?"alert-subtle":"gray-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":c?"Cancel clear":"Clear secret value",onClick:()=>l(t,c?"":l9,{shouldDirty:!0})}),children:c?"Cancel â keep current value":"Clear saved value"})]})})}function ig(e){let{env:t}=e;return(0,i.jsxs)(t5,{trigger:(0,i.jsx)(sm.E2M,{className:"inline text-[--muted]"}),children:["Set by environment variable: ",(0,i.jsx)("code",{children:t})]})}function ib(e){let{k:t}=e,s=(0,i.jsx)(iv,{k:t});return void 0===t.deprecated?s:(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(lB,{intent:"warning-basic",title:"Deprecated",description:l8(t.deprecated)}),s]})}function iv(e){let{k:t}=e,s=ip(t.key),a="environment"===t.source,r=(0,i.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[t.label,a&&t.env&&(0,i.jsx)(ig,{env:t.env})]}),n=t.description||void 0;if(t.secret){let e=t.secretSet?`${n?n+" \xb7 ":""}A value is set. Type to replace it, or clear it.`:n;return t.ui.multiline?(0,i.jsx)(ii,{name:s,label:t.label,help:e,disabled:a,secretSet:t.secretSet}):(0,i.jsx)(ix,{name:s,label:r,help:e,secretSet:t.secretSet,disabled:a})}switch(t.ui.kind){case"boolean":return(0,i.jsx)(lD.Switch,{name:s,label:r,help:l8(n),side:"right",disabled:a});case"number":return(0,i.jsx)(lD.Number,{name:s,label:r,help:l8(n),disabled:a,min:t.ui.min,max:t.ui.max,step:t.ui.step});case"enum":return(0,i.jsx)(lD.Select,{name:s,label:r,help:l8(n),disabled:a,options:(t.ui.options??[]).map(e=>({label:e,value:e}))});case"list":return(0,i.jsx)(it,{name:s,label:t.label,help:n,disabled:a});case"multiEnum":return(0,i.jsx)(ih,{name:s,label:t.label,help:n,disabled:a,options:t.ui.options??[],orderable:t.ui.orderable});case"map":return(0,i.jsx)(ie,{name:s,label:t.label,help:n,disabled:a,valueKind:t.ui.mapValueKind??"string",width:t.ui.mapWidth??"equal",min:t.ui.min});case"duration":return(0,i.jsx)(il,{name:s,label:t.label,help:n,disabled:a});case"size":return(0,i.jsx)(iu,{name:s,label:t.label,help:n,disabled:a});case"boolOrList":return(0,i.jsx)(is,{name:s,label:t.label,help:n,disabled:a});case"json":return(0,i.jsx)(im,{name:s,label:t.label,help:n,disabled:a});default:if(t.ui.multiline)return(0,i.jsx)(ii,{name:s,label:t.label,help:n,disabled:a});return(0,i.jsx)(lD.Text,{name:s,label:r,help:l8(n),disabled:a})}}var iy=s(51400);let ij={subTrigger:(0,c.F)(["UI-DropdownMenu__subTrigger","focus:bg-[--subtle] data-[state=open]:bg-[--subtle]"]),subContent:(0,c.F)(["UI-DropdownMenu__subContent","z-50 min-w-[12rem] overflow-hidden rounded-[--radius] border bg-[--background] p-2 text-[--foreground] shadow-sm","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-100 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:sli
17de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"]),root:(0,c.F)(["UI-DropdownMenu__root","z-50 min-w-[15rem] overflow-hidden rounded-[--radius] border bg-[--background] p-2 text-[--foreground] shadow-sm","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-100 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"]),item:(0,c.F)(["UI-DropdownMenu__item","relative flex cursor-default select-none items-center rounded-[--radius] cursor-pointer px-2 py-2 text-sm outline-none transition-colors","focus:bg-[--subtle] data-[disabled]:pointer-events-none","data-[disabled]:opacity-50","[&>svg]:mr-2 [&>svg]:text-lg"]),group:(0,c.F)(["UI-DropdownMenu__group"]),label:(0,c.F)(["UI-DropdownMenu__label","px-2 py-1.5 text-sm font-semibold text-[--muted]"]),separator:(0,c.F)(["UI-DropdownMenu__separator","-mx-1 my-2 h-px bg-[--border]"]),shortcut:(0,c.F)(["UI-DropdownMenu__shortcut","ml-auto text-xs tracking-widest opacity-60"])},iw=u.createContext({}),iN=u.forwardRef((e,t)=>{let{children:s,trigger:a,defaultOpen:r,open:n,onOpenChange:l,dir:o,allowOutsideInteraction:d,sideOffset:c=4,className:u,subContentClass:m,subTriggerClass:h,shortcutClass:p,itemClass:g,labelClass:f,separatorClass:b,groupClass:v,...y}=e;return(0,i.jsx)(iw.Provider,{value:{subContentClass:m,subTriggerClass:h,shortcutClass:p,itemClass:g,labelClass:f,separatorClass:b,groupClass:v},children:(0,i.jsxs)(iy.bL,{defaultOpen:r,open:n,onOpenChange:l,dir:o,modal:!d,...y,children:[(0,i.jsx)(iy.l9,{asChild:!0,children:a}),(0,i.jsx)(iy.ZL,{children:(0,i.jsx)(iy.UC,{ref:t,sideOffset:c,className:x(ij.root(),u),...y,children:s})})]})})});iN.displayName="DropdownMenu",u.forwardRef((e,t)=>{let{className:s,...a}=e,{groupClass:r}=u.useContext(iw);return(0,i.jsx)(iy.YJ,{ref:t,className:x(ij.group(),r,s),...a}
17)}).displayName="DropdownMenuGroup",u.forwardRef((e,t)=>{let{children:s,triggerContent:a,triggerProps:r,triggerInset:n,defaultOpen:l,open:o,onOpenChange:d,sideOffset:c=8,className:m,subTriggerClass:h,...p}=e,{subTriggerClass:g,subContentClass:f}=u.useContext(iw);return(0,i.jsxs)(iy.Pb,{...p,children:[(0,i.jsxs)(iy.ZP,{className:x(ij.item(),ij.subTrigger(),n&&"pl-8",g,h,m),...r,children:[a,(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:x(ij.shortcut(),"w-4 h-4 ml-auto"),children:(0,i.jsx)("path",{d:"m9 18 6-6-6-6"})})]}),(0,i.jsx)(iy.ZL,{children:(0,i.jsx)(iy.G5,{ref:t,sideOffset:c,className:x(ij.subContent(),f,m),...p,children:s})})]})}).displayName="DropdownMenuSub";let ik=u.forwardRef((e,t)=>{let{className:s,inset:a,...r}=e,{itemClass:n}=u.useContext(iw);return(0,i.jsx)(iy.q7,{ref:t,className:x(ij.item(),a&&"pl-8",n,s),...r})});ik.displayName="DropdownMenuItem";let iS=u.forwardRef((e,t)=>{let{className:s,inset:a,...r}=e,{labelClass:n}=u.useContext(iw);return(0,i.jsx)(iy.JU,{ref:t,className:x(ij.label(),a&&"pl-8",n,s),...r})});iS.displayName="DropdownMenuLabel";let iC=u.forwardRef((e,t)=>{let{className:s,...a}=e,{separatorClass:r}=u.useContext(iw);return(0,i.jsx)(iy.wv,{ref:t,className:x(ij.separator(),r,s),...a}
17)});function i_(e,t){if(t)return"â¢â¢â¢â¢â¢â¢";if(null===e)return"null";if(void 0===e)return"â";if("string"==typeof e)return""===e?'""':e;if("number"==typeof e||"boolean"==typeof e)return String(e);try{let t=JSON.stringify(e);return t.length>60?t.slice(0,57)+"â¦":t}catch{return String(e)}}function iA(e){return e.secret?e.secretSet:JSON.stringify(e.value)!==JSON.stringify(e.default)}function iR(e){return{key:e.key,label:e.label,source:e.source,requiresRestart:e.requiresRestart,preview:{from:i_(e.value,e.secret),to:i_(e.default,e.secret)}}}function iT(e){let{open:t,onOpenChange:s,scope:a,scopeLabel:r,keys:n,managed:l,invalidate:o}=e,{mutateAsync:d,isPending:c}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[rX],t=(0,e3.jE)();return(0,e5.n)({mutationFn:e=>ea("POST /dashboard/settings/reset",{body:{keys:e}}),onSuccess:()=>e.forEach(e=>t.invalidateQueries({queryKey:e}))})}(o),h=u.useMemo(()=>[...n.filter(e=>"database"===e.source&&iA(e)).map(iR),...(l??[]).filter(e=>"database"===e.source&&!e.isDefault).map(e=>({key:e.key,label:e.label,source:e.source,requiresRestart:e.requiresRestart}))],[n,l]),p=u.useMemo(()=>n.filter(e=>"environment"===e.source).length+(l??[]).filter(e=>"environment"===e.source).length,[n,l]),x=u.useMemo(()=>n.filter(e=>"database"===e.source&&!iA(e)).length+(l??[]).filter(e=>"database"===e.source&&e.isDefault).length,[n,l]),[g,f]=u.useState(new Set);u.useEffect(()=>{t&&f(new Set(h.map(e=>e.key)))},[t,h]);let b=u.useMemo(()=>(function(e){let t=new Map;for(let s of e){let e=s.key.split("."),a=e[0],r=e.slice(1,-1).join(".");t.has(a)||t.set(a,new Map);let n=t.get(a);n.has(r)||n.set(r,[]),n.get(r).push(s)}let s=[];for(let[e,a]of t)for(let[t,r]of a){let a=(t?`${e}.${t}`:e).split(".").map(rZ).join(" ⺠");s.push({subsection:a,rows:r})}return s})(h),[h]),y=g.size===h.length&&h.length>0,j=g.size>0&&!y,w=e=>{f(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},N=async()=>{if(0!==g.size)try{let e=await d([...g]);m.oR.success(`Reset ${e.reset.length} setting${1===e.reset.length?"":"s"}.`);let t=e.skipped.filter(e=>"already-default"!==e.reason);t.length&&m.oR.warning(`${t.length} could not be reset (env-locked or unknown).`),e.requiresRestart&&m.oR.warning("Some changes require a restart to take effect.",{duration:8e3}),s(!1)}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to reset settings")}};return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"all"===a?"Reset all settings":`Reset settings in ${r}`,description:0===h.length?"Nothing to reset - every key in this scope already holds its default or is pinned by an env variable.":"Selected keys will revert to their environment value (if set) or built-in default. This cannot be undone.",contentClass:"max-w-2xl",footer:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>s(!1),disabled:c,children:"Cancel"}),(0,i.jsx)(v,{intent:"alert-subtle",onClick:N,loading:c,disabled:c||0===g.size,children:0===g.size?"Nothing selected":`Reset ${g.size} ${1===g.size?"key":"keys"}`})]}),children:h.length>0&&(0,i.jsxs)("div",{className:"space-y-3",children:[(p>0||x>0)&&(0,i.jsx)(lB,{intent:"info",description:(0,i.jsxs)(i.Fragment,{children:[p>0&&(0,i.jsxs)(i.Fragment,{children:[p," key",1===p?"":"s"," in this scope ",1===p?"is":"are"," pinned by environment variables and won't change."," "]}),x>0&&(0,i.jsxs)(i.Fragment,{children:[x," already"," ",1===x?"holds":"hold"," the default value, so ",1===x?"it is":"they are"," ","not listed."]})]}),isClosable:!1}),(0,i.jsx)("div",{className:"flex items-center justify-between border-b border-[--border] pb-2",children:(0,i.jsx)(lt,{label:y?`All ${h.length} selected`:j?`${g.size} of ${h.length} selected`:"Select all",value:!!y||!!j&&"indeterminate",onValueChange:()=>{f(e=>e.size===h.length?new Set:new Set(h.map(e=>e.key)))}})}),(0,i.jsx)("div",{className:"max-h-[50vh] overflow-y-auto space-y-4 pr-1",children:b.map(e=>(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-1.5",children:e.subsection}),(0,i.jsx)("ul",{className:"space-y-1",children:e.rows.map(e=>{let t=g.has(e.key);return(0,i.jsxs)("li",{className:"flex items-start gap-3 py-1.5 px-2 rounded-md hover:bg-[--subtle] transition-colors",children:[(0,i.jsx)("div",{className:"pt-0.5",children:(0,i.jsx)(lt,{value:t,onValueChange:()=>w(e.key)})}),(0,i.jsxs)("button",{type:"button",className:"flex-1 text-left min-w-0",onClick:()=>w(e.key),children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 min-w-0",children:[(0,i.jsx)("span",{className:"font-medium break-words",children:e.label}),(0,i.jsx)("code",{className:"text-xs text-[--muted] break-all min-w-0",children:e.key})]}),(0,i.jsx)("div",{className:"text-xs text-[--muted] break-all mt-0.5 min-w-0",children:e.preview?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"font-mono",children:e.preview.from}),(0,i.jsx)("span",{className:"mx-1.5",children:"â"}),(0,i.jsx)("span",{className:"font-mono",children:e.preview.to})]}):(0,i.jsx)("span",{className:"italic",children:"edited below; resetting restores the built-in defaults"})})]}),e.requiresRestart&&(0,i.jsx)(t5,{trigger:(0,i.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-orange-400 font-semibold mt-0.5",children:"restart"}),children:"Requires a restart to take effect"})]},e.key)})})]},e.subsection))})]})})}function iI(e){let t,{open:s,onOpenChange:a,envKeys:r}=e,{mutateAsync:n,isPending:l}=(t=(0,e3.jE)(),(0,e5.n)({mutationFn:()=>ea("POST /dashboard/settings/import/env"),onSuccess:()=>
17t.invalidateQueries({queryKey:rX})})),o=u.useMemo(()=>{let e=new Map;for(let t of r){let s=t.key.split(".")[0];e.has(s)||e.set(s,[]),e.get(s).push(t)}return[...e.entries()].sort((e,t)=>{let[s]=e,[a]=t;return s.localeCompare(a)})},[r]),d=async()=>{try{let e=await n();m.oR.success(`Imported ${e.imported.length} setting${1===e.imported.length?"":"s"} into the database.`),e.skippedAsDefault.length&&m.oR.info(`Skipped ${e.skippedAsDefault.length} that already match the default.`),e.failed.length&&m.oR.warning(`${e.failed.length} could not be imported. Check logs.`),e.imported.length&&m.oR.warning("Remove the corresponding env vars and restart for these to take effect.",{duration:1e4}),a(!1)}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to import env settings")}};return(0,i.jsx)(sl,{open:s,onOpenChange:a,title:"Import environment variables into the database",description:0===r.length?"No environment-pinned settings found.":"Copies the current value of every env-set setting into the database. Values that already match the schema default are skipped automatically.",contentClass:"max-w-2xl",footer:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{intent:"gray-basic",onClick:()=>a(!1),disabled:l,children:"Cancel"}),(0,i.jsxs)(v,{intent:"primary-subtle",onClick:d,loading:l,disabled:l||0===r.length,children:["Import ",r.length," ",1===r.length?"key":"keys"]})]}),children:r.length>0&&(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)(lB,{intent:"info",description:(0,i.jsxs)(i.Fragment,{children:["Environment variables always override database values. After importing, you must remove the matching env vars from your deployment ",(0,i.jsx)("em",{children:"and restart"})," for the persisted values to take effect - otherwise the env still overrides."]}),isClosable:!1}),(0,i.jsx)("div",{className:"max-h-[50vh] overflow-y-auto space-y-4 pr-1",children:o.map(e=>{let[t,s]=e;return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-1.5",children:rZ(t)}),(0,i.jsx)("ul",{className:"space-y-1",children:s.map(e=>(0,i.jsx)("li",{className:"flex items-start justify-between gap-3 py-1.5 px-2 rounded-md hover:bg-[--subtle] transition-colors",children:(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 min-w-0",children:[(0,i.jsx)("span",{className:"font-medium break-words",children:e.label}),e.env&&(0,i.jsx)("code",{className:"text-xs text-[--muted] break-all min-w-0",children:e.env})]}),(0,i.jsx)("div",{className:"text-xs text-[--muted] break-all mt-0.5 font-mono min-w-0",children:function(e,t){if(t)return"â¢â¢â¢â¢â¢â¢";if(null===e)return"null";if(void 0===e)return"â";if("string"==typeof e)return""===e?'""':e;if("number"==typeof e||"boolean"==typeof e)return String(e);try{let t=JSON.stringify(e);return t.length>60?t.slice(0,57)+"â¦":t}catch{return String(e)}}(e.value,e.secret)})]})},e.key))})]},t)})})]})})}iC.displayName="DropdownMenuSeparator",u.forwardRef((e,t)=>{let{className:s,...a}=e,{shortcutClass:r}=u.useContext(iw);return(0,i.jsx)("span",{ref:t,className:x(ij.shortcut(),r,s),...a}
17)}).displayName="DropdownMenuShortcut";let iE={initial:{opacity:0,x:12},animate:{opacity:1,x:0},exit:{opacity:0,x:-12},transition:{duration:.18,ease:"easeOut"}};function iM(e){let{open:t,onOpenChange:s,restrict:a,invalidate:r}=e,{mutateAsync:n,isPending:l}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[rX],t=(0,e3.jE)();return(0,e5.n)({mutationFn:e=>ea("POST /dashboard/settings/import/json",{body:{settings:e}}),onSuccess:()=>e.forEach(e=>t.invalidateQueries({queryKey:e}))})}(r),[o,d]=u.useState("pick"),[c,h]=u.useState(null),[p,x]=u.useState(null);u.useEffect(()=>{t||(d("pick"),h(null),x(null))},[t]);let g=async e=>{let t=e[0];if(t){x(null);try{let e=await t.text(),s=function(e,t,s){let a=JSON.parse(e);if(!a.settings||"object"!=typeof a.settings||Array.isArray(a.settings))throw Error("File is missing a `settings` object.");let r=new Set(Array.isArray(a.maskedSecretKeys)?a.maskedSecretKeys.filter(e=>"string"==typeof e):[]),n=a.settings,l={},i=[],o=[];for(let[e,t]of Object.entries(n)){if(s&&!s(e)){o.push(e);continue}if(r.has(e)&&null===t){i.push(e);continue}l[e]=t}return{settings:l,maskedSecrets:i,outOfScope:o,totalEntries:Object.keys(n).length,exportedAt:"string"==typeof a.exportedAt?a.exportedAt:void 0,version:"number"==typeof a.version?a.version:void 0,fileName:t}}(e,t.name,a);h(s),d("review")}catch(e){x((null==e?void 0:e.message)??"Failed to parse JSON file.")}}},f=u.useMemo(()=>{if(!c)return[];let e=new Map;for(let[t,s]of Object.entries(c.settings)){let a=t.split(".")[0];e.has(a)||e.set(a,[]),e.get(a).push([t,s])}return[...e.entries()].sort((e,t)=>{let[s]=e,[a]=t;return s.localeCompare(a)})},[c]),b=async()=>{if(c)try{let e=await n(c.settings);m.oR.success(`Imported ${e.imported.length} setting${1===e.imported.length?"":"s"}.`),e.skipped.length&&m.oR.info(`Skipped ${e.skipped.length} (unknown or env-locked keys).`),e.failed.length&&m.oR.warning(`${e.failed.length} failed validation. Check logs for details.`),e.requiresRestart&&m.oR.warning("Some changes require a restart to take effect.",{duration:8e3}),s(!1)}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to import settings")}},y=c?Object.keys(c.settings).length:0;return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Import settings from JSON",description:"pick"===o?"Choose a settings export file to preview and import.":`Reviewing ${(null==c?void 0:c.fileName)??""}`,contentClass:"max-w-2xl",footer:"pick"===o?(0,i.jsx)(v,{intent:"gray-basic",onClick:()=>s(!1),disabled:l,children:"Cancel"}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{intent:"gray-basic",leftIcon:(0,i.jsx)(sm.OLK,{}),onClick:()=>{h(null),d("pick")},disabled:l,children:"Back"}),(0,i.jsxs)(v,{intent:"primary-subtle",onClick:b,loading:l,disabled:l||0===y,children:["Import ",y," ",1===y?"key":"keys"]})]}),children:(0,i.jsxs)(t7.N,{mode:"wait",initial:!1,children:["pick"===o&&(0,i.jsxs)(se.P.div,{...iE,className:"space-y-3",children:[(0,i.jsx)(lb,{accept:{"application/json":[".json"]},multiple:!1,maxFiles:1,onValueChange:g,dropzoneText:"Click or drag a settings JSON file here"}),p&&(0,i.jsx)(lB,{intent:"alert",description:p,isClosable:!1}),(0,i.jsx)(lB,{intent:"info",description:"Masked secrets in the file will be skipped automatically - you'll need to re-enter them by hand after the import. Unknown or env-locked keys are reported back.",isClosable:!1})]},"pick"),"review"===o&&c&&(0,i.jsxs)(se.P.div,{...iE,className:"space-y-3",children:[c.exportedAt&&(0,i.jsx)(lB,{intent:"info",description:(0,i.jsxs)("span",{children:["Exported"," ",(0,i.jsx)("span",{className:"font-medium",children:new Date(c.exportedAt).toLocaleString()}),void 0!==c.version&&` \xb7 v${c.version}`," \xb7"," ",c.totalEntries," total entr",1===c.totalEntries?"y":"ies"," in source."]}),isClosable:!1}),c.outOfScope.length>0&&(0,i.jsx)(lB,{intent:"info",title:`${c.outOfScope.length} entr${1===c.outOfScope.length?"y":"ies"} outside this section ignored`,description:"Only keys managed by this page will be imported; everything else in the file is left untouched.",isClosable:!1}),c.maskedSecrets.length>0&&(0,i.jsx)(lB,{intent:"warning",title:`${c.maskedSecrets.length} masked secret${1===c.maskedSecrets.length?"":"s"} skipped`,description:(0,i.jsxs)("span",{children:["You'll need to enter these manually after the import:"," ",(0,i.jsxs)("span",{className:"font-mono text-xs",children:[c.maskedSecrets.slice(0,5).join(", "),c.maskedSecrets.length>5&&` and ${c.maskedSecrets.length-5} more`]})]}),isClosable:!1}),0===y?(0,i.jsx)(lB,{intent:"alert",description:"Nothing to import - the file contains
17no values that can be applied (everything was either a masked secret or empty).",isClosable:!1}):(0,i.jsx)("div",{className:"max-h-[40vh] overflow-y-auto space-y-4 pr-1",children:f.map(e=>{let[t,s]=e;return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-1.5",children:rZ(t)}),(0,i.jsx)("ul",{className:"space-y-1",children:s.map(e=>{let[t,s]=e;return(0,i.jsx)("li",{className:"flex items-start gap-3 py-1.5 px-2 rounded-md hover:bg-[--subtle] transition-colors",children:(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsx)("code",{className:"text-xs text-[--muted] break-all block",children:t}),(0,i.jsx)("div",{className:"text-xs text-[--foreground] break-all mt-0.5 font-mono min-w-0",children:function(e){if(null===e)return"null";if(void 0===e)return"â";if("string"==typeof e)return""===e?'""':e;if("number"==typeof e||"boolean"==typeof e)return String(e);try{let t=JSON.stringify(e);return t.length>60?t.slice(0,57)+"â¦":t}catch{return String(e)}}(s)})]})},t)})})]},t)})})]},"review")]})})}let iP=e=>"database"===e.source&&(e.secret?e.secretSet:JSON.stringify(e.value)!==JSON.stringify(e.default)),i$=e=>"database"===e.source&&!e.isDefault;function iD(e){let{allKeys:t,allManagedKeys:s,sectionKeys:a,sectionManagedKeys:r,sectionLabel:n,invalidate:l,scope:o}=e,[d,c]=u.useState(null),[h,p]=u.useState(!1),[x,g]=u.useState(!1),[f,b]=u.useState(!1),v=u.useMemo(()=>a.filter(iP).length+(r??[]).filter(i$).length,[a,r]),y=u.useMemo(()=>(t??[]).filter(iP).length+(s??[]).filter(i$).length,[t,s]),j=u.useMemo(()=>(t??[]).filter(e=>"environment"===e.source).length,[t]),N=async()=>{if(!o)return void window.open("/api/v1/dashboard/settings/export?download=1","_blank");b(!0);try{let e=await r5(),t={};for(let[s,a]of Object.entries(e.settings))o.includes(s)&&(t[s]=a);let s={...e,settings:t,maskedSecretKeys:e.maskedSecretKeys.filter(e=>o.includes(e))},a=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),r=URL.createObjectURL(a),n=new Date().toISOString().replace(/[:.]/g,"-"),l=document.createElement("a");l.href=r,l.download=`${o.fileStem}-${n}.json`,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(r)}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to export settings")}finally{b(!1)}},k=o?o.noun:"database";return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(iN,{align:"end",trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.voe,{}),"aria-label":"Settings actions"}),children:[(0,i.jsx)(iS,{children:"Reset"}),(0,i.jsxs)(ik,{onSelect:()=>c("section"),disabled:0===v,children:[(0,i.jsx)(sm.zOm,{}),"Reset settings in this sectionâ¦",(0,i.jsx)("span",{className:"ml-auto text-xs text-[--muted]",children:v})]}),t&&(0,i.jsxs)(ik,{onSelect:()=>c("all"),disabled:0===y,children:[(0,i.jsx)(sm.zOm,{}),"Reset all settingsâ¦",(0,i.jsx)("span",{className:"ml-auto text-xs text-[--muted]",children:y})]}),!o&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(iC,{}),(0,i.jsx)(iS,{children:"Environment"}),(0,i.jsxs)(ik,{onSelect:()=>p(!0),disabled:0===j,children:[(0,i.jsx)(sm.bh6,{}),"Import environment variablesâ¦",(0,i.jsx)("span",{className:"ml-auto text-xs text-[--muted]",children:j})]})]}),(0,i.jsx)(iC,{}),(0,i.jsx)(iS,{children:"Backup"}),(0,i.jsxs)(ik,{onSelect:()=>g(!0),children:[(0,i.jsx)(sm.Ah9,{}),"Import ",k," settingsâ¦"]}),(0,i.jsxs)(ik,{onSelect:N,disabled:f,children:[(0,i.jsx)(sm.tAF,{}),"Export ",k," settings"]})]}),(0,i.jsx)(iT,{open:null!==d,onOpenChange:e=>!e&&c(null),scope:d??"section",scopeLabel:"all"===d?"all settings":n,keys:"all"===d&&t?t:a,managed:"all"===d?s:r,invalidate:l}),!o&&(0,i.jsx)(iI,{open:h,onOpenChange:p,envKeys:(t??[]).filter(e=>"environment"===e.source)}),(0,i.jsx)(iM,{open:x,onOpenChange:g,restrict:null==o?void 0:o.includes,invalidate:l})]})}let iL=u.createContext(null);function iO(e){let{panelsRef:t,children:s}=e,a=u.useMemo(()=>({register:(e,s)=>void t.current.set(e,s),unregister:e=>void t.current.delete(e)}),[t]);return(0,i.jsx)(iL.Provider,{value:a,children:s})}function iU(e,t){let s=ip(e),a=u.useContext(iL),{resetField:r}=(0,nq.xW)(),{field:n}=(0,nq.as)({name:s});u.useEffect(()=>
17{if(a)return a.register(s,t),()=>a.unregister(s)});let l=u.useCallback(e=>r(s,{defaultValue:e}),[s,r]);return{name:s,value:n.value,setValue:n.onChange,seed:l}}async function iF(e,t){let s=[];for(let[a,r]of e){let{message:e,value:n}=await r.save(t[a]);e&&s.push(e),void 0!==n&&(t[a]=n)}return s}function iz(e){return{id:e.id,name:e.name??"",type:e.type,url:e.url,apiKey:"",hasApiKey:e.hasApiKey,enabled:!1!==e.enabled,categories:e.categories??[]}}function iV(e){return{id:e.id,name:e.name.trim()||void 0,type:e.type,url:e.url.trim(),apiKey:e.apiKey?e.apiKey:e.hasApiKey?"__stored__":"",enabled:e.enabled,categories:e.categories.map(e=>e.trim()).filter(Boolean)}}function iq(e){let{intent:t,children:s}=e;return(0,i.jsx)("span",{className:x("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium","success"===t?"bg-emerald-500/15 text-emerald-500":"bg-red-500/15 text-red-400"),children:s})}let iB=[{value:"blocklist_search",label:"Replace",help:"Blocklist the release and search for another"},{value:"blocklist",label:"Blocklist",help:"Blocklist it, but do not search again"},{value:"import",label:"Import",help:"Push the import through by hand"},{value:"remove",label:"Remove",help:"Just clear the queue entry"}];function iK(e){return{id:e.id,enabled:e.enabled,action:e.action}}function iH(e){var t,s,a;let r=(0,nq.xW)(),n=r0(),l=null==r||null==(t=r.watch)?void 0:t.call(r,ip(e));if("string"==typeof l&&l)return l;if("boolean"==typeof l||"number"==typeof l)return String(l);let i=null==(a=n.data)||null==(s=a.keys.find(t=>t.key===e))?void 0:s.value;return"boolean"==typeof i||"number"==typeof i?String(i):"string"==typeof i?i:""}function iW(e){let{title:t,note:s,command:a}=e,r=async()=>{try{await navigator.clipboard.writeText(a),m.oR.success("Copied")}catch{m.oR.error("Could not copy to the clipboard")}};return(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:t}),(0,i.jsx)(w,{size:"sm",intent:"white-subtle",icon:(0,i.jsx)(sm.Xpf,{}),onClick:r})]}),s&&(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:s}),(0,i.jsx)("pre",{className:"text-xs bg-[--subtle] rounded-[--radius] p-3 overflow-x-auto whitespace-pre",children:a})]})}function iG(e){let{mountDir:t,davUrl:s}=e,a=`rclone config create aiostreams webdav \\ 18 url=${s} \\ 19 vendor=other \\ 20 user=YOUR_AIOSTREAMS_USER \\ 21 pass="$(rclone obscure YOUR_PASSWORD)"`,r=`rclone mount aiostreams: ${t} \\ 22 --links \\ 23 --read-only \\ 24 --dir-cache-time 20s \\ 25 --vfs-cache-mode off \\ 26 --allow-other`;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(iW,{title:"1. Create the rclone remote",note:"Use an AIOSTREAMS_AUTH user that holds the webdav permission.",command:a}),(0,i.jsx)(iW,{title:"2. Mount it (Linux / Docker)",note:"--links is what turns the .rclonelink files into real symlinks; without it the arrs import a text file. Needs rclone 1.70.3 or newer, plus SYS_ADMIN, /dev/fuse and a shared /mnt bind in Docker.",command:r}),(0,i.jsx)(iW,{title:"Windows",note:"Use rclone with WinFsp rather than mapping the WebDAV URL in Explorer: Explorer's WebDAV client cannot open files larger than 4 GB and drops paths over 260 characters.",command:"rclone mount aiostreams: Z: ^\n --links ^\n --read-only ^\n --network-mode ^\n --dir-cache-time 20s"})]})}function iY(e){let{host:t,port:s,mountDir:a}=e,r=`sudo mkdir -p ${a} 27sudo mount -t nfs4 -o ro,port=${s} ${t}:/ ${a}`;return(0,i.jsx)(iW,{title:"Mount it from another Linux machine",note:"Straight from the kernel, no rclone. That machine's IP has to fall inside Allowed clients, and the mount point must be the same absolute path the arrs use.",command:r})}function iJ(e){let{mountPath:t}=e,s=t.replace(/\/[^/]*$/,"")||"/",a=`services: 28 aiostreams: 29 image: ghcr.io/viren070/aiostreams:latest 30 cap_add: 31 - SYS_ADMIN 32 devices: 33 - /dev/fuse:/dev/fuse:rwm 34 security_opt: 35 - apparmor:unconfined 36 volumes: 37 # rshared is what makes the mount visible to the other containers 38 - ${s}:${s}:rshared 39 40 sonarr: 41 volumes: 42 - ${s}:${s}:rslave`;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(iW,{title:"Docker: give the container what a mount needs",note:`AIOStreams mounts the library at ${t}
42 inside its own container. Every container that reads it (Sonarr, Radarr, Plex, Jellyfin) binds the same parent directory with rslave so the mount shows up at the same path.`,command:a}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"FUSE is Linux only. On Windows or macOS turn the local mount off and mount the WebDAV share with rclone instead; on another Linux machine, the NFS server serves the same tree."})]})}let iZ={off:"Off",unavailable:"Unavailable",mounting:"Mounting",mounted:"Mounted",unmounted:"Not mounted",error:"Failed"},iQ={mounted:"bg-green-500/15 text-green-400",mounting:"bg-blue-500/15 text-blue-400",unavailable:"bg-yellow-500/15 text-yellow-400",error:"bg-red-500/15 text-red-400",unmounted:"bg-[--subtle] text-[--muted]",off:"bg-[--subtle] text-[--muted]"},iX=e=>e.trim().replace(/\/+$/,"");function i0(e){let{label:t,value:s}=e;return(0,i.jsxs)("div",{className:"flex items-baseline justify-between gap-4 text-sm",children:[(0,i.jsx)("span",{className:"text-[--muted]",children:t}),(0,i.jsx)("span",{className:"font-mono text-right break-all",children:s})]})}var i1=s(11482);function i2(e){let t=[];
42return e.releaseKey&&t.push(e.releaseKey),/^[0-9a-f]{40}$/.test(e.nzbHash)&&t.push(`nh1:${e.nzbHash}`),t}let i3=["dashboard","usenet"],i5=[...i3,"settings"],i4=[...i3,"live"],i6=null,i9=0;function i8(){let e=(0,e3.jE)();return(0,e5.n)({mutationFn:e=>ea("POST /dashboard/usenet/stats/reset",{body:{confirm:!0,...e}}),onSuccess:(t,s)=>{s.dryRun||e.invalidateQueries({queryKey:[...i3,"stats"]})}})}function i7(){return(0,e5.n)({mutationFn:e=>{let t=e.download?"download":"play",s=e.fileSel?`/${encodeURIComponent(e.fileSel)}`:"";return ea(`/dashboard/usenet/library/${encodeURIComponent(e.hash)}/${t}${s}`)}})}let oe=["prefetchSegments","maxConcurrentDownloads","segmentDiskCacheBytes"],ot={"arr.instances":function(){let e,t=(0,ty.I)({queryKey:r2,queryFn:()=>ea("/dashboard/arr/instances"),staleTime:1e4}),s=(e=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea("PUT /dashboard/arr/instances",{body:{instances:e}}),onSuccess:()=>e.invalidateQueries({queryKey:rX})})),a=(0,e5.n)({mutationFn:e=>ea("POST /dashboard/arr/instances/test",{body:e})}),[r,n]=u.useState({}),{name:l,value:o,setValue:d,seed:c}=iU("arr.instances",{save:async e=>{let t=await s.mutateAsync(e.map(iV)),a=t.instances.length;return{message:`${a} Sonarr/Radarr instance${1===a?"":"s"}`,value:t.instances.map(iz)}}});if(u.useEffect(()=>{void 0===o&&t.data&&c(t.data.instances.map(iz))},[t.data,o,c]),t.isLoading||void 0===o)return(0,i.jsx)(J,{className:"p-6 flex justify-center",children:(0,i.jsx)(C,{className:"w-6 h-6"})});if(t.isError)return(0,i.jsx)(J,{className:"p-6 text-sm text-red-400",children:"Failed to load Sonarr/Radarr instances."});let h=(e,t)=>d(o.map(s=>s.id===e?{...s,...t}:s)),p=async e=>{n(t=>({...t,[e.id]:"pending"}));try{let t=await a.mutateAsync(iV(e));n(s=>({...s,[e.id]:t})),t.ok?m.oR.success(`${t.appName??"Connected"} ${t.version??""}`):m.oR.error(t.error??"Connection failed")}catch(s){let t={ok:!1,error:(null==s?void 0:s.message)??"Connection failed"};n(s=>({...s,[e.id]:t})),m.oR.error(t.error)}};return(0,i.jsxs)(J,{className:"p-4 space-y-4",children:[(0,i.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"font-semibold",children:"Sonarr / Radarr instances"}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Optional. Lets AIOStreams nudge an instance to import as soon as a grab is ready, and tell it to replace a release the library recheck found dead."})]}),(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",leftIcon:(0,i.jsx)(sm.Ca6,{}),onClick:()=>{var e,t;return d([...o,{id:(null==(t=globalThis.crypto)||null==(e=t.randomUUID)?void 0:e.call(t))??`a_${Math.random().toString(36).slice(2)}`,name:"",type:"sonarr",url:"",apiKey:"",hasApiKey:!1,enabled:!0,categories:[]}])},children:"Add"})]}),0===o.length&&(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No instances configured."}),o.map((e,t)=>{let s=r[e.id];return(0,i.jsxs)(J,{className:"p-4 space-y-3 bg-[--subtle]/30",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(ni,{value:e.enabled,onValueChange:t=>h(e.id,{enabled:t}),label:"Enabled"}),s&&"pending"!==s&&(0,i.jsxs)(iq,{intent:s.ok?"success":"alert",children:[s.ok?(0,i.jsx)(sm.qGT,{}):(0,i.jsx)(sm.wew,{}),s.ok?`${s.appName??"OK"} ${s.version??""}`.trim():"Failed"]})]}),(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)(v,{size:"sm",intent:"white-subtle",leftIcon:(0,i.jsx)(sm.UWw,{}),loading:"pending"===s,onClick:()=>p(e),children:"Test"}),(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),onClick:()=>d(o.filter(t=>t.id!==e.id))})]})]}),(0,i.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,i.jsx)(L,{label:"Name",children:(0,i.jsx)(K,{value:e.name,placeholder:"Sonarr",onValueChange:t=>h(e.id,{name:t})})}),(0,i.jsx)(L,{label:"Application",children:(0,i.jsx)(nc,{value:e.type,options:[{value:"sonarr",label:"Sonarr"},{value:"radarr",label:"Radarr"}],onValueChange:t=>h(e.id,{type:t})})}),(0,i.jsx)(L,{label:"URL",help:"As AIOStreams reaches it, e.g. http://sonarr:8989",children:(0,i.jsx)(K,{value:e.url,placeholder:"http://sonarr:8989",onValueChange:t=>h(e.id,{url:t})})}),(0,i.jsx)(L,{label:"API key",help:e.hasApiKey?"Stored. Leave blank to keep it.":void 0,children:(0,i.jsx)(G,{value:e.apiKey,placeholder:e.hasApiKey?"â¢â¢â¢â¢â¢â¢â¢â¢":"",onValueChange:t=>h(e.id,{apiKey:t})})}),(0,i.jsx)("div",{className:"sm:col-span-2",children:(0,i.jsx)(it,{name:`${l}.${t}.categories`,label:"Categories",help:"Download-client categories this instance owns, spelt exactly as in the arr. Each one is advertised over the SABnzbd API and gets a folder under `completed/`. Leave empty for any."})})]})]},e.id)})]})},"arr.queueCleanup.rules":function(){var e;
42let t,s=(0,ty.I)({queryKey:r3,queryFn:()=>ea("/dashboard/arr/queue-rules"),staleTime:1e4}),a=(t=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea("PUT /dashboard/arr/queue-rules",{body:{rules:e}}),onSuccess:()=>t.invalidateQueries({queryKey:rX})})),r=null==(e=s.data)?void 0:e.rules,{value:n,setValue:l,seed:o}=iU("arr.queueCleanup.rules",{save:async e=>{let t=await a.mutateAsync(e),s=t.rules.filter(e=>e.enabled).length;return{message:`${s} queue cleanup rule${1===s?"":"s"}`,value:t.rules.map(iK)}}});if(u.useEffect(()=>{void 0===n&&r&&o(r.map(iK))},[r,n,o]),s.isLoading||void 0===n)return(0,i.jsx)(J,{className:"p-6 flex justify-center",children:(0,i.jsx)(C,{className:"w-6 h-6"})});if(s.isError||!r)return(0,i.jsx)(J,{className:"p-6 text-sm text-red-400",children:"Failed to load the queue cleanup rules."});let d=(e,t)=>l(n.map(s=>s.id===e?{...s,...t}:s));return(0,i.jsxs)(J,{className:"p-4 space-y-4",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"font-semibold",children:"Queue cleanup rules"}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"When an arr cannot import one of our downloads it says why. Each reason below gets one of four responses. Only downloads AIOStreams handed over are ever touched."})]}),(0,i.jsx)("div",{className:"space-y-2",children:n.map(e=>{var t;let s=r.find(t=>t.id===e.id);return s?(0,i.jsxs)("div",{className:x("flex flex-col gap-2 rounded-[--radius] border border-[--border] p-3","sm:flex-row sm:items-center sm:justify-between",!e.enabled&&"opacity-60"),children:[(0,i.jsxs)("div",{className:"flex items-start gap-3 min-w-0",children:[(0,i.jsx)(ni,{value:e.enabled,onValueChange:t=>d(e.id,{enabled:t})}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:s.label}),(0,i.jsxs)("p",{className:"text-xs text-[--muted] truncate",children:["â",s.phrase,"â"]}),s.note&&(0,i.jsx)("p",{className:"text-xs text-[--muted] mt-0.5",children:s.note})]})]}),(0,i.jsx)("div",{className:"sm:w-48 shrink-0",children:(0,i.jsx)(nc,{value:e.action,disabled:!e.enabled,options:iB.map(e=>({value:e.value,label:e.label})),onValueChange:t=>d(e.id,{action:t}),help:null==(t=iB.find(t=>t.value===e.action))?void 0:t.help})})]},e.id):null})})]})},"shares.fuse":function(){var e;let t,s="true"===iH("shares.fuse.enabled"),a=(e={enabled:s},(0,ty.I)({queryKey:r1,queryFn:()=>ea("/dashboard/shares/fuse/status"),refetchInterval:5e3,enabled:(null==e?void 0:e.enabled)??!0})),r=(t=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea(`POST /dashboard/shares/fuse/${e}`),onSuccess:e=>t.setQueryData(r1,e)})),n=iH("shares.fuse.mountPath"),l=iH("arr.mountDir");if(!s)return null;let o=a.data,d=(null==o?void 0:o.mountPath)||n||"/mnt/aiostreams",c=(null==o?void 0:o.state)??"off",u=r.isPending||"mounting"===c,h=async e=>{try{let t=await r.mutateAsync(e);"mounted"===t.state?m.oR.success(`Mounted at ${t.mountPath}`):"unmounted"===t.state?m.oR.success("Unmounted"):t.error?m.oR.error(t.error):t.reason&&m.oR.warning(t.reason)}catch(e){m.oR.error(e.message)}};return(0,i.jsxs)(J,{className:"p-4 space-y-4",children:[(0,i.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"font-semibold",children:"Mount status"}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"AIOStreams mounts the library itself; Sonarr, Radarr and your media server read it as an ordinary folder with real symlinks."})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,i.jsx)("span",{className:x("rounded-full px-2.5 py-0.5 text-xs font-medium",iQ[c]),children:iZ[c]}),(0,i.jsx)(w,{size:"sm",intent:"white-subtle",icon:(0,i.jsx)(sm.Zxy,{}),loading:a.isFetching,onClick:()=>a.refetch()})]})]}),(0,i.jsxs)("div",{className:"space-y-1.5",children:[(0,i.jsx)(i0,{label:"Mount path",value:d}),(null==o?void 0:o.since)&&"mounted"===c&&(0,i.jsx)(i0,{label:"Since",value:new Date(o.since).toLocaleString()}),(null==o?void 0:o.stats)&&"mounted"===c&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(i0,{label:"Open files",value:o.stats.openFiles}),(0,i.jsx)(i0,{label:"In-flight reads",value:o.stats.pendingRequests}),(0,i.jsx)(i0,{label:"Cached inodes",value:o.stats.inodes}),(0,i.jsx)(i0,{label:"Requests",value:`${o.stats.requests} (${o.stats.errors} failed)`})]})]}),"unavailable"===c&&(null==o?void 0:o.reason)&&(0,i.jsx)(lB,{intent:"warning",title:"This host cannot mou
42nt",description:o.reason}),"error"===c&&(null==o?void 0:o.error)&&(0,i.jsx)(lB,{intent:"alert",title:"Mount failed",description:o.error}),a.error&&(0,i.jsx)(lB,{intent:"alert",title:"Could not read the mount status",description:a.error.message}),l.trim()?iX(l)!==iX(d)?(0,i.jsx)(lB,{intent:"info",title:"Mount directory differs from the FUSE mount path",description:`Sonarr / Radarr are told ${iX(l)} while AIOStreams mounts at ${iX(d)}. That is right only if the arr container binds the mount at a different path; otherwise make them the same.`}):null:(0,i.jsx)(lB,{intent:"warning",title:"Sonarr / Radarr mount directory is empty",description:`Set it to ${d} (the path the arr sees the mount at) so the symlinks it imports resolve. Grabs work without it; imports do not.`}),(0,i.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"primary",loading:u&&"mount"===r.variables,disabled:u||"mounted"===c,onClick:()=>h("mount"),children:"error"===c||"unavailable"===c?"Retry mount":"Mount"}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",loading:u&&"unmount"===r.variables,disabled:u||"mounted"!==c,onClick:()=>h("unmount"),children:"Unmount"})]})]})},"shares.connect":function(){let e="true"===iH("shares.fuse.enabled"),t=iH("arr.mountDir")||"/mnt/aiostreams",s=iH("shares.fuse.mountPath")||"/mnt/aiostreams",a="false"!==iH("shares.webdav.enabled"),r="true"===iH("shares.nfs.enabled"),n=iH("shares.nfs.port")||"2049",l=(iH("bootstrap.baseUrl")||("u">typeof window?window.location.origin:"")).replace(/\/$/,""),o=`${l}/webdav`,d="AIOSTREAMS_HOST";try{d=new URL(l).hostname||d}catch{}return(0,i.jsxs)(J,{className:"p-4 space-y-5",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"font-semibold",children:"Connect"}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Mount the share so Sonarr, Radarr, Plex or Jellyfin can read files the engine streams on demand. The mount path must be the same absolute path in every container that reads it â that is what the Sonarr / Radarr mount directory setting records."})]}),e?(0,i.jsx)(iJ,{mountPath:s}):(0,i.jsxs)(i.Fragment,{children:[a&&(0,i.jsx)(iG,{mountDir:t,davUrl:o}),r&&(0,i.jsx)(iY,{host:d,port:n,mountDir:t}),!a&&!r&&(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Nothing is being served right now: turn the local mount on, or switch on the WebDAV or NFS server above."})]}),a&&(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:"Without mounting anything"}),(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["A player that speaks WebDAV (Infuse, VLC, a file manager) can open"," ",(0,i.jsx)("code",{className:"font-mono",children:o})," directly, signed in as an AIOSTREAMS_AUTH user with the webdav permission. Nothing needs mounting for that â but Sonarr and Radarr do need a real folder."]})]})]})}},os={usenet:function(){var e;let{setValue:t,getValues:s}=(0,nq.xW)(),a=null==(e=(0,ty.I)({queryKey:i5,queryFn:()=>ea("/dashboard/usenet/settings"),staleTime:1e4,enabled:(void 0)??!0}).data)?void 0:e.profiles,r=ip("usenet.performanceProfile"),n=oe.map(e=>ip(`usenet.${e}`)),l=(0,nq.FH)({name:r}),i=(0,nq.FH)({name:n[0]}),o=(0,nq.FH)({name:n[1]}),d=(0,nq.FH)({name:n[2]}),c=u.useRef(!1);return u.useEffect(()=>{let e=a&&l&&"custom"!==l?a[l]:void 0;if(!e||oe.every((t,a)=>Number(s(n[a]))===e[t]))return;c.current=!0,oe.forEach((s,a)=>t(n[a],e[s],{shouldDirty:!0}));let r=setTimeout(()=>{c.current=!1},0);return()=>clearTimeout(r)},[l,a]),u.useEffect(()=>{if(c.current)return;let e=a&&l&&"custom"!==l?a[l]:void 0;if(!e)return;let s=[i,o,d];oe.every((t,a)=>Number(s[a])===e[t])||t(r,"custom",{shouldDirty:!0})},[i,o,d]),null}},oa=e=>e?Array.isArray(e)?e:[e]:[];function or(e,t){return e.every(e=>{let s=t(e.key);return void 0===s||(void 0!==e.not?s!==e.not:s===e.equals)})}function on(e){let t=(0,nq.FH)({name:e.map(ip)}),s=new Map(e.map((e,s)=>[e,t[s]]));return e=>s.get(e)}function ol(e){let{when:t,children:s}=e,a=on(t.map(e=>e.key));return or(t,a)?(0,i.jsx)(i.Fragment,{children:s}):null}function oi(e){let{when:t,children:s}=e,a=oa(t);return 0===a.length?(0,i.jsx)(i.Fragment,{children:s}):(0,i.jsx)(ol,{when:a,children:s})}function oo(e){let{own:t,fields:s,children:a}=e,r=on([...new Set([...t,...s.flat()].map(e=>e.key))]);return or(t,r)&&s.some(e=>or(e,r))?(0,i.jsx)(i.Fragment,{children:a}):null}function od(e){let{when:t,fields:s,children:a}=e,r=oa(t),n=s.map(oa);return 0===r.length&&n.some(e=>0===e.length)?(0,i.jsx)(i.Fragment,{children:a}):(0,i.jsx)(oo,{own:r,fields:n,children:a})}function oc(e){let t,{tab:s,allKeys:a,managed:r}=e,{mutateAsync:n,isPending:l}=(t=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea("PATCH /dashboard/settings",{body:e}),onSettled:()=>
42t.invalidateQueries({queryKey:rX})})),o=u.useRef(new Map),d=u.useMemo(()=>{let e=new Set((s.cards??[]).flatMap(e=>"editor"in e?[e.editor]:[]));return((s.editors??[]).filter(t=>!e.has(t))??[]).map(e=>ot[e]).filter(e=>!!e)},[s.cards,s.editors]),c=u.useRef(null),h=u.useMemo(()=>[...s.groups.values()].flat(),[s]),{schema:p,defaults:x,byName:g}=u.useMemo(()=>{let e={},t={},a=new Map;for(let s of h){let r=ip(s.key);e[r]=nV.bz(),s.secret||null===s.value&&"enum"===s.ui.kind?t[r]="":t[r]=s.value,a.set(r,s)}for(let a of s.editors??[]){let s=ip(a);e[s]=nV.bz(),t[s]=void 0}return{schema:nV.Ik(e),defaults:t,byName:a}},[h,s.editors]);return(0,i.jsx)(n3,{schema:p,defaultValues:x,stackClass:"space-y-4 relative",onSubmit:async e=>{var t,s,a,r,l;let i={};for(let[t,s]of Object.entries(e)){let e=g.get(t);if(!e||"environment"===e.source)continue;if(e.secret){s===l9?i[e.key]=null:""!==s&&null!=s&&(i[e.key]=s);continue}let a=(null===e.value||null===e.default)&&""===s?null:s;JSON.stringify(a)!==JSON.stringify(e.value)&&(i[e.key]=a)}let d=null==(t=c.current)?void 0:t.formState.defaultValues,u=(l=o.current,[...l].filter(t=>{let[s]=t;return void 0!==e[s]&&JSON.stringify(e[s])!==JSON.stringify(null==d?void 0:d[s])}));if(0===Object.keys(i).length&&0===u.length){m.oR.info("No changes to save."),null==(s=c.current)||s.reset(e,{keepValues:!0,keepIsValid:!0});return}try{let t=[],s={updated:[],requiresRestart:!1};for(let[a]of(Object.keys(i).length>0&&(s=await n(i),t.push(`${s.updated.length} setting${1===s.updated.length?"":"s"}`)),t.push(...await iF(u,e)),u))null==(r=c.current)||r.setValue(a,e[a],{shouldDirty:!1});m.oR.success(`Saved ${t.join(" and ")}.`),null==(a=c.current)||a.reset(e,{keepValues:!0,keepIsValid:!0}),s.requiresRestart&&m.oR.warning("Some changes require a restart to take effect.",{duration:8e3})}catch(t){let e=null==t?void 0:t.issues;if(e)for(let[t,s]of Object.entries(e))m.oR.error(`${t}: ${s}`);else m.oR.error((null==t?void 0:t.message)??"Failed to save settings")}},children:e=>{c.current=e;let t=os[s.section],n=[...s.groups.keys()],u=!s.curated&&n.includes("")?["",...n.filter(e=>""!==e)]:n,m=s.cards?[...s.cards.map(e=>"editor"in e?{editor:e.editor,when:e.visibleWhen}:{title:e.title,note:e.note,when:e.visibleWhen}),...s.groups.has("Other")?[{title:"Other"}]:[]]:u.map(e=>{var t;return{title:e,when:null==(t=s.cardVisibility)?void 0:t[e]}});return(0,i.jsxs)(iO,{panelsRef:o,children:[t&&(0,i.jsx)(t,{}),(0,i.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,i.jsx)(lz,{title:s.label,description:`${s.label} configuration`,icon:s.icon}),(0,i.jsx)("div",{className:"pt-1",children:(0,i.jsx)(iD,{allKeys:a,allManagedKeys:r,sectionKeys:h,sectionManagedKeys:r.filter(e=>{var t;return null==(t=s.editors)?void 0:t.includes(e.key)}),sectionLabel:s.label})})]}),m.map(e=>{if("editor"in e){let t=ot[e.editor];return t?(0,i.jsx)(oi,{when:e.when,children:(0,i.jsx)(t,{})},`editor:${e.editor}`):null}let t=s.groups.get(e.title);return(null==t?void 0:t.length)?(0,i.jsx)(od,{when:e.when,fields:t.map(e=>{var t;return null==(t=s.fieldVisibility)?void 0:t[e.key]}),children:(0,i.jsxs)(lF,{title:s.curated?e.title:e.title?e.title.split(".").map(rZ).join(" ⺠"):void 0,children:[s.curated&&e.note&&(0,i.jsx)("p",{className:"text-sm text-[--muted] -mt-1",children:(0,i.jsx)(l6,{children:e.note})}),t.map(e=>{var t;return(0,i.jsx)(oi,{when:null==(t=s.fieldVisibility)?void 0:t[e.key],children:(0,i.jsx)("div",{id:`setting-${e.key}`,children:(0,i.jsx)(ib,{k:e})})},e.key)})]})},e.title||"_root"):null}),d.map((e,t)=>(0,i.jsx)(e,{},t)),(0,i.jsx)("div",{className:"flex justify-end pt-2",children:(0,i.jsx)(lK,{isPending:l})}),(0,i.jsx)(lH,{isPending:l})]})}})}function ou(e){let{className:t}=e;return(0,i.jsx)("div",{className:x("p-8 flex items-center justify-center w-full",t),children:(0,i.jsx)(C,{className:"w-6 h-6"})})}function om(e){let{title:t="Failed to load",message:s,onRetry:a,retrying:r=!1,className:n}=e;return(0,i.jsxs)(J,{className:x("p-6 flex flex-col items-center text-center gap-3",n),children:[(0,i.jsx)(sm.wew,{className:"w-8 h-8 text-red-400"}),(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsx)("p",{className:"font-medium",children:t}),s&&(0,i.jsx)("p",{className:"text-sm text-[--muted] break-words max-w-md",children:s})]}),a&&(0,i.jsx)(v,{size:"sm",intent:"warning-subtle",leftIcon:(0,i.jsx)(sm.Zxy,{}),loading:r,onClick:a,children:"Retry"})]})}function oh(e){let{query:t,skeleton:s,errorTitle:a,children:r}=e;return t.isPending?(0,i.jsx)(i.Fragment,{children:s??(0,i.jsx)(ou,{})}):t.isError?(0,i.jsx)(om,{title:a??"Failed to load",message:function(e){if(!e)return"Unknown error";if(e instanceof Error)return e.message;if("string"==typeof e)return e;try{return JSON.stringify(e)}catch{return String(e)}}(t.error),onRetry:()=>
42t.refetch(),retrying:t.isFetching}):(0,i.jsx)(i.Fragment,{children:r(t.data)})}var op=s(58396),ox=s(89507),og=s(95321),of=s(35634),ob=s(93825),ov=s(60502),oy=s(92666),oj=s(4097),ow=s(65814),oN=s(21519),ok=s(88810),oS=s(77341),oC=s(43773),o_=s(77444),oA=s(2980);let oR=["var(--brand)","#22c55e","#f59e0b","#06b6d4","#a855f7","#ef4444","#ec4899","#14b8a6"],oT={stroke:"var(--muted)",fontSize:11,tickLine:!1,axisLine:!1},oI={...oT,interval:"preserveStartEnd",minTickGap:24};function oE(e){var t,s;let{active:a,payload:r,label:n,valueFormatter:l,tooltipLabelKey:o}=e;if(!a||!(null==r?void 0:r.length))return null;let d=(o?null==(s=r[0])||null==(t=s.payload)?void 0:t[o]:void 0)??n;return(0,i.jsxs)("div",{className:"rounded-lg border border-[--border] bg-[--paper] px-3 py-2 text-xs shadow-xl",children:[void 0!==d&&(0,i.jsx)("div",{className:"mb-1 font-medium text-[--foreground]",children:d}),r.map((e,t)=>(0,i.jsxs)("div",{className:"flex items-center gap-2 tabular-nums",children:[(0,i.jsx)("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:e.color||e.fill}}),(0,i.jsx)("span",{className:"text-[--muted]",children:e.name}),(0,i.jsx)("span",{className:"ml-auto font-medium text-[--foreground]",children:l?l(e.value):e.value})]},t))]})}function oM(e,t){return e.color??oR[t%oR.length]}function oP(e){let{data:t,xKey:s,series:a,height:r=260,className:n,valueFormatter:l,yTickFormatter:o,tooltipLabelKey:d,hideLegend:c,hideGrid:u}=e;return(0,i.jsx)("div",{className:x("w-full",n),children:(0,i.jsx)(op.u,{width:"100%",height:r,children:(0,i.jsxs)(ox.b,{data:t,margin:{top:8,right:8,bottom:0,left:0},children:[!u&&(0,i.jsx)(og.d,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),(0,i.jsx)(of.W,{dataKey:s,...oI}),(0,i.jsx)(ob.h,{...oT,width:o?60:40,tickFormatter:o}),(0,i.jsx)(ov.m,{content:(0,i.jsx)(oE,{valueFormatter:l,tooltipLabelKey:d}),cursor:{stroke:"var(--border)"}}),!c&&a.length>1&&(0,i.jsx)(oy.s,{wrapperStyle:{fontSize:12}}),a.map((e,t)=>(0,i.jsx)(oj.N1,{type:"monotone",dataKey:e.key,name:e.label??e.key,stroke:oM(e,t),strokeWidth:2,dot:!1,activeDot:{r:4}},e.key))]})})})}function o$(e){let{data:t,xKey:s,series:a,height:r=260,className:n,stacked:l,valueFormatter:o,yTickFormatter:d,tooltipLabelKey:c,hideLegend:u,hideGrid:m}=e;return(0,i.jsx)("div",{className:x("w-full",n),children:(0,i.jsx)(op.u,{width:"100%",height:r,children:(0,i.jsxs)(ow.Q,{data:t,margin:{top:8,right:8,bottom:0,left:0},children:[(0,i.jsx)("defs",{children:a.map((e,t)=>(0,i.jsxs)("linearGradient",{id:`grad-${e.key}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,i.jsx)("stop",{offset:"5%",stopColor:oM(e,t),stopOpacity:.35}),(0,i.jsx)("stop",{offset:"95%",stopColor:oM(e,t),stopOpacity:0})]},e.key))}),!m&&(0,i.jsx)(og.d,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),(0,i.jsx)(of.W,{dataKey:s,...oI}),(0,i.jsx)(ob.h,{...oT,width:d?60:40,tickFormatter:d}),(0,i.jsx)(ov.m,{content:(0,i.jsx)(oE,{valueFormatter:o,tooltipLabelKey:c}),cursor:{stroke:"var(--border)"}}),!u&&a.length>1&&(0,i.jsx)(oy.s,{wrapperStyle:{fontSize:12}}),a.map((e,t)=>(0,i.jsx)(oN.Gk,{type:"monotone",dataKey:e.key,name:e.label??e.key,stackId:l?"stack":void 0,stroke:oM(e,t),strokeWidth:2,fill:`url(#grad-${e.key})`},e.key))]})})})}function oD(e){let{data:t,xKey:s,series:a,height:r=260,className:n,stacked:l,valueFormatter:o,hideLegend:d,hideGrid:c}=e;return(0,i.jsx)("div",{className:x("w-full",n),children:(0,i.jsx)(op.u,{width:"100%",height:r,children:(0,i.jsxs)(ok.E,{data:t,margin:{top:8,right:8,bottom:0,left:0},children:[!c&&(0,i.jsx)(og.d,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),(0,i.jsx)(of.W,{dataKey:s,...oT}),(0,i.jsx)(ob.h,{...oT,width:40}),(0,i.jsx)(ov.m,{content:(0,i.jsx)(oE,{valueFormatter:o}),cursor:{fill:"var(--subtle)"}}),!d&&a.length>1&&(0,i.jsx)(oy.s,{wrapperStyle:{fontSize:12}}),a.map((e,t)=>(0,i.jsx)(oS.yP,{dataKey:e.key,name:e.label??e.key,stackId:l?"stack":void 0,fill:oM(e,t),radius:l?0:[4,4,0,0]},e.key))]})})})}function oL(e){let{data:t,height:s=200,className:a,centerLabel:r,centerValue:n,valueFormatter:l}=e;return(0,i.jsxs)("div",{className:x("relative w-full",a),children:[(0,i.jsx)(op.u,{width:"100%",height:s,children:(0,i.jsxs)(oC.r,{children:[(0,i.jsx)(o_.Fq,{data:t,dataKey:"value",nameKey:"name",innerRadius:"62%",outerRadius:"90%",paddingAngle:2,stroke:"none",children:t.map((e,t)=>(0,i.jsx)(oA.f,{fill:e.color??oR[t%oR.length]},t))}),(0,i.jsx)(ov.m,{content:(0,i.jsx)(oE,{valueFormatter:l})})]})}),(n||r)&&(0,i.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center",children:[n&&(0,i.jsx)("span",{className:"text-xl font-bold tabular-nums text-[--foreground]",children:n}),r&&(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:r})]})]})}function oO(e){let{data:t,color:s="var(--brand)",width:a=80,height:r=24,className:n}=e;if(!t.length)return null;let l=Math.min(...t),o=Math.max(...t)-l||1,d=t.map((e,s)=>{let n=s/(t.length-1||1)*a,i=r-(e-l)/o*r;return`${n.toFixed(1)},${i.toFixed(1)}`}).join(" ");return(0,i.jsx)("svg",{width:a,height:r,className:x("overflow-visible",n),preserveAspectRatio:"none",children:(0,i.jsx)("polyline",{points:d,fill:"none",stroke:s,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"})})}function oU(e){let{label:t,value:s,hint:a,delta:r,spark:n,className:l}=e;return(0,i.jsxs)("div",{className:x("rounded-xl border border-[--border] bg-[--paper] p-4 flex flex-col gap-1",l),children:[(0,i.jsx)("span",{className:"text-xs uppercase tracking-wide text-[--muted]",children:t}),(0,i.jsxs)("div",{className:"flex items-end justify-between gap-2",children:[(0,i.jsx)("span",{className:"text-2xl font-bold tabular-nums text-[--foreground]",children:s}),n&&(0,i.jsx)(oO,{data:n})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[r&&(0,i.jsx)("span",{className:x("text-xs font-medium",r.positive?"text-emerald-500":"text-red-500"),children:r.value}),a&&(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:a})]})]})}function oF(e){let{value:t}
42=e,s=nT(t),a=t.toLocaleString();return s===a?(0,i.jsx)("span",{className:"tabular-nums",children:s}):(0,i.jsx)(t5,{trigger:(0,i.jsx)("span",{className:"tabular-nums cursor-default border-b border-dotted border-[--muted]/40",children:s}),children:a})}let oz=["24h","7d","30d","all"];function oV(e){let{value:t,onChange:s}=e;return(0,i.jsx)("div",{className:"flex gap-1",children:oz.map(e=>(0,i.jsx)("button",{onClick:()=>s(e),className:x("px-2.5 py-1 rounded-md text-xs font-medium border transition-colors",t===e?"border-brand bg-brand/10 text-brand":"border-[--border] text-[--muted] hover:text-[--foreground]"),children:e},e))})}function oq(e){var t;let{title:s,rows:a}=e,r=a.slice(0,12),n=(null==(t=r[0])?void 0:t.count)??0;return(0,i.jsxs)("div",{children:[(0,i.jsx)("h4",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-2",children:s}),0===r.length?(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No data for this range."}):(0,i.jsx)("ul",{className:"space-y-1.5",children:r.map(e=>(0,i.jsxs)("li",{className:"text-sm",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,i.jsx)("span",{className:"truncate font-medium",children:e.key}),(0,i.jsx)("span",{className:"text-[--muted]",children:(0,i.jsx)(oF,{value:e.count})})]}),(0,i.jsx)("div",{className:"h-1 rounded-full bg-[--subtle] overflow-hidden",children:(0,i.jsx)("div",{className:"h-full bg-brand",style:{width:n?`${e.count/n*100}%`:"0%"}})})]},e.key))})]})}function oB(e){let{uuidHash:t,range:s,onClose:a}=e,r=(0,ty.I)({queryKey:["dashboard","analytics","user-activity",t,s],queryFn:()=>ea(`/dashboard/analytics/users/${t}?range=${s}`),enabled:!!t,staleTime:3e4}),n=r.data,l=n?Math.max(1,...n.resources.map(e=>e.count)):1;return(0,i.jsx)(sl,{open:!!t,onOpenChange:e=>{e||a()},title:"User activity",description:t?`Hashed config ${t.slice(0,16)} \xb7 ${s}`:void 0,contentClass:"max-w-xl",children:r.isLoading?(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Loadingâ¦"}):r.isError?(0,i.jsx)("p",{className:"text-sm text-red-400",children:"Failed to load user activity."}):n?(0,i.jsxs)("div",{className:"space-y-5",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-[--muted]",children:"Requests by resource"}),0===n.resources.length?(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No requests in this range."}):(0,i.jsx)("ul",{className:"space-y-1.5",children:n.resources.map(e=>(0,i.jsxs)("li",{className:"text-sm",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,i.jsx)("span",{className:"font-medium",children:e.resource}),(0,i.jsx)("span",{className:"text-[--muted]",children:(0,i.jsx)(oF,{value:e.count})})]}),(0,i.jsx)("div",{className:"h-1 overflow-hidden rounded-full bg-[--subtle]",children:(0,i.jsx)("div",{className:"h-full bg-brand",style:{width:`${e.count/l*100}%`}})})]},e.resource))})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-[--muted]",children:["IP addresses (",n.ips.length,")"]}),0===n.ips.length?(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No IP data recorded for this user."}):(0,i.jsx)("div",{className:"max-h-64 overflow-y-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"text-xs uppercase text-[--muted]",children:(0,i.jsxs)("tr",{className:"border-b border-[--border] text-left",children:[(0,i.jsx)("th",{className:"py-1.5 pr-3",children:"Anonymized IP"}),(0,i.jsx)("th",{className:"py-1.5 px-3 text-right",children:"Requests"}),(0,i.jsx)("th",{className:"py-1.5 pl-3 text-right",children:"Last seen"})]})}),(0,i.jsx)("tbody",{children:n.ips.map(e=>(0,i.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,i.jsx)("td",{className:"py-1.5 pr-3 font-mono text-xs",children:e.ipPrefix}),(0,i.jsx)("td",{className:"py-1.5 px-3 text-right",children:(0,i.jsx)(oF,{value:e.count})}),(0,i.jsx)("td",{className:"py-1.5 pl-3 text-right whitespace-nowrap text-[--muted]",children:new Date(e.lastSeen).toLocaleStr
42ing()})]},e.ipPrefix))})]})})]})]}):null})}let oK=e=>({ts:e.ts,cpu:{total:e.cpu.total,process:e.cpu.process,perCore:e.cpu.perCore},memory:{used:e.memory.used,heapUsed:e.memory.heapUsed,heapTotal:e.memory.heapTotal,external:e.memory.external,rss:e.memory.rss}});function oH(){let[e,t]=u.useState(null),[s,a]=u.useState(!1),[r,n]=u.useState(null),[l,i]=u.useState(0),o=u.useRef([]),[d,c]=u.useState([]),m=u.useCallback(e=>{var t;let s=new Map(o.current.map(e=>[e.ts,e]));for(let t of e)s.set(t.ts,t);let a=[...s.values()].sort((e,t)=>e.ts-t.ts),r=((null==(t=a.at(-1))?void 0:t.ts)??0)-3e5,n=a.filter(e=>e.ts>=r).slice(-120);o.current=n,c(n)},[]),h=u.useCallback(()=>{n(null),i(e=>e+1)},[]);return u.useEffect(()=>{let e=!1;ea("/dashboard/system").then(s=>{e||(t(s),n(null),m([...s.history??[],oK(s)]))}).catch(t=>{e||n(e=>e??(t instanceof Error?t.message:"Failed to load system metrics"))});let s=new EventSource("/api/v1/dashboard/system/stream",{withCredentials:!0});return s.onopen=()=>{a(!0),n(null)},s.onerror=()=>a(!1),s.onmessage=e=>{try{let s=JSON.parse(e.data);t(e=>({...s,lifecycleEnabled:null==e?void 0:e.lifecycleEnabled})),m([oK(s)])}catch{}},()=>{e=!0,s.close()}},[m,l]),{metrics:e,connected:s,history:d,windowMs:3e5,error:r,retry:h}}function oW(e){let{label:t,pct:s,detail:a}=e;return(0,i.jsxs)(J,{className:"p-4 flex flex-col items-center",children:[(0,i.jsx)("span",{className:"text-xs uppercase tracking-wide text-[--muted] mb-2",children:t}),(0,i.jsx)(oL,{height:150,data:[{name:t,value:s,color:s>90?"#ef4444":s>70?"#f59e0b":"var(--brand)"},{name:"free",value:100-s,color:"var(--subtle)"}],centerValue:`${Math.round(s)}%`}),(0,i.jsx)("span",{className:"text-xs text-[--muted] mt-2",children:a})]})}let oG=e=>{let t=new Date(e);return[t.getHours(),t.getMinutes(),t.getSeconds()].map(e=>String(e).padStart(2,"0")).join(":")},oY=[{key:"heapUsed",label:"Heap used",color:"var(--brand)"},{key:"heapSlack",label:"Heap slack",color:"#06b6d4"},{key:"external",label:"External",color:"#a855f7"},{key:"other",label:"Other",color:"#64748b"}];function oJ(e){return{heapUsed:e.heapUsed,heapSlack:Math.max(0,e.heapTotal-e.heapUsed),external:e.external,other:Math.max(0,e.rss-e.heapTotal-e.external)}}function oZ(e){let{memory:t,history:s}=e,[a,r]=u.useState("process"),n="system"===a?{data:s.map(e=>({t:oG(e.ts),used:e.memory.used})),series:[{key:"used",label:"Used"}]}:{data:s.map(e=>({t:oG(e.ts),...oJ(e.memory)})),series:oY.map(e=>({key:e.key,label:e.label,color:e.color}))},l=oJ(t),o="process"===a?oY.map(e=>({label:e.label,color:e.color,value:l[e.key]})):[{label:"Used",color:"var(--brand)",value:t.used},{label:"Free",color:"#64748b",value:t.free},{label:"This process",color:"#a855f7",value:t.rss}];return(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:[(0,i.jsxs)("div",{className:"flex items-baseline gap-3",children:[(0,i.jsx)("h3",{className:"text-sm font-semibold",children:"Memory usage"}),(0,i.jsxs)("span",{className:"text-sm",children:[(0,i.jsx)("span",{className:"text-xs text-[--muted] mr-1",children:"process"===a?"RSS":"Used"}),(0,i.jsx)("span",{className:"font-medium",children:ny("process"===a?t.rss:t.used)}),"system"===a&&(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:[" / ",ny(t.total)]})]})]}),(0,i.jsx)(oQ,{value:a,onChange:r,options:[{value:"system",label:"System"},{value:"process",label:"Process"}]})]}),(0,i.jsx)(o$,{data:n.data,xKey:"t",series:n.series,height:200,stacked:"process"===a,hideLegend:!0,valueFormatter:ny,yTickFormatter:ny}),(0,i.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-4 text-sm",children:o.map(e=>(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"text-xs text-[--muted] flex items-center gap-1.5",children:[(0,i.jsx)("span",{className:"inline-block w-2 h-2 rounded-full shrink-0",style:{background:e.color}}),e.label]}),(0,i.jsx)("div",{className:"font-medium",children:ny(e.value)})]},e.label))})]})}function oQ(e){let{value:t,onChange:s,options:a}=e;return(0,i.jsx)("div",{className:"inline-flex rounded-md border border-[--border] bg-[--subtle]/30 p-0.5 text-xs",children:a.map(e=>(0,i.jsx)("button",{type:"button",onClick:()=>!e.disabled&&s(e.value),disabled:e.disabled,title:e.title,className:x("px-2.5 py-1 rounded-[5px] transition-colors",t===e.value?"bg-[--paper] text-[--foreground] shadow-sm":"text-[--muted] hover:text-[--foreground]",e.disabled&&"opacity-40 cursor-not-allowed hover:text-[--muted]"),children:e.label},e.value))})}let oX=["10","25","50","100"],o0=e=>{if(!e)return"never";let t=(Date.now()-e)/1e3;return t<0?`in ${nS(-t)}`:`${nS(t)} ago`},o1=e=>null==e?"":"0s"===nS(e/1e3)?`${e}ms`:nS(e/1e3),o2={memory:"bg-sky-500/10 text-sky-500 border-sky-500/20",sql:"bg-violet-500/10 text-violet-500 border-violet-500/20",redis:"bg-red-500/10 text-red-400 border-red-400/20",disk:"bg-amber-500/10 text-amber-500 border-amber-500/20"};function o3(e){let{sections:t,value:s,onChange:a}=e,[r,n]=u.useState(!1),l=u.useRef(null),o=t.find(e=>e.id===s)??t[0],d=o.icon;return u.useEffect(()=>{if(!r)return;let e=e=>{l.current&&!l.current.contains(e.target)&&n(!1)},t=e=>{"Escape"===e.key&&n(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[r]),(0,i.jsxs)("div",{ref:l,className:"relative sm:hidden",children:[(0,i.jsxs)("button",{type:"button","aria-haspopup":"listbox","aria-expanded":r,onClick:()=>n(e=>!e),className:"flex h-11 w-full items-center gap-2.5 rounded-full border border-[--border] bg-[--subtle]/40 px-4 text-sm font-medium",children:[(0,i.jsx)(d,{className:"shrink-0 text-lg text-[--muted]"}),(0,i.jsx)("span",{className:"flex-1 text-left",children:o.label}),(0,i.jsx)(sm.nwe,{className:x("text-lg text-[--muted] transition-transform",r&&"rotate-180")}
42)]}),(0,i.jsx)(t7.N,{children:r&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(se.P.div,{className:"fixed inset-0 w-screen z-40 bg-black/30",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>n(!1)}),(0,i.jsx)(se.P.ul,{role:"listbox",initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.15,ease:"easeOut"},className:"absolute inset-x-0 top-full z-50 mt-2 overflow-hidden rounded-xl border border-[--border] bg-[--background] shadow-lg",children:t.map(e=>{let t=e.id===s,r=e.icon;return(0,i.jsx)("li",{children:(0,i.jsxs)("button",{type:"button",role:"option","aria-selected":t,onClick:()=>{a(e.id),n(!1)},className:x("flex w-full items-center gap-3 px-4 py-3 text-sm transition-colors",t?"bg-[--subtle] font-medium text-[--foreground]":"text-[--muted] hover:bg-[--subtle]/40 hover:text-[--foreground]"),children:[(0,i.jsx)(r,{className:"shrink-0 text-lg"}),(0,i.jsx)("span",{className:"flex-1 text-left",children:e.label}),t&&(0,i.jsx)(sm.mmP,{className:"text-lg text-[--muted]"})]})},e.id)})})]})})]})}let o5=["dead","defective","fake","mislabeled"],o4=["full","corroborate","observe"],o6={dead:"bg-red-500/10 text-red-400 border-red-400/20",defective:"bg-amber-500/10 text-amber-500 border-amber-500/20",fake:"bg-fuchsia-500/10 text-fuchsia-500 border-fuchsia-500/20",mislabeled:"bg-sky-500/10 text-sky-500 border-sky-500/20"},o9={usenet:"bg-violet-500/10 text-violet-500 border-violet-500/20",torrent:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",local:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",remote:"bg-sky-500/10 text-sky-500 border-sky-500/20",imported:"bg-amber-500/10 text-amber-500 border-amber-500/20"},o8={full:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",corroborate:"bg-sky-500/10 text-sky-500 border-sky-500/20",observe:"bg-gray-500/10 text-gray-400 border-gray-500/20"};function o7(e){let{className:t,children:s}=e;return(0,i.jsx)("span",{className:x("text-[10px] uppercase px-1.5 py-0.5 rounded border whitespace-nowrap",t),children:s})}function de(e){return e?new Date(1e3*e).toLocaleString():"â"}function dt(e){return e%86400==0?`${e/86400}d`:e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function ds(){return(0,ty.I)({queryKey:["dashboard","blocklist","snapshot"],queryFn:()=>ea("/dashboard/blocklist"),refetchInterval:3e4})}function da(){let e=(0,e3.jE)();return()=>e.invalidateQueries({queryKey:["dashboard","blocklist"]})}function dr(e){let{snapshot:t,invalidate:s}=e,[a,r]=u.useState(!1),[n,l]=u.useState(!1),[o,d]=u.useState(!1),[c,h]=u.useState(),[p,g]=u.useState(new Set),[f,b]=u.useState(!1),[y,j]=u.useState(null),N=t.sources,k=N.filter(e=>"local"!==e.id),S=N.length>0&&N.every(e=>p.has(e.id)),C=N.map(e=>e.id).sort().join(",");u.useEffect(()=>{g(new Set)},[C]);let _=(0,e5.n)({mutationFn:e=>ea("POST /dashboard/blocklist/sources/remove",{body:{ids:e}}),onSuccess:e=>{m.oR.success(`Removed ${e.affected} source${1===e.affected?"":"s"}`),s()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Remove failed")}),A=(0,e5.n)({mutationFn:e=>ea("POST /dashboard/blocklist/sources/clear",{body:{ids:e}}),onSuccess:e=>{m.oR.success(`Cleared ${e.affected} source${1===e.affected?"":"s"}`),s()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Clear failed")}),R=(0,e5.n)({mutationFn:e=>ea("POST /dashboard/blocklist/sources/refresh",{body:{ids:e}}),onSuccess:e=>{m.oR.success(`Refreshed ${e.affected} source${1===e.affected?"":"s"}`),s()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Refresh failed")}),T=(0,e5.n)({mutationFn:e=>ea("PATCH /dashboard/blocklist/sources",{body:{ids:e.ids,...e.body}}),onSuccess:()=>s(),onError:e=>m.oR.error((null==e?void 0:e.message)??"Update failed")}),I={onSuccess:()=>g(new Set)},E=sd({title:(null==y?void 0:y.title)??"",description:null==y?void 0:y.description,actionText:null==y?void 0:y.actionText,actionIntent:null==y?void 0:y.actionIntent,onConfirm:()=>null==y?void 0:y.onConfirm()}),M=e=>{j(e),E.open()},P=e=>`${e} source${1===e?"":"s"}`,$=[...p].some(e=>{var t;return(null==(t=N.find(t=>t.id===e))?void 0:t.kind)==="remote"}),D=[...p].some(e=>{var t;return(null==(t=N.find(t=>
42t.id===e))?void 0:t.kind)==="local"}),L=!D,O=!D,U=!D&&$;return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex gap-2 flex-wrap items-center min-h-9",children:[(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",leftIcon:(0,i.jsx)(sm.Ca6,{}),onClick:()=>r(!0),children:"Subscribe to a list"}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",leftIcon:(0,i.jsx)(sm.tAF,{}),onClick:()=>l(!0),children:"Import"}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",leftIcon:(0,i.jsx)(sm.Ah9,{}),onClick:()=>d(!0),children:"Export"}),(0,i.jsxs)("div",{className:"relative flex flex-1 gap-2 items-center",children:[(0,i.jsxs)("div",{className:x("flex flex-1 gap-2 items-center",0===p.size&&"invisible"),children:[(0,i.jsxs)("span",{className:"text-sm font-medium tabular-nums text-[--muted]",children:[p.size," selected"]}),(0,i.jsx)("div",{className:"flex-1"}),(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.Zxy,{}),"aria-label":"Refresh selected",title:U?"Refresh selected":D?"Cannot refresh local sources":"No remote sources selected",loading:R.isPending,onClick:()=>M({title:"Refresh selected sources",description:`${P(p.size)} selected: refetch their lists from their remote URLs now.`,actionText:"Refresh all",actionIntent:"primary-subtle",onConfirm:()=>R.mutate([...p],I)}),disabled:!U}),(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.z$h,{}),"aria-label":"Edit selected",title:L?"Edit selected":"Cannot edit the local source",onClick:()=>b(!0),disabled:!L}),(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.PLI,{}),"aria-label":"Clear entries of selected",title:"Clear entries of selected",loading:A.isPending,onClick:()=>M({title:"Clear entries from selected sources",description:`${P(p.size)} selected: entries are removed but the sources themselves are kept.`,actionText:"Clear all",actionIntent:"alert-subtle",onConfirm:()=>A.mutate([...p],I)})}),(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Remove selected",title:O?"Remove selected":"Cannot remove the local source",loading:_.isPending,onClick:()=>M({title:"Remove selected sources",description:`${P(p.size)} selected: the source and every entry it contributed will be removed. This cannot be undone. The local source is skipped.`,actionText:"Remove all",actionIntent:"alert-subtle",onConfirm:()=>_.mutate([...p],I)}),disabled:!O})]}),0===p.size&&k.length>0&&(0,i.jsx)(v,{size:"sm",intent:"alert-subtle",leftIcon:(0,i.jsx)(sm.id1,{}),title:"Remove all sources except the local one",loading:_.isPending,onClick:()=>M({title:"Remove all non-local sources",description:`Remove every source except this instance's own list (${P(k.length)}). This cannot be undone.`,actionText:"Remove all",actionIntent:"alert-subtle",onConfirm:()=>_.mutate(k.map(e=>e.id),I)}),className:"absolute right-0",children:"Remove all"})]})]}),(0,i.jsx)(J,{className:"p-0 overflow-hidden",children:(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"p-3 w-10",children:N.length>0&&(0,i.jsx)(lt,{value:S,onValueChange:e=>g(!0===e?new Set(N.map(e=>e.id)):new Set),"aria-label":"Select all"})}),(0,i.jsx)("th",{className:"p-3",children:"Name"}),(0,i.jsx)("th",{className:"p-3",children:"Kind"}),(0,i.jsx)("th",{className:"p-3",children:"Trust"}),(0,i.jsx)("th",{className:"p-3",children:"Refresh"}),(0,i.jsx)("th",{className:"p-3",children:"Status"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Entries"}),(0,i.jsx)("th",{className:"p-3",children:"Enabled"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,i.jsx)("tbody",{children:t.sources.map(e=>{var t,s,a;return(0,i.jsxs)("tr",{className:x("border-t border-[--border]/50",p.has(e.id)?"bg-[--accent]/5":"hover:bg-[--subtle]/30"),children:[(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(lt,{value:p.has(e.id),onValueChange:()=>{var t;return t=e.id,void g(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},"aria-label":`Select ${e.name}`})}),(0,i.jsx)("td",{className:"p-3 font-medium",children:e.name}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(o7,{className:o9[e.kind],children:e.kind})}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(o7,{className:o8[e.trust],children:e.trust})}),(0,i.jsx)("td",{className:"p-3 tabular-nums",children:"remote"===e.kind?dt(e.refreshSeconds):"â"}),(0,i.jsx)("td",{className:"p-3 text-xs text-[--muted] max-w-[220px] truncate",title:e.status??void 0,children:e.status??"â"}),(0,i.jsxs)("td",{className:"p-3 text-right tabular-nums",children:[(0,i.jsx)("div",{children:e.count}),e.count>0&&(0,i.jsxs)("div",{className:"text-xs text-[--muted]",title:"Entries no other source lists",children:[e.uniqueCount," unique"]})]}),(0,i.jsx)("td",{className:"p-3",children:"local"===e.kind?"â":(0,i.jsx)(ni,{value:e.enabled,onValueChange:t=>
42T.mutate({ids:[e.id],body:{enabled:t}})})}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsxs)("div",{className:"flex justify-end gap-1",children:["remote"===e.kind&&(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.Zxy,{}),"aria-label":"Refresh now",loading:R.isPending&&(null==(t=R.variables)?void 0:t.length)===1&&R.variables[0]===e.id,onClick:()=>R.mutate([e.id])}),"local"!==e.kind&&(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.z$h,{}),"aria-label":"Edit source",onClick:()=>h(e)}),(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.PLI,{}),"aria-label":"Clear entries",loading:A.isPending&&(null==(s=A.variables)?void 0:s.length)===1&&A.variables[0]===e.id,onClick:()=>M({title:"Clear source entries",description:"This removes every entry this source contributed but keeps the source itself.",actionText:"Clear",actionIntent:"alert-subtle",onConfirm:()=>A.mutate([e.id])})}),"local"!==e.kind&&(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Remove source",loading:_.isPending&&(null==(a=_.variables)?void 0:a.length)===1&&_.variables[0]===e.id,onClick:()=>M({title:"Remove source",description:"This removes the source and every entry it contributed. This cannot be undone.",actionText:"Remove",actionIntent:"alert-subtle",onConfirm:()=>_.mutate([e.id])})})]})})]},e.id)})})]})})}),(0,i.jsx)(dl,{open:a,onOpenChange:r,invalidate:s}),(0,i.jsx)(dd,{open:n,onOpenChange:l,invalidate:s}),(0,i.jsx)(dc,{open:o,onOpenChange:d}),c&&(0,i.jsx)(dn,{source:c,onClose:()=>h(void 0),invalidate:s}),f&&(0,i.jsx)(du,{selectedIds:[...p],sources:N,onSave:e=>T.mutate({ids:[...p],body:e},{onSuccess:e=>{m.oR.success(`Updated ${e.affected} source${1===e.affected?"":"s"}`),g(new Set),b(!1)}}),loading:T.isPending,onClose:()=>b(!1)}),(0,i.jsx)(sc,{...E})]})}function dn(e){let{source:t,onClose:s,invalidate:a}=e,[r,n]=u.useState(t.name),[l,o]=u.useState(""),[d,c]=u.useState(t.trust),[h,p]=u.useState(Math.max(1,Math.round(t.refreshSeconds/3600))),x=(0,e5.n)({mutationFn:()=>{let e={name:r.trim()||t.name,trust:d};return"remote"===t.kind&&(e.refreshSeconds=Math.round(3600*h),l.trim()&&(e.url=l.trim())),ea("PATCH /dashboard/blocklist/sources",{body:{ids:[t.id],...e}})},onSuccess:()=>{m.oR.success("Source updated"),s(),a()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Update failed")});return(0,i.jsx)(sl,{open:!0,onOpenChange:e=>!e&&s(),title:`Edit "${t.name}"`,children:(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)(K,{label:"Name",value:r,onValueChange:n}),"remote"===t.kind&&(0,i.jsx)(K,{label:"URL",placeholder:"(unchanged)",value:l,onValueChange:o,help:t.url?`Current: ${t.url}`:"Leave blank to keep the current URL"}),(0,i.jsx)(nc,{label:"Trust",options:o4.map(e=>({label:e,value:e})),value:d,onValueChange:e=>c(e),help:"full filters on its own; corroborate needs the quorum; observe never filters"}),"remote"===t.kind&&(0,i.jsx)(lm,{label:"Refresh (hours)",value:h,min:1,max:720,onValueChange:e=>p(e||24)}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:s,children:"Cancel"}),(0,i.jsx)(v,{intent:"primary",loading:x.isPending,onClick:()=>x.mutate(),children:"Save"})]})]})})}function dl(e){let{open:t,onOpenChange:s,invalidate:a}=e,[r,n]=u.useState(""),[l,o]=u.useState("full"),[d,c]=u.useState(24),h=r.split("\n").map(e=>e.trim()).filter(e=>e&&!e.startsWith("#")).length,p=(0,e5.n)({mutationFn:()=>ea("POST /dashboard/blocklist/sources/remote",{body:{input:r,trust:l,refreshSeconds:Math.round(3600*d)}}),onSuccess:e=>{let{import:t}=e,r=[`${t.added} added`];t.skipped&&r.push(`${t.skipped} already present`),t.errors.length&&r.push(`${t.errors.length} failed`),m.oR.success(r.join(", ")),s(!1),n(""),a()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Subscribe failed")});return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Subscribe to blocklists",description:"Any URL serving a blocklist or Warden NDJSON list, e.g. another instance's /blocklist/export. One URL per line.",children:(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)(ly,{label:"List URL(s)",placeholder:"https://example.com/blocklist/export",rows:5,value:r,onValueChange:n}),(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,i.jsx)(nc,{label:"Trust",options:o4.map(e=>({label:e,value:e})),value:l,onValueChange:e=>o(e),help:"full filters on its own; corroborate needs the quorum; observe never filters"}),(0,i.jsx)(lm,{label:"Refresh (hours)",value:d,min:1,max:720,onValueChange:e=>c(e||24)})]}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,i.jsx)(v,{intent:"primary",loading:p.isPending,disabled:0===
42h,onClick:()=>p.mutate(),children:h>1?`Subscribe (${h})`:"Subscribe"})]})]})})}let di={"application/x-ndjson":[".ndjson"],"application/json":[".json"],"application/gzip":[".gz"],"text/plain":[".txt"]};function dd(e){let{open:t,onOpenChange:s,invalidate:a}=e,[r,n]=u.useState(""),[l,o]=u.useState(null),[d,c]=u.useState(!1),h=async()=>{if(l){c(!0);try{let t=await l.arrayBuffer(),i=new URLSearchParams;r.trim()&&i.set("name",r.trim());let d=await fetch(`/api/v1/dashboard/blocklist/import?${i.toString()}`,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:t}),c=await d.json().catch(()=>void 0);if(!d.ok||(null==c?void 0:c.success)===!1){var e;throw Error((null==c||null==(e=c.error)?void 0:e.message)??`HTTP ${d.status}`)}m.oR.success("List imported"),s(!1),o(null),n(""),a()}catch(e){m.oR.error((null==e?void 0:e.message)??"Import failed")}finally{c(!1)}}};return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Import a blocklist",description:"Upload an NDJSON list (native or Warden format, .gz supported). Imports become their own source and never merge into your local list.",children:(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)(K,{label:"Name (optional)",placeholder:`Import ${new Date().toISOString().slice(0,10)}`,value:r,onValueChange:n}),(0,i.jsx)(lb,{accept:di,className:"min-h-[120px] w-full",dropzoneText:"Drop a list file here, or click to choose",onValueChange:e=>o(e[0]??null),onDropRejected:e=>{let t=e.map(e=>e.file.name);m.oR.error(1===t.length?`"${t[0]}" isn't a supported list file`:"Drop a single .ndjson, .json, .gz or .txt file")}}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,i.jsx)(v,{intent:"primary",loading:d,disabled:!l,onClick:h,children:"Import"})]})]})})}function dc(e){let{open:t,onOpenChange:s}=e,[a,r]=u.useState(!1),[n,l]=u.useState("local");return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Export the blocklist",description:"Download the list as NDJSON, ready to be imported or subscribed to by another instance.",children:(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)(nc,{label:"Scope",options:[{label:"This instance's own verdicts",value:"local"},{label:"Everything (all sources, deduplicated)",value:"all"}],value:n,onValueChange:e=>l(e)}),(0,i.jsx)(ni,{label:"Warden-compatible format",value:a,onValueChange:r,help:"For davex. Carries only dead usenet fingerprints; content-hash and torrent entries are left out."}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,i.jsx)(v,{intent:"primary",leftIcon:(0,i.jsx)(sm.Ah9,{}),onClick:()=>{let e=document.createElement("a");e.href=`/api/v1/dashboard/blocklist/export?format=${a?"warden":"native"}&scope=${n}`,e.download="",document.body.appendChild(e),e.click(),e.remove(),s(!1)},children:"Download"})]})]})})}function du(e){let{selectedIds:t,sources:s,onSave:a,loading:r,onClose:n}=e,l=s.filter(e=>t.includes(e.id)).some(e=>"remote"===e.kind),[o,d]=u.useState(""),[c,m]=u.useState(24),[h,p]=u.useState(!1),[x,g]=u.useState(""),f=()=>{let e={};return o&&(e.trust=o),l&&h&&c>0&&(e.refreshSeconds=Math.round(3600*c)),""!==x&&(e.enabled=x),e};return(0,i.jsx)(sl,{open:!0,onOpenChange:e=>!e&&n(),title:`Edit ${t.length} source${1===t.length?"":"s"}`,description:"Set common fields for all selected sources. Blank fields are left unchanged.",children:(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)(nc,{label:"Trust",options:[{label:"Leave unchanged",value:""},...o4.map(e=>({label:e,value:e}))],value:o,onValueChange:e=>d(e),help:"full filters on its own; corroborate needs the quorum; observe never filters"}),l&&(0,i.jsx)(lm,{label:"Refresh (hours)",value:c,min:1,max:720,onValueChange:e=>{m(e||24),p(!0)},help:"Only applies to remote sources"}),(0,i.jsx)(nc,{label:"Enabled",options:[{label:"Leave unchanged",value:""},{label:"Enable",value:"true"},{label:"Disable",value:"false"}],value:""===x?"":String(x),onValueChange:e=>g(""===e?"":"true"===e),help:"Enable or disable the source. The local source cannot be disabled."}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:n,children:"Cancel"}),(0,i.jsx)(v,{intent:"primary",loading:r,disabled:0===Object.keys(f()).length,onClick:()=>a(f()),children:"Save"})]})]})})}let dm={root:(0,c.F)(["UI-Pagination__root","flex gap-1 text-xs font-medium"]),item:(0,c.F)(["UI-Pagination__item","bg-transparent dark:bg-transparent text-sm text-[--muted] inline-flex h-8 min-w-8 px-1 tabular-nums items-center justify-center rounded-[--radius] border cursor-pointer","hover:bg-[--subtle] dark:hover:bg-[--subtle] hover:border-[--subtle] select-none","data-[selected=true]:bg-brand-500 data-[selected=true]:border-transparent data-[selected=true]:text-white data-[selected=true]:hover:bg-brand data-[selected=true]:pointer-events-none","data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none data-[disabled=true]:cursor-not-allowed","outline-none focus-visible:outline-none focus-visible:ring-1 ring-offset-1 ring-offset-[--background] focus-visible:ring-white/40"]),ellipsis:(0,c.F)(["UI-Pagination__ellipsis","flex p-2 items-center text-[1.05rem]"])},dh=u.createContext({}),dp=u.forwardRef((e,t)=>
42{let{children:s,itemClass:a,className:r,ellipsisClass:n,...l}=e;return(0,i.jsx)(dh.Provider,{value:{itemClass:a,ellipsisClass:n},children:(0,i.jsx)("ul",{ref:t,className:x(dm.root(),r),role:"navigation",...l,children:s})})});dp.displayName="Pagination";let dx=u.forwardRef((e,t)=>{let{value:s,className:a,...r}=e,{itemClass:n}=u.useContext(dh);return(0,i.jsx)("li",{children:(0,i.jsx)("button",{className:x(dm.item(),n,a),...r,ref:t,children:s})})});dx.displayName="PaginationItem";let dg=u.forwardRef((e,t)=>{let{isChevrons:s=!1,isDisabled:a=!1,direction:r,className:n,...l}=e,{itemClass:o}=u.useContext(dh);return(0,i.jsx)("li",{children:(0,i.jsx)("button",{className:x(dm.item(),o,n),"data-disabled":a,tabIndex:a?-1:void 0,...l,ref:t,children:"previous"===r?(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4 w-4",children:s?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("polyline",{points:"11 17 6 12 11 7"}),(0,i.jsx)("polyline",{points:"18 17 13 12 18 7"})]}):(0,i.jsx)("polyline",{points:"15 18 9 12 15 6"})}):(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4 w-4",children:s?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("polyline",{points:"13 17 18 12 13 7"}),(0,i.jsx)("polyline",{points:"6 17 11 12 6 7"})]}):(0,i.jsx)("polyline",{points:"9 18 15 12 9 6"})})})})});dg.displayName="PaginationTrigger";let df=u.forwardRef((e,t)=>{let{className:s,...a}=e,{ellipsisClass:r}=u.useContext(dh);return(0,i.jsx)("li",{className:x(dm.ellipsis(),r,s),children:(0,i.jsx)("span",{...a,ref:t,children:"â¦"})})});function db(e,t){let s=[...new Set([1,t,e-1,e,e+1])].filter(e=>e>=1&&e<=t).sort((e,t)=>e-t),a=[],r=0;for(let e of s)r&&e-r>1&&a.push("â¦"),a.push(e),r=e;return a}function dv(e){let{snapshot:t,invalidate:s}=e,[a,r]=u.useState(""),[n,l]=u.useState(""),[o,d]=u.useState(""),[c,h]=u.useState(""),[p,g]=u.useState(1),[f,b]=u.useState(!1),[y,j]=u.useState(),w=(0,ty.I)({queryKey:["dashboard","blocklist","entries",{search:a,sourceId:n,verdict:o,kind:c,page:p}],queryFn:()=>{let e=new URLSearchParams({page:String(p)});return a.trim()&&e.set("search",a.trim()),n&&e.set("source",n),o&&e.set("verdict",o),c&&e.set("kind",c),ea(`/dashboard/blocklist/entries?${e}`)},placeholderData:i1.rX}),N=(0,e5.n)({mutationFn:e=>ea("POST /dashboard/blocklist/unmark",{body:{releases:[[e]]}}),onSuccess:()=>{m.oR.success("Release allowed on this instance"),s()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed")}),k=(0,e5.n)({mutationFn:e=>ea(`DELETE /dashboard/blocklist/entries?key=${encodeURIComponent(e)}`),onSuccess:()=>{m.oR.success("Verdict removed"),s()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed")}),S=(0,e5.n)({mutationFn:e=>ea(`DELETE /dashboard/blocklist/overrides${e?`?key=${encodeURIComponent(e)}`:""}`),onSuccess:(e,t)=>{m.oR.success(t?"Override cleared":"All overrides cleared"),s()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed")}),C=sd({title:"Clear all overrides",description:`Re-block every release this instance has allowed (${t.counts.overrides} override${1===t.counts.overrides?"":"s"}). Their remote verdicts start filtering again.`,actionText:"Clear all",actionIntent:"alert-subtle",onConfirm:()=>S.mutate(void 0)}),_=w.data,A=_?Math.max(1,Math.ceil(_.total/_.pageSize)):1,R="__any__";return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex gap-2 flex-wrap items-end",children:[(0,i.jsx)(K,{leftIcon:(0,i.jsx)(sm.iyI,{}),placeholder:"Search keysâ¦",value:a,onValueChange:e=>{r(e),g(1)},className:"w-64"}),(0,i.jsx)(nc,{options:[{label:"All sources",value:R},...t.sources.map(e=>({label:e.name,value:e.id}))],value:n||R,onValueChange:e=>{l(e===R?"":e),g(1)}}),(0,i.jsx)(nc,{options:[{label:"All verdicts",value:R},...o5.map(e=>({label:e,value:e}))],value:o||R,onValueChange:e=>{d(e===R?"":e),g(1)}}),(0,i.jsx)(nc,{options:[{label:"All kinds",value:R},{label:"usenet",value:"usenet"},{label:"torrent",value:"torrent"}],value:c||R,onValueChange:e=>{h(e===R?"":e),g(1)}}),(0,i.jsx)("div",{className:"flex-1"}),t.counts.overrides>0&&(0,i.jsxs)(v,{size:"sm",intent:"gray-outline",loading:S.isPending&&void 0===S.variables,onClick:C.open,title:"Overrides suppress remote verdicts for releases this instance proved working",children:["Clear all overrides (",t.counts.overrides,")"]}),(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",leftIcon:(0,i.jsx)(sm.Ca6,{}),onClick:()=>b(!0),children:"Mark a release"})]}),(0,i.jsx)(oh,{query:w,errorTitle:"Failed to load entries",children:e=>(0,i.jsxs)(J,{className:"p-0 overflow-hidden",children:[(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"p-3",children:"Key"}),(0,i.jsx)("th",{className:"p-3",children:"Kind"}),(0,i.jsx)("th",{className:"p-3",children:"Verdict"}),(0,i.jsx)("th",{className:"p-3",children:"Sources"}),(0,i.jsx)("th",{className:"p-3",children:"Backbones"}),(0,i.jsx)("th",{className:"p-3",children:"Last seen"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,i.jsxs)("tbody",{children:[0===e.entries.length&&(0,i.jsx)("tr",{children:(0,i.jsx)("td",{className:"p-6 text-center text-[--muted]",colSpan:7,children:"No entries"})}),e.entries.map(e=>(0,i.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,i.jsx)("td",{className:"p-3 font-mono text-xs max-w-[260px] truncate cursor-pointer",title:`${e.key} (click to copy)`,onClick:()=>void nf(e.key,{onSuccess:()=>m.oR.success("Key copied"),onError:()=>m.oR.error("Copy failed")}),children:e.key}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(o7,{className:o9[e.kind],children:e.kind})}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsxs)("div",{className:"flex gap-1",children:[(0,i.jsx)(o7,{className:o6[e.verdict],children:e.verdict}),e.overridden&&(0,i.jsx)(o7,{className:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",children:"allowed"})]})}),(0,i.jsx)("td",{className:"p-3 text-xs max-w-[200px] truncate",title:e.sources.map(e=>`${e.name} (${e.verdict}, ${e.trust})`).join("\n"),children:e.sources.map(e=>e.name).join(", ")}),(0,i.jsx)("td",{className:x("p-3 text-xs text-[--muted] max-w-[180px] truncate",e.backbones.length>0&&"cursor-pointer underline decoration-dotted"),title:e.backbones.length>0?"Click for the full backbone scope":void 0,onClick:()=>e.backbones.length>0&&j(e),children:e.backbones.join(", ")||"everywhere"}),(0,i.jsx)("td",{className:"p-3 text-xs tabular-nums whitespace-nowrap",children:de(e.lastAt)}
42),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)("div",{className:"flex justify-end",children:e.overridden?(0,i.jsx)(v,{size:"sm",intent:"gray-subtle",leftIcon:(0,i.jsx)(sm.PLI,{}),loading:S.isPending&&S.variables===e.key,onClick:()=>S.mutate(e.key),title:"Remove the override so these verdicts filter again",children:"Re-block"}):e.sources.some(e=>"local"!==e.id)?(0,i.jsx)(v,{size:"sm",intent:"gray-subtle",leftIcon:(0,i.jsx)(sm.DNZ,{}),loading:N.isPending&&N.variables===e.key,onClick:()=>N.mutate(e.key),title:"Remove any local verdict and suppress the remote ones",children:"Allow"}):(0,i.jsx)(v,{size:"sm",intent:"gray-subtle",leftIcon:(0,i.jsx)(sm.id1,{}),loading:k.isPending&&k.variables===e.key,onClick:()=>k.mutate(e.key),title:"Delete this instance's verdict",children:"Remove"})})})]},e.key))]})]})}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 p-3 border-t border-[--border]/50 text-xs text-[--muted]",children:[(0,i.jsxs)("span",{className:"tabular-nums",children:["Showing"," ",(e.page-1)*e.pageSize+ +(e.entries.length>0),"â",Math.min(e.page*e.pageSize,e.total)," of"," ",e.total]}),A>1&&(0,i.jsxs)(dp,{children:[(0,i.jsx)(dg,{direction:"previous",isDisabled:p<=1,onClick:()=>g(e=>Math.max(1,e-1))}),db(p,A).map((e,t)=>"â¦"===e?(0,i.jsx)(df,{},`e${t}`):(0,i.jsx)(dx,{value:e,"data-selected":e===p,onClick:()=>g(e)},e)),(0,i.jsx)(dg,{direction:"next",isDisabled:p>=A,onClick:()=>g(e=>Math.min(A,e+1))})]})]})]})}),y&&(0,i.jsx)(sl,{open:!0,onOpenChange:e=>!e&&j(void 0),title:"Backbone scope",description:y.key,children:(0,i.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs uppercase text-[--muted] mb-1",children:"Backbones"}),(0,i.jsx)("div",{children:y.backbones.join(", ")||"everywhere"})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("div",{className:"text-xs uppercase text-[--muted]",children:"As recorded per source"}),y.sources.map(e=>(0,i.jsxs)("div",{className:"text-xs",children:[(0,i.jsx)("span",{className:"font-medium",children:e.name})," ",(0,i.jsxs)("span",{className:"text-[--muted]",children:["(",e.verdict,", seen ",e.n,"\xd7)"]}),(0,i.jsx)("div",{className:"font-mono text-[--muted]",children:e.backbones.join(", ")||"no scope (applies everywhere)"})]},e.id))]})]})}),(0,i.jsx)(dy,{open:f,onOpenChange:b,invalidate:s}),(0,i.jsx)(sc,{...C})]})}function dy(e){let{open:t,onOpenChange:s,invalidate:a}=e,[r,n]=u.useState(""),[l,o]=u.useState("dead"),d=(0,e5.n)({mutationFn:()=>ea("POST /dashboard/blocklist/mark",{body:{releases:[[r.trim()]],verdict:l}}),onSuccess:()=>{m.oR.success("Release marked"),s(!1),n(""),a()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Mark failed")});return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Mark a release",description:"Add a verdict to this instance's own list. Torrents are keyed btih:<infohash>, usenet releases wd1:<fingerprint> or nh1:<nzb content hash>.",children:(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)(K,{label:"Release key",placeholder:"btih:⦠or wd1:â¦",value:r,onValueChange:n}),(0,i.jsx)(nc,{label:"Verdict",options:o5.map(e=>({label:e,value:e})),value:l,onValueChange:e=>o(e)}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,i.jsx)(v,{intent:"primary",loading:d.isPending,disabled:!r.trim(),onClick:()=>d.mutate(),children:"Mark"})]})]})})}df.displayName="PaginationEllipsis";let dj={local:"Own verdicts",all:"Every source"};function dw(e){nf(e,{onSuccess:()=>m.oR.success("Copied to clipboard"),onError:()=>m.oR.error("Failed to copy")})}function dN(e){let{target:t}=e;return t.error?(0,i.jsx)(P,{className:"w-96",align:"start",trigger:(0,i.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 text-xs text-red-400 hover:underline underline-offset-2",children:["Push failed",(0,i.jsx)(sm.wfp,{className:"h-3.5 w-3.5"})]}),children:(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-sm font-medium",children:"Last push failed"}),(0,i.jsx)("div",{className:"text-xs text-[--muted]",children:de(t.lastChecked)})]}),(0,i.jsx)(w,{size:"xs",intent:"gray-subtle",icon:(0,i.jsx)(sm.Xpf,{}),"aria-label":"Copy the error",onClick:()=>dw(t.error)})]}),(0,i.jsx)("p",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words text-xs text-[--muted]",children:t.error})]})}):(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:t.status??"â"})}function dk(e){let{title:t,description:s,files:a}=e,[r,n]=u.useState(!1),l=u.useMemo(()=>{let e;return e=e=>2*("native"!==e.format)+ +("local"!==e.scope),[...a].sort((t,s)=>e(t)-e(s))},[a]),o=l[0];if(!o)return(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"â"});let d=l.length-1;return(0,i.jsxs)("div",{className:"space-y-1",children:[o.url?(0,i.jsxs)("button",{type:"button",className:"group flex items-center gap-1.5 text-xs font-mono max-w-[260px]",title:o.url,"aria-label":`Copy the URL for ${o.label}`,onClick:()=>dw(o.url),children:[(0,i.jsx)(sm.Xpf,{className:"h-3.5 w-3.5 shrink-0 text-[--muted] group-hover:text-[--brand]"}),(0,i.jsx)("span",{className:"truncate group-hover:text-[--brand]",children:o.label})]}):(0,i.jsx)("span",{className:"flex items-center gap-1.5 text-xs font-mono text-[--muted] max-w-[260px]",title:"The URL appears once the file has been pushed",children:(0,i.jsx)("span",{className:"truncate",children:o.label})}),d>0&&(0,i.jsxs)("button",{type:"button",className:"ml-5 text-xs text-[--muted] hover:text-[--foreground] hover:underline underline-offset-2",onClick:()=>n(!0),children:[d," more ",1===d?"file":"files"]}),r&&(0,i.jsx)(dS,{title:t,description:s,files:l,onClose:()=>n(!1)})]})}function dS(e){let{title:t,description:s,files:a,onClose:r}=e;return(0,i.jsx)(sl,{open:!0,onOpenChange:e=>!e&&r(),title:t,description:s,children:(0,i.jsx)("div",{className:"space-y-2 min-w-0",children:a.map(e=>{let t;return(0,i.jsxs)("div",{className:"rounded-[--radius] border border-[--border]/60 bg-[--subtle]/30 p-3 space-y-1.5",children:[(0,i.jsx)("div",{className:"text-sm font-mono break-all",children:e.label}),(0,i.jsx)("div",{className:"text-xs text-[--muted]",children:(t=[dj[e.scope]],"warden"===e.format&&t.push("Warden format"),e.gzip&&t.push("gzip"),e.pushedAt&&t.push(`pushed ${de(e.pushedAt)}`),t.join(" \xb7 "))}),e.url?(0,i.jsxs)("div",{className:"flex items-start gap-1",children:[(0,i.jsx)("span",{className:"flex-1 min-w-0 break-all text-xs font-mono text-[--muted]",title:e.url,children:e.url}),(0,i.jsx)(w,{size:"xs",intent:"gray-subtle",icon:(0,i.jsx)(sm.Xpf,{}),"aria-label":`Copy the URL for ${e.label}`,onClick:()=>dw(e.url)})]}):(0,i.jsx)("div",{className:"text-xs text-[--muted]",children:"The URL appears once the file has been pushed."})]},e.key)})})})}
42function dC(e){let{snapshot:t,invalidate:s}=e,[a,r]=u.useState(!1),[n,l]=u.useState(!1),[o,d]=u.useState(),[c,h]=u.useState(),p=(0,e5.n)({mutationFn:e=>ea(`PATCH /dashboard/blocklist/targets/${e.id}`,{body:e.body}),onSuccess:s,onError:e=>m.oR.error((null==e?void 0:e.message)??"Update failed")}),x=(0,e5.n)({mutationFn:e=>ea(`POST /dashboard/blocklist/targets/${e}/publish`,{body:{}}),onSuccess:(e,t)=>{let a=e.targets.find(e=>e.id===t);(null==a?void 0:a.error)?m.oR.error(a.error):m.oR.success((null==a?void 0:a.status)??"Pushed"),s()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Push failed")}),g=(0,e5.n)({mutationFn:e=>ea(`DELETE /dashboard/blocklist/targets/${e}`),onSuccess:()=>{m.oR.success("Target removed"),s()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Delete failed")}),f=sd({title:"Remove publish target",description:"This stops pushing to this destination. Files already uploaded there are not deleted.",actionText:"Remove",actionIntent:"alert-subtle",onConfirm:()=>c&&g.mutate(c.id)});return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex gap-2 flex-wrap items-center",children:[(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",leftIcon:(0,i.jsx)(sm.Ca6,{}),onClick:()=>{d(void 0),r(!0)},children:"Add target"}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Push this instance's blocklist to remote destinations so others can subscribe without reaching your instance."})]}),(0,i.jsx)(J,{className:"p-0 overflow-hidden",children:(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"p-3",children:"Name"}),(0,i.jsx)("th",{className:"p-3",children:"Provider"}),(0,i.jsx)("th",{className:"p-3",children:"Files"}),(0,i.jsx)("th",{className:"p-3",children:"Interval"}),(0,i.jsx)("th",{className:"p-3",children:"Last push"}),(0,i.jsx)("th",{className:"p-3",children:"Status"}),(0,i.jsx)("th",{className:"p-3",children:"Enabled"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,i.jsxs)("tbody",{children:[(0,i.jsx)(dA,{snapshot:t,invalidate:s,onEdit:()=>l(!0)}),t.targets.map(e=>{var t;let s;return(0,i.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,i.jsxs)("td",{className:"p-3 font-medium",children:[e.name,e.configUnreadable&&(0,i.jsx)("div",{className:"text-xs text-red-400",children:"config unreadable â re-enter it"})]}),(0,i.jsxs)("td",{className:"p-3",children:[(0,i.jsx)(o7,{className:"bg-sky-500/10 text-sky-500 border-sky-500/20",children:e.providerLabel}),(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(s=(t=e).summary)&&"github-gist"===t.provider?s.gistId?`gist ${s.gistId}`:"creates a gist on first push":""})]}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(dk,{title:`Files pushed to "${e.name}"`,description:"Hand these URLs to anyone who wants to subscribe to this list.",files:e.artifacts.map(e=>({key:`${e.format}:${e.scope}`,format:e.format,scope:e.scope,gzip:e.gzip,label:e.filename,url:e.url,pushedAt:e.pushedAt}))})}),(0,i.jsx)("td",{className:"p-3 tabular-nums",children:dt(e.intervalSeconds)}),(0,i.jsx)("td",{className:"p-3 text-xs text-[--muted] whitespace-nowrap",children:de(e.lastPushed)}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(dN,{target:e})}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(ni,{value:e.enabled,onValueChange:t=>p.mutate({id:e.id,body:{enabled:t}})})}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.tAF,{}),"aria-label":"Push now",loading:x.isPending&&x.variables===e.id,onClick:()=>x.mutate(e.id)}),(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.z$h,{}),"aria-label":"Edit target",onClick:()=>{d(e),r(!0)}}),(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Remove target",onClick:()=>{h(e),f.open()}})]})})]},e.id)})]})]})})}),a&&(0,i.jsx)(dE,{providers:t.providers,target:o,onClose:()=>r(!1),invalidate:s}),n&&(0,i.jsx)(dR,{snapshot:t,onClose:()=>l(!1),invalidate:s}),(0,i.jsx)(sc,{...f})]})}function d_(e){return e?`Set by ${e}; change it in the environment.`:void 0}function dA(e){var t;let{snapshot:s,invalidate:a,onEdit:r}=e,{status:n}=tj(),l=(null==n||null==(t=n.settings)?void 0:t.baseUrl)||window.location.origin,{settings:o,publicExportEnv:d}=s,c=(0,e5.n)({mutationFn:e=>ea("PATCH /dashboard/blocklist/settings",{body:{publicExport:e}}),onSuccess:a,onError:e=>
42m.oR.error((null==e?void 0:e.message)??"Update failed")});return(0,i.jsxs)("tr",{className:"border-t border-[--border]/50 bg-[--subtle]/20",children:[(0,i.jsx)("td",{className:"p-3 font-medium",children:"This instance"}),(0,i.jsxs)("td",{className:"p-3",children:[(0,i.jsx)(o7,{className:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",children:"public export"}),(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:"served live, nothing is pushed"})]}),(0,i.jsx)("td",{className:"p-3",children:o.publicExport?(0,i.jsx)(dk,{title:"Files served by this instance",description:"Hand these URLs to anyone who wants to subscribe to this list.",files:function(e,t){let s=[];for(let a of"all"===e.publicExportScope?["local","all"]:["local"])for(let r of["native","warden"]){let n=new URLSearchParams;"all"===a&&n.set("scope","all"),"warden"===r&&n.set("format","warden");let l=new URLSearchParams(n);e.publicExportPassword&&l.set("key",e.publicExportPassword);let i=e=>{let t=e.toString();return t?`?${t}`:""};s.push({key:`${r}:${a}`,format:r,scope:a,gzip:!1,label:`/blocklist/export${i(n)}`,url:`${t}/blocklist/export${i(l)}`,pushedAt:null})}return s}(o,l)}):(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"â"})}),(0,i.jsx)("td",{className:"p-3 tabular-nums",children:"â"}),(0,i.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:"â"}),(0,i.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:o.publicExport?"subscribers fetch it directly":"disabled"}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)("span",{title:d_(d.publicExport),children:(0,i.jsx)(ni,{value:o.publicExport,disabled:!!d.publicExport||c.isPending,onValueChange:e=>c.mutate(e)})})}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)("div",{className:"flex justify-end gap-1",children:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.z$h,{}),"aria-label":"Edit the public export",onClick:r})})})]})}function dR(e){let{snapshot:t,onClose:s,invalidate:a}=e,{settings:r,publicExportEnv:n}=t,[l,o]=u.useState(r.publicExport),[d,c]=u.useState(r.publicExportScope),[h,p]=u.useState(r.publicExportPassword),x=(0,e5.n)({mutationFn:e=>ea("PATCH /dashboard/blocklist/settings",{body:e}),onSuccess:()=>{m.oR.success("Public export updated"),s(),a()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Save failed")});return(0,i.jsx)(sl,{open:!0,onOpenChange:e=>!e&&s(),title:"Public export",description:"Serve this instance's blocklist at /blocklist/export so others can subscribe to it directly.",children:(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)(ni,{side:"right",label:"Serve the public export",value:l,disabled:!!n.publicExport,onValueChange:o,help:d_(n.publicExport)??"The list contains only release digests and backbone root domains."}),(0,i.jsx)(nc,{label:"Scope",options:[{label:"local (own verdicts)",value:"local"},{label:"all (every source)",value:"all"}],value:d,disabled:!!n.publicExportScope,onValueChange:e=>c(e),help:d_(n.publicExportScope)??"The most a subscriber may ask for. With local, only verdicts this instance recorded first-hand are ever served."}),(0,i.jsx)(K,{type:"password",label:"Password",autoComplete:"new-password",placeholder:"No password",value:h,disabled:!!n.publicExportPassword,onValueChange:p,help:d_(n.publicExportPassword)??"When set, subscribers must pass ?key=<value>. A missing or wrong key gets the same 404 as a disabled export, so the endpoint stays invisible."}),"all"===d&&(0,i.jsx)(lB,{intent:"warning",children:'Serving the "all" scope rebroadcasts lists you subscribe to: one upstream verdict can then look independently corroborated to anyone consuming both lists. Prefer "local" unless you are deliberately aggregating.'}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:s,children:"Cancel"}),(0,i.jsx)(v,{intent:"primary",loading:x.isPending,onClick:()=>{let e={};if(n.publicExport||l===r.publicExport||(e.publicExport=l),n.publicExportScope||d===r.publicExportScope||(e.publicExportScope=d),n.publicExportPassword||h===r.publicExportPassword||(e.publicExportPassword=h),0===Object.keys(e).length)return s();x.mutate(e)},children:"Save"})]})]})})}function dT(e,t,s){let a={};for(let r of e)if("switch"===r.type){let e=s?t[r.key]:void 0;
42a[r.key]=!!(e??r.default)}else if(r.secret)a[r.key]="";else{let e=s?t[r.key]:void 0;a[r.key]=null!=e?String(e):String(r.default??"")}return a}function dI(e){let{field:t,value:s,editing:a,onChange:r}=e,n=a&&t.editHelp||t.help,l=a&&t.editPlaceholder||t.placeholder;return"switch"===t.type?(0,i.jsx)(ni,{side:"right",label:t.label,value:!!s,onValueChange:r,help:n}):"select"===t.type?(0,i.jsx)(nc,{label:t.label,options:t.options??[],value:String(s),onValueChange:r,help:n}):"textarea"===t.type?(0,i.jsx)(ly,{label:t.label,rows:3,placeholder:l,value:String(s),onValueChange:r,help:n}):(0,i.jsx)(K,{type:"password"===t.type?"password":"text",label:t.label,placeholder:l,value:String(s),onValueChange:r,help:n})}function dE(e){var t;let{providers:s,target:a,onClose:r,invalidate:n}=e,l=!!a,o=(null==a?void 0:a.summary)??{},[d,c]=u.useState((null==a?void 0:a.provider)??(null==(t=s[0])?void 0:t.id)??"github-gist"),h=s.find(e=>e.id===d),[p,x]=u.useState((null==a?void 0:a.name)??""),[g,f]=u.useState(a?Math.max(1,Math.round(a.intervalSeconds/3600)):6),[b,y]=u.useState(a?a.artifacts.map(e=>({format:e.format,scope:e.scope,gzip:e.gzip})):[{format:"native",scope:"local",gzip:!!(null==h?void 0:h.capabilities.binary)}]),[j,N]=u.useState(()=>dT((null==h?void 0:h.fields)??[],o,l)),k=(0,e5.n)({mutationFn:()=>{let e={name:p.trim(),intervalSeconds:Math.round(3600*g),artifacts:b.map(e=>({format:e.format,scope:e.scope,gzip:null!=h&&!!h.capabilities.binary&&e.gzip})),config:(()=>{let e={};for(let t of(null==h?void 0:h.fields)??[]){let s=j[t.key];if("switch"===t.type){e[t.key]=!!s;continue}let a=String(s??"").trim();t.secret?a&&(e[t.key]=a):e[t.key]=a}return e})()};return l?ea(`PATCH /dashboard/blocklist/targets/${a.id}`,{body:e}):ea("POST /dashboard/blocklist/targets",{body:{...e,provider:d}})},onSuccess:()=>{m.oR.success(l?"Target updated":"Target added"),r(),n()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Save failed")}),S=b.some(e=>"all"===e.scope);return(0,i.jsx)(sl,{open:!0,onOpenChange:e=>!e&&r(),title:l?`Edit "${a.name}"`:"Add publish target",children:(0,i.jsxs)("div",{className:"space-y-3",children:[!l&&(0,i.jsx)(nc,{label:"Provider",options:s.map(e=>({label:e.label,value:e.id})),value:d,onValueChange:e=>{let t=s.find(t=>t.id===e);c(e),N(dT((null==t?void 0:t.fields)??[],{},!1)),y(e=>e.map(e=>({...e,gzip:!!(null==t?void 0:t.capabilities.binary)&&e.gzip})))}}),(0,i.jsx)(K,{label:"Name",value:p,onValueChange:x}),(0,i.jsx)(lm,{label:"Push interval (hours)",value:g,min:1,max:720,onValueChange:e=>f(e||6)}),((null==h?void 0:h.fields)??[]).map(e=>(0,i.jsx)(dI,{field:e,value:j[e.key]??("switch"!==e.type&&""),editing:l,onChange:t=>N(s=>({...s,[e.key]:t}))},`${d}:${e.key}`)),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("label",{className:"text-xs font-medium text-[--muted] ml-1",children:"Files to push"}),b.map((e,t)=>(0,i.jsxs)("div",{className:"rounded-[--radius] border border-[--border]/60 bg-[--subtle]/30 p-3 space-y-3",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsx)("span",{className:"text-xs font-mono text-[--muted]",children:`blocklist-${e.scope}${"warden"===e.format?"-warden":""}.ndjson${e.gzip?".gz":""}`}),b.length>1&&(0,i.jsx)(w,{size:"xs",rounded:!0,intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Remove file",onClick:()=>y(e=>e.filter((e,s)=>s!==t))})]}),(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,i.jsx)(nc,{label:"Format",options:[{label:"native",value:"native"},{label:"warden",value:"warden"}],value:e.format,onValueChange:e=>y(s=>s.map((s,a)=>a===t?{...s,format:e}:s))}),(0,i.jsx)(nc,{label:"Scope",options:[{label:"local (own verdicts)",value:"local"},{label:"all (every source)",value:"all"}],value:e.scope,onValueChange:e=>y(s=>s.map((s,a)=>a===t?{...s,scope:e}:s))})]}),(null==h?void 0:h.capabilities.binary)&&(0,i.jsx)(ni,{side:"right",label:"Compress (gzip)",value:e.gzip,onValueChange:e=>y(s=>s.map((s,a)=>a===t?{...s,gzip:e}:s))})]},t)),b.length<4&&(0,i.jsx)("div",{className:"flex justify-center",children:(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,i.jsx)(sm.Ca6,{}),"aria-label":"Add file",onClick:()=>y(e=>[...e,{format:"warden",scope:"local",gzip:!!(null==h?void 0:h.capabilities.binary)}])})}),S&&(0,i.jsx)(lB,{intent:"warning",children:'Publishing the "all" scope rebroadcasts lists you subscribe to: one upstream verdict can then look independently corroborated to anyone consuming both lists. Prefer "local" unless you are deliberately aggregating.'})]}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:r,children:"Cancel"}),(0,i.jsx)(v,{intent:"primary",loading:k.isPending,onClick:()=>
42{if(!p.trim())return m.oR.error("a name is required");if(new Set(b.map(e=>`${e.format}:${e.scope}`)).size!==b.length)return m.oR.error("duplicate format/scope file");for(let e of(null==h?void 0:h.fields)??[]){let t=j[e.key];if(e.required&&"switch"!==e.type&&!String(t??"").trim()&&!(l&&e.secret))return m.oR.error(`${e.label} is required`)}k.mutate()},children:l?"Save":"Add target"})]})]})})}var dM=s(64422),dP=s(38390),d$=s(40883);function dD(e){let{value:t,format:s,durationSec:a=.35,ease:r="easeOut"}=e,n=(0,nK.I)(),l=(0,dM.d)(t),o=(0,dP.G)(l,s),d=u.useRef(!1);return u.useEffect(()=>{let e=l.get(),s=Math.max(Math.abs(e),Math.abs(t)),i=s>0&&Math.abs(t-e)/s>.5;if(!d.current||n||i){d.current=!0,l.set(t);return}let o=(0,d$.i)(l,t,{duration:a,ease:r});return()=>o.stop()},[t,a,r,n,l]),(0,i.jsx)(se.P.span,{children:o})}let dL=["dashboard","streams"],dO=[...dL,"live"],dU=[...dL,"bans"];function dF(e){return(null==e?void 0:e.tickMs)??500}let dz=null,dV=0;function dq(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=(0,e3.jE)();return u.useEffect(()=>{if(e)return dV++,dz||((dz=new EventSource("/api/v1/dashboard/streams/live/stream",{withCredentials:!0})).onmessage=e=>{try{t.setQueryData(dO,JSON.parse(e.data))}catch{}}),()=>{--dV>0||(null==dz||dz.close(),dz=null)}},[t,e]),(0,ty.I)({queryKey:dO,queryFn:()=>ea("/dashboard/streams/live"),staleTime:1/0,enabled:e})}function dB(e){return(0,ty.I)({queryKey:[...dL,"bandwidth",e],queryFn:()=>ea(`/dashboard/streams/bandwidth?window=${e}`),staleTime:15e3,refetchInterval:3e4})}function dK(){let e=(0,e3.jE)();return(0,e5.n)({mutationFn:e=>ea("POST /dashboard/streams/bans",{body:e}),onSuccess:()=>{e.invalidateQueries({queryKey:dU}),e.invalidateQueries({queryKey:dO})}})}let dH="aiostreams.proxy.generated",dW=nV.Ik({url:nV.Yj(),filename:nV.bz(),requestHeaders:nV.bz(),responseHeaders:nV.bz(),type:nV.bz(),encrypt:nV.bz()});function dG(e){nf(e,{onSuccess:()=>m.oR.success("Copied to clipboard"),onError:()=>m.oR.error("Failed to copy to clipboard")})}function dY(){let[e,t]=u.useState(!1),[s,a]=u.useState(null),r=(0,e5.n)({mutationFn:async e=>{let t=await fetch("/api/v1/proxy/generate",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json().catch(()=>({}));if(!t.ok){var a;throw Error((null==s||null==(a=s.error)?void 0:a.message)??(null==s?void 0:s.detail)??`Request failed (${t.status})`)}return s}}),[n,l]=u.useState(()=>{try{return JSON.parse(localStorage.getItem(dH)||"[]")}catch{return[]}});return(0,i.jsxs)(sl,{open:e,onOpenChange:e=>{t(e),e||a(null)},title:"Generate proxy link",trigger:(0,i.jsx)(v,{intent:"primary-subtle",size:"sm",leftIcon:(0,i.jsx)(sm.Jty,{}),children:"Generate proxy link"}),children:[(0,i.jsx)(n3,{schema:dW,defaultValues:{url:"",filename:"",requestHeaders:{},responseHeaders:{},type:"stream",encrypt:!0},onSubmit:async e=>{var t;if(!(null==(t=e.url)?void 0:t.trim()))return void m.oR.error("URL is required");try{let t=await r.mutateAsync({url:e.url.trim(),filename:e.filename||void 0,requestHeaders:Object.keys(e.requestHeaders||{}).length?e.requestHeaders:void 0,responseHeaders:Object.keys(e.responseHeaders||{}).length?e.responseHeaders:void 0,type:e.type||"stream",encrypt:!1!==e.encrypt});a(t.proxified_url);let s=[t.proxified_url,...n].slice(0,20);l(s),localStorage.setItem(dH,JSON.stringify(s))}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to generate")}},children:()=>(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)(lD.Text,{name:"url",label:"URL",placeholder:"https://â¦"}),(0,i.jsx)(lD.Text,{name:"filename",label:"Filename (optional)"}),(0,i.jsx)(ie,{name:"requestHeaders",label:"Request headers",valueKind:"string"}),(0,i.jsx)(ie,{name:"responseHeaders",label:"Response headers",valueKind:"string"}),(0,i.jsx)(lD.Select,{name:"type",label:"Type",options:[{label:"Stream",value:"stream"},{label:"NZB",value:"nzb"}]}),(0,i.jsx)(lD.Switch,{name:"encrypt",label:"Encrypt payload",side:"right"}),(0,i.jsx)(lD.Submit,{loading:r.isPending,children:"Generate"})]})}),s&&(0,i.jsxs)("div",{className:"mt-4 flex items-center gap-2 rounded-lg bg-[--subtle] p-3",children:[(0,i.jsx)("code",{className:"flex-1 break-all text-xs",children:s}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",leftIcon:(0,i.jsx)(sm.Xpf,{}),onClick:()=>dG(s),children:"Copy"})]}),n.length>0&&(0,i.jsxs)("div",{className:"mt-4",children:[(0,i.jsx)("p",{className:"mb-1 text-xs text-[--muted]",children:"Recent (this browser)"}),(0,i.jsx)("ul",{className:"max-h-40 space-y-1 overflow-auto",children:n.map((e,t)=>(0,i.jsxs)("li",{className:"flex items-center gap-2",children:[(0,i.jsx)("code",{className:"flex-1 break-all text-[10px] text-[--muted]",children:e}),(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.Xpf,{}),"aria-label":"Copy link",onClick:()=>dG(e)})]},t))})]})]})}let dJ={usenet:{label:"Usenet",icon:sm.hQe,className:"border-indigo-500/40 bg-indigo-500/10 text-indigo-300"},proxy:{label:"Proxy",icon:sm.IS1,className:"border-teal-500/40 bg-teal-500/10 text-teal-300"}};function dZ(e){let{transport:t,className:s}=e,a=dJ[t]??dJ.proxy,r=a.icon;return(0,i.jsxs)("span",{className:x("inline-flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide",a.className,s),children:[(0,i.jsx)(r,{className:"text-xs"}),a.label]})}let dQ="inline-flex shrink-0 items-center gap-1 rounded-md border border-[--border] px-1.5 py-0.5 text-[10px] font-medium text-[--muted]";function dX(e){let{children:t,className:s}=e;return(0,i.jsx)("span",{className:x(dQ,s),children:t})}function d0(e){let{reads:t}=e;return(0,i.jsxs)(t5,{trigger:(0,i.jsxs)(dX,{className:"border-amber-500/40 bg-amber-500/10 text-amber-300",children:[(0,i.jsx)(sm.P$d,{}),t]}),children:[t," range requests open at once â a player normally holds one."]})}function d1(e){let{ip:t}=e,[s,a]=u.useState(!1),r=function(e){if(e.endsWith(".x")||e.endsWith("::/48"))return e;let t=e.replace(/^::ffff:/i,"");if(t.includes(".")){let e=t.split(".");return 4===e.length?`${e[0]}.â¢â¢â¢.â¢.â¢`:"â¢â¢â¢"}
42if(t.includes(":")){let e=t.split(":").filter(Boolean)[0];return e?`${e}:â¢â¢â¢`:"â¢â¢â¢"}return"â¢â¢â¢"}(t);if(r===t)return(0,i.jsx)(dX,{className:"font-mono",children:t});let n=s?"Hide client IP":"Reveal client IP";return(0,i.jsx)("button",{type:"button",onClick:()=>a(e=>!e),"aria-label":n,"aria-pressed":s,title:n,className:x(dQ,"font-mono transition-colors hover:border-[--muted] hover:text-[--foreground]"),children:s?t:r})}function d2(e){let{value:t,onChange:s,options:a,className:r}=e;return(0,i.jsx)("div",{role:"tablist",className:x("inline-flex items-center gap-0.5 rounded-lg border border-[--border] bg-[--subtle]/50 p-0.5",r),children:a.map(e=>{let a=e.value===t;return(0,i.jsx)("button",{role:"tab","aria-selected":a,onClick:()=>s(e.value),className:x("rounded-[6px] px-2.5 py-1 text-xs font-medium transition-colors",a?"bg-[--paper] text-[--foreground] shadow-sm":"text-[--muted] hover:text-[--foreground]"),children:e.label},e.value)})})}function d3(e){return e.filename||e.displayUrl||e.targetKey}function d5(e){return e.size?Math.min(1,Math.max(0,(e.start+e.currentBytes)/e.size)):0}function d4(e){return e||"unidentified"}function d6(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),s=Math.max(0,Math.round((t-e)/1e3));return s<60?`${s}s ago`:s<3600?`${Math.round(s/60)}m ago`:s<86400?`${Math.round(s/3600)}h ago`:`${Math.round(s/86400)}d ago`}let d9=[{label:"15 minutes",ms:9e5},{label:"1 hour",ms:36e5},{label:"24 hours",ms:864e5},{label:"7 days",ms:6048e5},{label:"Until lifted"}];function d8(e){let t,s,{stream:a,now:r,frameMs:n,onBlock:l}=e,o=d5(a),d="streaming"===a.activity,c=(t=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea(`DELETE /dashboard/streams/sessions/${encodeURIComponent(e)}`),onSuccess:()=>t.invalidateQueries({queryKey:dO})})),u=(s=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea(`POST /dashboard/streams/users/${encodeURIComponent(e)}/kill`),onSuccess:()=>s.invalidateQueries({queryKey:dO})})),h=!!a.username,p=(e,t)=>e.then(()=>m.oR.success(t)).catch(e=>m.oR.error((null==e?void 0:e.message)??"Action failed")),g=sd({title:"Stop this stream",description:(0,i.jsxs)(i.Fragment,{children:["End ",(0,i.jsx)("span",{className:"break-all",children:d3(a)})," for"," ",d4(a.username),". Their player will drop, and nothing prevents it reconnecting â use a block for that."]}),actionText:"Stop",actionIntent:"alert-subtle",onConfirm:()=>void p(c.mutateAsync(a.id),"Stream stopped")}),f=sd({title:`Stop all streams for ${d4(a.username)}`,description:"End every stream this user currently has open, across the proxy and the usenet engine. They can start new ones immediately unless you also block them.",actionText:"Stop all",actionIntent:"alert-subtle",onConfirm:()=>void p(u.mutateAsync(a.username),"Stopped all their streams")});return(0,i.jsxs)("div",{className:"space-y-1.5 rounded-lg border border-[--border] bg-[--paper] p-3",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1.5",children:[(0,i.jsx)(dZ,{transport:a.transport}),a.activeReads>1&&(0,i.jsx)(d0,{reads:a.activeReads}),(0,i.jsx)("span",{className:"order-last w-full min-w-0 truncate text-sm font-medium sm:order-none sm:w-auto sm:flex-1",title:d3(a),children:d3(a)}),(0,i.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-[--muted]",children:d?(0,i.jsx)(dD,{value:a.bytesPerSec,format:nj,durationSec:n/1e3}):(0,i.jsxs)("span",{className:"inline-flex items-center gap-1",title:`No bytes for ${nR(a.idleMs)}`,children:[(0,i.jsx)(sm._5G,{}),"paused"===a.activity?"paused":"idle"]})}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm._6i,{}),"aria-label":"Stop stream",disabled:c.isPending,onClick:g.open}),children:"Stop this stream"}),(0,i.jsxs)(iN,{align:"end",trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.voe,{}),"aria-label":"More actions"}),children:[(0,i.jsx)(iS,{children:h?d4(a.username):"Unidentified stream"}),(0,i.jsxs)(ik,{disabled:!h,onSelect:()=>l({scope:"target",username:a.username,targetKey:a.targetKey,label:d3(a)}),children:[(0,i.jsx)(sm.PLI,{}),"Block this titleâ¦"]}),(0,i.jsx)(iC,{}),(0,i.jsxs)(ik,{disabled:!h||u.isPending,onSelect:f.open,children:[(0,i.jsx)(sm._6i,{}),"Stop all their streams"]}
42),(0,i.jsxs)(ik,{disabled:!h,onSelect:()=>l({scope:"user",username:a.username}),children:[(0,i.jsx)(sm.Jg2,{}),"Block this userâ¦"]})]})]}),(0,i.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-[--subtle]",children:(0,i.jsx)("div",{className:x("h-full bg-brand transition-[width] ease-linear motion-reduce:transition-none",d&&"animate-pulse"),style:{width:`${100*o}%`,transitionDuration:`${n}ms`}})}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs tabular-nums text-[--muted]",children:[(0,i.jsx)(dX,{children:d4(a.username)}),a.clientIp&&(0,i.jsx)(d1,{ip:a.clientIp}),a.size>0&&(0,i.jsx)("span",{children:(0,i.jsx)(dD,{value:100*o,format:e=>`${Math.round(e)}%`,durationSec:n/1e3,ease:"linear"})}),(0,i.jsxs)("span",{children:[(0,i.jsx)(dD,{value:a.bytesServed,format:ny,durationSec:n/1e3,ease:"linear"}),a.size>0?` of ${ny(a.size)}`:""," served"]}),(0,i.jsxs)("span",{children:[a.requests," request",1===a.requests?"":"s"]}),(0,i.jsxs)("span",{children:[nR(r-a.startedAt)," elapsed"]})]}),(0,i.jsx)(sc,{...g}),(0,i.jsx)(sc,{...f})]})}function d7(e){let{target:t,onClose:s}=e,a=dK(),[r,n]=u.useState("0"),[l,o]=u.useState("");if(u.useEffect(()=>{t&&(n("0"),o(""))},[t]),!t)return null;let d="user"===t.scope,c=async()=>{try{var e;let n=await a.mutateAsync({scope:t.scope,username:t.username,targetKey:t.targetKey,reason:l.trim()||void 0,durationMs:null==(e=d9[Number(r)])?void 0:e.ms});m.oR.success(n.stopped>0?`Blocked â stopped ${n.stopped} stream${1===n.stopped?"":"s"}`:"Blocked"),s()}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to block")}};return(0,i.jsx)(sl,{open:!0,onOpenChange:e=>!e&&s(),title:d?`Block ${t.username}`:"Block this stream",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:d?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"text-[--foreground]",children:t.username})," ","will not be able to start any stream, and everything they have open now will be stopped."]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"text-[--foreground]",children:t.username})," ","will not be able to reopen"," ",(0,i.jsx)("span",{className:"break-all text-[--foreground]",children:t.label||"this title"}),". Their other streams keep working."]})}),(0,i.jsx)(L,{label:"Duration",children:(0,i.jsx)(nc,{value:r,onValueChange:n,options:d9.map((e,t)=>({label:e.label,value:String(t)}))})}),(0,i.jsx)(L,{label:"Reason (optional)",children:(0,i.jsx)(K,{value:l,onValueChange:o,placeholder:"Shown on the Blocks list"})}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",size:"sm",onClick:s,children:"Cancel"}),(0,i.jsx)(v,{intent:"alert",size:"sm",loading:a.isPending,onClick:c,children:"Block"})]})]})})}let ce={idle:{label:"Finished"},stopped:{label:"Stopped",className:"border-orange-400/40 bg-orange-500/10 text-orange-300"},banned:{label:"Blocked",className:"border-red-400/40 bg-red-500/10 text-red-200"},limit:{label:"Limit reached",className:"border-red-400/40 bg-red-500/10 text-red-200"},error:{label:"Error",className:"border-red-400/40 bg-red-500/10 text-red-200"},stale:{label:"Interrupted",className:"border-amber-500/40 bg-amber-500/10 text-amber-300"}},ct=[{label:"All types",value:"all"},{label:"Usenet",value:"usenet"},{label:"Proxy",value:"proxy"}],cs=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}),ca=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}),cr=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"});function cn(e){let{used:t,limit:s}=e;if(s<=0)return(0,i.jsx)("span",{className:"tabular-nums",children:ny(t)});let a=Math.min(1,t/s);return(0,i.jsxs)("div",{className:"flex min-w-[160px] items-center gap-2",children:[(0,i.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-[--subtle]",children:(0,i.jsx)("div",{className:x("h-full",a>=1?"bg-red-400":a>=.85?"bg-amber-500":"bg-brand"),style:{width:`${100*a}%`}})}),(0,i.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-[--muted]",children:[ny(t)," / ",ny(s)]})]})}let cl=[{value:"total",label:"Total"},{value:"user",label:"By user"}];function ci(){let[e,t]=u.useState(!1),[s,a]=u.useState(""),[r,n]=u.useState("0"),[l,o]=u.useState(""),d=dK(),c=async()=>
42{if(!s.trim())return void m.oR.error("Username is required");try{var e;await d.mutateAsync({scope:"user",username:s.trim(),reason:l.trim()||void 0,durationMs:null==(e=d9[Number(r)])?void 0:e.ms}),m.oR.success("Blocked"),t(!1),a(""),o("")}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to block")}};return(0,i.jsx)(sl,{open:e,onOpenChange:t,title:"Block a user",trigger:(0,i.jsx)(v,{intent:"alert-subtle",size:"sm",leftIcon:(0,i.jsx)(sm.Ca6,{}),children:"Block a user"}),children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(L,{label:"Username",help:"Must match a username in AIOSTREAMS_AUTH.",children:(0,i.jsx)(K,{value:s,onValueChange:a,placeholder:"alice"})}),(0,i.jsx)(L,{label:"Duration",children:(0,i.jsx)(nc,{value:r,onValueChange:n,options:d9.map((e,t)=>({label:e.label,value:String(t)}))})}),(0,i.jsx)(L,{label:"Reason (optional)",children:(0,i.jsx)(K,{value:l,onValueChange:o})}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),(0,i.jsx)(v,{intent:"alert",size:"sm",loading:d.isPending,onClick:c,children:"Block"})]})]})})}function co(e){let[t,s]=(0,u.useState)(()=>"u">typeof window&&!!window.matchMedia&&window.matchMedia(e).matches);return(0,u.useEffect)(()=>{if("u"<typeof window||!window.matchMedia)return;let t=window.matchMedia(e),a=()=>s(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),t}function cd(e){if(e.name)return e.name;let t=e.path??"",s=t.lastIndexOf("/");return -1===s?t:t.slice(s+1)}function cc(e){var t;let{hash:s,name:a,open:r,onOpenChange:n}=e,l=(t=r?s:null,(0,ty.I)({queryKey:[...i3,"library","files",t],enabled:!!t,queryFn:()=>ea(`/dashboard/usenet/library/${encodeURIComponent(t)}/files`)})),o=i7(),d=e=>e.path??(null!=e.index?String(e.index):e.name),c=(e,t)=>{s&&o.mutateAsync({hash:s,fileSel:d(e),download:t}).then(e=>window.open(e.url,"_blank")).catch(e=>m.oR.error((null==e?void 0:e.message)??"No playable source"))},u=l.data?function(e){let t={};for(let s of e){let e=s.path??s.name??"",a=e.lastIndexOf("/"),r=-1===a?"":e.slice(0,a);(t[r]||(t[r]=[])).push(s)}return t}(l.data.files):{},h=Object.keys(u).sort();return(0,i.jsx)(sl,{open:r,onOpenChange:n,title:a||"Browse NZB",description:"Files in this NZB (including stored archive contents).",contentClass:"max-w-4xl",headerClass:"pr-8",children:(0,i.jsx)("div",{className:"max-h-[72vh] overflow-y-auto space-y-4",children:l.isLoading?(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Loadingâ¦"}):l.isError?(0,i.jsx)("p",{className:"text-sm text-red-400",children:"Failed to load files."}):0===h.length?(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No files."}):h.map(e=>{var t;let a;return(0,i.jsxs)("div",{children:[e&&(0,i.jsxs)("div",{className:"flex items-start gap-1.5 text-xs text-[--muted] mb-1",children:[(0,i.jsx)(sm.gNt,{className:"shrink-0 mt-0.5"}),(0,i.jsx)("span",{className:"min-w-0 break-all",children:e})]}),(0,i.jsx)("div",{className:"space-y-1",children:(t=u[e],a=e=>+("video"!==e.category&&"audio"!==e.category),[...t].sort((e,t)=>a(e)-a(t)||(e.category??"").localeCompare(t.category??"")||cd(e).localeCompare(cd(t)))).map((t,a)=>{let r=!1!==t.streamable;return(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-md border border-[--border]/60 px-2.5 py-1.5",children:[(0,i.jsxs)("div",{className:"flex w-full min-w-0 items-start gap-2 sm:w-auto sm:flex-1",children:[(0,i.jsx)(sm.MG2,{className:"text-[--muted] shrink-0 mt-0.5"}),(0,i.jsx)("span",{className:"min-w-0 text-sm break-all",children:cd(t)})]}),t.category&&(0,i.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:t.category}),(0,i.jsx)("span",{className:"text-xs tabular-nums text-[--muted] shrink-0 sm:w-20 sm:text-right",children:ny(t.size)}),(0,i.jsxs)("div",{className:"flex items-center gap-1 shrink-0 ml-auto sm:ml-0",children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(sm.UIR,{}),"aria-label":"Preview",disabled:!r,className:x(!r&&"opacity-40"),onClick:()=>c(t,!1)}),children:r?"Preview":"Not individually streamable"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.Ah9,{}),"aria-label":"Download",disabled:!r,className:x(!r&&"opacity-40"),onClick:()=>c(t,!0)}),children:r?"Download":"Not individually streamable"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.o9J,{}),"aria-label":"Copy download link",disabled:!r,className:x(!r&&"opacity-40"),onClick:()=>{s&&o.mutateAsync({hash:s,fileSel:d(t),download:!0}).then(e=>nf(window.location.origin+e.url,{onSuccess:()=>m.oR.success("Download link copied"),onError:()=>m.oR.error("Failed to copy link")})).catch(e=>m.oR.error((null==e?void 0:e.message)??"No downloadable source"))}}),children:"Copy download link"})]})]},`${e}-${a}`)})})]},e||"root")})})})}function cu(e,t){nf(e,{onSuccess:()=>m.oR.success(`${t} copied`),onError:()=>m.oR.error("Copy failed")})}function cm(e){let{label:t,value:s,onCopy:a,children:r}=e;return null!=s||r?(0,i.jsxs)("div",{className:"flex items-start gap-3 py-1.5 border-b border-[--border]/40 last:border-0",children:[(0,i.jsx)("span",{className:"w-28 shrink-0 text-xs font-medium text-[--muted] pt-0.5",children:t}),(0,i.jsxs)("div",{className:"min-w-0 flex-1 text-sm flex items-center gap-2",children:[r??(0,i.jsx)("span",{className:"break-all",children:s}),a&&(0,i.jsx)(w,{size:"xs",intent:"gray-subtle",icon:(0,i.jsx)(sm.Xpf,{}),"aria-label":`Copy ${t}`,className:"shrink-0 ml-auto",onClick:a})]})]}):null}function ch(e){let{label:t,secret:s}=e,[a,r]=u.useState(!1);return(0,i.jsxs)(cm,{label:t,children:[(0,i.jsx)("span",{className:"font-mono break-all",children:a?s:"â¢".repeat(Math.min(s.length,12))}),(0,i.jsx)(w,{size:"xs",intent:"gray-subtle",icon:a?(0,i.jsx)(sm.MXC,{}):(0,i.jsx)(sm.Nyy,{}),"aria-label":a?`Hide ${t}`:`Show ${t}`,className:"shrink-0 ml-auto",onClick:()=>r(e=>!e)}),(0,i.jsx)(w,{size:"xs",intent:"gray-subtle",icon:(0,i.jsx)(sm.Xpf,{}),"aria-label":`Copy ${t}`,className:"shrink-0",onClick:()=>cu(s,t)})]})}function cp(e){let{url:t}=e;if(t.startsWith("local-nzb://"))return null;let s=t;try{s=new URL(t).hostname}catch{}
42return(0,i.jsxs)(cm,{label:"NZB URL",children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)("span",{className:"font-mono break-all cursor-default",children:s}),className:"max-w-md break-all",children:t}),(0,i.jsx)(w,{size:"xs",intent:"gray-subtle",icon:(0,i.jsx)(sm.Xpf,{}),"aria-label":"Copy NZB URL",className:"shrink-0 ml-auto",onClick:()=>cu(t,"NZB URL")})]})}let cx={wd1:"Portable release fingerprint based on indexer metadata (size, poster, date)",nh1:"Exact NZB content hash"};function cg(e){let{entry:t}=e,s=i2(t);return 0===s.length?null:(0,i.jsx)(cm,{label:1===s.length?"Release key":"Release keys",children:(0,i.jsx)("div",{className:"min-w-0 flex-1 flex flex-col gap-1",children:s.map(e=>(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(t5,{side:"left",trigger:(0,i.jsx)("span",{className:"font-mono text-xs break-all cursor-default",children:e}),children:cx[e.split(":")[0]]??"Blocklist key"}),(0,i.jsx)(w,{size:"xs",intent:"gray-subtle",icon:(0,i.jsx)(sm.Xpf,{}),"aria-label":"Copy release key",className:"shrink-0 ml-auto",onClick:()=>cu(e,"Release key")})]},e))})})}function cf(e){let{entry:t}=e,s=t.arrLink;if(!s)return null;let a=s.repair;return(0,i.jsx)(cm,{label:"Arr repair",value:(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("span",{children:a?({pending:"Queued",blocklisted:"Marked failed in the arr",searched:"Marked failed, replacement searched",done:"Done",failed:"Gave up"})[a.state]:"Not needed"}),(null==a?void 0:a.attempts)?(0,i.jsxs)("span",{className:"text-[--muted]",children:[" ","\xb7 ",a.attempts," attempt",1===a.attempts?"":"s"]}):null,(null==a?void 0:a.lastError)&&(0,i.jsx)("p",{className:"text-xs text-red-400 break-words",children:a.lastError})]})})}function cb(e){let{entry:t,open:s,onOpenChange:a}=e;return t?(0,i.jsx)(sl,{open:s,onOpenChange:a,title:"NZB details",contentClass:"max-w-lg",children:(0,i.jsxs)("div",{className:x("mt-1"),children:[(0,i.jsx)(cm,{label:"Name",value:t.name||t.nzbHash,onCopy:()=>cu(t.name||t.nzbHash,"Name")}),(0,i.jsx)(cm,{label:"Status",value:t.status}),"failed"===t.status&&t.failReason&&(0,i.jsx)(cm,{label:"Error",value:t.failReason}),(0,i.jsx)(cm,{label:"Size",value:ny(t.size)}),(0,i.jsx)(cm,{label:"Files",value:`${t.files.length} file${1===t.files.length?"":"s"}`}),(0,i.jsx)(cm,{label:"Source",value:t.source}),t.owner&&(0,i.jsx)(cm,{label:"Added by",value:t.owner}),t.postedAt&&(0,i.jsx)(cm,{label:"Posted",value:nI(new Date(1e3*t.postedAt).toISOString())}),(0,i.jsx)(cm,{label:"Added",value:nI(t.addedAt)}),(0,i.jsx)(cm,{label:"Last used",value:nI(t.lastUsedAt)}),null!=t.importMs&&(0,i.jsx)(cm,{label:"Import time",value:function(e){if(null==e||!Number.isFinite(e))return"â";if(e<1e3)return`${Math.round(e)} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`}(t.importMs)}),t.password&&(0,i.jsx)(ch,{label:"Password",secret:t.password}),t.nzbUrl&&(0,i.jsx)(cp,{url:t.nzbUrl}),(0,i.jsx)(cm,{label:"Hash",value:(0,i.jsx)("span",{className:"font-mono text-xs break-all",children:t.nzbHash}),onCopy:()=>cu(t.nzbHash,"Hash")}),(0,i.jsx)(cf,{entry:t}),(0,i.jsx)(cg,{entry:t})]})}):null}let cv={queued:"bg-[--subtle] text-[--muted]",inspecting:"bg-amber-500/15 text-amber-500",available:"bg-emerald-500/15 text-emerald-500",degraded:"bg-orange-500/15 text-orange-400",failed:"bg-red-400/15 text-red-400"},cy=[{value:"all",label:"All statuses"},{value:"queued",label:"Queued"},{value:"inspecting",label:"Inspecting"},{value:"available",label:"Available"},{value:"degraded",label:"Degraded"},{value:"failed",label:"Failed"}],cj=[{value:"activity",label:"Recent activity"},{value:"added",label:"Date added"},{value:"name",label:"Name"},{value:"size",label:"Size"}],cw={activity:"desc",added:"desc",name:"asc",size:"desc"},cN=[15,30,50,100],ck=cN.map(e=>({value:String(e),label:`${e} / page`})),cS="usenet.library.view",cC="usenet.library.pageSize";function c_(){try{return"list"===localStorage.getItem(cS)?"list":"grid"}catch{return"grid"}}function cA(){try{let e=Number(localStorage.getItem(cC));return cN.includes(e)?e:15}catch{return 15}}function cR(e){let{value:t,onChange:s}=e,a=(e,a,r)=>(0,i.jsx)("button",{type:"button","aria-label":r,"aria-pressed":t===e,onClick:()=>s(e),className:x("flex h-9 w-9 items-center justify-center rounded text-lg transition-colors",t===e?"bg-brand/10 text-brand":"text-[--muted] hover:text-[--foreground]"),children:a});return(0,i.jsxs)("div",{className:"flex h-10 items-center gap-0.5 rounded-md border border-[--border] p-0.5",children:[a("grid",(0,i.jsx)(sm.fiy,{}),"Grid view"),a("list",(0,i.jsx)(sm.XfR,{}),"List view")]})}function cT(e){let{status:t}=e;return(0,i.jsx)("span",{className:x("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",cv[t]),children:t})}let cI={"application/x-nzb":[".nzb"],"application/xml":[".nzb"],"text/xml":[".nzb"]}
42;function cE(){let e,t,[s,a]=u.useState(""),[r,n]=u.useState(null),l=(e=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea("POST /dashboard/usenet/library",{body:e}),onSuccess:()=>e.invalidateQueries({queryKey:[...i3,"library"]})})),o=(t=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>{let t=new FormData;return t.append("file",e.file,e.file.name),e.name&&t.append("name",e.name),ea("POST /dashboard/usenet/library/upload",{body:t})},onSuccess:()=>t.invalidateQueries({queryKey:[...i3,"library"]})})),d=e=>{"failed"===e.status?m.oR.error(e.failReason??"Import failed"):m.oR.success("NZB queued")},c=async e=>{n({done:0,total:e.length});let t=0;await Promise.all(e.map(async s=>{try{let e=await o.mutateAsync({file:s,name:s.name});d(e)}catch(e){m.oR.error(`${s.name}: ${(null==e?void 0:e.message)??"upload failed"}`)}finally{n({done:t+=1,total:e.length})}})),n(null)},h=()=>{let e=s.trim();e&&l.mutateAsync({url:e}).then(e=>{d(e),"failed"!==e.status&&a("")}).catch(e=>m.oR.error((null==e?void 0:e.message)??"Failed to add NZB"))};return(0,i.jsxs)(J,{className:"p-4 space-y-3",children:[(0,i.jsx)(lz,{title:"Add NZB",description:"Import .nzb files or paste a URL",icon:sm.K0Y,size:"md"}),(0,i.jsx)(lb,{accept:cI,multiple:!0,className:"min-h-[120px] w-full",dropzoneText:"Drop .nzb files here, or click to choose",onValueChange:e=>{e.length&&c(e)},onDropRejected:e=>{let t=e.map(e=>e.file.name);m.oR.error(1===t.length?`"${t[0]}" isn't a .nzb file`:`${t.length} files skipped, only .nzb files are supported`)}}),r&&(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["Importing ",r.done,"/",r.total,"â¦"]}),(0,i.jsxs)("div",{className:"flex items-stretch",children:[(0,i.jsx)(K,{leftIcon:(0,i.jsx)(sm.Jty,{}),placeholder:"â¦or add by URL: https://â¦/file.nzb",value:s,onValueChange:a,onKeyDown:e=>"Enter"===e.key&&h(),className:"flex-1 rounded-r-none"}),(0,i.jsx)(v,{intent:"primary",leftIcon:(0,i.jsx)(sm.Ca6,{}),loading:l.isPending,onClick:h,disabled:!s.trim(),className:"rounded-l-none shrink-0",children:"Add"})]})]})}function cM(e){var t;let{entry:s,onBrowse:a,onInfo:r,onBlock:n,onUnblock:l,onRequeue:o,onRepair:d,onDelete:c}=e,u=i7(),h="available"===s.status||"degraded"===s.status,p=s.files.length>1,x=h&&!p,g=e=>{u.mutateAsync({hash:s.nzbHash,download:e}).then(e=>window.open(e.url,"_blank")).catch(e=>m.oR.error((null==e?void 0:e.message)??"No playable source"))},f=i2(s);return(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"gray-outline",leftIcon:(0,i.jsx)(sm.uwC,{}),onClick:()=>a(s),children:"Browse"}),(0,i.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(sm.UIR,{}),"aria-label":"Preview",disabled:!x,onClick:()=>g(!1)}),children:p?"Browse to pick a file":"Preview"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.Ah9,{}),"aria-label":"Download",disabled:!x,onClick:()=>g(!0)}),children:p?"Browse to pick a file":"Download"}),(0,i.jsxs)(iN,{align:"end",trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.voe,{}),"aria-label":"More actions"}),children:[(0,i.jsxs)(ik,{onSelect:()=>r(s),children:[(0,i.jsx)(sm.wfp,{}),"Details"]}),(0,i.jsxs)(ik,{onSelect:()=>o([s.nzbHash]),disabled:!s.nzbUrl,children:[(0,i.jsx)(sm.Zxy,{}),s.nzbUrl?"Requeue import":"No source NZB to re-import"]}),(0,i.jsxs)(ik,{onSelect:()=>{var e;let t=document.createElement("a");e=s.nzbHash,t.href=`/api/v1/dashboard/usenet/library/${encodeURIComponent(e)}/nzb`,t.rel="noopener",document.body.appendChild(t),t.click(),t.remove()},children:[(0,i.jsx)(sm.w4m,{}),"Export NZB"]}),s.arrLink&&(0,i.jsxs)(ik,{onSelect:()=>d(s),children:[(0,i.jsx)(sm.x8l,{}),(null==(t=s.arrLink.repair)?void 0:t.state)==="failed"?"Retry repair":"Replace via Sonarr/Radarr"]}),f.length>0&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(iC,{}),(0,i.jsxs)(ik,{onSelect:()=>s.blocked?l(s):n(s),children:[s.blocked?(0,i.jsx)(sm.DNZ,{}):(0,i.jsx)(sm.PLI,{}),s.blocked?"Unblock release":"Block release"]})]})]}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Delete entry",onClick:()=>c(s.nzbHash)}),children:"Delete"})]})]})}function cP(e){let{entry:t,view:s,selectMode:a,selected:r,onToggleSelect:n,onBrowse:l,onInfo:o,onBlock:d,onUnblock:c,onRequeue:u,onRepair:m,onDelete:h}=e,p=t.name||t.nzbHash,g=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{children:ny(t.size)}),(0,i.jsxs)("span",{children:[t.files.length," file",1===t.files.length?"":"s"]}),"sabnzbd"===t.origin&&(0,i.jsx)("span",{title:"Added through the SABnzbd API (Sonarr, Radarr, NZBHydra, â¦)",children:t.hiddenAt?"sab \xb7 imported":"sab"})]}),f=x("transition-[background-color,box-shadow] duration-200",a&&"cursor-pointer hover:bg-[--subtle]/30",r&&"ring-1 ring-inset ring-brand/60 bg-brand/[0.06]"),b=a?()=>n(t,!r):void 0;return"list"===s?(0,i.jsx)(J,{className:x(f,"p-3"),onClick:b,children:(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsx)("span",{className:"block font-medium text-sm break-all line-clamp-1",children:p}),(0,i.jsxs)("div",{className:"mt-0.5 flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-[--muted]",children:[g,"failed"===t.status&&t.failReason&&(0,i.jsx)("span",{className:"text-red-400",title:t.errorCode,children:t.failReason})]})]}),(0,i.jsx)(cT,{status:t.status}),!a&&(0,i.jsx)("div",{className:"shrink-0",children:(0,i.jsx)(cM,{entry:t,onBrowse:l,onInfo:o,onBlock:d,onUnblock:c,onRequeue:u,onRepair:m,onDelete:h})})]})}):(0,i.jsxs)(J,{className:x(f,"flex flex-col h-full p-3 sm:p-4"),onClick:b,children:[(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-start gap-2",children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)("span",{className:"min-w-0 flex-1 font-medium text-sm break-all line-clamp-2",children:p}),children:p}),(0,i.jsx)(cT,{status:t.status})]}),"failed"===t.status&&t.failReason&&(0,i.jsx)("p",{className:"text-xs text-red-400 mt-0.5",title:t.errorCode,children:t.failReason}),(0,i.jsx)("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-[--muted]",children:g})]}),!a&&(0,i.jsx)("div",{className:"mt-auto pt-3",children:(0,i.jsx)(cM,{entry:t,onBrowse:l,onInfo:o,onBlock:d,onUnblock:c,onRequeue:u,onRepair:m,onDelete:h})})]})}let c$=[{value:"all",label:"All recorded history"},{value:"1h",label:"Just this hour",hours:1},{value:"24h",label:"Last 24 hours",hours:24},{value:"7d",label:"Last 7 days",hours:168}];function cD(e){var t,s;let a=null==(t=c$.find(t=>t.value===e))?void 0:t.hours;return void 0===a?void 0:(s=Date.now())-s%36e5-(a-1)*36e5}function cL(e){let{target:t,onClose:s}=e,[a,r]=u.useState("all"),[n,l]=u.useState(null),o=i8(),d=i8();if(u.useEffect(()=>{t&&r("all")},[t]),u.useEffect(()=>{if(!t)return;let e=!0;return l(null),o.mutateAsync({target:t.target,id:t.id,sinceMs:cD(a),dryRun:!0}).then(t=>{e&&l(t)}).catch(()=>{}),()=>{e=!1}},[null==t?void 0:t.target,null==t?void 0:t.id,a]),!t)return null;
42let c=async()=>{try{let e=await d.mutateAsync({target:t.target,id:t.id,sinceMs:cD(a)}),r=e.providerRows+e.indexerRows;m.oR.success(0===r?"Nothing to reset":`Reset ${nT(r)} hourly row${1===r?"":"s"}`),s()}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to reset stats")}};return(0,i.jsx)(sl,{open:!0,onOpenChange:e=>!e&&s(),title:`Reset stats â ${t.label}`,children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["Deletes the recorded history for"," ",(0,i.jsx)("span",{className:"text-[--foreground]",children:t.label}),". Charts and totals are rebuilt from what is left, and this cannot be undone."]}),(0,i.jsx)(L,{label:"Range",children:(0,i.jsx)(nc,{value:a,onValueChange:r,options:c$.map(e=>({label:e.label,value:e.value}))})}),(0,i.jsx)("p",{className:"text-sm tabular-nums",children:n?function(e,t){let s=t.providerRows+t.indexerRows;if(0===s)return"Nothing recorded in this range.";let a=[];"indexers"!==e&&t.providerRows>0&&a.push(`${ny(t.providerBytes)}, ${nT(t.providerArticles)} articles`),"providers"!==e&&t.indexerRows>0&&a.push(`${nT(t.indexerGrabs)} grabs`);let r=1===s?"row":"rows";return`Removes ${nT(s)} hourly ${r}${a.length?` (${a.join(" \xb7 ")})`:""}.`}(t.target,n):(0,i.jsx)("span",{className:"text-[--muted]",children:"Checking what this removesâ¦"})}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:s,children:"Cancel"}),(0,i.jsx)(v,{intent:"alert",loading:d.isPending,disabled:(null==n?void 0:n.providerRows)===0&&(null==n?void 0:n.indexerRows)===0,onClick:c,children:"Reset stats"})]})]})})}let cO=["24h","7d","30d","all"];function cU(e){let{value:t,onChange:s}=e;return(0,i.jsx)("div",{className:"flex gap-1",children:cO.map(e=>(0,i.jsx)("button",{onClick:()=>s(e),className:x("px-2.5 py-1 rounded-md text-xs font-medium border transition-colors",t===e?"border-brand bg-brand/10 text-brand":"border-[--border] text-[--muted] hover:text-[--foreground]"),children:e},e))})}let cF={online:"bg-emerald-500",connecting:"bg-amber-500",offline:"bg-[--muted]",auth_failed:"bg-red-400",disabled:"bg-[--muted]/40"};function cz(e){let t=Date.now()-e;return t<1e3?"just now":`${nA(t)} ago`}function cV(e){let{p:t,health:s}=e;return(0,i.jsx)(P,{modal:!1,align:"start",className:"w-80",trigger:(0,i.jsx)("button",{type:"button","aria-label":`${t.name||t.id}: ${s.label}. Show details`,className:x("shrink-0 -my-1 p-1 rounded-full transition-opacity hover:opacity-70","bad"===s.tone?"text-red-400":"text-amber-500"),children:(0,i.jsx)(sm.wew,{className:"w-4 h-4"})}),children:(0,i.jsxs)("div",{className:"space-y-2.5",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("span",{className:x("w-2 h-2 rounded-full shrink-0",s.cls)}),(0,i.jsx)("span",{className:"text-sm font-semibold",children:s.label})]}),s.hint&&(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:s.hint}),t.lastDialError&&(0,i.jsxs)("div",{className:"rounded-[--radius] bg-[--subtle] p-2 space-y-1",children:[(0,i.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,i.jsx)("span",{className:"text-xs font-medium",children:t.lastDialError.kind}),(0,i.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:cz(t.lastDialError.at)})]}),(0,i.jsx)("p",{className:"text-xs text-[--muted] break-words",children:t.lastDialError.message})]}),(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:[t.lastDialOkAt?`Last successful connection ${cz(t.lastDialOkAt)}`:"No successful connection recorded",t.queued>0&&` \xb7 ${t.queued} queued in pool`]})]})})}function cq(e){let t=Math.max(0,e.globalDownloadsInUse-e.globalDownloadsOnWire);return`${e.globalDownloadsOnWire} downloading \xb7 ${t} queued of ${e.globalDownloadMax} budget`+(e.globalDownloadsWaiting>0?` \xb7 +${e.globalDownloadsWaiting} waiting`:"")}function cB(){let e=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=(0,e3.jE)();return u.useEffect(()=>{if(e)return i9++,i6||((i6=new EventSource("/api/v1/dashboard/usenet/live/stream",{withCredentials:!0})).onmessage=e=>{try{t.setQueryData(i4,JSON.parse(e.data))}catch{}}),()=>{--i9>0||(null==i6||i6.close(),i6=null)}},[t,e]),(0,ty.I)({queryKey:i4,queryFn:()=>ea("/dashboard/usenet/live"),staleTime:1/0,enabled:e})}().data,t=null==e?void 0:e.live,s=null==e?void 0:e.pool,a=function(e){let[t,s]=u.useState(!1),a=u.useRef(null),r=(null==e?void 0:e.providers.reduce((e,t)=>
42e+t.queued,0))??0,n=(null==e?void 0:e.globalDownloadsOnWire)??0;return u.useEffect(()=>{r>0&&0===n?(a.current??(a.current=Date.now()),s(Date.now()-a.current>6e4)):(a.current=null,s(!1))},[r,n,e]),t}(s),r=(null==s?void 0:s.providers.some(e=>e.isBackup))??!1,n=(null==e?void 0:e.tickMs)??500;return(0,i.jsxs)("div",{className:"space-y-4",children:[a&&(0,i.jsx)(lB,{intent:"warning",title:"Downloads are queued but no connections are transferring",description:"Fetches have been parked for over a minute with no wire activity. If this persists, check provider reachability or re-save the provider settings to rebuild the connection pools."}),(0,i.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,i.jsx)(oU,{label:"Active streams",value:t?String(t.activeStreams):"â",hint:s?cq(s):""}),(0,i.jsx)(oU,{label:"Download speed",value:t?(0,i.jsx)(dD,{value:t.currentBytesPerSec,format:nj,durationSec:n/1e3}):"â",hint:t?`peak ${nj(t.peakBytesPerSec)}`:""}),(0,i.jsx)(oU,{label:"Articles / min",value:t?(0,i.jsx)(dD,{value:t.articlesLastMinute,format:e=>nT(Math.round(e)),durationSec:n/1e3}):"â",hint:t?`${t.errorsLastMinute} errors`:""}),(0,i.jsx)(oU,{label:"Cache hit rate",value:e?(0,i.jsx)(dD,{value:e.cache.hitRate,format:nN,durationSec:n/1e3}):"â",hint:e?`${ny(e.cache.diskBytes)} on disk`:""})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsxs)("div",{className:"flex items-baseline justify-between mb-3",children:[(0,i.jsx)("h3",{className:"text-sm font-semibold",children:"Live connections"}),(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:[s?cq(s):"0 downloading \xb7 0 queued",r?" \xb7 includes backup capacity":""]})]}),s&&0!==s.providers.length?(0,i.jsx)("div",{className:"space-y-2.5",children:s.providers.map(e=>{let t=function(e){if("disabled"===e.state)return{tone:"off",cls:"bg-[--muted]/40",label:"Disabled"};if("auth_failed"===e.state)return{tone:"bad",cls:"bg-red-400",label:"Authentication failed",hint:"The provider rejected the username or password. Update the credentials on the Providers page."};let t=(e,t)=>({tone:"warn",cls:"bg-amber-500",label:e,hint:t});return e.tripped?t("Circuit breaker tripped","Too many failures in a row, so new requests skip this provider and fail over to the others. It retries automatically."):e.throttled?t("Connection-limit throttled","The provider refused another connection, usually because the account is at its connection limit. The pool has backed off and is running below its configured maximum."):"connecting"===e.state?t("Connecting"):e.lastDialError&&e.lastDialError.at>(e.lastDialOkAt??0)?t(`Last dial failed (${e.lastDialError.kind})`,"The most recent connection attempt did not succeed. If this persists, check the host, port and TLS settings."):e.acquired>0||e.total>0||e.lastDialOkAt&&Date.now()-e.lastDialOkAt<9e4?{tone:"ok",cls:"bg-emerald-500",label:"Reachable"}:{tone:"idle",cls:"bg-[--muted]",label:"Idle (no recent connections)"}}(e),s="warn"===t.tone||"bad"===t.tone,a=t=>e.max?`${Math.min(100,t/e.max*100)}%`:"0%";return(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)("span",{className:x("w-2 h-2 rounded-full shrink-0",t.cls)}),children:t.label}),(0,i.jsxs)("span",{className:"text-sm font-medium w-40 truncate flex items-center gap-1.5",children:[(0,i.jsx)("span",{className:"truncate",children:e.name||e.id}),e.isBackup&&(0,i.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:"backup"}),s&&(0,i.jsx)(cV,{p:e,health:t})]}),(0,i.jsxs)("div",{className:"relative flex-1 h-1.5 rounded-full bg-[--subtle] overflow-hidden",children:[(0,i.jsx)("div",{className:x("absolute inset-y-0 left-0","transition-[width] ease-out motion-reduce:transition-none",e.tripped?"bg-red-400/30":"bg-brand/30"),style:{width:a(e.total),transitionDuration:`${n}ms`}}),(0,i.jsx)("div",{className:x("absolute inset-y-0 left-0","transition-[width] ease-out motion-reduce:transition-none",e.tripped?"bg-red-400":"bg-brand"),style:{width:a(e.acquired),transitionDuration:`${n}ms`}})]}),(0,i.jsx)("span",{className:"text-xs tabular-nums w-24 text-right text-[--foreground]",title:`per-connection download-rate EWMA the load-balancer splits group traffic by \xb7 ${e.freeSlots} free pipeline slots \xb7 aggregate â this \xd7 active connections (see the windowed table for total speed)`,children:e.throughput?
42(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(dD,{value:e.throughput,format:nj,durationSec:n/1e3}),"/conn"]}):"â"}),(0,i.jsxs)("span",{className:"text-xs text-[--muted] tabular-nums w-40 text-right",title:`${e.queued} queued in pool`,children:[e.acquired," active \xb7 ",e.total," open \xb7 max ",e.max]})]},e.id)})}):(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No active provider pools. Connections open on demand when streaming."})]})]})}function cK(e){let{id:t}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"font-medium text-[--muted]",title:t,children:"Removed provider"}),(0,i.jsx)("span",{className:"text-xs text-[--muted] tabular-nums",title:t,children:t.slice(0,8)})]})}function cH(e){let{providers:t,onReset:s}=e;return 0===t.length?(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No provider activity recorded in this window yet."}):(0,i.jsx)("div",{className:"overflow-x-auto -mx-4 px-4 lg:mx-0 lg:px-0",children:(0,i.jsxs)("table",{className:"w-full text-sm min-w-[800px]",children:[(0,i.jsx)("thead",{className:"text-[--muted] text-xs uppercase",children:(0,i.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,i.jsx)("th",{className:"py-2 pr-3",children:"Provider"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Share"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Data"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Avg speed"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Articles"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",title:"How long the provider takes to answer a request for an article, before it starts sending it. Unlike the time to fetch a whole article, this does not grow when your bandwidth is shared across more streams, so it is comparable between providers.",children:"Avg latency"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Errors"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Missing"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",title:"Articles the provider delivered whose contents failed the checksum or size check. The fetch falls over to the next provider.",children:"Unreadable"}),(0,i.jsx)("th",{className:"py-2 pl-3 w-8","aria-label":"Actions"})]})}),(0,i.jsx)("tbody",{children:t.map(e=>(0,i.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,i.jsx)("td",{className:"py-2 pr-3",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("span",{className:x("w-2 h-2 rounded-full shrink-0",cF[e.live.state]),title:e.live.state}),e.removed?(0,i.jsx)(cK,{id:e.id}):(0,i.jsx)("span",{className:"font-medium",children:e.name||e.host}),e.isBackup&&(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"backup"}),e.removed?(0,i.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-[--radius] bg-[--subtle] text-[--muted]",children:"removed"}):!e.enabled&&(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"(disabled)"})]})}),(0,i.jsx)("td",{className:"py-2 px-3 text-right",children:(0,i.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,i.jsx)("div",{className:"w-16 h-1 rounded-full bg-[--subtle] overflow-hidden",children:(0,i.jsx)("div",{className:"h-full bg-brand",style:{width:`${100*e.articleShare}%`}})}),(0,i.jsx)("span",{className:"tabular-nums w-10 text-right",children:nN(e.articleShare)})]})}),(0,i.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:ny(e.bytes)}),(0,i.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",title:e.avgArticleMs?`${e.avgArticleMs}ms to fetch a whole article on average`:void 0,children:e.avgBytesPerSec?nj(e.avgBytesPerSec):"â"}),(0,i.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:nT(e.articles)}),(0,i.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",title:null==e.avgLatencyMs&&e.articles>0?"Latency is only measured on fetches that had a connection to themselves, so a provider running with pipelining enabled may report none.":void 0,children:null==e.avgLatencyMs?"â":`${e.avgLatencyMs}ms`}),(0,i.jsx)("td",{className:x("py-2 px-3 text-right tabular-nums",e.errorRate>.1&&"text-red-400"),children:nN(e.errorRate)}),(0,i.jsx)("td",{className:"py-2 px-3 text-right tabular-nums text-[--muted]",children:nN(e.missRate)}),(0,i.jsx)("td",{className:x("py-2 px-3 text-right tabular-nums",e.undecodableRate>0?"text-amber-400":"text-[--muted]"),children:nN(e.undecodableRate)}),(0,i.jsx)("td",{className:"py-2 pl-3 text-right",children:(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.sxT,{}),onClick:()=>s({target:"providers",id:e.id,label:e.removed?`Removed provider ${e.id.slice(0,8)}`:e.name||e.host}),"aria-label":"Reset stats for this provider"}),children:"Reset this provider's recorded stats"})})]},e.id))})]})})}function cW(e){let t=e.failedFetch-e.fetchAuth-e.fetchLimited,s=e.failed-e.failedMissing-e.failedFetch;return[e.failedMissing>0&&`${e.failedMissing} missing on providers`,e.fetchAuth>0&&`${e.fetchAuth} blocked (401/403)`,e.fetchLimited>0&&`${e.fetchLimited} rate-limited (429)`,t>0&&`${t} fetch failed`,s>0&&`${s}
42 other`].filter(Boolean).join(" \xb7 ")}function cG(e){let{indexer:t,error:s,breakdown:a}=e,r=401===s.status||403===s.status?{tone:"bad",label:`Blocked by indexer (HTTP ${s.status})`,hint:"The indexer refused the NZB download. Check that the API key is valid and the account is in good standing."}:429===s.status?{tone:"warn",label:"Rate-limited (HTTP 429)",hint:"The indexer is rate-limiting NZB downloads, usually because the account hit its daily API or grab limit. This normally clears on its own."}:{tone:"warn",label:s.status?`Grab failed (HTTP ${s.status})`:"Grab failed",hint:"The most recent NZB download from this indexer did not succeed. If this persists, check the indexer URL and its status page."};return(0,i.jsx)(P,{modal:!1,align:"start",className:"w-80",trigger:(0,i.jsx)("button",{type:"button","aria-label":`${t}: ${r.label}. Show details`,className:x("shrink-0 -my-1 p-1 rounded-full transition-opacity hover:opacity-70","bad"===r.tone?"text-red-400":"text-amber-500"),children:(0,i.jsx)(sm.wew,{className:"w-4 h-4"})}),children:(0,i.jsxs)("div",{className:"space-y-2.5",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("span",{className:x("w-2 h-2 rounded-full shrink-0","bad"===r.tone?"bg-red-400":"bg-amber-500")}),(0,i.jsx)("span",{className:"text-sm font-semibold",children:r.label})]}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:r.hint}),(0,i.jsxs)("div",{className:"rounded-[--radius] bg-[--subtle] p-2 space-y-1",children:[(0,i.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,i.jsx)("span",{className:"text-xs font-medium",children:"Last grab error"}),(0,i.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:cz(s.atMs)})]}),(0,i.jsx)("p",{className:"text-xs text-[--muted] break-words",children:s.message})]}),a&&(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["Failed in this window: ",a]})]})})}function cY(e){let{indexers:t,onReset:s}=e;return 0===t.length?(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No grabs recorded in this window yet."}):(0,i.jsx)("div",{className:"overflow-x-auto -mx-4 px-4 lg:mx-0 lg:px-0",children:(0,i.jsxs)("table",{className:"w-full text-sm min-w-[720px]",children:[(0,i.jsx)("thead",{className:"text-[--muted] text-xs uppercase",children:(0,i.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,i.jsx)("th",{className:"py-2 pr-3",children:"Indexer"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Share"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Grabs"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",title:"Grabs whose import produced a streamable entry (degraded included).",children:"Success"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Failed"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",title:"How long the indexer takes to
42serve the .nzb file itself.",children:"Avg grab"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",title:"How long the import/inspection of the release took after the grab.",children:"Avg import"}),(0,i.jsx)("th",{className:"py-2 pl-3 w-8","aria-label":"Actions"})]})}),(0,i.jsx)("tbody",{children:t.map(e=>(0,i.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,i.jsx)("td",{className:"py-2 pr-3",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("span",{className:"font-medium",children:e.indexer}),e.lastError&&Date.now()-e.lastError.atMs<864e5&&(0,i.jsx)(cG,{indexer:e.indexer,error:e.lastError,breakdown:e.failed>0?cW(e):void 0})]})}),(0,i.jsx)("td",{className:"py-2 px-3 text-right",children:(0,i.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,i.jsx)("div",{className:"w-16 h-1 rounded-full bg-[--subtle] overflow-hidden",children:(0,i.jsx)("div",{className:"h-full bg-brand",style:{width:`${100*e.grabShare}%`}})}),(0,i.jsx)("span",{className:"tabular-nums w-10 text-right",children:nN(e.grabShare)})]})}),(0,i.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:nT(e.grabs)}),(0,i.jsx)("td",{className:x("py-2 px-3 text-right tabular-nums",e.grabs>0&&1-e.successRate>.1&&"text-red-400"),title:e.degraded>0?`includes ${e.degraded} degraded import${1===e.degraded?"":"s"}`:void 0,children:nN(e.successRate)}),(0,i.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",title:e.failed>0?cW(e):void 0,children:nT(e.failed)}),(0,i.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:null==e.avgGrabMs?"â":nA(e.avgGrabMs)}),(0,i.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:null==e.avgImportMs?"â":nA(e.avgImportMs)}),(0,i.jsx)("td",{className:"py-2 pl-3 text-right",children:(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.sxT,{}),onClick:()=>s({target:"indexers",id:e.indexer,label:e.indexer}),"aria-label":"Reset stats for this indexer"}),children:"Reset this indexer's recorded stats"})})]},e.indexer))})]})})}function cJ(e){let{label:t,onClick:s}=e;return(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.sxT,{}),onClick:s,"aria-label":t}),children:t})}function cZ(e){let{data:t,onReset:s}=e,a=t.throughput.map(e=>{var s,a;let r,n;return{t:(s=e.bucketMs,a=t.window,r=new Date(s),n=e=>String(e).padStart(2,"0"),"24h"===a?`${n(r.getHours())}:00`:"7d"===a?`${n(r.getMonth()+1)}/${n(r.getDate())} ${n(r.getHours())}h`:`${n(r.getMonth()+1)}/${n(r.getDate())}`),bytes:e.bytes}}),r=t.providers.filter(e=>e.articles>0).slice(0,6).map(e=>({name:e.name||e.host,value:e.articles})),n=t.indexers.reduce((e,t)=>e+t.grabs,0),l=t.indexers.filter(e=>e.grabs>0).slice(0,6).map(e=>({name:e.indexer,value:e.grabs}));return(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3",children:[(0,i.jsx)(oU,{label:"Data downloaded",value:ny(t.totals.bytes)}),(0,i.jsx)(oU,{label:"Avg download speed",value:t.totals.avgBytesPerSec?nj(t.totals.avgBytesPerSec):"â",hint:`avg while streaming \xb7 ${t.window}`}),(0,i.jsx)(oU,{label:"Articles",value:nT(t.totals.articles)}),(0,i.jsx)(oU,{label:"Avg latency",value:null==t.totals.avgLatencyMs?"â":`${t.totals.avgLatencyMs}ms`,hint:t.totals.avgArticleMs?`${t.totals.avgArticleMs}ms per whole article`:""}),(0,i.jsx)(oU,{label:"Error rate",value:nN(t.totals.articles+t.totals.errors>0?t.totals.errors/(t.totals.articles+t.totals.errors):0),hint:t.totals.undecodable?`${nT(t.totals.undecodable)} unreadable`:""})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Data downloaded"}),0===a.length?(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No data for this window yet."}):(0,i.jsx)(o$,{data:a,xKey:"t",series:[{key:"bytes",label:"Downloaded",color:"var(--brand)"}],height:240,valueFormatter:e=>ny(Number(e)),yTickFormatter:e=>ny(Number(e))})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,i.jsx)("h3",{className:"text-sm font-semibold",children:"Provider performance"}),(0,i.jsx)(cJ,{label:"Reset all provider stats",onClick:()=>s({target:"providers",label:"All providers"})})]}),r.length>0?(0,i.jsxs)("div",{className:"grid lg:grid-cols-[1fr,240px] gap-6 items-center",children:[(0,i.jsx)(cH,{providers:t.providers,onReset:s}),(0,i.jsx)("div",{className:"mx-auto w-full max-w-[240px] aspect-square",children:(0,i.jsx)(oL,{data:r,centerLabel:"articles",centerValue:nT(t.totals.articles),height:240})})]}):(0,i.jsx)(cH,{providers:t.providers,onReset:s})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,i.jsx)("h3",{className:"text-sm font-semibold",children:"Indexer performance"}),(0,i.jsx)(cJ,{label:"Reset all indexer stats",onClick:()=>s({target:"indexers",label:"All indexers"})})]}),l.length>0?(0,i.jsxs)("div",{className:"grid lg:grid-cols-[1fr,240px] gap-6 items-center",children:[(0,i.jsx)(cY,{indexers:t.indexers,onReset:s}),(0,i.jsx)("div",{className:"mx-auto w-full max-w-[240px] aspect-square",children:(0,i.jsx)(oL,{data:l,centerLabel:"grabs",centerValue:nT(n),height:240})})]}):(0,i.jsx)(cY,{indexers:t.indexers,onReset:s})]})]})}function cQ(e){let{intent:t,children:s}=e;return(0,i.jsx)("span",{className:x("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",{success:"bg-emerald-500/15 text-emerald-500",alert:"bg-red-400/15 text-red-400",warning:"bg-orange-500/15 text-orange-400"}[t]),children:s})}function cX(e){return{id:e.id,name:e.name??"",host:e.host,port:e.port,tls:e.tls,tlsSkipVerify:e.tlsSkipVerify??!1,username:e.username??"",password:"",hasPassword:e.hasPassword,maxConnections:e.maxConnections,pipelineDepth:e.pipelineDepth??1,isBackup:e.isBackup??
42!1,enabled:!1!==e.enabled,priority:e.priority}}function c0(e){let t=e.map((e,t)=>({d:e,i:t})).sort((e,t)=>{let s=!!e.d.isBackup-!!t.d.isBackup;return 0!==s?s:e.d.priority!==t.d.priority?e.d.priority-t.d.priority:e.i-t.i}).map(e=>{let{d:t}=e;return t}),s=0,a=null,r=null;return t.map(e=>((e.priority!==a||e.isBackup!==r)&&(s++,a=e.priority,r=e.isBackup),{...e,priority:s}))}function c1(e){let t=e.password?e.password:e.hasPassword?"__stored__":void 0;return{id:e.id,name:e.name||void 0,host:e.host.trim(),port:e.port,tls:e.tls,tlsSkipVerify:e.tlsSkipVerify||void 0,username:e.username||void 0,password:t,maxConnections:e.maxConnections,pipelineDepth:e.pipelineDepth>1?e.pipelineDepth:void 0,priority:e.priority,isBackup:e.isBackup||void 0,enabled:e.enabled}}function c2(e){let t,{providers:s}=e,[a,r]=u.useState(()=>c0(s.map(cX))),[n,l]=u.useState({}),[o,d]=u.useState({}),c=(t=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea("PUT /dashboard/usenet/providers",{body:{providers:e}}),onSuccess:()=>{t.invalidateQueries({queryKey:[...i3,"providers"]}),t.invalidateQueries({queryKey:[...i3,"stats"]})}})),h=(0,e5.n)({mutationFn:e=>ea("POST /dashboard/usenet/providers/test",{body:e})}),p=(0,e5.n)({mutationFn:e=>ea(`POST /dashboard/usenet/providers/${encodeURIComponent(e)}/speedtest`)}),x=u.useMemo(()=>new Set(s.map(e=>e.id)),[s]),g=u.useMemo(()=>JSON.stringify(s),[s]),f=u.useRef(g);u.useEffect(()=>{g!==f.current&&(f.current=g,r(c0(s.map(cX))),l({}),d({}))},[g,s]);let b=async e=>{l(t=>({...t,[e.id]:"pending"}));try{let t=await h.mutateAsync(c1(e));l(s=>({...s,[e.id]:t})),t.ok?m.oR.success(`${e.name||e.host}: connected in ${t.latencyMs}ms`):m.oR.error(`${e.name||e.host}: ${t.error??"failed"}`)}catch(s){let t={ok:!1,error:(null==s?void 0:s.message)??"failed"};l(s=>({...s,[e.id]:t})),m.oR.error(`${e.name||e.host}: ${t.error}`)}},y=async e=>{d(t=>({...t,[e.id]:"pending"}));try{let t=await p.mutateAsync(e.id);d(s=>({...s,[e.id]:t})),t.ok?m.oR.success(`${e.name||e.host}: ${nj(t.bytesPerSec??0)}`):m.oR.error(`${e.name||e.host}: ${t.error??"speed test failed"}`)}catch(s){let t={ok:!1,error:(null==s?void 0:s.message)??"failed"};d(s=>({...s,[e.id]:t})),m.oR.error(`${e.name||e.host}: ${t.error}`)}},j=async()=>{for(let e of a)if(!e.host.trim())return void m.oR.error("Every provider needs a host.");try{await c.mutateAsync(a.map(c1)),m.oR.success("Providers saved.")}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to save providers")}},w=function(e){let t=[];for(let s of e){let e=t[t.length-1];e&&e[0].priority===s.priority?e.push(s):t.push([s])}return t}(a);return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"text-sm font-semibold",children:"NNTP providers"}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Lower priority numbers are tried first. Give two providers the same priority to put them in one load-balanced group (shown bracketed) so they split load by free capacity instead of one sitting idle as failover â the up arrow groups a provider with the one above, the down arrow splits it back out. Mark metered block accounts as backups (the toggle applies to the whole group) so theyâre only used when a primary misses an article."})]}),(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",leftIcon:(0,i.jsx)(sm.Ca6,{}),onClick:()=>r(e=>{var t,s;return c0([...e,{...{id:(null==(s=globalThis.crypto)||null==(t=s.randomUUID)?void 0:t.call(s))??`p_${Math.random().toString(36).slice(2)}`,name:"",host:"",port:563,tls:!0,tlsSkipVerify:!1,username:"",password:"",hasPassword:!1,maxConnections:10,pipelineDepth:1,isBackup:!1,enabled:!0,priority:1},priority:(e.length?Math.max(...e.map(e=>e.priority)):0)+1}])}),children:"Add provider"})]}),0===a.length&&(0,i.jsx)(J,{className:"p-6 text-center text-sm text-[--muted]",children:"No providers configured yet. Add your first NNTP account to start streaming."}),(0,i.jsx)("div",{className:"space-y-3",children:w.map(e=>(0,i.jsx)("div",{className:"space-y-px",children:e.map((t,s)=>(0,i.jsx)(c6,{draft:t,grouped:e.length>1,isGroupHead:0===s,isGroupTail:s===e.length-1,canGroupUp:t.priority>1,canUngroup:e.length>1,testResult:n[t.id],speedResult:o[t.id],canSpeedTest:x.has(t.id),onChange:e=>{let s;return s=t.id,r(t=>t.map(t=>
42t.id===s?{...t,...e}:t))},onSetPriority:e=>{let s;return s=t.id,r(t=>{let a=Math.max(1,Math.round(e)||1);return c0(t.map(e=>{var r;if(e.id!==s)return e;let n=null==(r=t.find(e=>e.id!==s&&e.priority===a))?void 0:r.isBackup;return{...e,priority:a,isBackup:n??e.isBackup}}))})},onGroupUp:()=>{let e;return e=t.id,r(t=>{var s;let a=t.find(t=>t.id===e);if(!a||a.priority<=1)return t;let r=a.priority-1,n=(null==(s=t.find(e=>e.priority===r))?void 0:s.isBackup)??a.isBackup;return c0(t.map(t=>t.id===e?{...t,priority:r,isBackup:n}:t))})},onUngroup:()=>{let e;return e=t.id,r(t=>{let s=t.find(t=>t.id===e);return!s||t.filter(e=>e.priority===s.priority).length<=1?t:c0(t.map(t=>t.id===e?{...t,priority:t.priority+.5}:t))})},onSetBackup:e=>{let s;return s=t.id,r(t=>{let a=t.find(e=>e.id===s);return a?c0(t.map(t=>t.priority===a.priority?{...t,isBackup:e}:t)):t})},onRemove:()=>{let e;return e=t.id,r(t=>c0(t.filter(t=>t.id!==e)))},onTest:()=>b(t),onSpeedTest:()=>y(t)},t.id))},e[0].id))}),(0,i.jsx)("div",{className:"flex justify-end",children:(0,i.jsx)(v,{intent:"primary",loading:c.isPending,onClick:j,children:"Save providers"})})]})}function c3(e){let{result:t}=e;return"pending"===t?(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"testingâ¦"}):t?t.ok?(0,i.jsxs)(cQ,{intent:"success",children:[(0,i.jsx)(sm.qGT,{})," ",t.latencyMs,"ms"]}):(0,i.jsxs)(cQ,{intent:"alert",children:[(0,i.jsx)(sm.wew,{})," ",t.code??"failed"]}):null}function c5(e){let{result:t}=e;if("pending"===t)return(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"speed testingâ¦"});if(!t)return null;if(!t.ok)return(0,i.jsxs)(cQ,{intent:"warning",children:[(0,i.jsx)(sm.wew,{})," ",t.code??"failed"]});let s=null!=t.connections?`${t.connections} conn${t.pipelineDepth&&t.pipelineDepth>1?` \xd7 depth ${t.pipelineDepth}`:""}`:void 0;return(0,i.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,i.jsxs)(cQ,{intent:"success",children:[(0,i.jsx)(sm.I2B,{})," ",nj(t.bytesPerSec??0)]}),s?(0,i.jsx)("span",{className:"text-[10px] text-[--muted]",title:`Fanned out across ${t.connections} connections, pipeline depth ${t.pipelineDepth??1}`,children:s}):null]})}function c4(e){let{value:t,onCommit:s}=e,a=u.useRef(t);return u.useEffect(()=>{a.current=t},[t]),(0,i.jsx)("div",{onBlur:()=>a.current!==t&&s(a.current),children:(0,i.jsx)(lm,{defaultValue:t,min:1,hideControls:!0,size:"sm",className:"w-16 text-center tabular-nums","aria-label":"Priority",onValueChange:e=>{a.current=Number.isFinite(e)&&e>=1?Math.round(e):1}},t)})}function c6(e){let{draft:t,grouped:s,isGroupHead:a,isGroupTail:r,canGroupUp:n,canUngroup:l,testResult:o,speedResult:d,canSpeedTest:c,onChange:u,onSetPriority:m,onGroupUp:h,onUngroup:p,onSetBackup:g,onRemove:f,onTest:b,onSpeedTest:v}=e,y="pending"===o,j="pending"===d,N=sd({title:"Delete provider?",description:(0,i.jsxs)(i.Fragment,{children:["Are you sure you want to remove"," ",(0,i.jsx)("strong",{children:t.name||t.host||"this provider"}),"?"]}),actionText:"Delete",actionIntent:"alert-subtle",onConfirm:f});return(0,i.jsxs)(J,{className:x("p-4 transition-opacity duration-300",!t.enabled&&"opacity-60",s&&"border-l-2 border-l-[--brand]",s&&!a&&"rounded-t-none",s&&!r&&"rounded-b-none"),children:[(0,i.jsxs)("div",{className:"flex items-start gap-3",children:[(0,i.jsxs)("div",{className:"flex flex-col items-center gap-1 pt-1",children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"xs",intent:"gray-subtle",icon:(0,i.jsx)(sm.mlL,{}),disabled:!n,onClick:h,"aria-label":"Group with provider above"}),children:"Group with the provider above"}),(0,i.jsx)(c4,{value:t.priority,onCommit:m}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"xs",intent:"gray-subtle",icon:(0,i.jsx)(sm.nwe,{}),disabled:!l,onClick:p,"aria-label":"Split out of group"}),children:"Split out into its own priority"})]}),(0,i.jsxs)("div",{className:"flex-1 space-y-3",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2 flex-1 min-w-[180px]",children:[(0,i.jsx)("span",{className:"font-medium text-sm",children:t.name||t.host||"New provider"}),t.isBackup&&(0,i.jsx)(cQ,{intent:"warning",children:"backup"}),s&&(0,i.jsx)(cQ,{intent:"success",children:"load-balanced"}),(0,i.jsx)(c3,{result:o}),(0,i.jsx)(c5,{result:d})]}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.UWw,{}),onClick:b,loading:y,disabled:!t.host||y,"aria-label":"Test provider"}),children:"Test connection"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.I2B,{}),onClick:v,loading:j,disabled:!c||j,"aria-label":"Speed test provider"}),children:c?"Speed test (downloads from your library)":"Save the provider first to speed test"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:t.enabled?"success-subtle":"gray-subtle",icon:t.enabled?(0,i.jsx)(W.lXh,{}):(0,i.jsx)(W.czG,{}),className:"transition-colors duration-300",onClick:()=>u({enabled:!t.enabled}),"aria-label":t.enabled?"Disable provider":"Enable provider"}),children:t.enabled?"Enabled â click to disable":"Disabled â click to enable"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),onClick:N.open,"aria-label":"Remove provider"}),children:"Remove provider"})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[(0,i.jsx)(L,{label:"Name",children:(0,i.jsx)(K,{value:t.name,placeholder:"Friendly name",onValueChange:e=>u({name:e})})}),(0,i.jsx)(L,{label:"Host",className:"lg:col-span-2",children:(0,i.jsx)(K,{value:t.host,placeholder:"news.example.com",onValueChange:e=>u({host:e})})}),(0,i.jsx)(L,{label:"Port",children:(0,i.jsx)(lm,{value:t.port,min:1,max:65535,hideControls:!0,onValueChange:e=>u({port:e||0})})}),(0,i.jsx)(L,{label:"Max connections",children:(0,i.jsx)(lm,{value:t.maxConnections,min:1,onValueChange:e=>u({maxConnections:e||1})})}),(0,i.jsx)(L,{label:"Pipeline depth",moreHelp:"How many requests can be waiting on each connection at once. 1 (the default) sends one request at a time. Higher values (e.g. 4â8) can reach full speed with far fewer connections â especially useful when the provider's server is far away â and automatically fall back to 1 if the provider doesn't support it.",children:(0,i.jsx)(lm,{value:t.pipelineDepth,min:1,max:20,onValueChange:e=>u({pipelineDepth:Math.min(20,Math.max(1,e||1))})})}),(0,i.jsx)(L,{label:"Username",children:(0,i.jsx)(K,{value:t.username,autoComplete:"off",onValueChange:e=>u({username:e})})}),(0,i.jsx)(L,{label:"Password",className:"lg:col-span-2",children:(0,i.jsx)(G,{value:t.password,autoComplete:"new-password",placeholder:t.hasPassword?"â¢â¢â¢â¢â¢â¢â¢â¢ (unchanged)":"",onValueChange:e=>u({password:e})})})]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-3 rounded-md border border-[--border]/60 px-3 py-2.5",children:[(0,i.jsx)(ni,{value:t.tls,onValueChange:e=>u({tls:e}),label:"SSL/TLS",side:"right"}),(0,i.jsx)(ni,{value:t.isBackup,onValueChange:g,label:"Backup",moreHelp:s?"Applies to the whole group â backup providers are only used when a download is missing pieces on your main providers.":"Only used when a download is missing pieces on your main providers â ideal for metered block accounts.",side:"right"}),(0,i.jsx)(ni,{value:t.tlsSkipVerify,onValueChange:e=>u({tlsSkipVerify:e}),label:"Skip TLS verify",side:"right"})]})]})]}),(0,i.jsx)(sc,{...N})]})}let c9=["dashboard","community"];function c8(e){let t=new URLSearchParams;e.kind&&t.set("kind",e.kind),e.status&&t.set("status",e.status),e.search&&t.set("search",e.search),e.pending&&t.set("pending","1"),void 0!==e.limit&&t.set("limit",String(e.limit)),void 0!==e.offset&&t.set("offset",String(e.offset));let s=t.toString();return(0,ty.I)({queryKey:[...c9,"items",s],queryFn:()=>ea(`/dashboard/community/items${s?`?${s}`:""}`),placeholderData:i1.rX,staleTime:1e4})}function c7(e){let t=(0,e3.jE)();return(0,e5.n)({mutationFn:e,onSuccess:()=>{t.invalidateQueries({queryKey:c9}),t.invalidateQueries({queryKey:["community"]})}})}let ue=e=>`/dashboard/community/items/${encodeURIComponent(e)}`;function ut(){return c7(e=>ea(`DELETE ${ue(e)}`))}function us(e){let{kind:t}=e;return(0,i.jsx)(dX,{className:"template"===t?"border-purple-500/30 bg-purple-500/10 text-purple-300":"border-sky-500/30 bg-sky-500/10 text-sky-300",children:t})}function ua(e){let{tags:t}=e;return 0===t.length?null:(0,i.jsx)("div",{className:"flex flex-wrap gap-1",children:t.map(e=>(0,i.jsx)(dX,{children:e},e))})}function ur(e){let{kind:t,payload:s}=e,[a,r]=(0,u.useState)("formatter"===t);if("formatter"===t){let e=s??{};return(0,i.jsxs)("div",{className:"space-y-2 text-xs",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:"Name"}),(0,i.jsx)("pre",{className:"whitespace-pre-wrap break-words rounded border border-[--border] bg-[--subtle]/40 p-2",children:e.name})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:"Description"}),(0,i.jsx)("pre",{className:"whitespace-pre-wrap break-words rounded border border-[--border] bg-[--subtle]/40 p-2",children:e.description})]})]})}return(0,i.jsxs)("div",{className:"text-xs",children:[(0,i.jsxs)("button",{type:"button",className:"text-[--brand] hover:underline",onClick:()=>r(e=>!e),children:[a?"Hide":"Show"," template JSON"]}),a&&(0,i.jsx)("pre",{className:"mt-2 max-h-96 overflow-auto whitespace-pre rounded border border-[--border] bg-[--subtle]/40 p-2",children:JSON.stringify(s,null,2)})]})}function un(e){var t,s;let{summary:a}=e,r=a.presets.filter(e=>e.urlOptions.some(e=>e.differsFromDefault));return(0,i.jsxs)("div",{className:"space-y-3 rounded border border-[--border] bg-[--subtle]/30 p-3 text-xs",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:"Addons"}),a.presetsInspected?0===a.presets.length?(0,i.jsx)("p",{className:"text-[--muted]",children:"No addons."}):(0,i.jsx)("ul",{className:"space-y-1",children:a.presets.map((e,t)=>(0,i.jsxs)("li",{className:"flex flex-wrap gap-x-2",children:[(0,i.jsx)("span",{className:"font-medium",children:e.name??e.type}),(0,i.jsxs)("span",{className:"text-[--muted]",children:["(",e.type,")"]}),e.urlOptions.map(e=>(0,i.jsxs)("span",{className:e.differsFromDefault?"font-mono text-red-200":"font-mono text-[--muted]",children:[e.id,"=",e.value]},e.id))]},`${e.type}-${t}`))}):(0,i.jsx)("p",{className:"text-yellow-300",children:"The addon list is a template directive, so it could not be inspected. Read the JSON below."}),r.length>0&&(0,i.jsxs)("p",{className:"mt-1 text-red-200",children:[r.length," addon",1===r.length?"":"s"," point at a non-default host. Those hosts may receive the service credentials of anyone who applies this template."]})]}),a.changelogUrl&&(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:"Changelog URL"}),(0,i.jsx)("p",{className:"break-all font-mono",children:a.changelogUrl}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Fetched by usersâ browsers when they open the changelog; the author can change its contents at any time."})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:["Regex patterns (",a.regexPatterns.length,")"]}),0===a.regexPatterns.length?(0,i.jsx)("p",{className:"text-[--muted]",children:"None."}):(0,i.jsx)("ul",{className:"max-h-40 space-y-0.5 overflow-auto font-mono",children:a.regexPatterns.map((e,t)=>(0,i.jsx)("li",{className:"break-all",children:e},t))})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:["Synced URLs (",a.syncedUrls.length,")"]}),0===a.syncedUrls.length?(0,i.jsx)("p",{className:"text-[--muted]",children:"None."}):(0,i.jsx)("ul",{className:"max-h-40 space-y-0.5 overflow-auto font-mono",children:a.syncedUrls.map((e,t)=>(0,i.jsx)("li",{className:"break-all",children:e},t))})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:["Variant scripts (",(null==(t=a.variantScripts)?void 0:t.length)??0,")"]}),(null==(s=a.variantScripts)?void 0:s.length)?(0,i.jsxs)("div",{className:"max-h-60 space-y-2 overflow-auto",children:[a.variantScripts.map(e=>(0,i.jsxs)("div",{children:[(0,i.jsxs)("p",{className:"font-medium",children:[e.name??e.id," ",(0,i.jsxs)("span",{className:"text-[--muted]",children:["(",e.id,")"]})]}),(0,i.jsx)("pre",{className:"whitespace-pre-wrap break-all font-mono text-[--muted]",children:e.script})]},e.id)),(0,i.jsx)("p",{className:"text-[--muted]",children:"Stored as written."})]}):(0,i.jsx)("p",{className:"text-[--muted]",children:"None."})]})]})}function ul(e){let{open:t,onOpenChange:s,title:a,actionText:r,pen
42ding:n,onConfirm:l}=e,[o,d]=(0,u.useState)("");return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:a,children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(ly,{value:o,onValueChange:d,placeholder:"The uploader sees this reason.",maxLength:500}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",size:"sm",onClick:()=>s(!1),children:"Cancel"}),(0,i.jsx)(v,{intent:"alert",size:"sm",disabled:!o.trim(),loading:n,onClick:()=>{l(o.trim()),d("")},children:r})]})]})})}function ui(e){let{item:t}=e,s=c7(e=>{let{id:t,trusted:s}=e;return ea(`POST ${ue(t)}/approve`,{body:{trusted:s}})}),a=c7(e=>{let{id:t,reason:s}=e;return ea(`POST ${ue(t)}/reject`,{body:{reason:s}})}),r=c7(e=>ea(`POST ${ue(e)}/draft/approve`)),n=c7(e=>{let{id:t,reason:s}=e;return ea(`POST ${ue(t)}/draft/reject`,{body:{reason:s}})}),l=ut(),o=c7(e=>ea("POST /dashboard/community/blocks",{body:e})),[d,c]=(0,u.useState)(!1),[h,p]=(0,u.useState)(null),x="approved"===t.status&&!!t.draft,g=x&&t.draft?t.draft:t,f=(e,t)=>e.then(()=>m.oR.success(t)).catch(e=>m.oR.error((null==e?void 0:e.message)??"Failed")),b=sd({title:"Delete submission",description:`Delete "${t.name}" entirely? This cannot be undone.`,actionText:"Delete",onConfirm:()=>f(l.mutateAsync(t.id),"Deleted")}),y=sd({title:"Block uploader",description:"Blocks the configuration that uploaded this from sharing or liking anything else. The item itself stays as it is.",actionText:"Block",onConfirm:()=>f(o.mutateAsync({itemId:t.id,kind:"owner",reason:`blocked via ${t.name}`}),"Uploader blocked")}),j=sd({title:"Block network address",description:"Blocks the address this was uploaded from. Shared addresses (mobile carriers, VPNs, CGNAT) will block other people too.",actionText:"Block address",onConfirm:()=>f(o.mutateAsync({itemId:t.id,kind:"ip",reason:`blocked via ${t.name}`}),"Address blocked")});return(0,i.jsxs)(J,{className:"space-y-4 p-4",children:[(0,i.jsx)(sc,{...b}),(0,i.jsx)(sc,{...y}),(0,i.jsx)(sc,{...j}),(0,i.jsx)(ul,{open:null!==h,onOpenChange:e=>!e&&p(null),title:"draft"===h?"Reject update":"Reject submission",actionText:"Reject",pending:a.isPending||n.isPending,onConfirm:e=>{f("draft"===h?n.mutateAsync({id:t.id,reason:e}):a.mutateAsync({id:t.id,reason:e}),"Rejected").finally(()=>p(null))}}),(0,i.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:(0,i.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)(us,{kind:t.kind}),(0,i.jsx)("h3",{className:"text-base font-semibold",children:g.name}),(0,i.jsxs)(dX,{children:["v",g.version]}),x&&(0,i.jsxs)(dX,{className:"border-yellow-400/30 bg-yellow-500/10 text-yellow-300",children:["update to v",t.version]}),"rejected"===t.status&&(0,i.jsx)(dX,{className:"border-red-400/30 bg-red-500/10 text-red-200",children:"previously rejected"})]}),(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["by ",g.author," \xb7 submitted"," ",d6(x&&t.draft?t.draft.submittedAt:t.createdAt),t.likes>0&&` \xb7 ${t.likes} likes`]}),g.description&&(0,i.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:g.description}),(0,i.jsx)(ua,{tags:g.tags??[]})]})}),x&&t.draft&&(0,i.jsx)(uo,{live:t,draft:t.draft}),"template"===t.kind&&g.reviewSummary?(0,i.jsx)(un,{summary:g.reviewSummary}):null,(0,i.jsx)(ur,{kind:t.kind,payload:g.payload}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-[--border]/50 pt-3",children:["template"===t.kind&&!x&&(0,i.jsxs)("label",{className:"mr-2 flex items-center gap-2 text-xs text-[--muted]",children:[(0,i.jsx)(lt,{value:d,onValueChange:e=>c(!!e)}),"Approve as trusted (whitelists its regex patterns and synced URLs; takes a restart to undo)"]}),(0,i.jsx)(v,{size:"sm",intent:"success",leftIcon:(0,i.jsx)(sm.mmP,{}),loading:s.isPending||r.isPending,onClick:()=>f(x?r.mutateAsync(t.id):s.mutateAsync({id:t.id,trusted:"template"===t.kind?d:void 0}),x?"Update published":"Published"),children:x?"Approve update":"Approve"}),(0,i.jsx)(v,{size:"sm",intent:"alert-subtle",leftIcon:(0,i.jsx)(sm.Gsv,{}),onClick:()=>p(x?"draft":"item"),children:x?"Reject update":"Reject"}),(0,i.jsxs)("div",{className:"ml-auto flex flex-wrap gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"gray-outline",leftIcon:(0,i.jsx)(sm.PLI,{}),onClick:y.open,children:"Block uploader"}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",leftIcon:(0,i.jsx)(sm.PLI,{}),onClick:j.open,children:"Block address"}),(0,i.jsx)(v,{size:"sm",intent:"alert-subtle",leftIcon:(0,i.jsx)(sm.id1,{}),onClick:b.open,children:"Delete"})]})]})]})}function uo(e){let{live:t,draft:s}=e,a=[],r=(e,t,s)=>{t!==s&&a.push([e,t,s])};if(r("Name",t.name,s.name),r("Description",t.description,s.description),r("Author",t.author,s.author),r("Tags",(t.tags??[]).join(", "),(s.tags??[]).join(", ")),"formatter"===t.kind){let e=t.payload??{},a=s.payload??{};r("Name template",e.name??"",a.name??""),r("Description template",e.de
42scription??"",a.description??"")}else JSON.stringify(t.payload)!==JSON.stringify(s.payload)&&a.push(["Config","published version","changed, see JSON below"]);return 0===a.length?(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Only the version changed; the payload and metadata are identical."}):(0,i.jsx)("div",{className:"overflow-x-auto rounded border border-[--border]/60",children:(0,i.jsxs)("table",{className:"w-full text-xs",children:[(0,i.jsx)("thead",{className:"bg-[--subtle]/40 uppercase text-[--muted]",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"p-2",children:"Field"}),(0,i.jsx)("th",{className:"p-2",children:"Published"}),(0,i.jsx)("th",{className:"p-2",children:"Proposed"})]})}),(0,i.jsx)("tbody",{children:a.map(e=>{let[t,s,a]=e;return(0,i.jsxs)("tr",{className:"border-t border-[--border]/40",children:[(0,i.jsx)("td",{className:"p-2 font-medium",children:t}),(0,i.jsx)("td",{className:"max-w-[240px] whitespace-pre-wrap break-words p-2 text-[--muted]",children:s||"â"}),(0,i.jsx)("td",{className:"max-w-[240px] whitespace-pre-wrap break-words p-2",children:a||"â"})]},t)})})]})})}function ud(){var e;let t=(null==(e=(0,ty.I)({queryKey:[...c9,"remote"],queryFn:()=>ea("/dashboard/community/remote"),staleTime:1e4}).data)?void 0:e.sources)??[];return(0,i.jsxs)(J,{className:"space-y-3 p-4",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"text-sm font-semibold",children:"Remote sources"}),(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["Approved items from other instances, shown read-only in the browsers."," ",(0,i.jsx)("a",{href:"/dashboard/settings?tab=community",className:"text-[--brand] hover:underline",children:"Edit the list in settings"}),"; run"," ",(0,i.jsx)("a",{href:"/dashboard/tasks",className:"text-[--brand] hover:underline",children:"Community remote refresh"})," ","from Tasks to fetch now."]})]}),0===t.length?(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"No remote sources configured."}):(0,i.jsxs)("table",{className:"w-full text-xs",children:[(0,i.jsx)("thead",{className:"text-[--muted]",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"py-1 pr-3",children:"Source"}),(0,i.jsx)("th",{className:"py-1 pr-3",children:"Items"}),(0,i.jsx)("th",{className:"py-1 pr-3",children:"Last fetched"}),(0,i.jsx)("th",{className:"py-1",children:"Status"})]})}),(0,i.jsx)("tbody",{children:t.map(e=>(0,i.jsxs)("tr",{className:"border-t border-[--border]/40",children:[(0,i.jsx)("td",{className:"max-w-[360px] truncate py-1 pr-3 font-mono",children:e.url}),(0,i.jsx)("td",{className:"py-1 pr-3",children:e.count}),(0,i.jsx)("td",{className:"py-1 pr-3 text-[--muted]",children:e.lastFetchedAt?d6(e.lastFetchedAt):"never"}),(0,i.jsx)("td",{className:e.error?"py-1 text-red-200":"py-1 text-green-300",children:e.error??"ok"})]},e.url))})]})]})}function uc(e){let{item:t}=e,s=ut(),a=c7(e=>ea(`POST ${ue(e)}/reset-likes`)),r=c7(e=>{let{id:t,trusted:s}=e;return ea(`POST ${ue(t)}/trusted`,{body:{trusted:s}})}),n=(e,t)=>e.then(()=>m.oR.success(t)).catch(e=>m.oR.error((null==e?void 0:e.message)??"Failed")),l=sd({title:"Delete item",description:`Remove "${t.name}" from the community? People who installed it keep their copy.`,actionText:"Delete",onConfirm:()=>n(s.mutateAsync(t.id),"Deleted")}),o=sd({title:"Reset likes",description:`Clear all ${t.likes} likes on "${t.name}"?`,actionText:"Reset",onConfirm:()=>n(a.mutateAsync(t.id),"Likes reset")});return(0,i.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,i.jsx)(sc,{...l}),(0,i.jsx)(sc,{...o}),(0,i.jsxs)("td",{className:"p-3",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(us,{kind:t.kind}),(0,i.jsx)("span",{className:"font-medium",children:t.name}),(0,i.jsxs)(dX,{children:["v",t.version]}),t.draft&&(0,i.jsx)(dX,{className:"border-yellow-400/30 bg-yellow-500/10 text-yellow-300",children:"update pending"})]}),t.description&&(0,i.jsx)("p",{className:"mt-1 max-w-[420px] truncate text-xs text-[--muted]",children:t.description})]}),(0,i.jsx)("td",{className:"p-3 text-[--muted]",children:t.author}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(ua,{tags:t.tags??[]})}),(0,i.jsx)("td",{className:"p-3",children:t.likes}),(0,i.jsx)("td",{className:"p-3",children:"template"===t.kind?(0,i.jsx)(t5,{trigger:(0,i.jsx)("span",{children:(0,i.jsx)(ni,{value:t.trusted,onValueChange:e=>n(r.mutateAsync({id:t.id,trusted:!!e}),e?"Marked trusted":"Trust removed (takes effect on restart)")})}),children:"Trusted templates whitelist their regex patterns and synced URLs for every user. Removing trust takes effect on restart."}):(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"â"})}),(0,i.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:d6(t.updatedAt)}),(0,i.jsx)("td",{className:"p-3 text-right",children:(0,i.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.zOm,{}),"aria-label":"Reset likes",disabled:0===t.likes,onClick:o.open}),children:"Reset likes"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Delete",onClick:l.open}),children:"Delete"})]})})]})}var uu=s(43300);function um(e){let{to:t,icon:s,title:a,aside:r,className:n,children:l}=e,o=(0,i.jsxs)(J,{className:x("flex h-full min-w-0 flex-col gap-3 p-4",t&&"transition-colors group-hover:border-[--muted]/40 group-hover:bg-[--subtle]/50",n),children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(s,{className:x("shrink-0 text-[--muted]",t&&"transition-colors group-hover:text-[--foreground]")}),(0,i.jsx)("h3",{className:"truncate text-sm font-semibold",children:a}),(0,i.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1.5 text-xs tabular-nums text-[--muted]",children:[r,t&&(0,i.jsx)(sm.XWt,{className:"text-base transition-transform group-hover:translate-x-0.5"})]})]}),l]});return t?(0,i.jsx)(uu.N_,{to:t,className:"group block min-w-0 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[--muted]",children:o}):o}function uh(e){let{label:t,value:s,hint:a,ratio:r}=e;return(0,i.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,i.jsx)("div",{className:"text-xs uppercase tracking-wide text-[--muted]",children:t}),(0,i.jsx)("div",{className:x("truncate text-lg font-semibold tabular-nums",null!=r&&r>=.95&&"text-red-400",null!=r&&r>
42=.85&&r<.95&&"text-amber-500"),children:s}),a&&(0,i.jsx)("div",{className:"truncate text-xs text-[--muted]",children:a})]})}function up(e){let{children:t}=e;return(0,i.jsx)("p",{className:"text-xs italic text-[--muted]",children:t})}function ux(e){let{stream:t,frameMs:s}=e,a="streaming"===t.activity,r=d5(t);return(0,i.jsxs)("li",{className:"space-y-1",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(dZ,{transport:t.transport}),(0,i.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm",title:d3(t),children:d3(t)}),(0,i.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-[--muted]",children:a?(0,i.jsx)(dD,{value:t.bytesPerSec,format:nj,durationSec:s/1e3}):(0,i.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,i.jsx)(sm._5G,{}),"paused"===t.activity?"paused":"idle"]})})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("div",{className:"h-1 min-w-0 flex-1 overflow-hidden rounded-full bg-[--subtle]",children:(0,i.jsx)("div",{className:"h-full bg-brand transition-[width] ease-linear motion-reduce:transition-none",style:{width:`${100*r}%`,transitionDuration:`${s}ms`}})}),(0,i.jsx)(dX,{children:d4(t.username)})]})]})}function ug(){var e,t;let s=dq(),a=dF(s.data),r=null==(e=s.data)?void 0:e.summary,n=null==(t=s.data)?void 0:t.streams,l=u.useMemo(()=>[...n??[]].sort((e,t)=>t.bytesPerSec-e.bytesPerSec).slice(0,3),[n]),o=((null==r?void 0:r.paused)??0)+((null==r?void 0:r.idle)??0),d=((null==n?void 0:n.length)??0)-l.length;return(0,i.jsxs)(um,{to:"/dashboard/streams/active",icon:sm.U2S,title:"Active streams",aside:r&&(0,i.jsx)(dD,{value:r.totalBytesPerSec,format:nj,durationSec:a/1e3}),children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[(0,i.jsx)("span",{className:x("text-2xl font-semibold tabular-nums",(null==r?void 0:r.streaming)?void 0:"text-[--muted]"),children:(null==r?void 0:r.streaming)??"â"}),(0,i.jsx)("span",{className:"text-sm text-[--muted]",children:"streaming"}),o>0&&(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:["\xb7 ",o," paused"]}),(null==r?void 0:r.connectionLimit)?(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:["\xb7 ",r.connectionLimit," allowed at once"]}):null]}),s.isError?(0,i.jsx)(up,{children:"Failed to load active streams."}):0===l.length?(0,i.jsx)(up,{children:"Nothing streaming right now."}):(0,i.jsxs)("ul",{className:"space-y-2",children:[l.map(e=>(0,i.jsx)(ux,{stream:e,frameMs:a},e.id)),d>0&&(0,i.jsxs)("li",{className:"text-xs text-[--muted]",children:["+",d," more ",1===d?"stream":"streams"]})]})]})}function uf(){let e=dB("30d"),t=e.data,s=(null==t?void 0:t.periodMode)==="monthly";return(0,i.jsxs)(um,{to:"/dashboard/streams/bandwidth",icon:sm.yWU,title:s?"Bandwidth this month":"Bandwidth",aside:t&&(s?`since ${new Date(t.periodStart).toLocaleDateString()}`:"last 30 days"),children:[(0,i.jsxs)("div",{className:"space-y-0.5",children:[(0,i.jsx)("div",{className:"text-2xl font-semibold tabular-nums",children:t?ny(t.periodTotal):"â"}),t&&t.globalLimit>0&&(0,i.jsxs)("div",{className:"text-xs text-[--muted]",children:["of ",ny(t.globalLimit)," allowed this period"]}),t&&t.total>0&&(0,i.jsxs)("div",{className:"text-xs text-[--muted]",children:[nN((t.byTransport.usenet??0)/t.total)," usenet \xb7"," ",nN((t.byTransport.proxy??0)/t.total)," proxy"]})]}),e.isError&&(0,i.jsx)(up,{children:"Failed to load bandwidth."})]})}function ub(){return(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Sections"}),(0,i.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4",children:sb.filter(e=>"/dashboard"!==e.href).map(e=>{let t=e.icon,s=sv[e.href];return(0,i.jsxs)(J,{className:"group relative p-4 transition-colors hover:border-[--muted]/40 hover:bg-[--subtle]/50",children:[(0,i.jsxs)(uu.N_,{to:e.href,className:"flex items-center gap-2 font-medium before:absolute before:inset-0 before:rounded-xl before:content-[''] focus-visible:outline-none",children:[(0,i.jsx)(t,{className:"text-[--muted] transition-colors group-hover:text-[--foreground]"}),e.label]}),s?(0,i.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:s.map(t=>{var s,a;return(0,i.jsx)(uu.N_,{to:(s=e.href,a=t.id,`${s}/${a}`),className:"relative rounded-md border border-[--border] bg-[--subtle]/50 px-2 py-1 text-[11px] font-medium text-[--muted] transition-colors hover:border-[--muted]/50 hover:text-[--foreground]",children:t.label},t.id)})}):e.desc&&(0,i.jsx)("p",{className:"mt-2 text-xs text-[--muted]",children:e.desc})]},e.href)})})]})}function uv(e){let{metrics:t}=e,{cpu:s,memory:a,process:r}=t,n=a.total>0?a.used/a.total:0;return(0,i.jsx)(um,{to:"/dashboard/system",icon:sm.EYW,title:"System",aside:`up ${nS(r.uptimeSec)}`,children:(0,i.jsxs)("div",{className:"grid gap-4 sm:grid-cols-3",children:[(0,i.jsx)(uh,{label:"CPU",value:`${Math.round(s.total)}%`,hint:`${Math.round(s.process)}% this process \xb7 ${s.cores} cores`,ratio:s.total/100}),(0,i.jsx)(uh,{label:"Memory",value:`${ny(a.used)} / ${ny(a.total)}`,hint:`${Math.round(100*n)}% used \xb7 ${ny(a.free)} free`,ratio:n}),(0,i.jsx)(uh,{label:"Process memory",value:ny(a.rss),hint:`${ny(a.heapUsed)} of ${ny(a.heapTotal)} heap`})]})})}function uy(e){let{label:t,value:s}=e;return(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("dt",{className:"truncate text-[10px] uppercase tracking-wide text-[--muted]",children:t}),(0,i.jsx)("dd",{className:"truncate text-sm font-medium tabular-nums",children:s})]})}function uj(e){let{data:t}=e,{live:s,pool:a,cache:r}=t,n=a.providers.length;return(0,i.jsxs)(um,{to:"/dashboard/usenet/stats",icon:sm.hQe,title:"Usenet activity",aside:`${n} ${1===n?"provider":"providers"}`,children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-2xl font-semibold tabular-nums",children:nj(s.currentBytesPerSec)}),(0,i.jsxs)("div",{className:"text-xs text-[--muted]",children:["peak ",nj(s.peakBytesPerSec)]})]}),(0,i.jsxs)("dl",{className:"grid grid-cols-3 gap-2",children:[(0,i.jsx)(uy,{label:"Streams",value:String(s.activeStreams)}),(0,i.jsx)(uy,{label:"Articles/min",value:nT(s.articlesLastMinute)}),(0,i.jsx)(uy,{label:"Cache hits",value:nN(r.hitRate)})]}),a.globalDownloadMax>0&&(0,i.jsxs)("div",{className:"text-xs tabular-nums text-[--muted]",children:[a.globalDownloadsInUse," / ",a.globalDownloadMax," concurrent downloads"]}),s.errorsLastMinute>0&&(0,i.jsxs)("p",{className:"text-xs text-amber-500",children:[s.errorsLastMinute," article",1===s.errorsLastMinute?"":"s"," failed in the last minute"]})]})}let uw={root:(0,c.F)(["UI-Badge__root","inline-flex flex-none text-base w-fit overflow-hidden justify-center items-center gap-2","group/badge"],{variants:{intent:{gray:"text-gray-300 bg-gray-100 border border-gray-500 border-opacity-40 bg-opacity-10",primary:"text-indigo-300 bg-indigo-50 border border-indigo-500 border-opacity-40 bg-opacity-10",success:"text-green-300 bg-green-50 border border-green-500 border-opacity-40 bg-opacity-10",warning:"text-orange-300 bg-orange-50 border border-orange-500 border-opacity-40 bg-opacity-10",alert:"text-red-300 bg-red-50 border border-red-500 border-opacity-40 bg-opacity-10",blue:"text-blue-300 bg-blue-50 border border-blue-500 border-opacity-40 bg-opacity-10",white:"text-white bg-gray-800 border border-gray-500 border-opacity-40 bg-opacity-10","primary-solid":"text-white bg-indigo-500","success-solid":"text-white bg-green-500","alert-solid":"text-white bg-red-400","gray-solid":"text-white bg-gray-700","white-solid":"text-gray-900 bg-white",unstyled:"border text-gray-300"},size:{sm:"h-[1.2rem] px-1.5 text-xs",md:"h-6 px-2 text-xs",lg:"h-7 px-3 text-md"},tag:{false:"font-semibold tracking-wide rounded-full",true:"font-semibold border-none rounded-[--radius]"}},defaultVariants:{intent:"gray",size:"md",tag:!1}}),icon:(0,c.F)(["UI-Badge__icon","inline-flex self-center flex-shrink-0"])},uN=u.forwardRef((e,t)=>
42{let{children:s,className:a,size:r,intent:n,tag:l=!1,leftIcon:o,rightIcon:d,iconClass:c,...u}=e;return(0,i.jsxs)("span",{ref:t,className:x(uw.root({size:r,intent:n,tag:l}),a),...u,children:[o&&(0,i.jsx)("span",{className:x(uw.icon(),c),children:o}),s,d&&(0,i.jsx)("span",{className:x(uw.icon(),c),children:d})]})});uN.displayName="Badge";var uk=s(57145);async function uS(e,t,s){let a=[],r=t,n=!0;for(let t=0;t<s;t++){let t=await ta(r);if(a.push(...t.releases.filter(t=>{var s;return s=t.tag_name,"stable"===e?s.startsWith("v")&&!s.includes("nightly"):e8.test(s)})),r+=1,!(n=t.hasNextPage)||a.length>=20)break}return a.sort((e,t)=>new Date(t.published_at).getTime()-new Date(e.published_at).getTime()),{collected:a,page:r,more:n}}function uC(e,t,s){let a=(0,uk.q)({queryKey:["github-releases",t],queryFn:e=>{let{pageParam:s}=e;return uS(t,s,1===s?1:4)},initialPageParam:1,getNextPageParam:e=>e.more?e.page:void 0,enabled:s&&"dev"!==t,staleTime:1/0}),{data:r,error:n,fetchNextPage:l,hasNextPage:i,isFetchingNextPage:o}=a,d=a.isLoading,c=u.useMemo(()=>{let e=new Set,t=[];for(let s of(null==r?void 0:r.pages)??[])for(let a of s.collected)e.has(a.tag_name)||(e.add(a.tag_name),t.push(a));return t},[r]),m=u.useCallback(()=>{o||d||!i||l()},[l,i,o,d]),h=u.useMemo(()=>e&&"unknown"!==e.toLowerCase()?c.filter(s=>(function(e,t,s){if("stable"===s){let s=e.replace(/^v/,"").split(".").map(Number),a=t.replace(/^v/,"").split(".").map(Number);for(let e=0;e<Math.max(s.length,a.length);e++){let t=s[e]||0,r=a[e]||0;if(t>r)return 1;if(t<r)return -1}return 0}let a=e.replace("-nightly",""),r=t.replace("-nightly","");return a>r?1:a<r?-1:0})(s.tag_name,e,t)>0):[],[c,e,t]);return{releases:c,newer:h,loading:d,loadingMore:o,error:n?n.message:null,hasMore:i,loadMore:m}}var u_=s(50496),uA=s(10930);let uR={root:(0,c.F)(["UI-Accordion__root"]),header:(0,c.F)(["UI-Accordion__header","flex text-lg"]),trigger:(0,c.F)(["UI-Accordion__trigger","flex flex-1 items-center justify-between px-4 py-2 font-medium transition-all hover:bg-[--subtle] [&[data-state=open]>svg]:rotate-180"]),triggerIcon:(0,c.F)(["UI-Accordion__triggerIcon","h-4 w-4 shrink-0 transition-transform duration-200"]),item:(0,c.F)(["UI-Accordion__item",""]),contentContainer:(0,c.F)(["UI-Accordion__contentContainer","overflow-hidden transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"]),content:(0,c.F)(["UI-Accordion__content","p-4"])},uT=u.createContext({}),uI=u.forwardRef((e,t)=>{let{className:s,headerClass:a,triggerClass:r,triggerIconClass:n,contentContainerClass:l,contentClass:o,itemClass:d,...c}=e;return(0,i.jsx)(uT.Provider,{value:{itemClass:d,headerClass:a,triggerClass:r,triggerIconClass:n,contentContainerClass:l,contentClass:o},children:(0,i.jsx)(tY.bL,{ref:t,className:x(uR.root(),s),...c})})});uI.displayName="Accordion";let uE=u.forwardRef((e,t)=>{let{className:s,...a}=e,{itemClass:r}=u.useContext(uT);return(0,i.jsx)(tY.q7,{ref:t,className:x(uR.item(),r,s),...a}
42)});uE.displayName="AccordionItem";let uM=u.forwardRef((e,t)=>{let{className:s,headerClass:a,triggerIconClass:r,children:n,...l}=e,{headerClass:o,triggerClass:d,triggerIconClass:c}=u.useContext(uT);return(0,i.jsx)(tY.Y9,{className:x(uR.header(),o,a),children:(0,i.jsxs)(tY.l9,{ref:t,className:x(uR.trigger(),d,s),...l,children:[n,(0,i.jsx)("svg",{className:x(uR.triggerIcon(),c,r),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})]})})});uM.displayName="AccordionTrigger";let uP=u.forwardRef((e,t)=>{let{className:s,contentContainerClass:a,children:r,...n}=e,{contentContainerClass:l,contentClass:o}=u.useContext(uT);return(0,i.jsx)(tY.UC,{ref:t,className:x(uR.contentContainer(),l,a),...n,children:(0,i.jsx)("div",{className:x(uR.content(),o,s),children:r})})});uP.displayName="AccordionContent";let u$={root:(0,c.F)(["UI-Skeleton__root","animate-pulse rounded-[--radius-md] bg-[--subtle] w-full h-12"])},uD=u.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,i.jsx)("div",{ref:t,className:x(u$.root(),s),...a})});function uL(e){var t;let{release:s,isNewer:a}=e,r=null==(t=s.body)?void 0:t.replace(s.tag_name,"").trim();return(0,i.jsxs)(uE,{value:s.tag_name,className:x("rounded-lg border overflow-hidden transition-colors",a?"border-brand-500/50 bg-brand-500/[0.06]":"border-gray-700/60 bg-gray-800/30"),children:[(0,i.jsx)(uM,{className:"px-3.5 py-2.5 gap-3 hover:bg-gray-700/20",triggerIconClass:"text-gray-500",children:(0,i.jsxs)("span",{className:"flex items-center gap-3 min-w-0 flex-1",children:[(0,i.jsx)("span",{className:x("text-sm font-semibold",a?"text-[--brand]":"text-gray-200"),children:s.tag_name}),a&&(0,i.jsx)("span",{className:"text-[10px] leading-none font-medium px-1.5 py-1 rounded bg-brand-500/20 text-[--brand]",children:"Newer"}),(0,i.jsx)("span",{className:"ml-auto text-xs text-gray-500 shrink-0",children:new Date(s.published_at).toLocaleDateString()})]})}),(0,i.jsxs)(uP,{className:"px-3.5 pb-3.5 pt-0.5 space-y-3",children:[(0,i.jsx)("div",{className:"prose prose-invert prose-sm max-w-none min-w-0 [&_p]:text-sm [&_ul]:text-sm [&_li]:text-sm [&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_*]:break-words",children:(0,i.jsx)(u_.oz,{children:r||"No changelog provided."})}),(0,i.jsxs)("a",{href:s.html_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs text-gray-500 hover:text-white transition-colors",children:["View on GitHub",(0,i.jsx)(uA.A,{className:"w-3 h-3"})]})]})]})}function uO(e){let{open:t,onOpenChange:s,channel:a,releases:r}=e,n=co("(min-width: 640px)"),{loadMore:l,hasMore:o,loadingMore:d,loading:c,error:m}=r,h=u.useRef(null),p=u.useRef(l);p.current=l;let x=u.useCallback(e=>{var t;if(null==(t=h.current)||t.disconnect(),!e){h.current=null;return}h.current=new IntersectionObserver(e=>{var t;(null==(t=e[0])?void 0:t.isIntersecting)&&p.current()},{rootMargin:"300px"}),h.current.observe(e)},[]);u.useEffect(()=>()=>{var e;return null==(e=h.current)?void 0:e.disconnect()},[]);let g=new Set(r.newer.map(e=>e.tag_name));return(0,i.jsxs)(tz,{open:t,onOpenChange:s,side:n?"right":"bottom",size:n?"lg":"full",title:"All releases",description:"nightly"===a?"Every nightly build, newest first.":"Every release, newest first.",contentClass:"flex flex-col",children:[(0,i.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1",children:[m&&(0,i.jsx)(lB,{intent:"alert",title:"Error",description:m,className:"mb-2"}),c?(0,i.jsx)("div",{className:"space-y-2",children:[0,1,2,3,4].map(e=>(0,i.jsx)(uD,{className:"h-11 w-full rounded-lg"},e))}):(0,i.jsx)(uI,{type:"multiple",defaultValue:g.size?r.newer.map(e=>e.tag_name).slice(0,5):r.releases[0]?[r.releases[0].tag_name]:[],className:"space-y-2",children:r.releases.map((e,t)=>(0,i.jsx)(se.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.18,delay:.03*Math.min(t,8),ease:"easeOut"},children:(0,i.jsx)(uL,{release:e,isNewer:g.has(e.tag_name)})},e.id||e.tag_name))}),(0,i.jsx)("div",{ref:x,className:"h-px"}),d&&(0,i.jsx)("div",{className:"space-y-2 pt-2",children:[0,1,2].map(e=>(0,i.jsx)(uD,{className:"h-11 w-full rounded-lg"},e))}),!c&&o&&!d&&(0,i.jsx)("div",{className:"flex justify-center py-4",children:(0,i.jsx)("button",{type:"button",onClick:l,className:"text-xs text-gray-500 hover:text-white transition-colors",children:"Load older releases"})}),!c&&!o&&r.releases.length>0&&(0,i.jsx)("p",{className:"text-center text-xs text-gray-600 py-4",children:"That's everything."})]}),(0,i.jsx)("div",{className:"pt-3 mt-3 border-t border-gray-700/60",children:(0,i.jsxs)("a",{href:e9,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-[--brand] hover:underline",children:["Read the written changelog",(0,i.jsx)(uA.A,{className:"w-3.5 h-3.5"})]})})]})}uD.displayName="Skeleton";let uU="https://github.com/Viren070/AIOStreams",uF={stable:{label:"Stable",intent:"success"},nightly:{label:"Nightly",intent:"blue"},dev:{label:"Dev",intent:"gray"}},uz="hover:text-[--foreground] hover:underline";function uV(e){let{href:t,title:s,className:a="hover:underline",children:r}=e;return(0,i.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:s,className:a,children:r})}function uq(e){let t=e.filter(Boolean);if(0!==t.length)return t.map((e,t)=>(0,i.jsxs)(u.Fragment,{children:[t>0&&" \xb7 ",e]},t))}function uB(e){let{channel:t,releases:s}=e;if("dev"===t)return(0,i.jsx)(uh,{label:"Latest",value:"â",hint:"Not checked on dev builds"});if(s.loading)return(0,i.jsx)(uh,{label:"Latest",value:"â",hint:"Checking for updatesâ¦"});if(s.error){let e=`Couldn't check: ${s.error}`;return(0,i.jsx)(uh,{label:"Latest",value:"â",hint:(0,i.jsx)("span",{title:e,children:e})})}let a=s.newer[0];if(!a)return(0,i.jsx)(uh,{label:"Latest",value:(0,i.jsx)("span",{className:"text-emerald-500",children:"Up to date"}),hint:`No newer ${"nightly"===t?"nightly":"release"}`});let r=s.newer.length;return(0,i.jsx)(uh,{label:"Latest",value:(0,i.jsx)(uV,{href:a.html_url,className:"text-amber-500 hover:underline",children:a.tag_name}),hint:`${r} ${"nightly"===t?"build":"release"}${1===r?"":"s"} behind \xb7 released ${nE(Date.parse(a.published_at))}`})}function uK(e){var t;let{status:s}=e,{tag:a,channel:r,commit:n}=s,l=uC(a,r,!0),o=(0,ty.I)(tc),[d,c]=u.useState(!1),m=Date.parse(s.buildTime),h="dev"!==r&&"unknown"!==a.toLowerCase(),p="stable"!==r&&n&&"unknown"!==n,g=te(o.data??[],"stable"===r?(null==(t=l.newer[0])?void 0:t.tag_name)??a:s.version);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(um,{icon:sm.eqh,title:"Version",aside:(0,i.jsx)(uN,{intent:uF[r].intent,size:"sm",children:uF[r].label}),children:(0,i.jsxs)("div",{className:"grid gap-4 sm:grid-cols-3",children:[(0,i.jsx)(uh,{label:"Running",value:h?(0,i.jsx)(uV,{href:`${uU}/releases/tag/${a}`,children:a}):a,hint:uq([!Number.isNaN(m)&&(0,i.jsxs)("span",{title:nI(s.buildTime),children:["Built ",nE(m)]}),p&&(0,i.jsx)(uV,{href:`${uU}/commit/${n}`,className:x("font-mono",uz),children:n})])}),(0,i.jsx)(uB,{channel:r,releases:l}),(0,i.jsx)(uh,{label:g?`What's new in ${g.version??g.title}`:"What's new",value:o.isLoading?"â":g?(0,i.jsx)(uV,{href:tt(g),title:g.description??g.title,children:g.title}):(0,i.jsx)(uV,{href:e9,children:"Changelog"}),hint:uq([g&&(0,i.jsx)(uV,{href:e9,className:uz,children:"Changelog"}),"dev"!==r&&(0,i.jsx)("button",{type:"button",onClick:()=>c(!0),className:uz,children:"All releases"})])})]})}),"dev"!==r&&(0,i.jsx)(uO,{open:d,onOpenChange:c,channel:r,releases:l})]})}function uH(e){let{label:t,value:s,hint:a,intent:r,className:n}=e;return(0,i.jsxs)(J,{className:x("p-4",n),children:[(0,i.jsx)("div",{className:"text-xs uppercase tracking-wide text-[--muted]",children:t}),(0,i.jsx)("div",{className:x("mt-1 text-2xl font-semibold tabular-nums","ok"===r&&"text-emerald-500","warn"===r&&"text-amber-500","err"===r&&"text-red-400"),children:s}),a&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:a})]})}function uW(e){let{open:t,onSuccess:s,onOpenChange:a,initialUuid:r}=e,{setUserData:n,setUuid:l,setPassword:o,setEncryptedPassword:d,setBaseline:c}=ri(),{user:h}=su(),{status:p}=tj(),x=(null==p?void 0:p.settings.configSessionsEnabled)!==!1,g=(0,e3.jE)(),[f,b]=u.useState(r||""),[y,j]=u.useState(""),[N,k]=u.useState(!1),[C,_]=u.useState(!0),[A,R]=u.useState(""),[T,I]=u.useState(!1),[E,M]=u.useState(null),[P,$]=u.useState(null),[D,L]=u.useState(null),[O,U]=u.useState(!1),F=u.useRef(C);F.current=C;let z=u.useRef(null),{data:V,isLoading:q}=(0,ty.I)({...tu,enabled:t&&!!h}),B=(null==V?void 0:V.profiles)??[],H=B.length>0,W=u.useCallback(async function(e,t){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=await eh(e,t);if(n(()=>r.userData),c(r.userData),l(e),o(t),d(r.encryptedPassword),x)try{await ec(e,t,a)}catch{}s()},[x,n,c,l,o,d,s]),Y=async e=>{e.preventDefault(),I(!0);try{if(await W(f,y,C),N&&h)try{await ek(f,y,A.trim()||void 0),g.invalidateQueries({queryKey:tu.queryKey})}catch(e){m.oR.error(e instanceof Error?`Loaded, but not saved: ${e.message}`:"Loaded, but could not be saved as a profile")}}catch(e){m.oR.error(e instanceof Error?e.message:"Failed to load configuration")}finally{I(!1)}},J=u.useCallback(async e=>{M(e.id);try{let t=await e_(e.id);await W(t.uuid,t.password,F.current)}catch(t){t instanceof es&&(b(e.uuid),U(!0),g.invalidateQueries({queryKey:tu.queryKey})),m.oR.error(t instanceof Error?t.message:"Failed to open configuration")}finally{M(null)}},[W,g]),Z=r?B.find(e=>e.uuid===r&&!e.needsRelink):void 0,Q=u.useRef(null);u.useEffect(()=>{t&&Z&&Q.current!==Z.id&&(Q.current=Z.id,J(Z))},[t,Z,J]);let X=async e=>{$(e.id);try{await eC(e.id),g.invalidateQueries({queryKey:tu.queryKey}),m.oR.success(`Deleted profile "${e.label}"`)}catch(e){m.oR.error(e instanceof Error?e.message:"Failed to delete profile")}finally{$(null),L(null)}};u.useEffect(()=>{t||(j(""),k(!1),_(!0),R(""),U(!1),L(null),Q.current=null)},[t]),u.useEffect(()=>{r?b(r):b("")},[r]);let ee=!q&&(O||!!r&&!Z||!H),et=x?(0,i.jsx)(lt,{label:"Remember me",value:C,onValueChange:e=>_(!0===e)}):null;return(0,i.jsx)(sl,{open:t,onOpenChange:a,title:"Load Configuration",onOpenAutoFocus:r?e=>{var t;
42e.preventDefault(),null==(t=z.current)||t.focus()}:void 0,children:(0,i.jsxs)("div",{className:"space-y-4",children:[h&&q&&(0,i.jsx)("div",{className:"flex justify-center py-2",children:(0,i.jsx)(S,{})}),H&&(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["Your profiles",h?` (${h.username})`:""]}),(0,i.jsx)("ul",{className:"space-y-1",children:B.map(e=>(null==D?void 0:D.id)===e.id?(0,i.jsxs)("li",{className:"flex flex-wrap items-center gap-2 rounded-[--radius] border border-[--border] px-3 py-2",children:[(0,i.jsxs)("span",{className:"flex-1 min-w-0 text-sm",children:["Delete ",(0,i.jsx)("b",{children:e.label}),"? The configuration itself is kept."]}),(0,i.jsx)(v,{type:"button",intent:"alert-subtle",size:"sm",loading:P===e.id,onClick:()=>X(e),children:"Delete"}),(0,i.jsx)(v,{type:"button",intent:"gray-subtle",size:"sm",disabled:null!==P,onClick:()=>L(null),children:"Cancel"})]},e.id):(0,i.jsxs)("li",{className:"flex items-center gap-2",children:[(0,i.jsxs)(v,{type:"button",intent:"gray-subtle",className:"flex-1 justify-start min-w-0",loading:E===e.id,disabled:null!==E,onClick:()=>J(e),children:[(0,i.jsx)("span",{className:"truncate",children:e.label}),e.alias&&(0,i.jsxs)("span",{className:"ml-2 text-xs text-[--muted] truncate",children:["/u/",e.alias]}),e.needsRelink&&(0,i.jsx)("span",{className:"ml-2 text-xs text-[--red]",children:"needs password"})]}),(0,i.jsx)(w,{type:"button",icon:(0,i.jsx)(sm.id1,{}),intent:"alert-subtle",size:"sm",disabled:null!==E||null!==P,"aria-label":`Delete profile ${e.label}`,onClick:()=>L(e)})]},e.id))}),!ee&&(0,i.jsx)(v,{type:"button",intent:"white-link",size:"sm",leftIcon:(0,i.jsx)(sm.zaF,{}),onClick:()=>U(!0),children:"Use a UUID and password"}),!ee&&et]}),ee&&(0,i.jsxs)("form",{onSubmit:Y,className:"space-y-4",children:[(0,i.jsx)(K,{label:"UUID",id:"uuid",name:"username",autoComplete:"username",autoCapitalize:"none",spellCheck:!1,value:f,onValueChange:e=>b(e),placeholder:"Enter your configuration UUID",required:!0,readOnly:!!r,className:r?"opacity-50":void 0}),(0,i.jsx)(G,{ref:z,label:"Password",id:"password",name:"password",value:y,onValueChange:e=>j(e),placeholder:"Enter your configuration password",required:!0}),h&&(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(lt,{label:"Save as a profile",value:N,onValueChange:e=>k(!0===e)}),N&&(0,i.jsx)(K,{label:"Name",value:A,onValueChange:R,placeholder:"Optional, defaults to the start of the UUID"})]}),et,(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{type:"button",onClick:()=>{a(!1)},children:"Cancel"}),(0,i.jsx)(v,{type:"submit",loading:T,children:"Load"})]})]})]})})}let uG=u.createContext(null);function uY(){let e=u.useContext(uG);if(!e)throw Error("useConfigAuth must be used within a ConfigAuthProvider");return e}let uJ=/stremio\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/.*\/configure/;function uZ(e){let{children:t}=e,{uuid:s,setUserData:a,setUuid:r,setPassword:n,setEncryptedPassword:l,setBaseline:o}=ri(),{status:d}=tj(),[c,h]=u.useState(!1),[p,x]=u.useState(),[g,f]=u.useState(!1),b=(null==d?void 0:d.settings.configSessionsEnabled)!==!1,[v,y]=u.useState(()=>b&&ed()),j=!!s,w=u.useCallback(e=>{a6(s),a(null),r(null),n(null),l(null),(e?em():eu()).catch(()=>{})},[s,a,r,n,l]),N=sd({title:"Sign Out",description:"Are you sure you want to sign out?",onConfirm:()=>w(g)}),k=u.useCallback(e=>{e&&x(e),h(!0)},[]);u.useEffect(()=>{if("u"<typeof window)return;let e=window.location.pathname.match(uJ);e&&k(e[1])},[k]),u.useEffect(()=>{if(!v)return;let e=!1;return ep().then(t=>{e||(a(()=>t.userData),o(t.userData),r(t.userData.uuid??null),l(t.encryptedPassword))}).catch(()=>{}).finally(()=>{e||y(!1)}),()=>{e=!0}},[v,a,o,r,l]);let S=u.useRef(N);S.current=N;let C=u.useCallback(()=>{S.current.open()},[]),_=u.useMemo(()=>({isSignedIn:j,openSignIn:k,openSignOut:C,toggleSession:()=>j?C():k()}),[j,k,C]);return(0,i.jsxs)(uG.Provider,{value:_,children:[t,(0,i.jsx)(uW,{open:c,onSuccess:()=>{h(!1),m.oR.success("Signed in successfully")},onOpenChange:e=>{e||h(!1)},initialUuid:p}),(0,i.jsx)(sc,{...N,description:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)("p",{children:"Are you sure you want to sign out?"}),b&&(0,i.jsx)("div",{className:"flex justify-center",children:(0,i.jsx)(lt,{label:"Sign out on all devices",value:g,onValueChange:e=>f(!0===e)})})]})})]})}var uQ=s(62447);function uX(e){let{open:t,onOpenChange:s}=e;return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Support AIOStreams",children:(0,i.jsxs)("div",{className:"flex flex-col gap-5 items-center text-center p-2",children:[(0,i.jsxs)("div",{className:"flex flex-col gap-2 items-center",children:[(0,i.jsx)("span",{className:"text-3xl",children:"\uD83D\uDC96"}),(0,i.jsx)("h2",{className:"text-xl font-bold",children:"Donate to Me"}),(0,i.jsx)("p",{className:"text-sm text-[--muted] max-w-md",children:"AIOStreams is a solo project built and maintained by me in my free time. If you find it useful, please consider supporting my work. Your donation helps me keep the project alive and improve it for everyone!"})]}),(0,i.jsxs)("div",{className:"flex flex-col gap-3 w-full mt-2",children:[(0,i.jsx)(v,{intent:"alert-subtle",onClick:()=>window.open("https://github.com/sponsors/Viren070","_blank"),leftIcon:(0,i.jsx)(uQ.Zak,{}),className:"w-full",children:"GitHub Sponsors"}),(0,i.jsx)(v,{intent:"alert-subtle",onClick:()=>window.open("https://ko-fi.com/Viren070","_blank"),leftIcon:(0,i.jsx)(uQ.OnT,{}),className:"w-full",children:"Ko-fi"})]})]})})}function u0(){let e=(0,T.Z)(),{selectedMenu:t,setSelectedMenu:s}=rh(),a=so(!1),r=ri(),{isSignedIn:n,openSignIn:l,openSignOut:o}=uY(),{status:d,error:c,loading:u}=tj(),{mode:m,setMode:h}=sF(),{open:p}=rS();rR(n?{id:"sign-out",label:"Sign Out",icon:(0,i.jsx)(sm.eZR,{}),keywords:["logout","log out"],onSelect:o}:{id:"sign-in",label:"Sign In",icon:(0,i.jsx)(sm.XzR,{}),keywords:["login","log in"],onSelect:()=>l()},[n,l,o]),rR({id:"donate",label:"Donate",icon:(0,i.jsx)(sm.uoR,{}),keywords:["support","sponsor"],onSelect:()=>a.open()},[a]),rR({id:"toggle-mode",label:"pro"===m?"Switch to Simple mode":"Switch to Advanced mode",icon:(0,i.jsx)(sm.nMM,{}),keywords:["mode","pro","noob","beginner","advanced"],onSelect:()=>h("pro"===m?"noob":"pro")},[m,h]);let x=[{name:"About",iconType:sm.wfp,isCurrent:"about"===t,id:"about"},{name:"Services",iconType:sm.V0M,isCurrent:"services"===t,id:"services"},{name:"Addons",iconType:sm.DT2,isCurrent:"addons"===t,id:"addons"},{name:"Filters",iconType:sm.Jw7,isCurrent:"filters"===t,id:"filters"},..."pro"===m?[{name:"Sorting",iconType:sm.MFA,isCurrent:"sorting"===t,i
42d:"sorting"}]:[],{name:"Formatter",iconType:sm.fSy,isCurrent:"formatter"===t,id:"formatter"},{name:"Proxy",iconType:sm.nmg,isCurrent:"proxy"===t,id:"proxy"},{name:"Miscellaneous",iconType:sm.nMM,isCurrent:"miscellaneous"===t,id:"miscellaneous"},...(null==d?void 0:d.settings.userAnalyticsEnabled)&&n?[{name:"Stats",iconType:sm.yWU,isCurrent:"stats"===t,id:"stats"}]:[],{name:"Save & Install",iconType:sm.Ruw,isCurrent:"save-install"===t,id:"save-install"}],g=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"mb-4 p-4 pb-0 flex flex-col items-center w-full",children:[(0,i.jsx)("div",{className:"flex items-center gap-2",children:(0,i.jsx)("img",{src:(null==d?void 0:d.settings.alternateDesign)?(null==d?void 0:d.channel)==="nightly"?"/mini-nightly-white.png":"/mini-stable-white.png":r.userData.addonLogo||"/logo.png",alt:"logo",className:"max-w-[90px] max-h-[60px] object-contain p-4"})}),(null==d?void 0:d.settings.alternateDesign)===!1&&(0,i.jsx)("span",{className:"text-xs text-gray-500",children:d?"nightly"===d.channel?"nightly":d.tag:""})]}),(0,i.jsx)(ne,{label:"Search settings",onOpen:p})]}),f=[{name:"Dashboard",iconType:sm.fiy,onClick(t){t.ctrlKey||t.metaKey?window.open("/dashboard","_blank"):e({to:"/dashboard"})}},{name:"Donate",iconType:sm.uoR,onClick:()=>a.open()},{name:n?"Sign Out":"Sign In",iconType:n?sm.eZR:sm.XzR,onClick:()=>n?o():l()}];return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(sr,{header:g,items:x,footerItems:f,onItemSelect:e=>{s(e.id)}}),(0,i.jsx)(uX,{open:a.isOpen,onOpenChange:a.toggle})]})}var u1=s(72780),u2=s(98188);let u3=e=>{let{words:t,className:s,style:a,...r}=e,[n,l]=(0,u1.l)(),o=t.split(" ");return(0,u.useEffect)(()=>
42{l("span",{opacity:1},{duration:2,delay:(0,u2.y)(.2)})},[t]),(0,i.jsx)("div",{className:x("font-bold",s),style:a,...r,children:(0,i.jsx)(se.P.div,{ref:n,children:o.map((e,t)=>(0,i.jsxs)(se.P.span,{className:"opacity-0",children:[e," "]},e+t))})})};function u5(e){let{title:t}=e;return(0,i.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[--background]",children:(0,i.jsxs)("div",{className:x("flex flex-col items-center gap-6 transition-opacity duration-300 ease-out","opacity-100"),children:[(0,i.jsx)(C,{className:"w-10 h-10 m-0"}),t&&(0,i.jsx)(u3,{words:t||"Loading...",className:"text-2xl"})]})})}var u4=s(98592);let u6=["id","version","description","name","logo","behaviorHints","stremioAddonsConfig"];function u9(e){let t={...e};for(let e of u6)delete t[e];return t}function u8(e,t){let s=t>>>0;for(let t=0;t<e.length;t++)s^=e.charCodeAt(t),s=Math.imul(s,0x1000193)>>>0;return s.toString(16).padStart(8,"0")}function u7(e,t){let s=e.split("\n"),a=t.split("\n");return s.length*a.length>25e5?[{type:"remove",content:`[Content too large to diff: ${s.length} lines]`,oldLineNumber:1,truncated:!0},{type:"add",content:`[Content too large to diff: ${a.length} lines]`,newLineNumber:1,truncated:!0}]:function(e,t){let s=e.length,a=t.length,r=Array(s+1).fill(0).map(()=>Array(a+1).fill(0));for(let n=1;n<=s;n++)for(let s=1;s<=a;s++)e[n-1]===t[s-1]?r[n][s]=r[n-1][s-1]+1:r[n][s]=Math.max(r[n-1][s],r[n][s-1]);let n=[],l=s,i=a;for(;l>0||i>0;)l>0&&i>0&&e[l-1]===t[i-1]?(n.push({type:"same",content:e[l-1],oldLineNumber:l,newLineNumber:i}),l--,i--):i>0&&(0===l||r[l][i-1]>=r[l-1][i])?(n.push({type:"add",content:t[i-1],newLineNumber:i}),i--):l>0&&(0===i||r[l][i-1]<r[l-1][i])&&(n.push({type:"remove",content:e[l-1],oldLineNumber:l}),l--);return n.reverse()}(s,a)}var me=s(96221),mt=s(20440);function ms(e){let{diffs:t,valueFormatter:s,oldValue:a,newValue:r,annotations:n,pathFormatter:l}=e,o=e=>{if(s){let t=s(e);if(null!=t)return t}if(void 0===e)return"(undefined)";if(null===e)return"(null)";if("object"==typeof e&&null!==e)try{return JSON.stringify(e,null,2)}catch{return"[Circular Reference]"}return String(e)},d=(0,u.useMemo)(()=>{if(!a&&!r)return[];try{let e=a?JSON.stringify(a,null,2):"",t=r?JSON.stringify(r,null,2):"";return u7(e,t)}catch(e){return console.error("Failed to stringify JSON for diff:",e),u7("","")}},[a,r]),c=(0,u.useMemo)(()=>{if(!n||0===n.size)return t;let e={critical:0,warning:1,info:2};return[...t].sort((t,s)=>{let a=t.path.join(".").replace(/\.\[/g,"["),r=s.path.join(".").replace(/\.\[/g,"["),l=n.get(a),i=n.get(r);return l&&!i?-1:!l&&i?1:l&&i?(e[l.severity??"info"]??3)-(e[i.severity??"info"]??3):0})},[t,n]);return 0===t.length?(0,i.jsx)("div",{className:"text-center p-4 text-[--muted]",children:"No changes detected."}):(0,i.jsx)("div",{className:"w-full mt-4",children:(0,i.jsxs)(nG,{defaultValue:"visual",className:"w-full",animated:!1,children:[(0,i.jsxs)(nY,{className:"mb-4 grid w-full grid-cols-2",children:[(0,i.jsx)(nJ,{value:"visual",children:"Visual"}),(0,i.jsx)(nJ,{value:"json",children:"Raw JSON"})]}),(0,i.jsx)(nZ,{value:"visual",className:"max-h-[60vh] overflow-y-auto pr-2 custom-scrollbar",children:(0,i.jsx)("div",{className:"space-y-3",children:c.map((e,t)=>{var s;let a,r=e.path.join(".").replace(/\.\[/g,"["),d=l?l(e.path):r,c=null==n?void 0:n.get(r);return(0,i.jsxs)("div",{className:"p-3 bg-gray-800/50 rounded-lg border border-gray-700 relative group",children:[(0,i.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,i.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,i.jsx)(mr,{type:e.type}),c&&(0,i.jsx)("span",{className:`px-2 py-0.5 text-[10px] font-semibold rounded border ${c.className??"bg-blue-500/10 text-blue-400 border-blue-500/20"}`,children:c.label}),(0,i.jsx)("span",{className:"font-mono text-sm text-gray-300",children:d})]})}),(null==c?void 0:c.description)&&(0,i.jsx)("div",{className:`mb-2 text-xs pl-2 border-l-2 border-current/50 italic ${(a=null==(s=c.className)?void 0:s.match(/\btext-\S+-\d+\b/))?a[0]:"text-gray-400"}`,children:c.description}),(0,i.jsxs)("div",{className:`grid gap-4 text-sm ${"CHANGE"===e.type?"grid-cols-2":"grid-cols-1"}`,children:["ADD"!==e.type&&(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsx)("div",{className:"text-xs text-[--muted] uppercase",children:"Old"}),(0,i.jsx)("div",{className:"p-2 bg-red-600/20 text-red-200 rounded break-all border border-red-600/30 font-mono text-xs whitespace-pre-wrap",children:o(e.oldValue)})]}),"REMOVE"!==e.type&&(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsx)("div",{className:"text-xs text-[--muted] uppercase",children:"New"}),(0,i.jsx)("div",{className:"p-2 bg-green-900/20 text-green-200 rounded break-all border border-green-900/30 font-mono text-xs whitespace-pre-wrap",children:o(e.newValue)})]})]})]},`${e.path.join(".")}-${e.type}-${t}`)})})}),(0,i.jsx)(nZ,{value:"json",className:"relative max-h-[60vh] overflow-hidden rounded-md border border-gray-800 bg-gray-950/50 flex flex-col group",children:(0,i.jsx)(ma,{textDiffs:d})})]})})}function ma(e){let{textDiffs:t}=e,[s,a]=(0,u.useState)(0),r=(0,u.useRef)(null),n=(0,u.useRef)([]),l=(0,u.useMemo)(()=>{let e=[],s=!1;return t.forEach((t,a)=>{"same"!==t.type?s||(e.push(a),s=!0):s=!1}),e},[t]),o=(0,u.useCallback)(e=>{let t=l[e];void 0!==t&&n.current[t]&&r.current&&n.current[t].scrollIntoView({behavior:"smooth",block:"center"}),a(e)},[l]);return(0,u.useEffect)(()=>{let e;return a(0),n.current=n.current.slice(0,t.length),l.length>0&&(e=setTimeout(()=>
42o(0),100)),()=>{e&&clearTimeout(e)}},[t,l,o]),(0,u.useEffect)(()=>{t.some(e=>e.truncated)&&m.oR.warning("Large File Detected: Diff simplified for performance.",{id:"large-file-warning"})},[t]),(0,i.jsxs)(i.Fragment,{children:[l.length>0&&(0,i.jsxs)("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2 bg-gray-900/90 border border-gray-700 rounded-md p-1.5 shadow-lg backdrop-blur-sm opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[(0,i.jsxs)("span",{className:"text-xs text-gray-400 font-mono px-2 select-none",children:[s+1," / ",l.length]}),(0,i.jsx)("div",{className:"h-4 w-px bg-gray-700 mx-1"}),(0,i.jsx)(v,{className:"h-7 w-7 p-0 hover:bg-gray-800 bg-transparent",onClick:()=>{o((s-1+l.length)%l.length)},title:"Previous Change","aria-label":"Previous Change",children:(0,i.jsx)(me.A,{className:"h-4 w-4"})}),(0,i.jsx)(v,{className:"h-7 w-7 p-0 hover:bg-gray-800 bg-transparent",onClick:()=>{o((s+1)%l.length)},title:"Next Change","aria-label":"Next Change",children:(0,i.jsx)(mt.A,{className:"h-4 w-4"})})]}),(0,i.jsx)("div",{ref:r,className:"overflow-y-auto custom-scrollbar p-4 flex-1 font-mono text-xs",children:(0,i.jsxs)("div",{className:"flex flex-col",children:[t.map((e,t)=>(0,i.jsxs)("div",{ref:e=>{n.current[t]=e},className:`flex ${"add"===e.type?"bg-green-900/20 text-green-300":"remove"===e.type?"bg-red-600/20 text-red-300":"text-gray-400"} ${t===l[s]?"ring-1 ring-blue-500/50":""}`,children:[(0,i.jsx)("div",{className:"w-8 shrink-0 text-right pr-3 select-none text-gray-600 border-r border-gray-800 mr-2",children:e.oldLineNumber||" "}),(0,i.jsx)("div",{className:"w-8 shrink-0 text-right pr-3 select-none text-gray-600 border-r border-gray-800 mr-2",children:e.newLineNumber||" "}),(0,i.jsxs)("pre",{className:"whitespace-pre-wrap break-all flex-1",children:["add"===e.type?"+":"remove"===e.type?"-":" "," ",e.content]})]},t)),0===t.length&&(0,i.jsx)("div",{className:"text-center p-4 text-[--muted]",children:"No raw JSON available for comparison."})]})})]})}function mr(e){let{type:t}=e,s={CHANGE:"bg-yellow-500/10 text-yellow-500 border-yellow-500/20",ADD:"bg-green-500/10 text-green-500 border-green-500/20",REMOVE:"bg-red-500/10 text-red-500 border-red-500/20"}[t]||"bg-gray-500/10 text-gray-500 border-gray-500/20";return(0,i.jsx)("span",{className:`px-2 py-0.5 text-[10px] font-bold rounded border ${s}`,children:t})}function mn(e){let{oldConfig:t,newConfig:s}=e,a=(0,u.useMemo)(()=>[...(null==t?void 0:t.presets)??[],...(null==s?void 0:s.presets)??[]],[null==t?void 0:t.presets,null==s?void 0:s.presets]),r
42=(0,u.useMemo)(()=>{let e;return e=t=>{if("string"==typeof t){let e=null==a?void 0:a.find(e=>{if(e.instanceId===t)return!0;let s=e.options;return(null==s?void 0:s.id)===t});if(e){let t=e.options;if((null==t?void 0:t.name)&&"string"==typeof t.name)return t.name}return t}return Array.isArray(t)?t.map(e):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(t=>{let[s,a]=t;return[s,e(a)]})):t},t=>{let s=e(t);if("object"==typeof s&&null!==s)try{return JSON.stringify(s,null,2)}catch{return"[Circular Reference]"}return String(s)}},[a]),{diffs:n,processedOld:l,processedNew:o}=(0,u.useMemo)(()=>aW(t,s),[t,s]);return(0,i.jsx)(ms,{diffs:n,valueFormatter:r,oldValue:l,newValue:o})}function ml(e){return`${e.name} (${e.type})`}function mi(e){if(null==e)return String(e);if(mo(e))return ml(e);if(Array.isArray(e)){if(e.every(e=>"string"==typeof e))return e.join("\n");if(e.every(mo))return e.map(ml).join("\n")}if("object"==typeof e)try{return JSON.stringify(e,null,2)}catch{return"[object]"}return String(e)}function mo(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.type&&"string"==typeof e.id&&"string"==typeof e.name}function md(e,t){let s=u9(e),a=u9(t),{catalogs:r,...n}=s,{catalogs:l,...i}=a,o=[...function(e){let t=[],s=new Map,a=new Map;for(let r of e){let e=r.path[r.path.length-1]??"",n="idPrefixes"===r.path[r.path.length-2]&&/^\[\d+\]$/.test(e);if(n&&"ADD"===r.type){let e=r.path.slice(0,-1),t=e.join("\0");s.has(t)||s.set(t,{parentPath:e,values:[]}),s.get(t).values.push(r.newValue);continue}if(n&&"REMOVE"===r.type){let e=r.path.slice(0,-1),t=e.join("\0");a.has(t)||a.set(t,{parentPath:e,values:[]}),a.get(t).values.push(r.oldValue);continue}"CHANGE"===r.type&&"idPrefixes"===r.path[r.path.length-1]&&Array.isArray(r.oldValue)&&Array.isArray(r.newValue)||t.push(r)}for(let[,{parentPath:e,values:a}]of s)t.push({path:e,type:"ADD",newValue:a});for(let[,{parentPath:e,values:s}]of a)t.push({path:e,type:"REMOVE",oldValue:s});return t}(aB(n,i)),...function(e,t){let s=e=>`${e.type}:${e.id}`,a=e.map(s),r=t.map(s);if(new Set(a).size!==e.length||new Set(r).size!==t.length)return aB({catalogs:e},{catalogs:t}).map(e=>({...e}));let n=new Map(e.map(e=>[s(e),e])),l=new Map(t.map(e=>[s(e),e])),i=[];for(let e of a)if(!l.has(e)){let t=a.indexOf(e);i.push({path:["catalogs",`[${t}]`],type:"REMOVE",oldValue:n.get(e)})}for(let e of r){let t=r.indexOf(e);if(n.has(e))for(let s of aB(n.get(e),l.get(e)))i.push({...s,path:["catalogs",`[${t}]`,...s.path]});else i.push({path:["catalogs",`[${t}]`],type:"ADD",newValue:l.get(e)})}let o=a.filter(e=>l.has(e)),d=r.filter(e=>n.has(e));if(o.some((e,t)=>e!==d[t])){let e=e=>{let t=l.get(e)??n.get(e);return t?ml(t):e};i.push({path:["catalogs"],type:"CHANGE",oldValue:a.map(e),newValue:r.map(e)})}return i}(e.catalogs??[],t.catalogs??[])],d=function(e,t,s){let a=new Map;for(let o of e){var r,n,l,i;let e=o.path.join(".").replace(/\.\[/g,"["),d=o.path[0];if("catalogs"===d){let i=1===o.path.length&&"CHANGE"===o.type,d="ADD"===o.type&&2===o.path.length,c="REMOVE"===o.type&&2===o.path.length,u=o.path.length>=3;if(i)a.set(e,{label:"â CATALOG ORDER",className:"bg-amber-500/10 text-amber-400 border-amber-500/20",severity:"warning",description:"Catalog ordering has changed. Stremio will display them in the old order until you reinstall."});else if(d){let t=o.newValue,s=t?ml(t):"Unknown";a.set(e,{label:"â NEW CATALOG",className:"bg-green-500/10 text-green-400 border-green-500/20",severity:"critical",description:`"${s}" was added. It won't appear in Stremio until you reinstall.`})}else if(c){let t=o.oldValue,s=t?ml(t):"Unknown";a.set(e,{label:"â CATALOG REMOVED",className:"bg-red-500/10 text-red-300 border-red-400/20",severity:"critical",description:`"${s}" was removed. It will appear empty or broken in Stremio until you reinstall.`})}else if(u){let i=null==(r=o.path[1])?void 0:r.match(/\[(\d+)\]/),d=i?parseInt(i[1],10):-1,c=d>=0?(null==(n=s.catalogs)?void 0:n[d])??(null==(l=t.catalogs)?void 0:l[d]):void 0,u=c?ml(c):"";o.path.length>=4&&"extra"===o.path[2]&&"isRequired"===o.path[o.path.length-1]?a.set(e,{label:"â EXTRA REQUIRED",className:"bg-amber-500/10 text-amber-400 border-amber-500/20",severity:"warning",description:`An extra parameter's "required" status changed in catalog${u?`: ${u}`:""}.`}):a.set(e,{label:"â CATALOG CHANGED",className:"bg-amber-500/10 text-amber-400 border-amber-500/20",severity:"warning",description:u?`In catalog: ${u}`:void 0})}continue}if("idPrefixes"===d){("ADD"===o.type||"CHANGE"===o.type&&function(e,t){let s=new Set(t??[]);return Array.isArray(e.newValue)?e.newValue.some(e=>!s.has(e)):"string"==typeof e.newValue&&!s.has(e.newValue)}(o,t.idPrefixes))&&a.set(e,{label:"â NEW ID PREFIXES",className:"bg-blue-500/10 text-blue-300 border-blue-400/20",severity:"critical",description:"New ID prefixes were added to the manifest. Stremio won't know that this install supports these new prefixes, so it won't query AIOStreams for matching content until you reinstall."});continue}if("resources"===d&&o.path.some(e=>"idPrefixes"===e)){if("ADD"===o.type||"CHANGE"===o.type){let r=null==(i=o.path[1])?void 0:i.match(/\[(\d+)\]/),n=r?parseInt(r[1],10):-1,l=n>=0?(s.resources??[])[n]??(t.resources??[])[n]:void 0,d="string"==typeof l?l:"string"==typeof(null==l?void 0:l.name)?l.name:"this resource";a.set(e,{label:"â NEW ID PREFIXES",className:"bg-blue-500/10 text-blue-300 border-blue-400/20",severity:"critical",description:`Stremio won't know that this install supports the new ID prefix(es) for the ${d} resource. Until you reinstall, Stremio won't query AIOStreams for ${d} content with these new prefixes.`})}continue}
42if("resources"===d&&"ADD"===o.type&&2===o.path.length){let t=o.newValue,s="string"==typeof t?t:"string"==typeof(null==t?void 0:t.name)?t.name:"Unknown";a.set(e,{label:"â NEW RESOURCE",className:"bg-purple-500/10 text-purple-400 border-purple-500/20",severity:"critical",description:`${s} support was added. Stremio won't request ${s} content from AIOStreams until you reinstall â e.g. if subtitles were added, they won't appear until then.`})}}return a}(o,e,t);return{diffs:o,annotations:d}}function mc(e){let{oldManifest:t,newManifest:s}=e,{diffs:a,annotations:r}=(0,u.useMemo)(()=>md(t,s),[t,s]),n=(0,u.useMemo)(()=>e=>e.map((a,r)=>{let n=a.match(/^\[(\d+)\]$/);if(!n)return a;let l=parseInt(n[1],10);if("resources"===e[r-1]){let e=((null==s?void 0:s.resources)??[])[l]??((null==t?void 0:t.resources)??[])[l];if(e&&"object"==typeof e&&"string"==typeof e.name)return`["${e.name}"]`}return a}).reduce((e,t,s)=>0===s?t:t.startsWith("[")?e+t:e+"."+t,""),[t,s]);return 0===a.length?(0,i.jsx)("div",{className:"text-center p-4 text-[--muted] text-sm",children:"No meaningful manifest changes detected."}):(0,i.jsx)(ms,{diffs:a,valueFormatter:mi,oldValue:t,newValue:s,annotations:r,pathFormatter:n})}function mu(e){let{oldManifest:t,newManifest:s}=e,{diffs:a,annotations:r}=(0,u.useMemo)(()=>md(t,s),[t,s]),n=(0,u.useMemo)(()=>{let e={critical:0,warning:1,info:2};return a.map(e=>{let t=e.path.join(".").replace(/\.\[/g,"["),s=r.get(t);return s?{diff:e,annotation:s,pathKey:t}:null}).filter(e=>null!==e).sort((t,s)=>(e[t.annotation.severity??"info"]??3)-(e[s.annotation.severity??"info"]??3))},[a,r]);if(0===a.length)return null;let l=n.some(e=>"critical"===e.annotation.severity),o=!l&&n.some(e=>"warning"===e.annotation.severity);return(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(lB,{intent:l?"alert":o?"warning":"info",isClosable:!1,description:l?"Reinstall required - some changes will not take effect until you reinstall.":o?"Reinstall recommended to apply all changes correctly.":"No significant changes - reinstall is not required for expected functionality."}),n.length>0&&(0,i.jsx)("div",{className:"space-y-1.5",children:n.map((e,t)=>(0,i.jsxs)("div",{className:"p-2.5 rounded-lg border border-[--border] bg-gray-800/30 space-y-1",children:[(0,i.jsx)("span",{className:`inline-block px-2 py-0.5 text-[10px] font-semibold rounded border ${e.annotation.className??""}`,children:e.annotation.label}),e.annotation.description&&(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:e.annotation.description})]},t))})]})}async function mm(e,t){try{let s=await eZ({uuid:e,password:t});for(let e of s.filter(e=>!e.ok))m.oR.error(`Could not push to ${e.label}: ${e.error??""}`);return s}catch(e){return m.oR.error(e instanceof Error?e.message:"Could not push your changes"),null}}let mh=u.createContext(void 0);function mp(e){var t,s;let{children:a}=e,{userData:r,setUserData:n,uuid:l,password:o,encryptedPassword:d,setBaseline:c}=ri(),{status:h}=tj(),{setSelectedMenu:p}=rh(),x=(null==h||null==(t=h.settings)?void 0:t.baseUrl)||("u">typeof window?window.location.origin:""),[g,f]=u.useState(!1),[b,y]=u.useState(!1),[j,w]=u.useState(!1),[N,k]=u.useState(!1),[S,C]=u.useState(!1),[_,A]=u.useState(!1),[R,T]=u.useState(!1),[I,E]=u.useState(null),[M,P]=u.useState(null),[$,D]=u.useState(!1),[L,O]=u.useState(!1),U=(null==(s=r.linkedAccounts)?void 0:s.pushBehaviour)??"ask",F=r.manifestNotice??(l?"u"<typeof window?"always":"true"===localStorage.getItem(`aiostreams-manifest-all-dismissed-${l}`)?"never":"true"===localStorage.getItem(`aiostreams-manifest-insignificant-dismissed-${l}`)?"significant":"always":"always"),[z,V]=u.useState(null),q=u.useMemo(()=>{var e,t;return z?(e=z)&&"object"==typeof e?u8(t=function e(t){if(null===t||"object"!=typeof t)return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(e).join(",")}]`;let s=Object.entries(t).filter(e=>{let[,t]=e;return void 0!==t}).sort((e,t)=>{let[s]=e,[a]=t;return s<a?-1:+(s>a)}).map(t=>{let[s,a]=t;return`${JSON.stringify(s)}:${e(a)}`});return`{${s.join(",")}}`}(u9(e)),0x811c9dc5)+u8(t,0x1000193)+u8(t,0x9e3779b9)+u8(t,0x85ebca6b):"":null},[z]),[B,K]=u.useState(null),[H,W]=u.useState(null),G=u.useRef(!1),Y=l&&d?/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(l)?`${x}/stremio/${l}/${d}/manifest.json`:`${x}/stremio/u/${l}/manifest.json`:null,J=(0,e3.jE)(),Z=l?{uuid:l,password:o}:null,{data:Q}=(0,ty.I)(tm(Z)),X=Q??[];u.useEffect(()=>{Y?eQ(Y).then(V).catch(e=>{console.warn("Failed to fetch manifest:",e)}):V(null)},[l,d]);let ee=u.useRef(null);ee.current=z;let et=u.useCallback(async()=>
42{if(Y&&l)try{let e=await eQ(Y),t=ee.current,s=null!==t&&function(e,t){let{diffs:s}=md(e,t);return s.length>0}(t,e);if(s&&"auto"===U){let t=await mm(l,o);if(J.invalidateQueries({queryKey:th}),null==t?void 0:t.some(e=>e.ok)){let e=t.filter(e=>e.ok).length;m.oR.success(`Pushed to ${e} linked ${1===e?"account":"accounts"}`)}V(e);return}if(P(null),s&&"never"!==F){let s=function(e,t){let{annotations:s}=md(e,t);return Array.from(s.values()).some(e=>"critical"===e.severity||"warning"===e.severity)}(t,e);if(!s&&"significant"===F)return void V(e);T(s),K(e),k(!1),C(!1),w(!0)}else V(e)}catch{}},[Y,l,o,U,F,J]),es=u.useCallback(async e=>{let t=((null==e?void 0:e.skipDiff)??!1)||G.current;if(G.current=!1,!l){p("save-install"),m.oR.info("Please create a configuration first");return}let s=!1;if(!t&&(null==r?void 0:r.showChanges)){f(!0);try{let e=(await eh(l,o)).userData,{diffs:t}=aW(e,r);if(0===t.length)m.oR.info("No changes detected"),s=!0,f(!1);else{E(e),y(!0),f(!1);return}}catch(e){console.error("Error checking for changes:",e),m.oR.warning("Error checking for changes. Proceeding with save."),f(!1)}}f(!0);try{await eg(l,r,o),c(r),J.invalidateQueries({queryKey:tp}),s||m.oR.success("Configuration updated successfully"),W(z),await et()}catch(e){m.oR.error(e instanceof Error?e.message:"Failed to save configuration")}finally{f(!1)}},[l,o,r,h,et,p,n,c,J]),ea=()=>{let e=N?"never":S&&!R?"significant":void 0,t=void 0!==e||$,s={...r,...e?{manifestNotice:e}:{},...$?{linkedAccounts:{...r.linkedAccounts,pushBehaviour:"auto"}}:{}};t&&l&&(n(()=>s),eg(l,s,o).catch(()=>m.oR.warning("Could not remember that preference"))),D(!1),P(null),V(B),w(!1),A(!1),setTimeout(()=>{K(null),W(null)},300)};return(0,i.jsxs)(mh.Provider,{value:{handleSave:es,loading:g,currentManifestFingerprint:q,currentManifestUrl:Y},children:[a,(0,i.jsx)(sl,{open:b,onOpenChange:y,title:"Confirm Changes",description:"Review the changes you are about to make to your configuration.",contentClass:"max-w-4xl",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(mn,{oldConfig:I,newConfig:r}),(0,i.jsxs)("div",{className:"flex justify-between pt-4",children:[(0,i.jsx)(v,{intent:"alert",onClick:()=>{I&&(n(e=>({...re,...I,uuid:e.uuid,encryptedPassword:e.encryptedPassword,trusted:e.trusted,accessKey:e.accessKey,ip:e.ip,showChanges:e.showChanges})),m.oR.success("Changes reverted"),y(!1))},disabled:g,children:"Reset Changes"}),(0,i.jsxs)("div",{className:"flex gap-3",children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>y(!1),disabled:g,children:"Cancel"}),(0,i.jsx)(v,{intent:"white",onClick:()=>{y(!1),es({skipDiff:!0})},loading:g,children:"Confirm & Save"})]})]})]})}),(0,i.jsx)(sl,{open:j,onOpenChange:e=>{e||ea()},title:"Manifest Changed",description:"Your addon manifest has changed since your last install.",contentClass:"max-w-xl",children:(0,i.jsxs)("div",{className:"space-y-4",children:[H&&B&&(0,i.jsx)(mu,{oldManifest:H,newManifest:B}),H&&B&&(0,i.jsx)(v,{intent:"primary",className:"w-full text-sm",onClick:()=>A(!0),children:"See what changed â"}),null!==M&&(0,i.jsx)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsx)("div",{className:"text-sm font-medium text-white",children:M.every(e=>e.ok)?`Pushed to ${M.length} linked ${1===M.length?"account":"accounts"}`:`Pushed to ${M.filter(e=>e.ok).length} of ${M.length} linked accounts`}),(0,i.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:M.every(e=>e.ok)?"They are now up to date with this change":"Open the install page to see what failed"})]})}),null===M&&"ask"===U&&X.length>0&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,i.jsxs)("div",{className:"flex-1 pr-3",children:[(0,i.jsxs)("div",{className:"text-sm font-medium text-white",children:["Push to your linked"," ",1===X.length?X[0].label:`${X.length} accounts`]}),(0,i.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Send this change now so they pick it up without a reinstall"})]}),(0,i.jsx)(v,{intent:"primary",loading:L,onClick:async()=>
42{l&&(O(!0),P(await mm(l,o)),J.invalidateQueries({queryKey:th}),O(!1))},children:"Push now"})]}),(0,i.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsx)("div",{className:"text-sm font-medium text-white",children:"Push automatically when a reinstall is needed"}),(0,i.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Whenever a save changes your manifest, push it without asking"})]}),(0,i.jsx)(ni,{id:"always-push-linked-accounts",value:$,onValueChange:D})]})]}),!R&&(0,i.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsx)("div",{className:"text-sm font-medium text-white",children:"Don't show for insignificant changes"}),(0,i.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Skip this notice when there are no significant manifest changes"})]}),(0,i.jsx)(ni,{id:"dont-show-insignificant-again",value:S,onValueChange:C})]}),(0,i.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsx)("div",{className:"text-sm font-medium text-white",children:"Don't show this again"}),(0,i.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Skip this notice for all future manifest changes"})]}),(0,i.jsx)(ni,{id:"dont-show-manifest-again",value:N,onValueChange:k})]}),(0,i.jsx)("div",{className:"flex justify-end",children:(0,i.jsx)(v,{intent:"white",onClick:ea,children:"OK"})})]})}),(0,i.jsx)(sl,{open:_,onOpenChange:A,title:"What Changed",description:"Detailed diff of your manifest changes.",contentClass:"max-w-4xl",children:H&&B&&(0,i.jsx)(mc,{oldManifest:H,newManifest:B})})]})}function mx(){let e=u.useContext(mh);if(void 0===e)throw Error("useSave must be used within a SaveProvider");return e}function mg(){let{setSelectedMenu:e,selectedMenu:t,previousMenu:s,nextMenu:a,firstMenu:r,lastMenu:n}=rh(),{handleSave:l,loading:o}=mx(),{isSignedIn:d,toggleSession:c}=uY();return(0,i.jsxs)("div",{className:"flex flex-1 gap-2 items-center",children:[(0,i.jsx)(v,{leftIcon:(0,i.jsx)(u4.QVr,{}),intent:"white",size:"md",hideTextOnSmallScreen:!0,rounded:!0,className:"min-w-[60px] md:min-w-[120px]",onClick:()=>{s()},onMouseDown:t=>{if(0===t.button){let t=setTimeout(()=>{e(r)},500),s=()=>{clearTimeout(t),window.removeEventListener("mouseup",s)};window.addEventListener("mouseup",s)}},disabled:t===r,children:"Previous"}),(0,i.jsx)(w,{icon:d?(0,i.jsx)(sm.eZR,{}):(0,i.jsx)(sm.XzR,{}),intent:"white-outline",rounded:!0,size:"md",onClick:c}),d&&(0,i.jsx)(w,{icon:(0,i.jsx)(sm.Ruw,{}),intent:"white-outline",rounded:!0,size:"md",loading:o,onClick:()=>l()}),(0,i.jsx)(v,{rightIcon:(0,i.jsx)(u4.Z0P,{}),intent:"white",size:"md",hideTextOnSmallScreen:!0,rounded:!0,className:"min-w-[60px] md:min-w-[120px]",onClick:()=>{a()},onMouseDown:t=>{if(0===t.button){let t=setTimeout(()=>{e(n)},500),s=()=>{clearTimeout(t),window.removeEventListener("mouseup",s)};window.addEventListener("mouseup",s)}},disabled:t===n,children:"Next"})]})}let mf="overflow-hidden supports-[overflow:clip]:overflow-clip",mb={enter:e=>({x:e>=0?40:-40,opacity:0}),center:{x:0,opacity:1},exit:e=>({x:e>=0?-40:40,opacity:0})};function mv(e){let{tabs:t,activeTab:s,onTabChange:a,defaultMobileOpen:r="",revealOnChange:n=!1,animated:l=!0}=e,o=co("(min-width: 640px)"),d=t.findIndex(e=>e.value===s),c=d>=0?t[d].content:null,m=u.useRef(d),h=d===m.current?0:d>m.current?1:-1;u.useEffect(()=>{m.current=d},[d]);let p=u.useRef(null),g=u.useRef(!1);u.useEffect(()=>{if(!n)return;if(!g.current){g.current=!0;return}let e=p.current;if(!e)return;let t=e.getBoundingClientRect(),s=window.innerHeight;t.height+32<=s&&t.bottom+32>s&&window.scrollBy({top:t.bottom+32-s,behavior:"smooth"})},[s,n]);let[f,b]=u.useState(r||s);return(u.useEffect(()=>{b(s)},[s]),o)?(0,i.jsxs)("div",{children:[(0,i.jsx)(nG,{value:s,onValueChange:a,animated:l,className:"w-full",children:(0,i.jsx)(nY,{className:"flex w-full border-b border-[--border] overflow-x-auto",children:t.map(e=>(0,i.jsxs)(nJ,{value:e.value,className:"flex flex-1 basis-0 items-center gap-1.5",children:[e.icon,e.label]},e.value))})}),(0,i.jsx)("div",{ref:p,className:"relative mt-4 overflow-x-clip",children:(0,i.jsx)(t7.N,{mode:"popLayout",initial:!1,custom:h,children:(0,i.jsx)(se.P.div,{custom:h,variants:mb,initial:"enter",animate:"center",exit:"exit",transition:{duration:.3,ease:[.32,.72,0,1]},className:"space-y-4 p-1",children:c},s)})})]}):(0,i.jsx)("div",{className:"space-y-2",children:(0,i.jsx)(uI,{type:"single",collapsible:!0,value:f,onValueChange:e=>{b(e),e&&a(e)},children:t.map(e=>(0,i.jsxs)(uE,{value:e.value,className:x("border border-[--border] rounded-[--radius-md] mb-2",mf),children:[(0,i.jsx)(uM,{children:(0,i.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[e.icon,e.label]})}),(0,i.jsx)(uP,{contentContainerClass:mf,children:(0,i.jsx)("div",{ref:t=>{t&&(t.inert=f!==e.value)},className:"space-y-4",children:e.content})})]},e.value))})})}function my(e){let{section:t}=e;return(0,i.jsx)(t5,{trigger:(0,i.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-brand-500/10 text-[--brand] border border-brand-500/20 cursor-default select-none",children:[(0,i.jsx)(lV.ayE,{className:"w-3 h-3"}),"Inherited"]}),children:"This section is inherited from your parent config. Change the merge strategy in Miscellaneous â Parent Config to override it."})}let mj={realdebrid:"https://cdn.jsdelivr.net/gh/selfhst/icons/png/real-debrid.png",debridlink:"https://debrid-link.com/img/brand/dl-white-blue.svg",premiumize:"https://www.premiumize.me/icon_normal.svg",alldebrid:"https://cdn.alldebrid.com/lib/images/default/logo_alldebrid.png",torbox:"https://torbox.app/assets/logo-bb7a9579.svg",putio:"https://images.seeklogo.com/logo-png/51/1/put-io-logo-png_seeklogo-516681.png",pikpak:"https://mypikpak.com/apple-touch-icon.png",offcloud:"https://offcloud.com/images/logo-blue-short-lg.png",seedr:"https://static.seedr.cc/images/seed_v2.png",easydebrid:"https://paradise-cloud.com/apple-touch-icon.png",debrider:"https://debrider.app/icon.svg",easynews:"/assets/easynews_logo.png",stremthru_newz:"https://emojiapi.dev/api/v1/sparkles/256.png",stremio_nntp:"https://raw.githubusercontent.com/Stremio/stremio-brand/refs/heads/master/logos/PNG/stremio-logo-800px.png",nzbdav:"https://raw.githubusercontent.com/nzbdav-dev/nzbdav/refs/heads/main/frontend/public/logo.svg",altmount:"https://raw.githubusercontent.com/javi11/altmount/refs/heads/main/docs/static/img/logo.png",aiostreams:"/logo.png",torrin:"https://torrin.app/favicon.png"},mw=[as,aa,ar,at,an,al],mN=["torbox"];function mk(e){return mw.includes(e)}function mS(e){return mN.includes(e)}let mC=[{id:"debrid",label:"Debrid"},{id:"usenet",label:"Usenet"}];function m_(e){let{serviceId:t,shortName:s,className:a}=e,r=mj[t];return r?(0,i.jsx)("img",{src:r,alt:s,className:x("w-9 h-9 rounded-lg object-contain shrink-0",a)}):(0,i.jsx)("div",{className:x("w-9 h-9 rounded-lg bg-[--subtle] border border-[--border] flex items-center justify-center text-xs font-bold font-mono shrink-0 text-[--muted]",a),children:s})}function mA(e){let{id:t,url:s,className:a,trusted:r=!0}=e,n=(()=>{switch(t){case"github":return"View the addon's GitHub repository";case"discord":return"Join the Developer's Discord";case"github-sponsors":return"Sponsor the Developer on GitHub";case"ko-fi":return"Support the Developer on Ko-fi";case"patreon":return"Support the Developer on Patreon";
42case"buymeacoffee":return"Support the Developer on Buy Me a Coffee";case"donate":return"Support the Developer";default:return null}})(),l=sd({title:"External Link Warning",description:(0,i.jsxs)(i.Fragment,{children:["This link was added by a template creator and is not verified or endorsed by AIOStreams.",(0,i.jsx)("br",{}),(0,i.jsx)("br",{}),"You are being taken to"," ",(0,i.jsx)("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] underline",onClick:e=>e.stopPropagation(),children:(0,i.jsx)("b",{children:s})}),"."]}),actionText:"Continue",onConfirm:()=>{window.open(s,"_blank","noopener,noreferrer")}}),o=r?void 0:e=>{e.preventDefault(),l.open()};return(0,i.jsxs)(i.Fragment,{children:[!r&&(0,i.jsx)(sc,{...l}),n?(0,i.jsx)(t5,{side:"top",trigger:(0,i.jsx)(mR,{id:t,url:s,className:a,onClick:o}),children:n}):(0,i.jsx)(mR,{id:t,url:s,className:a,onClick:o})]})}let mR=e=>{let{id:t,url:s,className:a,onClick:r}=e;return(0,i.jsx)("a",{href:s,target:"_blank",rel:"noopener noreferrer",onClick:r,className:x("inline-flex items-center justify-center text-gray-400 transition-colors hover:opacity-80 hover:text-[--brand]",a),children:(()=>{switch(t){case"website":return(0,i.jsx)(u4.f35,{className:"w-7 h-7"});case"discord":return(0,i.jsx)(I.fzZ,{className:"w-7 h-7"});case"github":return(0,i.jsx)(lV.BR8,{className:"w-7 h-7"});case"github-sponsors":return(0,i.jsx)(uQ.Zak,{className:"w-7 h-7"});case"ko-fi":return(0,i.jsx)(uQ.OnT,{className:"w-7 h-7"});case"patreon":return(0,i.jsx)(u4.hk0,{className:"w-7 h-7"});case"buymeacoffee":return(0,i.jsx)(uQ.Ylh,{className:"w-7 h-7"});case"donate":return(0,i.jsx)(sm.xko,{className:"w-7 h-7"});default:return null}})()})};var mT=s(8963).Buffer;function mI(e){let{subsectionIntent:t,buttonIntent:s,name:a,description:r,onClick:n,disabled:l}=e;return"block"===t?(0,i.jsxs)("button",{type:"button",onClick:n,disabled:l,className:"w-full text-left bg-[--background] border border-[--border] rounded-[--radius] px-4 py-3 hover:bg-[--subtle] transition-colors disabled:opacity-50 disabled:pointer-events-none shadow-sm",children:[(0,i.jsx)("div",{className:"font-semibold text-sm",children:a}),r&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,i.jsx)(l6,{children:r})})]}):"pill"===t?(0,i.jsxs)("div",{children:[(0,i.jsx)(v,{type:"button",rounded:!0,intent:s??"white-subtle",size:"md",onClick:n,disabled:l,className:"w-full",children:a}),r&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-2",children:(0,i.jsx)(l6,{children:r})})]}):"inline"===t?(0,i.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)("span",{className:"font-medium text-sm",children:a}),r&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:(0,i.jsx)(l6,{children:r})})]}),(0,i.jsx)(v,{type:"button",rounded:!0,intent:s??"white",size:"sm",onClick:n,disabled:l,className:"shrink-0",children:"Open"})]}):"link"===t?(0,i.jsxs)("button",{type:"button",onClick:n,disabled:l,className:"group text-left disabled:opacity-50 disabled:pointer-events-none",children:[(0,i.jsxs)("span",{className:"inline-flex items-center gap-1 text-sm font-medium text-[--brand] group-hover:underline",children:[a,(0,i.jsx)(u4.X6T,{className:"w-3 h-3 opacity-60 transition-transform group-hover:translate-x-0.5"})]}),r&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:(0,i.jsx)(l6,{children:r})})]}):"banner"===t?(0,i.jsx)("button",{type:"button",onClick:n,disabled:l,className:"w-full text-left border-l-4 border-[--brand] bg-[--subtle] px-4 py-3 rounded-r-[--radius] hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors disabled:opacity-50 disabled:pointer-events-none",children:(0,i.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"font-semibold text-sm",children:a}),r&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:(0,i.jsx)(l6,{children:r})})]}),(0,i.jsx)(u4.X6T,{className:"w-3 h-3 text-[--muted] shrink-0"})]})}):(0,i.jsxs)("div",{className:"flex items-center gap-3 bg-gray-100 dark:bg-gray-800 p-4 rounded-lg",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsx)("h4",{className:"font-medium mb-1",children:a}),r&&(0,i.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,i.jsx)(l6,{children:r})})]}),(0,i.jsx)(w,{icon:(0,i.jsx)(u4.XGb,{}),intent:"primary-outline",onClick:n,disabled:l,title:`Configure ${a}`})]})}function mE(e){let{label:t,value:s,onChange:a,options:r,required:n,disabled:l}=e,o=e=>{a("undefined"===e?void 0:e)},d=!(null==r?void 0:r.some(e=>e.value===s)),c=[...(null==r?void 0:r.map(e=>({label:e.label,value:e.value})))??[],{label:"Custom",value:"Custom"}];return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nc,{label:t,value:d?"Custom"
42:s,onValueChange:e=>{o("Custom"===e?"":e)},options:c,required:n,disabled:l}),d&&(0,i.jsx)(K,{label:"Custom",value:s??"",onValueChange:o,required:n,disabled:l})]})}let mM=e=>{let{option:t,value:s,trusted:a,onChange:r,disabled:n}=e,{id:l,name:o,description:d,type:c,required:m,options:h,constraints:p,forced:x,default:g,intent:f,subsectionIntent:b,buttonIntent:y,socials:j,oauth:N,emptyIsUndefined:k=!1}=t,S=n||null!=x,C=null!=x?x:void 0;switch(c){case"socials":return(0,i.jsx)("div",{className:"flex items-center justify-center w-full gap-6 mt-2",children:null==j?void 0:j.map(e=>(0,i.jsx)(mA,{id:e.id,url:e.url,trusted:a},e.id))});case"alert":return(0,i.jsx)(lB,{intent:f,title:o,description:(0,i.jsx)(l6,{children:d})});case"password":return(0,i.jsxs)("div",{children:[(0,i.jsx)(G,{label:o,value:C??s??g??"",onValueChange:e=>r(k?e||void 0:e),required:m,disabled:S,autoComplete:"new-password",minLength:(null==p?void 0:p.forceInUi)!==!1?null==p?void 0:p.min:void 0,maxLength:(null==p?void 0:p.forceInUi)!==!1?null==p?void 0:p.max:void 0}),d&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,i.jsx)(l6,{children:d})})]});case"string":return(0,i.jsxs)("div",{children:[(0,i.jsx)(K,{label:o,value:C??s??g??"",onValueChange:e=>r(k?e||void 0:e),required:m,minLength:(null==p?void 0:p.forceInUi)!==!1?null==p?void 0:p.min:void 0,maxLength:(null==p?void 0:p.forceInUi)!==!1?null==p?void 0:p.max:void 0,disabled:S}),d&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,i.jsx)(l6,{children:d})})]});case"number":return(0,i.jsxs)("div",{children:[(0,i.jsx)(lm,{value:C??s??g??void 0,label:o,onValueChange:(e,t)=>
42r(isNaN(e)?void 0:e),required:m,step:(null==p?void 0:p.max)&&Math.floor((null==p?void 0:p.max)/100)>0?Math.floor((null==p?void 0:p.max)/100):1,disabled:S,clampValueOnBlur:!1,min:(null==p?void 0:p.forceInUi)!==!1?null==p?void 0:p.min:void 0,max:(null==p?void 0:p.forceInUi)!==!1?null==p?void 0:p.max:void 0}),d&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,i.jsx)(l6,{children:d})})]});case"boolean":return(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,i.jsx)("span",{className:"font-medium text-sm",children:o}),(0,i.jsx)(ni,{disabled:S,value:!!(C??s??g),onValueChange:r})]}),d&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,i.jsx)(l6,{children:d})})]});case"select":return(0,i.jsxs)("div",{children:[(0,i.jsx)(nc,{label:o,value:C??s??g,onValueChange:r,options:(null==h?void 0:h.map(e=>({label:e.label,value:e.value})))??[],required:m,disabled:S}),d&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,i.jsx)(l6,{children:d})})]});case"select-with-custom":return(0,i.jsxs)("div",{children:[(0,i.jsx)(mE,{label:o,value:C??s??g,onChange:r,options:h,required:m,disabled:S}),d&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,i.jsx)(l6,{children:d})})]});case"multi-select":return(0,i.jsxs)("div",{children:[(0,i.jsx)(li,{label:o,value:C??Array.isArray(s)?s:g,onValueChange:e=>r(k&&(null==e?void 0:e.length)===0?void 0:e),options:(null==h?void 0:h.map(e=>({label:e.label,value:e.value,textValue:e.label})))??[],multiple:!0,emptyMessage:"No options",disabled:S,required:m,maxItems:(null==p?void 0:p.forceInUi)!==!1?null==p?void 0:p.max:void 0}),d&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,i.jsx)(l6,{children:d})})]});case"url":return(0,i.jsxs)("div",{children:[(0,i.jsx)(K,{label:o,value:C??s??g??"",onValueChange:e=>r(k?e||void 0:e),required:m,type:"url",disabled:S,minLength:(null==p?void 0:p.forceInUi)!==!1?null==p?void 0:p.min:void 0,maxLength:(null==p?void 0:p.forceInUi)!==!1?null==p?void 0:p.max:void 0}),d&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,i.jsx)(l6,{children:d})})]});case"oauth":{var _,A;let[e,t]=(0,u.useState)(!!s);if(!e)return(0,i.jsx)("div",{children:(0,i.jsx)("div",{className:"flex flex-col gap-3",children:(0,i.jsxs)("div",{className:"flex items-center gap-3 bg-[--subtle] p-4 rounded-lg",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsx)("h4",{className:"font-medium mb-1",children:o}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:(0,i.jsx)(l6,{children:d})})]}),(0,i.jsx)(w,{icon:(0,i.jsx)(u4.pXu,{}),intent:"primary-outline",onClick:()=>{window.open((null==N?void 0:N.authorisationUrl)||"","_blank"),t(!0)},className:"shrink-0"})]})})});return(0,i.jsx)("div",{children:(0,i.jsx)("div",{className:"flex flex-col gap-3",children:(0,i.jsxs)("div",{className:"bg-[--subtle] p-4 rounded-lg",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,i.jsxs)("h4",{className:"font-medium",children:["Enter ",(null==N||null==(_=N.oauthResultField)?void 0:_.name)||"Authorization Code"]}),(0,i.jsx)(w,{icon:(0,i.jsx)(u4.QVr,{className:"w-4 h-4"}),intent:"primary-subtle",size:"sm",onClick:()=>t(!1),"aria-label":"Go back to authorization"})]}),(0,i.jsx)(G,{value:C??s??g,onValueChange:e=>r(k?e||void 0:e),required:m,disabled:S,autoComplete:"new-password"}),(null==N||null==(A=N.oauthResultField)?void 0:A.description)&&(0,i.jsx)("div",{className:"text-sm text-[--muted] mt-2",children:(0,i.jsx)(l6,{children:N.oauthResultField.description})})]})})})}case"subsection":{let[e,a]=(0,u.useState)(!1),n=t.subOptions??[],l=C??s??g??{},c={};for(let e of n)void 0!==e.default&&(c[e.id]=e.default);let m={...c,...l},[h,p]=(0,u.useState)(m);return(0,i.jsxs)("div",{children:[(0,i.jsx)(mI,{subsectionIntent:b,buttonIntent:y,name:o,description:d,onClick:()=>{p(m),a(!0)},disabled:S}),(0,i.jsx)(sl,{open:e,onOpenChange:e=>!e&&void(p(m),a(!1)),title:o,children:(0,i.jsxs)("div",{className:"space-y-4",children:[n.map(e=>(0,i.jsx)(mM,{option:e,value:h[e.id],onChange:t=>{var s;return s=e.id,void p(e=>({...e,[s]:t}))},disabled:S}
42,e.id)),(0,i.jsx)(v,{type:"button",intent:"primary",className:"w-full",onClick:()=>{r(h),a(!1)},children:"Save"})]})})]})}case"custom-nntp-servers":return(0,i.jsx)(mO,{name:o,description:d,value:C??s??g,onChange:r,disabled:S});case"nab-endpoint":return(0,i.jsx)(m$,{option:t,value:C??s??g,onChange:r,disabled:S});default:return null}},mP={caps:"Could not reach a Newznab API here. Check the URL, including its path.",auth:"The endpoint is reachable, but the API key was rejected.",search:"The endpoint is reachable, but the search request failed."};function m$(e){var t,s,a;let{option:r,value:n,onChange:l,disabled:o}=e,d=r.subOptions??[],c=d.find(e=>"url"===e.id),h=d.find(e=>"apiKey"===e.id),p=n??{},[x,g]=(0,u.useState)(!1),[f,b]=(0,u.useState)(null),v=e=>{b(null),l({...p,...e})},y=null==c||null==(s=c.options)||null==(t=s.find(e=>e.value===p.url))?void 0:t.apiKeyUrl,j=[null==h?void 0:h.description,y&&`[Find your API key](${y})`].filter(Boolean).join(" "),N=async()=>{g(!0),b(null);try{var e,t,s;let a=await fetch(`/builtins/${(null==(e=r.nab)?void 0:e.namespace)??"newznab"}/test`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p.url,apiKey:p.apiKey,preset:null==(t=r.nab)?void 0:t.preset})}),n=await a.json();if(!n.success)throw Error(n.detail||(null==(s=n.error)?void 0:s.message)||"Could not run the test");b(n.data)}catch(e){m.oR.error(e instanceof Error?e.message:"Could not run the test")}finally{g(!1)}};return(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("div",{className:"flex items-end gap-2",children:[(0,i.jsx)("div",{className:"flex-1 min-w-0 space-y-2",children:(null==c||null==(a=c.options)?void 0:a.length)?(0,i.jsx)(mE,{label:c.name,value:p.url,onChange:e=>v({url:e}),options:c.options,required:c.required,disabled:o}):(0,i.jsx)(K,{label:(null==c?void 0:c.name)??"URL",value:p.url??"",onValueChange:e=>v({url:e}),type:"url",required:null==c?void 0:c.required,disabled:o})}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{intent:"gray-subtle",icon:(0,i.jsx)(sm.UWw,{}),onClick:N,loading:x,disabled:o||x,"aria-label":"Test endpoint",className:"shrink-0"}),children:"Test connection"})]}),(null==c?void 0:c.description)&&(0,i.jsx)("div",{className:"text-xs text-[--muted]",children:(0,i.jsx)(l6,{children:c.description})}),h&&(0,i.jsxs)("div",{children:[(0,i.jsx)(G,{label:h.name,value:p.apiKey??"",onValueChange:e=>v({apiKey:e}),required:h.required,disabled:o,autoComplete:"new-password"}),j&&(0,i.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,i.jsx)(l6,{children:j})})]}),f&&(0,i.jsx)(mD,{result:f})]})}function mD(e){var t,s,a,r,n,l;let o,d,{result:c}=e;if(!c.ok){let e=c.stage?mP[c.stage]:void 0;return(0,i.jsx)(lB,{intent:"alert-basic",title:"Test failed",description:(0,i.jsxs)("span",{children:[e?`${e} `:"",null==(r=c.error)?void 0:r.message,(null==(n=c.error)?void 0:n.code)!==void 0&&` (${c.error.code})`]})})}let u=[(o=(null==(l=c.idSearchParams)?void 0:l.movie)??[],d=(null==l?void 0:l.series)??[],0===o.length&&0===d.length?"No ID search, results are matched by title only":o.length===d.length&&o.every(e=>d.includes(e))?`ID search: ${o.join(", ")}`:`ID search: ${o.length?o.join(", "):"none"} (movies), ${d.length?d.join(", "):"none"} (series)`),void 0!==c.resultCount&&`${c.resultCount} results`,(null==(t=c.limits)?void 0:t.max)!==void 0&&`max ${c.limits.max} per request`,(null==(s=c.searchModes)?void 0:s.length)&&`supports ${c.searchModes.join(", ")}`].filter(Boolean);return(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(lB,{intent:"success-basic",title:`Connected to ${(null==(a=c.server)?void 0:a.title)||"the indexer"}`,description:u.join(" \xb7 ")}),c.missingInfoHash&&(0,i.jsx)(lB,{intent:"warning-basic",title:"No hash in the sample result",description:"This indexer may need to download the torrent file for every result, which can affect performance or hit request limits. Consider lowering the results limit if you notice issues."})]})}let mL=e=>{if(!e)return[];try{let t=mT.from(e,"base64").toString("utf-8");return JSON.parse(t)}catch{return[]}};function mO(e){let{name:t,description:s,value:a,onChange:r,disabled:n}=e,[l,o]=(0,u.useState)(!1),[d,c]=(0,u.useState)([]);(0,u.useEffect)(()=>{l&&c(mL(a))},[l,a]);let m=mL(a).length,h=(e,t)=>{c(s=>{let a=[...s],r="up"===t?e-1:e+1;return r<0||r>=a.length?s:([a[e],a[r]]=[a[r],a[e]],a)})},p=(e,t,s)=>{c(a=>a.map((a,r)=>
42r===e?{...a,[t]:s}:a))};return(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center gap-3 bg-[--subtle] p-4 rounded-lg",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsx)("h4",{className:"font-medium mb-1",children:t}),s&&(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:(0,i.jsx)(l6,{children:s})}),m>0&&(0,i.jsxs)("p",{className:"text-sm text-[--brand] mt-1",children:[m," server",1!==m?"s":""," configured"]})]}),(0,i.jsx)(w,{icon:(0,i.jsx)(u4.vwk,{}),intent:"primary-outline",onClick:()=>o(!0),disabled:n,className:"shrink-0"})]}),(0,i.jsxs)(sl,{open:l,onOpenChange:o,title:"Configure NNTP Servers",contentClass:"max-w-4xl",children:[(0,i.jsxs)("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto pr-1",children:[0===d.length?(0,i.jsxs)("div",{className:"text-center py-8 text-[--muted]",children:[(0,i.jsx)(u4.vwk,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),(0,i.jsx)("p",{children:"No servers configured"}),(0,i.jsx)("p",{className:"text-sm",children:"Click the button below to add a server"})]}):d.map((e,t)=>(0,i.jsxs)("div",{className:"border border-[--border] rounded-lg p-4 bg-[--subtle]",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,i.jsxs)("span",{className:"font-medium text-sm",children:["Server ",t+1]}),(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)(w,{icon:(0,i.jsx)(u4.Ucs,{className:"w-4 h-4"}),intent:"gray-subtle",size:"sm",onClick:()=>h(t,"up"),disabled:0===t}),(0,i.jsx)(w,{icon:(0,i.jsx)(u4.Vr3,{className:"w-4 h-4"}),intent:"gray-subtle",size:"sm",onClick:()=>h(t,"down"),disabled:t===d.length-1}),(0,i.jsx)(w,{icon:(0,i.jsx)(u4.G02,{className:"w-4 h-4"}),intent:"alert-subtle",size:"sm",onClick:()=>{c(e=>e.filter((e,s)=>s!==t))}})]})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,i.jsx)(K,{label:"Host",value:e.host??"",onValueChange:e=>p(t,"host",e),placeholder:"news.example.com",required:!0}),(0,i.jsx)(lm,{label:"Port",value:e.port,onValueChange:e=>p(t,"port",e),min:1,max:65535,required:!0}),(0,i.jsx)(K,{label:"Username",autoComplete:"off",value:e.username??"",onValueChange:e=>p(t,"username",e),placeholder:"username",required:!0}),(0,i.jsx)(G,{label:"Password",autoComplete:"new-password",value:e.password??"",onValueChange:e=>p(t,"password",e),placeholder:"password",required:!0}),(0,i.jsx)(lm,{label:"Connections",value:e.connections,onValueChange:e=>p(t,"connections",e),min:1,max:500,required:!0}),(0,i.jsx)("div",{className:"flex items-end pb-1",children:(0,i.jsx)(ni,{label:"Use SSL",value:e.ssl,onValueChange:e=>p(t,"ssl",e),side:"right"})})]})]},t)),(0,i.jsx)(v,{type:"button",intent:"primary-outline",className:"w-full",leftIcon:(0,i.jsx)(u4.OiG,{className:"w-4 h-4"}),onClick:()=>{c(e=>[...e,{username:"",password:"",host:"",port:563,ssl:!0,connections:5}])},children:"Add Server"})]}),(0,i.jsxs)("div",{className:"flex gap-2 mt-4 pt-4 border-t border-[--border]",children:[(0,i.jsx)(v,{type:"button",className:"w-full",intent:"primary-outline",onClick:()=>{o(!1)},children:"Cancel"}),(0,i.jsx)(v,{type:"button",className:"w-full",onClick:()=>{r((e=>{if(0!==e.length)return mT.from(JSON.stringify(e)).toString("base64")})(d.filter(e=>""!==e.host.trim()))),o(!1)},children:"Save"})]})]})]})}function mU(){var e,t,s,a,r;let{status:n}=tj();if(!n)return null;let{setUserData:l,userData:o}=ri(),[d,c]=(0,u.useState)(!1),[m,h]=(0,u.useState)(null),[p,g]=(0,u.useState)({}),[f,b]=(0,u.useState)(!1),[v,y]=(0,u.useState)(""),[j,w]=(0,u.useState)("all"),N=e=>{var t;h(e);let s=null==(t=o.services)?void 0:t.find(t=>t.id===e);g((null==s?void 0:s.credentials)||{}),c(!0)},k=()=>{c(!1),h(null),g({})};(0,u.useEffect)(()=>{let e=Object.keys(n.settings.services),t=o.services??[],s=t.filter(t=>e.includes(t.id)),a=e.filter(e=>!s.some(t=>t.id===e));if(a.length>0||s.length!==t.length){let e=a.map(e=>({id:e,enabled:!1,credentials:{}}));l(t=>({...t,services:[...s,...e]}))}},[n.settings.services,o.services]);let S=(0,lW.FR)((0,lW.MS)(lW.AN),(0,lW.MS)(lW.IG,{activationConstraint:{delay:150,tolerance:8}}));(0,u.useEffect)(()=>{function e(e){f&&e.preventDefault()}function t(){b(!1)}return f?(document.body.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("pointerup",t),document.addEventListener("touchend",t)):document.body.removeEventListener("touchmove",e),()=>{document.body.removeEventListener("touchmove",e),document.removeEventListener("pointerup",t),document.removeEventListener("touchend",t)}},[f]);let C=(null==(e=o.services)?void 0:e.filter(e=>{let t=n.settings.services[e.id];return!!t&&e.enabled&&t.credentials.some(t=>{var s;return!(null==(s=e.credentials)?void 0:s[t.id])&&t.required})}).map(e=>{var t;return null==(t=n.settings.services[e.id])?void 0:t.name}))??[],_=(null==(t=o.services)?void 0:t.map(e=>e.id))||[],A=""!==v.trim()||"all"!==j,R=(o.services??[]).filter(e=>{let t=n.settings.services[e.id];if(!t)return!1;if("all"!==j){let t=mS(e.id),s=mk(e.id);if(!t&&("debrid"===j&&s||"usenet"===j&&!s))return!1}if(v.trim()){let e=v.toLowerCase(),s=(t.name??"").toLowerCase(),a=(t.shortName??"").toLowerCase();if(!s.includes(e)&&!a.includes(e))return!1}return!0});return(0,i.jsxs)(i.Fragment,{children:[C.length>0&&(0,i.jsx)(lB,{intent:"alert",title:"Missing Credentials",description:(0,i.jsxs)(i.Fragment,{children:["The following services are missing credentials:",(0,i.jsx)("div",{className:"flex flex-col gap-1 mt-2",children:C.map(e=>(0,i.jsxs)("div",{className:"flex items-center",children:[(0,i.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-current mr-2"}),e]},e))})]})}),(0,i.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 items-start sm:items-center",children:[(0,i.jsx)(K,{className:"flex-1 w-full sm:w-auto",placeholder:"Search services...",leftIcon:(0,i.jsx)(lV.CKj,{className:"w-4 h-4 text-[--muted]"}),value:v,onValueChange:y}),(0,i.jsx)("div",{className:"flex gap-1.5 shrink-0",children:["all","debrid","usenet"].map(e=>{let t="debrid"===e?"bg-purple-100 text-purple-700 border-purple-300 dark:bg-purple-900/40 dark:text-purple-300 dark:border-purple-700":"usenet"===e?"bg-blue-100 text-blue-700 border-blue-300 dark:bg-blue-500/40 dark:text-blue-300 dark:border-blue-500":"bg-[--subtle-highlight] text-[--foreground] border-[--border]";return(0,i.jsx)("button",{type:"button",onClick:()=>w(e),className:x("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors capitalize",j===e?t:"border-[--border] text-[--muted] hover:bg-[--subtle]"),children:"all"===e?"All":e.charAt(0).toUpperCase()+e.slice(1)},e)})})]}),A?(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["Showing ",R.length," of ",(null==(s=o.services)?void 0:s.length)??0," ","services."," ",(0,i.jsx)("button",{type:"button",className:"underline hover:text-[--foreground] transition-colors",onClick:()=>{y(""),w("all")},children:"Clear filters"})," ","to reorder."]}):(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["Drag to reorder by priority. Enable a service and click"," ",(0,i.jsx)("strong",{children:"Configure"})," to enter credentials."]}),A?(0,i.jsx)("ul",{className:"space-y-2",children:0===R.length?(0,i.jsx)("li",{children:(0,i.jsx)("div",{className:"flex flex-col items-center justify-center py-12",children:(0,i.jsx)("span",{className:"text-lg text-[--muted] font-semibold text-center",children:"No services match your search."})})}):R.map(e=>{let t=n.settings.services[e.id];return t?(0,i.jsx)(mz,{service:e,meta:t,onEdit:()=>N(e.id),onToggleEnabled:t=>{l(s=>({...s,services:(s.services??[]).map(s=>s.id===e.id?{...s,enabled:t}:s)}))}},e.id):null})}):(0,i.jsx)(lW.Mp,{modifiers:[lY.FN],onDragEnd:function(e){let{active:t,over:s}=e;s&&(t.id!==s.id&&l(e=>{let a=e.services??[],r=a.findIndex(e=>e.id===t.id),n=a.findIndex(e=>e.id===s.id),l=(0,lG.be)(a,r,n);return{...e,services:l}}),b(!1))},onDragStart:function(){b(!0)},sensors:S,children:(0,i.jsx)(lG.gB,{items:_,strategy:lG._G,children:(0,i.jsx)("ul",{className:"space-y-2",children:((null==(a=o.services)?void 0:a.length)??0)===0?(0,i.jsx)("li",{children:(0,i.jsx)("div",{className:"flex flex-col items-center justify-center py-12",children:(0,i.jsx)("span",{className:"text-lg text-[--muted] font-semibold text-center",children:"No services found."})})}):null==(r=o.services)?void 0:r.map(e=>{let t=n.settings.services[e.id];return t?(0,i.jsx)(mV,{service:e,meta:t,onEdit:()=>N(e.id),onToggleEnabled:t=>{l(s=>({...s,services:(s.services??[]).map(s=>s.id===e.id?{...s,enabled:t}:s)}))}},e.id):null})})})}),(0,i.jsx)(mq,{open:d,onOpenChange:c,serviceId:m,values:p,onSubmit:e=>{l(t=>{let s={...t};return s.services=(s.services??[]).map(t=>
42t.id===m?{...t,enabled:!0,credentials:e}:t),s}),k()},onClose:k})]})}function mF(e){let{service:t,meta:s,onEdit:a,onToggleEnabled:r,dragHandleProps:n}=e,l=s.credentials.every(e=>e.forced),o=mk(t.id),d=mS(t.id);return(0,i.jsxs)("div",{className:"px-3 py-2.5 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 items-center relative",children:[n?(0,i.jsx)("div",{className:"rounded-full w-6 h-auto self-stretch flex-shrink-0 bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move",...n.attributes,...n.listeners}):(0,i.jsx)("div",{className:"w-6 flex-shrink-0"}),(0,i.jsx)(m_,{serviceId:t.id,shortName:s.shortName}),(0,i.jsxs)("div",{className:"flex-1 flex flex-col justify-center min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,i.jsx)("span",{className:"font-semibold text-sm truncate",children:(null==s?void 0:s.name)||t.id}),d?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full font-medium shrink-0 bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",children:"Debrid"}),(0,i.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full font-medium shrink-0 bg-blue-100 text-blue-700 dark:bg-blue-500/30 dark:text-blue-400",children:"Usenet"})]}):o?(0,i.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full font-medium shrink-0 bg-blue-100 text-blue-700 dark:bg-blue-500/30 dark:text-blue-400",children:"Usenet"}):(0,i.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full font-medium shrink-0 bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",children:"Debrid"})]}),(0,i.jsx)("span",{className:"text-xs text-[--muted] font-normal line-clamp-1",children:(0,i.jsx)(l6,{children:null==s?void 0:s.signUpText})})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,i.jsx)(ni,{value:!!t.enabled,onValueChange:r,disabled:l}),(0,i.jsx)(w,{intent:"gray-outline",size:"sm",onClick:a,disabled:l,icon:(0,i.jsx)(lV.VSk,{})})]})]})}function mz(e){let{service:t,meta:s,onEdit:a,onToggleEnabled:r}=e;return(0,i.jsx)("li",{children:(0,i.jsx)(mF,{service:t,meta:s,onEdit:a,onToggleEnabled:r,dragHandleProps:null})})}function mV(e){let{service:t,meta:s,onEdit:a,onToggleEnabled:r}=e,{attributes:n,listeners:l,setNodeRef:o,transform:d,transition:c,isDragging:u}=(0,lG.gl)({id:t.id}),m={transform:lJ.Ks.Transform.toString(d),transition:c,opacity:u?.5:1};return(0,i.jsx)("li",{ref:o,style:m,children:(0,i.jsx)(mF,{service:t,meta:s,onEdit:a,onToggleEnabled:r,dragHandleProps:{attributes:n,listeners:l}})})}function mq(e){let{open:t,onOpenChange:s,serviceId:a,values:r,onSubmit:n,onClose:l}=e,{status:o}=tj(),[d,c]=(0,u.useState)({});if((0,u.useEffect)(()=>{t&&c(r)},[t,r]),!o||!a)return null;let m=o.settings.services[a],h=m.credentials||[];return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:`Configure ${m.name}`,children:(0,i.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),n(d)},children:[h.map(e=>(0,i.jsx)(mM,{option:{...e,required:!1},value:e.forced||e.default||d[e.id],onChange:t=>c(s=>({...s,[e.id]:t||void 0}))},e.id)),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(v,{type:"button",className:"w-full",intent:"primary-outline",onClick:l,children:"Cancel"}),(0,i.jsx)(v,{type:"submit",className:"w-full",children:"Save"})]})]})})}function mB(e){let{title:t,children:s}=e,[a,r]=(0,u.useState)({x:0,y:0}),n=(0,u.useRef)(null);return(0,i.jsx)("div",{className:"pb-4",children:(0,i.jsx)("div",{ref:n,onMouseMove:e=>{if(!n.current)return;let t=n.current.getBoundingClientRect();r({x:e.clientX-t.left,y:e.clientY-t.top})},className:"contents lg:block relative group/settings-nav",children:s})})}function mK(e){let{title:t,description:s,children:a,className:r,titleClassName:n,action:l,id:o}=e,[d,c]=(0,u.useState)({x:0,y:0}),[m,h]=(0,u.useState)(!1),p=(0,u.useRef)(null);return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(J,{ref:p,id:o,"data-settings-card":!0,className:x("group/settings-card relative lg:bg-gray-950/70 scroll-mt-24",r),onMouseMove:e=>{if(!p.current)return;let t=p.current.getBoundingClientRect();c({x:e.clientX-t.left,y:e.clientY-t.top})},children:[t&&(0,i.jsx)(Z,{className:"p-0 pb-4",children:(0,i.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsx)(Q,{className:x("font-bold tracking-widest uppercase text-sm transition-colors duration-300 group-hover/settings-card:text-white group-hover/settings-card:from-brand-500/10 group-hover/settings-card:to-purple-500/5 px-4 py-2 border bg-transparent bg-gradient-to-br bg-[--subtle] border-t-0 border-l-0 w-fit roun
42ded-tl-md rounded-br-md",n),children:t}),s&&(0,i.jsx)(X,{className:"px-4 mt-2",children:s})]}),l&&(0,i.jsx)("div",{className:"flex-shrink-0 px-4 pt-2",children:l})]})}),(0,i.jsx)(ee,{className:x(!t&&"pt-4","space-y-3 flex-wrap"),children:a})]})})}function mH(e){let{label:t,help:s,disabled:a,value:r,onValueChange:n,placeholder:l,min:o=0}=e,[d,c]=u.useState(()=>nA(r)),[m,h]=u.useState(null);return u.useEffect(()=>{n_(d)!==r&&(c(nA(r)),h(null))},[r]),(0,i.jsx)(K,{label:t,help:s,error:m??void 0,disabled:a,value:d,placeholder:l??'e.g. "1.5s", "500ms", "2s"',onValueChange:e=>{c(e);let t=n_(e);null==t||t<o?h("Invalid duration. Use e.g. 500ms, 1.5s, 2s, 1m."):(h(null),n(t))}})}function mW(){var e,t,s,a,r,n,l,o,d,c,u,m,h,p,x,g,f,b,v,y,j,w,N,k,S,C,_,A,R,T,I,E,M,P,$,D,L,O,U,F,z,V,q,B,K;let{status:H}=tj(),{userData:W,setUserData:G}=ri();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(mK,{title:"Service Wrap",id:"serviceWrap",description:"Wrap P2P results from external addons through your own debrid services, without sharing your credentials with those addons. Works with P2P-capable marketplace addons and custom addons added via a custom manifest URL.",children:[(0,i.jsx)(ni,{label:"Enable Service Wrap",side:"right",value:(null==(e=W.serviceWrap)?void 0:e.enabled)??!1,onValueChange:e=>{G(t=>({...t,serviceWrap:{...t.serviceWrap,enabled:e}}))},help:"When enabled, AIOStreams configures supported addons to return raw torrents, then resolves them through your debrid services."}),(null==(t=W.serviceWrap)?void 0:t.enabled)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ni,{label:"Reconfigure Service",side:"right",value:(null==(s=W.serviceWrap)?void 0:s.reconfigureService)??!1,onValueChange:e=>{G(t=>({...t,serviceWrap:{...t.serviceWrap,reconfigureService:e}}))},help:"Re-processes debrid results from selected addons through your configured services. Useful if the addon doesn't support returning P2P results.",moreHelp:"Only works when the torrent hash can be extracted from the stream - not all debrid results will be eligible."}),(0,i.jsx)(li,{label:"Wrap Addons",help:"Select which addons to wrap. Leave empty to wrap all applicable addons.",options:(W.presets??[]).filter(e=>{var t;let s=null==H?void 0:H.settings.presets.find(t=>t.ID===e.type);return(null==s||!s.BUILTIN)&&!!((null==s?void 0:s.ID)==="custom"||(null==s?void 0:s.SUPPORTED_STREAM_TYPES.includes("p2p"))||(null==(t=W.serviceWrap)?void 0:t.reconfigureService)&&(null==s?void 0:s.SUPPORTED_STREAM_TYPES.includes("debrid")))}).map(e=>({label:e.options.name||e.type,value:e.instanceId,textValue:e.options.name})),multiple:!0,emptyMessage:"No supported addons found",value:(null==(a=W.serviceWrap)?void 0:a.presets)??[],onValueChange:e=>{G(t=>({...t,serviceWrap:{...t.serviceWrap,presets:e.length>0?e:void 0}}))}}),(0,i.jsx)(li,{label:"Processing Services",help:"Select which debrid services to use for processing wrapped torrents. Leave empty to use all enabled services.",options:(W.services??[]).filter(e=>e.enabled&&ad.includes(e.id)&&![as,aa,ar,at].includes(e.id)).map(e=>{var t,s;return{label:(null==H||null==(t=H.settings.services[e.id])?void 0:t.name)??e.id,value:e.id,textValue:(null==H||null==(s=H.settings.services[e.id])?void 0:s.name)??e.id}}),multiple:!0,emptyMessage:"No supported services found",value:(null==(r=W.serviceWrap)?void 0:r.services)??[],onValueChange:e=>{G(t=>({...t,serviceWrap:{...t.serviceWrap,services:e.length>0?e:void 0}}))}})]})]}),(0,i.jsxs)(mK,{title:"Failover",id:"failover",description:"When a stream fails to play, AIOStreams automatically tries the next best result from your sorted list. Works with built-in Usenet and debrid results (those AIOStreams resolves itself).",children:[(0,i.jsx)(ni,{label:"Enable",side:"right",value:(null==(n=W.failover)?void 0:n.enabled)??!1,onValueChange:e=>{G(t=>({...t,failover:{...t.failover,enabled:e}}))}}),(0,i.jsx)(li,{label:"Failover Content Types",help:"Which kinds of result may be used as failover targets.",disabled:!(null==(l=W.failover)?void 0:l.enabled),options:[{label:"Usenet",value:"usenet",textValue:"Usenet"},{label:"Debrid",value:"debrid",textValue:"Debrid"}],multiple:!0,emptyMessage:"Select at least one content type",value:(null==(o=W.failover)?void 0:o.contentTypes)??["usenet"],onValueChange:e=>{G(t=>({...t,failover:{...t.failover,contentTypes:e}}))}}),(0,i.jsx)(ni,{label:"Allow Cross-Type Failover",side:"right",disabled:!(null==(d=W.failover)?void 0:d.enabled),help:"Allow a click on one kind (e.g. Usenet) to fall through into a different kind (e.g. debrid) that is next in the ranked list. When off, failover stays within the clicked item's own kind.",value:(null==(c=W.failover)?void 0:c.allowCrossType)??!1,onValueChange:e=>{G(t=>({...t,failover:{...t.failover,allowCrossType:e}}))}}),(0,i.jsx)(ni,{label:"Include External Addon Targets",side:"right",disabled:!(null==(u=W.failover)?void 0:u.enabled),help:"Also use non-owned debrid links from external addons (on the addon's own host) as failover targets. These are resolved by probing: a redirect to the addon's own host is treated as a dead link, a redirect to a CDN as success. A direct click on an external stream still won't fail over.",value:(null==(m=W.failover)?void 0:m.includeExternalFailover)??!1,onValueChange:e=>{G(t=>({...t,failover:{...t.failover,includeExternalFailover:e}}))}}),(0,i.jsx)(lm,{label:"Max Failover Attempts",help:(0,i.jsxs)(i.Fragment,{children:["How many unique fallback results to try before giving up. Maximum is set by ",(0,i.jsx)("code",{children:"MAX_FAILOVER_ATTEMPTS"})," (currently"," ",(null==H||null==(p=H.settings)||null==(h=p.limits)?void 0:h.maxFailoverAttempts)??5,")."]}),min:1,max:(null==H||null==(g=H.settings)||null==(x=g.limits)?void 0:x.maxFailoverAttempts)??5,defaultValue:3,disabled:!(null==(f=W.failover)?void 0:f.enabled),value:(null==(b=W.failover)?void 0:b.maxAttempts)??3,onValueChange:e=>{var t,s;let a=(null==H||null==(s=H.settings)||null==(t=s.limits)?void 0:t.maxFailoverAttempts)??5;G(t=>({...t,failover:{...t.failover,maxAttempts:Math.min(a,Math.max(1,Number(e||3)))}}))}}),(0,i.jsx)(lm,{label:"Same-Release Failover Attempts",help:"How many alternative sources of the SAME release (harvested by deduplicator merging) to try per release before moving to a different release. 0 disables same-release failover. Bounded by the overall Max Failover Attempts.",min:0,max:(null==H||null==(y=H.settings)||null==(v=y.limits)?void 0:v.maxFailoverAttempts)??5,defaultValue:2,disabled:!(null==(j=W.failover)?void 0:j.enabled),value:(null==(w=W.failover)?void 0:w.sameReleaseLimit)??2,onValueChange:e=>{var t,s;let a=(null==H||null==(s=H.settings)||null==(t=s.limits)?void 0:t.maxFailoverAttempts)??5;G(t=>({...t,failover:{...t.failover,sameReleaseLimit:Math.min(a,Math.max(0,Number(e??2)))}}))}}),(0,i.jsx)(ni,{label:"Only Same-Release Failover",side:"right",disabled:!(null==(N=W.failover)?void 0:N.enabled),help:"Never fail over to a different release, even if same-release alternatives run out.",value:(null==(k=W.failover)?void 0:k.onlySameReleaseFailover)??!1,onValueChange:e=>{G(t=>({...t,failover:{...t.failover,onlySameReleaseFailover:e}}))}}),(0,i.jsx)(lm,{label:"Parallel Attempts",help:(0,i.jsxs)(i.Fragment,{children:["How many attempts to run at once. 1 keeps the classic sequential behaviour (try one, then the next). Higher values race several attempts and take the first that proves healthy; the losing attempts are cancelled and cleaned up (usenet probes are aborted; debrid downloads added by a loser are removed, except private torrents). Maximum is set by ",(0,i.jsx)("code",{children:"MAX_PARALLEL_ATTEMPTS"})," ","(currently ",(null==H||null==(C=H.settings)||null==(S=C.limits)?void 0:S.maxParallelAttempts)??2,")."]}),min:1,max:(null==H||null==(A=H.settings)||null==(_=A.limits)?void 0:_.maxParallelAttempts)??2,defaultValue:1,disabled:!(null==(R=W.failover)?void 0:R.enabled),value:(null==(T=W.failover)?void 0:T.parallel)??1,onValueChange:e=>{var t,s;let a=(null==H||null==(s=H.settings)||null==(t=s.limits)?void 0:t.maxParallelAttempts)??2;G(t=>({...t,failover:{...t.failover,parallel:Math.min(a,Math.max(1,Number(e||1)))}}))}}),((null==(I=W.failover)?void 0:I.parallel)??1)>1&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(mH,{label:"Backup delay",help:"How long the clicked item runs alone before backups start in parallel. A head start that keeps provider load down. Accepts values like 1.5s or 500ms.",disabled:!(null==(E=W.failover)?void 0:E.enabled),value:(null==(M=W.failover)?void 0:M.staggerMs)??1e3,onValueChange:e=>{G(t=>({...t,failover:{...t.failover,staggerMs:e}}))}}),(0,i.jsx)(mH,{label:"Same-release backup delay",help:"Like Backup delay, but between attempts for the SAME release (alternative sources of the clicked release, harvested by deduplicator merging). These are essentially the same release, so no head start is needed â defaults to 0.",disabled:!(null==(P=W.failover)?void 0:P.enabled),value:(null==($=W.failover)?void 0:$.duplicateStaggerMs)??0,onValueChange:e=>{G(t=>({...t,failover:{...t.failover,duplicateStaggerMs:e}}))}}),(0,i.jsx)(mH,{label:"Preferred-item grace",help:"Once a backup is healthy, how long to wait for the item you actually clicked (or a higher-ranked one still in flight) to catch up before settling for the backup. 0 = take the first healthy result.",disabled:!(null==(D=W.failover)?void 0:D.enabled),value:(null==(L=W.failover)?void 0:L.preferredGraceMs)??2e3,onValueChange:e=>{G(t=>({...t,failover:{...t.failover,preferredGraceMs:e}}))}}),(0,i.jsx)(mH,{label:"Max wait",help:"Overall deadline for the parallel chain before giving up and serving an error.",min:1e3,disabled:!(null==(O=W.failover)?void 0:O.enabled),value:(null==(U=W.failover)?void 0:U.maxWaitMs)??3e4,onValueChange:e=>{G(t=>({...t,failover:{...t.failover,maxWaitMs:e}}))}})]}),(0,i.jsx)(ni,{label:"During Pre-cache",side:"right",disabled:!(null==(F=W.failover)?void 0:F.enabled),help:"Also apply failover when pre-caching the next episode's streams in the background. When off, pre-cache requests ski
42p failover entirely.",value:(null==(z=W.failover)?void 0:z.precacheFailover)??!1,onValueChange:e=>{G(t=>({...t,failover:{...t.failover,precacheFailover:e}}))}}),(0,i.jsx)(nc,{label:"Failover Position",disabled:!(null==(V=W.failover)?void 0:V.enabled),help:"Where in the processing pipeline the fallback chain is built. All positions are after sorting. Earlier positions draw from a larger pool of streams but may include streams that would later be removed by SEL filters or limits.",options:[{label:"Before SEL",value:"beforeSEL"},{label:"Before Limiting",value:"beforeLimiting"},{label:"Last (default)",value:"last"}],value:(null==(q=W.failover)?void 0:q.position)??"last",onValueChange:e=>{G(t=>({...t,failover:{...t.failover,position:e}}))}})]}),(0,i.jsx)(mK,{title:"Auto Remove Downloads",id:"autoRemoveDownloads",description:"Automatically removes the torrent/NZB from your debrid dashboard after generating a playback link. Only works for built-in addons and supported services â private torrents are not removed.",children:(0,i.jsx)(ni,{label:"Enable",side:"right",value:W.autoRemoveDownloads??!1,onValueChange:e=>{G(t=>({...t,autoRemoveDownloads:e}))}})}),(0,i.jsx)(mK,{title:"Check Library",id:"checkOwned",description:"When enabled, built-in addons and service wrapped addons will check if search results already exist in your debrid library and mark them accordingly. This applies to both torrent and usenet results.",children:(0,i.jsx)(ni,{label:"Enable",side:"right",value:W.checkOwned??!0,onValueChange:e=>{G(t=>({...t,checkOwned:e}))}})}),(0,i.jsxs)(mK,{title:"Cache and Play",id:"cacheAndPlay",description:"Allows uncached streams to wait for the download to finish before playing, instead of showing a 'try again' message. Only works for built-in addons â recommended for Usenet since downloads typically finish quickly.",children:[(0,i.jsx)(ni,{label:"Enable",side:"right",value:null==(B=W.cacheAndPlay)?void 0:B.enabled,onValueChange:e=>{G(t=>({...t,cacheAndPlay:{...t.cacheAndPlay,enabled:e}}))}}),(0,i.jsx)(li,{label:"Stream Types",options:["usenet","torrent"].map(e=>({label:e,value:e,textValue:e})),multiple:!0,emptyMessage:"No stream types found",defaultValue:["usenet"],value:(null==(K=W.cacheAndPlay)?void 0:K.streamTypes)??["usenet"],onValueChange:e=>{G(t=>({...t,cacheAndPlay:{...t.cacheAndPlay,streamTypes:e}}))}})]})]})}let mG="Provided by this instance (enter your own to override)";function mY(){let{status:e}=tj(),{userData:t,setUserData:s}=ri(),a=null==e?void 0:e.settings.metadata,r=!!(null==a?void 0:a.tmdb.accessToken),n=!!(null==a?void 0:a.tmdb.apiKey),l=!!(null==a?void 0:a.tvdb.apiKey);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(mK,{id:"tmdb",title:"TMDB",description:`Optionally provide your TMDB API Key and Read Access Token here. AIOStreams only needs one of them for title matching and its recommended and precaching to be able to 43 determine when to move to the next season. Some addons in the marketplace will require one or the other too.`,children:[(0,i.jsx)(G,{autoComplete:"new-password",label:"TMDB Read Access Token",help:(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)("p",{children:["You can get it from your"," ",(0,i.jsxs)("a",{href:"https://www.themoviedb.org/settings/api",target:"_blank",className:"text-[--brand] hover:underline",rel:"noopener noreferrer",children:["TMDB Account Settings."," "]}),"Make sure to copy the Read Access Token and not the 32 character API Key."]})}),required:!r&&!n,value:t.tmdbAccessToken,placeholder:r?mG:"Enter your TMDB access token",onValueChange:e=>{s(t=>({...t,tmdbAccessToken:e}))}}),(0,i.jsx)(G,{autoComplete:"new-password",label:"TMDB API Key",help:(0,i.jsxs)("span",{children:["You can get it from your"," ",(0,i.jsxs)("a",{href:"https://www.themoviedb.org/settings/api",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:["TMDB Account Settings."," "]}),"Make sure to copy the 32 character API Key and not the Read Access Token."]}),placeholder:n?mG:"Enter your TMDB API Key",value:t.tmdbApiKey,onValueChange:e=>{s(t=>({...t,tmdbApiKey:e}))}})]}),(0,i.jsx)(mK,{id:"tvdbApiKey",title:"TVDB",description:"Provide your TVDB API key to also fetch metadata from TVDB.",children:(0,i.jsx)(G,{autoComplete:"new-password",label:"TVDB API Key",value:t.tvdbApiKey,placeholder:l?mG:"Enter your TVDB API Key",help:(0,i.jsxs)("span",{children:["Sign up for a ",(0,i.jsx)("b",{children:"free"})," API Key at"," ",(0,i.jsxs)("a",{href:"https://www.thetvdb.com/api-information",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:["TVDB."," "]})]}),onValueChange:e=>{s(t=>({...t,tvdbApiKey:e}))}})})]})}function mJ(){let{userData:e,setUserData:t}=ri();return(0,i.jsxs)(mK,{title:"Poster Service",description:"Select a poster service to use for catalogs that support it.",children:[(0,i.jsx)(nc,{label:"Poster Service",options:[{label:"None",value:"none"},{label:"RPDB",value:"rpdb"},{label:"TOP Posters",value:"top-poster"},{label:"AIOratings",value:"aioratings"},{label:"OpenPosterDB",value:"openposterdb"}],value:e.posterService||"rpdb",onValueChange:e=>{t(t=>({...t,posterService:e}))},defaultValue:"rpdb"}),(!e.posterService||"rpdb"===e.posterService)&&(0,i.jsx)(G,{autoComplete:"new-password",label:"RPDB API Key",help:(0,i.jsxs)("span",{children:["Get your API Key from"," ",(0,i.jsx)("a",{href:"https://ratingposterdb.com/api-key/",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"here"})]}),value:e.rpdbApiKey,onValueChange:e=>{t(t=>({...t,rpdbApiKey:e}))}}),"top-poster"===e.posterService&&(0,i.jsx)(G,{autoComplete:"new-password",label:"TOP Posters API Key",help:(0,i.jsxs)("span",{children:["Get your API Key from"," ",(0,i.jsx)("a",{href:"https://api.top-posters.com/",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"TOP Posters"})]}),value:e.topPosterApiKey,onValueChange:e=>{t(t=>({...t,topPosterApiKey:e}))}}),"aioratings"===e.posterService&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(G,{autoComplete:"new-password",label:"AIOratings API Key",help:(0,i.jsxs)("span",{children:["Get your API Key from"," ",(0,i.jsx)("a",{href:"https://aioratings.com",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"here"})]}),value:e.aioratingsApiKey,onValueChange:e=>{t(t=>({...t,aioratingsApiKey:e}))}}),(0,i.jsx)(K,{label:"AIOratings Profile ID",help:(0,i.jsxs)("span",{children:["Custom profiles are a premium feature that lets you design your own poster layout. Premium users can map their API key and default posters dynamically from the"," ",(0,i.jsx)("a",{href:"https://aioratings.com",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"AIOratings website"}),'. Free users can leave this as "default".']}),value:e.aioratingsProfileId||"default",placeholder:"default",onValueChange:e=>{t(t=>({...t,aioratingsProfileId:e}))}})]}),"openposterdb"===e.posterService&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(G,{autoComplete:"new-password",label:"OpenPosterDB API Key",help:(0,i.jsxs)("span",{children:["Get your API Key from"," ",(0,i.jsx)("a",{href:"https://openposterdb.com",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"here"})]}),value:e.openposterdbApiKey,onValueChange:e=>{t(t=>({...t,openposterdbApiKey:e}))}}),(0,i.jsx)(K,{label:"OpenPosterDB URL",help:(0,i.jsx)("span",{children:"Custom base URL for OpenPosterDB. Leave empty to use the default."}),value:e.openposterdbUrl||"",placeholder:"https://openposterdb.com",onValueChange:e=>{t(t=>({...t,openposterdbUrl:e}))}}),(0,i.jsx)(K,{label:"OpenPosterDB Custom Parameters",help:(0,i.jsxs)("span",{children:["Optional query string appended to every poster to customise it (e.g. ratings, badge size and position). Enter it without the leading ",(0,i.jsx)("code",{children:"?"}),", for example"," ",(0,i.jsx)("code",{children:"ratings_limit=2&badge_size=l&position=br"}),". See the"," ",(0,i.jsx)("a",{href:"https://github.com/PNRxA/openposterdb#readme",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"available parameters"}),"."]}),value:e.openposterdbParameters||"",placeholder:"ratings_limit=2&badge_size=l&position=br",onValueChange:e=>{t(t=>({...t,openposterdbParameters:e}))}})]}),(0,i.jsx)(ni,{label:"Use Poster Service for Library/Continue Watching",side:"right",value:e.usePosterServiceForMeta||!1,onValueChange:e=>{t(t=>({...t,usePosterServiceForMeta:e}))},disabled:"none"===e.posterService||!e.rpdbApiKey&&!e.topPosterApiKey&&!e.aioratingsApiKey&&!e.openposterdbApiKey,help:(0,i.jsx)("span",{children:"If enabled, AIOStreams will use the selected poster service to fetch posters for single meta items â which generally means items in your Library and Continue Watching."})}),(0,i.jsx)(ni,{label:"Use Poster Redirect API",side:"right",disabled:"none"===e.posterService||!e.rpdbApiKey&&!e.topPosterApiKey&&!e.aioratingsApiKey&&!e.openposterdbApiKey,help:(0,i.jsx)("span",{children:"If enabled, poster URLs will first contact AIOStreams and then be redirected to the selected poster service. This allows fallback posters to be used if the selected poster service is down or does not have a poster for that item. It can however cause a minimal slowdown due to having to contact AIOStreams first."}),value:e.usePosterRedirectApi||!1,onValueChange:e=>{t(t=>({...t,usePosterRedirectApi:e}))}})]})}function mZ(){return(0,i.jsx)(ng,{className:"space-y-4 p-4 sm:p-8",children:(0,i.jsx)(mQ,{})})}function mQ(){let{mode:e}=sF(),{isInherited:t,hasParent:s}=ro(),{tab:a,setTab:r}=rv("services");return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex items-center w-full",children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("h2",{children:"Services"}),s&&t("services")&&(0,i.jsx)(my,{section:"services"})]}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Configure your debrid, metadata, and poster services."})]}),(0,i.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,i.jsx)(mg,{})})]}),(0,i.jsx)(mv,{tabs:[{value:"services",label:"Services",icon:(0,i.jsx)(lV.LIi,{className:"w-4 h-4 shrink-0"}),content:(0,i.jsx)(mU,{})},{value:"builtin",label:"Built-in",icon:(0,i.jsx)(lV.VSk,{className:"w-4 h-4 shrink-0"}),content:"pro"===e?(0,i.jsx)(mW,{}):(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,i.jsx)(lV.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,i.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Built-in addon settings are only available in Advanced mode."})]})},{value:"metadata",label:"Metadata",icon:(0,i.jsx)(lV.Hbo,{className:"w-4 h-4 shrink-0"}),content:(0,i.jsx)(mY,{})},{value:"posters",label:"Posters",icon:(0,i.jsx)(lV.fZZ,{className:"w-4 h-4 shrink-0"}),content:(0,i.jsx)(mJ,{})}],activeTab:a,onTabChange:r,defaultMobileOpen:"services"})]})}var mX=s(56738),m0=s(70254),m1=s(10820),m2=s(55008),m3=s(26286);function m5(e){var t,s,a;let{preset:r,onAdd:n}=e,[l,o]=(0,u.useState)(!1);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"border border-[rgb(255_255_255_/_5%)] relative overflow-hidden bg-gray-900/70 rounded-xl p-3 flex flex-col h-full",children:[r.BUILTIN&&(0,i.jsx)("div",{className:"absolute -right-[30px] top-[20px] bg-[rgb(var(--color-brand-500))] text-white text-xs font-semibold py-1 w-[120px] text-center transform rotate-45 shadow-md z-[2] cursor-pointer hover:bg-[rgb(var(--color-brand-600))] transition-colors",onClick:()=>o(!0),title:"Click to learn more about built-in addons",children:"Built-in"}),(0,i.jsxs)("div",{className:"z-[1] relative flex flex-col flex-1 gap-3",children:[(0,i.jsxs)("div",{className:"flex gap-3 pr-16",children:["custom"===r.ID?(0,i.jsx)("div",{className:"relative rounded-md size-12 bg-gray-950 overflow-hidden flex items-center justify-center",children:(0,i.jsx)(m3.A,{className:"w-6 h-6 text-[--brand]"})}):r.LOGO?(0,i.jsx)("div",{className:"relative rounded-md size-12 bg-gray-900 overflow-hidden",children:(0,i.jsx)("img",{src:r.LOGO,alt:r.NAME,className:"w-full h-full object-cover"})}):(0,i.jsx)("div",{className:"relative rounded-md size-12 bg-gray-950 overflow-hidden flex items-center justify-center",children:(0,i.jsx)("p",{className:"text-2xl font-bold",children:r.NAME[0].toUpperCase()})}),(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"font-semibold line-clamp-1",children:r.NAME}),(0,i.jsx)("p",{className:"text-xs line-clamp-1 tracking-wide opacity-30",children:r.ID})]})]}),r.DESCRIPTION&&(0,i.jsx)(P,{trigger:(0,i.jsx)("p",{className:"text-sm text-[--muted] line-clamp-2 cursor-pointer",children:(0,i.jsx)(l6,{children:r.DESCRIPTION})}),children:(0,i.jsx)("p",{className:"text-sm",children:(0,i.jsx)(l6,{children:r.DESCRIPTION})})}),(0,i.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[null==(t=r.SUPPORTED_SERVICES)?void 0:t.map(e=>{let t=ap[e];return(0,i.jsx)(t5,{side:"top",trigger:(0,i.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-[--brand]/10 text-[--brand] border border-[--brand]/20",children:(null==t?void 0:t.shortName)||e}),children:(null==t?void 0:t.name)||e},e)}),null==(s=r.SUPPORTED_RESOURCES)?void 0:s.map(e=>(0,i.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-blue-500/10 text-blue-300 border border-blue-400/20",children:e},e)),null==(a=r.SUPPORTED_STREAM_TYPES)?void 0:a.map(e=>(0,i.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-green-500/10 text-green-400 border border-green-500/20",children:e},e))]}),(0,i.jsx)("div",{className:"flex-1"}),r.DISABLED?(0,i.jsx)("div",{className:"mt-auto",children:(0,i.jsx)(lB,{intent:"alert",className:"w-full overflow-x-auto whitespace-nowrap",description:(0,i.jsx)(l6,{children:r.DISABLED.reason})})}):(0,i.jsx)("div",{className:"mt-auto",children:(0,i.jsx)(v,{size:"md",className:"w-full",intent:"primary-subtle",onClick:n,children:"Configure"})})]})]}),(0,i.jsx)(sl,{open:l,onOpenChange:o,title:"What are Built-in Addons?",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)("p",{className:"text-sm leading-relaxed",children:"Built-in addons are addons whose code lives directly inside AIOStreams. You still install and configure them from the marketplace just like any other addon (such as Comet or Torrentio), but they run locally on this AIOStreams instance."}),(0,i.jsxs)("div",{className:"bg-[--subtle] rounded-lg p-3 space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:"Why does this matter?"}),(0,i.jsxs)("ul",{className:"text-sm text-[--muted] space-y-1.5 list-disc list-inside",children:[(0,i.jsx)("li",{children:"Not affected by rate limits from other addon servers"}),(0,i.jsx)("li",{children:"Faster response times since there's no network delay"}),(0,i.jsx)("li",{children:"Exclusive to AIOStreams and can't be installed directly to Stremio"})]})]}),(0,i.jsx)("p",{className:"text-xs text-[--muted] italic",children:"Think of it like having the addon server built into AIOStreams itself!"})]})})]})}function m4(e){let{open:t,onOpenChange:s,mode:a,presetMetadata:r,initialValues:n={},onSubmit:l}=e,{mode:o}=sF(),[d,c]=(0,u.useState)(n);(0,u.useEffect)(()=>{t?c(n):setTimeout(()=>{c(n)},150)},[t,n]);let h=(null==r?void 0:r.OPTIONS)||[];"noob"===o&&(h=h.filter(e=>(null==e?void 0:e.showInSimpleMode)!==!1&&(null==e?void 0:e.advanced)!==!0));let p=h.every(e=>{var t;if(!e.required)return!0;let s=null==(t=d.options)?void 0:t[e.id];return"boolean"===e.type?"boolean"==typeof s:"nab-endpoint"===e.type?!!(null==s?void 0:s.url):null!=s&&""!==s});
43return(0,i.jsx)(sl,{open:t,description:(0,i.jsx)(l6,{children:null==r?void 0:r.DESCRIPTION}),onOpenChange:s,title:"add"===a?`Install ${null==r?void 0:r.NAME}`:`Edit ${null==r?void 0:r.NAME}`,children:(0,i.jsxs)("form",{className:"space-y-4",onSubmit:function(e){for(let s of(e.preventDefault(),h))if(s.constraints){var t;let e=null==(t=d.options)?void 0:t[s.id];if("string"==typeof e){if(s.constraints.min&&e.length<s.constraints.min)return m.oR.error(`${s.name} must be at least ${s.constraints.min} characters`),!1;if(s.constraints.max&&e.length>s.constraints.max)return m.oR.error(`${s.name} must be at most ${s.constraints.max} characters`),!1}else if("number"==typeof e){if(s.constraints.min&&e<s.constraints.min)return m.oR.error(`${s.name} must be at least ${s.constraints.min}`),!1;if(s.constraints.max&&e>s.constraints.max)return m.oR.error(`${s.name} must be at most ${s.constraints.max}`),!1}else if("multi-select"===s.type){if(s.constraints.max&&e.length>s.constraints.max)return m.oR.error(`${s.name} must be at most ${s.constraints.max} items`),!1;if(s.constraints.min&&e.length<s.constraints.min)return m.oR.error(`${s.name} must be at least ${s.constraints.min} items`),!1}}p?l(d):m.oR.error("Please fill in all required fields")},children:[h.map(e=>{var t;return(0,i.jsx)("div",{className:"mb-2",children:(0,i.jsx)(mM,{option:e,value:null==(t=d.options)?void 0:t[e.id],onChange:t=>c(s=>({...s,options:{...s.options,[e.id]:t}})),disabled:!1})},e.id)}),(0,i.jsx)(v,{className:"w-full mt-2",type:"submit",disabled:!p,children:"add"===a?"Install":"Update"})]})})}let m6="true";function m9(){var e;let{userData:t,setUserData:s}=ri(),a=(null==(e=t.groups)?void 0:e.groupings)??[],r=(0,u.useCallback)(e=>{let t=[...e];t.length>0&&!t[0].condition&&(t[0]={...t[0],condition:m6}),s(e=>({...e,groups:{...e.groups,groupings:t}}))},[s]),n=l1(a,r),l=(e,t)=>{r(a.map((s,a)=>a===e?{...s,...t}:s))};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"text-sm text-[--muted] mb-2",children:"Each row is one group: the addons it fetches from, and the condition deciding whether it is used. Group 1 always runs, so its condition is fixed."}),(0,i.jsx)(l2,{rows:n,children:a.map((e,s)=>{let r,o=n.keyAt(s);return(0,i.jsxs)(l3,{id:o,children:[(0,i.jsx)("div",{className:l0,children:(0,i.jsx)(l5,{rows:n,index:s})}),(0,i.jsx)("div",{className:"md:flex-[2] min-w-0",children:(0,i.jsx)(li,{multiple:!0,maxDisplayedItems:3,value:e.addons,options:(r=new Set(a.flatMap((e,t)=>t!==s?e.addons:[])),t.presets.filter(e=>!r.has(e.instanceId)).map(e=>({label:e.options.name,value:e.instanceId,textValue:e.options.name}))),emptyMessage:"You haven't installed any addons yet or they are already in a group","aria-label":"Addons",placeholder:"Select addons",onValueChange:e=>{l(s,{addons:e})}})}),(0,i.jsx)("div",{className:"md:flex-[3] min-w-0",children:(0,i.jsx)(K,{value:0===s?m6:e.condition,disabled:0===s,"aria-label":"Condition",placeholder:"count(totalStreams) < 4",onValueChange:e=>{l(s,{condition:e})}})})]},o)})}),(0,i.jsx)("div",{className:"mt-2 flex gap-2 items-center",children:(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(lZ.OiG,{}),"aria-label":"Add group",onClick:()=>r([...a,{addons:[],condition:0===a.length?m6:""}])}),children:"Add group"})})]})}function m8(){var e,t,s,a,r,n;let{userData:l,setUserData:o}=ri(),[d,c]=(0,u.useState)(()=>{var e,t;return(null==(e=l.dynamicAddonFetching)?void 0:e.enabled)?"dynamic":(null==(t=l.groups)?void 0:t.enabled)?"groups":"default"}),m=['count(resolution(totalStreams, "2160p")) > 0 or totalTimeTaken > 5000',"queryType == 'anime' ? (count(resolution(totalStreams, '1080p')) > 0 or totalTimeTaken > 5000) : false","'addon' in queriedAddons and (totalTimeTaken >= 6000 or count(totalStreams) >= 5)","count(seeders(size(totalStreams, '5GB', '20GB'), 50)) > 0","queryType == 'movie' ? count(cached(resolution(totalStreams, '2160p'))) > 0 : count(resolution(totalStreams, '1080p')) >= 2","count(cached(quality(totalStreams, 'Bluray REMUX', 'Bluray', 'WEB-DL'))) > 0"];return(0,i.jsxs)(mK,{title:"Addon Fetching Strategy",id:"fetchStrategy",description:"Choose how streams are fetched from your addons",children:[(0,i.jsx)(nc,{label:"Strategy",value:d,onValueChange:e=>{c(e),o(t=>({...t,groups:{...t.groups,enabled:"groups"===e},dynamicAddonFetching:{...t.dynamicAddonFetching,enabled:"dynamic"===e}}))},options:[{label:"Default",value:"default"},{label:"Dynamic",value:"dynamic"},{label:"Groups",value:"groups"}]}),(0,i.jsx)("div",{className:"text-sm text-[--muted] mt-2 mb-4",children:{default:"Fetch from all addons simultaneously and wait for all addons to finish fetching before returning results.",groups:"Organise addons into groups with conditions. Each group can be evaluated based on results from previous groups. Read the [docs](
43https://docs.aiostreams.viren070.me/guides/groups) for more information.",dynamic:"All addons start fetching at the same time. As soon as any addon returns results, the exit condition is evaluated. If the condition is met, results are returned immediately and any remaining addon results are ignored."}[d]}),"groups"===d&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nc,{label:"Group Behaviour",value:(null==(e=l.groups)?void 0:e.behaviour)??"parallel",onValueChange:e=>{o(t=>({...t,groups:{...t.groups,behaviour:e}}))},options:[{label:"Parallel",value:"parallel"},{label:"Sequential",value:"sequential"}],help:(null==(t=l.groups)?void 0:t.behaviour)==="sequential"?'Sequential: Start with group 1. Only fetch from group 2 if its condition evaluates to true based on group 1\'s results (e.g., "count(totalStreams) < 4"). Continue this pattern for subsequent groups.':"Parallel: Begin fetching from all groups simultaneously. When group 1's results arrive, evaluate group 2's condition. If true, wait for group 2's results; if false, return results without waiting."}),(null==(s=l.groups)?void 0:s.behaviour)!=="sequential"&&(0,i.jsx)(nc,{label:"When a Condition Fails",value:(null==(a=l.groups)?void 0:a.onConditionFailure)??"stop",onValueChange:e=>{o(t=>({...t,groups:{...t.groups,onConditionFailure:e}}))},options:[{label:"Stop",value:"stop"},{label:"Skip group and keep checking",value:"skip"},{label:"Keep everything already finished",value:"includeFinished"}],help:{stop:"Discard this group and every group after it, including any results they had already returned.",skip:"Discard this group, then carry on checking the remaining groups' conditions as normal. A later group is included only if its condition passes and it has already finished. Nothing is waited on.",includeFinished:"Include this group and every group after it that has already finished, ignoring their conditions. Nothing is waited on."}[(null==(r=l.groups)?void 0:r.onConditionFailure)??"stop"]}),(0,i.jsx)(m9,{})]}),"dynamic"===d&&(0,i.jsx)(K,{label:"Exit Condition",placeholder:m[Math.floor(Math.random()*m.length)],value:(null==(n=l.dynamicAddonFetching)?void 0:n.condition)??"",onValueChange:e=>{o(t=>({...t,dynamicAddonFetching:{...t.dynamicAddonFetching,condition:e}}))},help:(0,i.jsxs)("p",{children:["Write the condition using"," ",(0,i.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/stream-expressions",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"Stream Expression Language (SEL)"}),". The following variables are available:",(0,i.jsxs)("ul",{className:"list-disc list-inside space-y-1 ml-2 mt-2",children:[(0,i.jsxs)("li",{children:[(0,i.jsx)("code",{children:"totalStreams"}),": The total number of streams"]}),(0,i.jsxs)("li",{children:[(0,i.jsx)("code",{children:"totalTimeTaken"}),": The total time taken to fetch the streams"]}),(0,i.jsxs)("li",{children:[(0,i.jsx)("code",{children:"queryType"}),": The type of query e.g. 'movie', 'series', or 'anime'"]}),(0,i.jsxs)("li",{children:[(0,i.jsx)("code",{children:"queriedAddons"}),": The addons that have been queried. Tip: use the ",(0,i.jsx)("code",{children:"in"})," operator to check if a specific addon has been queried."]}),(0,i.jsxs)("li",{children:[(0,i.jsx)("code",{children:"allAddons"}),": All addons that were intended to be used for that query."]})]})]})})]})}var m7=s(97737),he=s(92814);let ht=e=>`${e.id}-${e.type}`,hs=e=>e.split(".")[0],ha=e=>hs(e).slice(0,-4),hr=e=>new Set((e??[]).filter(e=>!e.enabled).map(e=>e.instanceId));function hn(e,t,s){if(!t.size||!s.length)return e;let a=new Map(s.map((e,t)=>[e,t])),r=e=>a.get(ht(e))??Number.MAX_SAFE_INTEGER,n=new Map;for(let s of e){let e=hs(s.id);t.has(e)&&n.set(e,[...n.get(e)??[],s])}for(let e of n.values())e.sort((e,t)=>r(e)-r(t));return e.map(e=>{var t;return(null==(t=n.get(hs(e.id)))?void 0:t.shift())??e})}let hl=e=>e?e.charAt(0).toUpperCase()+e.slice(1):"",hi=["default","shuffle","reverse"],ho=e=>e.shuffle?"shuffle":e.reverse?"reverse":"default",hd=e=>e.id.startsWith("aiostreams.merged.");function hc(e){return e.genreRequired?!!e.showOnHome:!1!==e.hideable&&!e.onlyOnDiscover&&!e.onlyOnSearch}let hu=e=>e.genreRequired?{...e,showOnHome:!0,onlyOnSearch:!1}:!1!==e.hideable?{...e,onlyOnDiscover:!1,onlyOnSearch:!1}:e,hm=e=>e.genreRequired?{...e,showOnHome:!1}:!1!==e.hideable?{...e,onlyOnDiscover:!0,onlyOnSearch:!1}:e,hh=(0,u.memo)(function(e){let{attributes:t,listeners:s,setNodeRef:a,transform:r,transition:n,isDragging:l}=(0,lG.gl)({id:ht(e.catalog)});return(0,i.jsx)("li",{ref:a,style:{transform:lJ.Ks.Transform.toString(r),transition:n,opacity:l?.5:1},children:(0,i.jsx)(hp,{...e,attributes:t,listeners:s})})}),hp=(0,u.memo)(function(e){let{catalog:t,isNew:s,selected:a,onSelect:r,onUpdate:n,onMove:l,onToggleEnabled:o,onEditMerged:d,attributes:c,listeners:m}=e,[h,p]=(0,u.useState)(!1),x=e=>n(t.id,t.type,e),g=t.enabled??!0,f=hd(t),b="h-8 w-8 text-lg";return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{"data-selected":a||void 0,className:"flex items-center gap-2 rounded-[--radius-md] border bg-[var(--background)] px-2 py-1.5 transition-colors data-[selected]:border-[--brand] md:gap-3",children:[(0,i.jsx)("div",{className:"h-9 w-2.5 flex-shrink-0 cursor-move roun
43ded-full bg-[var(--subtle)] hover:bg-[var(--subtle-highlight)] md:w-3",...c,...m}),(0,i.jsx)(lt,{value:a,fieldClass:"flex w-auto flex-none","aria-label":"Select catalog",onClick:e=>{e.preventDefault(),r(ht(t),e.shiftKey)}}),(0,i.jsxs)("div",{className:`min-w-0 flex-1 ${g?"":"opacity-50"}`,title:t.id,children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("p",{className:"truncate text-sm font-medium",children:t.name??t.id}),s&&(0,i.jsx)(uN,{intent:"primary",size:"sm",className:"flex-shrink-0",children:"New"})]}),(0,i.jsxs)("p",{className:"truncate text-xs text-[--muted]",children:[hl(t.overrideType??t.type)," \xb7"," ",f?"Merged catalog":t.addonName]})]}),(0,i.jsxs)("div",{className:"hidden flex-shrink-0 items-center gap-1 md:flex",children:[f&&(0,i.jsx)("div",{title:"Merged Catalog",className:"flex h-8 w-8 items-center justify-center rounded-full bg-[var(--brand-subtle)]",children:(0,i.jsx)(W.dPp,{className:"text-lg text-[var(--brand)]"})}),(0,i.jsx)(w,{className:b,icon:(0,i.jsx)(W.TaX,{}),intent:"primary-subtle",rounded:!0,title:"Move to top","aria-label":"Move to top",onClick:()=>l(t.id,t.type,"top")}),(0,i.jsx)(w,{className:b,icon:(0,i.jsx)(W.KVh,{}),intent:"primary-subtle",rounded:!0,title:"Move to bottom","aria-label":"Move to bottom",onClick:()=>l(t.id,t.type,"bottom")}),(0,i.jsx)(hx,{catalog:t,update:x,iconClass:b})]}),(0,i.jsx)(ni,{value:g,onValueChange:e=>o(t.id,t.type,e)}),(0,i.jsx)(w,{rounded:!0,size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(W.ZB5,{}),"aria-label":"Catalog settings",title:"Settings",onClick:()=>p(!0)})]}),h&&(0,i.jsx)(hg,{catalog:t,update:x,onMove:e=>l(t.id,t.type,e),onEditMerged:()=>{p(!1),d(t.id)},onClose:()=>p(!1)})]})});function hx(e){let{catalog:t,update:s,iconClass:a}=e,r=hc(t),n=(e,t,s,r)=>(0,i.jsx)(w,{className:a,icon:t,intent:"primary-subtle",rounded:!0,title:e,"aria-label":e,disabled:r,onClick:s});return(0,i.jsxs)(i.Fragment,{children:[n(hl(ho(t)),t.shuffle?(0,i.jsx)(u4.xAZ,{}):t.reverse?(0,i.jsx)(u4.oWm,{}):(0,i.jsx)(u4.j6T,{}),()=>s(e=>{let t=hi[(hi.indexOf(ho(e))+1)%hi.length];return{...e,shuffle:"shuffle"===t,reverse:"reverse"===t}})),n("Poster Services",t.usePosterService?(0,i.jsx)(he.PYM,{}):(0,i.jsx)(he.h4A,{}),()=>s(e=>({...e,usePosterService:!e.usePosterService}))),(t.hideable||t.genreRequired)&&n(r?"On Home":"Discover Only",r?(0,i.jsx)(m7.tTb,{}):(0,i.jsx)(m7.o$K,{}),()=>s(r?hm:hu),t.onlyOnSearch),t.searchable&&n(t.onlyOnSearch?"Search Only":t.disableSearch?"Search Disabled":"Searchable",t.onlyOnSearch?(0,i.jsx)(m1.TOn,{}):t.disableSearch?(0,i.jsx)(m7.QDx,{}):(0,i.jsx)(m7.PuI,{}),()=>s(e=>e.onlyOnSearch||e.disableSearch?e.onlyOnSearch?{...e,onlyOnSearch:!1,disableSearch:!0}:{...e,disableSearch:!1}:{...e,onlyOnSearch:!0,onlyOnDiscover:!1,showOnHome:!1}))]})}function hg(e){let{catalog:t,update:s,onMove:a,onEditMerged:r,onClose:n}=e,l=hd(t),[o,d]=(0,u.useState)(t.name||""),[c,h]=(0,u.useState)(t.overrideType||t.type||""),p=o!==(t.name||"")||c!==(t.overrideType||t.type||"");return(0,i.jsx)(sl,{open:!0,onOpenChange:e=>!e&&n(),title:t.name??t.id,description:l?"Merged catalog":t.addonName,children:(0,i.jsxs)("div",{className:"space-y-4",children:[l&&(0,i.jsx)(v,{className:"w-full",intent:"white",rounded:!0,leftIcon:(0,i.jsx)(W.dPp,{}),onClick:r,children:"Edit name and sources"}),!l&&(0,i.jsxs)("form",{className:"space-y-3",onSubmit:e=>{(e.preventDefault(),c)?(s(e=>({...e,name:o,overrideType:c})),m.oR.success("Name and type saved")):m.oR.error("Type cannot be empty")},children:[(0,i.jsx)(K,{label:"Name",placeholder:"Enter catalog name",value:o,onValueChange:d}),(0,i.jsx)(K,{label:"Type",placeholder:"Enter catalog type",value:c,onValueChange:h}),(0,i.jsx)(v,{className:"w-full",type:"submit",intent:"white",rounded:!0,disabled:!p,children:"Save name and type"})]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(v,{className:"flex-1",intent:"gray-outline",size:"sm",rounded:!0,leftIcon:(0,i.jsx)(W.TaX,{}),onClick:()=>a("top"),children:"Move to top"}),(0,i.jsx)(v,{className:"flex-1",intent:"gray-outline",size:"sm",rounded:!0,leftIcon:(0,i.jsx)(W.KVh,{}),onClick:()=>a("bottom"),children:"Move to bottom"})]}),(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsx)(ni,{label:"Shuffle",help:"Randomize the order of catalog items on each request",side:"right",value:t.shuffle??!1,onValueChange:e=>s(t=>({...t,shuffle:e,reverse:!e&&t.reverse}))}),(0,i.jsx)(ni,{label:"Reverse Order",help:"Reverse the order of catalog items",side:"right",value:t.reverse??!1,onValueChange:e=>s(t=>({...t,reverse:e,shuffle:!e&&t.shuffle}))}),(0,i.jsxs)("div",{className:"flex flex-col gap-2 md:flex-row md:items-center",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsx)("label",{className:"text-sm font-medium",children:"Persist Shuffle For"}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"The amount of hours to keep a given shuffled catalog order before shuffling again. Defaults to 0 (Shuffle on every request)."})]}),(0,i.jsx)("div",{className:"w-full md:w-32",children:(0,i.jsx)(lm,{value:t.persistShuffleFor??0,min:0,step:1,max:24,onValueChange:e=>s(t=>({...t,persistShuffleFor:e}))})})]}),(0,i.jsx)(ni,{label:"Poster Services",help:"Replace movie/show posters with posters from poster services (RPDB or TOP Posters) when supported",side:"right",value:t.usePosterService??!1,onValueChange:e=>s(t=>({...t,usePosterService:e}))}),t.hideable&&(0,i.jsx)(ni,{label:"Discover Only",help:"Hide this catalog from the home page and only show it on the Discover page",side:"right",value:t.onlyOnDiscover??!1,disabled:t.onlyOnSearch,onValueChange:e=>s(t=>({...t,onlyOnDiscover:e,onlyOnSearch:!e&&t.onlyOnSearch}))}),t.genreRequired&&(0,i.jsx)(ni,{label:"Show on Home",help:"This catalog needs a genre, so it only shows on the Discover page. Show it on the home page too, with its first genre picked",side:"right",value:t.showOnHome??!1,disabled:t.onlyOnSearch,onValueChange:e=>s(t=>({...t,showOnHome:e,onlyOnSearch:!e&&t.onlyOnSearch}))}),t.searchable&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ni,{label:"Search Only",help:"Only show this catalog when searching",side:"right",value:t.onlyOnSearch??!1,disabled:t.disableSearch,onValueChange:e=>s(t=>({...t,onlyOnSearch:e,onlyOnDiscover:!e&&t.onlyOnDiscover,showOnHome:!e&&t.showOnHome}))}),(0,i.jsx)(ni,{label:"Disable Search",help:"Disable the search for this catalog",side:"right",value:t.disableSearch??!1,onValueChange:e=>s(t=>({...t,disableSearch:e,onlyOnSearch:!e&&t.onlyOnSearch}))})]})]})]})})}let hf=[lY.FN],hb="\0any",hv=[{value:"all",label:"Any status"},{value:"on",label:"On"},{value:"off",label:"Off"},{value:"home",label:"On home"},{value:"discover",label:"Not on home"},{value:"new",label:"New"}];function hy(e){let t=new URLSearchParams(e);return ht({id:t.get("id")??"",type:t.get("type")??""})}function hj(e){var t,s,a,r,n;let{loading:l,fetchCatalogsData:o,newCatalogs:d,upstreamKeys:c,onMerge:m}=e,{userData:h,setUserData:p}=ri(),x=(0,u.useRef)((null==(t=h.mergedCatalogs)?void 0:t.length)??0);(0,u.useEffect)(()=>{var e;let t=(null==(e=h.mergedCatalogs)?void 0:e.length)??0;t!==x.current&&(x.current=t,o(!0))},[null==(s=h.mergedCatalogs)?void 0:s.length,o]);let g=(0,u.useMemo)(()=>new Set((h.mergedCatalogs||[]).filter(e=>!1!==e.enabled).flatMap(e=>e.catalogIds.map(hy))),[h.mergedCatalogs]),f=(0,u.useMemo)(()=>hr(h.presets),[h.presets]),b=(0,u.useMemo)(()=>(h.catalogModifications??[]).filter(e=>!g.has(ht(e))&&!f.has(ha(e.id))),[h.catalogModifications,g,f]),[y,j]=(0,u.useState)(""),[N,k]=(0,u.useState)([]),[S,C]=(0,u.useState)(hb),[_,A]=(0,u.useState)("all"),R=(0,u.useMemo)(()=>{let e=new Map;for(let t of b){let s=hs(t.id);e.has(s)||e.set(s,hd(t)?"Merged catalogs":t.addonName??s)}let t=new Map;return[...e].map(e=>{let[s,a]=e,r=(t.get(a)??0)+1;t.set(a,r);let n=r>1?`${a} (${r})`:a;return{value:s,label:n,textValue:n}})},[b]),T=(0,u.useMemo)(()=>[{value:hb,label:"Any type"},...[...new Set(b.map(e=>e.overrideType??e.type))].map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))],[b]),I=(0,u.useDeferredValue)(y),E=(0,u.useMemo)(()=>{let e=I.trim().toLowerCase();
43return b.filter(t=>(!N.length||N.includes(hs(t.id)))&&(S===hb||(t.overrideType??t.type)===S)&&(e=>{let t=!1!==e.enabled;switch(_){case"on":return t;case"off":return!t;case"home":return t&&hc(e);case"discover":return t&&!hc(e);case"new":return d.has(ht(e));default:return!0}})(t)&&(!e||[t.name,t.id,t.addonName].some(t=>null==t?void 0:t.toLowerCase().includes(e))))},[b,I,N,S,_,d]),M=(0,u.useMemo)(()=>E.map(ht),[E]),[P,$]=(0,u.useState)(30);(0,u.useEffect)(()=>{P<E.length&&(0,u.startTransition)(()=>$(1/0))},[P,E.length]);let D=(0,u.useMemo)(()=>P<E.length?E.slice(0,P):E,[E,P]),L=(0,u.useMemo)(()=>D.map(ht),[D]),[O,U]=(0,u.useState)(()=>new Set),F=(0,u.useRef)(null),z=(0,u.useRef)(M);z.current=M,(0,u.useEffect)(()=>{U(new Set),F.current=null},[I,N,S,_]),(0,u.useEffect)(()=>{let e=new Set(M);U(t=>[...t].every(t=>e.has(t))?t:new Set([...t].filter(t=>e.has(t))))},[M]);let V=(0,u.useCallback)((e,t)=>{let s=F.current;F.current=e,U(a=>{let r=new Set(a),n=z.current,l=s?n.indexOf(s):-1,i=n.indexOf(e);if(t&&-1!==l&&-1!==i){let t=!a.has(e);for(let e of n.slice(Math.min(l,i),Math.max(l,i)+1))t?r.add(e):r.delete(e)}else r.has(e)?r.delete(e):r.add(e);return r})},[]),q=M.filter(e=>O.has(e)).length,B=E.length>0&&q===E.length,H=b.filter(e=>!1!==e.enabled).length,G=(0,u.useCallback)((e,t)=>({...e,catalogModifications:hn(t,new Set(e.upstreamCatalogOrder),c)}),[c]),Y=(0,u.useCallback)((e,t,s)=>{p(a=>{var r;return{...a,catalogModifications:null==(r=a.catalogModifications)?void 0:r.map(a=>a.id===e&&a.type===t?s(a):a)}})},[p]),J=(0,u.useCallback)((e,t,s)=>{p(a=>{if(!a.catalogModifications)return a;let r=a.catalogModifications.findIndex(s=>s.id===e&&s.type===t),n=a.catalogModifications.length-1;if(r<0||r===("top"===s?0:n))return a;let l=[...a.catalogModifications],[i]=l.splice(r,1);return"top"===s?l.unshift(i):l.push(i),G(a,l)})},[p,G]),Z=(0,u.useCallback)((e,t,s)=>{p(a=>{var r,n;return{...a,catalogModifications:null==(r=a.catalogModifications)?void 0:r.map(a=>a.id===e&&a.type===t?{...a,enabled:s}:a),...e.startsWith("aiostreams.merged.")&&{mergedCatalogs:null==(n=a.mergedCatalogs)?void 0:n.map(t=>t.id===e?{...t,enabled:s}:t)}}})},[p]),Q=e=>p(t=>{var s;return{...t,catalogModifications:null==(s=t.catalogModifications)?void 0:s.map(t=>O.has(ht(t))?e(t):t)}}),X=e=>p(t=>{var s,a;return{...t,catalogModifications:null==(s=t.catalogModifications)?void 0:s.map(t=>O.has(ht(t))?{...t,enabled:e}:t),mergedCatalogs:null==(a=t.mergedCatalogs)?void 0:a.map(t=>O.has(ht(t))?{...t,enabled:e}:t)}}),ee=e=>p(t=>{let s=t.catalogModifications??[],a=s.filter(e=>O.has(ht(e))),r=s.filter(e=>!O.has(ht(e)));return G(t,"top"===e?[...a,...r]:[...r,...a])}),et=(e,t)=>p(s=>{let a=new Set(s[e]);a.has(t)?a.delete(t):a.add(t);let r={...s,[e]:a.size?[...a]:void 0};return"upstreamCatalogOrder"===e?G(r,s.catalogModifications??[]):r}),es=(0,lW.FR)((0,lW.MS)(lW.AN),(0,lW.MS)(lW.IG,{activationConstraint:{delay:150,tolerance:8}})),[ea,er]=(0,u.useState)(!1);(0,u.useEffect)(()=>{function e(e){ea&&e.preventDefault()}function t(){er(!1)}return ea?(document.body.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("pointerup",t),document.addEventListener("touchend",t)):document.body.removeEventListener("touchmove",e),()=>{document.body.removeEventListener("touchmove",e),document.removeEventListener("pointerup",t),document.removeEventListener("touchend",t)}},[ea]);let{status:en}=tj(),el=(null==en||null==(r=en.settings)||null==(a=r.limits)?void 0:a.maxMergedCatalogSources)??10,ei=E.filter(e=>!hd(e)&&O.has(ht(e))),eo=(0,u.useCallback)(e=>m({kind:"edit",id:e}),[m]),ed=R.filter(e=>"aiostreams"!==e.value),[ec,eu]=(0,u.useState)(!1),em=0===q;return(0,i.jsx)(mK,{title:"Catalogs",id:"catalogs",description:"Rename, reorder, and toggle your catalogs, and apply modifications like RPDB posters and shuffling. Adjusting catalogs may require a reinstall - if it does, a pop-up will tell you.",action:(0,i.jsx)(w,{size:"sm",intent:"warning-subtle",icon:(0,i.jsx)(m1.joZ,{}),rounded:!0,onClick:()=>{o()},loading:l}),children:(null==(n=h.catalogModifications)?void 0:n.length)?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{"data-ui":"catalog-toolbar",className:"sticky top-0 z-10 -mx-4 space-y-2 border-b bg-[--background] px-4 pb-3 pt-2 lg:bg-gray-950",children:[(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-2 lg:grid-cols-[minmax(0,1fr),13rem,9rem,10rem]",children:[(0,i.jsx)("div",{className:"col-span-2 lg:col-span-1",children:(0,i.jsx)(K,{leftIcon:(0,i.jsx)(mX.A,{className:"h-4 w-4"}),placeholder:"Search catalogs",value:y,onValueChange:j})}),(0,i.jsx)("div",{className:"col-span-2 lg:col-span-1",children:(0,i.jsx)(li,{multiple:!0,options:R,value:N,onValueChange:k,placeholder:"Any addon",emptyMessage:"No addons match."})}),(0,i.jsx)(nc,{options:T,value:S,onValueChange:C}),(0,i.jsx)(nc,{options:hv,value:_,onValueChange:e=>A(e)})]}),(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)(lt,{fieldClass:"flex w-auto flex-none","aria-label":"Select every catalog shown",value:!!B||!em&&"indeterminate",onClick:e=>{e.preventDefault(),U(B?new Set:new Set(M))}}),(0,i.jsxs)("p",{className:"min-w-0 flex-1 truncate text-sm text-[--muted]",children:[em?`${E.length} shown`:`${q}
43 selected`," ","\xb7 ",H,"/",b.length," on"]}),(0,i.jsxs)(iN,{align:"end",trigger:(0,i.jsx)(v,{size:"sm",intent:"gray-outline",rounded:!0,rightIcon:(0,i.jsx)(W.zrT,{}),children:"Actions"}),children:[(0,i.jsx)(iS,{children:em?"Select catalogs to change them":`${q} selected`}),(0,i.jsx)(ik,{disabled:em,onSelect:()=>X(!0),children:"Turn on"}),(0,i.jsx)(ik,{disabled:em,onSelect:()=>X(!1),children:"Turn off"}),(0,i.jsx)(ik,{disabled:em,onSelect:()=>Q(hu),children:"Show on home"}),(0,i.jsx)(ik,{disabled:em,onSelect:()=>Q(hm),children:"Discover only"}),(0,i.jsx)(ik,{disabled:em,onSelect:()=>Q(e=>({...e,usePosterService:!0})),children:"Use poster services"}),(0,i.jsx)(ik,{disabled:em,onSelect:()=>Q(e=>({...e,usePosterService:!1})),children:"Stop using poster services"}),(0,i.jsx)(ik,{disabled:em,onSelect:()=>ee("top"),children:"Move to top"}),(0,i.jsx)(ik,{disabled:em,onSelect:()=>ee("bottom"),children:"Move to bottom"}),(0,i.jsx)(iC,{}),(0,i.jsx)(ik,{disabled:ei.length<2||ei.length>el,onSelect:()=>m({kind:"new",catalogs:ei.map(e=>{let{id:t,type:s}=e;return{id:t,type:s}})}),children:(0,i.jsxs)("span",{className:"flex flex-col",children:[(0,i.jsx)("span",{children:"Merge into one catalogâ¦"}),(ei.length<2||ei.length>el)&&(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:["Select 2 to ",el," catalogs"]})]})}),ed.length>0&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(iC,{}),(0,i.jsx)(ik,{onSelect:()=>eu(!0),children:"Addon optionsâ¦"})]})]}),(0,i.jsx)(sl,{open:ec,onOpenChange:eu,title:"Addon options",description:"How catalogs an addon adds or reorders later are handled.",children:(0,i.jsx)("div",{className:"space-y-6",children:ed.map(e=>{var t,s;return(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)("p",{className:"text-sm font-semibold",children:e.label}),(0,i.jsx)(ni,{side:"right",label:"Turn new catalogs on",help:"Catalogs the addon adds later start turned on. Turn this off to review them first.",value:!(null==(t=h.newCatalogsDisabled)?void 0:t.includes(e.value)),onValueChange:()=>et("newCatalogsDisabled",e.value)}),(0,i.jsx)(ni,{side:"right",label:"Keep the addon's order",help:"Its catalogs stay in the positions you give them, but in the order the addon lists them, and new ones appear next to the others.",value:(null==(s=h.upstreamCatalogOrder)?void 0:s.includes(e.value))??!1,onValueChange:()=>et("upstreamCatalogOrder",e.value)})]},e.value)})})})]})]}),0===E.length?(0,i.jsx)("p",{className:"my-8 text-center text-sm text-[--muted]",children:"No catalogs match."}):(0,i.jsx)(lW.Mp,{modifiers:hf,onDragEnd:e=>{let{active:t,over:s}=e;s&&(t.id!==s.id&&p(e=>{var a,r;let n=null==(a=e.catalogModifications)?void 0:a.findIndex(e=>ht(e)===t.id),l=null==(r=e.catalogModifications)?void 0:r.findIndex(e=>ht(e)===s.id);return void 0!==n&&void 0!==l&&e.catalogModifications?G(e,(0,lG.be)(e.catalogModifications,n,l)):e}),er(!1))},onDragStart:()=>er(!0),sensors:es,children:(0,i.jsx)(lG.gB,{items:L,strategy:lG._G,children:(0,i.jsx)("ul",{className:"space-y-1.5",children:D.map(e=>{let t=ht(e);return(0,i.jsx)(hh,{catalog:e,isNew:d.has(t),selected:O.has(t),onSelect:V,onUpdate:Y,onMove:J,onToggleEnabled:Z,onEditMerged:eo},t)})})})})]}):(0,i.jsx)("p",{className:"text-[--muted] text-base text-center my-8",children:"Your addons don't have any catalogs... or you haven't fetched them yet :/"})})}let hw=e=>`id=${encodeURIComponent(e.id)}&type=${encodeURIComponent(e.type)}`;function hN(e){var t,s;let a,{request:r,onRequestHandled:n}=e,{userData:l,setUserData:o}=ri(),{status:d}=tj(),c=(null==d||null==(s=d.settings)||null==(t=s.limits)?void 0:t.maxMergedCatalogSources)??10,[h,p]=(0,u.useState)(!1),[x,g]=(0,u.useState)(null),[f,b]=(0,u.useState)(""),[j,N]=(0,u.useState)("movie"),[k,S]=(0,u.useState)([]),[C,_]=(0,u.useState)(["id"]),[A,R]=(0,u.useState)("sequential"),[T,I]=(0,u.useState)(""),[E,M]=(0,u.useState)(new Set),[P,$]=(0,u.useState)(null),D=sd({title:"Delete Merged Catalog",description:"This is the last catalog in this merged catalog. Removing it will delete the entire merged catalog. Are you sure?",actionText:"Delete Merged Catalog",actionIntent:"alert",onConfirm:()=>
43{P&&(o(e=>{var t,s;return{...e,mergedCatalogs:null==(t=e.mergedCatalogs)?void 0:t.filter(e=>e.id!==P),catalogModifications:null==(s=e.catalogModifications)?void 0:s.filter(e=>e.id!==P)}}),$(null),m.oR.success("Merged catalog deleted"))}}),L=l.mergedCatalogs||[],O=e=>e?e.charAt(0).toUpperCase()+e.slice(1):"",U=(l.catalogModifications||[]).filter(e=>!e.id.startsWith("aiostreams.merged.")).map(e=>({value:hw(e),name:e.name||e.id,catalogType:e.type,addonName:e.addonName||"Unknown Addon",isDisabled:!1===e.enabled})),F=Object.entries(U.reduce((e,t)=>(e[t.addonName]||(e[t.addonName]=[]),e[t.addonName].push(t),e),{})).reduce((e,t)=>{let[s,a]=t,r=a.filter(e=>e.name.toLowerCase().includes(T.toLowerCase())||e.addonName.toLowerCase().includes(T.toLowerCase())||e.catalogType.toLowerCase().includes(T.toLowerCase()));if(r.length>0){let t=[...r].sort((e,t)=>{let s=e.name.localeCompare(t.name);return 0!==s?s:e.catalogType.localeCompare(t.catalogType)});e[s]=t}return e},{}),z=()=>{g(null),b(""),N("movie"),S([]),_(["id"]),R("sequential"),I(""),M(new Set),p(!0)},V=e=>{g(e),b(e.name),N(e.type),S(e.catalogIds),_(e.deduplicationMethods??["id"]),R(e.mergeMethod??"sequential"),I(""),M(new Set),p(!0)};return(0,u.useEffect)(()=>{if(!r)return;if(null==n||n(),"edit"===r.kind){var e;let t=null==(e=l.mergedCatalogs)?void 0:e.find(e=>e.id===r.id);t&&V(t);return}z();let t=new Set(r.catalogs.map(e=>e.type));1===t.size&&N([...t][0]),S(r.catalogs.map(hw))},[r]),(0,i.jsxs)(mK,{title:"Merged Catalogs",id:"mergedCatalogs",description:"Combine multiple catalogs into a single merged catalog. Useful for creating custom collections from different sources.",action:(0,i.jsx)(w,{size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(lZ.OiG,{}),rounded:!0,onClick:z}),children:[0===L.length&&(0,i.jsx)("p",{className:"text-[--muted] text-base text-center my-8",children:"No merged catalogs yet. Click the + button to create one."}),L.length>0&&(0,i.jsx)("ul",{className:"space-y-2",children:L.map(e=>(0,i.jsx)("li",{children:(0,i.jsxs)("div",{className:"relative px-4 py-3 bg-[var(--background)] rounded-[--radius-md] border overflow-hidden",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,i.jsx)("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-[var(--subtle)] flex-shrink-0",children:(0,i.jsx)(W.dPp,{className:"text-xl"})}),(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsx)("h3",{className:"text-sm md:text-base font-medium truncate",children:e.name}),(0,i.jsxs)("p",{className:"text-xs text-[var(--muted-foreground)]",children:[O(e.type)," ⢠",e.catalogIds.length," catalogs"]})]})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(w,{className:"h-8 w-8",icon:(0,i.jsx)(sm.u6n,{}),intent:"primary-subtle",rounded:!0,onClick:()=>V(e)}),(0,i.jsx)(w,{className:"h-8 w-8",icon:(0,i.jsx)(sm.id1,{}),intent:"alert-subtle",rounded:!0,onClick:()=>{var t;return t=e.id,void(o(e=>({...e,mergedCatalogs:(e.mergedCatalogs||[]).filter(e=>e.id!==t),catalogModifications:(e.catalogModifications||[]).filter(e=>e.id!==t)})),m.oR.success("Merged catalog deleted"))}})]})]}),(0,i.jsx)(uI,{type:"single",collapsible:!0,className:"mt-2",children:(0,i.jsxs)(uE,{value:"settings",children:[(0,i.jsx)(uM,{children:(0,i.jsx)("div",{className:"flex items-center justify-center md:justify-between w-full",children:(0,i.jsxs)("h4",{className:"text-xs font-medium text-[var(--muted-foreground)] uppercase tracking-wide hidden md:block",children:["Included Catalogs (",e.catalogIds.length,")"]})})}),(0,i.jsx)(uP,{children:(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.catalogIds.map(t=>{let s=U.find(e=>e.value===t),a=!s,r=e.catalogIds.filter(e=>U.find(t=>t.value===e)).length,n=!a&&1===r,l=1===e.catalogIds.length;return(0,i.jsxs)("span",{className:`inline-flex items-center gap-1.5 text-xs px-2 py-1 rounded-md bg-[var(--subtle)] border border-[var(--border)] text-[var(--muted-foreground)] ${(null==s?void 0:s.isDisabled)?"opacity-60":""} ${a?"bg-orange-50 dark:bg-orange-500/10 border border-orange-300 dark:border-orange-500/50":""}`,children:[(0,i.jsx)("span",{className:"font-medium text-[var(--foreground)]",children:s?s.name:"Unavailable Catalog"}),(null==s?void 0:s.isDisabled)&&(0,i.jsx)("span",{className:"text-[10px] px-1 py-0.5 rounded text-[--red]",children:"Disabled"}),s&&(0,i.jsx)("span",{className:"text-[10px] px-1 py-0.5 rounded bg-brand-800/20 border border-[--brand] border-brand-500/50 text-[--muted-foreground]",children:O(s.catalogType)}),(0,i.jsx)(y,{type:"button",className:"ml-0.5",size:"sm",onClick:s=>{if(s.stopPropagation(),n)return void m.oR.error("Cannot remove the last available catalog. Add another catalog first or delete the merged catalog.");if(l&&a){$(e.id),D.open();return}o(s=>{var a;return{...s,mergedCatalogs:null==(a=s.mergedCatalogs)?void 0:a.map(s=>s.id===e.id?{...s,catalogIds:s.catalogIds.filter(e=>e!==t)}:s)}})},title:n?"Cannot remove last available catalog":"Remove catalog"})]},t)})})})})]})})]})},e.id))}),(0,i.jsx)(sl,{open:h,onOpenChange:p,title:x?"Edit Merged Catalog":"Create Merged Catalog",children:(0,i.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),(()=>{if(!f.trim())return m.oR.error("Name is required");if(!j.trim())return m.oR.error("Type is required");if(k.length<2)return m.oR.error("Select at least 2 catalogs to merge");
43if(k.length>c)return m.oR.error(`Maximum ${c} source catalogs allowed per merged catalog`);if(x)o(e=>({...e,catalogModifications:(e.catalogModifications||[]).map(e=>e.id===x.id&&e.type===x.type?{...e,name:f.trim(),type:j.trim()}:e),mergedCatalogs:(e.mergedCatalogs||[]).map(e=>e.id===x.id?{...e,name:f.trim(),type:j.trim(),catalogIds:k,deduplicationMethods:C.length>0?C:void 0,mergeMethod:A??"sequential"}:e)})),m.oR.success("Merged catalog updated");else{let e=`aiostreams.merged.${Date.now()}`;o(t=>({...t,mergedCatalogs:[...t.mergedCatalogs||[],{id:e,name:f.trim(),type:j.trim(),catalogIds:k,enabled:!0,deduplicationMethods:C.length>0?C:void 0,mergeMethod:A??"sequential"}]})),m.oR.success("Merged catalog created")}p(!1)})()},children:[(0,i.jsx)(K,{label:"Name",placeholder:"e.g., My Combined Movies",value:f,onValueChange:b}),(0,i.jsx)(K,{label:"Type",placeholder:"e.g., movie, series, anime",help:"The content type for this merged catalog (e.g., movie, series, anime, tv)",value:j,onValueChange:N}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsx)("label",{className:"text-sm font-medium",children:"Catalogs to Merge"}),(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:[k.length," selected"]})]}),(0,i.jsx)(K,{placeholder:"Search catalogs...",value:T,onValueChange:I}),(0,i.jsx)("div",{className:"border rounded-[--radius-md] h-64 overflow-y-auto",children:0===Object.keys(F).length?(0,i.jsx)("p",{className:"text-sm text-[--muted] text-center py-8",children:T?"No catalogs match your search":"No catalogs available"}):Object.entries(F).map(e=>{let[t,s]=e,a=E.has(t);return(0,i.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,i.jsxs)("div",{onClick:()=>{M(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"px-3 py-2 bg-[var(--subtle)] cursor-pointer hover:bg-[var(--subtle-highlight)] flex items-center justify-between",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("svg",{className:`w-4 h-4 transition-transform ${a?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),(0,i.jsx)("span",{className:"text-xs font-semibold text-[var(--muted-foreground)] uppercase tracking-wide",children:t})]}),(0,i.jsx)("div",{className:"flex items-center gap-2",children:(0,i.jsxs)("span",{className:"text-xs text-[var(--muted-foreground)]",children:[s.length," catalog",1!==s.length?"s":""]})})]}),a&&s.map(e=>{let t=k.includes(e.value);return(0,i.jsxs)("div",{onClick:()=>{var t;return t=e.value,void S(e=>e.includes(t)?e.filter(e=>e!==t):e.length>=c?(m.oR.error(`Maximum ${c} source catalogs allowed`),e):[...e,t])},className:`flex items-center gap-3 px-3 py-2 cursor-pointer transition-colors ${t?"bg-[var(--brand-subtle)] hover:bg-[var(--brand-subtle)]":"hover:bg-[var(--subtle-highlight)]"} ${e.isDisabled?"opacity-60":""}`,children:[(0,i.jsx)("div",{className:`w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0 transition-colors ${t?"bg-[var(--brand)] border-[var(--brand)]":"border-[var(--muted)]"}`,children:t&&(0,i.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),(0,i.jsx)("div",{className:"flex-1 min-w-0",children:(0,i.jsx)("span",{className:`text-sm font-medium truncate block ${e.isDisabled?"text-[var(--muted-foreground)]":""}`,children:e.name})}),(0,i.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.isDisabled&&(0,i.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-orange-500/20 border border-orange-500/50 text-orange-300",children:"Disabled"}),(0,i.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full text-[var(--muted-foreground)] bg-brand-800/20 border border-brand-500/50",children:O(e.catalogType)})]})]},e.value)})]},t)})}),k.length>0&&(0,i.jsxs)(i.Fragment,{children:[0===(a=k.filter(e=>!U.find(t=>t.value===e))).length?null:(0,i.jsx)("div",{className:"p-3 rounded-[--radius] bg-orange-50 dark:bg-orange-500/10 border border-orange-300 dark:border-orange-500/50",children:(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,i.jsxs)("p",{className:"text-sm text-orange-700 dark:text-orange-300",children:[a.length," unavailable catalog",1!==a.length?"s":""," found"]}
43),(0,i.jsx)(v,{type:"button",size:"sm",intent:"warning",onClick:()=>S(e=>e.filter(e=>U.find(t=>t.value===e))),children:"Remove All"})]})}),(0,i.jsxs)("div",{className:"text-xs text-[--muted]",children:["Selected (",k.length,"/",c,"):"," ",k.filter(e=>U.find(t=>t.value===e)).slice(0,3).map(e=>{let t=U.find(t=>t.value===e);return(null==t?void 0:t.name)||e}).join(", "),k.filter(e=>U.find(t=>t.value===e)).length>3&&` +${k.filter(e=>U.find(t=>t.value===e)).length-3} more`]})]})]}),(0,i.jsx)(li,{multiple:!0,label:"Deduplication Methods",help:"Methods to remove duplicate items (applied in order). Leave empty to keep all items.",options:[{value:"id",label:"By ID - Remove items with same ID"},{value:"title",label:"By Title - Remove items with same title"}],value:C,onValueChange:e=>_(e),placeholder:"None - Keep all items",emptyMessage:"No deduplication methods available"}),(0,i.jsx)(nc,{label:"Merge Method",help:"How to combine results from the source catalogs.",options:[{value:"sequential",label:"Sequential"},{value:"interleave",label:"Interleave"},{value:"imdbRating",label:"IMDb Rating"},{value:"releaseDateDesc",label:"Release Date (Newest)"},{value:"releaseDateAsc",label:"Release Date (Oldest)"}],value:A??"sequential",onValueChange:e=>R(e)}),("imdbRating"===A||"releaseDateDesc"===A||"releaseDateAsc"===A)&&(0,i.jsx)(lB,{intent:"alert",description:"Sorting is applied per page only. Items are sorted within each page of results, not globally across all pages. A lower-rated item from page 1 may still appear before a higher-rated item from page 2."}),(0,i.jsx)(v,{className:"w-full",type:"submit",children:x?"Save Changes":"Create Merged Catalog"})]})}),(0,i.jsx)(sc,{...D})]})}function hk(e){let{item:t}=e,{attributes:s,listeners:a,setNodeRef:r,transform:n,transition:l,isDragging:o}=(0,lG.gl)({id:t.instanceId}),d={transform:lJ.Ks.Transform.toString(n),transition:l,opacity:o?.6:1,zIndex:10*!!o};return(0,i.jsxs)("li",{ref:r,style:d,className:`flex items-center gap-3 px-3 py-2 rounded-lg border bg-[var(--background)] select-none ${o?"shadow-lg border-[--brand]/50":"border-[--border]"} ${!t.enabled?"opacity-50":""}`,...s,children:[(0,i.jsx)("div",{className:"flex items-center justify-center w-5 text-sm font-mono text-[--muted] flex-shrink-0 cursor-move touch-none",...a,children:(0,i.jsx)("svg",{className:"w-4 h-4 text-[--muted]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,i.jsx)("path",{d:"M4 8h16M4 16h16",strokeLinecap:"round"})})}),(0,i.jsx)("div",{className:"relative flex-shrink-0 h-6 w-6",children:t.logo?(0,i.jsx)("img",{src:t.logo,alt:t.name,className:"absolute inset-0 w-full h-full object-contain rounded"}):"custom"===t.type?(0,i.jsx)(m3.A,{className:"w-full h-full text-[--brand]"}):(0,i.jsx)(m0.Yoo,{className:"w-full h-full text-[--brand]"})}),(0,i.jsx)("span",{className:"text-sm font-medium truncate flex-1",children:t.name}),!t.enabled&&(0,i.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[--subtle] text-[--muted] border border-[--border]",children:"Disabled"})]})}function hS(e){let{open:t,onOpenChange:s,presets:a,presetMetadataMap:r,manifestCache:n,onSave:l}=e,[o,d]=(0,u.useState)([]),[c,m]=(0,u.useState)(!1);(0,u.useEffect)(()=>{t&&d([...a])},[t,a]);let h=(0,lW.FR)((0,lW.MS)(lW.AN),(0,lW.MS)(lW.IG,{activationConstraint:{delay:150,tolerance:8}}));(0,u.useEffect)(()=>{function e(e){c&&e.preventDefault()}function t(){m(!1)}return c?(document.body.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("pointerup",t),document.addEventListener("touchend",t)):document.body.removeEventListener("touchmove",e),()=>{document.body.removeEventListener("touchmove",e),document.removeEventListener("pointerup",t),document.removeEventListener("touchend",t)}},[c]);let p=o.map(e=>{var t;let s=r.get(e.type),a=function(e,t){var s,a;if((null==t?void 0:t.ID)==="custom"||(null==t?void 0:t.ID)==="aiostreams")return null==(a=e.options)?void 0:a.manifestUrl;let r=null==(s=e.options)?void 0:s.url;if(r)try{if(new URL(r).pathname.endsWith("/manifest.json"))return r}catch{}}(e,s),l=a?n.get(a.replace(/^stremio:\/\//,"https://").replace(/\/$/,"")):void 0;return{instanceId:e.instanceId,name:(null==(t=e.options)?void 0:t.name)||(null==s?void 0:s.NAME)||e.type,type:(null==s?void 0:s.ID)||e.type,logo:(null==l?void 0:l.logo)||e.logo||(null==s?void 0:s.LOGO),enabled:e.enabled??!0}});return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Reorder Addon Priority",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["Drag addons to change their priority. Addons higher in the list have higher priority during deduplication and also controls sorting"," ",(0,i.jsx)("b",{children:"when sorting by the addon criterion"}),"."]}),(0,i.jsx)(lW.Mp,{modifiers:[lY.FN],onDragEnd:function(e){let{active:t,over:s}=e;s&&(t.id!==s.id&&d(e=>{let a=e.findIndex(e=>e.instanceId===t.id),r=e.findIndex(e=>e.instanceId===s.id);return(0,lG.be)(e,a,r)}),m(!1))},onDragStart:()=>m(!0),sensors:h,children:(0,i.jsx)(lG.gB,{items:p.map(e=>e.instanceId),strategy:lG._G,children:(0,i.jsx)("ul",{className:"space-y-1.5 max-h-[60vh] overflow-y-auto pr-1",children:p.map(e=>(0,i.jsx)(hk,{item:e},e.instanceId))})})}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(v,{className:"flex-1",intent:"primary-subtle",onClick:()=>s(!1),children:"Cancel"}),(0,i.jsx)(v,{className:"flex-1",onClick:()=>{l(o),s(!1)},children:"Save Order"})]})]})})}let hC=new Map,h_=[{key:"blue",bg:"bg-blue-400/15",text:"text-blue-300",border:"border-blue-400/40",swatch:"bg-blue-400"},{key:"purple",bg:"bg-purple-500/15",text:"text-purple-400",border:"border-purple-500/40",swatch:"bg-purple-500"},{key:"amber",bg:"bg-amber-500/15",text:"text-amber-400",border:"border-amber-500/40",swatch:"bg-amber-500"},{key:"emerald",bg:"bg-emerald-500/15",text:"text-emerald-400",border:"border-emerald-500/40",swatch:"bg-emerald-500"},{key:"rose",bg:"bg-rose-500/15",text:"text-rose-400",border:"border-rose-500/40",swatch:"bg-rose-500"},{key:"cyan",bg:"bg-cyan-500/15",text:"text-cyan-400",border:"border-cyan-500/40",swatch:"bg-cyan-500"},{key:"orange",bg:"bg-orange-500/15",text:"text-orange-400",border:"border-orange-400/40",swatch:"bg-orange-400"},{key:"pink",bg:"bg-pink-500/15",text:"text-pink-400",border:"border-pink-500/40",swatch:"bg-pink-500"},{key:"teal",bg:"bg-teal-500/15",text:"text-teal-400",border:"border-teal-500/40",swatch:"bg-teal-500"},{key:"indigo",bg:"bg-indigo-500/15",text:"text-indigo-400",border:"border-indigo-500/40",swatch:"bg-indigo-500"},{key:"lime",bg:"bg-lime-500/15",text:"text-lime-400",border:"border-lime-500/40",swatch:"bg-lime-500"},{key:"red",bg:"bg-red-400/15",text:"text-red-300",border:"border-red-400/40",swatch:"bg-red-400"}],hA={streams:h_[0],subtitles:h_[1],meta_catalogs:h_[2],misc:h_[3]},hR={streams:"Streams",subtitles:"Subtitles",meta_catalogs:"Metadata & Catalogs",misc:"Miscellaneous"};function hT(e,t){var s;let a;return e.category||(s=e.type,(null==(a=t.get(s))?void 0:a.CATEGORY)||"streams")}function hI(e,t){if(hA[e])return hA[e];let s=null==t?void 0:t[e];if(s){let e=h_.find(e=>e.key===s);if(e)return e}let a=0;for(let t=0;t<e.length;t++)a=e.charCodeAt(t)+((a<<5)-a);return h_[Math.abs(a)%h_.length]}function hE(e){let{onEdit:t}=e,{userData:s,setUserData:a}=ri(),{status:r}=tj(),{mode:n}=sF(),[l,o]=(0,u.useState)(new Set),[d,c]=(0,u.useState)("all"),[h,p]=(0,u.useState)(""),x=so(!1),g=so(!1),f=so(!1),[b,y]=(0,u.useState)("pick"),[j,N]=(0,u.useState)(new Set),[k,S]=(0,u.useState)({}),[C,_]=(0,u.useState)(""),[A,R]=(0,u.useState)("blue"),T=(0,u.useMemo)(()=>{var e;let t=new Map;if(null==r||null==(e=r.settings)?void 0:e.presets)for(let e of r.settings.presets)t.set(e.ID,e);return t},[r]),I=(0,u.useMemo)(()=>{let e=new Map;for(let t of s.presets){let s=hT(t,T);e.set(s,(e.get(s)||0)+1)}return e},[s.presets,T]),E=(0,u.useMemo)(()=>{let e=["streams","subtitles","meta_catalogs","misc"];return[...e.filter(e=>I.has(e)),...[...I.keys()].filter(t=>!e.includes(t)).sort((e,t)=>
43s.presets.findIndex(t=>hT(t,T)===e)-s.presets.findIndex(e=>hT(e,T)===t))]},[I,s.presets,T]),M=(0,u.useMemo)(()=>{let e=s.presets;if("all"!==d&&(e=e.filter(e=>hT(e,T)===d)),h.trim()){let t=h.toLowerCase();e=e.filter(e=>{var s;return((null==(s=e.options)?void 0:s.name)||"").toLowerCase().includes(t)})}return e},[s.presets,T,d,h]),P=(0,u.useMemo)(()=>{let e={};for(let t of M){let s=hT(t,T);e[s]||(e[s]=[]),e[s].push(t)}return e},[M,T]),$=M.length>0&&M.every(e=>l.has(e.instanceId)),D=l.size>0,L=(0,u.useMemo)(()=>{let e=s.presets.filter(e=>l.has(e.instanceId)),t=e.filter(e=>e.enabled).length;return e.filter(e=>!e.enabled).length>t},[s.presets,l]),O=e=>{o(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};(0,u.useEffect)(()=>{o(new Set)},[d,h]);let U=(0,u.useMemo)(()=>{if(0===l.size)return[];let e=s.presets.filter(e=>l.has(e.instanceId)),t=new Map;for(let s of e){let e=T.get(s.type);if(null==e?void 0:e.OPTIONS)for(let s of e.OPTIONS){if(["alert","socials","oauth","subsection"].includes(s.type))continue;let e=t.get(s.id);e?e.count++:t.set(s.id,{option:s,count:1})}}return[...t.values()].filter(t=>t.count===e.length).map(e=>e.option)},[l,s.presets,T]),F=sd({title:"Delete Selected Addons",description:`Are you sure you want to delete ${l.size} selected addon(s)? This cannot be undone.`,actionText:"Delete",actionIntent:"alert",onConfirm:()=>{a(e=>{let t=structuredClone(e);return t.presets=t.presets.filter(e=>!l.has(e.instanceId)),a7(t)}),o(new Set)}}),z=e=>{a(t=>({...t,presets:t.presets.map(t=>l.has(t.instanceId)?{...t,category:e}:t)})),m.oR.info(e?`Categorised ${l.size} addon(s) as "${e}"`:`Reset category for ${l.size} addon(s)`),f.close()},V=e=>hR[e]||e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(mK,{title:"My Addons",description:"Manage your installed addons. Reorder, batch edit, or categorise by type.",action:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(w,{rounded:!0,intent:"primary-subtle",icon:(0,i.jsx)(W.CBv,{className:"w-5 h-5"}),onClick:()=>x.open(),disabled:s.presets.length<2,title:"Reorder Priority"}),(0,i.jsx)(w,{rounded:!0,intent:$?"primary":"primary-subtle",icon:(0,i.jsx)(W.hpl,{className:"w-5 h-5"}),onClick:()=>{$?o(new Set):o(new Set(M.map(e=>e.instanceId)))},disabled:0===M.length,title:$?"Deselect All":"Select All"})]}),children:[s.presets.length>0&&(0,i.jsxs)("div",{className:"space-y-3 mb-4",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)("div",{className:"flex-1 min-w-[140px]",children:(0,i.jsx)(K,{value:h,onChange:e=>p(e.target.value),placeholder:"Search addons...",leftIcon:(0,i.jsx)(mX.A,{className:"w-4 h-4"})})}),D&&(0,i.jsxs)("div",{className:"flex items-center gap-1.5 animate-in fade-in duration-150",children:[(0,i.jsxs)("span",{className:"text-xs font-semibold text-[--brand] whitespace-nowrap",children:[l.size," selected"]}),(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"primary-subtle",icon:L?(0,i.jsx)(W.lXh,{className:"w-3.5 h-3.5"}):(0,i.jsx)(W.czG,{className:"w-3.5 h-3.5"}),onClick:()=>{a(e=>({...e,presets:e.presets.map(e=>l.has(e.instanceId)?{...e,enabled:L}:e)}))},title:L?"Enable selected":"Disable selected"}),"pro"===n&&U.length>0&&(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,i.jsx)(W.H6t,{className:"w-3.5 h-3.5"}),onClick:()=>{y("pick"),N(new Set),S({}),g.open()},title:"Edit common fields"}),(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,i.jsx)(W.kIN,{className:"w-3.5 h-3.5"}),onClick:()=>f.open(),title:"Set category"}),(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"alert-subtle",icon:(0,i.jsx)(W.Mst,{className:"w-3.5 h-3.5"}),onClick:()=>F.open(),title:"Delete selected"})]})]}),(0,i.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,i.jsxs)("button",{onClick:()=>c("all"),className:`px-2.5 py-1 text-xs font-medium rounded-full border transition-colors ${"all"===d?"bg-[--brand]/20 text-[--brand] border-[--brand]/50":"bg-transparent text-[--muted] border-[--border] hover:bg-[--subtle]"}`,children:["All (",s.presets.length,")"]}),E.map(e=>{let t=I.get(e)||0,a=hI(e,s.addonCategoryColors);return(0,i.jsxs)("button",{onClick:()=>c(d===e?"all":e),className:`px-2.5 py-1 text-xs font-medium rounded-full border transition-colors ${d===e?`${a.bg} ${a.text} ${a.border}`:"bg-transparent text-[--muted] border-[--border] hover:bg-[--subtle]"}`,children:[V(e)," (",t,")"]},e)})]})]}),0===s.presets.length?(0,i.jsx)("div",{className:"flex flex-col items-center justify-center py-12",children:(0,i.jsxs)("span",{className:"text-lg text-muted-foreground font-semibold text-center",children:["Looks like you don't have any addons...",(0,i.jsx)("br",{}),"Add some from the marketplace!"]})}):0===M.length?(0,i.jsx)("div",{className:"flex flex-col items-center justify-center py-8",children:(0,i.jsx)("span",{className:"text-sm text-[--muted]",children:"No addons match your search."})}):"all"!==d||h.trim()?(0,i.jsx)("ul",{className:"space-y-1.5",children:M.map(e=>
43(0,i.jsx)(hM,{preset:e,presetMetadata:T.get(e.type),isSelected:l.has(e.instanceId),onToggleSelect:()=>O(e.instanceId),onEdit:()=>t(e,T.get(e.type)),onRemove:()=>{a(t=>{let s=structuredClone(t);return s.presets=s.presets.filter(t=>t.instanceId!==e.instanceId),a7(s)})},onToggleEnabled:t=>{a(s=>({...s,presets:s.presets.map(s=>s.instanceId===e.instanceId?{...s,enabled:t}:s)}))}},e.instanceId))}):(0,i.jsx)("div",{className:"space-y-4",children:E.map(e=>{let r=P[e];if(!r||0===r.length)return null;let n=hI(e,s.addonCategoryColors);return(0,i.jsxs)("div",{children:[(0,i.jsxs)("button",{className:"flex items-center gap-2 mb-2 group cursor-pointer",onClick:()=>{let e=r.map(e=>e.instanceId),t=e.every(e=>l.has(e));o(s=>{let a=new Set(s);for(let s of e)t?a.delete(s):a.add(s);return a})},title:`Select all in ${V(e)}`,children:[(0,i.jsx)("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${n.swatch}`}),(0,i.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wider text-[--muted] group-hover:text-[--foreground] transition-colors",children:V(e)})]}),(0,i.jsx)("ul",{className:"space-y-1.5",children:r.map(e=>(0,i.jsx)(hM,{preset:e,presetMetadata:T.get(e.type),isSelected:l.has(e.instanceId),onToggleSelect:()=>O(e.instanceId),onEdit:()=>t(e,T.get(e.type)),onRemove:()=>{a(t=>{let s=structuredClone(t);return s.presets=s.presets.filter(t=>t.instanceId!==e.instanceId),a7(s)})},onToggleEnabled:t=>{a(s=>({...s,presets:s.presets.map(s=>s.instanceId===e.instanceId?{...s,enabled:t}:s)}))}},e.instanceId))})]},e)})})]}),(0,i.jsx)(hS,{open:x.isOpen,onOpenChange:x.toggle,presets:s.presets,presetMetadataMap:T,manifestCache:hC,onSave:e=>{a(t=>({...t,presets:e}))}}),(0,i.jsx)(sl,{open:g.isOpen,onOpenChange:g.toggle,title:"pick"===b?"Choose Fields to Edit":"Edit Selected Fields",children:"pick"===b?(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["Select which fields to update across ",l.size," selected addon(s). Only fields common to all selected addons are shown."]}),(0,i.jsx)("div",{className:"space-y-1.5 max-h-[50vh] overflow-y-auto",children:U.map(e=>(0,i.jsxs)("button",{onClick:()=>{N(t=>{let s=new Set(t);return s.has(e.id)?s.delete(e.id):s.add(e.id),s})},className:`w-full text-left px-3 py-2.5 rounded-lg border transition-colors flex items-center gap-3 ${j.has(e.id)?"border-[--brand]/50 bg-[--brand]/10":"border-[--border] hover:bg-[--subtle]"}`,children:[(0,i.jsx)("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center flex-shrink-0 transition-colors ${j.has(e.id)?"bg-brand-600 border-brand-600":"border-gray-500"}`,children:j.has(e.id)&&(0,i.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:e.name}),e.description&&(0,i.jsx)("p",{className:"text-xs text-[--muted] line-clamp-1",children:e.description})]})]},e.id))}),(0,i.jsxs)(v,{className:"w-full",disabled:0===j.size,onClick:()=>{let e={};for(let t of j){let s=U.find(e=>e.id===t);s&&(e[t]=s.default??void 0)}S(e),y("edit")},children:["Continue (",j.size," field",1!==j.size?"s":"",")"]})]}):(0,i.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),a(e=>({...e,presets:e.presets.map(e=>{if(!l.has(e.instanceId))return e;let t=T.get(e.type),s=new Set(((null==t?void 0:t.OPTIONS)||[]).map(e=>e.id)),a={...e.options};for(let e of j)s.has(e)&&(a[e]=k[e]);return{...e,options:a}})})),g.close()},children:[[...j].map(e=>{let t=U.find(t=>t.id===e);return t?(0,i.jsx)("div",{children:(0,i.jsx)(mM,{option:t,value:k[e],onChange:t=>S(s=>({...s,[e]:t})),disabled:!1})},e):null}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(w,{rounded:!0,intent:"primary-subtle",icon:(0,i.jsx)(W.wwB,{className:"w-4 h-4"}),onClick:()=>y("pick"),title:"Back",type:"button"}),(0,i.jsxs)(v,{className:"flex-1",type:"submit",children:["Apply to ",l.size," addon(s)"]})]})]})}),(0,i.jsx)(sl,{open:f.isOpen,onOpenChange:f.toggle,title:"Set Category",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["Choose a category for the ",l.size," selected addon(s), or create a new one."]}),(0,i.jsxs)("div",{className:"space-y-1.5 max-h-[40vh] overflow-y-auto",children:[(0,i.jsx)("button",{onClick:()=>z(void 0),className:"w-full text-left px-3 py-2 rounded-lg border border-[--border] hover:bg-[--subtle] transition-colors text-sm",children:"Reset to Default"}),E.map(e=>{let t=hI(e,s.addonCategoryColors);return(0,i.jsxs)("button",{onClick:()=>z(e),className:"w-full text-left px-3 py-2 rounded-lg border border-[--border] hover:bg-[--subtle] transition-colors flex items-center gap-2",children:[(0,i.jsx)("span",{className:`inline-block w-3 h-3 rounded-full ${t.swatch}`}),(0,i.jsx)("span",{className:"text-sm",children:V(e)}),(0,i.jsx)("span",{className:"text-xs text-[--muted] ml-auto",children:I.get(e)||0})]},e)})]}),(0,i.jsxs)("div",{className:"pt-2 border-t border-[--border] space-y-3",children:[(0,i.jsx)("p",{className:"text-xs font-medium text-[--muted] uppercase tracking-wide",children:"New Category"}),(0,i.jsx)(K,{value:C,onValueChange:_,placeholder:"e.g. Usenet, HTTP, Anime..."}),(0,i.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h_.map(e=>(0,i.jsx)("button",{onClick:()=>
43R(e.key),className:`w-6 h-6 rounded-full ${e.swatch} transition-all ${A===e.key?"ring-2 ring-offset-2 ring-offset-[--background] ring-white/60 scale-110":"hover:scale-110"}`,title:e.key},e.key))}),(0,i.jsx)(v,{className:"w-full",size:"md",disabled:!C.trim(),onClick:()=>{var e;e=C.trim(),a(t=>({...t,presets:t.presets.map(t=>l.has(t.instanceId)?{...t,category:e}:t),addonCategoryColors:{...t.addonCategoryColors||{},[e]:A}})),m.oR.info(`Categorised ${l.size} addon(s) as "${e}"`),f.close(),_(""),_("")},children:"Create & Apply"})]})]})}),(0,i.jsx)(sc,{...F})]})}function hM(e){var t,s,a,r,n,l;let{preset:o,presetMetadata:d,isSelected:c,onToggleSelect:h,onEdit:p,onRemove:x,onToggleEnabled:g}=e,{setUserData:f}=ri(),[b,y]=(0,u.useState)(!1),[j,N]=(0,u.useState)(o.logo||(null==d?void 0:d.LOGO)),[k,S]=(0,u.useState)(1),C=so(!1),[_,A]=(0,u.useState)(""),[R,T]=(0,u.useState)(!1),I=sd({title:"Delete Addon",description:`Are you sure you want to delete "${(null==(t=o.options)?void 0:t.name)||"this addon"}"?`,actionText:"Delete",actionIntent:"alert",onConfirm:x}),E=e=>e.replace(/^stremio:\/\//,"https://").replace(/\/$/,""),M=()=>{if((null==d?void 0:d.ID)==="custom"||(null==d?void 0:d.ID)==="aiostreams")return o.options.manifestUrl;let e=o.options.url;if(e)try{if(new URL(e).pathname.endsWith("/manifest.json"))return e}catch{}};(0,u.useEffect)(()=>{C.isOpen&&S(1)},[C.isOpen]),(0,u.useEffect)(()=>{let e=!0,t=M();if(t){let a=E(t),r=hC.get(a);if(r){var s;y((null==(s=r.behaviorHints)?void 0:s.configurable)===!0),N(r.logo);return}fetch(a).then(e=>e.json()).then(t=>{if(hC.set(a,t),e){var s;y((null==t||null==(s=t.behaviorHints)?void 0:s.configurable)===!0),N(null==t?void 0:t.logo)}}).catch(()=>{e&&y(!1)})}return()=>{e=!1}},[null==d?void 0:d.ID,o.options.manifestUrl,o.options.url]);let P=async e=>{e.preventDefault();let t=E(_);if(!_)return void m.oR.error("Please enter a new manifest URL");if(!/^(https?|stremio):\/\/.+\/manifest\.json$/.test(t))return void m.oR.error("Please enter a valid manifest URL");try{T(!0);let e=await fetch(t);if(!e.ok)throw Error(`${e.status} ${e.statusText}`);await e.json()}catch(e){m.oR.error(`Failed to fetch or parse manifest: ${e.message}`),T(!1);return}f(e=>{let s=e.presets.find(e=>e.instanceId===o.instanceId);if(!s)return e;let a=(null==d?void 0:d.ID)==="custom"||(null==d?void 0:d.ID)==="aiostreams"?{...s.options,manifestUrl:t}:{...s.options,url:t};return{...e,presets:e.presets.map(e=>e.instanceId===o.instanceId?{...e,options:a}:e)}}),A(""),C.close(),m.oR.success("Manifest URL updated successfully"),T(!1)};return(0,i.jsxs)("li",{children:[(0,i.jsxs)("div",{className:`px-2.5 py-2 rounded-[--radius-md] border flex gap-2 sm:gap-3 items-center transition-colors ${c?"border-brand-500/50 bg-brand-500/10":"bg-[var(--background)] border-[--border]"}`,children:[(0,i.jsx)("button",{onClick:h,className:"flex items-center justify-center flex-shrink-0",children:(0,i.jsx)("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${c?"bg-brand-600 border-brand-600":"border-gray-500 hover:border-gray-400"}`,children:c&&(0,i.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,i.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})}),(0,i.jsx)("div",{className:"relative flex-shrink-0 h-8 w-8 hidden sm:block",children:j?(0,i.jsx)("img",{src:j,alt:(null==d?void 0:d.NAME)||"",className:"absolute inset-0 w-full h-full object-contain rounded-md",referrerPolicy:"no-referrer"}):(null==d?void 0:d.ID)==="custom"?(0,i.jsx)(m3.A,{className:"w-full h-full object-contain text-[--brand]"}):(null==(a=o.options.name)||null==(s=a.trim())?void 0:s[0])?(0,i.jsx)("div",{className:"w-full h-full flex items-center justify-center rounded-md bg-gray-950",children:(0,i.jsx)("p",{className:"text-lg font-bold",children:(null==(l=o.options.name)||null==(n=l.trim())||null==(r=n[0])?void 0:r.toUpperCase())||"?"})}):(0,i.jsx)(m0.Yoo,{className:"w-full h-full object-contain text-[--brand]"})}),(0,i.jsx)("p",{className:"text-base line-clamp-1 truncate block flex-1 min-w-0",children:o.options.name}),(0,i.jsxs)("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[(0,i.jsx)(ni,{value:o.enabled??!1,onValueChange:g}),b&&(0,i.jsx)(w,{className:"rounded-full h-8 w-8 md:h-10 md:w-10",icon:(0,i.jsx)(W.xPd,{}),intent:"primary-subtle",onClick:()=>C.open()}),(0,i.jsx)(w,{className:"rounded-full h-8 w-8 md:h-10 md:w-10",icon:(0,i.jsx)(sm.u6n,{}),intent:"primary-subtle",onClick:p}),(0,i.jsx)(w,{className:"rounded-full h-8 w-8 md:h-10 md:w-10",icon:(0,i.jsx)(sm.id1,{}),intent:"alert-subtle",onClick:()=>I.open()})]})]}),(0,i.jsxs)(sl,{open:C.isOpen,onOpenChange:C.toggle,title:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"mr-1.5",children:"Reconfigure"}),(0,i.jsx)("span",{className:"font-semibold truncate overflow-hidden text-ellipsis",children:o.options.name})]}),titleClass:"truncate max-w-sm",children:[1===k&&(0,i.jsxs)("div",{className:"text-center space-y-4",children:[(0,i.jsx)("div",{className:"mx-auto bg-[--subtle] rounded-full h-12 w-12 flex items-center justify-center",children:(0,i.jsx)(W.TdP,{className:"h-6 w-6 text-[--brand]"})}),(0,i.jsx)("h3",{className:"text-lg font-semibold",children:"Reconfigure in a new tab"}),(0,i.jsx)("p",{className:"text-sm text-[var(--muted-foreground)]",children:"You'll be taken to a new tab to adjust your settings. Once finished, you will be given a new manifest URL to paste back here."}),(0,i.jsx)(v,{className:"w-full",onClick:()=>{let e;window.open((e=M())?E(e).replace(/\/manifest\.json$/,"/configure"):"","_blank"),S(2)},children:(0,i.jsx)("span",{className:"truncate",children:"Take me to configuration"})})]}),2===k&&(0,i.jsxs)("div",{className:"space-y-4 max-w-md",children:[(0,i.jsxs)("div",{className:"text-center",children:[(0,i.jsx)("div",{className:"mx-auto bg-[--subtle] rounded-full h-12 w-12 flex items-center justify-center",children:(0,i.jsx)(W.GzK,{className:"h-6 w-6 text-[--brand]"})}),(0,i.jsx)("h3",{className:"text-lg font-semibold",children:"Awaiting New URL"}),(0,i.jsx)("p",{className:"text-sm text-[var(--muted-foreground)]",children:"After adjusting your settings, copy the manifest URL and paste it below."})]}),(0,i.jsxs)("form",{onSubmit:P,className:"space-y-4 pt-2",children:[(0,i.jsx)(K,{type:"url",label:"New Manifest URL",placeholder:"Paste your new URL here",value:_,onValueChange:A,required:!0,autoFocus:!0}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(v,{intent:"primary-subtle",onClick:()=>S(1),children:"Back"}),(0,i.jsxs)(v,{loading:R,type:"submit",className:"max-w-sm w-full text-ellipsis whitespace-nowrap overflow-hidden text-left",children:["Update ",o.options.name]})]})]})]})]}),(0,i.jsx)(sc,{...I})]})}function hP(){return(0,i.jsx)(ng,{className:"space-y-4 p-4 sm:p-8",children:(0,i.jsx)(hD,{})})}function h$(e){return JSON.stringify((e??[]).map(e=>[e.instanceId,e.enabled,e.options]))}function hD(){let{status:e}=tj(),{mode:t}=sF(),{userData:s,setUserData:a}=ri(),{isInherited:r,hasParent:n}=ro(),[l,o]=(0,u.useState)("installed"),{tab:d,setTab:c}=rv("addons"),[h,p]=(0,u.useState)(()=>new Set),[x,g]=(0,u.useState)([]),[f,b]=(0,u.useState)(null),v=(0,u.useCallback)(()=>b(null),[]),y=(0,u.useMemo)(()=>h$(s.presets),[s.presets]),j=(0,u.useRef)(y);j.current=y;let{mutate:w,isPending:N}=(0,e5.n)({mutationFn:e=>eI(e),onSuccess:(e,t)=>{if(h$(t.presets)!==j.current)return;let s=e.map(ht);g(s);let r=t.catalogModifications??[];if(r.length){let e=new Set(r.map(ht)),t=s.filter(t=>!e.has(t));t.length&&p(e=>new Set([...e,...t]))}a(a=>{let r=a.catalogModifications||[],n=new Set(r.map(ht)),l=new Set(a.newCatalogsDisabled),i=new Set(a.upstreamCatalogOrder),o=r.map(t=>{if(t.id.startsWith("aiostreams.merged."))return t;let s=e.find(e=>e.id===t.id&&e.type===t.type);return s&&(s.addonName!==t.addonName||s.type!==t.type||s.hideable!==t.hideable||s.genreRequired!==t.genreRequired||s.searchable!==t.searchable)?{...t,addonName:s.addonName,type:s.type,hideable:s.hideable,genreRequired:s.genreRequired,searchable:s.searchable}:t});
43e.forEach(e=>{if(!n.has(ht(e))){let s=hs(e.id),a=i.has(s)?o.findLastIndex(e=>hs(e.id)===s):-1;o.splice(-1===a?o.length:a+1,0,{id:e.id,name:e.name,type:e.type,enabled:!l.has(e.id.split(".")[0]),shuffle:!1,usePosterService:!!(t.rpdbApiKey||t.topPosterApiKey||t.aioratingsApiKey),hideable:e.hideable,genreRequired:e.genreRequired,searchable:e.searchable,addonName:e.addonName})}});let d=new Set(s),c=new Set((a.mergedCatalogs||[]).map(e=>e.id)),u=hr(a.presets),m=o.filter(e=>e.id.startsWith("aiostreams.merged.")&&c.has(e.id)||d.has(ht(e))||u.has(ha(e.id)));return{...a,catalogModifications:hn(m,i,s)}})},onError:e=>{console.error("Error fetching catalogs:",e),e instanceof es?m.oR.error(e.message):m.oR.error("Failed to fetch catalogs")}}),k=(0,u.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];w(s,{onSuccess:e?void 0:()=>m.oR.success("Catalogs fetched successfully")})},[w,s]);(0,u.useEffect)(()=>{var e;(null==(e=s.presets)?void 0:e.length)&&w(s)},[y]);let[S,C]=(0,u.useState)(""),[_,A]=(0,u.useState)("all"),[R,T]=(0,u.useState)("all"),[I,E]=(0,u.useState)("all"),[M,P]=(0,u.useState)(!1),[$,D]=(0,u.useState)("add"),[L,O]=(0,u.useState)(null),[U,F]=(0,u.useState)({}),[z,V]=(0,u.useState)(null),q=(0,u.useMemo)(()=>{var t;if(!(null==e||null==(t=e.settings)?void 0:t.presets))return[];let s=[...e.settings.presets.filter(e=>{var t;return!(null==(t=e.DISABLED)?void 0:t.removed)})];return"all"!==_&&(s=s.filter(e=>(e.CATEGORY||"streams")===_)),"all"!==R&&(s=s.filter(e=>e.SUPPORTED_SERVICES&&e.SUPPORTED_SERVICES.includes(R))),"all"!==I&&(s=s.filter(e=>e.SUPPORTED_STREAM_TYPES&&e.SUPPORTED_STREAM_TYPES.includes(I))),S&&(s=s.filter(e=>e.NAME.toLowerCase().includes(S.toLowerCase())||e.DESCRIPTION.toLowerCase().includes(S.toLowerCase()))),s},[e,S,_,R,I]);function B(e){O(e),F({options:Object.fromEntries((e.OPTIONS||[]).map(e=>[e.id,e.forced??e.default??void 0]))}),D("add"),V(null),P(!0)}let H=Object.values(ap).map(e=>({label:e.name,value:e.id})),G={p2p:"P2P",http:"HTTP",usenet:"Usenet",debrid:"Debrid",live:"Live"},Y=(aE||[]).filter(e=>!["error","statistic","external","youtube","stremio-usenet","archive"].includes(e)).map(e=>({label:G[e],value:e})),Z=q.filter(e=>"streams"===e.CATEGORY||!e.CATEGORY),Q=q.filter(e=>"subtitles"===e.CATEGORY),X=q.filter(e=>"meta_catalogs"===e.CATEGORY),ee=q.filter(e=>"misc"===e.CATEGORY),et="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 3xl:grid-cols-5 5xl:grid-cols-6 6xl:grid-cols-7 7xl:grid-cols-8 gap-4";return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,i.jsx)(nX,{className:"w-fit max-w-full border rounded-full py-0",triggerClass:"px-4 py-1 text-md h-full rounded-full",pillClass:"rounded-full border-transparent",items:[{name:"Installed",isCurrent:"installed"===l,onClick:()=>o("installed"),iconType:W.Oz0},{name:"Marketplace",isCurrent:"marketplace"===l,onClick:()=>o("marketplace"),iconType:W.LG1}]}),(0,i.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,i.jsx)(mg,{})})]}),(0,i.jsxs)(t7.N,{mode:"wait",children:["installed"===l&&(0,i.jsx)(ng,{initial:{opacity:0,y:60},animate:{opacity:1,y:0},exit:{opacity:0,scale:.99},transition:{duration:.35},className:"pt-0 space-y-6 relative z-[4]",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("h2",{children:"Installed"}),n&&r("presets")&&(0,i.jsx)(my,{section:"presets"})]}),(0,i.jsx)("p",{className:"text-[--muted] text-sm",children:"Manage your installed addons and catalog settings."})]}),(0,i.jsx)(mv,{activeTab:d,onTabChange:e=>c(e),defaultMobileOpen:"addons",tabs:[{value:"addons",label:"Addons",icon:(0,i.jsx)(m0.Yoo,{className:"w-4 h-4"}),content:(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsx)(hE,{onEdit:function(e,t){O(t),F({options:{...e.options}}),D("edit"),V(e.instanceId),P(!0)}}),s.presets.length>0&&"pro"===t&&(0,i.jsx)(m8,{})]})},{value:"catalogs",label:"Catalogs",icon:(0,i.jsx)(m1.S$x,{className:"w-4 h-4"}),content:(0,i.jsx)("div",{className:"space-y-6",children:0===s.presets.length?(0,i.jsx)(J,{className:"p-8 text-center",children:(0,i.jsx)("p",{className:"text-[--muted]",children:"Install some addons first to configure catalogs."})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(hN,{request:f,onRequestHandled:v}),(0,i.jsx)(hj,{loading:N,fetchCatalogsData:k,newCatalogs:h,upstreamKeys:x,onMerge:b})]})})}]})]})},"installed"),"marketplace"===l&&(0,i.jsx)(ng,{initial:{opacity:0,y:60}
43,animate:{opacity:1,y:0},exit:{opacity:0,scale:.99},transition:{duration:.35},className:"pt-0 space-y-6 relative z-[4]",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Marketplace"}),(0,i.jsx)("p",{className:"text-[--muted] text-sm",children:"Browse and install addons from the marketplace."})]}),(0,i.jsx)(nX,{className:"w-fit max-w-full border rounded-full py-0",triggerClass:"px-4 py-1 text-sm h-full rounded-full",pillClass:"rounded-full border-transparent",items:[{name:"All",isCurrent:"all"===_,onClick:()=>A("all")},{name:"Streams",isCurrent:"streams"===_,onClick:()=>A("streams")},{name:"Subtitles",isCurrent:"subtitles"===_,onClick:()=>A("subtitles")},{name:"Metadata & Catalogs",isCurrent:"meta_catalogs"===_,onClick:()=>A("meta_catalogs")},{name:"Miscellaneous",isCurrent:"misc"===_,onClick:()=>A("misc")}]}),(0,i.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2",children:[(0,i.jsxs)("div",{className:"flex gap-2 flex-1 lg:flex-none",children:[(0,i.jsx)(nc,{value:R,onValueChange:T,options:[{label:"All Services",value:"all"},...H],fieldClass:"lg:w-[200px]"}),(0,i.jsx)(nc,{value:I,onValueChange:E,options:[{label:"All Types",value:"all"},...Y],fieldClass:"lg:w-[200px]"})]}),(0,i.jsx)(K,{value:S,onChange:e=>C(e.target.value),placeholder:"Search addons...",className:"flex-1",leftIcon:(0,i.jsx)(mX.A,{className:"w-4 h-4"})})]}),0===q.length&&(0,i.jsx)(J,{className:"p-8 text-center",children:(0,i.jsx)("p",{className:"text-[--muted]",children:"No addons found matching your criteria."})}),!!(null==Z?void 0:Z.length)&&(0,i.jsxs)(J,{className:"p-4 space-y-6",children:[(0,i.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,i.jsx)(m2.j$e,{})," Streams"]}),(0,i.jsx)("div",{className:et,children:Z.map(e=>(0,i.jsx)(m5,{preset:e,onAdd:()=>B(e)},e.ID))})]}),!!(null==Q?void 0:Q.length)&&(0,i.jsxs)(J,{className:"p-4 space-y-6",children:[(0,i.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,i.jsx)(m1.zZ_,{})," Subtitles"]}),(0,i.jsx)("div",{className:et,children:Q.map(e=>(0,i.jsx)(m5,{preset:e,onAdd:()=>B(e)},e.ID))})]}),!!(null==X?void 0:X.length)&&(0,i.jsxs)(J,{className:"p-4 space-y-6",children:[(0,i.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,i.jsx)(m1.S$x,{})," Metadata & Catalogs"]}),(0,i.jsx)("div",{className:et,children:X.map(e=>(0,i.jsx)(m5,{preset:e,onAdd:()=>B(e)},e.ID))})]}),!!(null==ee?void 0:ee.length)&&(0,i.jsxs)(J,{className:"p-4 space-y-6",children:[(0,i.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,i.jsx)(W.xPd,{})," Miscellaneous"]}),(0,i.jsx)("div",{className:et,children:ee.map(e=>(0,i.jsx)(m5,{preset:e,onAdd:()=>B(e)},e.ID))})]})]})},"marketplace")]}),(0,i.jsx)(m4,{open:M,onOpenChange:P,mode:$,presetMetadata:L,initialValues:U,onSubmit:function(e){if("add"===$&&L){let t={type:L.ID,instanceId:function e(){let t=Math.floor(4095*Math.random()).toString(16).padStart(3,"0");return s.presets.some(e=>e.instanceId===t)?e():t}(),enabled:!0,options:e.options},r=hL(t);if(s.presets.some(e=>hL(e)===r)){m.oR.error("You already have an addon with the same options added."),P(!1);return}a(e=>({...e,presets:[...e.presets,t]})),m.oR.info("Addon installed successfully!"),P(!1)}else"edit"===$&&z&&(a(t=>({...t,presets:t.presets.map(t=>t.instanceId===z?{...t,options:e.options}:t)})),m.oR.info("Addon updated successfully!"),P(!1))}})]})}function hL(e){return JSON.stringify({type:e.type,enabled:e.enabled,options:e.options})}function hO(e){return e.split(".").map(e=>Number(e)||0)}function hU(e){let[t=1,s=0,a=0]=hO(e);return`${t}.${s}.${a+1}`}let hF={title:"Share this template?",description:"It is uploaded exactly as it is: nothing is checked, rewritten or removed on the server. Service credentials, API keys and addon passwords are replaced with placeholders when a template is built from your configuration, but variant scripts, addon URLs, regex patterns and other free text are included as written. Check them for keys, tokens or personal details before sharing.",actionText:"I checked, share it",actionIntent:"primary"};function hz(e,t){if(!t)return e;let s=e.metadata.version,a=s&&function(e,t){let s=hO(e),a=hO(t);for(let e=0;e<3;e++){let t=(s[e]??0)-(a[e]??0);if(0!==t)return t}return 0}(s,t.version)>0?s:hU(t.version);return{...e,metadata:{...e.metadata,version:a}}}async function hV(e,t,s){let a,r=(a=t.metadata.name.trim().toLowerCase(),null==s?void 0:s.find(e=>"template"===e.kind&&e.name.toLowerCase()===a)),n=hz(t,r);return{item:r?await eV(e,r.id,{template:n}):await ez(e,n),updated:!!r}}function hq(e,t){return e.draft?"Update submitted for review":"pending"===e.status?"Submitted for review":t?"Update published":"Shared with the community"}function hB(){return new Promise((e,t)=>
43{let s=document.createElement("input");s.type="file",s.accept=".json",s.onchange=async()=>{var a;let r=null==(a=s.files)?void 0:a[0];if(!r)return e(null);try{e(JSON.parse(await r.text()))}catch(e){t(Error("That file is not valid JSON"))}},s.oncancel=()=>e(null),s.click()})}function hK(e){return!!e&&"object"==typeof e&&"object"==typeof e.metadata&&"object"==typeof e.config}let hH=["ip","uuid","accessKey","tmdbAccessToken","tmdbApiKey","tvdbApiKey","pmdbApiKey","rpdbApiKey","topPosterApiKey","aioratingsApiKey","aioratingsProfileId","openposterdbApiKey","openposterdbUrl","openposterdbParameters"];function hW(e){var t;return(null==(t=e.tags)?void 0:t.length)?e.tags:e.category?[e.category.toLowerCase()]:[]}function hG(e,t,s){return Object.fromEntries(Object.entries(e??{}).flatMap(e=>{let[a,r]=e,n=null==t?void 0:t.find(e=>e.id===a);if((null==n?void 0:n.type)==="password")return void 0!==s&&void 0!==r&&""!==r?[[a,s]]:[];let l=null==n?void 0:n.subOptions;return(null==l?void 0:l.length)&&r&&"object"==typeof r&&!Array.isArray(r)?[[a,hG(r,l,s)]]:[[a,r]]}))}function hY(e,t,s){let a=structuredClone(e);for(let e of hH)a[e]=void 0;return Array.isArray(a.services)&&(a.services=a.services.map(e=>({...e,credentials:{}}))),a.proxy&&"object"==typeof a.proxy&&(a.proxy={...a.proxy,credentials:void 0,url:void 0,publicUrl:void 0}),Array.isArray(a.presets)&&(a.presets=a.presets.map(e=>e&&"object"==typeof e&&"string"==typeof e.type?{...e,options:hG(e.options,t(e.type),s)}:e)),a}var hJ=s(70811),hZ=s(51915),hQ=s(95107),hX=s(87209);function h0(e){let t=new Set;for(let s of e.split(",")){let e=s.trim().toLowerCase().slice(0,20);if(e&&t.add(e),t.size>=5)break}return[...t]}let h1=["debrid","p2p","usenet","anime","minimal","4k"];function h2(e){var t;let{userData:s,filterCredentials:a,presets:r,meta:n}=e,l=a(s);s.tmdbApiKey&&(l.tmdbApiKey="<template_placeholder>"),s.tmdbAccessToken&&(l.tmdbAccessToken="<template_placeholder>"),s.tvdbApiKey&&(l.tvdbApiKey="<template_placeholder>"),s.pmdbApiKey&&(l.pmdbApiKey="<template_placeholder>"),s.rpdbApiKey&&(l.rpdbApiKey="<template_placeholder>"),(null==(t=s.proxy)?void 0:t.enabled)&&(l.proxy={...l.proxy,url:s.proxy.url?"<template_placeholder>":void 0,publicUrl:s.proxy.publicUrl?"<template_placeholder>":void 0,credentials:s.proxy.credentials?"<template_placeholder>":void 0,publicIp:s.proxy.publicIp?"<template_placeholder>":void 0}),l.presets&&l.presets.length>0&&(l.presets=l.presets.map(e=>{var t;let a=r.find(t=>t.ID===e.type),n=null==(t=s.presets)?void 0:t.find(t=>t.instanceId==e.instanceId);return{...e,options:hG((null==n?void 0:n.options)??e.options,null==a?void 0:a.OPTIONS,"<template_placeholder>")}}));let i=new Date,o=e=>e.toString().padStart(2,"0"),d=`${i.getFullYear()}-${o(i.getMonth()+1)}-${o(i.getDate())}.${o(i.getHours())}-${o(i.getMinutes())}-${o(i.getSeconds())}`;return{metadata:{id:`${n.name.toLowerCase().replace(/\s+/g,"-")}-${d}-${Math.random().toString(36).slice(2,9)}`,name:n.name.trim(),description:n.description.trim(),source:"external",author:n.author.trim(),version:n.version??"1.0.0",category:n.tags[0]??"general",tags:n.tags,services:void 0,serviceRequired:!1,setToSaveInstallMenu:!0},config:l}}function h3(e){let{open:t,onOpenChange:s,userData:a,filterCredentials:r}=e,{status:n}=tj(),[l,o]=(0,u.useState)(""),[d,c]=(0,u.useState)(""),[h,p]=(0,u.useState)(""),[x,g]=(0,u.useState)("");(0,u.useEffect)(()=>{t&&(o(""),c(""),p(""),g(""))},[t]);let f=(0,u.useMemo)(()=>h0(x),[x]);return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Export as Template",description:"Configure your template metadata and settings",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(lB,{intent:"info",description:(0,i.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,i.jsx)("p",{children:"A template is a configuration file that others can use as a starting point. Service credentials, API keys and addon passwords are replaced with placeholders; variant scripts and other free text are kept as written."}),(0,i.jsxs)("p",{children:[(0,i.jsx)("strong",{children:"Want more control?"})," Edit the exported JSON manually to add advanced features like:"]}
43),(0,i.jsxs)("ul",{className:"list-disc list-inside ml-2 space-y-1",children:[(0,i.jsx)("li",{children:"Conditional inputs and fields based on user selections"}),(0,i.jsx)("li",{children:"Template placeholders for dynamic values"}),(0,i.jsx)("li",{children:"Service filtering and smart service selection"}),(0,i.jsx)("li",{children:"Custom validation and input grouping"})]}),(0,i.jsxs)("p",{children:["See the"," ",(0,i.jsx)("a",{href:"https://docs.aiostreams.viren070.me/guides/templates",target:"_blank",className:"text-[--brand] hover:text-[--brand]/80 hover:underline",rel:"noopener noreferrer",children:"Templates docs"})," ","for detailed documentation."]})]})}),(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)(K,{label:"Template Name",placeholder:"e.g. My AIOStreams setup",value:l,onValueChange:o,required:!0}),(0,i.jsx)(ly,{label:"Description",placeholder:"Describe what makes this template useful...",value:d,onValueChange:c,required:!0,rows:3}),(0,i.jsx)(K,{label:"Author",placeholder:"Your name or username",value:h,onValueChange:p,required:!0}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(K,{label:"Tags",placeholder:"Comma separated, up to 5",value:x,onValueChange:g,required:!0}),(0,i.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h1.map(e=>(0,i.jsx)(v,{intent:f.includes(e)?"primary":"gray-outline",size:"sm",onClick:()=>{g((f.includes(e)?f.filter(t=>t!==e):[...f,e]).join(", "))},type:"button",children:e},e))})]})]}),(0,i.jsxs)("div",{className:"flex flex-wrap justify-end gap-2 pt-2 border-t border-gray-700",children:[(0,i.jsx)(v,{intent:"primary-outline",onClick:()=>s(!1),children:"Cancel"}),(0,i.jsx)(v,{intent:"white",rounded:!0,onClick:()=>{if(l.trim()?d.trim()?h.trim()?0!==f.length||(m.oR.error("Please add at least one tag"),!1):(m.oR.error("Please enter an author name"),!1):(m.oR.error("Please enter a description"),!1):(m.oR.error("Please enter a template name"),!1))try{let e=h2({userData:a,filterCredentials:r,presets:(null==n?void 0:n.settings.presets)??[],meta:{name:l,description:d,author:h,tags:f}}),t=JSON.stringify(e,null,2),i=new Blob([t],{type:"application/json"}),o=URL.createObjectURL(i),c=document.createElement("a");c.href=o,c.download=`${e.metadata.id}-template.json`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(o),m.oR.success("Template exported successfully"),s(!1)}catch(e){m.oR.error("Failed to export template")}},children:"Export Template"})]})]})})}let h5={approved:"bg-green-500/20 text-green-400 border-green-500/30",pending:"bg-yellow-400/20 text-yellow-400 border-yellow-400/30",rejected:"bg-red-400/20 text-red-300 border-red-400/30"};function h4(e,t){return(0,i.jsx)("span",{className:x("text-xs px-2 py-0.5 rounded border whitespace-nowrap",e),children:t})}function h6(e){let{open:t,onOpenChange:s,credentials:a,userData:r,filterCredentials:n,onChanged:l}=e,o=(0,e3.jE)(),{status:d}=tj(),c=(0,ty.I)({...tv(a),enabled:t}),h=(0,u.useMemo)(()=>(c.data??[]).filter(e=>"template"===e.kind),[c.data]),p=()=>{o.invalidateQueries({queryKey:tf}),o.invalidateQueries({queryKey:tb}),l()},x=(0,e5.n)({mutationFn:e=>eV(a,e.id,{template:h2({userData:r,filterCredentials:n,presets:(null==d?void 0:d.settings.presets)??[],meta:{name:e.name,description:e.description,author:e.author,tags:e.tags??[],version:hU(e.version)}})}),onSuccess:e=>{m.oR.success(e.draft?"Update submitted for review":"Update published"),p()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to update")}),g=(0,e5.n)({mutationFn:async e=>{let t=await hB();if(null===t)return null;if(!hK(t))throw Error("That file is not a template (needs metadata and config)");return eV(a,e.id,{template:hz(t,e)})},onSuccess:e=>{e&&(m.oR.success(hq(e,!0)),p())},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to update")}),f=(0,e5.n)({mutationFn:async()=>{let e=await hB();if(null===e)return null;if(!hK(e))throw Error("That file is not a template (needs metadata and config)");return hV(a,e,c.data)},onSuccess:e=>{e&&(m.oR.success(hq(e.item,e.updated)),p())},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to share")}),b=(0,e5.n)({mutationFn:e=>eq(a,e),onSuccess:()=>{m.oR.success("Update withdrawn"),p()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to withdraw")}),y=(0,e5.n)({mutationFn:e=>eB(a,e),onSuccess:()=>{m.oR.success("Removed from the community"),p()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to delete")}),j=(0,u.useRef)(()=>{}),w=sd({...hF,onConfirm:()=>j.current()}),N=e=>{j.current=e,w.open()};return(0,i.jsxs)(sl,{open:t,onOpenChange:s,title:"My shared templates",description:"Templates you shared with this instance. Share a new one from a JSON file, or update an existing one from your current configuration or a file you maintain.",contentClass:"max-w-2xl w-full",children:[(0,i.jsx)(sc,{...w}),(0,i.jsx)("div",{className:"flex justify-end",children:(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",leftIcon:(0,i.jsx)(hJ.A,{className:"w-4 h-4"}),disabled:f.isPending,onClick:()=>N(()=>f.mutate()),children:"Share a template JSON"})}),c.isPending?(0,i.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"Loading..."}):0===h.length?(0,i.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"You have not shared a template yet. Share a template JSON above, or use the share button on an imported templateâs card."}):(0,i.jsx)("div",{className:"space-y-2 max-h-[60vh] overflow-y-auto pr-1",children:h.map(e=>(0,i.jsx)(h9,{item:e,onUpdate:()=>N(()=>x.mutate(e)),onUpdateFromFile:()=>N(()=>g.mutate(e)),onWithdraw:()=>b.mutate(e.id),onDelete:()=>y.mutate(e.id),busy:x.isPending||g.isPending||f.isPending||b.isPending||y.isPending},e.id))})]})}function h9(e){let{item:t,onUpdate:s,onUpdateFromFile:a,onWithdraw:r,onDelete:n,busy:l}=e,o=sd({title:"Remove shared template",description:`Remove "${t.name}" from the community? People who applied it keep their configuration.`,actionText:"Remove",actionIntent:"alert-subtle",onConfirm:n}),d=t.draftRejectionReason??t.rejectionReason;return(0,i.jsxs)("div",{className:"rounded-lg border border-gray-800 bg-gray-900/60 p-3 space-y-2",children:[(0,i.jsx)(sc,{...o}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)("span",{className:"font-medium text-sm",children:t.name}),h4("bg-gray-800 text-gray-400 border-gray-700",`v${t.version}`),h4(h5[t.status],t.status),t.draft&&h4(h5.pending,`v${t.draft.version} pending review`),t.likes>0&&h4("bg-pink-500/10 text-pink-300 border-pink-500/30",`${t.likes} likes`)]}),d&&(0,i.jsxs)("p",{className:"text-xs text-red-200",children:[t.draftRejectionReason?"Update rejected: ":"Rejected: ",d]}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",leftIcon:(0,i.jsx)(hZ.A,{className:"w-3.5 h-3.5"}),disabled:l,onClick:s,children:"Update with current config"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(v,{size:"sm",intent:"gray-outline",leftIcon:(0,i.jsx)(hJ.A,{className:"w-3.5 h-3.5"}),disabled:l,onClick:a,children:"From JSON"}),children:"Upload a template JSON you maintain by hand; its version is used when higher than the published one"}),(0,i.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[t.draft&&(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,i.jsx)(hQ.A,{className:"h-3.5 w-3.5"}),disabled:l,onClick:r}),children:"Withdraw pending update"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"alert-subtle",icon:(0,i.jsx)(hX.A,{className:"h-3.5 w-3.5"}),disabled:l,onClick:o.open}),children:"Remove from community"})]})]})]})}var h8=s(46358);let h7=["string","password","url","custom-nntp-servers"],pe=nV.Ik({metadata:nV.Ik({id:nV.Yj().min(1).max(100).optional().transform(e=>e??crypto.randomUUID()),name:nV.Yj().min(1).max(100),description:nV.Yj().min(1).max(1e3),author:nV.Yj().min(1).max(20),source:nV.k5(["builtin","custom","external","community"]).optional().default("builtin"),version:nV.Np("semver",/^[0-9]+\.[0-9]+\.[0-9]+$/).optional().default("1.0.0"),category:nV.Yj().min(1).max(20),tags:nV.YO(nV.Yj().min(1).max(20)).max(5).optional(),services:nV.YO(nV.k5(ao)).optional(),serviceRequired:nV.zM().optional(),setToSaveInstallMenu:nV.zM().optional().default(!0),sourceUrl:nV.OZ().optional(),inputs:nV.YO(nV.bz()).optional(),changelog:nV.YO(nV.Ik({date:nV.Yj(),version:nV.Yj(),content:nV.Yj()})).optional(),changelogUrl:nV.OZ().optional()}),config:nV.bz()}),pt={welcome:"Get started",browse:"Choose a setup",selectService:"Services",templateInputs:"Options",inputs:"Credentials",review:"Review"},ps=new Map,pa=()=>{try{let e=localStorage.getItem("aiostreams-custom-templates");if(e)return nV.YO(pe).parse(JSON.parse(e)).map(e=>({...e,metadata:{...e.metadata,source:"external"}}))}catch(e){console.error("Error loading templates from localStorage:",e)}return[]},pr=e=>{try{localStorage.setItem("aiostreams-custom-templates",JSON.stringify(e))}catch(e){console.error("Error saving templates to localStorage:",e),m.oR.error("Failed to save templates to local storage")}},pn=(e,t)=>{let s=e.split(".").map(Number),a=t.split(".").map(Number);for(let e=0;e<3;
43e++){let t=s[e]||0,r=a[e]||0;if(t>r)return 1;if(t<r)return -1}return 0},pl=Symbol("aiostreams.remove");function pi(e,t){let s=t.split("."),a=e;for(let e of s){if(null==a)return;a=a[e]}return a}function po(e,t,s){let a=e.trim(),r=a.split(/ or (?=!?(?:inputs|services)\b)/);if(r.length>1)return r.some(e=>po(e.trim(),t,s));let n=a.split(/ xor (?=!?(?:inputs|services)\b)/);if(n.length>1)return n.filter(e=>po(e.trim(),t,s)).length%2==1;let l=a.split(/ and (?=!?(?:inputs|services)\b)/);if(l.length>1)return l.every(e=>po(e.trim(),t,s));let i=a.startsWith("!"),o=i?a.slice(1).trim():a,d=o.match(/^(\w+)\.(.+?)\s+(>=|<=|>|<)\s+(-?\d+(?:\.\d+)?)$/);if(d){let[,e,s,a,r]=d,n=parseFloat(r),l=!1;if("inputs"===e){let e=pi(t,s),r="number"==typeof e?e:parseFloat(String(e??""));isNaN(r)||(">="===a?l=r>=n:"<="===a?l=r<=n:">"===a?l=r>n:"<"===a&&(l=r<n))}return i?!l:l}let c=o.match(/^(\w+)\.(.+?)\s+(==|!=|includes)\s+(.+)$/);if(c){let[,e,s,a,r]=c,n=r.trim(),l=!1;if("inputs"===e){let e=pi(t,s);"=="===a?l=String(e??"")===n:"!="===a?l=String(e??"")!==n:"includes"===a&&(Array.isArray(e)?l=e.includes(n):"string"==typeof e&&(l=e.includes(n)))}return i?!l:l}let u=o.indexOf(".");if(-1===u)return"services"===o?i?0===s.length:s.length>0:i;let m=o.slice(0,u),h=o.slice(u+1),p=!1;if("inputs"===m){let e=pi(t,h);p=null!=e&&""!==e&&!1!==e&&!(Array.isArray(e)&&0===e.length)}else"services"===m&&(p=s.includes(h));return i?!p:p}function pd(e){return Array.isArray(e)?e:null!==e&&"object"==typeof e&&Array.isArray(e.__value)?e.__value:[]}let pc=new Set(["string","password","number","boolean","select","select-with-custom","multi-select","url","alert","socials","oauth","subsection","custom-nntp-servers","nab-endpoint"]),pu=new Set(["website","github","discord","ko-fi","patreon","buymeacoffee","github-sponsors","donate"]),pm=new Set(["alert","info","success","warning","info-basic","success-basic","warning-basic","alert-basic"]),ph=new Set(["alert","socials","subsection","custom-nntp-servers","nab-endpoint"]);function pp(e,t){var s,a,r,n,l,i,o,d;let c=[],u=[];if(!e.config)return u.push("Template is missing configuration data"),{isValid:!1,warnings:c,errors:u};let m=pe.safeParse(e);if(!m.success)return u.push((console.log(JSON.stringify(s=m.error,null,2)),h8.S1(s))),{isValid:!1,warnings:c,errors:u};let h=pd(e.config.presets);if(h.length>0&&t){let s=[];h.forEach(e=>{var a,r,n;let l=null==(r=t.settings)||null==(a=r.presets)?void 0:a.find(t=>t.ID===e.type);(!l||(null==(n=l.DISABLED)?void 0:n.disabled))&&(c.push(`"${e.type}" is not available or disabled on this instance.`),s.push(e.type))}),Array.isArray(e.config.presets)&&s.length>0&&(e.config.presets=e.config.presets.filter(e=>!s.includes(e.type)))}if(t){let s=Object.keys((null==(a=t.settings)?void 0:a.services)||{});pd(e.config.services).forEach(e=>{s.includes(e.id)||c.push(`Service "${e.id}" not available on this instance`)});let u=[...pd(e.config.excludedRegexPatterns),...pd(e.config.includedRegexPatterns),...pd(e.config.requiredRegexPatterns),...pd(e.config.preferredRegexPatterns).map(e=>"string"==typeof e?e:e.pattern)];if(u.length>0){let e=(null==(n=t.settings)||null==(r=n.regexAccess)?void 0:r.patterns)||[];if((null==(i=t.settings)||null==(l=i.regexAccess)?void 0:l.level)==="none"&&0===e.length)c.push("Template uses regex patterns but regex access is disabled on this instance");else if((null==(d=t.settings)||null==(o=d.regexAccess)?void 0:o.level)!=="all"){let t=u.filter(t=>!e.includes(t));t.length>0&&c.push(`Template has ${t.length} regex patterns that are not trusted.`)}}}let p=new Set((e.metadata.inputs??[]).map(e=>e.id)),x=new Set,g=(e,t)=>{if(!e||"object"!=typeof e){if("string"==typeof e){for(let[,s,a]of[...e.matchAll(/\{\{(inputs|services)\.([^}]+)\}\}/g)])if("inputs"===s){let e=a.split(".")[0];x.add(e),a.includes(".")&&x.add(a.split(".").slice(0,2).join(".")),p.has(e)||c.push(`${t}: interpolation {{inputs.${a}}} references undeclared input "${e}"`)}}return}if(Array.isArray(e))return void e.forEach((e,s)=>g(e,`${t}[${s}]`));if("__if"in e){let s=e.__if;if("string"==typeof s&&s.trim())for(let e of s.trim().split(/ and | or | xor /)){let s=e.trim().replace(/^!/,"").split(/\s+/)[0],a=s.indexOf(".");if(-1===a)"services"!==s&&u.push(`${t}.__if: "${e.trim()}" is not a valid condition - expected "inputs.<id>" or "services.<id> or "services"`);else{let e=s.slice(0,-1===a?void 0:a),r=s.slice(a+1),n=r.split(".")[0];"inputs"!==e&&"services"!==e?u.push(`${t}.__if: unknown namespace "${e}" - must be "inputs" or "services"`):"inputs"===e&&(x.add(n),r.includes(".")&&x.add(r.split(".").slice(0,2).join(".")),p.has(n)||c.push(`${t}.__if: references undeclared input "${n}"`))}}else u.push(`${t}.__if: condition must be a non-empty string`);let{__if:a,...r}=e;g(r,t);return}if("__switch"in e){let s=e.__switch;if("string"==typeof s&&s.trim()){let e=s.indexOf(".");if(-1===e)"services"!==s.trim()&&u.push(`${t}.__switch: "${s}" is not a valid reference - expected "inputs.<id>" or "services.<id> or "services"`);else{let a=s.slice(0,e),r=s.slice(e+1),n=r.split(".")[0];"inputs"!==a&&"services"!==a?u.push(`${t}.__switch: unknown namespace "${a}" - must be "inputs" or "services"`):"inputs"===a&&(x.add(n),r.includes(".")&&x.add(r.split(".").slice(0,2).join(".")),p.has(n)||c.push(`${t}.__switch: references undeclared input "${n}"`))}}else u.push(`${t}.__switch: value must be a non-empty string`);if(e.cases&&"object"==typeof e.cases)for(let[s,a]of Object.entries(e.cases))g(a,`${t}.__switch.cases.${s}`);else"cases"in e||c.push(`${t}.__switch: missing "cases" object - switch will always resolve to default`);"default"in e&&g(e.default,`${t}.__switch.default`);return}if("__value"in e)return void g(e.__value,`${t}.__value`);if(!("__remove"in e))for(let[s,a]of Object.entries(e))g(a,`${t}.${s}`)},f=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"metadata.inputs",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;Array.isArray(e)?e.forEach((e,a)=>{let r=`${t}[${a}]`;if("object"!=typeof e||null===e)return void u.push(`${r}: must be an object`);if("string"==typeof e.id&&e.id.trim()?s.has(e.id)?u.push(`${r}.id: duplicate input id "${e.id}"`):s.add(e.id):u.push(`${r}.id: must be a non-empty string`),!e.type||!pc.has(e.type))return void u.push(`${r}.type: "${e.type}" is not a valid input type`);switch("socials"===e.type||"alert"===e.type?void 0!==e.name&&"string"!=typeof e.name&&u.push(`${r}.name: must be a string`):("string"!=typeof e.name||!e.name.trim())&&u.push(`${r}.name: must be a non-empty string`),e.type){case"select":case"select-with-custom":case"multi-select":if(void 0===e.default||("multi-select"!==e.type?"string"==typeof e.default&&e.default.trim():"object"==typeof e.default&&Array.isArray(e.default))||u.push(`${r}.default: must be a ${"multi-select"===e.type?"array":"non-empty string"}`),Array.isArray(e.options)&&0!==e.options.length){let t=new Set;e.options.forEach((e,s)=>{let a=`${r}.options[${s}]`;"object"!=typeof e||null===e?u.push(`${a}: must be an object with "label" and "value"`):("string"==typeof e.label&&e.label.trim()||u.push(`${a}.label: must be a non-empty string`),void 0===e.value||null===e.value||""===e.value||"string"!=typeof e.value?u.push(`${a}.value: must be a non-empty string`):t.has(e.value)?c.push(`${a}.value: duplicate option value "${e.value}"`):t.add(e.value))}),("multi-select"===e.type?Array.isArray(e.default)?e.default:[]:void 0!==e.default?[e.default]:[]).forEac
43h((s,a)=>{let n="multi-select"===e.type?`${r}.default[${a}]`:`${r}.default`;if("string"!=typeof s||!s.trim()){"multi-select"===e.type&&u.push(`${n}: must be a non-empty string`);return}"select-with-custom"===e.type||t.has(s)||c.push(`${n}: "${s}" is not one of the declared option values`)})}else u.push(`${r}.options: "${e.type}" requires a non-empty options array`);break;case"socials":Array.isArray(e.socials)&&0!==e.socials.length?e.socials.forEach((e,t)=>{let s=`${r}.socials[${t}]`;if(pu.has(e.id)||u.push(`${s}.id: "${e.id}" is not a valid social id`),"string"==typeof e.url&&e.url.trim())try{new URL(e.url)}catch{u.push(`${s}.url: "${e.url}" is not a valid URL`)}else u.push(`${s}.url: must be a non-empty string`)}):u.push(`${r}.socials: "socials" type requires a non-empty socials array`);break;case"alert":e.intent&&!pm.has(e.intent)&&c.push(`${r}.intent: "${e.intent}" is not a recognised alert intent`);break;case"oauth":if(e.oauth&&"object"==typeof e.oauth){if("string"==typeof e.oauth.authorisationUrl&&e.oauth.authorisationUrl.trim())try{new URL(e.oauth.authorisationUrl)}catch{u.push(`${r}.oauth.authorisationUrl: not a valid URL`)}else u.push(`${r}.oauth.authorisationUrl: must be a non-empty string`);e.oauth.oauthResultField&&"object"==typeof e.oauth.oauthResultField?("string"==typeof e.oauth.oauthResultField.name&&e.oauth.oauthResultField.name.trim()||u.push(`${r}.oauth.oauthResultField.name: must be a non-empty string`),"string"==typeof e.oauth.oauthResultField.description&&e.oauth.oauthResultField.description.trim()||u.push(`${r}.oauth.oauthResultField.description: must be a non-empty string`)):u.push(`${r}.oauth.oauthResultField: must be an object`)}else u.push(`${r}.oauth: "oauth" type requires an oauth config object`);break;case"subsection":case"nab-endpoint":Array.isArray(e.subOptions)?f(e.subOptions,`${r}.subOptions`,new Set):u.push(`${r}.subOptions: "${e.type}" type requires a subOptions array`);break;case"string":case"password":case"url":void 0===e.default||"string"==typeof e.default&&e.default.trim()||u.push(`${r}.default: must be a non-empty string for "${e.type}" type`);break;case"number":if(void 0!==e.default&&"number"!=typeof e.default&&c.push(`${r}.default: expected a number for "number" type, got ${typeof e.default}`),e.constraints){let{min:t,max:s}=e.constraints;void 0!==t&&"number"!=typeof t&&u.push(`${r}.constraints.min: must be a number`),void 0!==s&&"number"!=typeof s&&u.push(`${r}.constraints.max: must be a number`),"number"==typeof t&&"number"==typeof s&&t>s&&u.push(`${r}.constraints: min (${t}) cannot exceed max (${s})`)}}void 0!==e.forced&&null!==e.forced&&!0===e.required&&c.push(`${r}: both "forced" and "required" are set - "required" has no effect when a value is forced`)}):u.push(`${t} must be an array`)};return e.config&&g(e.config,"config"),e.metadata.inputs&&f(e.metadata.inputs),e.metadata.inputs&&e.metadata.inputs.forEach(e=>{!e.id||"string"!=typeof e.type||ph.has(e.type)||x.has(e.id)||c.push(`metadata.inputs: "${e.id}" (${e.type}) is declared but never referenced in config`),("subsection"===e.type||"nab-endpoint"===e.type)&&Array.isArray(e.subOptions)&&e.subOptions.forEach(t=>{!t.id||"string"!=typeof t.type||ph.has(t.type)||x.has(`${e.id}.${t.id}`)||c.push(`metadata.inputs: "${e.id}.${t.id}" (${t.type}) is declared but never referenced in config`)})}),{isValid:0===u.length,warnings:c,errors:u}}function px(e){let[t,s]=(0,u.useState)([]),[a,r]=(0,u.useState)({}),[n,l]=(0,u.useState)(!1),[i,o]=(0,u.useState)({}),{userData:d}=ri(),c=(0,u.useMemo)(()=>{let e=null==d?void 0:d.appliedTemplates;if(!e||0===e.length||0===t.length)return[];let s=[];for(let a of e){let e=t.find(e=>e.metadata.id===a.id);if(!e||0>=pn(e.metadata.version,a.version)||a.ignored||a.dismissedVersion&&pn(a.dismissedVersion,e.metadata.version)>=0)continue;let r=(e.metadata.changelog??[]).filter(e=>pn(e.version,a.version)>0);s.push({template:e,appliedVersion:a.version,newChangelog:r})}return s},[t,null==d?void 0:d.appliedTemplates]),h=async e=>{let t=[],s=[];for(let u of e){if(!u.metadata.sourceUrl){t.push(u);continue}try{var a,r,n,l,i,o,d,c;let e=[],m=ps.get(u.metadata.sourceUrl);
43if(m)e=m;else{let s=await fetch(u.metadata.sourceUrl);if(!s.ok){console.warn(`Failed to fetch update for template "${u.metadata.name}": ${s.status}`),t.push(u);continue}let a=await s.json();e=Array.isArray(a)?a:[a],ps.set(u.metadata.sourceUrl,e)}let h=e.find(e=>{var t;return((null==(t=e.metadata)?void 0:t.id)||e.id)===u.metadata.id});if(!h){console.warn(`Template "${u.metadata.name}" not found at source URL`),t.push(u);continue}let p={metadata:{...h.metadata,id:u.metadata.id,source:"external",sourceUrl:u.metadata.sourceUrl,setToSaveInstallMenu:(null==(a=h.metadata)?void 0:a.setToSaveInstallMenu)??!0,version:(null==(r=h.metadata)?void 0:r.version)||"1.0.0",name:(null==(n=h.metadata)?void 0:n.name)||u.metadata.name,description:(null==(l=h.metadata)?void 0:l.description)||u.metadata.description,author:(null==(i=h.metadata)?void 0:i.author)||u.metadata.author,category:(null==(o=h.metadata)?void 0:o.category)||u.metadata.category,services:null==(d=h.metadata)?void 0:d.services,serviceRequired:null==(c=h.metadata)?void 0:c.serviceRequired},config:h.config||h},x=p.metadata.version||"1.0.0",g=u.metadata.version||"1.0.0";pn(x,g)>0?(s.push({old:u,new:p}),t.push(p),console.log(`Updated template "${u.metadata.name}" from v${g} to v${x}`)):t.push(u)}catch(e){console.error(`Error checking update for template "${u.metadata.name}":`,e),t.push(u)}}if(s.length>0){let e=s.map(e=>e.new.metadata.name).join(", ");m.oR.success(`Updated ${s.length} template${1!==s.length?"s":""}: ${e}`)}return t},p=async()=>{l(!0);let t=[];try{var a;let n=ps.get("api_templates");n?t=n:(t=await eM(),ps.set("api_templates",t));let l=pa(),i=await h(l);JSON.stringify(i)!==JSON.stringify(l)&&(pr(i),l=i),l=l.filter(e=>{let s=t.find(t=>t.metadata.id===e.metadata.id);return!s||1===pn(e.metadata.version,s.metadata.version)});let d=[];if((null==e||null==(a=e.settings.community)?void 0:a.templates)!=="off")try{let e=await eO("template");r(Object.fromEntries(e.map(e=>[e.id,e]))),d=e.map(e=>e.payload)}catch(e){console.warn("Failed to load community templates:",e)}let c=[...l,...t,...d].reduce((e,t)=>(e.some(e=>e.metadata.id===t.metadata.id)||e.push(t),e),[]);if(s(c),e){let t={};
43c.forEach(s=>{t[s.metadata.id]=pp(s,e)}),o(t)}}catch(e){console.error("Error fetching templates:",e),m.oR.error("Failed to load templates")}finally{l(!1)}};return{templates:t,setTemplates:s,loadingTemplates:n,templateValidations:i,setTemplateValidations:o,loadTemplates:p,appliedTemplateUpdates:c,communityItems:a,setCommunityItems:r}}let pg=e=>{if("string"!=typeof e)return{isPlaceholder:!1,required:!1};for(let{pattern:t,required:s}of[{pattern:/<required_template_placeholder>/i,required:!0},{pattern:/<optional_template_placeholder>/i,required:!1},{pattern:/<template_placeholder>/i,required:!0}])if(t.test(e))return{isPlaceholder:!0,required:s};return{isPlaceholder:!1,required:!1}},pf=(e,t,s)=>{if("string"==typeof e){let a=pg(e);a.isPlaceholder&&s.set(t.join("."),a.required);return}if(e&&"object"==typeof e&&!("__switch"in e)&&!("__value"in e)&&!("__remove"in e))for(let[a,r]of Object.entries(e))(0!==t.length||"services"!==a)&&pf(r,[...t,a],s)},pb=(e,t,s)=>{var a,r,n,l,i,o,d,c,u,m,h,p;let x=[],g=Object.keys((null==t||null==(a=t.settings)?void 0:a.services)||{}),f=[],b=!1,v=!1,y=!0!==e.metadata.serviceRequired;void 0===e.metadata.services?(v=!0,f=g):Array.isArray(e.metadata.services)&&0===e.metadata.services.length?(b=!0,f=[]):Array.isArray(e.metadata.services)&&(1===(f=e.metadata.services.filter(e=>g.includes(e))).length&&!0===e.metadata.serviceRequired?b=!0:f.length>0?v=!0:b=!0);let j=e.config,w=new Map;pf(j,[],w),pd(null==j?void 0:j.presets).forEach((e,s)=>{var a,r,n;let l=null==t||null==(r=t.settings)||null==(a=r.presets)?void 0:a.find(t=>t.ID===(null==e?void 0:e.type));null==l||null==(n=l.OPTIONS)||n.forEach(t=>{var a;let r=`presets.${s}.options.${t.id}`;!["string","password","url"].includes(t.type)||!t.required||(null==(a=e.options)?void 0:a[t.id])||w.has(r)||w.set(r,!0)})});let N={tmdbApiKey:!!(null==t||null==(l=t.settings)||null==(n=l.metadata)||null==(r=n.tmdb)?void 0:r.apiKey),tmdbAccessToken:!!(null==t||null==(d=t.settings)||null==(o=d.metadata)||null==(i=o.tmdb)?void 0:i.accessToken),tvdbApiKey:!!(null==t||null==(m=t.settings)||null==(u=m.metadata)||null==(c=u.tvdb)?void 0:c.apiKey),pmdbApiKey:null==t||null==(p=t.settings)||null==(h=p.jellyfin)?void 0:h.segments.providers.some(e=>"pmdb"===e.id&&"instance"===e.key)};return w.forEach((e,a)=>{let{optionRequired:r,...n}=((e,t,s)=>{var a,r,n,l;let[i,...o]=e.split(".");if("proxy"===i&&1===o.length){let e=o[0],s=ah[null==t||null==(a=t.proxy)?void 0:a.id],r=(null==s?void 0:s.name)??"Proxy",n={url:{label:`${r} URL`,description:`The URL of your ${r} instance`,type:"url"},publicUrl:{label:`${r} Public URL`,description:`The public URL of your ${r} instance (if different from URL)`,type:"url"},credentials:{label:`${r} Credentials`,description:null==s?void 0:s.credentialDescription,type:"password"},publicIp:{label:`${r} Public IP`,description:`Public IP address of your ${r} instance`,type:"string"}};if(n[e])return{key:`proxy_${e}`,...n[e]}}if(0===o.length&&Object.hasOwn(ax,i)){let e=ax[i];return{key:`toplevel_${i}`,label:e.name,description:e.description,type:e.type}}if("presets"===i&&"options"===o[1]){let e=pd(null==t?void 0:t.presets)[Number(o[0])],a=null==s||null==(n=s.settings)||null==(r=n.presets)?void 0:r.find(t=>t.ID===(null==e?void 0:e.type)),i=o.slice(2),d=((e,t)=>{let s=[],a=e;for(let e of t){let t=null==a?void 0:a.find(t=>t.id===e);if(!t)return[];s.push(t),a=t.subOptions}return s})(null==a?void 0:a.OPTIONS,i),c=d.at(-1);if(e){let t;return 1===d.length&&(null==c?void 0:c.id)==="debridioApiKey"?{key:"debridioApiKey",label:c.name,description:c.description,type:"password",optionRequired:!0===c.required}:{key:`preset_${e.instanceId}_${i.join("_")}`,label:[(null==(l=e.options)?void 0:l.name)||e.type,...c?d.map(e=>e.name||e.id):i].join(" - "),description:null==c?void 0:c.description,type:"password"===(t=null==c?void 0:c.type)||"url"===t?t:"string",optionRequired:(null==c?void 0:c.required)===!0}}}return{key:`path_${e}`,label:e,type:"string"}})(a,j,t),l=!0===N[a],i=(e||!!r)&&!l,o=x.find(e=>e.key===n.key);if(o){o.path=[o.path,a].flat(),o.required||(o.required=i);return}let d=a.split(".").reduce((e,t)=>
43null==e?void 0:e[t],s);x.push({...n,description:l?[n.description,"This instance provides a default. Leave blank to use it, or enter your own to override."].filter(Boolean).join(" "):n.description,path:a,required:i,value:"string"!=typeof d||pg(d).isPlaceholder?"":d})}),{template:e,services:f,skipServiceSelection:b,showServiceSelection:v,allowSkipService:y,inputs:x}},pv=(e,t,s,a)=>{let r=[];return t.forEach(e=>{var t,n;let l=null==s||null==(n=s.settings)||null==(t=n.services)?void 0:t[e];(null==l?void 0:l.credentials)&&l.credentials.filter(e=>h7.includes(e.type)).forEach(t=>{var s,n,i;r.push({key:`service_${e}_${t.id}`,path:`services.${e}.${t.id}`,label:`${l.name} - ${t.name||t.id}`,description:t.description,type:t.type,required:t.required??!0,value:(null==a||null==(i=a.services)||null==(n=i.find(t=>t.id===e))||null==(s=n.credentials)?void 0:s[t.id])||""})})}),r},py=(e,t)=>{var s;if(!Array.isArray(e.presets))return;let a=new Set(((null==t||null==(s=t.settings)?void 0:s.presets)||[]).filter(e=>{var t;return!(null==(t=e.DISABLED)?void 0:t.disabled)}).map(e=>e.ID)),r=e.presets.filter(e=>!a.has(e.type));r.length>0&&(m.oR.warning(`Removed ${r.length} preset${1!==r.length?"s":""} not available on this instance: ${r.map(e=>e.type).join(", ")}`,{duration:5e3}),e.presets=e.presets.filter(e=>a.has(e.type)))},pj=(e,t,s)=>{let a=t.split("."),r=e;for(let e=0;e<a.length-1;e++){let t=a[e],s=a[e+1],n=/^\d+$/.test(s);t in r||(r[t]=n?[]:{}),r=r[t]}r[a[a.length-1]]=s},pw=(e,t,s,a)=>t.reduce((t,r)=>{if("noob"===e&&(!0===r.advanced||!1===r.showInSimpleMode)||r.__if&&"string"==typeof r.__if&&!po(r.__if,s,a))return t;let n={...r};return r.subOptions&&(n.subOptions=pw(e,r.subOptions,s,a)),t.push(n),t},[]),pN=(e,t)=>{let s=new Map((e??[]).map(e=>[e.id,e])),a=(e,t)=>(e.options??[]).some(e=>String(e.value)===String(t)),r={};for(let[e,i]of Object.entries(t??{})){var n,l;let t=s.get(e);if(t){if("subsection"===t.type){i&&"object"==typeof i&&!Array.isArray(i)&&(r[e]=pN(t.subOptions??[],i));continue}if((null==(n=t.options)?void 0:n.length)&&"select"===t.type){if(!a(t,i))continue}else if((null==(l=t.options)?void 0:l.length)&&"multi-select"===t.type&&Array.isArray(i)){let s=i.filter(e=>a(t,e));if(0===s.length&&i.length>0)continue;r[e]=s;continue}r[e]=i}}return r};var pk=s(24252);function pS(e){let{steps:t,current:s,title:a,description:r,children:n,footer:l}=e,o=t.indexOf(s),d=-1!==o&&t.length>1;return(0,i.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col md:flex-row md:gap-8 min-w-0",children:[d&&(0,i.jsx)(pC,{steps:t,index:o}),(0,i.jsxs)("div",{className:"flex-1 min-w-0 min-h-0 flex flex-col",children:[(0,i.jsxs)("div",{className:"mb-4 shrink-0 pr-10 md:pr-8",children:[(0,i.jsx)("h2",{className:"text-xl font-semibold text-white",children:a}),r&&(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:r})]}),(0,i.jsx)(se.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},className:"flex-1 min-h-0 flex flex-col gap-3",children:n},s),l&&(0,i.jsx)("div",{className:"shrink-0 flex items-center justify-between gap-3 pt-4 mt-4 border-t border-gray-700/60",children:l})]})]})}function pC(e){let{steps:t,index:s}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("nav",{className:"hidden md:flex w-44 shrink-0 flex-col","aria-label":"Setup progress",children:t.map((e,a)=>{let r=a<s,n=a===s;return(0,i.jsxs)("div",{className:"flex items-stretch gap-3",children:[(0,i.jsxs)("div",{className:"flex flex-col items-center",children:[(0,i.jsx)("span",{className:x("w-6 h-6 rounded-full border flex items-center justify-center text-[11px] leading-none font-semibold shrink-0 transition-colors",n&&"border-brand-500 bg-brand-500 text-white",r&&"border-brand-500/50 bg-brand-500/20 text-[--brand]",!n&&!r&&"border-gray-700 text-gray-500"),children:r?(0,i.jsx)(pk.A,{className:"w-3.5 h-3.5"}):a+1}),a<t.length-1&&(0,i.jsx)("span",{className:x("w-px flex-1 min-h-5 my-1",r?"bg-brand-500/60":"bg-gray-700/70")})]}),(0,i.jsx)("span",{className:x("text-sm pb-5 -mt-0.5 leading-6 transition-colors",n?"text-white font-medium":"text-gray-500"),children:pt[e]})]},e)})}),(0,i.jsxs)("div",{className:"md:hidden mb-4 pr-10",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-1.5",children:[(0,i.jsx)("span",{className:"text-xs font-medium text-white",children:pt[t[s]]}),(0,i.jsxs)("span",{className:"text-xs text-gray-500",children:["Step ",s+1," of ",t.length]})]}),(0,i.jsx)("div",{className:"h-1 rounded-full bg-gray-700/70 overflow-hidden",children:(0,i.jsx)(se.P.div,{className:"h-full bg-brand-500",initial:!1,animate:{width:`${(s+1)/t.length*100}%`},transition:{duration:.25,ease:"easeOut"}})})]})]})}function p_(e){let{onBack:t,backLabel:s="Back",onSkip:a,skipLabel:r="Skip",primary:n}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{children:t&&(0,i.jsx)(v,{intent:"gray-subtle",size:"sm",onClick:t,children:s})}),(0,i.jsxs)("div",{className:"flex items-center gap-4",children:[a&&(0,i.jsx)("button",{type:"button",onClick:a,className:"text-sm text-gray-500 hover:text-gray-300 transition-colors",children:r}),n]})]})}var pA=s(10044),pR=s(33999),pT=s(68786);function pI(e){let{icon:t,title:s,description:a,meta:r,recommended:n,onClick:l}=e;return(0,i.jsxs)("button",{type:"button",onClick:l,className:x("group w-full text-left rounded-xl border p-4 flex items-start gap-4 transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500",n?"border-brand-500/60 bg-brand-500/[0.08] hover:border-brand-500 hover:bg-brand-500/[0.14]":"border-gray-700/70 bg-gray-800/40 hover:border-gray-600 hover:bg-gray-800/70"),children:[(0,i.jsx)("span",{className:x("shrink-0 w-10 h-10 rounded-lg flex items-center justify-center transition-colors",n?"bg-brand-500/20 text-[--brand]":"bg-gray-700/50 text-gray-400 group-hover:text-gray-300"),children:t}),(0,i.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,i.jsxs)("span",{className:"flex items-center gap-2 flex-wrap",children:[(0,i.jsx)("span",{className:"font-semibold text-white",children:s}),n&&(0,i.jsx)("span",{className:"text-[10px] leading-none font-medium uppercase tracking-wider px-1.5 py-1 rounded bg-brand-500/20 text-[--brand]",children:"Recommended"})]}),(0,i.jsx)("span",{className:"block text-sm text-[--muted] mt-1",children:a}),r&&(0,i.jsx)("span",{className:"block text-xs text-gray-500 mt-1.5",children:r})]})]})}function pE(e){let{onUseTemplate:t,onStartFresh:s,onSignIn:a,recommendedTemplateName:r,templateCount:n,hasExistingConfig:l}=e;return(0,i.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,i.jsx)(pI,{recommended:!0,icon:(0,i.jsx)(pA.A,{className:"w-5 h-5"}
43),title:"Use a ready-made setup",description:l?"Apply a prepared configuration on top of your current one. You can still change everything afterwards.":"Start from a configuration someone has already put together. The quickest way to a working addon.",meta:r?`Starting with ${r} \xb7 ${n} available`:n>0?`${n} available`:void 0,onClick:t}),(0,i.jsx)(pI,{icon:(0,i.jsx)(pR.A,{className:"w-5 h-5"}),title:l?"Keep configuring":"Set it up myself",description:l?"Carry on where you left off and adjust each section by hand.":"Start from an empty configuration and choose every addon, filter and service yourself.",onClick:s}),a&&(0,i.jsx)(pI,{icon:(0,i.jsx)(pT.A,{className:"w-5 h-5"}),title:"I already have a configuration",description:"Load an existing setup with its UUID and password.",onClick:a})]})}var pM=s(77809),pP=s(24558),p$=s(30713),pD=s(1497),pL=s(46408),pO=s(36995),pU=s(57556),pF=s(85421);function pz(e){return!!e&&"object"==typeof e&&"string"==typeof e.type&&("options"in e||"instanceId"in e)}function pV(e){var t;let s=null==(t=e.options)?void 0:t.name;return"string"!=typeof s||s.includes("{{")?e.type:s}function pq(e){var t;let s=null==(t=e.config)?void 0:t.presets,a=new Set;!function e(t,s){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(t&&"object"==typeof t&&!(a>12)){if(Array.isArray(t)){for(let r of t)pz(r)?s.add(pV(r)):e(r,s,a+1);return}if(pz(t))return void s.add(pV(t));for(let r of Object.keys(t))"__if"!==r&&"__switch"!==r&&e(t[r],s,a+1)}}(s,a);let r=e.metadata.services;return{addons:[...a],services:(r??[]).map(e=>{var t;return(null==(t=ap[e])?void 0:t.name)||e}),servicesChosenDuringSetup:void 0===r,skipsServiceSelection:Array.isArray(r)&&0===r.length,addonsVary:!!s&&!Array.isArray(s)}}function pB(e){let{open:t,template:s,data:a,onProceed:r,proceedLabel:n,onClose:l}=e;return a&&s?(0,i.jsx)(sl,{open:t,onOpenChange:e=>{e||l()},title:a.errors.length>0?`Template Errors - ${s.metadata.name}`:`Template Warnings - ${s.metadata.name}`,contentClass:"max-w-2xl",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"space-y-4 overflow-y-auto max-h-[60vh] pr-1",children:[a.errors.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,i.jsx)(pM.A,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),(0,i.jsxs)("span",{className:"text-sm font-semibold text-red-400",children:[a.errors.length," error",1!==a.errors.length?"s":""," - template cannot be loaded"]})]}),(0,i.jsx)("ul",{className:"space-y-1.5",children:a.errors.map((e,t)=>(0,i.jsx)("li",{className:"text-xs text-red-300 bg-red-700/40 border border-red-600/50 rounded px-3 py-2 break-words font-mono",children:e},t))})]}),a.warnings.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,i.jsx)(pM.A,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),(0,i.jsxs)("span",{className:"text-sm font-semibold text-yellow-400",children:[a.warnings.length," warning",1!==a.warnings.length?"s":"",0===a.errors.length?" - you may still proceed":""]})]}),(0,i.jsx)("ul",{className:"space-y-1.5",children:a.warnings.map((e,t)=>(0,i.jsx)("li",{className:"text-xs text-yellow-300 bg-yellow-800/40 border border-yellow-700/50 rounded px-3 py-2 break-words font-mono",children:e},t))})]})]}),(0,i.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-gray-700",children:[(0,i.jsx)(v,{intent:"primary-outline",onClick:l,children:a.errors.length>0?"Close":"Cancel"}),0===a.errors.length&&null!==r&&(0,i.jsx)(v,{intent:"white",rounded:!0,onClick:()=>{l(),r()},children:n})]})]})}):null}function pK(e){let{className:t,children:s,glowSize:a="500px",glowOpacity:r=.07,transitionDuration:n="0.5s"}=e,l=(0,u.useRef)(null),o=(0,u.useRef)(null),d=(0,u.useRef)(null);return(0,i.jsxs)("div",{ref:l,onMouseMove:e=>{if(!l.current)return;let t=l.current.getBoundingClientRect(),s=e.clientX-t.left,n=e.clientY-t.top;o.current&&(o.current.style.background=`radial-gradient(${a} circle at ${s}px ${n}px, rgba(139, 92, 246, ${r}), transparent 65%)`),d.current&&(d.current.style.background=`radial-gradient(70% 100% at ${s}px 0px, rgba(139, 92, 246, ${Math.min(1,7*r)}), transparent)`)},onMouseEnter:()=>{o.current&&(o.current.style.opacity="1"),d.current&&(d.current.style.opacity="1")},onMouseLeave:()=>{o.current&&(o.current.style.opacity="0"),d.current&&(d.current.style.opacity="0")},className:x("relative overflow-hidden rounded-xl border border-gray-700/50 bg-gray-800/40",t),children:[(0,i.jsx)("div",{ref:o,className:"pointer-events-none absolute inset-0 rounded-xl",style:{opacity:0,transition:`opacity ${n} ease`}}),(0,i.jsx)("div",{ref:d,className:"pointer-events-none absolute top-0 inset-x-0 h-px rounded-t-xl",style:{opacity:0,transition:`opacity ${n} ease`}}),s]})}let pH=new Map;async function pW(e){let t=pH.get(e);if(void 0!==t)return t;let s=await fetch(e);if(!s.ok)throw Error(`Failed to fetch changelog from ${e}: HTTP ${s.status}`);let a=function(e){let t,s=[],a=/^## +([^\s(]+)\s*\(([^)]+)\)\s*$/gm,r=[];for(;null!==(t=a.exec(e));)r.push({version:t[1],date:t[2].trim(),headerEnd:t.index+t[0].length,nextStart:t.index});for(let t=0;t<r.length;t++){let a=r[t],n=a.headerEnd,l=t+1<r.length?r[t+1].nextStart:e.length,i=e.slice(n,l).trim();s.push({version:a.version,date:a.date,content:i})}return s}(await s.text());return pH.set(e,a),a}function pG(e){let{entry:t}=e;return(0,i.jsxs)("div",{className:"space-y-2.5",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,i.jsxs)("span",{className:"text-sm font-bold text-[--brand]",children:["v",t.version]}),(0,i.jsx)("span",{className:"text-[10px] font-medium px-2.5 py-0.5 rounded-full bg-gray-700/60 text-gray-400 border border-gray-600/40 flex-shrink-0",children:t.date})]}),(0,i.jsx)("div",{className:"prose prose-invert prose-sm max-w-none min-w-0 text-gray-300 [&_p]:leading-relaxed [&_ul]:space-y-0.5 [&_li]:text-sm [&_p]:text-sm [&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_strong]:text-gray-100 [&_a]:text-[--brand] [&_a:hover]:underline [&_code]:bg-gray-800 [&_code]:px-1 [&_code]:rounded [&_code]:text-[--brand] [&_code]:text-xs [&_*]:break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full",children:(0,i.jsx)(u_.oz,{children:t.content})})]})}function pY(){return(0,i.jsxs)("div",{className:"space-y-3 py-2",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsx)(uD,{className:"h-4 w-16"}),(0,i.jsx)(uD,{className:"h-4 w-24 rounded-full"})]}),(0,i.jsx)(uD,{className:"h-3 w-full"}),(0,i.jsx)(uD,{className:"h-3 w-5/6"}),(0,i.jsx)(uD,{className:"h-3 w-4/6"})]})}function pJ(e){let{entries:t}=e;return(0,i.jsx)("div",{className:"divide-y divide-gray-700/50",children:t.map(e=>(0,i.jsx)("div",{className:"py-4 first:pt-1 last:pb-1",children:(0,i.jsx)(pG,{entry:e})}
43,e.version))})}function pZ(e){let{open:t,onOpenChange:s,templateName:a,changelog:r=[],changelogUrl:n}=e,[l,o]=(0,u.useState)(null),[d,c]=(0,u.useState)(!1),[m,h]=(0,u.useState)(null);(0,u.useEffect)(()=>{t&&n&&null===l&&(c(!0),h(null),pW(n).then(o).catch(e=>{console.error("Failed to load changelog:",e),h("Failed to load changelog. Please try again later."),o([])}).finally(()=>c(!1)))},[t,n]);let p=n?l??[]:r;return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:`Changelog â ${a}`,contentClass:"max-w-2xl",children:d?(0,i.jsx)(pY,{}):m?(0,i.jsx)("p",{className:"text-sm text-red-300 italic py-2",children:m}):0===p.length?(0,i.jsx)("p",{className:"text-sm text-gray-500 italic py-2",children:"No changelog available."}):(0,i.jsx)("div",{className:"max-h-[60vh] overflow-y-auto pr-4 -mr-2",children:(0,i.jsx)(pJ,{entries:p})})})}function pQ(e){let{update:t}=e,[s,a]=(0,u.useState)(null),[r,n]=(0,u.useState)(!1),[l,o]=(0,u.useState)(null),d=t.template.metadata.changelogUrl;return((0,u.useEffect)(()=>{d&&(n(!0),pW(d).then(e=>{a(e.filter(e=>pn(e.version,t.appliedVersion)>0))}).catch(e=>{console.error("Failed to load template changelog:",e),o("Failed to load changelog."),a([])}).finally(()=>n(!1)))},[d,t.appliedVersion]),r)?(0,i.jsx)(pY,{}):l?(0,i.jsx)("p",{className:"text-xs text-red-300 italic",children:l}):s&&0!==s.length?(0,i.jsx)("div",{className:"divide-y divide-gray-700/50",children:s.map(e=>(0,i.jsx)("div",{className:"py-3 first:pt-1 last:pb-1",children:(0,i.jsx)(pG,{entry:e})},e.version))}):(0,i.jsx)("p",{className:"text-xs text-gray-500 italic",children:"No changelog provided for this update."})}function pX(e){let{template:t,community:s}=e,a=t.metadata.source,r="builtin"===a?"Built-in":"custom"===a?"From this instance":"external"===a?"Imported":(null==s?void 0:s.federated)?`From ${s.origin}`:"Community";return(0,i.jsx)("span",{className:x("text-[10px] leading-none font-medium px-1.5 py-1 rounded border whitespace-nowrap","community"===a?"bg-amber-500/10 text-amber-300/90 border-amber-500/25":"bg-gray-700/40 text-gray-400 border-gray-600/40"),children:r})}function p0(e){let{template:t,validation:s,onOpenDetail:a,community:r,onLike:n,likeDisabledReason:l}=e,o=((null==s?void 0:s.warnings.length)??0)>0,d=((null==s?void 0:s.errors.length)??0)>0,{addons:c,services:u,servicesChosenDuringSetup:m,skipsServiceSelection:h,addonsVary:p}=pq(t);return(0,i.jsxs)(pK,{glowSize:"350px",glowOpacity:.08,transitionDuration:"0.3s",className:x("flex flex-col bg-gray-900/60 border-gray-800 rounded-lg p-4","hover:border-gray-600 transition-colors duration-200"),children:[(0,i.jsxs)("button",{type:"button",onClick:()=>a(t),className:"flex-1 flex flex-col text-left focus-visible:outline-none",children:[(0,i.jsxs)("div",{className:"flex items-start gap-2 mb-1.5",children:[(0,i.jsx)("h3",{className:"flex-1 min-w-0 text-base font-semibold text-white truncate",children:t.metadata.name}),(0,i.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(d||o)&&(0,i.jsx)(pM.A,{className:x("w-3.5 h-3.5",d?"text-red-300":"text-yellow-400")}),(0,i.jsx)(pX,{template:t,community:r})]})]}),(0,i.jsx)("div",{className:"text-sm text-gray-400 line-clamp-3 mb-3",children:(0,i.jsx)(l6,{children:t.metadata.description})}),(0,i.jsxs)("div",{className:"mt-auto flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500",children:[(0,i.jsxs)("span",{className:"truncate max-w-[10rem]",children:["by ",t.metadata.author]}),c.length>0&&(0,i.jsxs)("span",{className:"flex items-center gap-1",children:[(0,i.jsx)(pP.A,{className:"w-3.5 h-3.5"}),p?"up to ":"",c.length," addon",1===c.length?"":"s"]}),u.length>0?(0,i.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,i.jsx)(p$.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,i.jsxs)("span",{className:"truncate",children:["Needs ",u.slice(0,2).join(", "),u.length>2?` +${u.length-2}`:""]})]}):m?(0,i.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,i.jsx)(p$.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,i.jsx)("span",{className:"truncate",children:"You pick the services"})]}):h?(0,i.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,i.jsx)(pD.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,i.jsx)("span",{className:"truncate",children:"No service to pick"})]}):null]})]}),r&&(0,i.jsx)("div",{className:"mt-3 pt-2.5 border-t border-gray-800/80 flex",children:(0,i.jsx)(t5,{trigger:(0,i.jsx)("span",{children:(0,i.jsxs)("button",{type:"button",disabled:!n||r.federated,onClick:e=>{e.stopPropagation(),null==n||n(r.id)},className:x("flex items-center gap-1 rounded-md border px-2 py-1 text-xs transition-colors",!n||r.federated?"border-gray-800 text-gray-500 cursor-not-allowed":"border-gray-700 text-gray-400 hover:border-pink-500/40 hover:text-pink-300"),children:[(0,i.jsx)(pL.A,{className:"w-3.5 h-3.5"}),r.likes]})}
43),children:r.federated?"Likes only work for templates published on this instance":l??"Like this template"})})]})}function p1(e){var t;let{template:s,validation:a,isLoading:r,onLoadTemplate:n,onDeleteRequest:l,onShare:o,shareDisabledReason:d,community:c,onClose:m}=e,[h,p]=(0,u.useState)(!1),[g,f]=(0,u.useState)(!1),{addons:b,services:y,servicesChosenDuringSetup:j,skipsServiceSelection:N,addonsVary:k}=pq(s),S=((null==(t=s.metadata.changelog)?void 0:t.length)??0)>0||!!s.metadata.changelogUrl,C=((null==a?void 0:a.warnings.length)??0)>0,_=((null==a?void 0:a.errors.length)??0)>0;return(0,i.jsxs)("div",{className:"flex flex-col gap-5 h-full min-h-0",children:[(0,i.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1 flex flex-col gap-5",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)(pX,{template:s,community:c}),(0,i.jsxs)("span",{className:"text-xs text-gray-500",children:["v",s.metadata.version||"1.0.0"," \xb7 by"," ",s.metadata.author]})]}),(_||C)&&(0,i.jsxs)("button",{type:"button",onClick:()=>p(!0),className:x("flex items-center gap-2 text-left text-xs rounded-lg border px-3 py-2 transition-colors",_?"border-red-400/30 bg-red-500/5 text-red-200 hover:bg-red-500/10":"border-yellow-400/30 bg-yellow-500/5 text-yellow-300 hover:bg-yellow-500/10"),children:[(0,i.jsx)(pM.A,{className:"w-4 h-4 shrink-0"}),_?`${a.errors.length} problem${1===a.errors.length?"":"s"} with this template â view details`:`${a.warnings.length} warning${1===a.warnings.length?"":"s"} â view details`]}),(y.length>0||b.length>0||j||N)&&(0,i.jsxs)("div",{className:"rounded-lg border border-gray-700/70 bg-gray-800/40 p-4 space-y-3",children:[(0,i.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500",children:"What this sets up"}),y.length>0?(0,i.jsxs)("div",{className:"flex items-start gap-2.5 text-sm",children:[(0,i.jsx)(p$.A,{className:"w-4 h-4 text-gray-500 mt-0.5 shrink-0"}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("div",{className:"text-gray-300",children:!0===s.metadata.serviceRequired?"You will need an account for":"Optionally works with"}),(0,i.jsx)("div",{className:"text-gray-400 mt-0.5",children:y.join(", ")})]})]}):j?(0,i.jsxs)("div",{className:"flex items-start gap-2.5 text-sm",children:[(0,i.jsx)(p$.A,{className:"w-4 h-4 text-gray-500 mt-0.5 shrink-0"}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("div",{className:"text-gray-300",children:!0===s.metadata.serviceRequired?"Needs a debrid or usenet service":"Works with or without a service"}),(0,i.jsx)("div",{className:"text-gray-400 mt-0.5",children:"You choose which ones during setup."})]})]}):N?(0,i.jsxs)("div",{className:"flex items-start gap-2.5 text-sm",children:[(0,i.jsx)(pD.A,{className:"w-4 h-4 text-gray-500 mt-0.5 shrink-0"}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("div",{className:"text-gray-300",children:"No service to pick"}),(0,i.jsx)("div",{className:"text-gray-400 mt-0.5",children:"This setup does not ask you to choose a service."})]})]}):null,b.length>0&&(0,i.jsxs)("div",{className:"flex items-start gap-2.5 text-sm",children:[(0,i.jsx)(pP.A,{className:"w-4 h-4 text-gray-500 mt-0.5 shrink-0"}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsxs)("div",{className:"text-gray-300",children:[k?"Up to ":"",b.length," addon",1===b.length?"":"s",k&&(0,i.jsxs)("span",{className:"text-gray-500",children:[" ","â the exact set depends on your answers"]})]}),(0,i.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:b.map((e,t)=>(0,i.jsx)("span",{className:"text-xs bg-gray-700/50 text-gray-300 px-2 py-0.5 rounded",children:e},`${e}-${t}`))})]})]})]}),(0,i.jsx)(l6,{className:"text-sm text-gray-300 [&_a]:text-[--brand] [&_a:hover]:underline [&_ul]:list-disc [&_ul]:pl-4 [&_li]:mb-0.5",children:s.metadata.description}),(0,i.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:hW(s.metadata).map(e=>(0,i.jsx)("span",{className:"text-xs bg-gray-800/60 text-gray-400 px-2 py-1 rounded",children:e},e))})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2 pt-3 border-t border-gray-700/60",children:[S&&(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{icon:(0,i.jsx)(pO.A,{className:"w-4 h-4"}),intent:"gray-outline",onClick:()=>f(!0)}),children:"View changelog"}),"external"===s.metadata.source&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{icon:(0,i.jsx)(hX.A,{className:"w-4 h-4"}),intent:"alert-outline",onClick:()=>{m(),l(s)}}),children:"Delete this imported template"}),(o||d)&&(0,i.jsx)(t5,{trigger:(0,i.jsx)("span",{children:(0,i.jsx)(w,{icon:(0,i.jsx)(pU.A,{className:"w-4 h-4"}),intent:"gray-outline",disabled:!o,onClick:()=>null==o?void 0:o(s)})}),children:o?"Share this JSON with the community (updates your existing submission of the same name)":d})]}),(0,i.jsx)(v,{intent:"primary",leftIcon:(0,i.jsx)(pk.A,{className:"w-4 h-4"}),onClick:()=>n(s),loading:r,className:"flex-1",children:"Use this setup"})]}),h&&a&&(0,i.jsx)(pB,{open:h,template:s,data:a,onProceed:null,proceedLabel:"",onClose:()=>p(!1)}),(0,i.jsx)(pZ,{open:g,onOpenChange:e=>!e&&f(!1),templateName:s.metadata.name,changelog:s.metadata.changelog,changelogUrl:s.metadata.changelogUrl})]})}let p2={all:"All",builtin:"Built-in",custom:"This instance",external:"Imported",community:"Community"},p3={all:"Every source",builtin:"Provided with AIOStreams",custom:"Added by whoever hosts this instance",external:"Templates you imported yourself",community:"Shared by other users â review before applying"};function p5(e){let{active:t,onClick:s,children:a,count:r}=e;return(0,i.jsxs)("button",{type:"button",onClick:s,className:x("px-2.5 py-1 text-xs font-medium rounded-md border transition-colors whitespace-nowrap shrink-0",t?"bg-brand-500/20 text-[--brand] border-brand-500/50":"bg-gray-800/50 text-gray-400 border-gray-700/70 hover:border-gray-600 hover:text-gray-300"),children:[a,void 0!==r&&(0,i.jsx)("span",{className:"ml-1.5 text-[10px] leading-none text-gray-500",children:r})]})}function p4(e){let{searchQuery:t,onSearchChange:s,selectedCategory:a,onCategoryChange:r,selectedSource:n,onSourceChange:l,categories:o,sources:d,filteredTemplates:c,allTemplates:m,loadingTemplates:h,templateValidations:p,isLoading:x,onLoadTemplate:g,onImportOpen:f,onDeleteRequest:b,totalTemplateCount:v,initialExpandedTemplate:y,onInitialExpandedConsumed:j,communityItems:N,onLike:k,likeDisabledReason:S,onMineOpen:C,onShare:_,shareDisabledReason:A}=e,[R,T]=(0,u.useState)(null),I=co("(min-width: 640px)");(0,u.useEffect)(()=>{y&&(T(y),null==j||j())},[null==y?void 0:y.metadata.id]);let E=(0,u.useMemo)(()=>{let e={all:m.length};for(let t of m){let s=t.metadata.source??"builtin";e[s]=(e[s]??0)+1}return e},[m]),M=d.filter(e=>"all"===e||(E[e]??0)>0);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"space-y-2.5 min-w-0",children:[(0,i.jsx)(K,{placeholder:"Search setups...",value:t,onValueChange:s,leftIcon:(0,i.jsx)(mX.A,{className:"w-4 h-4"})}),(0,i.jsx)("div",{className:"flex gap-1.5 overflow-x-auto min-w-0 pb-1",children:M.map(e=>(0,i.jsx)(t5,{trigger:(0,i.jsx)(p5,{active:n===e,onClick:()=>l(e),count:E[e]??0,children:p2[e]??e}),children:p3[e]??e},e))}),o.length>1&&(0,i.jsx)("div",{className:"flex gap-1.5 overflow-x-auto min-w-0 pb-1",children:o.map(e=>(0,i.jsx)(p5,{active:a===e,onClick:()=>r(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,i.jsx)("div",{className:"flex-1 min-h-0 grid grid-cols-1 md:grid-cols-2 gap-3 overflow-y-auto pr-2 auto-rows-min",children:h?(0,i.jsx)("div",{className:"col-span-full text-center py-8 text-gray-400 text-sm",children:"Loading setups..."}):0===c.length?(0,i.jsx)("div",{className:"col-span-full text-center py-8 text-gray-400 text-sm",children:"No setups match your search."}):c.map(e=>(0,i.jsx)(p0,{template:e,validation:p[e.metadata.id],onOpenDetail:T,community:null==N?void 0:N[e.metadata.id],onLike:k,likeDisabledReason:S},e.metadata.id))}),(0,i.jsxs)("div",{className:"flex justify-between items-center gap-3 pt-3 border-t border-gray-700/60",children:[(0,i.jsx)("span",{className:"text-xs text-gray-500",children:c.length===v?`${v} setup${1===v?"":"s"}`:`${c.length} of ${v}`}
43),(0,i.jsxs)("div",{className:"flex gap-2",children:[C&&(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{intent:"gray-outline",size:"sm",icon:(0,i.jsx)(pF.A,{className:"w-4 h-4"}),onClick:C}),children:"My shared templates"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{intent:"gray-outline",size:"sm",icon:(0,i.jsx)(sm.bh6,{}),onClick:f}),children:"Import a template"})]})]}),(0,i.jsx)(tz,{open:null!==R,onOpenChange:e=>{e||T(null)},side:I?"right":"bottom",size:I?"lg":"full",title:(null==R?void 0:R.metadata.name)??"",contentClass:"flex flex-col",children:R&&(0,i.jsx)(p1,{template:R,validation:p[R.metadata.id],isLoading:x,onLoadTemplate:e=>{T(null),g(e)},onDeleteRequest:b,onShare:_,shareDisabledReason:A,community:null==N?void 0:N[R.metadata.id],onClose:()=>T(null)})})]})}function p6(e){let{processedTemplate:t,selectedServices:s,onServicesChange:a,status:r,configuredServices:n}=e,l=t.services.filter(e=>{var t,s;return!!(null==r||null==(s=r.settings)||null==(t=s.services)?void 0:t[e])}),o=mC.map(e=>({...e,services:l.filter(t=>{var s;let a;return s=e.id,"both"==(a=mS(t)?"both":mk(t)?"usenet":"debrid")||a===s})})).filter(e=>e.services.length>0),d=o.length>1;return(0,i.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1 space-y-4",children:o.map(e=>(0,i.jsxs)("div",{className:"space-y-2",children:[d&&(0,i.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500",children:e.label}),e.services.map(e=>{let t=r.settings.services[e],l=s.includes(e),o=n.includes(e);return(0,i.jsxs)("button",{type:"button",role:"checkbox","aria-checked":l,onClick:()=>a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:x("w-full p-3 rounded-lg border text-left transition-colors flex items-center gap-3","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500",l?"border-brand-500/70 bg-brand-500/10":"border-gray-700/70 bg-gray-800/40 hover:border-gray-600 hover:bg-gray-800/70"),children:[(0,i.jsx)("span",{className:x("w-5 h-5 rounded border flex items-center justify-center shrink-0 transition-colors",l?"bg-brand-500 border-brand-500 text-white":"border-gray-600"),children:l&&(0,i.jsx)(pk.A,{className:"w-3.5 h-3.5"})}),(0,i.jsx)(m_,{serviceId:e,shortName:t.shortName,className:"w-8 h-8"}),(0,i.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,i.jsxs)("span",{className:"flex items-center gap-2 flex-wrap",children:[(0,i.jsx)("span",{className:"font-medium text-white text-sm",children:t.name}),o&&(0,i.jsx)("span",{className:"text-[10px] leading-none font-medium px-1.5 py-1 rounded bg-gray-700/60 text-gray-400",children:"Already configured"})]}),t.signUpText&&(0,i.jsx)(l6,{className:"block text-xs text-[--muted] mt-0.5 line-clamp-1",stopPropagation:!0,children:t.signUpText})]})]},e)})]},e.id))})}function p9(e){let{options:t,values:s,onValuesChange:a,trusted:r,selectedServices:n}=e,[l,o]=u.useState(!1),d=pw("noob",t,s,n),c=pw("pro",t,s,n),m=new Set(d.map(e=>e.id)),h=c.filter(e=>!m.has(e.id)),p=e=>(0,i.jsx)(mM,{option:e,value:s[e.id]??e.default,trusted:r,onChange:t=>a(s=>({...s,[e.id]:t}))},e.id),g=0===d.length&&h.length>0;return(0,i.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-2 space-y-3",children:0===c.length?(0,i.jsx)("p",{className:"text-sm text-[--muted] py-6 text-center",children:"This setup has no options to configure."}):(0,i.jsxs)(i.Fragment,{children:[d.map(p),h.length>0&&(0,i.jsxs)("div",{className:"pt-1",children:[!g&&(0,i.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"flex items-center gap-1.5 text-sm text-gray-400 hover:text-white transition-colors",children:[(0,i.jsx)(mt.A,{className:x("w-4 h-4 transition-transform",l&&"rotate-180")}),l?"Hide":"Show"," ",h.length," ","advanced option",1===h.length?"":"s"]}),(l||g)&&(0,i.jsx)("div",{className:"space-y-3 mt-3",children:h.map(p)})]})]})})}function p8(e){let{processedTemplate:t,inputValues:s,onInputValuesChange:a,status:r}=e,n=u.useMemo(()=>{let e=new Map;for(let s of t.inputs){let t=function(e){let t=(Array.isArray(e.path)?e.path:[e.path]).find(e=>e.startsWith("services."));return t?t.split(".")[1]:null}(s),a=e.get(t);a?a.push(s):e.set(t,[s])}return[...e.entries()].sort((e,t)=>
43{let[s]=e,[a]=t;return null===s?1:null===a?-1:0})},[t.inputs]);return 0===t.inputs.length?(0,i.jsx)("p",{className:"text-sm text-[--muted] py-6 text-center",children:"Nothing to enter for this setup."}):(0,i.jsx)("form",{className:"flex-1 min-h-0 overflow-y-auto pr-2 space-y-5",children:n.map(e=>{var t,n;let[l,o]=e,d=l?null==r||null==(n=r.settings)||null==(t=n.services)?void 0:t[l]:void 0;return(0,i.jsxs)("div",{className:"space-y-3",children:[l&&d&&(0,i.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,i.jsx)(m_,{serviceId:l,shortName:d.shortName,className:"w-6 h-6 rounded mt-0.5"}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("span",{className:"block text-sm font-medium text-white",children:d.name}),d.signUpText&&(0,i.jsx)(l6,{className:"block text-xs text-[--muted] mt-0.5 break-words",stopPropagation:!0,children:d.signUpText})]})]}),(0,i.jsx)("div",{className:l&&d?"space-y-3 pl-0 sm:pl-8":"space-y-3",children:o.map(e=>{var t;let r;return(0,i.jsx)(p7,{type:e.type,value:s[e.key]||"",onValueChange:t=>a(s=>({...s,[e.key]:t})),label:l&&d?-1===(r=(t=e.label).indexOf(" - "))?t:t.slice(r+3):e.label,description:e.description,required:e.required},e.key)})})]},l??"__template")})})}function p7(e){let{type:t,value:s,onValueChange:a,label:r,description:n,required:l,placeholder:o}=e;return(0,i.jsxs)("div",{children:["string"===t||"url"===t?(0,i.jsx)(K,{type:"url"===t?"url":"text",value:s,onValueChange:a,label:r,required:l,placeholder:o}):"password"===t?(0,i.jsx)(G,{value:s,onValueChange:a,label:r,required:l,placeholder:o}):"custom-nntp-servers"===t?(0,i.jsx)(mO,{name:r,description:n,value:s||void 0,onChange:e=>a(e||"")}):null,n&&"custom-nntp-servers"!==t&&(0,i.jsx)(l6,{className:"text-xs text-[--muted] mt-1",children:n})]})}var xe=s(42690);function xt(e){let{icon:t,title:s,count:a,children:r}=e;return(0,i.jsxs)("div",{className:"rounded-lg border border-gray-700/70 bg-gray-800/40 p-4",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,i.jsx)("span",{className:"text-gray-500",children:t}),(0,i.jsx)("span",{className:"text-sm font-medium text-white",children:s}),(0,i.jsx)("span",{className:"text-xs text-gray-500",children:a})]}),r]})}function xs(e){let{processedTemplate:t,selectedServices:s,inputValues:a,status:r,currentUserData:n,previewUserData:l}=e,[o,d]=u.useState(!1),{metadata:c}=t.template,m=o?l():null,{addons:h}=pq(t.template),p=t.inputs.filter(e=>{var t;return null==(t=a[e.key])?void 0:t.trim()});return(0,i.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1 space-y-3",children:[(0,i.jsx)("div",{className:"rounded-lg border border-brand-500/50 bg-brand-500/[0.08] p-4",children:(0,i.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,i.jsx)("span",{className:"font-semibold text-white",children:c.name}),(0,i.jsxs)("span",{className:"text-xs text-gray-400",children:["v",c.version||"1.0.0"," \xb7 by ",c.author]})]})}),h.length>0&&(0,i.jsx)(xt,{icon:(0,i.jsx)(pP.A,{className:"w-4 h-4"}),title:"Addons",count:h.length,children:(0,i.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h.map((e,t)=>(0,i.jsx)("span",{className:"text-xs bg-gray-700/50 text-gray-300 px-2 py-1 rounded",children:e},`${e}-${t}`))})}),s.length>0&&(0,i.jsx)(xt,{icon:(0,i.jsx)(p$.A,{className:"w-4 h-4"}),title:"Services",count:s.length,children:(0,i.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>{var t,s;let a=null==r||null==(s=r.settings)||null==(t=s.services)?void 0:t[e];return(0,i.jsxs)("span",{className:"flex items-center gap-2 text-xs bg-gray-700/50 text-gray-300 pl-1 pr-2.5 py-1 rounded",children:[(0,i.jsx)(m_,{serviceId:e,shortName:(null==a?void 0:a.shortName)??e,className:"w-5 h-5 rounded"}),(null==a?void 0:a.name)??e]},e)})})}),t.inputs.length>0&&(0,i.jsx)(xt,{icon:(0,i.jsx)(pT.A,{className:"w-4 h-4"}),title:"Credentials",count:p.length,children:(0,i.jsx)("div",{className:"space-y-1.5",children:t.inputs.map(e=>{var t;let s=!!(null==(t=a[e.key])?void 0:t.trim());return(0,i.jsxs)("div",{className:"flex items-center justify-between gap-3 text-xs",children:[(0,i.jsx)("span",{className:"text-gray-400 truncate",children:e.label}),(0,i.jsx)("span",{className:s?"text-gray-500 font-mono shrink-0":"text-gray-600 italic shrink-0",children:s?"â¢â¢â¢â¢â¢â¢â¢â¢":"not set"})]},e.key)})})}),(0,i.jsx)(lB,{intent:"info",description:"Applying this replaces the matching parts of your current configuration. Nothing is saved to your account until you save on the Save & Install page."}),n&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("button",{type:"button",onClick:()=>d(!0),className:"flex items-center gap-1.5 text-sm text-gray-400 hover:text-white transition-colors",children:[(0,i.jsx)(xe.A,{className:"w-4 h-4"}),"See exactly what changes"]}),(0,i.jsx)(sl,{open:o,onOpenChange:d,title:"Changes this setup makes",description:"Your current configuration on the left, the result of applying this setup on the right.",contentClass:"max-w-4xl",children:(0,i.jsxs)("div",{className:"space-y-4",children:[m?(0,i.jsx)(mn,{oldConfig:n,newConfig:m}):(0,i.jsx)(lB,{intent:"alert",description:"Could not work out the changes for this setup."}),(0,i.jsx)("div",{className:"flex justify-end pt-2",children:(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>d(!1),children:"Close"})})]})})]})]})}function xa(e){let{showImportModal:t,onImportModalChange:s,importUrl:a,onImportUrlChange:r,isImporting:n,onImportFromUrl:l,onImportFromFile:o,showImportConfirmModal:d,onImportConfirmModalChange:c,pendingImportTemplates:u,selectedPendingTemplateIndex:m,onSelectedIndexChange:h,showDeepLinkWarning:p,onConfirmImport:g,onCancelImport:f,status:b}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Import Template",description:"Import a template from a URL or local file",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(K,{placeholder:"Enter template URL...",value:a,onValueChange:r,className:"flex-1"}),(0,i.jsx)(v,{intent:"primary",onClick:l,loading:n,disabled:!a.trim(),children:"Go"})]}),(0,i.jsxs)("div",{className:"relative",children:[(0,i.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,i.jsx)("div",{className:"w-full border-t border-gray-700"})}),(0,i.jsx)("div",{className:"relative flex justify-center text-xs uppercase",children:(0,i.jsx)("span",{className:"bg-gray-900 px-2 text-gray-400",children:"or"})})]}),(0,i.jsx)(v,{intent:"primary",className:"w-full",leftIcon:(0,i.jsx)(sm.bh6,{className:"w-4 h-4"}),onClick:o,children:"Import from File"})]})}),(0,i.jsx)(sl,{open:d,onOpenChange:c,title:"Confirm Import",description:1===u.length?"Review the template details before importing":`${u.length} templates will be imported`,children:(0,i.jsxs)("div",{className:"space-y-4",children:[p&&(0,i.jsx)(lB,{intent:"warning",isClosable:!1,title:"Externally Linked Template",description:"This template is being loaded from an external URL that was passed via a link. Only proceed if you recognise the source and trust where this link came from. If you did not expect to see this, click Cancel."}),1===u.length?(0,i.jsxs)("div",{className:"bg-gray-800/50 border border-gray-700 rounded-lg p-4 space-y-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Name"}),(0,i.jsxs)("div",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[u[0].metadata.name,(0,i.jsxs)("span",{className:"text-[10px] text-gray-400 bg-gray-800 px-1.5 py-0.5 rounded",children:["v",u[0].metadata.version||"1.0.0"]})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Description"}),(0,i.jsx)(l6,{className:"text-sm text-gray-300",children:u[0].metadata.description})]}),(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Author"}),(0,i.jsx)("div",{className:"text-sm text-gray-300",children:u[0].metadata.author})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Category"}),(0,i.jsx)("div",{className:"text-sm text-gray-300",children:u[0].metadata.category})]})]}),u[0].metadata.services&&u[0].metadata.services.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Services"}),(0,i.jsx)("div",{className:"flex flex-wrap gap-1.5",children:u[0].metadata.services.map(e=>{var t;return(0,i.jsx)("span",{className:"text-xs bg-green-600/30 text-green-300 px-2 py-0.5 rounded",children:(null==(t=ap[e])?void 0:t.name)||e},e)})})]})]}):(0,i.jsxs)("div",{className:"bg-gray-800/50 border border-gray-700 rounded-lg p-4",children:[(0,i.jsx)("p",{className:"text-xs text-gray-400 mb-3",children:"Click a template to select it, then use âUse Selected Templateâ to apply it - or import them all at once."}),(0,i.jsx)("div",{className:"space-y-1 max-h-[300px] overflow-y-auto",children:u.map((e,t)=>(0,i.jsxs)("div",{onClick:()=>h(t===m?null:t),className:x("flex items-center gap-3 py-2 px-2 rounded cursor-pointer transition-colors border",m===t?"bg-white/10 border-white/20":"border-transparent hover:bg-gray-700/50"),children:[(0,i.jsx)("div",{className:x("w-3 h-3 rounded-full border-2 flex-shrink-0 transition-colors",m===t?"bg-white border-white":"border-gray-500")}),(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)("div",{className:"text-sm font-medium text-white truncate",children:e.metadata.name}),(0,i.jsxs)("div",{className:"text-xs text-gray-400 truncate",children:[e.metadata.category," ⢠v",e.metadata.version||"1.0.0"]})]})]},t))})]}),(0,i.jsx)(lB,{intent:"info",description:`The template${1!==u.length?"s":""} will be saved to your browser's local storage and added to your templates list.`}),(0,i.jsxs)("div",{className:"flex justify-between gap-2 pt-2 border-t border-gray-700",children:[(0,i.jsx)(v,{intent:"primary-outline",onClick:f,children:"Cancel"}),(0,i.jsx)("div",{className:"flex gap-2",children:1===u.length?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>g(!1),children:"OK"}),(0,i.jsx)(v,{intent:"white",rounded:!0,onClick:()=>g(!0),children:"Use This Template Now"})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>g(!1),children:"Import All"}),null!==m&&(0,i.jsx)(v,{intent:"white",rounded:!0,onClick:()=>g(!0,m),children:"Use Selected"})]})})]})]})})]})}function xr(e){var t,s,a;let{open:r,onOpenChange:n,openImportModal:l=!1,deepLinkUrl:o,deepLinkTemplateId:d,initialExpandedTemplateId:c,startAtWelcome:h=!1,onStartFresh:p,onSignIn:x}=e,{setUserData:g,userData:f,uuid:b,password:y}=ri(),{status:j}=tj(),{setSelectedMenu:w}=rh(),[N,k]=(0,u.useState)(""),[S,C]=(0,u.useState)("all"),[_,A]=(0,u.useState)("all"),[R,T]=(0,u.useState)(!1),[I,E]=(0,u.useState)(null),M=u.useRef(null),P=u.useRef(!1),$=function(){let[e,t]=(0,u.useState)(!1),[s,a]=(0,u.useState)(null),[r,n]=(0,u.useState)(null),[l,i]=(0,u.useState)(null),[o,d]=(0,u.useState)("Proceed");return{show:e,template:s,data:r,onProceed:l,proceedLabel:o,open:e=>{let{template:s,data:r,onProceed:l,proceedLabel:o}=e;a(s),n(r),i(()=>l),d(o),t(!0)},close:()=>{t(!1),a(null),n(null),i(null),d("Proceed")},setOnProceed:i}}(),D=px(j),L=function(e){let{status:t,userData:s,setUserData:a,validationModal:r,templateValidations:n,setSelectedMenu:l,onOpenChange:i,initialStep:o="browse"}=e,[d,c]=(0,u.useState)(o),[h,p]=(0,u.useState)(["browse","review"]),x=(0,u.useRef)(o);x.current=o;let[g,f]=(0,u.useState)(null),[b,v]=(0,u.useState)([]),[y,j]=(0,u.useState)({}),[w,N]=(0,u.useState)(null),[k,S]=(0,u.useState)([]),[C,_]=(0,u.useState)({}),[A,R]=(0,u.useState)([]),[T,I]=(0,u.useState)(!1),E=()=>{let e={step:d,processedTemplate:g?JSON.parse(JSON.stringify(g)):null,pendingTemplate:w?JSON.parse(JSON.stringify(w)):null,templateInputOptions:JSON.parse(JSON.stringify(k)),templateInputValues:JSON.parse(JSON.stringify(C)),selectedServices:[...b],inputValues:{...y}};R(t=>[...t,e])},M=e=>((null==s?void 0:s.services)??[]).filter(t=>e.includes(t.id)&&t.enabled&&t.credentials&&Object.values(t.credentials).some(e=>e)).map(e=>e.id),P=(e,a)=>{var r;let n=((null==(r=e.metadata.inputs)?void 0:r.length)??0)>0,l=pv(a,a.services,t,s),i=["browse"];a.showServiceSelection&&i.push("selectService"),n&&i.push("templateInputs"),(a.inputs.length>0||l.length>0)&&i.push("inputs"),i.push("review"),p(i)},$=e=>p(t=>t.filter(t=>t!==e)),D=e=>{let{config:t,inputs:s,resolvedValues:a,selectedSvcs:r}=e,n=a8(JSON.parse(JSON.stringify(t)));
43if(s.forEach(e=>{let t=a[e.key];if(t||!e.required)for(let s of Array.isArray(e.path)?e.path:[e.path])if(s.startsWith("services.")){let e=s.split("."),a=e[1],r=e[2];n.services||(n.services=[]);let l=n.services.find(e=>e.id===a);l||(l={id:a,enabled:!0,credentials:{}},n.services.push(l)),l.credentials||(l.credentials={}),l.credentials[r]=t||""}else pj(n,s,t||"")}),r.length>0){n.services||(n.services=[]);let e=n.services;r.forEach(t=>{let s=e.find(e=>e.id===t);s?s.enabled||(s.enabled=!0):e.push({id:t,enabled:!0,credentials:{}})}),e.forEach(e=>{r.includes(e.id)||(e.enabled=!1)})}return!function e(t,s){if("string"==typeof t)return t.replace(/\{\{services\.(\w[\w-]*)\.(\w[\w-]*)\}\}/g,(e,t,a)=>s[`service_${t}_${a}`]??"");if(Array.isArray(t))return t.map(t=>e(t,s));if(t&&"object"==typeof t)for(let a of Object.keys(t))t[a]=e(t[a],s);return t}(n,a),n},L=async e=>{let{config:t,inputs:s,resolvedValues:r,selectedSvcs:n,templateName:o,setToSaveInstallMenu:d,templateId:u,templateVersion:h,templateSourceUrl:p}=e;I(!0);try{let e=D({config:t,inputs:s,resolvedValues:r,selectedSvcs:n});a(t=>({...t,...e})),u&&h&&a(e=>({...e,appliedTemplates:[...(e.appliedTemplates??[]).filter(e=>e.id!==u),{id:u,version:h,...p?{url:p}:{}}]}));let g=(e.presets||[]).filter(e=>["gdrive"].some(t=>e.type.toLowerCase().includes(t))).map(e=>{var t;return(null==(t=e.options)?void 0:t.name)||e.type});m.oR.success(`Template "${o}" loaded successfully`),g.length>0&&setTimeout(()=>{m.oR.info(`Note: ${g.join(", ")} require additional setup. Please configure them in the Addons section.`,{duration:8e3})},1e3),f(null),c(x.current),v([]),j({}),R([]),d&&l("save-install"),i(!1)}catch(e){console.error("Error loading template:",e),m.oR.error("Failed to load template")}finally{I(!1)}},O=e=>{py(e.config,t);let a=pb(e,t,s);if(f(a),P(e,a),a.skipServiceSelection){if(1===a.services.length){let e=pv(a,a.services,t,s);a.inputs=[...e,...a.inputs],v(a.services)}if(0===a.inputs.length){v(1===a.services.length?a.services:[]),j({}),$("inputs"),c("review");return}j(a.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),c("inputs")}else if(a.showServiceSelection)v(M(a.services)),c("selectService");else{if(0===a.inputs.length){v([]),j({}),$("inputs"),c("review");return}j(a.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),c("inputs")}},U=e=>{E();let a=e.metadata.inputs||[];if(a.length>0){let r={};for(let e of a)if(void 0!==e.default?r[e.id]=e.default:"boolean"===e.type&&(r[e.id]=!1),"subsection"===e.type&&Array.isArray(e.subOptions)){let t={};for(let s of e.subOptions)void 0!==s.default?t[s.id]=s.default:"boolean"===s.type&&(t[s.id]=!1);Object.keys(t).length>0&&(r[e.id]={...t,...r[e.id]??{}})}let n=((e,t)=>{let s={...e};for(let a of Object.keys(t))null===t[a]||"object"!=typeof t[a]||Array.isArray(t[a])||"object"!=typeof e[a]||null===e[a]||Array.isArray(e[a])?s[a]=t[a]:s[a]={...e[a],...t[a]};return s})(r,pN(a,(e=>{try{let t=localStorage.getItem("aiostreams-template-inputs");if(t)return JSON.parse(t)[e]??{}}catch{}return{}})(e.metadata.id))),l=pb(e,t,s);if(P(e,l),l.showServiceSelection){f(l),N(e),S(a),_(n),v(M(l.services)),c("selectService");return}f(null),N(e),S(a),_(n),c("templateInputs");return}O(e)},F=async()=>{g&&await L({config:g.template.config,inputs:g.inputs,resolvedValues:y,selectedSvcs:b,templateName:g.template.metadata.name,setToSaveInstallMenu:g.template.metadata.setToSaveInstallMenu,templateId:g.template.metadata.id,templateVersion:g.template.metadata.version,templateSourceUrl:g.template.metadata.sourceUrl})};return{currentStep:d,plannedSteps:h,processedTemplate:g,selectedServices:b,inputValues:y,pendingTemplate:w,templateInputOptions:k,templateInputValues:C,wizardHistory:A,isLoading:T,setSelectedServices:v,setInputValues:j,setTemplateInputValues:_,setProcessedTemplate:f,executeLoadTemplate:U,handleLoadTemplate:e=>{let t=n[e.metadata.id];t&&(t.errors.length>0||t.warnings.length>0)?r.open({template:e,data:t,proceedLabel:"Load Anyway",onProceed:0===t.errors.length?()=>U(e):null}):U(e)},handleServiceSelectionNext:()=>{if(!g)return;if(!g.allowSkipService&&0===b.length)return void m.oR.error("Please select at least one service");E();let e=[...pv(g,b,t,s),...g.inputs];if(g.inputs=e,f(e=>{if(!e)return null;for(let a of b){var t,s;let r=null==(s=e.template.config.services)||null==(t=s.find)?void 0:t.call(s,e=>e.id===a);r&&(r.enabled=!0)}return e}),null!==w)return void c("templateInputs");if(j(e.reduce((e,t)=>
43({...e,[t.key]:t.value}),{})),0===e.length){$("inputs"),c("review");return}c("inputs")},handleServiceSelectionSkip:()=>{if(g){if(!g.allowSkipService)return void m.oR.error("Service selection cannot be skipped for this template");if(E(),v([]),null!==w)return void c("templateInputs");if(j(g.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),0===g.inputs.length){$("inputs"),c("review");return}c("inputs")}},handleTemplateInputsNext:()=>{if(!w)return;let e=pw("pro",k,C,b).filter(e=>e.required&&(void 0===C[e.id]||null===C[e.id]||""===C[e.id]));if(e.length>0)return void m.oR.error(`Please fill in required fields: ${e.map(e=>e.name||e.id).join(", ")}`);E();let a=function e(t,s,a){if(Array.isArray(t))return t.filter(e=>!e||"object"!=typeof e||!("__if"in e)||po(e.__if,s,a)).flatMap(t=>{if(t&&"object"==typeof t&&"__if"in t){let{__if:r,...n}=t;if("__value"in n){let t=e(n.__value,s,a);return Array.isArray(t)?t:[t]}return e(n,s,a)}if(t&&"object"==typeof t&&"__value"in t){let r=e(t.__value,s,a);return Array.isArray(r)?r:[r]}let r=e(t,s,a);return Array.isArray(r)?r:[r]});if(t&&"object"==typeof t){if("__switch"in t){let r,n=t.__switch,l=t.cases??{},i=t.default??null,o="services"===(r=n.trim())?a.slice():r.startsWith("inputs.")?pi(s,r.slice(7)):r.startsWith("services.")?a.includes(r.slice(9)):void 0,d=null!=o?String(o):null;return e(null!==d&&d in l?l[d]:i,s,a)}if("__if"in t&&"__value"in t)return po(t.__if,s,a)?e(t.__value,s,a):pl;if(!0===t.__remove)return pl;let r={};for(let[n,l]of Object.entries(t)){let t=e(l,s,a);t!==pl&&(r[n]=t)}return r}if("string"==typeof t){if("{{services}}"===t)return a.slice();let e=t.match(/^\{\{(inputs|services)\.([^}]+)\}\}$/);if(e){let[,t,r]=e;if("inputs"===t){let e=pi(s,r);return null!=e?e:""}if("services"===t)return r.includes(".")?`{{services.${r}}}`:a.includes(r)}return t.replace(/\{\{services\}\}/g,a.join(",")).replace(/\{\{(inputs|services)\.([^}]+)\}\}/g,(e,t,r)=>{if("inputs"===t){let e=pi(s,r);return null!=e?String(e):""}return"services"===t?r.includes(".")?`{{services.${r}}}`:String(a.includes(r)):""})}return t}(JSON.parse(JSON.stringify(w.config)),C,b);py(a,t);let r={...w,config:a};var n=w.metadata.id;try{let e=localStorage.getItem("aiostreams-template-inputs"),t=e?JSON.parse(e):{};t[n]=C,localStorage.setItem("aiostreams-template-inputs",JSON.stringify(t))}catch{}if(N(null),S([]),null!==g){let e=pb(r,t,s);if(e.inputs=[...g.inputs.filter(e=>Array.isArray(e.path)?e.path.some(e=>e.startsWith("services.")):e.path.startsWith("services.")),...e.inputs],f(e),j(e.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),0===e.inputs.length){$("inputs"),c("review");return}c("inputs")}else O(r)},handleCredentialsNext:()=>{if(!g)return;let e=g.inputs.filter(e=>{var t;return e.required&&!(null==(t=y[e.key])?void 0:t.trim())});e.length>0?m.oR.error(`Please fill in all required fields: ${e.map(e=>e.label).join(", ")}`):(E(),c("review"))},previewUserData:()=>{if(!g)return null;try{return{...s,...D({config:g.template.config,inputs:g.inputs,resolvedValues:y,selectedSvcs:b})}}catch(e){return console.error("Failed to preview template changes:",e),null}},goToStep:e=>{E(),c(e)},resetTo:e=>{f(null),N(null),S([]),_({}),v([]),j({}),R([]),p(["browse","review"]),c(e)},pushHistory:E,handleBack:()=>{if(0===A.length)return;let e=A[A.length-1];R(A.slice(0,-1)),c(e.step),f(e.processedTemplate),N(e.pendingTemplate),S(e.templateInputOptions),_(e.templateInputValues),v(e.selectedServices),j(e.inputValues)},confirmLoadTemplate:F,handleCancel:()=>{f(null),N(null),S([]),_({}),c(x.current),v([]),j({}),R([]),p(["browse","review"]),i(!1)}}}({status:j,userData:f,setUserData:g,validationModal:$,templateValidations:D.templateValidations,setSelectedMenu:w,onOpenChange:n,initialStep:h?"welcome":"browse"}),O=function(e){let{status:t,templates:s,setTemplates:a,setTemplateValidations:r,validationModal:n,handleLoadTemplate:l,executeLoadTemplate:i}=e,[o,d]=(0,u.useState)(!1),[c,h]=(0,u.useState)(""),[p,x]=(0,u.useState)(!1),[g,f]=(0,u.useState)(!1),[b,v]=(0,u.useState)([]),[y,j]=(0,u.useState)(null),[w,N]=(0,u.useState)(!1),[k,S]=(0,u.useState)(null),C=sd({title:"Delete Template",description:"Are you sure you want to delete this template? This action cannot be undone.",actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>{var e;k&&(e=k.metadata.id,a(t=>t.filter(t=>t.metadata.id!==e)),pr(pa().filter(t=>t.metadata.id!==e)),m.oR.success("Template deleted successfully"))}}),_=(e,a,l)=>{try{let N=Array.isArray(e)?e:[e],k=[],S=[];if(l){let e=function(e){let t=[],s=[],a=[],r=0;for(;r<e.length;){let n=e[r];if("{"===n){let e=a.join("")||"root";s.push({path:e,seen:new Set}),r++;continue}if("}"===n){s.pop(),r++;continue}if('"'===n&&s.length>0){let a=r+1,n="";for(;a<e.length;){if("\\"===e[a]){a+=2;continue}if('"'===e[a])break;n+=e[a],a++}for(a++;a<e.length&&/\s/.test(e[a]);)a++;if(":"===e[a]){let e=s[s.length-1];e.seen.has(n)?t.push(`${e.path}: duplicate key "${n}"`):e.seen.add(n),r=a+1;continue}}r++}return t}(l);S.push(...e)}for(let e of N){var i,o,c,u,p,x,g,b,y,j,w;if(!e.config)return void m.oR.error("Invalid template: missing config field");let l=(null==(i=e.metadata)?void 0:i.id)||`imported-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,f=s.find(e=>e.metadata.id===l);if(f&&("builtin"===f.metadata.source||"custom"===f.metadata.source)&&1!==pn(e.metadata.version,f.metadata.version)){console.log(`Skipping template "${e.metadata.name}" because it is not newer than the existing template`);continue}let v={metadata:{id:l,name:(null==(o=e.metadata)?void 0:o.name)||"Imported Template",description:(null==(c=e.metadata)?void 0:c.description)||"Imported from JSON",author:(null==(u=e.metadata)?void 0:u.author)||"Unknown",version:(null==(p=e.metadata)?void 0:p.version)||"1.0.0",category:(null==(x=e.metadata)?void 0:x.category)||"Custom",services:null==(g=e.metadata)?void 0:g.services,serviceRequired:null==(b=e.metadata)?void 0:b.serviceRequired,source:"external",setToSaveInstallMenu:!0,sourceUrl:a,inputs:null==(y=e.metadata)?void 0:y.inputs,changelog:null==(j=e.metadata)?void 0:j.changelog,changelogUrl:null==(w=e.metadata)?void 0:w.changelogUrl},config:e.config||e};if(t){let e=pp(v,t);if(e.errors.length>0){d(!1),h(""),n.open({template:v,data:e,onProceed:null,proceedLabel:"Import Anyway"});return}if(r(t=>({...t,[v.metadata.id]:e})),e.warnings.length>0){let t=N.length>1?`[${v.metadata.name}] `:"";S.push(...e.warnings.map(e=>`${t}${e}`))}}k.push(v)}if(0===k.length)return void m.oR.info("There were no templates to import as existing templates are newer or the same version.");
43if(S.length>0){d(!1),h(""),n.open({template:k[0],data:{isValid:!0,errors:[],warnings:S},proceedLabel:"Import Anyway",onProceed:()=>{v(k),f(!0)}});return}d(!1),h(""),v(k),f(!0)}catch(e){m.oR.error("Invalid template format: "+e.message)}},A=async()=>{if(!c.trim())return void m.oR.error("Please enter a URL");x(!0);try{let e=await fetch(c);if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=await e.text(),s=JSON.parse(t);_(s,c,t)}catch(e){m.oR.error("Failed to import template: "+e.message)}finally{x(!1)}};return{showImportModal:o,setShowImportModal:d,importUrl:c,setImportUrl:h,isImporting:p,showImportConfirmModal:g,setShowImportConfirmModal:f,pendingImportTemplates:b,selectedPendingTemplateIndex:y,setSelectedPendingTemplateIndex:j,showDeepLinkWarning:w,setShowDeepLinkWarning:N,templateToDelete:k,setTemplateToDelete:S,processImportedTemplate:_,handleImportFromUrl:A,handleImportFromFile:()=>{let e=document.createElement("input");e.type="file",e.accept=".json",e.onchange=async e=>{var t;let s=null==(t=e.target.files)?void 0:t[0];if(s)try{let e=await s.text(),t=JSON.parse(e);_(t,void 0,e)}catch(e){m.oR.error("Failed to read file: "+e.message)}},e.click()},handleConfirmImport:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0,s=pa(),r=new Set(b.map(e=>e.metadata.id));pr([...b,...s.filter(e=>!r.has(e.metadata.id))]),a(e=>[...b,...e.filter(e=>!r.has(e.metadata.id))]);let n=s.filter(e=>r.has(e.metadata.id)).length;n>0?m.oR.success(`Successfully imported ${b.length} template${1!==b.length?"s":""} (${n} overwritten)`):m.oR.success(`Successfully imported ${b.length} template${1!==b.length?"s":""}`),e&&(1===b.length||void 0!==t)?(f(!1),i(b[t??0])):f(!1),v([]),j(null),N(!1)},handleCancelImport:()=>{f(!1),v([]),j(null),N(!1)},confirmDeleteTemplate:C}}({status:j,templates:D.templates,setTemplates:D.setTemplates,setTemplateValidations:D.setTemplateValidations,validationModal:$,handleLoadTemplate:L.handleLoadTemplate,executeLoadTemplate:L.executeLoadTemplate});(0,u.useEffect)(()=>{r&&!P.current&&(L.resetTo(h?"welcome":"browse"),E(c??null)),P.current=r},[r,h]),(0,u.useEffect)(()=>{if(r)try{D.loadTemplates(),l&&O.setShowImportModal(!0)}catch(t){let e="Failed to load templates";t instanceof es?e+=`: ${t.message}`:console.error("Error loading templates:",t),m.oR.error(e)}},[r]),(0,u.useEffect)(()=>{r&&o&&M.current!==o&&(M.current=o,O.setShowDeepLinkWarning(!0),(async()=>{try{let e=await fetch(o);if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=await e.json();O.processImportedTemplate(t,o)}catch(e){m.oR.error("Failed to load template from link: "+e.message)}})())},[r,o]),(0,u.useEffect)(()=>{if(d&&O.pendingImportTemplates.length>0){let e=O.pendingImportTemplates.findIndex(e=>e.metadata.id===d);-1!==e&&O.setSelectedPendingTemplateIndex(e)}},[O.pendingImportTemplates,d]);let U=(0,u.useMemo)(()=>["all",...Array.from(new Set(D.templates.flatMap(e=>hW(e.metadata))))],[D.templates]),F=["all","builtin","custom","external","community"],z=b?{uuid:b,password:y}:null,V=(null==j||null==(t=j.settings.community)?void 0:t.templates)!=="off",q=(0,ty.I)({...tv(z),enabled:r&&!!z&&V}),B=(0,e5.n)({mutationFn:e=>hV(z,e,q.data),onSuccess:e=>{let{item:t,updated:s}=e;m.oR.success(hq(t,s)),q.refetch(),D.loadTemplates()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to share")}),K=u.useRef(null),H=sd({...hF,onConfirm:()=>{K.current&&B.mutate(K.current)}}),W=(0,e5.n)({mutationFn:e=>eK(z,e),onSuccess:(e,t)=>{D.setCommunityItems(s=>s[t]?{...s,[t]:{...s[t],likes:e.likes}}:s)},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to like")}),G=(0,u.useMemo)(()=>{var e;let t=new Map;return((null==j||null==(e=j.settings)?void 0:e.featuredTemplateIds)??[]).forEach((e,s)=>t.set(e,s)),t},[null==j||null==(s=j.settings)?void 0:s.featuredTemplateIds]),Y=(0,u.useMemo)(()=>D.templates.filter(e=>{var t;let s=e.metadata.name.toLowerCase().includes(N.toLowerCase())||e.metadata.description.toLowerCase().includes(N.toLowerCase())||(null==(t=e.metadata.services)?void 0:t.some(e=>e.toLowerCase().includes(N.toLowerCase()))),a="all"===S||hW(e.metadata).includes(S),r="all"===_||e.metadata.source===_;return s&&a&&r}).sort((e,t)=>
43(G.get(e.metadata.id)??1/0)-(G.get(t.metadata.id)??1/0)),[D.templates,N,S,_,G]),J=((null==f?void 0:f.presets)??[]).length>0||((null==f?void 0:f.services)??[]).some(e=>e.enabled),Z=(0,u.useMemo)(()=>((null==f?void 0:f.services)??[]).filter(e=>e.credentials&&Object.values(e.credentials).some(e=>!!e)).map(e=>e.id),[null==f?void 0:f.services]),Q=(0,u.useMemo)(()=>{var e;for(let t of(null==j||null==(e=j.settings)?void 0:e.featuredTemplateIds)??[]){let e=D.templates.find(e=>e.metadata.id===t);if(e)return e}return D.templates[0]},[null==j||null==(a=j.settings)?void 0:a.featuredTemplateIds,D.templates]),X=L.currentStep,ee=L.wizardHistory.length>0,et=(()=>{switch(X){case"welcome":return{title:"Set up AIOStreams",description:"Two minutes to a working addon. Pick a starting point.",body:(0,i.jsx)(pE,{recommendedTemplateName:null==Q?void 0:Q.metadata.name,templateCount:D.templates.length,hasExistingConfig:!!b,onUseTemplate:()=>{E((null==Q?void 0:Q.metadata.id)??null),L.goToStep("browse")},onStartFresh:()=>{L.handleCancel(),null==p||p()},onSignIn:b?void 0:()=>{L.handleCancel(),null==x||x()}}),footer:null};case"browse":return{title:"Choose a setup",description:"Open one to see what it installs and what you will need.",body:(0,i.jsx)(p4,{searchQuery:N,onSearchChange:k,selectedCategory:S,onCategoryChange:C,selectedSource:_,onSourceChange:A,categories:U,sources:F,filteredTemplates:Y,allTemplates:D.templates,loadingTemplates:D.loadingTemplates,templateValidations:D.templateValidations,isLoading:L.isLoading,onLoadTemplate:e=>{E(e.metadata.id),L.handleLoadTemplate(e)},onImportOpen:()=>O.setShowImportModal(!0),onDeleteRequest:e=>{O.setTemplateToDelete(e),O.confirmDeleteTemplate.open()},totalTemplateCount:D.templates.length,communityItems:D.communityItems,onLike:z?e=>W.mutate(e):void 0,likeDisabledReason:z?void 0:"Create or load your configuration (UUID and password) first; likes are tied to it",onMineOpen:z&&V?()=>T(!0):void 0,onShare:z&&V?e=>{K.current=e,H.open()}:void 0,shareDisabledReason:V&&!z?"Create or load your configuration (UUID and password) first; shared templates are tied to it":void 0,initialExpandedTemplate:I&&!$.show?D.templates.find(e=>e.metadata.id===I)??void 0:void 0,onInitialExpandedConsumed:()=>E(null)}),footer:ee?(0,i.jsx)(p_,{onBack:L.handleBack}):null};case"selectService":{let e=L.processedTemplate;if(!e)return null;let t=e.allowSkipService,s=0===L.selectedServices.length;return{title:"Which services do you use?",description:t?"Pick the ones you have accounts for. You can skip this if none apply.":"Pick the ones you have accounts for.",body:(0,i.jsx)(p6,{processedTemplate:e,selectedServices:L.selectedServices,onServicesChange:L.setSelectedServices,status:j,configuredServices:Z}),footer:(0,i.jsx)(p_,{onBack:ee?L.handleBack:void 0,onSkip:t?L.handleServiceSelectionSkip:void 0,skipLabel:"I don't use any of these",primary:(0,i.jsx)(v,{intent:"primary",onClick:L.handleServiceSelectionNext,disabled:!t&&s,children:"Continue"})})}}case"templateInputs":var e,t;return{title:"Options",description:"Adjust this setup before it is applied.",body:(0,i.jsx)(p9,{options:L.templateInputOptions,values:L.templateInputValues,onValuesChange:L.setTemplateInputValues,trusted:!["external","community"].includes((null==(t=L.pendingTemplate)||null==(e=t.metadata)?void 0:e.source)??""),selectedServices:L.selectedServices}),footer:(0,i.jsx)(p_,{onBack:ee?L.handleBack:void 0,primary:(0,i.jsx)(v,{intent:"primary",onClick:L.handleTemplateInputsNext,children:"Continue"})})};case"inputs":{let e=L.processedTemplate;if(!e)return null;let t=e.inputs.filter(e=>{var t;return e.required&&!(null==(t=L.inputValues[e.key])?void 0:t.trim())});return{title:"Credentials",description:"These are stored in your configuration and never shared with other users.",body:(0,i.jsx)(p8,{processedTemplate:e,inputValues:L.inputValues,onInputValuesChange:L.setInputValues,status:j}),footer:(0,i.jsx)(p_,{onBack:ee?L.handleBack:void 0,primary:(0,i.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[(0,i.jsx)(v,{intent:"primary",onClick:L.handleCredentialsNext,disabled:t.length>0,children:"Continue"}),t.length>0&&(0,i.jsxs)("span",{className:"text-xs text-gray-500",children:[t.length," required field",1===t.length?"":"s"," left"]})]})})}}case"review":{let e=L.processedTemplate;if(!e)return null;return{title:"Ready to apply",description:"A last look before this touches your configuration.",body:(0,i.jsx)(xs,{processedTemplate:e,selectedServices:L.selectedServices,inputValues:L.inputValues,status:j,currentUserData:J?f:null,previewUserData:L.previewUserData}),footer:(0,i.jsx)(p_,{onBack:ee?L.handleBack:void 0,primary:(0,i.jsx)(v,{intent:"primary",onClick:L.confirmLoadTemplate,loading:L.isLoading,children:"Apply setup"})})}}default:return null}})();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(sl,{open:r&&null!==et,onOpenChange:e=>{e||L.handleCancel()},onOpenAutoFocus:e=>e.preventDefault(),contentClass:"max-w-5xl w-full !flex flex-col overflow-hidden h-[100svh] sm:h-[min(46rem,calc(100svh-2rem))]",children:et&&(0,i.jsx)(pS,{steps:"welcome"===X||"browse"===X?[]:L.plannedSteps,current:X,title:et.title,de
43scription:et.description,footer:et.footer,children:et.body})}),(0,i.jsx)(xa,{showImportModal:O.showImportModal,onImportModalChange:O.setShowImportModal,importUrl:O.importUrl,onImportUrlChange:O.setImportUrl,isImporting:O.isImporting,onImportFromUrl:O.handleImportFromUrl,onImportFromFile:O.handleImportFromFile,showImportConfirmModal:O.showImportConfirmModal,onImportConfirmModalChange:O.setShowImportConfirmModal,pendingImportTemplates:O.pendingImportTemplates,selectedPendingTemplateIndex:O.selectedPendingTemplateIndex,onSelectedIndexChange:O.setSelectedPendingTemplateIndex,showDeepLinkWarning:O.showDeepLinkWarning,onConfirmImport:O.handleConfirmImport,onCancelImport:O.handleCancelImport,status:j}),(0,i.jsx)(pB,{open:$.show,template:$.template,data:$.data,onProceed:$.onProceed,proceedLabel:$.proceedLabel,onClose:$.close}),(0,i.jsx)(sc,{...O.confirmDeleteTemplate}),(0,i.jsx)(sc,{...H}),z&&(0,i.jsx)(h6,{open:R,onOpenChange:T,credentials:z,userData:f,filterCredentials:e=>hY(e,e=>{var t;return null==j||null==(t=j.settings.presets.find(t=>t.ID===e))?void 0:t.OPTIONS}),onChanged:()=>void D.loadTemplates()})]})}var xn=s(13243),xl=s(60767),xi=s(24720);function xo(e){let{addonName:t,addonDescription:s,logo:a,version:r,channel:n,commit:l,onCustomize:o,onDonate:d,isSignedIn:c,onToggleSession:u}=e;return(0,i.jsxs)("div",{className:"flex items-start gap-4 sm:gap-5 w-full",children:[(0,i.jsx)("img",{src:a,alt:"",width:72,height:72,className:"w-16 h-16 sm:w-[72px] sm:h-[72px] rounded-xl shadow-lg shrink-0"}),(0,i.jsxs)("div",{className:"min-w-0 flex-1 pt-0.5",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-end gap-x-3 gap-y-1 min-w-0",children:[(0,i.jsx)("h1",{className:"text-2xl sm:text-3xl font-bold tracking-tight text-gray-100 truncate min-w-0",children:t}),(0,i.jsxs)("span",{className:"text-lg sm:text-xl font-semibold text-gray-400 pb-0.5",children:[r,("nightly"===n||"dev"===n)&&l&&(0,i.jsxs)(i.Fragment,{children:[" ",(0,i.jsxs)("a",{href:`https://github.com/Viren070/AIOStreams/commit/${l}`,target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:["(",l,")"]})]})]}),(0,i.jsx)(w,{icon:(0,i.jsx)(xn.A,{className:"w-3.5 h-3.5"}),intent:"gray-subtle",onClick:o,className:"rounded-full shrink-0 self-center",size:"sm"})]}),(0,i.jsx)("p",{className:"text-sm sm:text-base text-[--muted] mt-1.5 max-w-3xl",children:s})]}),(0,i.jsxs)("div",{className:"hidden lg:flex items-center gap-2 shrink-0",children:[(0,i.jsx)(v,{intent:"gray-outline",size:"sm",rounded:!0,leftIcon:(0,i.jsx)(pL.A,{className:"w-4 h-4"}),onClick:d,className:"shrink-0 border-red-300/30 text-red-200 hover:bg-red-500/10 hover:border-red-300/50 hover:text-red-100",children:"Donate"}),(0,i.jsx)(v,{intent:"gray-outline",size:"sm",rounded:!0,leftIcon:c?(0,i.jsx)(xl.A,{className:"w-4 h-4"}):(0,i.jsx)(xi.A,{className:"w-4 h-4"}),onClick:u,className:"shrink-0",children:c?"Sign Out":"Sign In"})]})]})}var xd=s(19688),xc=s(72898);function xu(e){let{isSignedIn:t,hasConfig:s,onStartSetup:a,onContinue:r,onBrowseSetups:n,onInstall:l,onSignIn:o}=e;return(0,i.jsxs)(pK,{className:"p-5 sm:p-6 flex flex-col gap-4",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"text-lg font-semibold text-white",children:s?"Your configuration":"Get started"}),(0,i.jsxs)("p",{className:"text-sm text-[--muted] mt-1",children:[s?"Pick up where you left off, or grab your install link.":"Pick a ready-made setup or build one yourself. It takes a couple of minutes.",s&&!t&&(0,i.jsx)("span",{className:"block text-xs text-gray-500 mt-1",children:"Not saved yet â finish on Save & Install to get your install link."})]})]}),(0,i.jsx)("div",{className:"flex flex-col sm:flex-row gap-2",children:s?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{intent:"primary",rounded:!0,leftIcon:(0,i.jsx)(xd.A,{className:"w-4 h-4"}),className:"w-full sm:flex-1 h-11",onClick:r,children:"Continue setup"}),(0,i.jsx)(v,{intent:"gray-outline",rounded:!0,leftIcon:(0,i.jsx)(xc.A,{className:"w-4 h-4"}),className:"w-full sm:flex-1 h-11",onClick:l,children:"Save & install"})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{intent:"primary",rounded:!0,leftIcon:(0,i.jsx)(xd.A,{className:"w-4 h-4"}),className:"w-full sm:flex-1 h-11",onClick:a,children:"Start setup"}),(0,i.jsx)(v,{intent:"gray-outline",rounded:!0,leftIcon:(0,i.jsx)(pA.A,{className:"w-4 h-4"}),className:"w-full sm:flex-1 h-11",onClick:n,children:"Browse setups"})]})}),(s||!t)&&(0,i.jsxs)("div",{className:"space-y-1 text-xs text-gray-500",children:[s&&(0,i.jsxs)("p",{children:[(0,i.jsx)("button",{type:"button",onClick:n,className:"text-[--brand] hover:underline",children:"Browse ready-made setups"})," ","to apply a new one, or re-apply one you already use."]}),!t&&(0,i.jsxs)("p",{children:["Already have a configuration?"," ",(0,i.jsx)("button",{type:"button",onClick:o,className:"text-[--brand] hover:underline",children:"Sign in"})," ","to load it."]})]})]})}function xm(e){let{template:t,onOpen:s}=e,{addons:a,services:r,servicesChosenDuringSetup:n,skipsServiceSelection:l,addonsVary:o}=pq(t);return(0,i.jsx)(pK,{className:"bg-gray-900/60 border-gray-800 hover:border-gray-600 transition-colors duration-200 rounded-lg",children:(0,i.jsxs)("button",{type:"button",onClick:s,className:"text-left w-full h-full p-4 flex flex-col focus-visible:outline-none",children:[(0,i.jsxs)("div",{className:"flex items-start gap-2 mb-1.5",children:[(0,i.jsx)("h4",{className:"flex-1 min-w-0 text-base font-semibold text-white truncate",children:t.metadata.name}),(0,i.jsx)(pX,{template:t})]}),(0,i.jsx)("div",{className:"text-sm text-gray-400 line-clamp-3 mb-3",children:(0,i.jsx)(l6,{children:t.metadata.description})}),(0,i.jsxs)("div",{className:"mt-auto flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500",children:[(0,i.jsxs)("span",{className:"truncate max-w-[10rem]",children:["by ",t.metadata.author]}),a.length>0&&(0,i.jsxs)("span",{className:"flex items-center gap-1",children:[(0,i.jsx)(pP.A,{className:"w-3.5 h-3.5"}),o?"up to ":"",a.length," addon",1===a.length?"":"s"]}),r.length>0?(0,i.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,i.jsx)(p$.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,i.jsxs)("span",{className:"truncate",children:["Needs ",r.slice(0,2).join(", "),r.length>
432?` +${r.length-2}`:""]})]}):n?(0,i.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,i.jsx)(p$.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,i.jsx)("span",{className:"truncate",children:"You pick the services"})]}):l?(0,i.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,i.jsx)(pD.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,i.jsx)("span",{className:"truncate",children:"No service to pick"})]}):null]})]})})}function xh(e){let{templates:t,totalCount:s,loading:a,onOpen:r,onBrowseAll:n}=e;return a?(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,i.jsx)(uD,{className:"h-5 w-36"}),(0,i.jsx)(uD,{className:"h-4 w-24"})]}),(0,i.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[0,1].map(e=>(0,i.jsx)(uD,{className:"h-32 w-full rounded-lg"},e))})]}):0===t.length?null:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,i.jsx)("h3",{className:"text-base font-semibold text-white",children:"Featured setups"}),(0,i.jsxs)("button",{type:"button",onClick:n,className:"text-sm text-[--brand] hover:underline transition-colors",children:["Browse all ",s," â"]})]}),(0,i.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:t.map(e=>(0,i.jsx)(xm,{template:e,onOpen:()=>r(e)},e.metadata.id))})]})}var xp=s(55784),xx=s(65238);function xg(e){let{href:t,onClick:s,icon:a,label:r,hint:n,emphasis:l}=e,o=x("group flex items-center gap-3 rounded-lg px-3 py-2.5 transition-colors text-left w-full",l?"bg-red-500/[0.07] hover:bg-red-400/15":"hover:bg-gray-800/70"),d=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:x("shrink-0 transition-colors",l?"text-red-300":"text-gray-500 group-hover:text-gray-300"),children:a}),(0,i.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,i.jsx)("span",{className:"block text-sm font-medium text-gray-200",children:r}),(0,i.jsx)("span",{className:"block text-xs text-gray-500 truncate",children:n})]}),(0,i.jsx)(lZ.X6T,{className:"w-3 h-3 text-gray-600 group-hover:text-gray-400 transition-colors shrink-0"})]});return t?(0,i.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:o,children:d}):(0,i.jsx)("button",{type:"button",onClick:s,className:o,children:d})}function xf(e){let{discordUrl:t,githubUrl:s,onDonate:a}=e;return(0,i.jsxs)(pK,{className:"p-5",children:[(0,i.jsx)("h3",{className:"text-base font-semibold text-white mb-3",children:"Help & resources"}),(0,i.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1",children:[(0,i.jsx)(xg,{href:e6,icon:(0,i.jsx)(xp.A,{className:"w-4 h-4"}),label:"Documentation",hint:"Every option, explained"}),(0,i.jsx)(xg,{href:`${e6}/configuration/setup`,icon:(0,i.jsx)(xx.A,{className:"w-4 h-4"}),label:"Setup guide",hint:"Walkthrough for a first install"}),(0,i.jsx)(xg,{href:e9,icon:(0,i.jsx)(pO.A,{className:"w-4 h-4"}),label:"Changelog",hint:"What each release added"}),(0,i.jsx)(xg,{href:t,icon:(0,i.jsx)(I.fzZ,{className:"w-4 h-4"}),label:"Discord",hint:"Ask for help"}),(0,i.jsx)(xg,{href:s,icon:(0,i.jsx)(lV.BR8,{className:"w-4 h-4"}),label:"GitHub",hint:"Source and issues"}),(0,i.jsx)(xg,{onClick:a,icon:(0,i.jsx)(pL.A,{className:"w-4 h-4"}),label:"Donate",hint:"Support development",emphasis:!0})]})]})}let xb={sm:"h-9 text-xs",md:"h-11 text-sm",lg:"h-12 text-base"};function xv(e){let{value:t,onChange:s,size:a="md",className:r}=e;return(0,i.jsxs)("div",{role:"radiogroup",className:x("relative flex rounded-full bg-gray-800/60 border border-gray-800",xb[a],r),children:[(0,i.jsx)("div",{className:"absolute inset-y-[3px] left-[3px] w-[calc(50%-3px)] bg-white border border-[--brand]/30 rounded-full transition-transform duration-300 ease-in-out",style:{transform:`translateX(${"pro"===t?"100%":"0"})`}}),(0,i.jsx)("button",{type:"button",role:"radio","aria-checked":"noob"===t,onClick:()=>s("noob"),className:x("relative flex-1 flex items-center justify-center font-bold tracking-wide transition-colors duration-200","noob"===t?"text-black":"text-gray-400 hover:text-gray-300"),children:"SIMPLE"}),(0,i.jsx)("button",{type:"button",role:"radio","aria-checked":"pro"===t,onClick:()=>s("pro"),className:x("relative flex-1 flex items-center justify-center font-bold tracking-wide transition-colors duration-200","pro"===t?"text-black":"text-gray-400 hover:text-gray-300"),children:"ADVANCED"})]})}function xy(){let{mode:e,setMode:t}=sF();return(0,i.jsxs)(pK,{className:"p-5 flex flex-col sm:flex-row sm:items-center gap-4",children:[(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsx)("h3",{className:"text-base font-semibold text-white",children:"Interface"}),(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"pro"===e?"Advanced is on: the Sorting page and all advanced options are shown.":"Simple hides the Sorting page and the more advanced options."})]}
43),(0,i.jsx)(xv,{value:e,onChange:t,className:"w-full sm:w-48 sm:h-10 shrink-0"})]})}var xj=s(49638),xw=s(18579);function xN(e){let{version:t,baseVersion:s,channel:a,releases:r,docsEntries:n,docsLoading:l}=e,[o,d]=u.useState(!1);if("dev"===a)return(0,i.jsx)(pK,{className:"p-4",children:(0,i.jsxs)("p",{className:"text-sm text-gray-400",children:["This is a dev/PR build (",(0,i.jsx)("span",{className:"font-mono text-gray-300",children:t}),"). Update checks are not available."]})});let c=r.newer[0],m=!r.loading&&!r.error&&0===r.newer.length,h="nightly"===a?s:void 0,p=te(n,h??(null==c?void 0:c.tag_name)??t);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(pK,{className:"p-5",children:r.loading?(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(uD,{className:"h-5 w-52"}),(0,i.jsx)(uD,{className:"h-4 w-full max-w-md"})]}):r.error?(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,i.jsxs)("p",{className:"text-sm text-gray-400",children:["Could not check for updates â ",r.error]}),(0,i.jsx)(xk,{onOpenReleases:()=>d(!0)})]}):(0,i.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,i.jsxs)("div",{className:"flex items-start gap-3",children:[c?(0,i.jsx)(xj.A,{className:"w-5 h-5 text-[--brand] shrink-0 mt-0.5"}):(0,i.jsx)(xw.A,{className:"w-5 h-5 text-gray-500 shrink-0 mt-0.5"}),(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:c?(0,i.jsxs)(i.Fragment,{children:[c.tag_name," is available",r.newer.length>1&&(0,i.jsxs)("span",{className:"text-gray-500 font-normal",children:[" ","\xb7 ",r.newer.length," releases behind"]})]}):m?`You're on the latest ${"nightly"===a?"nightly":"release"}`:`Running ${t}`}),c&&(0,i.jsxs)("p",{className:"text-xs text-gray-500 mt-0.5",children:["You're on ",t]}),l?(0,i.jsx)(uD,{className:"h-4 w-64 mt-2"}):p?(0,i.jsxs)("div",{className:"mt-2",children:[h&&(0,i.jsxs)("p",{className:"text-xs text-gray-500",children:["Built on v",h.replace(/^v/,"")]}),(0,i.jsx)("p",{className:"text-sm text-gray-300",children:p.title}),p.description&&(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-0.5",children:p.description})]}):null]})]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p&&(0,i.jsxs)(v,{intent:"primary",size:"sm",rightIcon:(0,i.jsx)(uA.A,{className:"w-3.5 h-3.5"}),onClick:()=>window.open(tt(p),"_blank","noopener,noreferrer"),children:["What's new in ",p.version??p.title]}),(0,i.jsx)(xk,{onOpenReleases:()=>d(!0)})]})]})}),(0,i.jsx)(uO,{open:o,onOpenChange:d,channel:a,releases:r})]})}function xk(e){let{onOpenReleases:t}=e;return(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[(0,i.jsxs)("a",{href:e9,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-gray-400 hover:text-white transition-colors",children:[(0,i.jsx)(pO.A,{className:"w-3.5 h-3.5"}),"Changelog"]}),(0,i.jsx)("button",{type:"button",onClick:t,className:"text-sm text-gray-400 hover:text-white transition-colors",children:"All releases"})]})}var xS=s(5901);function xC(e){let{tag:t,baseVersion:s,channel:a,docsEntries:r}=e,[n,l]=u.useState(null),o="stable"===a?t:"nightly"===a&&s?`v${s.replace(/^v/,"")}`:"";u.useEffect(()=>{if(!o||"unknown"===o.toLowerCase())return;let e=function(){try{return localStorage.getItem(tr)}catch{return null}}();if(!e)return void(!function(){try{if(ed()||"u">typeof window&&tl.test(window.location.pathname))return!0;return tn.some(e=>null!==localStorage.getItem(e))}catch{return!1}}()?ti(o):l(o));if(e===o)return;let t=function(e,t){let s=e=>e.replace(/^v/,"").split(".").map(Number),[a,r,n]=s(e),[l,i,o]=s(t);return[a,r,n,l,i,o].some(Number.isNaN)?null:l>a?"major":l<a?null:i>r?"minor":i<r?null:o>n?"patch":null}(e,o);"major"===t||"minor"===t?l(o):ti(o)},[o]);let d=()=>{ti(o),l(null)},c=te(r,o),m="nightly"===a;return(0,i.jsx)(sl,{open:null!==n,onOpenChange:e=>{e||d()},contentClass:"max-w-lg",children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsxs)("div",{className:"flex items-start gap-3",children:[(0,i.jsx)("span",{className:"w-10 h-10 rounded-lg bg-brand-500/20 text-[--brand] flex items-center justify-center shrink-0",children:(0,i.jsx)(xS.A,{className:"w-5 h-5"})}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("h2",{className:"text-lg font-semibold text-white",children:m?`AIOStreams ${o} is out`:`AIOStreams was updated to ${o}`}),m?(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"This instance runs nightly builds, so you've had its changes as they landed. Read the changelog to catch up on anything you missed."}):c?(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:c.title}):(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"This instance is running a newer version than the last time you were here."})]})]}),((null==c?void 0:c.description)||m&&c)&&(0,i.jsxs)("div",{className:"text-sm border-l-2 border-gray-700 pl-3",children:[m&&(0,i.jsx)("p",{className:"text-white",children:null==c?void 0:c.title}),(null==c?void 0:c.description)&&(0,i.jsx)("p",{className:m?"text-gray-400 mt-0.5":"text-gray-300",children:c.description})]}),(0,i.jsxs)("div",{className:"flex items-center justify-between gap-3 pt-1",children:[(0,i.jsx)("button",{type:"button",onClick:d,className:"text-sm text-gray-500 hover:text-gray-300 transition-colors",children:"Dismiss"}),(0,i.jsx)(v,{intent:"primary",rightIcon:(0,i.jsx)(uA.A,{className:"w-3.5 h-3.5"}),onClick:()=>{window.open(c?tt(c):e9,"_blank","noopener,noreferrer"),d()},children:"See what changed"})]})]})})}function x_(e){let{open:t,onOpenChange:s,currentName:a,currentLogo:r,currentDescription:n}=e,{setUserData:l}=ri(),[o,d]=(0,u.useState)(a),[c,h]=(0,u.useState)(r),[p,x]=(0,u.useState)(n);return(0,u.useEffect)(()=>{d(a),h(r),x(n)},[a,r,n]),(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Customize Addon",children:(0,i.jsx)("form",{onSubmit:e=>{(e.preventDefault(),o.trim())?(l(e=>({...e,addonName:o.trim(),addonLogo:null==c?void 0:c.trim(),addonDescription:(null==p?void 0:p.trim())||void 0})),m.oR.success("Customization saved"),s(!1)):m.oR.error("Name cannot be empty")},children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(K,{label:"Addon Name",value:o,onValueChange:d,placeholder:"Enter addon name"}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"This name is shown wherever the addon is installed"})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(K,{label:"Logo URL",value:c,onValueChange:e=>{h(e.trim()||void 0)},placeholder:"Enter logo URL",type:"url"}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Enter a valid URL for your addon's logo image. Leave blank for default logo."})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(ly,{label:"Addon Description",value:p,onValueChange:x,placeholder:"Enter addon description",rows:3}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"This description is shown wherever the addon is installed"})]}),(0,i.jsxs)("div",{className:"flex justify-end gap-2 mt-2",children:[(0,i.jsx)(v,{intent:"primary-outline",onClick:()=>s(!1),children:"Cancel"}),(0,i.jsx)(v,{type:"submit",intent:"primary",children:"Save Changes"})]})]})})})}function xA(e){let{open:t,onOpenChange:s,updates:a,onApply:r,onDismiss:n,onForget:l,onDismissAll:o}=e;return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Template Updates Available",contentClass:"max-w-2xl",children:(0,i.jsxs)("div",{className:"space-y-4 min-w-0",children:[(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Templates you've applied have new versions available."}),(0,i.jsx)("div",{className:"space-y-3 max-h-[52vh] overflow-y-auto overflow-x-hidden pr-4 -mr-2",children:a.map(e=>(0,i.jsxs)("div",{className:"rounded-lg border border-gray-700 bg-gray-800/50 p-4 space-y-3",children:[(0,i.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,i.jsx)("span",{className:"font-semibold text-white",children:e.template.metadata.name}),(0,i.jsxs)("span",{className:"text-xs text-gray-400 whitespace-nowrap flex-shrink-0",children:["v",e.appliedVersion," ",(0,i.jsx)("span",{className:"text-gray-600",children:"â"})," ",(0,i.jsxs)("span",{className:"text-green-400",children:["v",e.template.metadata.version]})]})]}),e.newChangelog.length>0?(0,i.jsx)("div",{className:"space-y-3",children:e.newChangelog.map(e=>(0,i.jsx)(pG,{entry:e},e.version))}):e.template.metadata.changelogUrl?(0,i.jsx)(pQ,{update:e}):(0,i.jsx)("p",{className:"text-xs text-gray-500 italic",children:"No changelog provided for this update."}),(0,i.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,i.jsx)(v,{intent:"primary",className:"flex-1",onClick:()=>r(e),children:"Apply Update"}),(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>n(e.template.metadata.id,e.template.metadata.version),children:"Skip this version"})]}),(0,i.jsx)("button",{className:"text-xs text-gray-600 hover:text-gray-400 transition-colors underline-offset-2 hover:underline",onClick:()=>l(e.template.metadata.id),children:"Ignore all future updates for this template"})]},e.template.metadata.id))}),(0,i.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-gray-700",children:[(0,i.jsx)("button",{className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",onClick:o,children:"Dismiss all"}),(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>s(!1),children:"Maybe later"})]})]})})}function xR(){return(0,i.jsx)(ng,{className:"space-y-5 p-4 sm:p-8",children:(0,i.jsx)(xT,{})})}function xT(){var e,t,s;let{status:a}=tj(),{nextMenu:r,setSelectedMenu:n}=rh(),{userData:l,setUserData:o,uuid:d,password:c}=ri(),{isFirstTime:m,setIsFirstTime:h}=sF(),p=px(a),x=so(!1),g=so(!1),f=so(!1),b=so(!1),[v,y]=u.useState(!1),[j,w]=u.useState(null),[N,k]=u.useState([]),[S,C]=u.useState(),[_,A]=u.useState(),R=(0,ty.I)(tc),T=R.data??[],I=u.useRef(!1),{isSignedIn:E,openSignIn:M,toggleSession:P}=uY(),$=l.addonName||(null==a||null==(e=a.settings)?void 0:e.addonName)||"AIOStreams",D=l.addonDescription||"AIOStreams consolidates multiple Stremio addons and debrid services â including its own suite of exclusive built-in addons â into a single, highly customisable super-addon.",L=(null==a?void 0:a.tag)||"Unknown",O=(null==a?void 0:a.channel)??(L.startsWith("v")?"stable":"nightly"),U=null==a||null==(t=a.settings)?void 0:t.customHtml,F=uC(L,O,!0),z=(l.presets??[]).length>0||(l.services??[]).some(e=>e.enabled),V=u.useMemo(()=>{var e;let t=((null==a||null==(e=a.settings)?void 0:e.featuredTemplateIds)??[]).slice(0,2).map(e=>p.templates.find(t=>t.metadata.id===e)).filter(e=>void 0!==e);return t.length>0?t:p.templates.slice(0,2)},[null==a||null==(s=a.settings)?void 0:s.featuredTemplateIds,p.templates]);u.useEffect(()=>{p.loadTemplates()},[]),u.useEffect(()=>
43{m&&!d&&(y(!0),f.open(),h(!1))},[]),u.useEffect(()=>{if("u"<typeof window)return;let e=new URL(window.location.href),t=e.searchParams.get("template"),s=e.searchParams.get("templateId")??void 0;t&&(C(t),A(s),f.open(),e.searchParams.delete("template"),e.searchParams.delete("templateId"),window.history.replaceState({},"",e.toString()))},[]),u.useEffect(()=>{I.current=!1},[d]),u.useEffect(()=>{!d||I.current||0!==p.appliedTemplateUpdates.length&&(I.current=!0,k(p.appliedTemplateUpdates),b.open())},[p.appliedTemplateUpdates,d,c]);let q=e=>{k(t=>{let s=t.filter(t=>t.template.metadata.id!==e);return 0===s.length&&b.close(),s})},B=e=>{y((null==e?void 0:e.welcome)??!1),w((null==e?void 0:e.template)??null),f.open()};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex flex-col gap-5 w-full",children:[(0,i.jsx)(xo,{addonName:$,addonDescription:D,logo:l.addonLogo||"/logo.png",version:L,channel:O,commit:null==a?void 0:a.commit,onCustomize:g.open,onDonate:x.open,isSignedIn:E,onToggleSession:P}),U&&(0,i.jsx)(mK,{children:(0,i.jsx)("div",{className:"[&_a]:text-[--brand] [&_a:hover]:underline",dangerouslySetInnerHTML:{__html:U}})}),(0,i.jsx)(xu,{isSignedIn:E,hasConfig:z,onStartSetup:()=>B({welcome:!0}),onContinue:()=>r(),onBrowseSetups:()=>B(),onInstall:()=>n("save-install"),onSignIn:()=>M()}),(0,i.jsx)(xh,{templates:V,totalCount:p.templates.length,loading:p.loadingTemplates,onOpen:e=>B({template:e}),onBrowseAll:()=>B()}),(0,i.jsx)(xN,{version:L,baseVersion:null==a?void 0:a.version,channel:O,releases:F,docsEntries:T,docsLoading:R.isLoading}),(0,i.jsx)(xy,{}),(0,i.jsx)(xf,{discordUrl:"https://discord.viren070.me",githubUrl:"https://github.com/Viren070/AIOStreams",onDonate:x.open}),(0,i.jsxs)("div",{className:"flex flex-col items-center gap-0.5 text-xs text-gray-500 pt-2",children:[(0,i.jsxs)("span",{children:["\xa9 ",new Date().getFullYear()," AIOStreams. Developed by Viren070."]}),(0,i.jsxs)("span",{children:["This beautiful UI would not be possible without"," ",(0,i.jsx)("a",{href:"https://seanime.rahim.app/",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"Seanime"})]})]})]}),(0,i.jsx)(uX,{open:x.isOpen,onOpenChange:x.toggle}),(0,i.jsx)(x_,{open:g.isOpen,onOpenChange:g.toggle,currentName:$,currentLogo:l.addonLogo,currentDescription:l.addonDescription}),(0,i.jsx)(xr,{open:f.isOpen,onOpenChange:e=>{e?f.open():(f.close(),w(null),y(!1))},deepLinkUrl:S,deepLinkTemplateId:_,initialExpandedTemplateId:null==j?void 0:j.metadata.id,startAtWelcome:v,onStartFresh:()=>r(),onSignIn:()=>M()}),(0,i.jsx)(xA,{open:b.isOpen,onOpenChange:b.toggle,updates:N,onApply:e=>{b.close(),B({template:e.template})},onDismiss:(e,t)=>{o(s=>({...s,appliedTemplates:(s.appliedTemplates??[]).map(s=>s.id===e?{...s,dismissedVersion:t}:s)})),q(e)},onForget:e=>{o(t=>({...t,appliedTemplates:(t.appliedTemplates??[]).filter(t=>t.id!==e)})),q(e)},onDismissAll:()=>{o(e=>({...e,appliedTemplates:(e.appliedTemplates??[]).map(e=>{let t=N.find(t=>t.template.metadata.id===e.id);return t?{...e,dismissedVersion:t.template.metadata.version}:e})})),b.close()}}),(0,i.jsx)(xC,{tag:L,baseVersion:null==a?void 0:a.version,channel:O,docsEntries:T})]})}var xI=s(74298),xE=s(39733),xM=s(70858);let xP={root:(0,c.F)(["UI-Slider__root","relative flex w-full touch-none select-none items-center"],{variants:{size:{sm:"h-4 w-full",md:"h-5 w-full",lg:"h-6 w-full"}},defaultVariants:{size:"md"}}),track:(0,c.F)(["UI-Slider__track","relative h-1.5 w-full grow overflow-hidden rounded-full","bg-gray-200 dark:bg-gray-700","data-[disabled=true]:opacity-50"],{variants:{size:{sm:"h-1 w-full",md:"h-1.5 w-full",lg:"h-2 w-full"},defaultVariants:{size:"md"}}}),range:(0,c.F)(["UI-Slider__range","absolute h-full bg-brand","data-[disabled=true]:opacity-50"]),thumb:(0,c.F)(["UI-Slider__thumb","block h-4 w-4 rounded-full","border border-brand/50 bg-white shadow transition-colors","focus-visible:outline-none focus-visible:ring-1 ring-offset-1 ring-offset-[--background] focus-visible:ring-white/40","disabled:pointer-events-none disabled:opacity-50","data-[disabled=true]:opacity-50"],{variants:{size:{sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"}},defaultVariants:{size:"md"}}),mark:(0,c.F)(["UI-Slider__mark","absolute top-6 -translate-x-1/2 text-xs text-gray-500"]),markIndicator:(0,c.F)(["UI-Slider__markIndicator","absolute top-[7px] h-1 w-0.5 -translate-x-1/2 bg-gray-300 dark:bg-gray-600"]),label:(0,c.F)(["UI-Slider__label","relative font-normal","data-[disabled=true]:text-gray-300 cursor-pointer user-select-none select-none"])},x$=u.forwardRef((e,t)=>
43{let[{value:s,className:a,onValueChange:r,defaultValue:n,trackClass:l,rangeClass:o,thumbClass:d,markClass:c,markIndicatorClass:m,labelClass:h,showMarks:p,marks:g,size:f,...b},{label:v,moreHelp:y,...j}]=D(e,u.useId()),w=u.useRef(!0),[N,k]=u.useState(s??n??[0]),S=u.useCallback(e=>{k(e),null==r||r(e)},[r]);u.useEffect(()=>{n&&w.current||k(s??[0]),w.current=!1},[s]);let C=u.useMemo(()=>{if(!p||g)return[];let e=b.step||1,t=b.min||0;return Array.from({length:Math.floor(((b.max||100)-t)/e)+1},(s,a)=>({value:t+a*e,label:(t+a*e).toString()}))},[p,g,b.step,b.min,b.max]),_=g||C;return(0,i.jsx)(L,{...j,id:j.id,children:(0,i.jsxs)("div",{className:"flex flex-col gap-1",children:[v&&(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)("label",{className:x(xP.label(),h),htmlFor:j.id,"data-disabled":j.disabled,children:v}),y&&(0,i.jsx)(P,{className:"text-sm",trigger:(0,i.jsx)(I.ExT,{className:"transition-opacity opacity-45 hover:opacity-90"}),children:y})]}),(0,i.jsxs)(xM.bL,{ref:tL([t]),className:x(xP.root({size:f}),a),value:N,onValueChange:S,disabled:j.disabled||j.readonly,"data-disabled":j.disabled,"data-readonly":j.readonly,"data-error":!!j.error,...b,children:[(0,i.jsx)(xM.CC,{className:x(xP.track(),l),children:(0,i.jsx)(xM.Q6,{className:x(xP.range(),o)})}),_.map(e=>{let{value:t,label:s}=e;return(0,i.jsxs)(u.Fragment,{children:[(0,i.jsx)("div",{className:x(xP.markIndicator(),m),style:{left:`${(t-(b.min||0))/((b.max||100)-(b.min||0))*100}%`}}),(0,i.jsx)("div",{className:x(xP.mark(),c),style:{left:`${(t-(b.min||0))/((b.max||100)-(b.min||0))*100}%`},children:s})]},t)}),N.map((e,t)=>(0,i.jsx)(xM.zi,{className:x(xP.thumb({size:f}),d)},t))]})]})})});function xD(e){let{filterName:t,preferredOptions:s,requiredOptions:a,excludedOptions:r,includedOptions:n,onPreferredChange:l,onRequiredChange:o,onExcludedChange:d,onIncludedChange:c,options:m}=e,[h,p]=(0,u.useState)(a),[x,g]=(0,u.useState)(r),[f,b]=(0,u.useState)(s),[v,y]=(0,u.useState)(n),[j,w]=(0,u.useState)(!1),{mode:N}=sF(),k=e=>e.filter(e=>m.some(t=>t.value===e));(0,u.useEffect)(()=>{p(k(a)),g(k(r)),b(k(s)),y(k(n))},[a,r,s,n]);let S=(0,lW.FR)((0,lW.MS)(lW.AN),(0,lW.MS)(lW.IG,{activationConstraint:{delay:150,tolerance:8}}));return(0,u.useEffect)(()=>{function e(e){j&&e.preventDefault()}function t(){w(!1)}return j?(document.body.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("pointerup",t),document.addEventListener("touchend",t)):document.body.removeEventListener("touchmove",e),()=>{document.body.removeEventListener("touchmove",e),document.removeEventListener("pointerup",t),document.removeEventListener("touchend",t)}},[j]),(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsx)(mK,{title:`${t} Selection`,description:`Configure required, excluded, and preferred ${t.toLowerCase()}`,children:(0,i.jsxs)("div",{className:"space-y-4",children:["pro"===N&&(0,i.jsx)(li,{label:`Required ${t}`,help:`Any stream that is not one of the required ${t.toLowerCase()} will be excluded.`,value:h,onValueChange:e=>{p(e),o(e)},options:m.map(e=>({value:e.value,label:e.name,textValue:e.name})),multiple:!0,emptyMessage:`No ${t.toLowerCase()} available`,placeholder:`Select required ${t.toLowerCase()}...`}),(0,i.jsx)("div",{children:(0,i.jsx)(li,{label:`Excluded ${t}`,value:x,help:`Any stream that is one of the excluded ${t.toLowerCase()} will be excluded.`,onValueChange:e=>{g(e),d(e)},options:m.map(e=>({value:e.value,label:e.name,textValue:e.name})),multiple:!0,emptyMessage:`No ${t.toLowerCase()} available`,placeholder:`Select excluded ${t.toLowerCase()}...`})}),"pro"===N&&(0,i.jsx)("div",{children:(0,i.jsx)(li,{label:`Included ${t}`,value:v,help:`Included ${t.toLowerCase()} will be included regardless of ANY other exclude/required filters, not just for ${t.toLowerCase()}`,onValueChange:e=>{y(e),c(e)},options:m.map(e=>({value:e.value,label:e.name,textValue:e.name})),multiple:!0,emptyMessage:`No ${t.toLowerCase()} available`,placeholder:`Select included ${t.toLowerCase()}...`})}),(0,i.jsx)("div",{children:(0,i.jsx)(li,{label:`Preferred ${t}`,help:`Set preferred ${t.toLowerCase()} and control its order below. This is used if the relevant sort criterion is enabled in the Sorting section.`,value:f,onValueChange:e=>{b(e),l(e)},options:m.map(e=>({value:e.value,label:e.name,textValue:e.name})),multiple:!0,emptyMessage:`No ${t.toLowerCase()} available`,placeholder:`Select preferred ${t.toLowerCase()}...`})})]})}),f.length>0&&(0,i.jsx)(mK,{title:"Preference Order",description:`Drag to reorder your preferred ${t.toLowerCase()}`,children:(0,i.jsx)(lW.Mp,{modifiers:[lY.FN],onDragEnd:function(e){let{active:t,over:s}=e;
43if(s){if(t.id!==s.id){let e=f.indexOf(t.id),a=f.indexOf(s.id),r=(0,lG.be)(f,e,a);b(r),l(r)}w(!1)}},onDragStart:function(e){w(!0)},sensors:S,children:(0,i.jsx)(lG.gB,{items:f,strategy:lG._G,children:(0,i.jsx)("div",{className:"space-y-2",children:f.map(e=>{var t;return(0,i.jsx)(xL,{id:e,name:(null==(t=m.find(t=>t.value===e))?void 0:t.name)||e,onDelete:()=>{let t=f.filter(t=>t!==e);b(t),l(t)}},e)})})})})})]})}function xL(e){let{id:t,name:s,onDelete:a}=e,{attributes:r,listeners:n,setNodeRef:l,transform:o,transition:d,isDragging:c}=(0,lG.gl)({id:t}),u={transform:lJ.Ks.Transform.toString(o),transition:d,opacity:c?.5:1};return(0,i.jsx)("div",{ref:l,style:u,children:(0,i.jsxs)("div",{className:"px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 relative",children:[(0,i.jsx)("div",{className:"rounded-full w-6 h-auto bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move",...r,...n}),(0,i.jsx)("div",{className:"flex-1 flex flex-col justify-center min-w-0",children:(0,i.jsx)("span",{className:"font-mono text-base truncate",children:s})}),(0,i.jsx)("div",{className:"flex-shrink-0 ml-auto",children:(0,i.jsx)(w,{size:"sm",rounded:!0,icon:(0,i.jsx)(lZ.H8h,{}),intent:"alert-subtle",onClick:e=>{e.preventDefault(),e.stopPropagation(),a()}})})]})})}function xO(e){let{open:t,onOpenChange:s,onImport:a}=e,[r,n]=(0,u.useState)(!1),l=(0,u.useRef)(null),o=so(!1),[d,c]=(0,u.useState)(""),h=async()=>{if(!d)return void m.oR.error("Please enter a URL");n(!0);try{let e=await fetch(d);if(!e.ok)throw Error("Failed to fetch URL");let t=await e.json();a(t),o.close(),s(!1)}catch(e){console.error("Error importing from URL:",e),m.oR.error("Failed to import from URL")}finally{n(!1)}};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Import",children:(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsx)("input",{type:"file",ref:l,onChange:e=>{var t;let r=null==(t=e.target.files)?void 0:t[0];if(!r)return;let n=new FileReader;n.onload=e=>{try{var t;let r=null==(t=e.target)?void 0:t.result,n=JSON.parse(r);a(n),s(!1)}catch(e){console.error("Error importing file:",e),m.oR.error("Failed to parse JSON file")}},n.readAsText(r),l.current&&(l.current.value="")},accept:".json",className:"hidden"}),(0,i.jsx)(v,{intent:"primary",onClick:()=>{var e;return null==(e=l.current)?void 0:e.click()},className:"w-full",children:"Import from File"}),(0,i.jsx)(v,{intent:"primary",onClick:o.open,className:"w-full",children:"Import from URL"})]})})}),(0,i.jsx)(sl,{open:o.isOpen,onOpenChange:o.close,title:"Import from URL",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(K,{label:"URL",value:d,onValueChange:c,placeholder:"Enter URL to JSON file"}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"primary-outline",onClick:o.close,children:"Cancel"}),(0,i.jsx)(v,{intent:"primary",onClick:h,loading:r,children:"Import"})]})]})})]})}function xU(e,t){return e.length===t.length&&e.every((e,s)=>e===t[s])}function xF(e){let{renderType:t,syncMode:s,syncedValues:a,isLoading:r,fetchError:n}=e,{userData:l,setUserData:o}=ri(),{isOpen:d,open:c,close:h}=so(!1),[p,g]=(0,u.useState)(null),[f,b]=(0,u.useState)(null),y="sel"===s,j=y?"selOverrides":"regexOverrides",N=y?"Expression":"Pattern";return r?(0,i.jsxs)("div",{className:"px-3 pb-2 text-xs text-[--muted] animate-pulse",children:["Loading ",N.toLowerCase(),"s..."]}):n&&0===a.length?(0,i.jsx)("div",{className:"px-3 pb-3",children:(0,i.jsxs)("div",{className:"rounded border border-red-400/30 bg-red-500/5 p-2 text-xs text-red-300",children:[(0,i.jsx)("span",{className:"font-medium",children:"Error: "}),n]})}):0===a.length?null:(0,i.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[n&&(0,i.jsxs)("div",{className:"rounded border border-yellow-400/30 bg-yellow-500/5 p-2 text-xs text-yellow-400",children:[(0,i.jsx)("span",{className:"font-medium",children:"Warning: "}),n]}),a.map((e,s)=>{let a=e.pattern??e.expression??"",r=l[j]||[],n=y?function(e){let t,s=!(arguments.length>1)||void 0===arguments[1]||arguments[1],a=/\/\*\s*(.*?)\s*\*\//g,r=[];for(;null!==(t=a.exec(e));){let e=t[1];e.startsWith("#")?s||r.push(e.slice(1).trim()):r.push(e)}return r.length>0?r:void 0}(a,!1):void 0,d=t=>y?t.expression===a||!!t.exprNames&&!!n&&xU(t.exprNames,n):t.pattern===a||e.name&&t.originalName===e.name,u=r.find(d),h=u?u.disabled:!1===e.enabled,p=y?(null==n?void 0:n.join(", "))??"":(null==u?void 0:u.name)??e.name??"",f=y?!!u&&!u.disabled&&void 0!==u.score:!!u&&!u.disabled,v=(null==u?void 0:u.score)!==void 0?u.score:e.score??0,k=t=>{o(s=>{let r=[...s[j]||[]];if(t){let t=r.findIndex(d);if(t>=0){let a=r[t],n=void 0!==a.score&&a.score!==e.score;return!y&&void 0!==a.name&&a.name!==e.name||n?r[t]={...a,disabled:!1}:!1===e.enabled?r[t]={...a,disabled:!1}:r.splice(t,1),{...s,[j]:r}}if(!1===e.enabled){let t=y?{expression:a,exprNames:n,disabled:!1}:{pattern:a,originalName:e.name,disabled:!1};return r.push(t),{...s,[j]:r}}return s}let l=r.findIndex(d),i=l>=0?r[l]:null,o=y?{expression:a,score:null==i?void 0:i.score,exprNames:n,disabled:!0}:{pattern:a,name:null==i?void 0:i.name,score:null==i?void 0:i.score,originalName:e.name,disabled:!0};return l>=0?r[l]=o:r.push(o),{...s,[j]:r}}),m.oR.success(t?`${N} enabled`:`${N} disabled`)},S=()=>{o(e=>({...e,[j]:(e[j]||[]).filter(e=>!d(e))})),m.oR.info("Override removed")};return(0,i.jsxs)("div",{className:x("p-2 rounded border",h?"opacity-50 border-gray-700/50 bg-gray-900/30":"border-gray-700 bg-gray-900/60",f&&!h&&"border-primary/40"),children:["simple"===t&&(0,i.jsxs)("div",{className:"relative flex gap-2 items-start pl-[calc(24px+0.5rem)]",children:[(0,i.jsx)("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 min-w-[24px] flex justify-center",children:(0,i.jsx)(lt,{value:!h,size:"lg",onValueChange:e=>k(!0===e)})}),(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(K,{value:a,label:`${N} (Synced)`,disabled:!0,size:"sm"})})]}),"nameable"===t&&(0,i.jsxs)("div",{className:"relative flex gap-2 items-start pl-[calc(24px+0.5rem)]",children:[(0,i.jsx)("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 min-w-[24px] flex justify-center",children:(0,i.jsx)(lt,{value:!h,size:"lg",onValueChange:e=>k(!0===e)})}),(0,i.jsx)("div",{className:"flex-none w-1/3",children:(0,i.jsx)(K,{value:p,label:!y&&f?"Name (Overridden)":"Name (Synced)",disabled:!0,size:"sm",className:x(h&&"line-through text-gray-500")})}),(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(K,{value:a,label:`${N} (Synced)`,disabled:!0,size:"sm",className:x(h&&"line-through text-gray-500")})}),(0,i.jsxs)("div",{className:"pb-0.5 flex gap-1 flex-shrink-0 self-end",children:[f&&(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,icon:(0,i.jsx)(lZ.EEI,{className:"text-xs"}),intent:"alert-subtle",onClick:S,className:"h-[38px] w-[38px] border border-red-400/20 hover:border-red-400/50 transition-colors shadow-sm"}),children:"Reset Override"}),!y&&(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,icon:(0,i.jsx)(lZ.uO9,{className:"text-xs"}),intent:f?"primary":"primary-subtle",onClick:()=>{g({pattern:a,name:(null==u?void 0:u.name)??e.name??"",originalName:e.name}),c()},className:"h-[38px] w-[38px] border border-primary/20 hover:border-primary/50 transition-colors shadow-sm"}),children:"Override"})]})]}),"ranked"===t&&(0,i.jsxs)("div",{className:"relative",children:[(0,i.jsx)("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 min-w-[24px] flex justify-center",children:(0,i.jsx)(lt,{value:!h,size:"lg",onValueChange:e=>k(!0===e)})}),(0,i.jsxs)("div",{className:"flex gap-2 items-start pl-[calc(24px+0.5rem)]",children:[(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(K,{value:a,label:`${N} (Synced)`,disabled:!0,size:"sm",className:x(h&&"line-through text-gray-500")})}),(0,i.jsxs)("div",{className:"pb-0.5 flex gap-1 flex-shrink-0 self-end",children:[f&&(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{rounded:!0,size:"sm",icon:(0,i.jsx)(lZ.EEI,{className:"text-xs"}),intent:"alert-subtle",onClick:S}),children:"Reset Override"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,icon:(0,i.jsx)(lZ.uO9,{className:"text-xs"}),intent:f?"primary":"primary-subtle",onClick:()=>{y?b({expression:a,score:v,exprNames:n}):g({pattern:a,name:(null==u?void 0:u.name)??e.name??"",score:v,originalName:e.name}),c()}}),children:"Override"})]})]}),(0,i.jsxs)("div",{className:"flex gap-2 pl-[calc(24px+0.5rem)] mt-2",children:[(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(K,{value:p,label:`Name${n&&n.length>
431?"s":""} (Synced)`,disabled:!0,size:"sm",className:x(h&&"line-through text-gray-500")})}),(0,i.jsx)("div",{className:"w-24",children:(0,i.jsx)(lm,{value:v,label:f?"Score (Ovr)":"Score",disabled:!0,size:"sm"})})]})]})]},s)}),(0,i.jsx)(sl,{open:d&&null!==p,onOpenChange:e=>{e||(g(null),h())},title:"Override",children:(0,i.jsxs)("div",{className:"space-y-4 py-2",children:[(0,i.jsxs)("p",{className:"text-xs text-[--muted] break-all",children:[N,":"," ",(0,i.jsx)("code",{className:"text-[--primary]",children:null==p?void 0:p.pattern})]}),("nameable"===t||"ranked"===t)&&(0,i.jsx)(K,{label:"Custom Name",value:(null==p?void 0:p.name)||"",onValueChange:e=>g(t=>t?{...t,name:e}:null)}),"ranked"===t&&(0,i.jsx)(lm,{label:"Custom Score",value:(null==p?void 0:p.score)||0,min:-1e6,max:1e6,step:50,onValueChange:e=>g(t=>t?{...t,score:e}:null)}),(0,i.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,i.jsx)(v,{intent:"primary-outline",onClick:()=>{g(null),h()},children:"Cancel"}),(0,i.jsx)(v,{onClick:()=>{p&&(o(e=>{let t=[...e[j]||[]],s=t.findIndex(e=>e.pattern===p.pattern||p.originalName&&e.originalName===p.originalName),a=s>=0?t[s]:void 0,r={pattern:p.pattern,name:p.name||void 0,score:p.score||0,originalName:p.originalName,disabled:p.disabled??(null==a?void 0:a.disabled)};return s>=0?t[s]=r:t.push(r),{...e,[j]:t}}),g(null),h(),m.oR.success("Override saved"))},children:"Save Override"})]})]})}),(0,i.jsx)(sl,{open:d&&null!==f,onOpenChange:e=>{e||(b(null),h())},title:"Score Override",children:(0,i.jsxs)("div",{className:"space-y-4 py-2",children:[(0,i.jsxs)("p",{className:"text-xs text-[--muted] break-all",children:["Expression:"," ",(0,i.jsx)("code",{className:"text-[--primary]",children:null==f?void 0:f.expression})]}),(0,i.jsx)(lm,{label:"Custom Score",value:(null==f?void 0:f.score)||0,min:-1e6,max:1e6,step:50,onValueChange:e=>b(t=>t?{...t,score:e}:null)}),(0,i.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,i.jsx)(v,{intent:"primary-outline",onClick:()=>{b(null),h()},children:"Cancel"}),(0,i.jsx)(v,{onClick:()=>{f&&(o(e=>{let t=[...e[j]||[]],s=t.findIndex(e=>e.expression===f.expression||!!e.exprNames&&!!f.exprNames&&xU(e.exprNames,f.exprNames)),a=s>=0?t[s]:void 0,r={expression:f.expression,score:f.score||0,exprNames:f.exprNames,disabled:f.disabled??(null==a?void 0:a.disabled)};return s>=0?t[s]=r:t.push(r),{...e,[j]:t}}),b(null),h(),m.oR.success("Score override saved"))},children:"Save Override"})]})]})})]})}function xz(e){var t;let{syncConfig:s,renderType:a="simple"}=e,{status:r}=tj(),{userData:n,password:l}=ri(),[o,d]=(0,u.useState)(""),[c,h]=(0,u.useState)({}),p=(null==s?void 0:s.syncMode)??"regex",x="sel"===p?"expressions":"patterns";if((0,u.useEffect)(()=>{if(!s)return;let{urls:e}=s;if(0===e.length)return;let t=new AbortController,a=n.uuid?{uuid:n.uuid,password:l}:void 0;for(let s of(h(t=>{let s={...t};for(let r of e){var a;s[r]={values:(null==(a=t[r])?void 0:a.values)??[],isLoading:!0,error:null}}return s}),e))("sel"===p?eT([s],a).then(e=>{var t;let a=null==(t=e.errors)?void 0:t.find(e=>e.url===s);return{values:(e.expressions||[]).map(e=>({expression:e.expression,pattern:e.expression,name:e.name,score:e.score,enabled:e.enabled})),error:(null==a?void 0:a.error)??null}}):eR([s],a).then(e=>{var t;let a=null==(t=e.errors)?void 0:t.find(e=>e.url===s);return{values:(e.patterns||[]).map(e=>({pattern:e.pattern,name:e.name,score:e.score})),error:(null==a?void 0:a.error)??null}})).then(e=>{let{values:a,error:r}=e;t.signal.aborted||h(e=>({...e,[s]:{values:a,isLoading:!1,error:r}}))}).catch(e=>{t.signal.aborted||h(t=>({...t,[s]:{values:[],isLoading:!1,error:e instanceof Error?e.message:"Failed to fetch from URL"}}))});return()=>t.abort()},[null==s||null==(t=s.urls)?void 0:t.join(","),n.uuid,l,p]),!s)return null;let{urls:g,onUrlsChange:f,trusted:b}=s,v=e=>{for(let a of g.filter(t=>!e.includes(t))){var t;null==(t=s.onRemovePlaceholder)||t.call(s,a)}f(e)},y=()=>{(e=>{var t,s,a,n,l,i;let o=(null==r||null==(s=r.settings)||null==(t=s.regexAccess)?void 0:t.urls)||[];if(!e)return!1;try{new URL(e)}catch{return m.oR.error("Invalid URL format"),!1}if(g.includes(e))return m.oR.error("URL is already added"),!1;if("sel"===p){let t=(null==r||null==(n=r.settings)||null==(a=n.selSyncAccess)?void 0:a.level)??"all";return!!("all"===t||"trusted"===t&&b)||!!((null==r||null==(i=r.settings)||null==(l=i.selSyncAccess)?void 0:l.trustedUrls)||[]).includes(e)||(m.oR.error("This URL is not in the allowed list. Contact the instance owner to whitelist it."),!1)}return!!((null==r?void 0:r.settings.regexAccess.level)==="all"||(null==r?void 0:r.settings.regexAccess.level)==="trusted"&&b)||!!o.includes(e)||(m.oR.error("URL is not in the allowed list"),!1)})(o)&&(v([...g,o]),d(""))};return(0,i.jsxs)("div",{className:"mt-4 border-t border-gray-800 pt-4 space-y-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("h5",{className:"text-sm font-medium",children:["Synced URLs",g.length>0&&(0,i.jsxs)("span",{className:"ml-1.5 text-xs text-[--muted] font-normal",children:["(",g.length,")"]})]}),(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["Automatically fetch and sync ",x," from URLs"]})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[g.length>0&&(0,i.jsx)("div",{className:"rounded-md border border-[--brand]/20 bg-[--brand]/5 divi
43de-y divide-[--brand]/10",children:g.map(e=>{var t,r;let n=c[e];return(0,i.jsx)("div",{"data-synced-url":e,children:(0,i.jsx)(tQ,{type:"single",collapsible:!0,children:(0,i.jsxs)(tX,{value:"items",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 p-2 px-3 text-sm",children:[(0,i.jsx)(t0,{children:(0,i.jsx)("button",{type:"button",className:"group flex items-center",children:(0,i.jsx)(lZ.Vr3,{className:"text-[10px] text-[--muted] transition-transform duration-200 group-data-[state=open]:rotate-180"})})}),(0,i.jsx)("span",{className:"flex-1 break-all font-mono text-xs text-[--muted]",children:e}),s.onInsertPlaceholder&&(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,icon:(0,i.jsx)(lZ.jHd,{}),intent:(null==(t=s.hasPlaceholder)?void 0:t.call(s,e))?"primary":"primary-subtle",onClick:()=>{var t,a;(null==(t=s.hasPlaceholder)?void 0:t.call(s,e))?null==(a=s.onRemovePlaceholder)||a.call(s,e):s.onInsertPlaceholder(e)}}),children:(null==(r=s.hasPlaceholder)?void 0:r.call(s,e))?"Remove from inline":"Place inline"}),(0,i.jsx)(w,{size:"sm",rounded:!0,icon:(0,i.jsx)(lZ.H8h,{}),intent:"alert-subtle",onClick:()=>v(g.filter(t=>t!==e))})]}),(0,i.jsx)(t1,{children:(0,i.jsx)(xF,{renderType:a,syncMode:p,syncedValues:(null==n?void 0:n.values)??[],isLoading:(null==n?void 0:n.isLoading)??!0,fetchError:(null==n?void 0:n.error)??null})})]})})},e)})}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(K,{value:o,placeholder:`https://example.com/${x}.json`,onValueChange:d,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),y())}})}),(0,i.jsx)(w,{onClick:y,disabled:!o,icon:(0,i.jsx)(lZ.OiG,{}),rounded:!0,intent:"primary-subtle"})]})]})]})}x$.displayName="Slider";let xV="md:flex-1 md:min-w-[100px]";function xq(e){return e.charAt(0).toLowerCase()+e.slice(1).replace(/\s+/g,"")}function xB(e){let{rows:t,index:s,url:a,iconPosition:r}=e,n=(0,u.useCallback)(e=>{let t=(e.currentTarget.closest("[data-settings-card]")??document).querySelector(`[data-synced-url="${window.CSS.escape(a)}"]`);t&&(t.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>{let e=t.querySelector("[data-radix-collection-item]");(null==e?void 0:e.dataset.state)!=="open"&&(null==e||e.click())},400))},[a]),l=(0,i.jsx)(t5,{trigger:(0,i.jsx)("button",{type:"button","aria-label":"Jump to synced URL",onClick:n,className:"h-6 w-6 flex items-center justify-center cursor-pointer hover:opacity-80 transition-opacity shrink-0",children:(0,i.jsx)(lZ.AnD,{className:"text-[--brand] text-base"})}),children:"Jump to synced URL"});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:lQ,children:["inside"!==r&&(0,i.jsx)("div",{className:lX,children:l}),(0,i.jsx)("div",{className:l0,children:(0,i.jsx)(l5,{rows:t,index:s})})]}),(0,i.jsxs)("div",{className:"md:flex-1 min-w-0 flex items-center gap-2 rounded-[--radius] bg-[--paper] border border-[--border] shadow-sm h-10 px-3 opacity-75 overflow-hidden",children:["inside"===r&&l,(0,i.jsx)("span",{className:"text-sm text-[--muted] font-mono truncate min-w-0 flex-1",children:a})]})]})}function xK(e,t,s,a,r){return t.map((t,n)=>{let l=e.keyAt(n),o=(null==r?void 0:r.syncEnabled)?function(e){if(!e.startsWith("<SYNCED: ")||!e.endsWith(">"))return null;let t=e.slice(9,-1).trim();return t.length>0?t:null}(s(t)):null;return(0,i.jsx)(l3,{id:l,children:o?(0,i.jsx)(xB,{rows:e,index:n,url:o,iconPosition:null==r?void 0:r.iconPosition}):a(t,n)},l)})}function xH(e,t,s){let a=so(!1);return{modal:a,handleImport:(0,u.useCallback)(e=>{t(e)||m.oR.error("Invalid import format")},[t]),handleExport:(0,u.useCallback)(()=>{var t,a;let r,n,l,i,o,d,c,u,m,h;t=e(),n=(r=new Date).getFullYear(),l=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0"),o=String(r.getHours()).padStart(2,"0"),d=String(r.getMinutes()).padStart(2,"0"),c=`${n}-${l}-${i}.${o}-${d}`,a=`${s.toLowerCase().replace(/\s+/g,"-")}-${c}.json`,u=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),m=URL.createObjectURL(u),(h=document.createElement("a")).href=m,h.download=a,document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(m)},[e,s])}}function xW(e){let{onAdd:t,onImportClick:s,onExport:a,children:r}=e;return(0,i.jsxs)("div",{className:"mt-2 flex gap-2 items-center",children:[(0,i.jsx)(w,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(lZ.OiG,{}),onClick:t}),r,(0,i.jsxs)("div",{className:"ml-auto flex gap-2",children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(lZ.PiR,{}),onClick:s}),children:"Import"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(lZ.Mbn,{}),onClick:a}),children:"Export"})]})]})}function xG(e){let{fieldName:t,itemName:s,label:a,help:r,values:n,onValuesChange:l,placeholder:o,syncConfig:d,disabled:c}=e,m=(0,u.useRef)(n);m.current=n;let h=l1(n,l),{modal:p,handleImport:x,handleExport:g}=xH((0,u.useCallback)(()=>({values:m.current}),[]),(0,u.useCallback)(e=>!!Array.isArray(e.values)&&(l(e.values),!0),[l]),a),f=(0,u.useCallback)((e,t)=>{let s=m.current;l([...s.slice(0,t),e,...s.slice(t+1)])},[l]);return(0,i.jsxs)(mK,{id:t??xq(a),title:a,description:r,children:[(0,i.jsx)(l2,{rows:h,children:xK(h,n,e=>e,(e,t)=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:l0,children:(0,i.jsx)(l5,{rows:h,index:t})}),(0,i.jsx)("div",{className:"md:flex-1",children:(0,i.jsx)(K,{value:e,"aria-label":s,placeholder:o??s,onValueChange:e=>f(e,t)})})]}),{syncEnabled:!!d,iconPosition:"inside"})}),(0,i.jsx)(xW,{onAdd:()=>l([...n,""]),onImportClick:p.open,onExport:g}),(0,i.jsx)(xO,{open:p.isOpen,onOpenChange:p.toggle,onImport:x}),d&&(0,i.jsx)(xz,{syncConfig:d,renderType:"simple"})]},a)}function xY(e){let{title:t,fieldName:s,description:a,values:r,onValuesChange:n,onExpressionChange:l,onEnabledChange:o,placeholder:d,syncConfig:c}=e,m=(0,u.useRef)(r);m.current=r;let h=l1(r,n),{modal:p,handleImport:x,handleExport:g}=xH((0,u.useCallback)(()=>m.current.map(e=>({expression:e.expression,enabled:e.enabled})),[]),(0,u.useCallback)(e=>Array.isArray(e)&&e.every(e=>"string"==typeof e.expression)?(n(e.map(e=>({expression:e.expression,enabled:e.enabled??!0}))),!0):!!Array.isArray(null==e?void 0:e.values)&&(n(e.values.map(e=>({expression:e,enabled:!0}))),!0),[n]),t);return(0,i.jsxs)(mK,{id:s??xq(t),title:t,description:a,children:[(0,i.jsx)(l2,{rows:h,children:xK(h,r,e=>e.expression,(e,t)=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:lQ,children:[(0,i.jsx)("div",{className:lX,children:(0,i.jsx)(lt,{value:e.enabled??!0,defaultValue:!0,size:"lg","aria-label":"Enabled",onValueChange:e=>{o&&o(!0===e,t)}})}),(0,i.jsx)("div",{className:l0,children:(0,i.jsx)(l5,{rows:h,index:t})})]}),(0,i.jsx)("div",{className:"md:flex-1",children:(0,i.jsx)(K,{value:e.expression,"aria-label":"Expression",placeholder:d,disabled:!1===e.enabled,onValueChange:e=>l(e,t)})})]}),{syncEnabled:!!c})}),(0,i.jsx)(xW,{onAdd:()=>n([...r,{expression:"",enabled:!0}]),onImportClick:p.open,onExport:g}),(0,i.jsx)(xO,{open:p.isOpen,onOpenChange:p.toggle,onImport:x}),c&&(0,i.jsx)(xz,{syncConfig:c,renderType:"nameable"})]})}function xJ(e){let{title:t,description:s,keyName:a,keyId:r,keyPlaceholder:n,valueId:l,valueName:o,valuePlaceholder:d,values:c,onValuesChange:m,onValueChange:h,onKeyChange:p,disabled:x,syncConfig:g}=e,f=(0,u.useRef)(c);f.current=c;let b=l1(c,m),{modal:v,handleImport:y,handleExport:j}=xH((0,u.useCallback)(()=>f.current.map(e=>({[r]:e.name,[l]:e.value})),[r,l]),(0,u.useCallback)(e=>!!(Array.isArray(e)&&e.every(e=>"string"==typeof e[r]&&"string"==typeof e[l]))&&(m(e.map(e=>({name:e[r],value:e[l]}
43))),!0),[m,r,l]),t);return(0,i.jsxs)(mK,{title:t,description:s,children:[(0,i.jsx)(l2,{rows:b,children:xK(b,c,e=>e.value,(e,t)=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:l0,children:(0,i.jsx)(l5,{rows:b,index:t})}),(0,i.jsx)("div",{className:"md:flex-1",children:(0,i.jsx)(K,{value:e.name,"aria-label":a,placeholder:n,onValueChange:e=>p(e,t)})}),(0,i.jsx)("div",{className:"md:flex-1",children:(0,i.jsx)(K,{value:e.value,"aria-label":o,placeholder:d,onValueChange:e=>h(e,t)})})]}),{syncEnabled:!!g,iconPosition:"inside"})}),(0,i.jsx)(xW,{onAdd:()=>m([...c,{name:"",value:""}]),onImportClick:v.open,onExport:j}),(0,i.jsx)(xO,{open:v.isOpen,onOpenChange:v.toggle,onImport:y}),g&&(0,i.jsx)(xz,{syncConfig:g,renderType:"nameable"})]})}function xZ(e){let{title:t,fieldName:s,description:a,values:r,onValuesChange:n,onExpressionChange:l,onScoreChange:o,onEnabledChange:d,syncConfig:c}=e,m=(0,u.useRef)(r);m.current=r;let h=l1(r,n),{modal:p,handleImport:x,handleExport:g}=xH((0,u.useCallback)(()=>m.current.map(e=>({expression:e.expression,score:e.score,enabled:e.enabled})),[]),(0,u.useCallback)(e=>!!(Array.isArray(e)&&e.every(e=>"string"==typeof e.expression&&"number"==typeof e.score))&&(n(e.map(e=>({expression:e.expression,score:e.score,enabled:e.enabled??!0}))),!0),[n]),t);return(0,i.jsxs)(mK,{id:s??xq(t),title:t,description:a,children:[(0,i.jsx)(l2,{rows:h,children:xK(h,r,e=>e.expression,(e,t)=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:lQ,children:[(0,i.jsx)("div",{className:lX,children:(0,i.jsx)(lt,{value:e.enabled??!0,defaultValue:!0,size:"lg","aria-label":"Enabled",onValueChange:e=>{d&&d(!0===e,t)}})}),(0,i.jsx)("div",{className:l0,children:(0,i.jsx)(l5,{rows:h,index:t})})]}),(0,i.jsx)("div",{className:"md:flex-[3]",children:(0,i.jsx)(K,{value:e.expression,"aria-label":"Expression",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",disabled:!1===e.enabled,onValueChange:e=>l(e,t)})}),(0,i.jsx)("div",{className:xV,children:(0,i.jsx)(lm,{value:e.score||0,defaultValue:0,"aria-label":"Score",disabled:!1===e.enabled,onValueChange:e=>o(e||0,t),min:-1e6,max:1e6,step:50})})]}),{syncEnabled:!!c})}),(0,i.jsx)(xW,{onAdd:()=>n([...r,{expression:"",score:0,enabled:!0}]),onImportClick:p.open,onExport:g}),(0,i.jsx)(xO,{open:p.isOpen,onOpenChange:p.toggle,onImport:x}),c&&(0,i.jsx)(xz,{syncConfig:c,renderType:"ranked"})]})}function xQ(e){let{title:t,description:s,values:a,onValuesChange:r,onPatternChange:n,onNameChange:l,onScoreChange:o,syncConfig:d}=e,c=(0,u.useRef)(a);c.current=a;let m=l1(a,r),{modal:h,handleImport:p,handleExport:x}=xH((0,u.useCallback)(()=>c.current.map(e=>({pattern:e.pattern,name:e.name,score:e.score})),[]),(0,u.useCallback)(e=>!!(Array.isArray(e)&&e.every(e=>"string"==typeof e.pattern&&"number"==typeof e.score))&&(r(e.map(e=>({pattern:e.pattern,name:e.name,score:e.score}))),!0),[r]),t);return(0,i.jsxs)(mK,{title:t,description:s,children:[(0,i.jsx)(l2,{rows:m,children:xK(m,a,e=>e.pattern,(e,t)=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:l0,children:(0,i.jsx)(l5,{rows:m,index:t})}),(0,i.jsx)("div",{className:"md:flex-[3]",children:(0,i.jsx)(K,{value:e.pattern,"aria-label":"Pattern",placeholder:"Regex Pattern",onValueChange:e=>n(e,t)})}),(0,i.jsx)("div",{className:"md:flex-[2]",children:(0,i.jsx)(K,{value:e.name||"","aria-label":"Name",placeholder:"Name (Optional)",onValueChange:e=>l(e,t)})}),(0,i.jsx)("div",{className:xV,children:(0,i.jsx)(lm,{value:e.score,"aria-label":"Score",onValueChange:e=>o(e??0,t),min:-1e6,max:1e6,step:50})})]}),{syncEnabled:!!d,iconPosition:"inside"})}),(0,i.jsx)(xW,{onAdd:()=>r([...a,{pattern:"",name:"",score:0}]),onImportClick:h.open,onExport:x}),(0,i.jsx)(xO,{open:h.isOpen,onOpenChange:h.toggle,onImport:p}),d&&(0,i.jsx)(xz,{syncConfig:d,renderType:"ranked"})]})}let xX=[{key:"movies",heading:"Movies"},{key:"series",heading:"Series"},{key:"anime",heading:"Anime Series"}];function x0(e){let{label:t,help:s,moviesValue:a,seriesValue:r,animeValue:n,onMoviesChange:l,onSeriesChange:o,onAnimeChange:d,min:c,max:u,formatValue:m,kind:h}=e,p={movies:a,series:r,anime:n},x={movies:l,series:o,anime:d};return(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsx)("h4",{className:"text-base font-medium",children:t}),xX.map(e=>{let{key:t,heading:a}=e,r=p[t],n=x[t];return(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("h5",{className:"text-sm font-medium text-[--muted]",children:a}),(0,i.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)(x$,{min:c,max:u,defaultValue:[c,u],step:u/1e3,value:r,onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&n([e[0],e[1]]),minStepsBetweenThumbs:1,label:`${a} ${h} Range`,help:s}),(0,i.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,i.jsx)("span",{children:m(r[0])}),(0,i.jsx)("span",{children:m(r[1])})]})]}),(0,i.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,i.jsx)(lm,{label:"Min",step:u/1e3,value:r[0],min:c,max:r[1],onValueChange:e=>void 0!==e&&n([e,r[1]])}),(0,i.jsx)(lm,{label:"Max",step:u/1e3,value:r[1],min:r[0],max:u,onValueChange:e=>void 0!==e&&n([r[0],e])})]})]})]},t)})]})}function x1(e){let{min:t=0,max:s=1e11,...a}=e;return(0,i.jsx)(x0,{min:t,max:s,formatValue:ny,kind:"Size",...a})}function x2(e){let{min:t=0,max:s=25e7,...a}=e;return(0,i.jsx)(x0,{min:t,max:s,formatValue:nw,kind:"Bitrate",...a})}let x3=["2160p","1440p","1080p","720p","576p","480p","360p","240p","144p","Unknown"],x5=["BluRay REMUX","BluRay","WEB-DL","WEBRip","HDRip","HC HD-Rip","DVD REMUX","DVDRip","HDTV","CAM","TS","TC","SCR","Unknown"],x4=[],x6=[],x9=[],x8=[],x7=x("w-full grid grid-cols-1 lg:grid lg:grid-cols-[300px,1fr] gap-4"),ge=x("font-bold text-base px-6 rounded-[--radius-md] w-fit lg:w-full border-none data-[state=active]:bg-[--subtle] data-[state=active]:text-white dark:hover:text-white","h-9 lg:justify-start px-3 transition-all duration-200 hover:bg-[--subtle]/50 hover:transform"),gt=x("w-full flex flex-wrap lg:flex-nowrap h-fit xl:h-10","lg:block p-2 lg:p-0"),gs=x("contents lg:block border-0 bg-transparent lg:border lg:bg-[--paper] overflow-clip p-1"),ga=x("space-y-4 animate-in fade-in-0 slide-in-from-right-2 duration-300");function gr(e){if(e<24)return`${e}h`;let t=Math.floor(e/24);return`${t}d`}function gn(e){let{heading:t}=e;return(0,i.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4 mb-4",children:[(0,i.jsx)("h3",{children:t}),(0,i.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,i.jsx)(mg,{})})]})}let gl={conservative:"Removes duplicates conservatively - removes uncached versions which have cached versions from the same service, and removes P2P versions when cached versions exist",aggressive:"Aggressively removes all uncached and p2p streams when cached versions exist, and removes uncached streams when p2p versions exist",keep_all:"Keeps all streams and processes each group independently"},gi="aggressive";function go(e){return`<SYNCED: ${e}>`}
43let gd={syncedPreferredRegexUrls:"preferredRegexPatterns",syncedExcludedRegexUrls:"excludedRegexPatterns",syncedIncludedRegexUrls:"includedRegexPatterns",syncedRequiredRegexUrls:"requiredRegexPatterns",syncedRankedRegexUrls:"rankedRegexPatterns",syncedPreferredStreamExpressionUrls:"preferredStreamExpressions",syncedExcludedStreamExpressionUrls:"excludedStreamExpressions",syncedIncludedStreamExpressionUrls:"includedStreamExpressions",syncedRequiredStreamExpressionUrls:"requiredStreamExpressions",syncedRankedStreamExpressionUrls:"rankedStreamExpressions"};function gc(e,t){return"string"==typeof t?t:(null==t?void 0:t.pattern)!==void 0?t.pattern:(null==t?void 0:t.expression)!==void 0?t.expression:""}function gu(){return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(ng,{className:"p-4 sm:p-8 space-y-4",children:(0,i.jsx)(gm,{})})})}function gm(){var e,t,s,a,r,n,l,o,d,c,h,p,x,g,f,b,y,j,N,k,S,C,_,A,R,T,E,M,$,D,L,O,U,F,z,V,q,B,K,H,W,G,Y,Z,Q,X,ee,et,es,ea,er,en,el,ei,eo,ed,ec,eu,em,eh,ep,ex,eg,ef,eb,ev,ey,ej,ew,eN,ek,eS,eC,e_,eA,eR,eT,eI,eE,eM,eP,e$,eD,eL,eO,eU,eF,ez,eV,eq,eB,eK,eH,eW,eG,eY,eJ,eZ,eQ,eX,e0,e1,e2,e3,e5,e4,e6,e9,e8,e7,te,tt,ts,ta,tr,tn,tl,ti,to,td,tc,tu,tm,th,tp,tx,tg,tf,tb,tv,ty,tw,tN,tk,tS,tC,t_,tA,tR,tT,tI,tE,tM,tP,t$,tD,tL,tO,tU,tF,tz,tV,tq,tB,tK,tH,tW,tG,tY;let{tab:tJ,setTab:tZ}=rv("filters"),{status:tQ}=tj(),{mode:tX}=sF(),{userData:t0,setUserData:t1}=ri(),{isInherited:t2,hasParent:t3}=ro(),t5=so(!1),t4=so(!1),t6=so(!1),t9=e=>{let t=gd[e];return{syncConfig:{urls:t0[e]||[],trusted:t0.trusted,syncMode:e.includes("StreamExpression")?"sel":"regex",onUrlsChange:t=>{t1(s=>({...s,[e]:t}))},onInsertPlaceholder:t?e=>{let s=function(e,t){let s=go(t);switch(e){case"excludedRegexPatterns":case"includedRegexPatterns":case"requiredRegexPatterns":default:return s;case"preferredRegexPatterns":return{name:"",pattern:s};case"rankedRegexPatterns":return{pattern:s,name:"",score:0};case"excludedStreamExpressions":case"includedStreamExpressions":case"requiredStreamExpressions":case"preferredStreamExpressions":return{expression:s,enabled:!0};case"rankedStreamExpressions":return{expression:s,score:0,enabled:!0}}}(t,e);t1(e=>({...e,[t]:[...e[t]||[],s]}))}:void 0,onRemovePlaceholder:t?e=>{let s=go(e);t1(e=>{let a=e[t];if(!Array.isArray(a))return e;let r=a.filter(e=>gc(t,e)!==s);return r.length===a.length?e:{...e,[t]:r}})}:void 0,hasPlaceholder:t?e=>{let s=go(e),a=t0[t];return!!Array.isArray(a)&&a.some(e=>gc(t,e)===s)}:void 0}}};return(0,u.useEffect)(()=>{t0.preferredResolutions||t1(e=>({...e,preferredResolutions:x3})),t0.preferredQualities||t1(e=>({...e,preferredQualities:x5})),t0.preferredEncodes||t1(e=>({...e,preferredEncodes:x4})),t0.preferredStreamTypes||t1(e=>({...e,preferredStreamTypes:x6})),t0.preferredVisualTags||t1(e=>({...e,preferredVisualTags:x9})),t0.preferredAudioTags||t1(e=>({...e,preferredAudioTags:x8}))},[]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(nG,{value:tJ,onValueChange:e=>{tZ(e)},variant:"pill",className:x7,triggerClass:ge,listClass:gt,contentClass:ga,children:[(0,i.jsx)(nY,{className:"flex-wrap max-w-full lg:space-y-2",children:(0,i.jsxs)(mB,{children:[(0,i.jsx)("div",{className:"w-full my-2",children:(0,i.jsxs)("div",{className:"flex items-center gap-2 justify-center",children:[(0,i.jsx)("h4",{children:"Filters"}),t3&&t2("filters")&&(0,i.jsx)(my,{section:"filters"})]})}),(0,i.jsxs)("div",{className:"overflow-x-none overflow-y-scroll lg:overflow-y-hidden h-40 lg:h-auto rounded-[--radius-md] border lg:border-none lg:space-y-3 [--webkit-overflow-scrolling:touch]",children:[(0,i.jsxs)(J,{className:gs,children:[(0,i.jsxs)(nJ,{value:"cache",children:[(0,i.jsx)(lZ.lHQ,{className:"text-lg mr-3"}),"Cache"]}
43),"pro"===tX&&(0,i.jsxs)(nJ,{value:"stream-type",children:[(0,i.jsx)(m1.iDz,{className:"text-lg mr-3"}),"Stream Type"]}),(0,i.jsxs)(nJ,{value:"seeders",children:[(0,i.jsx)(m1.LTk,{className:"text-lg mr-3"}),"Seeders"]}),(0,i.jsxs)(nJ,{value:"age",children:[(0,i.jsx)(lZ.w_X,{className:"text-lg mr-3"}),"Age"]})]}),(0,i.jsxs)(J,{className:gs,children:[(0,i.jsxs)(nJ,{value:"resolution",children:[(0,i.jsx)(sm._U5,{className:"text-lg mr-3"}),"Resolution"]}),"pro"===tX&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(nJ,{value:"quality",children:[(0,i.jsx)(m1.KBW,{className:"text-lg mr-3"}),"Quality"]}),(0,i.jsxs)(nJ,{value:"encode",children:[(0,i.jsx)(lZ.UUG,{className:"text-lg mr-3"}),"Encode"]}),(0,i.jsxs)(nJ,{value:"visual-tag",children:[(0,i.jsx)(m1.Xc1,{className:"text-lg mr-3"}),"Visual Tag"]}),(0,i.jsxs)(nJ,{value:"audio-tag",children:[(0,i.jsx)(xI.YkV,{className:"text-lg mr-3"}),"Audio Tag"]}),(0,i.jsxs)(nJ,{value:"audio-channel",children:[(0,i.jsx)(m1.pCc,{className:"text-lg mr-3"}),"Audio Channel"]})]})]}),(0,i.jsxs)(J,{className:gs,children:[(0,i.jsxs)(nJ,{value:"language",children:[(0,i.jsx)(lZ.gqt,{className:"text-lg mr-3"}),"Language"]}),(0,i.jsxs)(nJ,{value:"subtitle",children:[(0,i.jsx)(m1.zZ_,{className:"text-lg mr-3"}),"Subtitle"]})]}),(0,i.jsxs)(J,{className:gs,children:[(0,i.jsxs)(nJ,{value:"size",children:[(0,i.jsx)(xE.mKD,{className:"text-lg mr-3"}),"Size"]}),(0,i.jsxs)(nJ,{value:"bitrate",children:[(0,i.jsx)(lZ.$BV,{className:"text-lg mr-3"}),"Bitrate"]})]}),"pro"===tX&&(0,i.jsx)(J,{className:gs,children:(0,i.jsxs)(nJ,{value:"matching",children:[(0,i.jsx)(lZ.VsL,{className:"text-lg mr-3"}),"Matching"]})}),"pro"===tX&&(0,i.jsxs)(J,{className:gs,children:[(0,i.jsxs)(nJ,{value:"keyword",children:[(0,i.jsx)(m1.Gfv,{className:"text-lg mr-3"}),"Keyword"]}),(0,i.jsxs)(nJ,{value:"release-group",children:[(0,i.jsx)(u4.Com,{className:"text-lg mr-3"}),"Release Group"]}),(0,i.jsxs)(nJ,{value:"stream-expression",children:[(0,i.jsx)(m7.awR,{className:"text-lg mr-3"}),"Stream Expression"]}),((null==tQ?void 0:tQ.settings.regexAccess.level)!=="none"||((null==tQ||null==(e=tQ.settings.regexAccess.patterns)?void 0:e.length)??0)>0||((null==tQ||null==(t=tQ.settings.regexAccess.urls)?void 0:t.length)??0)>0)&&(0,i.jsxs)(nJ,{value:"regex",children:[(0,i.jsx)(xI.zvj,{className:"text-lg mr-3"}),"Regex"]})]}),(0,i.jsxs)(J,{className:gs,children:[(0,i.jsxs)(nJ,{value:"limit",children:[(0,i.jsx)(xE.GJ9,{className:"text-lg mr-3"}),"Result Limits"]}),(0,i.jsxs)(nJ,{value:"deduplicator",children:[(0,i.jsx)(m1.xbI,{className:"text-lg mr-3"}),"Deduplicator"]})]}),(0,i.jsx)(J,{className:gs,children:(0,i.jsxs)(nJ,{value:"miscellaneous",children:[(0,i.jsx)(m1.y2g,{className:"text-lg mr-3"}),"Miscellaneous"]})})]})]})}),(0,i.jsxs)("div",{className:"space-y-0 relative",children:[(0,i.jsx)(nZ,{id:"filter-tab-cache",value:"cache",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Cache"}),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(mK,{id:"excludeUncached",title:"Uncached",description:"Control the exclusion of uncached results",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(ni,{label:"Exclude Uncached",help:"Completely remove uncached results",moreHelp:"Enabling this option overrides the below controls and cannot be used in conjunction with them",side:"right",value:t0.excludeUncached??!1,onValueChange:e=>{t1(t=>({...t,excludeUncached:e}))}}),"pro"===tX&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(li,{help:"Addons selected here will have their uncached results excluded",label:"Exclude Uncached From Addons",value:t0.excludeUncachedFromAddons??[],onValueChange:e=>{t1(t=>({...t,excludeUncachedFromAddons:e}))},options:t0.presets.map(e=>({label:e.options.name||e.type,value:e.instanceId,textValue:e.options.name})),emptyMessage:"You haven't installed any addons...",placeholder:"Select addons...",multiple:!0,disabled:!0===t0.excludeUncached}),(0,i.jsx)(li,{help:"Services selected here will have their uncached results excluded",label:"Exclude Uncached From Services",value:t0.excludeUncachedFromServices??[],onValueChange:e=>{t1(t=>({...t,excludeUncachedFromServices:e}))},options:Object.values((null==tQ?void 0:tQ.settings.services)??{}).map(e=>({label:e.name,value:e.id,textValue:e.name})),placeholder:"Select services...",emptyMessage:"This is odd... there aren't any services to choose from...",multiple:!0,disabled:!0===t0.excludeUncached}),(0,i.jsx)(li,{help:"Stream types selected here will have their uncached results excluded",label:"Exclude Uncached From Stream Types",value:t0.excludeUncachedFromStreamTypes??[],onValueChange:e=>{t1(t=>({...t,excludeUncachedFromStreamTypes:e}))},options:aE.filter(e=>["debrid","usenet"].includes(e)).map(e=>({label:e,value:e,textValue:e})),emptyMessage:"This is odd... there aren't any stream types to choose from...",placeholder:"Select stream types...",multiple:!0,disabled:!0===t0.excludeUncached}),(0,i.jsx)(nc,{label:"Apply mode",disabled:!0===t0.excludeUncached,help:"How these three options (from addons, services and stream types) are applied. AND means a result must match all, OR means a result only needs to match one",value:t0.excludeUncachedMode??"or",onValueChange:e=>{t1(t=>({...t,excludeUncachedMode:e}))},options:[{label:"OR",value:"or"},{label:"AND",value:"and"}]})]})]})}),(0,i.jsx)(mK,{id:"excludeCached",title:"Cached",description:"Control the exclusion of cached results",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(ni,{label:"Exclude Cached",help:"Completely remove cached results",moreHelp:"Enabling this option overrides the below controls and cannot be used in conjunction with them",side:"right",value:t0.excludeCached??!1,onValueChange:e=>{t1(t=>({...t,excludeCached:e}))}}),"pro"===tX&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(li,{help:"Addons selected here will have their cached results excluded",label:"Exclude Cached From Addons",value:t0.excludeCachedFromAddons??[],onValueChange:e=>{t1(t=>({...t,excludeCachedFromAddons:e}))},options:t0.presets.map(e=>({label:e.options.name||e.type,value:e.instanceId,textValue:e.options.name||e.type})),emptyMessage:"You haven't installed any addons...",placeholder:"Select addons...",multiple:!0,disabled:!0===t0.excludeCached}),(0,i.jsx)(li,{help:"Services selected here will have their cached results excluded",label:"Exclude Cached From Services",value:t0.excludeCachedFromServices??[],onValueChange:e=>{t1(t=>({...t,excludeCachedFromServices:e}))},options:Object.values((null==tQ?void 0:tQ.settings.services)??{}).map(e=>({label:e.name,value:e.id,textValue:e.name})),placeholder:"Select services...",emptyMessage:"This is odd... there aren't any services to choose from...",multiple:!0,disabled:!0===t0.excludeCached}),(0,i.jsx)(li,{help:"Stream types selected here will have their cached results excluded",label:"Exclude Cached From Stream Types",value:t0.excludeCachedFromStreamTypes??[],onValueChange:e=>{t1(t=>({...t,excludeCachedFromStreamTypes:e}))},options:aE.filter(e=>["debrid","usenet"].includes(e)).map(e=>({label:e,value:e,textValue:e})),emptyMessage:"This is odd... there aren't any stream types to choose from...",placeholder:"Select stream types...",multiple:!0,disabled:!0===t0.excludeCached}),(0,i.jsx)(nc,{label:"Apply mode",disabled:!0===t0.excludeCached,help:"How these three options (from addons, services and stream types) are applied. AND means a result must match all, OR means a result only needs to match one",value:t0.excludeCachedMode??"or",onValueChange:e=>{t1(t=>({...t,excludeCachedMode:e}))},options:[{label:"OR",value:"or"},{label:"AND",value:"and"}]})]})]})})]})]})}),(0,i.jsx)(nZ,{id:"filter-tab-resolution",value:"resolution",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Resolution"}),(0,i.jsx)(xD,{filterName:"Resolutions",preferredOptions:t0.preferredResolutions||x3,requiredOptions:t0.requiredResolutions||[],excludedOptions:t0.excludedResolutions||[],includedOptions:t0.includedResolutions||[],onPreferredChange:e=>t1(t=>({...t,preferredResolutions:e})),onRequiredChange:e=>t1(t=>({...t,requiredResolutions:e})),onExcludedChange:e=>t1(t=>({...t,excludedResolutions:e})),onIncludedChange:e=>t1(t=>({...t,includedResolutions:e})),options:ak.map(e=>({name:e,value:e}))})]})}
43),(0,i.jsx)(nZ,{id:"filter-tab-quality",value:"quality",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Quality"}),(0,i.jsx)(xD,{filterName:"Qualities",preferredOptions:t0.preferredQualities||x5,requiredOptions:t0.requiredQualities||[],excludedOptions:t0.excludedQualities||[],includedOptions:t0.includedQualities||[],onPreferredChange:e=>t1(t=>({...t,preferredQualities:e})),onRequiredChange:e=>t1(t=>({...t,requiredQualities:e})),onExcludedChange:e=>t1(t=>({...t,excludedQualities:e})),onIncludedChange:e=>t1(t=>({...t,includedQualities:e})),options:aS.map(e=>({name:e,value:e}))})]})}),(0,i.jsx)(nZ,{id:"filter-tab-encode",value:"encode",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Encode"}),(0,i.jsx)(xD,{filterName:"Encodes",preferredOptions:t0.preferredEncodes||x4,requiredOptions:t0.requiredEncodes||[],excludedOptions:t0.excludedEncodes||[],includedOptions:t0.includedEncodes||[],onPreferredChange:e=>t1(t=>({...t,preferredEncodes:e})),onRequiredChange:e=>t1(t=>({...t,requiredEncodes:e})),onExcludedChange:e=>t1(t=>({...t,excludedEncodes:e})),onIncludedChange:e=>t1(t=>({...t,includedEncodes:e})),options:aR.map(e=>({name:e,value:e}))})]})}),(0,i.jsx)(nZ,{id:"filter-tab-stream-type",value:"stream-type",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Stream Type"}),(0,i.jsx)(xD,{filterName:"Stream Types",preferredOptions:t0.preferredStreamTypes||x6,requiredOptions:t0.requiredStreamTypes||[],excludedOptions:t0.excludedStreamTypes||[],includedOptions:t0.includedStreamTypes||[],onPreferredChange:e=>t1(t=>({...t,preferredStreamTypes:e})),onRequiredChange:e=>t1(t=>({...t,requiredStreamTypes:e})),onExcludedChange:e=>t1(t=>({...t,excludedStreamTypes:e})),onIncludedChange:e=>t1(t=>({...t,includedStreamTypes:e})),options:aE.map(e=>({name:e,value:e}))})]})}),(0,i.jsx)(nZ,{id:"filter-tab-visual-tag",value:"visual-tag",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Visual Tag"}),(0,i.jsx)(xD,{filterName:"Visual Tags",preferredOptions:t0.preferredVisualTags||x9,requiredOptions:t0.requiredVisualTags||[],excludedOptions:t0.excludedVisualTags||[],includedOptions:t0.includedVisualTags||[],onPreferredChange:e=>t1(t=>({...t,preferredVisualTags:e})),onRequiredChange:e=>t1(t=>({...t,requiredVisualTags:e})),onExcludedChange:e=>t1(t=>({...t,excludedVisualTags:e})),onIncludedChange:e=>t1(t=>({...t,includedVisualTags:e})),options:aC.map(e=>({name:e,value:e}))})]})}),(0,i.jsx)(nZ,{id:"filter-tab-audio-tag",value:"audio-tag",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Audio Tag"}),(0,i.jsx)(xD,{filterName:"Audio Tags",preferredOptions:t0.preferredAudioTags||[],requiredOptions:t0.requiredAudioTags||[],excludedOptions:t0.excludedAudioTags||[],includedOptions:t0.includedAudioTags||[],onPreferredChange:e=>t1(t=>({...t,preferredAudioTags:e})),onRequiredChange:e=>t1(t=>({...t,requiredAudioTags:e})),onExcludedChange:e=>t1(t=>({...t,excludedAudioTags:e})),onIncludedChange:e=>t1(t=>({...t,includedAudioTags:e})),options:a_.map(e=>({name:e,value:e}))})]})}),(0,i.jsx)(nZ,{id:"filter-tab-audio-channel",value:"audio-channel",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Audio Channel"}),(0,i.jsx)(xD,{filterName:"Audio Channels",preferredOptions:t0.preferredAudioChannels||[],requiredOptions:t0.requiredAudioChannels||[],excludedOptions:t0.excludedAudioChannels||[],includedOptions:t0.includedAudioChannels||[],onPreferredChange:e=>t1(t=>({...t,preferredAudioChannels:e})),onRequiredChange:e=>t1(t=>({...t,requiredAudioChannels:e})),onExcludedChange:e=>t1(t=>({...t,excludedAudioChannels:e})),onIncludedChange:e=>t1(t=>({...t,includedAudioChannels:e})),options:aA.map(e=>({name:e,value:e}))})]})}),(0,i.jsx)(nZ,{id:"filter-tab-language",value:"language",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Language"}),(0,i.jsx)(xD,{filterName:"Languages",preferredOptions:t0.preferredLanguages||[],requiredOptions:t0.requiredLanguages||[],excludedOptions:t0.excludedLanguages||[],includedOptions:t0.includedLanguages||[],onPreferredChange:e=>t1(t=>({...t,preferredLanguages:e})),onRequiredChange:e=>t1(t=>({...t,requiredLanguages:e})),onExcludedChange:e=>t1(t=>({...t,excludedLanguages:e})),onIncludedChange:e=>t1(t=>({...t,includedLanguages:e})),options:aF.map(e=>({name:e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),value:e}))})]})}),(0,i.jsx)(nZ,{id:"filter-tab-subtitle",value:"subtitle",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Subtitle"}),(0,i.jsx)(lB,{intent:"warning",title:"Difference between Language and Subtitle filters",description:(0,i.jsxs)("div",{className:"text-sm",children:["Languages and subtitles behave differently depending on what information is available for a stream.",(0,i.jsx)("br",{}),(0,i.jsx)("br",{}),(0,i.jsxs)("span",{className:"inline-flex items-center gap-1",children:["When accurate media info is available",(0,i.jsx)(P,{className:"text-sm ",trigger:(0,i.jsx)(I.ExT,{className:"transition-opacity opacity-45 hover:opacity-90 inline-block cursor-pointer"}),children:(0,i.jsxs)("div",{className:"max-w-sm",children:[(0,i.jsx)("div",{className:"font-medium",children:"Accurate media info is available for:"}),(0,i.jsxs)("ul",{className:"list-disc list-inside mt-2 space-y-1 text-xs",children:[(0,i.jsx)("li",{children:"Certain results from built-in or service-wrapped addons"}),(0,i.jsx)("li",{children:"Certain results from StremThru Torz/Store and Meteor"}),(0,i.jsx)("li",{children:"Torznab/Newznab results from indexers that provide separate audio/subtitle metadata"}),(0,i.jsxs)("li",{children:[(0,i.jsx)("strong",{children:"nekoBT"})," results (all results have accurate audio/subtitle info)"]}),(0,i.jsxs)("li",{children:[(0,i.jsx)("strong",{children:"Torrentio"})," anime results (subtitles field may be populated)"]})]})]})})]}),", ",(0,i.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"languages"})," ","contains audio track languages and"," ",(0,i.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"subtitles"})," ","contains embedded subtitle languages.",(0,i.jsx)("br",{}),(0,i.jsx)("br",{}),"In all other cases,"," ",(0,i.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"subtitles"}
43)," ","is empty and"," ",(0,i.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"languages"})," ",'contains every language found in the filename â including subtitle-only languages (e.g. a filename containing "Eng.Sub" will add English to languages, not subtitles). This is a known limitation of filename-only parsing.']})}),(0,i.jsx)(xD,{filterName:"Subtitles",preferredOptions:t0.preferredSubtitles||[],requiredOptions:t0.requiredSubtitles||[],excludedOptions:t0.excludedSubtitles||[],includedOptions:t0.includedSubtitles||[],onPreferredChange:e=>t1(t=>({...t,preferredSubtitles:e})),onRequiredChange:e=>t1(t=>({...t,requiredSubtitles:e})),onExcludedChange:e=>t1(t=>({...t,excludedSubtitles:e})),onIncludedChange:e=>t1(t=>({...t,includedSubtitles:e})),options:aF.map(e=>({name:e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),value:e}))})]})}),(0,i.jsx)(nZ,{id:"filter-tab-seeders",value:"seeders",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Seeders"}),(0,i.jsx)(mK,{title:"Seeder Filters",description:"Configure required, excluded, and included seeder ranges",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)(x$,{min:0,max:1e3,defaultValue:[0,1e3],value:t0.requiredSeederRange||[0,1e3],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,requiredSeederRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Required Seeder Range",help:"Streams with seeders outside this range will be excluded"}),(0,i.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,i.jsx)("span",{children:(null==(s=t0.requiredSeederRange)?void 0:s[0])||0}),(0,i.jsx)("span",{children:(null==(a=t0.requiredSeederRange)?void 0:a[1])||1e3})]})]}),(0,i.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,i.jsx)(lm,{label:"Min",value:(null==(r=t0.requiredSeederRange)?void 0:r[0])||0,min:0,max:(null==(n=t0.requiredSeederRange)?void 0:n[1])||1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,requiredSeederRange:[e,(null==(s=t.requiredSeederRange)?void 0:s[1])||1e3]}})}),(0,i.jsx)(lm,{label:"Max",value:(null==(l=t0.requiredSeederRange)?void 0:l[1])||1e3,min:(null==(o=t0.requiredSeederRange)?void 0:o[0])||0,max:1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,requiredSeederRange:[(null==(s=t.requiredSeederRange)?void 0:s[0])||0,e]}})})]})]}),"pro"===tX&&(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)(x$,{min:0,max:1e3,defaultValue:[0,1e3],value:t0.excludeSeederRange||[0,1e3],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,excludeSeederRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Excluded Seeder Range",help:"Streams with seeders in this range will be excluded"}),(0,i.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,i.jsx)("span",{children:(null==(d=t0.excludeSeederRange)?void 0:d[0])||0}),(0,i.jsx)("span",{children:(null==(c=t0.excludeSeederRange)?void 0:c[1])||1e3})]})]}),(0,i.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,i.jsx)(lm,{label:"Min",value:(null==(h=t0.excludeSeederRange)?void 0:h[0])||0,min:0,max:(null==(p=t0.excludeSeederRange)?void 0:p[1])||1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,excludeSeederRange:[e,(null==(s=t.excludeSeederRange)?void 0:s[1])||1e3]}})}),(0,i.jsx)(lm,{label:"Max",value:(null==(x=t0.excludeSeederRange)?void 0:x[1])||1e3,min:(null==(g=t0.excludeSeederRange)?void 0:g[0])||0,max:1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,excludeSeederRange:[(null==(s=t.excludeSeederRange)?void 0:s[0])||0,e]}})})]})]})}),"pro"===tX&&(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)(x$,{min:0,max:1e3,defaultValue:[0,1e3],value:t0.includeSeederRange||[0,1e3],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,includeSeederRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Included Seeder Range",help:"Streams with seeders in this range will be included, ignoring ANY other exclude/required filters, not just for this filter"}),(0,i.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,i.jsx)("span",{children:(null==(f=t0.includeSeederRange)?void 0:f[0])||0}),(0,i.jsx)("span",{children:(null==(b=t0.includeSeederRange)?void 0:b[1])||1e3})]})]}),(0,i.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,i.jsx)(lm,{label:"Min",value:(null==(y=t0.includeSeederRange)?void 0:y[0])||0,min:0,max:(null==(j=t0.includeSeederRange)?void 0:j[1])||1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,includeSeederRange:[e,(null==(s=t.includeSeederRange)?void 0:s[1])||1e3]}})}),(0,i.jsx)(lm,{label:"Max",value:(null==(N=t0.includeSeederRange)?void 0:N[1])||1e3,min:(null==(k=t0.includeSeederRange)?void 0:k[0])||0,max:1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,includeSeederRange:[(null==(s=t.includeSeederRange)?void 0:s[0])||0,e]}})})]})]})})]}),(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsx)(li,{label:"Stream Types",emptyMessage:"There aren't any stream types to choose from...",options:["p2p","cached","uncached"].map(e=>({label:e,value:e})),value:t0.seederRangeTypes||[],onValueChange:e=>{t1(t=>({...t,seederRangeTypes:e}))},help:"Stream types that will use the seeder ranges defined above. Leave blank to apply to all stream types.",multiple:!0})})]})})]})}),(0,i.jsx)(nZ,{id:"filter-tab-age",value:"age",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Age"}),(0,i.jsx)(mK,{title:"Age Filters",description:"Configure required, excluded, and included age ranges (in hours since upload)",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)(x$,{min:0,max:155520,step:24,defaultValue:[0,155520],value:t0.requiredAgeRange||[0,155520],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,requiredAgeRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Required Age Range",help:"Streams with age outside this range will be excluded"}),(0,i.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,i.jsx)("span",{children:gr((null==(S=t0.requiredAgeRange)?void 0:S[0])||0)}),(0,i.jsx)("span",{children:gr((null==(C=t0.requiredAgeRange)?void 0:C[1])||155520)})]})]}),(0,i.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,i.jsx)(lm,{label:"Min",step:24,value:(null==(_=t0.requiredAgeRange)?void 0:_[0])||0,min:0,max:(null==(A=t0.requiredAgeRange)?void 0:A[1])||155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,requiredAgeRange:[e,(null==(s=t.requiredAgeRange)?void 0:s[1])||155520]}})}),(0,i.jsx)(lm,{label:"Max",step:24,value:(null==(R=t0.requiredAgeRange)?void 0:R[1])||155520,min:(null==(T=t0.requiredAgeRange)?void 0:T[0])||0,max:155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,requiredAgeRange:[(null==(s=t.requiredAgeRange)?void 0:s[0])||0,e]}})})]})]}),"pro"===tX&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)(x$,{min:0,max:155520,step:24,defaultValue:[0,155520],value:t0.excludeAgeRange||[0,155520],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,excludeAgeRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Excluded Age Range",help:"Streams with age in this range will be excluded"}),(0,i.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,i.jsx)("span",{children:gr((null==(E=t0.excludeAgeRange)?void 0:E[0])||0)}),(0,i.jsx)("span",{children:gr((null==(M=t0.excludeAgeRange)?void 0:M[1])||155520)})]})]}),(0,i.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,i.jsx)(lm,{label:"Min",step:24,value:(null==($=t0.excludeAgeRange)?void 0:$[0])||0,min:0,max:(null==(D=t0.excludeAgeRange)?void 0:D[1])||155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,excludeAgeRange:[e,(null==(s=t.excludeAgeRange)?void 0:s[1])||155520]}})}),(0,i.jsx)(lm,{label:"Max",step:24,value:(null==(L=t0.excludeAgeRange)?void 0:L[1])||155520,min:(null==(O=t0.excludeAgeRange)?void 0:O[0])||0,max:155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,excludeAgeRange:[(null==(s=t.excludeAgeRange)?void 0:s[0])||0,e]}})})]})]}),(0,i.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsx)(x$,{min:0,max:155520,step:24,defaultValue:[0,155520],value:t0.includeAgeRange||[0,155520],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,includeAgeRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Included Age Range",help:"Streams with age in this range will be included even if they would be excluded otherwise"}),(0,i.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,i.jsx)("span",{children:gr((null==(U=t0.includeAgeRange)?void 0:U[0])||0)}),(0,i.jsx)("span",{children:gr((null==(F=t0.includeAgeRange)?void 0:F[1])||155520)})]})]}),(0,i.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,i.jsx)(lm,{label:"Min",step:24,value:(null==(z=t0.includeAgeRange)?void 0:z[0])||0,min:0,max:(null==(V=t0.includeAgeRange)?void 0:V[1])||155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,includeAgeRange:[e,(null==(s=t.includeAgeRange)?void 0:s[1])||155520]}})}),(0,i.jsx)(lm,{label:"Max",step:24,value:(null==(q=t0.includeAgeRange)?void 0:q[1])||155520,min:(null==(B=t0.includeAgeRange)?void 0:B[0])||0,max:155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,includeAgeRange:[(null==(s=t.includeAgeRange)?void 0:s[0])||0,e]}})})]})]})]})]}),(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsx)(li,{label:"Stream Types",emptyMessage:"There aren't any stream types to choose from...",options:["debrid","usenet","p2p"].map(e=>({label:e,value:e})),defaultValue:["usenet"],value:t0.ageRangeTypes||["usenet"],onValueChange:e=>{t1(t=>({...t,ageRangeTypes:e}))},help:"Stream types that will use the age ranges defined above. Leave blank to apply to all stream types.",multiple:!0})})]})})]})}),(0,i.jsx)(nZ,{id:"filter-tab-matching",value:"matching",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Matching"}),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)(mK,{id:"titleMatching",title:"Title Matching",description:"Any streams which don't specifically match the requested title will be filtered out. You can optionally choose to only apply it to specific request types and addons. This requires a TMDB Read Access Token to be set in the Services menu.",children:[(0,i.jsx)(ni,{label:"Enabled",side:"right",value:(null==(K=t0.titleMatching)?void 0:K.enabled)??!1,onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching||{},enabled:e}}))}}),(0,i.jsx)(nc,{disabled:!(null==(H=t0.titleMatching)?void 0:H.enabled),label:"Matching Mode",options:["exact","contains"].map(e=>({label:e,value:e})),defaultValue:"exact",value:null==(W=t0.titleMatching)?void 0:W.mode,help:(null==(G=t0.titleMatching)?void 0:G.mode)==="contains"?"Streams whose detected title doesn't contain the requested title will be excluded":"Streams whose detected title doesn't match the requested title exactly will be excluded",onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching,mode:e}}))}}),(0,i.jsx)(nc,{disabled:!(null==(Y=t0.titleMatching)?void 0:Y.enabled),label:"Ambiguous Results",options:[{label:"keep",value:"keep"},{label:"discard",value:"discard"}],defaultValue:"keep",value:null==(Z=t0.titleMatching)?void 0:Z.ambiguousResults,help:"What to do with results that can't be told apart from a same-name series (reboots and country variants, e.g. The Office UK vs US). 'discard' keeps only results whose year, country tag or episode title confirms the requested series.",onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching,ambiguousResults:e}}))}}),(0,i.jsxs)("div",{className:"flex gap-4",children:[(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(x$,{label:"Similarity Threshold",help:"The minimum similarity threshold required for a title to be considered a match. Lower values allow more leniency whereas higher values are more strict.",moreHelp:"The similarity is calculated using the Levenshtein distance algorithm.",disabled:!(null==(Q=t0.titleMatching)?void 0:Q.enabled),value:[(null==(X=t0.titleMatching)?void 0:X.similarityThreshold)??.85],min:0,max:1,step:.
4301,defaultValue:[.85],onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching,similarityThreshold:e[0]}}))}})}),(0,i.jsx)("div",{className:"w-24",children:(0,i.jsx)(lm,{label:"Value",step:.01,value:(null==(ee=t0.titleMatching)?void 0:ee.similarityThreshold)??.85,min:0,max:1,disabled:!(null==(et=t0.titleMatching)?void 0:et.enabled),onValueChange:e=>{void 0!==e&&t1(t=>({...t,titleMatching:{...t.titleMatching,similarityThreshold:e}}))}})})]}),(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,i.jsx)(li,{multiple:!0,disabled:!(null==(es=t0.titleMatching)?void 0:es.enabled),label:"Request Types",emptyMessage:"There aren't any request types to choose from...",help:"Request types that will use title matching. Leave blank to apply to all request types.",options:aL.map(e=>({label:e,value:e,textValue:e})),value:null==(ea=t0.titleMatching)?void 0:ea.requestTypes,onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching,requestTypes:e}}))}}),(0,i.jsx)(li,{multiple:!0,disabled:!(null==(er=t0.titleMatching)?void 0:er.enabled),label:"Addons",help:"Addons that will use strict title matching. Leave blank to apply to all addons.",emptyMessage:"You haven't installed any addons yet...",options:t0.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(en=t0.titleMatching)?void 0:en.addons)||[],onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching,addons:e}}))}})]})})]}),(0,i.jsxs)(mK,{id:"yearMatching",title:"Year Matching",description:"Any streams which don't specifically match the requested year will be filtered out. You can optionally choose to only apply it to specific request types and addons",children:[(0,i.jsx)(ni,{label:"Enable",side:"right",value:(null==(el=t0.yearMatching)?void 0:el.enabled)??!1,onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,enabled:e}}))}}),(0,i.jsx)(ni,{label:"Strict",side:"right",help:"Filter out streams for movies that don't have a year specified.",moreHelp:"Disabling this will allow streams without a year to be included in the results.",disabled:!(null==(ei=t0.yearMatching)?void 0:ei.enabled),value:(null==(eo=t0.yearMatching)?void 0:eo.strict)??!0,onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,strict:e}}))}}),(0,i.jsx)(li,{multiple:!0,disabled:!(null==(ed=t0.yearMatching)?void 0:ed.enabled)||(null==(ec=t0.yearMatching)?void 0:ec.strict)===!1,label:"Strict Request Types",emptyMessage:"There aren't any request types to choose from...",help:"Request types where streams without a year are filtered out. Defaults to movie only, as series results usually don't include a year.",options:aL.map(e=>({label:e,value:e,textValue:e})),value:(null==(eu=t0.yearMatching)?void 0:eu.strictTypes)??["movie"],onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,strictTypes:e}}))}}),(0,i.jsx)(ni,{label:"Use Initial Air Date",side:"right",help:"For series/anime, compare against only the initial air year instead of the full year range.",moreHelp:"Helps filter out same-title-different-show results (e.g. 'One Piece 2023' live-action vs 'One Piece 1999' anime). May also filter torrents that include a season air year in their name.",disabled:!(null==(em=t0.yearMatching)?void 0:em.enabled),value:(null==(eh=t0.yearMatching)?void 0:eh.useInitialAirDate)??!1,onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,useInitialAirDate:e}}))}}),(0,i.jsx)(lm,{label:"Year Tolerance",disabled:!(null==(ep=t0.yearMatching)?void 0:ep.enabled),value:(null==(ex=t0.yearMatching)?void 0:ex.tolerance)??1,onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,tolerance:e}}))},min:0,max:100,help:"The number of years to tolerate when matching years. For example, if the year tolerance is 5, then a stream with a year of 2020 will match a request for 2025."}),(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,i.jsx)(li,{multiple:!0,disabled:!(null==(eg=t0.yearMatching)?void 0:eg.enabled),label:"Request Types",emptyMessage:"There aren't any request types to choose from...",help:"Request types that will use year matching. Leave blank to apply to all request types.",options:aL.map(e=>({label:e,value:e,textValue:e})),value:null==(ef=t0.yearMatching)?void 0:ef.requestTypes,onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,requestTypes:e}}))}}),(0,i.jsx)(li,{multiple:!0,disabled:!(null==(eb=t0.yearMatching)?void 0:eb.enabled),label:"Addons",help:"Addons that will use year matching. Leave blank to apply to all addons.",emptyMessage:"You haven't installed any addons yet...",options:t0.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(ev=t0.yearMatching)?void 0:ev.addons)||[],onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,addons:e}}))}})]})})]}),(0,i.jsxs)(mK,{id:"seasonEpisodeMatching",title:"Season/Episode Matching",description:"Any streams which don't specifically match the requested season/episode will be filtered out. You can optionally choose to only apply it to specific request types and addons",children:[(0,i.jsx)(ni,{label:"Enabled",side:"right",value:(null==(ey=t0.seasonEpisodeMatching)?void 0:ey.enabled)??!1,onValueChange:e=>{t1(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching||{},enabled:e}}))}}
43),(0,i.jsx)(ni,{label:"Strict",side:"right",help:"Filter out streams for series that don't have any season or episode specified.",moreHelp:"Disabling this will allow streams without a season or episode to be included in the results.",disabled:!(null==(ej=t0.seasonEpisodeMatching)?void 0:ej.enabled),value:(null==(ew=t0.seasonEpisodeMatching)?void 0:ew.strict)??!1,onValueChange:e=>{t1(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching,strict:e}}))}}),(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,i.jsx)(li,{multiple:!0,disabled:!(null==(eN=t0.seasonEpisodeMatching)?void 0:eN.enabled),label:"Request Types",help:"Request types that will use season/episode matching. Leave blank to apply to all request types.",emptyMessage:"There aren't any request types to choose from...",options:aL.map(e=>({label:e,value:e,textValue:e})),value:null==(ek=t0.seasonEpisodeMatching)?void 0:ek.requestTypes,onValueChange:e=>{t1(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching,requestTypes:e}}))}}),(0,i.jsx)(li,{multiple:!0,disabled:!(null==(eS=t0.seasonEpisodeMatching)?void 0:eS.enabled),label:"Addons",help:"Addons that will use season/episode matching. Leave blank to apply to all addons.",emptyMessage:"You haven't installed any addons yet...",options:t0.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(eC=t0.seasonEpisodeMatching)?void 0:eC.addons)||[],onValueChange:e=>{t1(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching,addons:e}}))}})]})})]}),(0,i.jsxs)(mK,{id:"episodeTitleMatching",title:"Episode Title Matching",description:"Any streams whose release name carries an episode title that doesn't match the requested episode's title will be filtered out. Streams without an episode title are unaffected. Helps tell apart same-name series (e.g. The Office UK vs US) whose episode titles differ. You can optionally choose to only apply it to specific request types and addons.",children:[(0,i.jsx)(ni,{label:"Enabled",side:"right",value:(null==(e_=t0.episodeTitleMatching)?void 0:e_.enabled)??!1,onValueChange:e=>{t1(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching||{},enabled:e}}))}}),(0,i.jsxs)("div",{className:"flex gap-4",children:[(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(x$,{label:"Similarity Threshold",help:"The minimum similarity threshold required for an episode title to be considered a match. Lower values allow more leniency whereas higher values are more strict.",disabled:!(null==(eA=t0.episodeTitleMatching)?void 0:eA.enabled),value:[(null==(eR=t0.episodeTitleMatching)?void 0:eR.similarityThreshold)??.8],min:0,max:1,step:.01,defaultValue:[.8],onValueChange:e=>{t1(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,similarityThreshold:e[0]}}))}})}),(0,i.jsx)("div",{className:"w-24",children:(0,i.jsx)(lm,{label:"Value",step:.01,value:(null==(eT=t0.episodeTitleMatching)?void 0:eT.similarityThreshold)??.8,min:0,max:1,disabled:!(null==(eI=t0.episodeTitleMatching)?void 0:eI.enabled),onValueChange:e=>{void 0!==e&&t1(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,similarityThreshold:e}}))}})})]}),(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,i.jsx)(li,{multiple:!0,disabled:!(null==(eE=t0.episodeTitleMatching)?void 0:eE.enabled),label:"Request Types",help:"Request types that will use episode title matching. Leave blank to apply to all request types.",emptyMessage:"There aren't any request types to choose from...",options:aL.map(e=>({label:e,value:e,textValue:e})),value:null==(eM=t0.episodeTitleMatching)?void 0:eM.requestTypes,onValueChange:e=>{t1(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,requestTypes:e}}))}}),(0,i.jsx)(li,{multiple:!0,disabled:!(null==(eP=t0.episodeTitleMatching)?void 0:eP.enabled),label:"Addons",help:"Addons that will use episode title matching. Leave blank to apply to all addons.",emptyMessage:"You haven't installed any addons yet...",options:t0.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(e$=t0.episodeTitleMatching)?void 0:e$.addons)||[],onValueChange:e=>{t1(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,addons:e}}))}})]})})]}),(0,i.jsxs)(mK,{id:"languageInference",title:"Language Inference",description:"When a stream declares no language of its own, the language of the metadata title it matched is added to it. A source only contributes while its own filter is running, so Title needs Title Matching enabled and Episode Title needs Episode Title Matching enabled. Inference also happens after the language filters, so an inferred language reaches the formatter, sorting and stream expressions, but cannot be filtered on in the same request.",children:[(0,i.jsx)(ni,{label:"Enabled",side:"right",value:(null==(eD=t0.languageInference)?void 0:eD.enabled)??!0,onValueChange:e=>{t1(t=>({...t,languageInference:{...t.languageInference||{},enabled:e}}))}}),(0,i.jsx)(li,{multiple:!0,disabled:(null==(eL=t0.languageInference)?void 0:eL.enabled)===!1,label:"Sources",emptyMessage:"There aren't any sources to choose from...",help:"Which matched title may contribute a language, on top of that title's own filter being enabled. Leave blank to allow both. Episode titles are the stronger signal, as a series title is often identical across languages.",options:[{label:"Title",value:"title",textValue:"Title"},{label:"Episode Title",value:"episodeTitle",textValue:"Episode Title"}],value:(null==(eO=t0.languageInference)?void 0:eO.sources)||[],onValueChange:e=>{t1(t=>({...t,languageInference:{...t.languageInference,sources:e}}))}})]})]})]})}),(0,i.jsx)(nZ,{id:"filter-tab-stream-expression",value:"stream-expression",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Stream Expression"}),(0,i.jsx)("div",{className:"mb-4",children:(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Create advanced filters to exclude, prefer or require specific streams from your results using stream expressions. Write expressions that evaluate which streams to select based on properties like addon type, qual
43ity, size, or any other stream attributes. Multiple expressions can be combined using logical operators for precise filtering control. You can also use ternary operators to apply conditional logic to the streams."})}),(0,i.jsx)("div",{className:"mb-4 space-y-4",children:(null==tQ?void 0:tQ.settings.selSyncAccess.level)==="trusted"&&(t0.trusted?(0,i.jsx)(lB,{intent:"success",title:"Trusted User",description:(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{children:"You are a trusted user. You can sync expressions from any URL."}),(null==tQ?void 0:tQ.settings.selSyncAccess.trustedUrls)&&tQ.settings.selSyncAccess.trustedUrls.length>0&&(0,i.jsx)("div",{className:"flex flex-row flex-wrap gap-2",children:(0,i.jsx)(v,{intent:"primary-outline",size:"sm",onClick:t6.open,children:"View Whitelisted Sync URLs"})})]})}):(0,i.jsx)(lB,{intent:"info",title:"Trusted Users Only",description:(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("p",{children:["Syncing stream expressions from arbitrary URLs is only available to trusted users. You can only sync from whitelisted URLs. If you are the owner of the instance, you can add your UUID to the"," ",(0,i.jsx)("code",{className:"font-mono",children:"TRUSTED_UUIDS"})," ","environment variable."]}),(null==tQ?void 0:tQ.settings.selSyncAccess.trustedUrls)&&tQ.settings.selSyncAccess.trustedUrls.length>0&&(0,i.jsx)("div",{className:"flex flex-row flex-wrap gap-2",children:(0,i.jsx)(v,{intent:"primary-outline",size:"sm",onClick:t6.open,children:"View Whitelisted Sync URLs"})})]})}))}),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(mK,{title:"Help",children:(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["This filter uses AIOStreams'"," ",(0,i.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/stream-expressions",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"stream expression language"}),", the same syntax used in the Groups system. The difference here is that you only have the"," ",(0,i.jsx)("code",{children:"streams"})," constant containing all available streams"]}),(0,i.jsxs)("div",{className:"text-sm text-[--muted]",children:[(0,i.jsx)("p",{className:"font-medium mb-2",children:"How it works:"}),(0,i.jsxs)("ul",{className:"list-disc list-inside space-y-1 ml-2",children:[(0,i.jsx)("li",{children:"Your expression should return an array of streams"}),(0,i.jsxs)("li",{children:["Use functions like ",(0,i.jsx)("code",{children:"addon()"}),","," ",(0,i.jsx)("code",{children:"type()"}),", ",(0,i.jsx)("code",{children:"quality()"})," to filter streams"]}),(0,i.jsx)("li",{children:"Combine multiple attributes together using nested functions"}),(0,i.jsxs)("li",{children:["Apply conditional logic using ternary operators"," ",(0,i.jsx)("code",{children:"expression ? arrayIfTrue : arrayIfFalse"})," ","where the two arrays can be replaced with true or false for all streams and no streams respectively."]})]})]}),(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:[(0,i.jsx)("strong",{children:"Example:"})," ",(0,i.jsx)("code",{children:"addon(type(streams, 'debrid'), 'TorBox')"})," ","excludes all TorBox debrid streams."]}),(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["For detailed syntax and available functions, see the"," ",(0,i.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/stream-expressions#function-reference",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"Full function reference"})]})]})}),(0,i.jsx)(xY,{title:"Required Stream Expressions",description:"The expressions to apply to the streams. Streams selected by any of these expressions will be required to be in the results.",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",values:t0.requiredStreamExpressions||[],onValuesChange:e=>{t1(t=>({...t,requiredStreamExpressions:e}))},onExpressionChange:(e,t)=>
43{t1(s=>({...s,requiredStreamExpressions:[...(s.requiredStreamExpressions||[]).slice(0,t),{...(s.requiredStreamExpressions||[])[t],expression:e},...(s.requiredStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t1(s=>({...s,requiredStreamExpressions:[...(s.requiredStreamExpressions||[]).slice(0,t),{...(s.requiredStreamExpressions||[])[t],enabled:e},...(s.requiredStreamExpressions||[]).slice(t+1)]}))},...t9("syncedRequiredStreamExpressionUrls")}),(0,i.jsx)(xY,{title:"Excluded Stream Expressions",description:"The expressions to apply to the streams. Streams selected by any of these expressions will be excluded from the results.",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",values:t0.excludedStreamExpressions||[],onValuesChange:e=>{t1(t=>({...t,excludedStreamExpressions:e}))},onExpressionChange:(e,t)=>{t1(s=>({...s,excludedStreamExpressions:[...(s.excludedStreamExpressions||[]).slice(0,t),{...(s.excludedStreamExpressions||[])[t],expression:e},...(s.excludedStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>
43{t1(s=>({...s,excludedStreamExpressions:[...(s.excludedStreamExpressions||[]).slice(0,t),{...(s.excludedStreamExpressions||[])[t],enabled:e},...(s.excludedStreamExpressions||[]).slice(t+1)]}))},...t9("syncedExcludedStreamExpressionUrls")}),(0,i.jsx)(xY,{title:"Included Stream Expressions",description:"The expressions to apply to the streams. Streams selected by any of these expressions will be included in the results.",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",values:t0.includedStreamExpressions||[],onValuesChange:e=>{t1(t=>({...t,includedStreamExpressions:e}))},onExpressionChange:(e,t)=>{t1(s=>({...s,includedStreamExpressions:[...(s.includedStreamExpressions||[]).slice(0,t),{...(s.includedStreamExpressions||[])[t],expression:e},...(s.includedStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t1(s=>({...s,includedStreamExpressions:[...(s.includedStreamExpressions||[]).slice(0,t),{...(s.includedStreamExpressions||[])[t],enabled:e},...(s.includedStreamExpressions||[]).slice(t+1)]}))},...t9("syncedIncludedStreamExpressionUrls")}),(0,i.jsx)(xY,{title:"Preferred Stream Expressions",description:"The expressions to apply to the streams. Streams selected by these expressions will be preferred over other streams and ranked by the order they are in this list.",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",values:t0.preferredStreamExpressions||[],onValuesChange:e=>{t1(t=>({...t,preferredStreamExpressions:e}))},onExpressionChange:(e,t)=>
43{t1(s=>({...s,preferredStreamExpressions:[...(s.preferredStreamExpressions||[]).slice(0,t),{...(s.preferredStreamExpressions||[])[t],expression:e},...(s.preferredStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t1(s=>({...s,preferredStreamExpressions:[...(s.preferredStreamExpressions||[]).slice(0,t),{...(s.preferredStreamExpressions||[])[t],enabled:e},...(s.preferredStreamExpressions||[]).slice(t+1)]}))},...t9("syncedPreferredStreamExpressionUrls")}),(0,i.jsx)(xZ,{title:"Ranked Stream Expressions",description:"Add expressions with scores. All matching expressions accumulate their scores on each stream. Use negative scores to penalize matches. Sort by 'Stream Expression Score' to order by the total.",values:t0.rankedStreamExpressions||[],onValuesChange:e=>{t1(t=>({...t,rankedStreamExpressions:e}))},onExpressionChange:(e,t)=>{t1(s=>({...s,rankedStreamExpressions:[...(s.rankedStreamExpressions||[]).slice(0,t),{...(s.rankedStreamExpressions||[])[t],expression:e},...(s.rankedStreamExpressions||[]).slice(t+1)]}))},onScoreChange:(e,t)=>
43{t1(s=>({...s,rankedStreamExpressions:[...(s.rankedStreamExpressions||[]).slice(0,t),{...(s.rankedStreamExpressions||[])[t],score:e},...(s.rankedStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t1(s=>({...s,rankedStreamExpressions:[...(s.rankedStreamExpressions||[]).slice(0,t),{...(s.rankedStreamExpressions||[])[t],enabled:e},...(s.rankedStreamExpressions||[]).slice(t+1)]}))},...t9("syncedRankedStreamExpressionUrls")})]})]})}),(0,i.jsx)(nZ,{id:"filter-tab-keyword",value:"keyword",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Keyword"}),(0,i.jsx)("div",{className:"mb-4",children:(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Filter your streams by keywords - words or phrases that must appear in the filename, folder name, indexer, or release group"})}),(0,i.jsxs)("div",{className:"space-y-4",children:["pro"===tX&&(0,i.jsx)(xG,{label:"Required Keywords",help:"Streams that do not contain any of these keywords will be excluded",itemName:"Keyword",values:t0.requiredKeywords||[],onValuesChange:e=>{t1(t=>({...t,requiredKeywords:e}))}}),(0,i.jsx)(xG,{label:"Excluded Keywords",help:"Streams that contain any of these keywords will be excluded",itemName:"Keyword",values:t0.excludedKeywords||[],onValuesChange:e=>{t1(t=>({...t,excludedKeywords:e}))}}),"pro"===tX&&(0,i.jsx)(xG,{label:"Included Keywords",help:"Streams that contain any of these keywords will be included, ignoring ANY other exclude/required filters, not just for this filter",itemName:"Keyword",values:t0.includedKeywords||[],onValuesChange:e=>{t1(t=>({...t,includedKeywords:e}))}}),(0,i.jsx)(xG,{label:"Preferred Keywords",help:"Streams that contain any of these keywords will be preferred",itemName:"Keyword",values:t0.preferredKeywords||[],onValuesChange:e=>{t1(t=>({...t,preferredKeywords:e}))}})]})]})}),(0,i.jsx)(nZ,{id:"filter-tab-release-group",value:"release-group",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Release Group"}),(0,i.jsx)("div",{className:"mb-4",children:(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Filter your streams by release group - the group that released the content (e.g., SPARKS, NTb, FLUX, etc.)"})}),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(xG,{label:"Required Release Groups",help:"Only streams from these release groups will be kept. Streams from other release groups will be excluded.",itemName:"Release Group",values:t0.requiredReleaseGroups||[],onValuesChange:e=>{t1(t=>({...t,requiredReleaseGroups:e}))}}),(0,i.jsx)(xG,{label:"Excluded Release Groups",help:"Streams from these release groups will be excluded",itemName:"Release Group",values:t0.excludedReleaseGroups||[],onValuesChange:e=>{t1(t=>({...t,excludedReleaseGroups:e}))}}),(0,i.jsx)(xG,{label:"Included Release Groups",help:"Streams from these release groups will be included, ignoring ANY other exclude/required filters, not just for this filter",itemName:"Release Group",values:t0.includedReleaseGroups||[],onValuesChange:e=>{t1(t=>({...t,includedReleaseGroups:e}))}}),(0,i.jsx)(xG,{label:"Preferred Release Groups",help:"Streams from these release groups will be sorted higher. The order matters - release groups at the top will be preferred over those below.",itemName:"Release Group",values:t0.preferredReleaseGroups||[],onValuesChange:e=>{t1(t=>({...t,preferredReleaseGroups:e}))}})]})]})}),(0,i.jsx)(nZ,{id:"filter-tab-regex",value:"regex",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Regex"}),(0,i.jsx)("div",{className:"mb-4",children:(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Filter your streams by regular expressions that must match one of the following: filename, folder name, indexer, or release group"})}),(0,i.jsxs)("div",{className:"mb-4 space-y-4",children:[(null==tQ?void 0:tQ.settings.regexAccess.level)==="trusted"&&(t0.trusted?(0,i.jsx)(lB,{intent:"success",title:"Trusted User",description:(0,i.jsx)("p",{children:"You are a trusted user. You have full access to regex filters."})}):(0,i.jsx)(lB,{intent:"info",title:"Trusted Users Only",description:(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)("p",{children:["Regex filters are only available to trusted users due to the potential for abuse. If you are the owner of the instance, you can add your UUID to the"," ",(0,i.jsx)("code",{className:"font-mono",children:"TRUSTED_UUIDS"})," ","environment variable."]})})})),((null==tQ||null==(eU=tQ.settings.regexAccess.patterns)?void 0:eU.length)||(null==tQ||null==(eF=tQ.settings.regexAccess.urls)?void 0:eF.length))&&(0,i.jsx)(lB,{intent:"info",title:"Allowed Regex Patterns",description:(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("div",{className:"max-w-full overflow-hidden",children:[(0,i.jsx)("p",{className:"break-words",children:"This instance has allowed a specific set of regexes to be used by all users."}),(null==tQ?void 0:tQ.settings.regexAccess.description)&&(0,i.jsx)("div",{className:"mt-2 break-words overflow-hidden",children:(0,i.jsx)(l6,{children:(null==tQ?void 0:tQ.settings.regexAccess.description)||""})})]}),(0,i.jsxs)("div",{className:"flex flex-row flex-wrap gap-2",children:[(null==tQ?void 0:tQ.settings.regexAccess.urls)&&tQ.settings.regexAccess.urls.length>0&&(0,i.jsx)(v,{intent:"primary-outline",size:"sm",onClick:t4.open,children:"View Allowed Import URLs"}),(0,i.jsx)(v,{intent:"primary-outline",size:"sm",onClick:t5.open,children:"View Allowed Patterns"})]})]})})]}),(0,i.jsxs)("div",{className:"space-y-4",children:["pro"===tX&&(0,i.jsx)(xG,{fieldName:"requiredRegexPatterns",label:"Required Regex",help:"Streams that do not match any of these regular expressions will be excluded",itemName:"Regex",values:t0.requiredRegexPatterns||[],onValuesChange:e=>{t1(t=>({...t,requiredRegexPatterns:e}))},...t9("syncedRequiredRegexUrls")}),(0,i.jsx)(xG,{label:"Excluded Regex",fieldName:"excludedRegexPatterns",help:"Streams that match any of these regular expressions will be excluded",itemName:"Regex",values:t0.excludedRegexPatterns||[],onValuesChange:e=>{t1(t=>({...t,excludedRegexPatterns:e}))},...t9("syncedExcludedRegexUrls")}),"pro"===tX&&(0,i.jsx)(xG,{label:"Included Regex",fieldName:"includedRegexPatterns",help:"Streams that match any of these regular expressions will be included, ignoring other exclude/required filters",itemName:"Regex",values:t0.includedRegexPatterns||[],onValuesChange:e=>{t1(t=>({...t,includedRegexPatterns:e}))},...t9("syncedIncludedRegexUrls")}),(0,i.jsx)(xJ,{title:"Preferred Regex Patterns",description:"Define regex patterns with names for easy reference",...t9("syncedPreferredRegexUrls"),keyName:"Name",keyId:"name",keyPlaceholder:"Enter pattern name",valueId:"pattern",valueName:"Pattern",valuePlaceholder:"Enter regex pattern",values:(t0.preferredRegexPatterns||[]).map(e=>({name:e.name,value:e.pattern}
43)),onValuesChange:e=>{t1(t=>({...t,preferredRegexPatterns:e.map(e=>({name:e.name,pattern:e.value}))}))},onValueChange:(e,t)=>{t1(s=>({...s,preferredRegexPatterns:[...(s.preferredRegexPatterns||[]).slice(0,t),{...(s.preferredRegexPatterns||[])[t],pattern:e},...(s.preferredRegexPatterns||[]).slice(t+1)]}))},onKeyChange:(e,t)=>{t1(s=>({...s,preferredRegexPatterns:[...(s.preferredRegexPatterns||[]).slice(0,t),{...(s.preferredRegexPatterns||[])[t],name:e},...(s.preferredRegexPatterns||[]).slice(t+1)]}))}}),(0,i.jsx)(xQ,{title:"Ranked Regex Patterns",description:"Add regex patterns with scores. Matches on filename only. Accumulates scores.",values:t0.rankedRegexPatterns||[],onValuesChange:e=>{t1(t=>({...t,rankedRegexPatterns:e}))},onPatternChange:(e,t)=>{t1(s=>({...s,rankedRegexPatterns:[...(s.rankedRegexPatterns||[]).slice(0,t),{...(s.rankedRegexPatterns||[])[t],pattern:e},...(s.rankedRegexPatterns||[]).slice(t+1)]}))},onNameChange:(e,t)=>{t1(s=>({...s,rankedRegexPatterns:[...(s.rankedRegexPatterns||[]).slice(0,t),{...(s.rankedRegexPatterns||[])[t],name:e},...(s.rankedRegexPatterns||[]).slice(t+1)]}))},onScoreChange:(e,t)=>
43{t1(s=>({...s,rankedRegexPatterns:[...(s.rankedRegexPatterns||[]).slice(0,t),{...(s.rankedRegexPatterns||[])[t],score:e},...(s.rankedRegexPatterns||[]).slice(t+1)]}))},...t9("syncedRankedRegexUrls")})]})]})}),(0,i.jsx)(nZ,{id:"filter-tab-bitrate",value:"bitrate",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Bitrate"}),(0,i.jsx)("div",{className:"mb-4",children:(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Set minimum and maximum bitrate limits for movies, series, and anime series. You can set a global limit, and also choose to set specific limits for each resolution. For a given stream, only one set of bitrate filters would be used. A resolution specific limit takes priority. Anime series limits take precedence over regular series limits."})}),(0,i.jsx)(lB,{intent:"warning",className:"mb-4",title:"Bitrate Accuracy",description:"Bitrate values are estimates calculated from file size and duration. These represent average bitrates and may not reflect peak bitrates or exact encoding quality."}),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)("div",{className:"rounded-[--radius-md] border bg-[--background] p-4",children:(0,i.jsx)(ni,{label:"Use Runtime from Metadata Providers",side:"right",help:"When enabled, uses runtime data from metadata providers (like TMDB) for bitrate calculations as fallback. Note: This makes estimates less accurate as actual file durations often differ from metadata, and most files lack duration info, making sorting by bitrate similar to sorting by size.",value:(null==(ez=t0.bitrate)?void 0:ez.useMetadataRuntime)??!0,onValueChange:e=>{t1(t=>({...t,bitrate:{...t.bitrate,useMetadataRuntime:e}}))}})}),(0,i.jsx)(mK,{title:"Global",description:"Apply bitrate filters for movies, series, and anime series",children:(0,i.jsx)(x2,{label:"Global Bitrate Limits",help:"Set the minimum and maximum bitrate limits for all results",moviesValue:((null==(eq=t0.bitrate)||null==(eV=eq.global)?void 0:eV.movies)||[0,25e7]).map(e=>Math.min(e,25e7)),seriesValue:((null==(eK=t0.bitrate)||null==(eB=eK.global)?void 0:eB.series)||[0,25e7]).map(e=>Math.min(e,25e7)),animeValue:((null==(eW=t0.bitrate)||null==(eH=eW.global)?void 0:eH.anime)||[0,25e7]).map(e=>Math.min(e,25e7)),onMoviesChange:e=>{t1(t=>{var s;return{...t,bitrate:{...t.bitrate,global:{...null==(s=t.bitrate)?void 0:s.global,movies:e}}}})},onSeriesChange:e=>{t1(t=>{var s;return{...t,bitrate:{...t.bitrate,global:{...null==(s=t.bitrate)?void 0:s.global,series:e}}}})},onAnimeChange:e=>{t1(t=>{var s;return{...t,bitrate:{...t.bitrate,global:{...null==(s=t.bitrate)?void 0:s.global,anime:e}}}})}})}),"pro"===tX&&(0,i.jsx)(mK,{title:"Resolution-Specific",description:"Set bitrate limits for specific resolutions",children:(0,i.jsx)("div",{className:"space-y-8",children:ak.map(e=>{var t,s,a,r,n,l,o,d,c;return(0,i.jsx)(x2,{label:e,help:`Set the minimum and maximum bitrate for ${e} results`,moviesValue:((null==(a=t0.bitrate)||null==(s=a.resolution)||null==(t=s[e])?void 0:t.movies)||[0,25e7]).map(e=>Math.min(e,25e7)),seriesValue:((null==(l=t0.bitrate)||null==(n=l.resolution)||null==(r=n[e])?void 0:r.series)||[0,25e7]).map(e=>Math.min(e,25e7)),animeValue:((null==(c=t0.bitrate)||null==(d=c.resolution)||null==(o=d[e])?void 0:o.anime)||[0,25e7]).map(e=>Math.min(e,25e7)),onMoviesChange:t=>{t1(s=>{var a,r,n;return{...s,bitrate:{...s.bitrate,resolution:{...null==(a=s.bitrate)?void 0:a.resolution,[e]:{...null==(n=s.bitrate)||null==(r=n.resolution)?void 0:r[e],movies:t}}}}})},onSeriesChange:t=>{t1(s=>{var a,r,n;return{...s,bitrate:{...s.bitrate,resolution:{...null==(a=s.bitrate)?void 0:a.resolution,[e]:{...null==(n=s.bitrate)||null==(r=n.resolution)?void 0:r[e],series:t}}}}})},onAnimeChange:t=>{t1(s=>{var a,r,n;return{...s,bitrate:{...s.bitrate,resolution:{...null==(a=s.bitrate)?void 0:a.resolution,[e]:{...null==(n=s.bitrate)||null==(r=n.resolution)?void 0:r[e],anime:t}}}}})}},e)})})})]})]})}),(0,i.jsx)(nZ,{id:"filter-tab-size",value:"size",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Size"}),(0,i.jsx)("div",{className:"mb-4",children:(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Set minimum and maximum size limits for movies, series, and anime series. You can set a global limit, and also choose to set specific limits for each resolution. For a given stream, only one set of size filters would be used. A resolution specific limit takes priority. Anime series limits take precedence over regular series limits."})}),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(mK,{title:"Global",description:"Apply size filters for movies, series, and anime series",children:(0,i.jsx)(x1,{label:"Global Size Limits",help:"Set the minimum and maximum size limits for all results",moviesValue:(null==(eY=t0.size)||null==(eG=eY.global)?void 0:eG.movies)||[0,1e11],seriesValue:(null==(eZ=t0.size)||null==(eJ=eZ.global)?void 0:eJ.series)||[0,1e11],animeValue:(null==(eX=t0.size)||null==(eQ=eX.global)?void 0:eQ.anime)||[0,1e11],onMoviesChange:e=>{t1(t=>{var s;return{...t,size:{...t.size,global:{...null==(s=t.size)?void 0:s.global,movies:e}}}})},onSeriesChange:e=>{t1(t=>{var s;return{...t,size:{...t.size,global:{...null==(s=t.size)?void 0:s.global,series:e}}}})},onAnimeChange:e=>{t1(t=>{var s;return{...t,size:{...t.size,global:{...null==(s=t.size)?void 0:s.global,anime:e}}}})}})}),"pro"===tX&&(0,i.jsx)(mK,{title:"Resolution-Specific",description:"Set size limits for specific resolutions",children:(0,i.jsx)("div",{className:"space-y-8",children:ak.map(e=>{var t,s,a,r,n,l,o,d,c;return(0,i.jsx)(x1,{label:e,help:`Set the minimum and maximum size for ${e} results`,moviesValue:(null==(a=t0.size)||null==(s=a.resolution)||null==(t=s[e])?void 0:t.movies)||[0,1e11],seriesValue:(null==(l=t0.size)||null==(n=l.resolution)||null==(r=n[e])?void 0:r.series)||[0,1e11],animeValue:(null==(c=t0.size)||null==(d=c.resolution)||null==(o=d[e])?void 0:o.anime)||[0,1e11],onMoviesChange:t=>{t1(s=>{var a,r,n;return{...s,size:{...s.size,resolution:{...null==(a=s.size)?void 0:a.resolution,[e]:{...null==(n=s.size)||null==(r=n.resolution)?void 0:r[e],movies:t}}}}})},onSeriesChange:t=>{t1(s=>{var a,r,n;return{...s,size:{...s.size,resolution:{...null==(a=s.size)?void 0:a.resolution,[e]:{...null==(n=s.size)||null==(r=n.resolution)?void 0:r[e],series:t}}}}})},onAnimeChange:t=>{t1(s=>{var a,r,n;return{...s,size:{...s.size,resolution:{...null==(a=s.size)?void 0:a.resolution,[e]:{...null==(n=s.size)||null==(r=n.resolution)?void 0:r[e],anime:t}}}}})}},e)})})})]})]})}),(0,i.jsx)(nZ,{id:"filter-tab-limit",value:"limit",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Result Limits"}),(0,i.jsx)(mK,{description:"Apply limits to specific kinds of results",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(nc,{label:"Limit Mode",help:"Independent: each category limit is checked separately. Conjunctive: category limits are combined into a composite key (e.g. 3 per resolution per addon).",value:(null==(e0=t0.resultLimits)?void 0:e0.mode)??"independent",onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,mode:e}}))},options:[{label:"Independent",value:"independent"},{label:"Conjunctive",value:"conjunctive"}]}),(0,i.jsx)(lm,{help:"Global limit for all results",label:"Global Limit",value:(null==(e1=t0.resultLimits)?void 0:e1.global)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,global:e||void 0}}))}}),"pro"===tX&&(0,i.jsx)(lm,{help:"Limit for results by service",label:"Service Limit",value:(null==(e2=t0.resultLimits)?void 0:e2.service)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,service:e||void 0}}))}}),"pro"===tX&&(0,i.jsx)(lm,{help:"Limit for results by addon",label:"Addon Limit",value:(null==(e3=t0.resultLimits)?void 0:e3.addon)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,addon:e||void 0}}))}}),(0,i.jsx)(lm,{help:"Limit for results by resolution",label:"Resolution Limit",value:(null==(e5=t0.resultLimits)?void 0:e5.resolution)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,resolution:e||void 0}}))}}),"pro"===tX&&(0,i.jsx)(lm,{help:"Limit for results by quality",label:"Quality Limit",value:(null==(e4=t0.resultLimits)?void 0:e4.quality)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,quality:e||void 0}}))}}),"pro"===tX&&(0,i.jsx)(lm,{help:"Limit for results by indexer",label:"Indexer Limit",value:(null==(e6=t0.resultLimits)?void 0:e6.indexer)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,indexer:e||void 0}}))}}),"pro"===tX&&(0,i.jsx)(lm,{help:"Limit for results by release group",label:"Release Group Limit",value:(null==(e9=t0.resultLimits)?void 0:e9.releaseGroup)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,releaseGroup:e||void 0}}))}})]})})]})}),(0,i.jsx)(nZ,{id:"filter-tab-deduplicator",value:"deduplicator",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Deduplicator"}),(0,i.jsx)("div",{className:"mb-4",children:(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Enable and customise the removal of duplicate results."})}),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(mK,{children:(0,i.jsx)(ni,{label:"Enable",side:"right",value:(null==(e8=t0.deduplicator)?void 0:e8.enabled)??!1,onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,enabled:e}}))}})}),"pro"===tX&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(mK,{title:"Group Handling",description:(0,i.jsx)("div",{children:"Sets of duplicates are separated into groups based on the streams' type. (e.g. cached, uncached, p2p, etc.) These options control how each set of duplicates are handled."}),children:[(0,i.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{className:"font-medium",children:"Single Result"}),(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"Keeps only one result from your highest priority service and highest priority addon. Enabled tiebreakers (torrent seeders, usenet age) are applied at the position configured below - either before or after addon order is considered."})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{className:"font-medium",children:"Per Service"}),(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"This keeps one result per service, and choses each result using the same criteria above."})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{className:"font-medium",children:"Per Addon"}),(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"This keeps one result per addon, and choses each result from your highest priority service, and for P2P/uncached results it looks at the number of seeders."})]})]}),(0,i.jsx)(nc,{disabled:!(null==(e7=t0.deduplicator)?void 0:e7.enabled),label:"Cached Results",value:(null==(te=t0.deduplicator)?void 0:te.cached)??"disabled",options:[{label:"Disabled",value:"disabled"},{label:"Single Result",value:"single_result"},{label:"Per Service",value:"per_service"},{label:"Per Addon",value:"per_addon"}],onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,cached:e}}))}}),(0,i.jsx)(nc,{disabled:!(null==(tt=t0.deduplicator)?void 0:tt.enabled),label:"Uncached Results",value:(null==(ts=t0.deduplicator)?void 0:ts.uncached)??"disabled",options:[{label:"Disabled",value:"disabled"},{label:"Single Result",value:"single_result"},{label:"Per Service",value:"per_service"},{label:"Per Addon",value:"per_addon"}],onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,uncached:e}}))}}),(0,i.jsx)(nc,{disabled:!(null==(ta=t0.deduplicator)?void 0:ta.enabled),label:"P2P Results",value:(null==(tr=t0.deduplicator)?void 0:tr.p2p)??"disabled",options:[{label:"Disabled",value:"disabled"},{label:"Single Result",value:"single_result"},{label:"Per Service",value:"per_service"},{label:"Per Addon",value:"per_addon"}],onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,p2p:e}}))}})]}),(0,i.jsxs)(mK,{title:"Other",children:[(0,i.jsx)(li,{disabled:!(null==(tn=t0.deduplicator)?void 0:tn.enabled),label:"Detection Methods",multiple:!0,help:"Select the methods used to detect duplicates",value:(null==(tl=t0.deduplicator)?void 0:tl.keys)??["filename","
43infoHash"],emptyMessage:"No detection methods available",onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,keys:e}}))},options:ag.map(e=>({label:e,value:e}))}),((null==(ti=t0.deduplicator)?void 0:ti.keys)??["filename","infoHash"]).includes("smartDetect")&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(li,{disabled:!(null==(to=t0.deduplicator)?void 0:to.enabled),label:"Smart Detect Attributes",multiple:!0,help:"Choose which file attributes are used to identify duplicates when Smart Detect is enabled. Numeric attributes (size, bitrate) use a configurable percentage tolerance.",value:(null==(td=t0.deduplicator)?void 0:td.smartDetectAttributes)??av,emptyMessage:"No attributes available",onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,smartDetectAttributes:e}}))},options:ab.map(e=>({label:e,value:e}))}),["size","bitrate"].some(e=>{var t;return((null==(t=t0.deduplicator)?void 0:t.smartDetectAttributes)??av).includes(e)})&&(0,i.jsx)(lm,{disabled:!(null==(tc=t0.deduplicator)?void 0:tc.enabled),label:"Numeric Rounding (%)",help:"Numeric attributes (size, bitrate) are bucketed using geometric rounding at this tolerance. Two values within roughly this percentage of each other are treated as equal. Higher = more lenient; lower = stricter.",min:1,max:50,step:1,value:(null==(tu=t0.deduplicator)?void 0:tu.smartDetectRounding)??10,onValueChange:e=>{void 0!==e&&t1(t=>({...t,deduplicator:{...t.deduplicator,smartDetectRounding:e}}))}})]}),(0,i.jsx)(li,{help:"Addons selected here will always have their results kept during deduplication.",label:"Addon Exclusions",value:(null==(tm=t0.deduplicator)?void 0:tm.excludeAddons)??[],onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,excludeAddons:e}}))},options:t0.presets.map(e=>({label:e.options.name||e.type,value:e.instanceId,textValue:e.options.name})),emptyMessage:"You haven't installed any addons...",placeholder:"Select addons...",multiple:!0,disabled:(null==(th=t0.deduplicator)?void 0:th.enabled)===!1}),(0,i.jsx)(nc,{label:"Multi-Group Behaviour",help:`Configure how duplicates across multiple types are handled. e.g. if a given duplicate set has both cached and uncached streams, what should be done. 44 ${gl[(null==(tp=t0.deduplicator)?void 0:tp.multiGroupBehaviour)||gi]} 45 `,value:(null==(tx=t0.deduplicator)?void 0:tx.multiGroupBehaviour)??gi,onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,multiGroupBehaviour:e}}))},disabled:!(null==(tg=t0.deduplicator)?void 0:tg.enabled),options:[{label:"Conservative",value:"conservative"},{label:"Aggressive",value:"aggressive"},{label:"Keep All",value:"keep_all"}]}),(0,i.jsx)(nc,{label:"Library Stream Behaviour",help:"How to treat library streams when duplicates are found. 'Ignore': library streams have no special priority â normal service/addon order decides. 'Prefer': a library stream always beats a non-library stream head-to-head, even if the non-library stream is from a higher-priority addon. Other tiebreakers still apply between two library streams. 'Exclusive': if the group contains any library stream, all non-library streams are dropped before selection runs â only meaningful with Per Service or Per Addon modes where multiple winners are kept.",value:(null==(tf=t0.deduplicator)?void 0:tf.libraryBehaviour)??"ignore",onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,libraryBehaviour:e}}))},disabled:!(null==(tb=t0.deduplicator)?void 0:tb.enabled),options:[{label:"Ignore",value:"ignore"},{label:"Prefer",value:"prefer"},{label:"Exclusive",value:"exclusive"}]}),af.map(e=>{var t,s;let a=((null==(t=t0.deduplicator)?void 0:t.tiebreakers)??[{type:"torrent_seeders",position:"before_addon"},{type:"usenet_age",position:"before_addon"}]).find(t=>t.type===e),r=(null==a?void 0:a.position)??"disabled";return(0,i.jsx)(nc,{disabled:!(null==(s=t0.deduplicator)?void 0:s.enabled),label:"torrent_seeders"===e?"Torrent Seeders Tiebreaker":"Usenet Age Tiebreaker",help:"torrent_seeders"===e?"When choosing between duplicate P2P or uncached streams, prefer the one with more seeders. Controls where in the priority order this check runs relative to addon order.":"When choosing between duplicate Usenet streams, prefer the newer post (posts released within the last 24 hours are considered equal). Controls where in the priority order this check runs relative to addon order.",value:r??"before_addon",onValueChange:t=>{t1(s=>{var a;let r=((null==(a=s.deduplicator)?void 0:a.tiebreakers)??[{type:"torrent_seeders",position:"before_addon"},{type:"usenet_age",position:"after_addon"}]).filter(t=>t.type!==e),n="disabled"===t?r:[...r,{type:e,position:t}];return{...s,deduplicator:{...s.deduplicator,tiebreakers:n}}})},options:[{label:"Disabled",value:"disabled"},{label:"Before Addon Order",value:"before_addon"},{label:"After Addon Order",value:"after_addon"}]},e)})]}),(0,i.jsxs)(mK,{title:"Merge Duplicates",description:"Instead of just discarding duplicates, fold their info into the surviving result: extra same-release failover targets and richer metadata from other addons.",children:[(0,i.jsx)(ni,{label:"Enable Merging",side:"right",disabled:!(null==(tv=t0.deduplicator)?void 0:tv.enabled),value:(null==(tw=t0.deduplicator)||null==(ty=tw.merge)?void 0:ty.enabled)??!1,onValueChange:e=>{t1(t=>{var s;return{...t,deduplicator:{...t.deduplicator,merge:{...null==(s=t.deduplicator)?void 0:s.merge,enabled:e}}}})}}),(0,i.jsx)(ni,{label:"Harvest Failover Variants",side:"right",help:"Collect discarded duplicates' playback URLs as same-release failover targets, so failover can try another copy of the SAME release (e.g. a different indexer's NZB) before moving to a different release. Follows your Failover content-type settings.",disabled:!(null==(tN=t0.deduplicator)?void 0:tN.enabled)||!(null==(tS=t0.deduplicator)||null==(tk=tS.merge)?void 0:tk.enabled),value:(null==(t_=t0.deduplicator)||null==(tC=t_.merge)?void 0:tC.failoverVariants)??!1,onValueChange:e=>{t1(t=>{var s;return{...t,deduplicator:{...t.deduplicator,merge:{...null==(s=t.deduplicator)?void 0:s.merge,failoverVariants:e}}}})}}),(0,i.jsx)(li,{label:"Merged Metadata Fields",multiple:!0,help:"Which metadata to merge from discarded duplicates into the kept result. Languages/subtitles are merged accuracy-aware: an addon's accurate audio/subtitle split is never overwritten by inaccurate filename-parsed guesses.",disabled:!(null==(tA=t0.deduplicator)?void 0:tA.enabled)||!(null==(tT=t0.deduplicator)||null==(tR=tT.merge)?void 0:tR.enabled),value:(null==(tE=t0.deduplicator)||null==(tI=tE.merge)?void 0:tI.fields)??[],emptyMessage:"No fields available",onValueChange:e=>{t1(t=>{var s;return{...t,deduplicator:{...t.deduplicator,merge:{...null==(s=t.deduplicator)?void 0:s.merge,fields:e}}}})},options:sB.map(e=>({label:e,value:e}))})]})]})]})]})}),(0,i.jsx)(nZ,{id:"filter-tab-miscellaneous",value:"miscellaneous",className:"space-y-4",children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(gn,{heading:"Miscellaneous"}),(0,i.jsx)("div",{className:"mb-4",children:(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Additional miscellaneous filters."})}),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)(mK,{id:"digitalReleaseFilter",title:"Digital Release Filter",description:"Filters out movies, series, and anime that haven't released yet, based on release dates (movies) or episode air dates (series/anime).",children:[(0,i.jsx)(ni,{label:"Enabled",side:"right",value:(null==(tM=t0.digitalReleaseFilter)?void 0:tM.enabled)??!1,onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter||{},enabled:e}}))}}),(0,i.jsxs)("div",{className:"flex gap-4",children:[(0,i.jsx)("div",{className:"flex-1",children:(0,i.jsx)(x$,{label:"Tolerance",moreHelp:"Ignore the digital release filter if the movie was released within this many days of the current date. This accounts for early releases, leaks, and server timezone differences.",disabled:!(null==(tP=t0.digitalReleaseFilter)?void 0:tP.enabled),value:[(null==(t$=t0.digitalReleaseFilter)?void 0:t$.tolerance)??0],min:0,max:365,step:1,defaultValue:[0],onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,tolerance:e[0]}}))}})}),(0,i.jsx)("div",{className:"w-24",children:(0,i.jsx)(lm,{label:"Value",step:1,value:(null==(tD=t0.digitalReleaseFilter)?void 0:tD.tolerance)??0,min:0,max:365,disabled:!(null==(tL=t0.digitalReleaseFilter)?void 0:tL.enabled),onValueChange:e=>{void 0!==e&&t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,tolerance:e}}))}})})]}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Tolerance in days"}),(0,i.jsx)(ni,{label:"Also Check Result Age",side:"right",disabled:!(null==(tO=t0.digitalReleaseFilter)?void 0:tO.enabled),value:(null==(tU=t0.digitalReleaseFilter)?void 0:tU.checkResultAge)??!1,moreHelp:"Blocks results uploaded before the release/air date (beyond tolerance). Only works when a result's age is known.",onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,checkResultAge:e}}))}}),(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,i.jsx)(li,{multiple:!0,disabled:!(null==(tF=t0.digitalReleaseFilter)?void 0:tF.enabled),label:"Request Types",emptyMessage:"There aren't any request types to choose from...",help:"Request types that will use the digital release filter. Leave blank to apply to all request types.",options:aL.map(e=>({label:e,value:e,textValue:e})),value:null==(tz=t0.digitalReleaseFilter)?void 0:tz.requestTypes,onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,requestTypes:e}}))}}),(0,i.jsx)(li,{multiple:!0,disabled:!(null==(tV=t0.digitalReleaseFilter)?void 0:tV.enabled),label:"Addons",help:"Addons that will use the digital release filter. Leave blank to apply to all addons.",emptyMessage:"You haven't installed any addons yet...",options:t0.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(tq=t0.digitalReleaseFilter)?void 0:tq.addons)||[],onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,addons:e}}))}})]})}),(0,i.jsx)(ni,{label:"Show Info Stream When Filtered",side:"right",defaultValue:!0,disabled:!(null==(tB=t0.digitalReleaseFilter)?void 0:tB.enabled),value:(null==(tK=t0.digitalReleaseFilter)?void 0:tK.showInfoOnFilter)??!0,moreHelp:"When the digital release filter triggers, show an info stream.",onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,showInfoOnFilter:e}}))}})]}),(0,i.jsx)(mK,{id:"enableSeadex",title:"SeaDex Integration",description:"Fetch SeaDex data (releases.moe) for anime to identify best quality releases.",children:(0,i.jsx)(ni,{label:"Enable",side:"right",value:t0.enableSeadex??!0,defaultValue:!0,onValueChange:e=>{t1(t=>({...t,enableSeadex:e}))}})}),(null==tQ?void 0:tQ.settings.remuxdb.enabled)&&(0,i.jsx)(mK,{id:"remuxDb",title:"RemuxDB Integration",description:"Fill in missing audio and subtitle languages, channels, HDR and resolution from RemuxDB's database of probed files. Each lookup sends the title's IMDb ID (and season and episode) to RemuxDB. Usenet results can only be matched when they come from the Newznab addon: NZBHydra and Prowlarr replace the indexer's NZB link with their own, so the NZB's ID can't be read from it.",children:(0,i.jsx)(ni,{label:"Enable",side:"right",value:(null==(tH=t0.remuxDb)?void 0:tH.enabled)??!1,onValueChange:e=>{t1(t=>({...t,remuxDb:{...t.remuxDb,enabled:e}}))}})}),"pro"===tX&&t0.excludeSeasonPacks&&(0,i.jsx)(mK,{id:"excludeSeasonPacks",title:"Exclude Season Packs",de
45scription:"Whether to filter out results that contain entire seasons.",children:(0,i.jsx)(ni,{label:"Enable",side:"right",value:t0.excludeSeasonPacks,onValueChange:e=>{t1(t=>({...t,excludeSeasonPacks:e}))}})})]})]})})]})]}),(0,i.jsx)(sl,{open:t5.isOpen,onOpenChange:t5.close,title:"Allowed Regex Patterns",description:"These are regex patterns that you are allowed to use in your filters.",children:(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsx)("div",{className:"border rounded-md bg-gray-900 border-gray-800 p-4 max-h-96 overflow-auto",children:(0,i.jsxs)("div",{className:"space-y-2",children:[null==tQ||null==(tW=tQ.settings.regexAccess.patterns)?void 0:tW.map((e,t)=>(0,i.jsx)("div",{className:"font-mono text-sm bg-gray-800 rounded px-3 py-2 break-all whitespace-pre-wrap",children:e},t)),(!(null==tQ?void 0:tQ.settings.regexAccess.patterns)||0===tQ.settings.regexAccess.patterns.length)&&(0,i.jsx)("div",{className:"text-muted-foreground text-sm text-center",children:"No allowed regex patterns configured"})]})})})}),(0,i.jsx)(sl,{open:t6.isOpen,onOpenChange:t6.close,title:"Whitelisted Sync URLs",description:"These are URLs that are whitelisted for syncing stream expressions.",children:(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsx)("div",{className:"border rounded-md bg-gray-900 border-gray-800 p-4 max-h-96 overflow-auto",children:(0,i.jsxs)("div",{className:"space-y-2",children:[null==tQ||null==(tG=tQ.settings.selSyncAccess.trustedUrls)?void 0:tG.map((e,t)=>(0,i.jsxs)("div",{className:"flex items-center gap-2 font-mono text-sm bg-gray-800 rounded px-3 py-2",children:[(0,i.jsx)("div",{className:"flex-1 break-all whitespace-pre-wrap",children:e}),(0,i.jsx)(w,{size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(lZ.zU_,{}),onClick:()=>nf(e,{onSuccess:()=>m.oR.success("URL copied to clipboard"),onError:()=>m.oR.error("Failed to copy URL")})})]},t)),(!(null==tQ?void 0:tQ.settings.selSyncAccess.trustedUrls)||0===tQ.settings.selSyncAccess.trustedUrls.length)&&(0,i.jsx)("div",{className:"text-muted-foreground text-sm text-center",children:"No whitelisted sync URLs configured"})]})})})}),(0,i.jsx)(sl,{open:t4.isOpen,onOpenChange:t4.close,title:"Allowed Regex Pattern URLs",description:"These are URLs that you can import regex patterns from.",children:(0,i.jsx)("div",{className:"space-y-4",children:(0,i.jsx)("div",{className:"border rounded-md bg-gray-900 border-gray-800 p-4 max-h-96 overflow-auto",children:(0,i.jsxs)("div",{className:"space-y-2",children:[null==tQ||null==(tY=tQ.settings.regexAccess.urls)?void 0:tY.map((e,t)=>(0,i.jsxs)("div",{className:"flex items-center gap-2 font-mono text-sm bg-gray-800 rounded px-3 py-2",children:[(0,i.jsx)("div",{className:"flex-1 break-all whitespace-pre-wrap",children:e}),(0,i.jsx)(w,{size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(lZ.zU_,{}),onClick:()=>nf(e,{onSuccess:()=>m.oR.success("URL copied to clipboard"),onError:()=>m.oR.error("Failed to copy URL")})})]},t)),(!(null==tQ?void 0:tQ.settings.regexAccess.urls)||0===tQ.settings.regexAccess.urls.length)&&(0,i.jsx)("div",{className:"text-muted-foreground text-sm text-center",children:"No allowed regex pattern URLs configured"})]})})})})]})}var gh=s(39114),gp=s(90571),gx=s(17328),gg=s(71972),gf=s(15498),gb=s(70339),gv=s(9413);let gy={global:"Global",movies:"Movies",series:"Series",anime:"Anime",cached:"Global Cached",uncached:"Global Uncached",cachedMovies:"Movie Cached",uncachedMovies:"Movie Uncached",cachedSeries:"Series Cached",uncachedSeries:"Series Uncached",cachedAnime:"Anime Cached",uncachedAnime:"Anime Uncached"};function gj(e,t){var s;return(null==(s=e.sortCriteria)?void 0:s[t])??[]}function gw(e){let{id:t,name:s,description:a,direction:r,onDirectionChange:n}=e,{attributes:l,listeners:o,setNodeRef:d,transform:c,transition:u,isDragging:m}=(0,lG.gl)({id:t}),h={transform:lJ.Ks.Transform.toString(c),transition:u,opacity:m?.5:1};return(0,i.jsx)("div",{ref:d,style:h,children:(0,i.jsxs)("div",{className:"px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 relative",children:[(0,i.jsx)("div",{className:"rounded-full w-6 h-auto bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move",...l,...o}
45),(0,i.jsxs)("div",{className:"flex-1 flex flex-col justify-center min-w-0",children:[(0,i.jsx)("span",{className:"font-mono text-base truncate",children:s}),(0,i.jsx)("span",{className:"text-[--muted] text-sm truncate",children:a})]}),(0,i.jsx)(w,{size:"sm",rounded:!0,icon:"asc"===r?(0,i.jsx)(gh.A,{}):(0,i.jsx)(gp.A,{}),intent:"primary-subtle",onClick:n})]})})}function gN(e){let{sortKey:t,inheritedFrom:s}=e,{userData:a,setUserData:r}=ri(),[n,l]=(0,u.useState)(!1),o=gj(a,t),d=(0,lW.FR)((0,lW.MS)(lW.AN),(0,lW.MS)(lW.IG,{activationConstraint:{delay:150,tolerance:8}}));function c(e){r(s=>({...s,sortCriteria:{...s.sortCriteria||{},[t]:e}}))}return(0,u.useEffect)(()=>{function e(e){n&&e.preventDefault()}return n?document.body.addEventListener("touchmove",e,{passive:!1}):document.body.removeEventListener("touchmove",e),()=>document.body.removeEventListener("touchmove",e)},[n]),(0,i.jsxs)("div",{className:"space-y-2",children:[0===o.length&&s&&(0,i.jsxs)("p",{className:"text-xs text-[--muted] italic",children:["Empty â using"," ",(0,i.jsx)("span",{className:"not-italic text-[--foreground]",children:s})," ","as fallback. Add criteria below to override."]}),0===o.length&&!s&&(0,i.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No criteria defined yet."}),(0,i.jsx)(li,{multiple:!0,value:o.map(e=>e.key),emptyMessage:"No sort criteria available",onValueChange:e=>{c(e.map(e=>o.find(t=>t.key===e)??{key:e,direction:aI[e].defaultDirection}))},options:aT.map(e=>({label:aI[e].name,textValue:aI[e].name,value:e}))}),o.length>0&&(0,i.jsx)(lW.Mp,{modifiers:[lY.FN],onDragEnd:function(e){let{active:t,over:s}=e;
45if(s&&t.id!==s.id){let e=o.findIndex(e=>`${e.key}-${e.direction}`===t.id),a=o.findIndex(e=>`${e.key}-${e.direction}`===s.id);c((0,lG.be)(o,e,a))}l(!1)},onDragStart:()=>l(!0),sensors:d,children:(0,i.jsx)(lG.gB,{items:o.map(e=>`${e.key}-${e.direction}`),strategy:lG._G,children:(0,i.jsx)("div",{className:"space-y-2",children:o.map(e=>(0,i.jsx)(gw,{id:`${e.key}-${e.direction}`,name:aI[e.key].name,description:"asc"===e.direction?`${aI[e.key].description}, ${aI[e.key].ascendingDescription}`:`${aI[e.key].description}, ${aI[e.key].descendingDescription}`,direction:e.direction,onDirectionChange:()=>{let t="asc"===e.direction?"desc":"asc";c(o.map(s=>s.key===e.key?{...s,direction:t}:s))}},`${e.key}-${e.direction}`))})})})]})}function gk(e){let{items:t}=e;if(0===t.length)return null;let s=t.slice(0,3);return(0,i.jsxs)("span",{className:"flex flex-wrap items-center gap-1",children:[s.map(e=>(0,i.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-[--subtle] text-[--muted] border border-[--border]",children:aI[e.key].name},e.key)),t.length>3&&(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:["+",t.length-3]})]})}function gS(e){let{sortKey:t}=e;return(0,i.jsx)("span",{className:x("text-xs px-1.5 py-0.5 rounded border font-medium shrink-0","global"===t||"cached"===t||"uncached"===t?"bg-violet-500/10 text-violet-400 border-violet-500/20":"bg-blue-500/10 text-blue-300 border-blue-400/20"),children:gy[t]})}function gC(){let{userData:e}=ri(),t=[{type:"movie",label:"Movies",icon:(0,i.jsx)(gx.A,{className:"w-3.5 h-3.5"})},{type:"series",label:"Series",icon:(0,i.jsx)(gg.A,{className:"w-3.5 h-3.5"})},{type:"anime",label:"Anime",icon:(0,i.jsx)(gf.A,{className:"w-3.5 h-3.5"})}];return(0,i.jsx)(mK,{title:"Active Sort Configuration",description:"The sort orders that will actually be applied for each content type.",children:(0,i.jsx)("div",{className:"divide-y divide-[--border]",children:t.map(t=>{let{type:s,label:a,icon:r}=t,n=function(e,t){var s,a,r,n,l,i,o,d,c,u,m,h,p,x,g,f,b;let v=e.sortCriteria;if(!v)return{primaryKey:"global",primary:[],cachedKey:null,uncachedKey:null,cachedItems:[],uncachedItems:[],splitActive:!1};let y="global",j=(null==(s=v.cached)?void 0:s.length)?"cached":null,w=(null==(a=v.uncached)?void 0:a.length)?"uncached":null;"movie"===t?((null==(r=v.movies)?void 0:r.length)&&(y="movies"),(null==(n=v.cachedMovies)?void 0:n.length)?j="cachedMovies":(null==(l=v.cached)?void 0:l.length)&&(j="cached"),(null==(i=v.uncachedMovies)?void 0:i.length)?w="uncachedMovies":(null==(o=v.uncached)?void 0:o.length)&&(w="uncached")):"series"===t?((null==(d=v.series)?void 0:d.length)&&(y="series"),(null==(c=v.cachedSeries)?void 0:c.length)?j="cachedSeries":(null==(u=v.cached)?void 0:u.length)&&(j="cached"),(null==(m=v.uncachedSeries)?void 0:m.length)?w="uncachedSeries":(null==(h=v.uncached)?void 0:h.length)&&(w="uncached")):((null==(p=v.anime)?void 0:p.length)&&(y="anime"),(null==(x=v.cachedAnime)?void 0:x.length)?j="cachedAnime":(null==(g=v.cached)?void 0:g.length)&&(j="cached"),(null==(f=v.uncachedAnime)?void 0:f.length)?w="uncachedAnime":(null==(b=v.uncached)?void 0:b.length)&&(w="uncached"));let N=gj(e,y),k=N.length>0&&"cached"===N[0].key&&null!==j&&null!==w,S=j?gj(e,j):[],C=w?gj(e,w):[];return{primaryKey:y,primary:N,cachedKey:j,uncachedKey:w,cachedItems:S,uncachedItems:C,splitActive:k}}(e,s);return(0,i.jsxs)("div",{className:"py-3 first:pt-0 last:pb-0 space-y-2",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,i.jsx)("span",{className:"text-[--muted]",children:r}),a,n.splitActive&&(0,i.jsxs)("span",{className:"flex items-center gap-0.5 text-xs font-normal text-green-400",children:[(0,i.jsx)(xw.A,{className:"w-3 h-3"}),"split"]})]}),n.splitActive?(0,i.jsx)("div",{className:"ml-5 space-y-1.5",children:[{dot:"bg-green-400",label:"Cached",key:n.cachedKey,items:n.cachedItems},{dot:"bg-yellow-400",label:"Uncached",key:n.uncachedKey,items:n.uncachedItems}].map(e=>{let{dot:t,label:s,key:a,items:r}=e;return(0,i.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,i.jsx)("span",{className:x("w-1.5 h-1.5 rounded-full shrink-0",t)}),(0,i.jsx)(gS,{sortKey:a}),r.length>0&&(0,i.jsx)("span",{className:"text-[--muted] text-xs shrink-0",children:"â"}),(0,i.jsx)(gk,{items:r}),0===r.length&&(0,i.jsx)("span",{className:"text-xs text-[--muted] italic",children:"no criteria defined"})]},s)})}):(0,i.jsxs)("div",{className:"ml-5 flex items-center gap-1.5 flex-wrap",children:[(0,i.jsx)(gS,{sortKey:n.primaryKey}),n.primary.length>0&&(0,i.jsx)("span",{className:"text-[--muted] text-xs shrink-0",children:"â"}),(0,i.jsx)(gk,{items:n.primary}),0===n.primary.length&&(0,i.jsx)("span",{className:"text-xs text-[--muted] italic",children:"no criteria defined"})]}),!n.splitActive&&(n.cachedKey||n.uncachedKey)&&(0,i.jsxs)("div",{className:"ml-5 flex items-start gap-1.5 text-xs text-yellow-400/80",children:[(0,i.jsx)(gb.A,{className:"w-3.5 h-3.5 shrink-0 mt-px"}),(0,i.jsxs)("span",{children:["Cached sorts are defined but inactive â make"," ",(0,i.jsx)("span",{className:"text-yellow-400",children:"Cached"})," the first primary criterion to enable split mode"]})]})]},s)})})})}let g_={global:{primaryKey:"global",cachedKey:"cached",uncachedKey:"uncached",primaryLabel:"Primary Sort Order",primaryDescription:"The default sort applied to all content. Movie, Series, and Anime tabs can each define their own override."},movies:{primaryKey:"movies",cachedKey:"cachedMovies",uncachedKey:"uncachedMovies",primaryLabel:"Movie Primary Sort",primaryDescription:"Overrides the Global primary sort for movies. Leave empty to fall back to Global.",primaryInherit:"Global",cachedInherit:"Global Cached",uncachedInherit:"Global Uncached"},series:{primaryKey:"series",cachedKey:"cachedSeries",uncachedKey:"uncachedSeries",primaryLabel:"Series Primary Sort",primaryDescription:"Overrides the Global primary sort for series. Leave empty to fall back to Global.",primaryInherit:"Global",cachedInherit:"Global Cached",uncachedInherit:"Global Uncached"},anime:{primaryKey:"anime",cachedKey:"cachedAnime",uncachedKey:"uncachedAnime",primaryLabel:"Anime Primary Sort",primaryDescription:"Overrides the Global primary sort for anime. Leave empty to fall back to Global.",primaryInherit:"Global",cachedInherit:"Global Cached",uncachedInherit:"Global Uncached"}};function gA(e){let{type:t}=e,{userData:s}=ri(),a=g_[t],r=s.sortCriteria;function n(){var e;if("global"!==t)return((null==r||null==(e=r.cached)?void 0:e.length)??0)>0?"Global Cached":void 0}function l(){var e;if("global"!==t)return((null==r||null==(e=r.uncached)?void 0:e.length)??0)>0?"Global Uncached":void 0}return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(mK,{title:a.primaryLabel,description:a.primaryDescription,children:(0,i.jsx)(gN,{sortKey:a.primaryKey,inheritedFrom:a.primaryInherit})}),(0,i.jsx)(mK,{title:"Split by Cache",description:(0,i.jsxs)(i.Fragment,{children:["When ",(0,i.jsx)("strong",{children:'"Cached"'})," is the"," ",(0,i.jsx)("strong",{children:"first criterion"})," above and both sorts below are defined, cached and uncached streams are sorted independently then merged."]}),children:(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("div",{className:"w-2 h-2 rounded-full bg-green-400 shrink-0"}),(0,i.jsx)("span",{className:"text-sm font-medium",children:"Cached Streams"}),0===gj(s,a.cachedKey).length&&(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:n()?`â using ${n()} as fallback`:"â undefined, split requires this"})]}),(0,i.jsx)(gN,{sortKey:a.cachedKey,inheritedFrom:n()})]}),(0,i.jsx)("div",{className:"border-t border-[--border]"}),(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("div",{className:"w-2 h-2 rounded-full bg-yellow-400 shrink-0"}),(0,i.jsx)("span",{className:"text-sm font-medium",children:"Uncached Streams"}),0===gj(s,a.uncachedKey).length&&(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:l()?`â using ${l()} as fallback`:"â undefined, split requires this"})]}),(0,i.jsx)(gN,{sortKey:a.uncachedKey,inheritedFrom:l()})]})]})})]})}function gR(){return(0,i.jsx)(ng,{className:"space-y-4 p-4 sm:p-8",children:(0,i.jsx)(gT,{})})}function gT(){var e,t,s,a,r,n,l,o,d;let{userData:c,setUserData:m}=ri(),{isInherited:h,hasParent:p}=ro(),[x,g]=(0,u.useState)("global");(0,u.useEffect)(()=>{c.sortCriteria||m(e=>({...e,sortCriteria:{global:[],movies:[],series:[],anime:[],cached:[],uncached:[],cachedMovies:[],uncachedMovies:[],cachedSeries:[],uncachedSeries:[],cachedAnime:[],uncachedAnime:[]}}))},[]);let f=c.sortCriteria,b=((null==f||null==(e=f.movies)?void 0:e.length)??0)>0||((null==f||null==(t=f.cachedMovies)?void 0:t.length)??0)>0||((null==f||null==(s=f.uncachedMovies)?void 0:s.length)??0)>0,v=((null==f||null==(a=f.series)?void 0:a.length)??0)>0||((null==f||null==(r=f.cachedSeries)?void 0:r.length)??0)>0||((null==f||null==(n=f.uncachedSeries)?void 0:n.length)??0)>0,y=((null==f||null==(l=f.anime)?void 0:l.length)??0)>0||((null==f||null==(o=f.cachedAnime)?void 0:o.length)??0)>0||((null==f||null==(d=f.uncachedAnime)?void 0:d.length)??0)>0;function j(e,t){return(0,i.jsxs)("span",{className:"flex items-center gap-1.5",children:[e,t&&(0,i.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-blue-300 inline-block"})]})}return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex items-center w-full",children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("h2",{children:"Sorting"}),p&&h("sorting")&&(0,i.jsx)(my,{section:"sorting"})]}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Configure how your streams are sorted and organised."})]}),(0,i.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,i.jsx)(mg,{})})]}),(0,i.jsx)(gC,{}),(0,i.jsx)(mv,{tabs:[{value:"global",label:"Global",icon:(0,i.jsx)(gv.A,{className:"w-4 h-4"}),content:(0,i.jsx)(gA,{type:"global"})},{value:"movies",label:j("Movies",b),icon:(0,i.jsx)(gx.A,{className:"w-4 h-4"}
45),content:(0,i.jsx)(gA,{type:"movies"})},{value:"series",label:j("Series",v),icon:(0,i.jsx)(gg.A,{className:"w-4 h-4"}),content:(0,i.jsx)(gA,{type:"series"})},{value:"anime",label:j("Anime",y),icon:(0,i.jsx)(gf.A,{className:"w-4 h-4"}),content:(0,i.jsx)(gA,{type:"anime"})}],activeTab:x,onTabChange:g})]})}function gI(){var e,t,s,a,r,n,l;let{userData:o,setUserData:d}=ri(),{status:c}=tj(),u=null==c||null==(t=c.settings)||null==(e=t.limits)?void 0:e.maxBackgroundPings;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(mK,{title:"Pre-cache Next Episode",id:"precacheNextEpisode",description:(0,i.jsxs)(i.Fragment,{children:["Fetches the next episode's streams in the background and pings the URLs selected by the precache selector, triggering server-side caching before you click."," ",void 0!==u&&(0,i.jsxs)(i.Fragment,{children:["Up to ",(0,i.jsx)("strong",{children:u})," stream",1===u?"":"s"," can be pinged per operation (",(0,i.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")."]})]}),children:[(0,i.jsx)(ni,{label:"Enable",side:"right",value:o.precacheNextEpisode,onValueChange:e=>{d(t=>({...t,precacheNextEpisode:e}))}}),(0,i.jsx)(ni,{label:"First stream only",help:(0,i.jsxs)(i.Fragment,{children:["When on (default), only the first stream returned by the selector is pinged. Turn off to ping all streams the selector returns",void 0!==u?(0,i.jsxs)(i.Fragment,{children:[" ","(up to ",(0,i.jsx)("strong",{children:u}),","," ",(0,i.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}):(0,i.jsxs)(i.Fragment,{children:[" ","(capped by ",(0,i.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}),"."]}),side:"right",disabled:!o.precacheNextEpisode,value:o.precacheSingleStream??!0,defaultValue:!0,onValueChange:e=>{d(t=>({...t,precacheSingleStream:e}))}}),(0,i.jsx)(K,{label:"Precache Selector",help:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("p",{children:"A SEL expression that determines which stream(s) to precache for the next episode. Should evaluate to a list of streams."}),(0,i.jsxs)("p",{className:"mt-2",children:[(0,i.jsx)("strong",{children:"Recommended pattern:"})," ",(0,i.jsx)("code",{children:"condition ? streamsToSelectFrom : []"})]}),(0,i.jsxs)("ul",{className:"mt-2 space-y-1 list-disc list-inside",children:[(0,i.jsxs)("li",{children:[(0,i.jsx)("code",{children:"condition"})," - When precaching should activate"]}),(0,i.jsxs)("li",{children:[(0,i.jsx)("code",{children:"streamsToSelectFrom"})," - Which streams AIOStreams should choose from"]})]}),(0,i.jsx)("p",{className:"mt-2",children:(0,i.jsx)("strong",{children:"Examples:"})}),(0,i.jsxs)("ul",{className:"mt-2 space-y-1 list-disc list-inside",children:[(0,i.jsxs)("li",{children:[(0,i.jsx)("strong",{children:"Default behavior"})," (precache only when all streams are uncached):",(0,i.jsx)("br",{}),(0,i.jsx)("code",{className:"text-xs",children:"count(cached(streams)) == 0 ? uncached(streams) : []"})]}),(0,i.jsxs)("li",{children:[(0,i.jsx)("strong",{children:"Always precache first uncached stream:"}),(0,i.jsx)("br",{}),(0,i.jsx)("code",{className:"text-xs",children:"true ? uncached(streams) : []"})]}),(0,i.jsxs)("li",{children:[(0,i.jsx)("strong",{children:"Only for anime series:"}),(0,i.jsx)("br",{}),(0,i.jsx)("code",{className:"text-xs",children:"queryType == 'anime.series' ? uncached(streams) : []"})]})]}),(0,i.jsx)("p",{className:"mt-2 text-sm text-gray-600",children:"Has access to the same constants as expression filters (streams, queryType, isAnime, etc.)."})]}),placeholder:"e.g., true ? uncached(streams) : []",disabled:!o.precacheNextEpisode,value:o.precacheSelector??"",onValueChange:e=>{d(t=>({...t,precacheSelector:e||void 0}))}})]}),(0,i.jsxs)(mK,{title:"Preload Streams",id:"preloadStreams",description:(0,i.jsxs)(i.Fragment,{children:["Automatically sends HTTP requests to selected streams so they start processing before you click â runs asynchronously without delaying results."," ",void 0!==u&&(0,i.jsxs)(i.Fragment,{children:["Up to ",(0,i.jsx)("strong",{children:u})," stream",1===u?"":"s"," can be pinged per operation (",(0,i.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")."]})]}),children:[(0,i.jsx)(ni,{label:"Enable",side:"right",value:null==(s=o.preloadStreams)?void 0:s.enabled,onValueChange:e=>{d(t=>({...t,preloadStreams:{...t.preloadStreams,enabled:e}}))}}),(0,i.jsx)(ni,{label:"First stream only",help:(0,i.jsxs)(i.Fragment,{children:["When on (default), only the first stream returned by the selector is pinged. Turn off to ping all streams the selector returns",void 0!==u?(0,i.jsxs)(i.Fragment,{children:[" ","(up to ",(0,i.jsx)("strong",{children:u}),","," ",(0,i.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}):(0,i.jsxs)(i.Fragment,{children:[" ","(capped by ",(0,i.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}),"."]}),side:"right",disabled:!(null==(a=o.preloadStreams)?void 0:a.enabled),value:(null==(r=o.preloadStreams)?void 0:r.singleStream)??!0,defaultValue:!0,onValueChange:e=>{d(t=>({...t,preloadStreams:{...t.preloadStreams,singleStream:e}}))}}),(0,i.jsx)(K,{label:"Preload Selector",help:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("p",{children:"A SEL expression that determines which streams to preload. Should evaluate to a list of streams â all streams in the result will have an HTTP request sent to their URLs."}),(0,i.jsx)("p",{className:"mt-2",children:(0,i.jsx)("strong",{children:"Examples:"})}),(0,i.jsxs)("ul",{className:"mt-2 space-y-1 list-disc list-inside",children:[(0,i.jsxs)("li",{children:[(0,i.jsx)("strong",{children:"Top 5 streams (default):"}),(0,i.jsx)("br",{}),(0,i.jsx)("code",{className:"text-xs",children:"slice(streams, 0, 5)"})]}),(0,i.jsxs)("li",{children:[(0,i.jsx)("strong",{children:"Top 5 usenet streams only:"}),(0,i.jsx)("br",{}),(0,i.jsx)("code",{className:"text-xs",children:"slice(type(streams, 'usenet'), 0, 5)"})]}),(0,i.jsxs)("li",{children:[(0,i.jsx)("strong",{children:"Top 3 cached streams:"}),(0,i.jsx)("br",{}),(0,i.jsx)("code",{className:"text-xs",children:"slice(cached(streams), 0, 3)"})]})]}),(0,i.jsx)("p",{className:"mt-2 text-sm text-gray-600",children:"Has access to the same constants as expression filters (streams, queryType, isAnime, etc.)."})]}),defaultValue:"slice(streams, 0, 2)",disabled:!(null==(n=o.preloadStreams)?void 0:n.enabled),value:(null==(l=o.preloadStreams)?void 0:l.selector)??"",onValueChange:e=>{d(t=>({...t,preloadStreams:{...t.preloadStreams,selector:e||void 0}}))}})]})]})}function gE(){var e,t,s,a,r,n,l,o,d,c,u,m;let{userData:h,setUserData:p}=ri();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(mK,{title:"Auto Play",id:"autoPlay",description:(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{children:"Configure how AIOStreams suggests the next stream for Stremio's auto-play feature."}),(0,i.jsx)(lB,{intent:"info-basic",children:(0,i.jsxs)("p",{className:"text-sm",children:["AIOStreams does not (and cannot) directly control auto-play. It uses the"," ",(0,i.jsx)("code",{children:(0,i.jsx)("a",{rel:"noopener noreferrer",href:"https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/responses/stream.md#additional-properties-to-provide-information--behaviour-flags",target:"_blank",className:"text-[--brand] hover:text-[--brand]/80 hover:underline",children:"bingeGroup"})})," ","attribute to suggest the next stream to Stremio. For this to work, you must have auto-play enabled in your Stremio settings."]})})]}),children:[(0,i.jsx)(ni,{label:"Enable",side:"right",value:(null==(e=h.autoPlay)?void 0:e.enabled)??!0,onValueChange:e=>{p(t=>({...t,autoPlay:{...t.autoPlay,enabled:e}}))}}),(0,i.jsx)(nc,{label:"Auto Play Method",disabled:(null==(t=h.autoPlay)?void 0:t.enabled)===!1,options:aw.map(e=>({label:aN[e].name,value:e})),value:(null==(s=h.autoPlay)?void 0:s.method)||"matchingFile",onValueChange:e=>{p(t=>({...t,autoPlay:{...t.autoPlay,method:e}}))},help:aN[(null==(a=h.autoPlay)?void 0:a.method)||"matchingFile"].description}),((null==(r=h.autoPlay)?void 0:r.method)??"matchingFile")==="matchingFile"&&(0,i.jsx)(li,{label:"Auto Play Attributes",help:"The attributes that will be used to match the stream for auto-play. The first stream for the next episode that has the same set of attributes selected above will be auto-played. Less attributes means more likely to auto-play but less accurate in terms of playing a similar type of stream.",options:ay.map(e=>({label:e,value:e})),multiple:!0,disabled:(null==(n=h.autoPlay)?void 0:n.enabled)===!1,emptyMessage:"No attributes found",value:null==(l=h.autoPlay)?void 0:l.attributes,defaultValue:aj,onValueChange:e=>{p(t=>({...t,autoPlay:{...t.autoPlay,attributes:e}}))}})]}),(0,i.jsxs)(mK,{title:"Are you still there?",id:"areYouStillThere",description:"Stop autoplay after a number of consecutive episodes so the player returns to stream selection.",children:[(0,i.jsx)(ni,{label:"Enable",side:"right",value:null==(o=h.areYouStillThere)?void 0:o.enabled,onValueChange:e=>{p(t=>({...t,areYouStillThere:{...t.areYouStillThere,enabled:e}}))}}),(0,i.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,i.jsx)(lm,{label:"Episodes before check",min:1,defaultValue:3,disabled:!(null==(d=h.areYouStillThere)?void 0:d.enabled),value:(null==(c=h.areYouStillThere)?void 0:c.episodesBeforeCheck)??3,onValueChange:e=>{p(t=>({...t,areYouStillThere:{...t.areYouStillThere,episodesBeforeCheck:Math.max(1,Number(e||3))}}))}}),(0,i.jsx)(lm,{label:"Cooldown (minutes)",min:1,defaultValue:60,disabled:!(null==(u=h.areYouStillThere)?void 0:u.enabled),value:(null==(m=h.areYouStillThere)?void 0:m.cooldownMinutes)??60,onValueChange:e=>{p(t=>({...t,areYouStillThere:{...t.areYouStillThere,cooldownMinutes:Math.max(1,Number(e||60))}}))}})]})]})]})}function gM(){var e,t,s,a,r;let{userData:n,setUserData:l}=ri();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(mK,{title:"Statistic Streams",id:"statistics",description:"AIOStreams will return the statistics of stream fetches and response times for each addon if enabled.",children:[(0,i.jsx)(ni,{label:"Enable",side:"right",value:null==(e=n.statistics)?void 0:e.enabled,onValueChange:e=>{l(t=>({...t,statistics:{...t.statistics,enabled:e}}))}}),(0,i.jsx)(nc,{label:"Statistics Position",help:"Whether to show the statistic streams at the top or bottom of the stream list.",disabled:!(null==(t=n.statistics)?void 0:t.enabled),options:[{label:"Top",value:"top"},{label:"Bottom",value:"bottom"}],value:(null==(s=n.statistics)?void 0:s.position)||"bottom",onValueChange:e=>{l(t=>({...t,statistics:{...t.statistics,position:e}}))}}
45),(0,i.jsx)(li,{label:"Statistics to Show",options:["addon","filter","timing"].map(e=>({label:e,value:e})),emptyMessage:"No statistics to show",multiple:!0,defaultValue:["addon","filter","timing"],value:null==(a=n.statistics)?void 0:a.statsToShow,onValueChange:e=>{l(t=>({...t,statistics:{...t.statistics,statsToShow:e}}))}}),(0,i.jsx)(ni,{label:"Show Filter Stats on No Streams",side:"right",defaultValue:!0,value:(null==(r=n.statistics)?void 0:r.showFilterStatsOnNoStreams)??!0,moreHelp:"When filtering results in 0 streams, show filter removal statistics as forced streams regardless of your statistics settings. Use this if you normally don't want to see filter stats, but want to know why no streams are available when that happens.",onValueChange:e=>{l(t=>({...t,statistics:{...t.statistics,showFilterStatsOnNoStreams:e}}))}})]}),(0,i.jsx)(mK,{title:"External Downloads",id:"externalDownloads",description:"Adds a stream that automatically opens the stream in your browser below every stream for easier downloading",children:(0,i.jsx)(ni,{label:"Enable",side:"right",value:n.externalDownloads,onValueChange:e=>{l(t=>({...t,externalDownloads:e}))}})}),(0,i.jsxs)(mK,{id:"hideErrors",title:"Hide Errors",children:[(0,i.jsx)(ni,{label:"Hide Errors",help:"AIOStreams will attempt to return the errors in responses to streams, catalogs etc. Turning this on will hide the errors.",side:"right",value:n.hideErrors,onValueChange:e=>{l(t=>({...t,hideErrors:e}))}}),(0,i.jsx)(li,{disabled:n.hideErrors,label:"Hide Errors for specific resources",options:aU.map(e=>({label:e,value:e})),multiple:!0,help:"This lets you hide errors for specific resources. For example, you may want to hide errors for the catalog resource, but not for the stream resource.",emptyMessage:"No resources found",value:n.hideErrorsForResources,onValueChange:e=>{l(t=>({...t,hideErrorsForResources:e}))}})]})]})}let gP=[{value:"inherit",label:"Inherit from parent"},{value:"override",label:"Override with mine"}],g$=[{value:"inherit",label:"Inherit from parent"},{value:"extend",label:"Extend parent (add mine)"},{value:"override",label:"Override with mine"}],gD={presets:"Addons",services:"Services",filters:"Filters",sorting:"Sorting & Deduplication",formatter:"Formatter",proxy:"Proxy",metadata:"Metadata & Poster APIs",misc:"Miscellaneous Settings",branding:"Branding"},gL={presets:"Addon presets and groupings.",services:'Debrid and download service credentials. Use "Extend" to add or override individual services while keeping the rest from the parent.',filters:"All include, exclude, require and prefer filters.",sorting:"Sort criteria, deduplication rules and result limits.",formatter:"Stream title formatter.",proxy:"Proxy configuration.",metadata:"TMDB, RPDB, TVDB and poster API keys.",misc:"Playback, display and other miscellaneous settings.",branding:"Addon visual identity overrides."},gO={filters:"Filters",sorting:"Sorting",formatter:"Formatter",proxy:"Proxy",metadata:"Metadata",misc:"Misc",branding:"Branding"},gU=["filters","sorting","formatter","proxy","metadata","misc","branding"],gF=Object.entries(sz).filter(e=>{let[,t]=e;return!t.ignoreForParentConfig}).map(e=>{let[t]=e;return t}).sort((e,t)=>{var s,a;return((null==(s=sz[e])?void 0:s.label)??e).localeCompare((null==(a=sz[t])?void 0:a.label)??t)}),gz=Object.fromEntries(gU.map(e=>[e,gF.filter(t=>{var s;return(null==(s=sz[t])?void 0:s.group)===e})]));function gV(e,t){var s;let a=null==(s=sz[e])?void 0:s.group;return a?(null==t?void 0:t[a])??"inherit":"inherit"}function gq(e){let{field:t,meta:s,activeOverride:a,groupStrategy:r,trimmedSearch:n,onChange:l}=e,o=[{value:"default",label:`Default: ${"inherit"===r?"Inherit (group)":"override"===r?"Override (group)":"Extend (group)"}`},..."list"===s.type?g$:gP];return(0,i.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2 rounded-[--radius] hover:bg-[--subtle] group",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col sm:flex-row sm:items-center sm:gap-2",children:[(0,i.jsx)("span",{className:"text-sm font-medium",children:s.label}),n&&(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:["(",gO[s.group],")"]})]}),(0,i.jsx)("div",{className:"w-48 shrink-0",children:(0,i.jsx)(nc,{size:"sm",options:o,value:a??"default",onValueChange:e=>l(t,e)})})]})}function gB(e){var t;let{open:s,onOpenChange:a,strategies:r,fieldOverrides:n,onChange:l}=e,[o,d]=(0,u.useState)("filters"),[c,m]=(0,u.useState)(""),h=c.trim().toLowerCase(),p=(0,u.useMemo)(()=>h?gF.filter(e=>{var t;return((null==(t=sz[e])?void 0:t.label)??e).toLowerCase().includes(h)}):gz[o]??[],[h,o]),x=(0,u.useMemo)(()=>Object.fromEntries(gU.map(e=>[e,gF.filter(t=>{var s;return(null==(s=sz[t])?void 0:s.group)===e&&n[t]}).length])),[n]),g=Object.keys(n).filter(e=>sz[e]).length;return(0,i.jsx)(sl,{open:s,onOpenChange:a,title:"Field Overrides",description:"Override the merge strategy for individual config fields. Field overrides always take precedence over the section-level strategy above.",contentClass:"!max-w-3xl",children:(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsx)(K,{placeholder:"Search f
45ieldsâ¦",value:c,onValueChange:m}),!h&&(0,i.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:gU.map(e=>{let t=x[e],s=o===e;return(0,i.jsxs)("button",{onClick:()=>d(e),className:["flex items-center gap-1.5 px-3 py-1.5 rounded-[--radius] text-sm font-medium transition-colors",s?"bg-brand-500 text-white":"bg-[--subtle] text-[--muted] hover:text-[--text-color] hover:bg-[--subtle-border]"].join(" "),children:[gO[e],t>0&&(0,i.jsx)("span",{className:["text-xs px-1.5 py-0.5 rounded-full font-semibold leading-none",s?"bg-white/20 text-white":"bg-[--brand]/20 text-[--brand]"].join(" "),children:t})]},e)})}),!h&&(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsxs)("p",{className:"text-sm font-semibold text-[--text-color]",children:[gO[o],(0,i.jsxs)("span",{className:"ml-2 text-xs font-normal text-[--muted]",children:[(null==(t=gz[o])?void 0:t.length)??0," fields"]})]}),x[o]>0&&(0,i.jsxs)("button",{onClick:()=>{let e;return e=new Set(gF.filter(e=>{var t;return(null==(t=sz[e])?void 0:t.group)===o}).map(e=>e)),void l(t=>Object.fromEntries(Object.entries(t).filter(t=>{let[s]=t;return!e.has(s)})))},className:"text-xs text-[--muted] hover:text-[--text-color] transition-colors",children:["Clear ",x[o]," override",1!==x[o]?"s":""]})]}),h&&(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:[p.length," field",1!==p.length?"s":""," ","matching â",c.trim(),"â"]}),(0,i.jsx)("div",{className:"space-y-1 max-h-[50vh] overflow-y-auto pr-0.5",children:0===p.length?(0,i.jsx)("p",{className:"text-sm text-[--muted] py-4 text-center",children:"No fields found."}):p.map(e=>{let t=sz[e],s=n[e],a=gV(e,r);return(0,i.jsx)(gq,{field:e,meta:t,activeOverride:s,groupStrategy:a,trimmedSearch:!!h,onChange:(e,t)=>
45{l(s=>{let a={...s};return t&&"default"!==t?a[e]=t:delete a[e],a})}},e)})}),g>0&&(0,i.jsxs)("p",{className:"text-xs text-[--muted] border-t pt-3",children:[g," field override",1!==g?"s":""," ","active across all sections."]})]})})}function gK(){let{userData:e,setUserData:t,uuid:s}=ri(),[a,r]=(0,u.useState)(""),[n,l]=(0,u.useState)(""),[o,d]=(0,u.useState)(!1),[c,h]=(0,u.useState)(!1),p=e.parentConfig;async function x(e){if(null==e||e.preventDefault(),a.trim()&&n){if(d(!0),a===s){m.oR.error("You cannot link to your own config"),d(!1);return}try{let e=await ey(a.trim(),n);t(t=>({...t,parentConfig:{uuid:e.uuid,password:n,mergeStrategies:{presets:"inherit",services:"inherit",filters:"inherit",sorting:"inherit",formatter:"inherit",proxy:"inherit",metadata:"inherit",misc:"inherit",branding:"inherit"}}})),r(""),l(""),m.oR.success("Parent config linked. Save your config to apply.")}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to link parent config")}finally{d(!1)}}}function g(e,s){t(t=>{var a;return{...t,parentConfig:{...t.parentConfig,mergeStrategies:{presets:"inherit",services:"inherit",filters:"inherit",sorting:"inherit",formatter:"inherit",proxy:"inherit",metadata:"inherit",misc:"inherit",branding:"inherit",...(null==(a=t.parentConfig)?void 0:a.mergeStrategies)??{},[e]:s}}}})}function f(e){t(t=>{var s;let a=(null==(s=t.parentConfig)?void 0:s.mergeStrategies)??{},r=a.fieldOverrides??{},n="function"==typeof e?e(r):e;return{...t,parentConfig:{...t.parentConfig,mergeStrategies:{presets:"inherit",services:"inherit",filters:"inherit",sorting:"inherit",formatter:"inherit",proxy:"inherit",metadata:"inherit",misc:"inherit",branding:"inherit",...a,fieldOverrides:Object.keys(n).length>0?n:void 0}}}})}let b=null==p?void 0:p.mergeStrategies,y=(null==b?void 0:b.fieldOverrides)??{},j=Object.keys(y).filter(e=>sz[e]).length;return(0,i.jsx)("div",{className:"space-y-4",children:p?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(mK,{title:"Parent Config",id:"parentConfig",description:"Settings from the parent config are merged into this config at runtime.",action:(0,i.jsx)(v,{intent:"alert-subtle",size:"sm",leftIcon:(0,i.jsx)(xE.KOA,{}),onClick:function(){t(e=>{let t={...e};return delete t.parentConfig,t}),m.oR.success("Parent config removed. Save your config to apply.")},children:"Unlink"}),children:(0,i.jsxs)("div",{className:"flex items-center gap-2 p-2 rounded-[--radius] bg-[--subtle] border text-sm",children:[(0,i.jsx)(xE.j2W,{className:"shrink-0 text-[--muted]"}),(0,i.jsx)("span",{className:"font-mono text-xs truncate text-[--muted]",children:p.uuid})]})}),(0,i.jsx)(mK,{title:"Merge Strategies",description:"For each section, choose whether to use the parent's settings, combine them with yours, or use only yours.",children:(0,i.jsxs)("div",{className:"space-y-4",children:[["presets","services"].map(e=>(0,i.jsx)("div",{className:"space-y-1",children:(0,i.jsx)(nc,{label:gD[e],help:gL[e],options:g$,value:(null==b?void 0:b[e])??"inherit",onValueChange:t=>g(e,t)})},e)),["filters","sorting","formatter","proxy","metadata","misc","branding"].map(e=>(0,i.jsx)("div",{className:"space-y-1",children:(0,i.jsx)(nc,{label:gD[e],help:gL[e],options:gP,value:(null==b?void 0:b[e])??"inherit",onValueChange:t=>g(e,t)})},e))]})}),(0,i.jsx)(mK,{title:"Field Overrides",description:"Fine-tune inheritance by setting a different strategy for individual fields. Overrides always take precedence over the section strategies above.",action:(0,i.jsx)(w,{size:"sm",intent:"white",rounded:!0,icon:(0,i.jsx)(lV.VSk,{}),onClick:()=>h(!0),title:"Configure Field Overrides"}),children:j>0?(0,i.jsx)("div",{className:"space-y-1 mt-2",children:Object.keys(y).filter(e=>sz[e]).map(e=>{let t=sz[e],s=y[e],a=gV(e,b);return(0,i.jsx)(gq,{field:e,meta:t,activeOverride:s,groupStrategy:a,trimmedSearch:!1,onChange:(e,t)=>
45{f(s=>{let a={...s};return t&&"default"!==t?a[e]=t:delete a[e],a})}},e)})}):(0,i.jsx)("p",{className:"text-sm text-[--muted] pt-2",children:"No field overrides configured. All fields use their section strategy."})}),(0,i.jsx)(gB,{open:c,onOpenChange:h,strategies:b,fieldOverrides:y,onChange:f})]}):(0,i.jsx)(mK,{title:"Link a Parent Config",id:"parentConfig",description:"Inherit settings from another config at runtime. Any changes made to the parent are immediately reflected here.",children:(0,i.jsxs)("form",{onSubmit:x,className:"space-y-3",children:[(0,i.jsx)(K,{label:"Parent UUID",placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",autoComplete:"off",value:a,onValueChange:r}),(0,i.jsx)(G,{label:"Parent Password",autoComplete:"off",value:n,onValueChange:l}),(0,i.jsx)(v,{type:"submit",size:"sm",intent:"white",rounded:!0,loading:o,disabled:!a.trim()||!n,leftIcon:(0,i.jsx)(xE.j2W,{}),children:"Link Parent"})]})})})}let gH={maxScriptLength:4e3,maxTotalInstructions:5e3,maxValueDepth:10,maxPathSegments:12,maxPathMatches:200},gW=new Set(["accessKey","parentConfig","variants","healthChecks"]),gG=new Set(["jellyfin.personas"]),gY=new Set(["__proto__","prototype","constructor"]),gJ=new Set(["true","false","null"]),gZ=new Set(["set","merge","unset","clear","add","prepe
45nd","remove","insert","enable","disable","use"]),gQ=new Set(["before","after"]),gX=/^[a-z0-9][a-z0-9_-]{0,31}$/;function g0(e,t){let s,a=e.toLowerCase(),r=Math.max(2,Math.ceil(e.length/3));for(let e of t){let t=function(e,t){let s=Array(t.length+1),a=Array(t.length+1);for(let e=0;e<=t.length;e++)s[e]=e;for(let r=1;r<=e.length;r++){a[0]=r;for(let n=1;n<=t.length;n++)a[n]=Math.min(s[n]+1,a[n-1]+1,s[n-1]+ +(e[r-1]!==t[n-1]));for(let e=0;e<=t.length;e++)s[e]=a[e]}return s[t.length]}(a,e.toLowerCase());t<r&&(r=t,s=e)}return s}class g1 extends Error{constructor(e,t){super(e),(0,et._)(this,"diagnostic",void 0),this.diagnostic=t}}class g2{get eof(){return this.pos>=this.src.length}peek(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.src[this.pos+e]??""}advance(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t="";for(let s=0;s<e&&!this.eof;s++){let e=this.src[this.pos++];"\n"===e&&this.line++,t+=e}return t}skipTrivia(){for(;!this.eof;){let e=this.peek();if("#"===e)for(;!this.eof&&"\n"!==this.peek();)this.advance();else{if(" "!==e&&" "!==e&&"\r"!==e&&"\n"!==e)return;this.advance()}}}skipToNextLine(){for(;!this.eof&&"\n"!==this.peek();)this.advance();this.eof||this.advance()}fail(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=t.index??this.pos,a=t.source??this.src.slice(s,Math.max(s+1,this.pos));throw new g1(e,{index:s,source:a,line:this.line,message:e,category:t.category??"syntax",suggestion:t.suggestion})}constructor(e){(0,et._)(this,"src",void 0),(0,et._)(this,"pos",void 0),(0,et._)(this,"line",void 0),this.src=e,this.pos=0,this.line=1}}function g3(e){return/[A-Za-z_]/.test(e)}function g5(e){return/[A-Za-z0-9_]/.test(e)}function g4(e){return e>="0"&&e<="9"}function g6(e){g3(e.peek())||e.fail("expected a name");let t=e.pos,s="";for(;!e.eof&&g5(e.peek());)s+=e.advance();return gY.has(s)&&e.fail(`"${s}" is not an allowed name`,{index:t,source:s}),s}function g9(e){let t=e.pos,s="";for(;!e.eof&&/[A-Za-z0-9_.-]/.test(e.peek());)s+=e.advance();return s||e.fail("expected a value"),gY.has(s)&&e.fail(`"${s}" is not an allowed name`,{index:t,source:s}),s}let g8=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function g7(e){if(!g3(e.peek()))return;let t="",s=0;for(;g5(e.peek(s));)t+=e.peek(s++);return t}function fe(e){let t=e.pos,s=e.advance(),a="";for(;;){e.eof&&e.fail("unterminated string",{index:t});let r=e.advance();if(r===s)return a;if("\\"!==r){a+=r;continue}let n=e.advance();switch(n){case"n":a+="\n";break;case"t":a+=" ";break;case"r":a+="\r";break;case"b":a+="\b";break;case"f":a+="\f";break;case"u":{let t=e.advance(4);/^[0-9a-fA-F]{4}$/.test(t)||e.fail("invalid unicode escape"),a+=String.fromCharCode(parseInt(t,16));break}case"\\":case"/":case'"':case"'":a+=n;break;default:e.fail(`invalid escape sequence "\\${n}"`)}}}function ft(e){let t=e.pos,s="";for("-"===e.peek()&&(s+=e.advance());g4(e.peek());)s+=e.advance();if("."===e.peek())for(s+=e.advance();g4(e.peek());)s+=e.advance();if("e"===e.peek()||"E"===e.peek())for(s+=e.advance(),("+"===e.peek()||"-"===e.peek())&&(s+=e.advance());g4(e.peek());)s+=e.advance();let a=Number(s);return""!==s&&"-"!==s&&Number.isFinite(a)||e.fail(`invalid number "${s}"`,{index:t,source:s||"-"}),a}function fs(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;s>t.maxValueDepth&&e.fail(`value nesting exceeds the maximum depth of ${t.maxValueDepth}`,{category:"limit"}),e.skipTrivia();let a=e.peek();if('"'===a||"'"===a)return fe(e);
45if("-"===a||g4(a))return ft(e);if("["===a){e.advance();let a=[];if(e.skipTrivia(),"]"===e.peek())return e.advance(),a;for(;;){if(a.push(fs(e,t,s+1)),e.skipTrivia(),","===e.peek()){if(e.advance(),e.skipTrivia(),"]"===e.peek())return e.advance(),a;continue}if("]"===e.peek())return e.advance(),a;e.fail('expected "," or "]" in array')}}if("{"===a){e.advance();let a={};if(e.skipTrivia(),"}"===e.peek())return e.advance(),a;for(;;){e.skipTrivia();let r=e.pos,n='"'===e.peek()||"'"===e.peek()?fe(e):g6(e);if(gY.has(n)&&e.fail(`"${n}" is not an allowed key`,{index:r,source:n}),Object.prototype.hasOwnProperty.call(a,n)&&e.fail(`duplicate key "${n}"`,{index:r,source:n}),e.skipTrivia(),":"!==e.peek()&&e.fail('expected ":" after object key'),e.advance(),a[n]=fs(e,t,s+1),e.skipTrivia(),","===e.peek()){if(e.advance(),e.skipTrivia(),"}"===e.peek())return e.advance(),a;continue}if("}"===e.peek())return e.advance(),a;e.fail('expected "," or "}" in object')}}let r=g7(e);if(r&&gJ.has(r))return e.advance(r.length),"true"===r||"false"!==r&&null;e.fail("expected a value (string, number, boolean, null, array or object)")}function fa(e,t){let s=e.pos,a=g6(e);gW.has(a)&&e.fail(`"${a}" cannot be changed by a variant`,{index:s,source:a,category:"denied-field"}),Object.prototype.hasOwnProperty.call(sz,a)||e.fail(`"${a}" is not a known configuration field`,{index:s,source:a,category:"unknown-field",suggestion:g0(a,Object.keys(sz).filter(e=>!gW.has(e)))});let r=[];for(;!e.eof;){if("."===e.peek()){e.advance();let t=e.pos,s=g6(e);!r.length&&gG.has(`${a}.${s}`)&&e.fail(`"${a}.${s}" cannot be changed by a variant`,{index:t,source:s,category:"denied-field"}),r.push({kind:"key",name:s})}else if("["===e.peek()){if(e.advance(),e.skipTrivia(),"*"===e.peek()&&"]"===e.peek(1))e.advance(),r.push({kind:"all"});else if(g4(e.peek())||"-"===e.peek()&&g4(e.peek(1))){let t=e.pos,s=ft(e);Number.isInteger(s)||e.fail("array index must be a whole number",{index:t}),r.push({kind:"index",index:s})}else{let s,a="";if(g3(e.peek()))for(a=g6(e);"."===e.peek();)e.advance(),a+=`.${g6(e)}`;e.skipTrivia(),"!"===e.peek()&&"*"===e.peek(1)&&"="===e.peek(2)?(e.advance(3),s="!*="):"!"===e.peek()&&"="===e.peek(1)?(e.advance(2),s="!="):"*"===e.peek()&&"="===e.peek(1)?(e.advance(2),s="*="):"="===e.peek()?(e.advance(),s="="):e.fail('expected "=", "!=", "*=" or "!*=" in selector'),e.skipTrivia();let n=function(e,t){let s=e.peek();if('"'===s||"'"===s||"["===s||"{"===s)return fs(e,t);let a="",r=0;for(;/[A-Za-z0-9_.+-]/.test(e.peek(r));)a+=e.peek(r++);return(a||e.fail("expected a value"),"true"===a||"false"===a)?(e.advance(a.length),"true"===a):"null"===a?(e.advance(a.length),null):g8.test(a)?ft(e):g9(e)}(e,t);r.push({kind:"filter",key:a,operator:s,value:n})}e.skipTrivia(),"]"!==e.peek()&&e.fail('expected "]"'),e.advance()}else break;r.length>t.maxPathSegments&&e.fail(`path exceeds the maximum of ${t.maxPathSegments} segments`,{index:s,category:"limit"})}return{root:a,segments:r,raw:e.src.slice(s,e.pos),index:s}}function fr(e,t){let s=[];if(e.skipTrivia(),!function(e){let t=e.peek();if('"'===t||"'"===t||"["===t||"{"===t||"-"===t||g4(t))return!0;let s=g7(e);return void 0!==s&&gJ.has(s)}(e))return s;for(s.push(fs(e,t));;){if(e.skipTrivia(),","!==e.peek())return s;e.advance(),s.push(fs(e,t))}}function fn(e){return'"'===e.peek()||"'"===e.peek()?fe(e):g9(e)}function fl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:gH,s=[],a=[],r=[];if(e.length>t.maxScriptLength)return r.push({index:t.maxScriptLength,source:e.slice(t.maxScriptLength,t.maxScriptLength+20),line:1,message:`script exceeds the maximum length of ${t.maxScriptLength} characters`,category:"limit",severity:"error"}),{program:{statements:s,referencedVariants:a},diagnostics:r};let n=new g2(e);for(;n.skipTrivia(),!n.eof;){let l=n.pos,i=n.line;try{let e=function(e,t){let s=e.pos,a=e.line,r=g6(e);switch(!gZ.has(r)&&e.fail(`unknown instruction "${r}"`,{index:s,source:r,category:"unknown-verb",suggestion:g0(r,[...gZ])}),e.skipTrivia(),r){case"set":case"merge":{let n=fa(e,t);e.skipTrivia(),"="!==e.peek()&&e.fail(`expected "=" after the path in ${r}`),e.advance();let l=fs(e,t);return"merge"===r&&(null===l||"object"!=typeof l)&&e.fail("merge requires an object or array value",{index:s}),{op:r,path:n,value:l,index:s,line:a}}case"unset":case"clear":case"enable":case"disable":return{op:r,path:fa(e,t),index:s,line:a};
45case"add":case"prepend":case"remove":{let n=fa(e,t),l=fr(e,t);return 0===l.length&&"remove"!==r&&e.fail(`${r} requires at least one value`,{index:s}),{op:r,path:n,values:l,index:s,line:a}}case"insert":{var n;let l="before",i=1,o=e.pos;g4(e.peek())&&((!Number.isInteger(i=ft(e))||i<1)&&e.fail("an insert count must be a whole number of places, from 1",{index:o,source:e.src.slice(o,e.pos)}),e.skipTrivia());let d=g7(e);d&&gQ.has(d)?(e.advance(d.length),l=d,e.skipTrivia()):e.pos!==o&&e.fail('a count needs "before" or "after" after it',{index:o,source:e.src.slice(o,e.pos)});let c=fa(e,t);(null==(n=c.segments[c.segments.length-1])?void 0:n.kind)==="all"&&e.fail('insert needs a single position, not "[*]"',{index:c.index,source:c.raw}),e.skipTrivia(),"="!==e.peek()&&e.fail('expected "=" after the path in insert'),e.advance();let u=fr(e,t);return 0===u.length&&e.fail("insert requires at least one value",{index:s}),{op:r,path:c,values:u,placement:l,count:i,index:s,line:a}}default:{let t=e.pos,r=g6(e);if(e.skipTrivia(),"formatter"===r)return{op:"useFormatter",name:fn(e),index:s,line:a};if("variant"===r){let t=e.pos,r=fn(e);return gX.test(r)||e.fail(`invalid variant id "${r}"`,{index:t,source:r}),{op:"useVariant",id:r,index:s,line:a}}return e.fail('expected "use formatter" or "use variant"',{index:t,source:r,suggestion:g0(r,["formatter","variant"])})}}}(n,t);s.push(e),"useVariant"===e.op&&a.push(e.id)}catch(t){t instanceof g1?r.push({...t.diagnostic,severity:"error"}):r.push({index:l,source:e.slice(l,n.pos)||" ",line:i,message:t instanceof Error?t.message:String(t),category:"syntax",severity:"error"}),n.skipToNextLine()}}return{program:{statements:s,referencedVariants:a},diagnostics:r}}function fi(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function fo(e){if(Array.isArray(e))return e.map(fo);if(fi(e)){let t={};for(let[s,a]of Object.entries(e))gY.has(s)||(t[s]=fo(a));return t}return e}function fd(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,s)=>fd(e,t[s]));if(fi(e)&&fi(t)){let s=Object.keys(e),a=Object.keys(t);return s.length===a.length&&s.every(s=>Object.prototype.hasOwnProperty.call(t,s)&&fd(e[s],t[s]))}return!1}function fc(e,t,s){"string"==typeof t&&gY.has(t)||(e[t]=s)}function fu(e,t){let s=e<0?t+e:e;return s>=0&&s<t?s:void 0}function fm(e,t){let s;if(t.key&&!fi(e))return!1;let a=e;for(let e of t.key?t.key.split("."):[]){if(!fi(a))return t.operator.startsWith("!");a=a[e]}let r=null!=a&&("object"!=typeof t.value||null===t.value);return s="*="===t.operator||"!*="===t.operator?r&&String(a).toLowerCase().includes(String(t.value).toLowerCase()):fd(a,t.value)||r&&String(a)===String(t.value),"!="===t.operator||"!*="===t.operator?!s:s}function fh(e,t,s){let a=[];for(let r of e)switch(t.kind){case"key":if(!fi(r))break;void 0===r[t.name]&&void 0!==s&&fc(r,t.name,s),void 0!==r[t.name]&&a.push(r[t.name]);break;case"index":{if(!Array.isArray(r))break;let e=fu(t.index,r.length);void 0!==e&&a.push(r[e]);break}case"all":Array.isArray(r)?a.push(...r):fi(r)&&a.push(...Object.values(r));break;case"filter":Array.isArray(r)&&a.push(...r.filter(e=>fm(e,t)))}return a}function fp(e){let t=new Map;for(let s of e)if(Array.isArray(s.container)&&"number"==typeof s.key){let e=t.get(s.container)??[];e.push(s.key),t.set(s.container,e)}else fi(s.container)&&delete s.container[s.key];for(let[e,s]of t)for(let t of[...new Set(s)].sort((e,t)=>t-e))e.splice(t,1)}function fx(e,t,s){let a="path"in e?e.path.raw:`use ${e.op}`;return{index:"path"in e?e.path.index:e.index,source:a,line:e.line,message:t,category:s,severity:"warning"}}var fg=s(57806),ff=s(2749);let fb=ff.Lz.theme({"&":{backgroundColor:"transparent",color:"var(--foreground)",fontSize:"0.8125rem",height:"100%"},".cm-content":{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",padding:"0.5rem 0.6rem",caretColor:"var(--foreground)"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.6",overflow:"auto"},"&.cm-focused":{outline:"none"},".cm-placeholder":{color:"var(--muted)"},".cm-content ::selection":{backgroundColor:"color-mix(in srgb, var(--ring) 30%, transparent)"},".cm-matchingBracket, &.cm-focused .cm-matchingBracket":{backgroundColor:"color-mix(in srgb, var(--ring) 22%, transparent)",outline:"1px solid color-mix(in srgb, var(--ring) 45%, transparent)"},".cm-nonmatchingBracket":{backgroundColor:"color-mix(in srgb, var(--red) 3
450%, transparent)"},".cm-tooltip":{backgroundColor:"var(--paper)",border:"1px solid var(--border)",borderRadius:"var(--radius)",color:"var(--foreground)",boxShadow:"0 4px 16px rgba(0,0,0,0.25)"},".cm-tooltip.cm-tooltip-autocomplete > ul":{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",maxHeight:"16rem"},".cm-tooltip-autocomplete ul li[aria-selected]":{backgroundColor:"color-mix(in srgb, var(--ring) 25%, transparent)",color:"var(--foreground)"},".cm-completionLabel":{color:"var(--foreground)"},".cm-completionDetail":{color:"var(--muted)",fontStyle:"italic"},".cm-tooltip.cm-tooltip-lint":{padding:"0.25rem 0.5rem"},".cm-diagnosticText":{color:"var(--foreground)"},".cmf-section":{color:"var(--sky)",fontWeight:"500"},".cmf-property":{color:"var(--blue)"},".cmf-dot":{color:"var(--muted)"},".cmf-modifier":{color:"var(--violet)"},".cmf-comparator":{color:"var(--amber)",fontWeight:"600"},".cmf-prefix":{color:"var(--amber)"},".cmf-args":{color:"var(--foreground)"},".cmf-literal":{color:"var(--green)"},".cmf-tool":{color:"var(--teal)",fontStyle:"italic"},".cmf-sep":{color:"var(--muted)"},".cmf-quote":{color:"var(--muted)"},".cmf-pipe":{color:"var(--rose)",fontWeight:"600"},".cmf-invalid":{color:"var(--muted)",textDecoration:"underline dotted color-mix(in srgb, var(--red) 60%, transparent)",opacity:"0.75"},".cmf-d0":{color:"var(--yellow)"},".cmf-d1":{color:"var(--violet)"},".cmf-d2":{color:"var(--sky)"},".cmf-d3":{color:"var(--pink)"},".cmf-d4":{color:"var(--teal)"},".cmf-hint":{color:"var(--muted)",fontStyle:"italic",opacity:"0.85",paddingLeft:"0.35rem"}});var fv=s(3708);let fy={comment:"cmv-comment",verb:"cmv-verb",root:"cmv-root",property:"cmv-property",operator:"cmv-operator",string:"cmv-string",number:"cmv-number",keyword:"cmv-keyword",punct:"cmv-punct"};function fj(e){let t=new fv.vB;for(let s of function(e){let t=[],s=0,a=!0,r=!1,n=!1,l="",i=(e,s,a)=>t.push({kind:e,start:s,end:a});for(;s<e.length;){let t=e[s];if("\n"===t){a=!0,s++;continue}if(" "===t||" "===t||"\r"===t){s++;continue}if("#"===t){let t=s;for(;s<e.length&&"\n"!==e[s];)s++;i("comment",t,s),a=!1;continue}if('"'===t||"'"===t){let l=s;for(s++;s<e.length&&e[s]!==t;)"\\"===e[s]&&s++,s++;s<e.length&&s++,i("string",l,s),a=!1,r=!1,n=!1;continue}if(g4(t)||"-"===t&&g4(e[s+1]??"")){let t=s;for(s++;s<e.length&&/[0-9.eE+-]/.test(e[s]);)s++;i("number",t,s),a=!1,"insert"!==l&&(r=!1),n=!1;continue}if(g3(t)){let t=s;for(;s<e.length&&g5(e[s]);)s++;let o=e.slice(t,s);if(gJ.has(o))i("keyword",t,s);else if(a&&gZ.has(o))i("verb",t,s),l=o,r=!0;else if(r&&!n){let e="formatter"===o||"variant"===o||"insert"===l&&gQ.has(o);i(e?"verb":"root",t,s),r=e}else i("property",t,s);a=!1,n=!1;continue}if("="===t||"!"===t||"*"===t){let t=s;for(;s<e.length&&/[=!*]/.test(e[s]);)s++;i("operator",t,s),a=!1;continue}n="."===t,i("punct",s,s+1),s++,a=!1}return t}(e.state.doc.toString()))t.add(s.start,s.end,ff.NZ.mark({class:fy[s.kind]}));return t.finish()}let fw=ff.Z9.fromClass(class{update(e){e.docChanged&&(this.decorations=fj(e.view))}constructor(e){(0,et._)(this,"decorations",void 0),this.decorations=fj(e)}},{decorations:e=>e.decorations}),fN=ff.Lz.theme({".cm-content":{caretColor:"transparent"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--foreground)",borderLeftWidth:"1px"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"color-mix(in srgb, var(--ring) 30%, transparent)"},".cm-gutters":{backgroundColor:"transparent",border:"none",color:"var(--muted)",opacity:"0.6"},".cm-lineNumbers .cm-gutterElement":{padding:"0 0.5rem 0 0.75rem",minWidth:"2ch"},".cm-activeLineGutter":{backgroundColor:"transparent"},".cm-gutter-lint":{width:"1rem"},".cmv-comment":{color:"var(--muted)",fontStyle:"italic"},".cmv-verb":{color:"var(--violet)",fontWeight:"600"},".cmv-root":{color:"var(--sky)",fontWeight:"500"},".cmv-property":{color:"var(--blue)"},".cmv-operator":{color:"var(--amber)",fontWeight:"600"},".cmv-string":{color:"var(--green)"},".cmv-number":{color:"var(--teal)"},".cmv-keyword":{color:"var(--rose)"},".cmv-punct":{color:"var(--muted)"}});var fk=s(80704),fS=s(15115);
45let fC=[{label:"set",type:"keyword",detail:"set <path> = <value>"},{label:"merge",type:"keyword",detail:"merge <path> = { ... }"},{label:"unset",type:"keyword",detail:"unset <path>"},{label:"clear",type:"keyword",detail:"clear <path>"},{label:"add",type:"keyword",detail:"add <path> <value>, ..."},{label:"prepend",type:"keyword",detail:"prepend <path> <value>, ..."},{label:"insert",type:"keyword",detail:"insert [n] [before|after] <path> = <value>"},{label:"remove",type:"keyword",detail:"remove <path> [<value>, ...]"},{label:"enable",type:"keyword",detail:"enable <path>"},{label:"disable",type:"keyword",detail:"disable <path>"},{label:"use formatter ",type:"keyword",detail:"apply a saved formatter"},{label:"use variant ",type:"keyword",detail:"apply another variant"}],f_=/^\s*(set|merge|unset|clear|add|prepend|remove|enable|disable|insert(\s+\d+\s+(before|after)|\s+(before|after))?)\s+\w*$/,fA=/^\s*insert\s+\w*$/,fR=/^\s*insert\s+\d+\s+\w*$/,fT=[{label:"before",type:"keyword",detail:"n places before the addressed entry"},{label:"after",type:"keyword",detail:"n places after the addressed entry"}],fI=Object.entries(sz).filter(e=>{let[t]=e;return!gW.has(t)}).map(e=>{let[t,s]=e;return{label:t,type:"list"===s.type?"property":"variable",detail:s.label}});function fE(e){let{value:t,onValueChange:s,limits:a,userData:r,currentVariantId:n,placeholder:l,disabled:o,className:d,initialHeight:c="14rem"}=e,m=(0,u.useMemo)(()=>[fw,fN,(0,fk.bu)(e=>{let t=e.state.doc.toString(),s=t.length;return fl(t,a).diagnostics.map(e=>{let t=Math.max(0,Math.min(e.index,s)),a=Math.max(t+1,Math.min(e.index+(e.source?e.source.length:1),s)),r={from:t,to:a,severity:e.severity,message:e.message};if(e.suggestion){let t=e.suggestion;r.actions=[{name:`Replace with ${t}`,apply(e,s,a){e.dispatch({changes:{from:s,to:a,insert:t}})}}]}return r})},{delay:200}),function(e){let{userData:t,currentVariantId:s}=e;return(0,fS.yU)({override:[e=>{let a=e.state.doc.lineAt(e.pos),r=e.state.sliceDoc(a.from,e.pos),n=/use\s+formatter\s+"?([\w\s-]*)$/.exec(r);if(n){var l,i;let s=Object.keys((null==(i=t.formatter)||null==(l=i.definitions)?void 0:l.saved)??{});return{from:e.pos-n[1].length,options:s.map(e=>({label:e,type:"text",detail:"saved formatter"})),validFor:/^[\w\s-]*$/}}let o=/use\s+variant\s+"?([\w-]*)$/.exec(r);if(o)return{from:e.pos-o[1].length,options:(t.variants??[]).filter(e=>e.id!==s).map(e=>({label:e.id,type:"text",detail:e.name??"variant"})),validFor:/^[\w-]*$/};let d=/presets\[instanceId\s*!?\*?=\s*"?([\w-]*)$/.exec(r);if(d)return{from:e.pos-d[1].length,options:(t.presets??[]).map(e=>{var t;return{label:e.instanceId,type:"text",detail:(null==(t=e.options)?void 0:t.name)??e.type}}),validFor:/^[\w-]*$/};let c=/presets\[type\s*!?\*?=\s*"?([\w-]*)$/.exec(r);if(c){let s=[...new Set((t.presets??[]).map(e=>e.type))];return{from:e.pos-c[1].length,options:s.map(e=>({label:e,type:"text",detail:"addon type"})),validFor:/^[\w-]*$/}}let u=/services\[id\s*!?\*?=\s*"?([\w-]*)$/.exec(r);if(u)return{from:e.pos-u[1].length,options:(t.services??[]).map(e=>({label:e.id,type:"text",detail:"service"})),validFor:/^[\w-]*$/};let m=e.matchBefore(/[\w]*/);return m&&(m.from!==m.to||e.explicit)?/^\s*\w*$/.test(r)?{from:m.from,options:fC,validFor:/^\w*$/}:fR.test(r)?{from:m.from,options:fT,validFor:/^\w*$/}:fA.test(r)?{from:m.from,options:[...fT,...fI],validFor:/^\w*$/}:f_.test(r)?{from:m.from,options:fI,validFor:/^\w*$/}:null:null}]})}({userData:r,currentVariantId:n}),fg.Lz.lineWrapping,(0,ff.qf)(l??"")],[a,r,n,l]);return(0,i.jsx)("div",{style:{height:c,minHeight:"8rem"},className:x("w-full rounded-[--radius] border border-[--border] bg-[--paper] shadow-sm overflow-hidden transition","resize-y","focus-within:ring-1 focus-within:ring-[--ring] focus-within:border-brand",o&&"opacity-60 pointer-events-none",d),children:(0,i.jsx)(fg.Ay,{className:"h-full",value:t,onChange:s,editable:!o,theme:fb,indentWithTab:!1,height:"100%",basicSetup:{lineNumbers:!0,foldGutter:!1,highlightActiveLine:!1,highlightActiveLineGutter:!1,autocompletion:!1,bracketMatching:!0,closeBrackets:!0,searchKeymap:!1,highlightSelectionMatches:!1,indentOnInput:!1,drawSelection:!0}
45,extensions:m})})}let fM=["stream","manifest.json","catalog","meta","subtitles","addon_catalog"];function fP(e){let{variants:t,healthChecks:s}=e,{uuid:a,password:r}=ri(),[n,l]=(0,u.useState)(""),[o,d]=(0,u.useState)("stream"),[c,h]=(0,u.useState)("movie"),[p,x]=(0,u.useState)("tt0111161"),[g,f]=(0,u.useState)(""),[b,y]=(0,u.useState)(null),[j,w]=(0,u.useState)([]),[N,k]=(0,u.useState)(!1),S=!!a;(0,u.useEffect)(()=>{l(navigator.userAgent)},[]),(0,u.useEffect)(()=>{a&&ef(a,r).then(w).catch(()=>w([]))},[a,r]);let C=async()=>{if(a){k(!0);try{let e={};for(let[t,s]of new URLSearchParams(g))e[t]=s;y(await eb(a,r,{variants:t,healthChecks:s,userAgent:n,resource:o,type:c||void 0,id:p||void 0,query:e}))}catch(e){y(null),m.oR.error((null==e?void 0:e.message)??"Could not evaluate the conditions")}finally{k(!1)}}};return(0,i.jsxs)(mK,{title:"Test conditions",description:"Describe a request and see which variants would activate for it.",children:[!S&&(0,i.jsx)(lB,{intent:"info-basic",title:"Save this configuration first",description:"Conditions are evaluated on the server, against the configuration you have saved."}),j.length>0&&(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:"Recently seen clients"}),(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["The last ",j.length," user agent",1===j.length?"":"s"," seen on stream and catalogue requests. Installing does not count: a client can install with one user agent and play with another. Select one to test against it."]}),(0,i.jsx)("div",{className:"flex flex-col gap-1",children:j.map(e=>(0,i.jsxs)("button",{type:"button",onClick:()=>l(e.userAgent),className:"text-left text-xs px-2 py-1.5 rounded bg-[--subtle] hover:bg-[--subtle-highlight] break-all",children:[(0,i.jsx)("span",{className:"font-mono",children:e.userAgent}),(0,i.jsxs)("span",{className:"text-[--muted]",children:[" ","\xb7 ",e.requests," request",1===e.requests?"":"s"," \xb7 last ",new Date(e.lastSeen).toLocaleString()]})]},e.userAgent))})]}),(0,i.jsx)(K,{label:"User agent",value:n,onValueChange:l}),(0,i.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,i.jsx)(nc,{label:"Resource",value:o,onValueChange:d,options:fM.map(e=>({label:e,value:e}))}),(0,i.jsx)(K,{label:"Type",value:c,onValueChange:h}),(0,i.jsx)(K,{label:"Id",value:p,onValueChange:x}),(0,i.jsx)(K,{label:"Query",help:"As it would appear in the URL, e.g. profile=tv&hd=1",value:g,onValueChange:f})]}),(0,i.jsx)("div",{children:(0,i.jsx)(v,{size:"sm",intent:"white",rounded:!0,leftIcon:(0,i.jsx)(lV.aze,{}),onClick:C,disabled:!S||N,children:N?"Evaluating...":"Evaluate"})}),b&&(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("div",{className:"space-y-1",children:[0===b.variants.length&&(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No variant has an activation condition."}),b.variants.map(e=>(0,i.jsxs)("div",{className:"flex items-start gap-2 text-sm px-2 py-1.5 rounded bg-[--subtle]",children:[e.matched?(0,i.jsx)(lV.YrT,{className:"mt-0.5 shrink-0 text-[--green]"}):(0,i.jsx)(lV.yGN,{className:"mt-0.5 shrink-0 text-[--muted]"}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("span",{className:"font-medium",children:e.id}),(0,i.jsxs)("span",{className:"text-[--muted] font-mono text-xs break-all",children:[" ",e.when]}),e.error&&(0,i.jsx)("p",{className:"text-xs text-[--red]",children:e.error})]})]},e.id))]}),Object.keys(b.health).length>0&&(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:"Health checks"}),Object.entries(b.health).map(e=>{let[t,s]=e;return(0,i.jsxs)("div",{className:"flex items-start gap-2 text-sm px-2 py-1.5 rounded bg-[--subtle]",children:[s.ok?(0,i.jsx)(lV.YrT,{className:"mt-0.5 shrink-0 text-[--green]"}):(0,i.jsx)(lV.yGN,{className:"mt-0.5 shrink-0 text-[--red]"}),(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("span",{className:"font-medium",children:t}),(0,i.jsxs)("span",{className:"text-[--muted] text-xs",children:[" ",s.status?`HTTP ${s.status}`:"",s.error?` ${s.error}`:""," \xb7 checked"," ",new Date(s.checkedAt).toLocaleTimeString()]})]})]},t)})]})]})]})}let f$=/^[a-z0-9][a-z0-9_-]{0,31}$/;function fD(){let{userData:e,setUserData:t}=ri(),{status:s}=tj(),[a,r]=(0,u.useState)(null),n=null==s?void 0:s.settings.variants,l=(0,u.useMemo)(()=>({maxScriptLength:(null==n?void 0:n.maxScriptLength)??4e3,maxTotalInstru
45ctions:(null==n?void 0:n.maxTotalInstructions)??5e3,maxValueDepth:(null==n?void 0:n.maxValueDepth)??10,maxPathSegments:(null==n?void 0:n.maxPathSegments)??12,maxPathMatches:(null==n?void 0:n.maxPathMatches)??200}),[n]),o=e.variants??[],d=(null==n?void 0:n.max)??10,c=e=>t(t=>({...t,variants:e}));return(null==n?void 0:n.access)==="none"?(0,i.jsx)(lB,{intent:"info-basic",title:"Variants are disabled",description:"This instance has turned off config variants."}):(null==n?void 0:n.access)!=="trusted"||e.trusted?(0,i.jsxs)("div",{className:"space-y-4",id:"variants",children:[(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["A variant is a named set of instructions that adjusts this configuration on the fly. Install one by adding"," ",(0,i.jsx)("code",{className:"text-xs px-1 py-0.5 rounded bg-[--subtle]",children:"?v=<id>"})," ","to your manifest URL and your client treats it as a separate addon. Use it for a second formatter, a different debrid account, or a tighter filter set without maintaining a second config."," ",(0,i.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/config-expressions",target:"_blank",rel:"noreferrer",className:"underline",children:"Language reference"})]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,i.jsx)(v,{size:"sm",intent:"white",rounded:!0,leftIcon:(0,i.jsx)(lV.GGD,{}),onClick:()=>{o.length>=d?m.oR.error(`This instance allows at most ${d} variants.`):c([...o,{id:function(e){if(!e.some(e=>"variant"===e.id))return"variant";for(let t=2;;t++){let s=`variant-${t}`;if(!e.some(e=>e.id===s))return s}}(o),script:""}])},disabled:o.length>=d,children:"Add variant"}),(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:[o.length," of ",d," used"]})]})]}),o.map((t,s)=>(0,i.jsx)(fL,{variant:t,variants:o,userData:e,limits:l,onChange:e=>c(o.map((t,a)=>a===s?{...t,...e}:t)),onDelete:()=>c(o.filter((e,t)=>t!==s)),onPreview:()=>r(t.id)},s)),0===o.length&&(0,i.jsx)(lB,{intent:"info-basic",title:"No variants yet",description:"Add one to serve a second, adjusted version of this configuration from the same UUID."}),o.length>0&&(0,i.jsx)(fP,{variants:o,healthChecks:e.healthChecks}),(0,i.jsx)(fO,{variantId:a,variants:o,userData:e,limits:l,onClose:()=>r(null)})]}):(0,i.jsx)(lB,{intent:"info-basic",title:"Variants are limited to trusted users",description:"This instance only lets trusted users define config variants. Ask the instance owner to add you."})}function fL(e){let{variant:t,variants:s,userData:a,limits:r,onChange:n,onDelete:l,onPreview:o}=e,d=(0,u.useMemo)(()=>fl(t.script,r).diagnostics,[t.script,r]).filter(e=>"error"===e.severity),c=f$.test(t.id)?s.filter(e=>e.id===t.id).length>1?"Another variant already uses this id.":void 0:'Use 1-32 characters: lowercase letters, digits, "-" or "_".';return(0,i.jsxs)(mK,{title:t.name||t.id,action:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(ni,{label:"Enabled",side:"right",value:!1!==t.enabled,onValueChange:e=>n({enabled:e})}),(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(lV.Vap,{}),onClick:o}),(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(lV.IXo,{}),onClick:l})]}),children:[(0,i.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,i.jsx)(K,{label:"Id",help:"Used in the install URL as ?v=<id>. Changing it breaks existing installs.",value:t.id,error:c,onValueChange:e=>n({id:e.toLowerCase()})}),(0,i.jsx)(K,{label:"Name",help:'A label for this list and the install page. To rename the addon in your client, write set addonName = "..." below.',value:t.name??"",onValueChange:e=>n({name:e||void 0})})]}),(0,i.jsx)(K,{label:"Activate when",help:"Optional. A true/false expression that makes this variant apply on its own, without ?v= in the URL. Available: userAgent, resource, type, id, query('name'), header('name'), health('id'), includes(a, b) and matches(value, 'regex'). Selecting the variant in the URL still applies it either way.",placeholder:"includes(userAgent, 'android')",value:t.when??"",onValueChange:e=>n({when:e||void 0})}),(0,i.jsx)(fE,{value:t.script,onValueChange:e=>n({script:e}),limits:r,userData:a,currentVariantId:t.id,placeholder:"# Example: set formatter.id = 'prism' to switch to the built-in Prism formatter."}),(0,i.jsxs)("div",{className:"flex items-center justify-between text-xs text-[--muted]",children:[(0,i.jsxs)("span",{children:[t.script.length," / ",r.maxScriptLength," characters"]}),(0,i.jsx)("span",{className:d.length?"text-[--red]":void 0,children:d.length?`${d.length} error${1===d.length?"":"s"}`:"No errors"})]})]})}function fO(e){let{variantId:t,variants:s,userData:a,limits:r,onClose:n}=e,[l,o]=(0,u.useState)(null);(0,u.useEffect)(()=>{let e=s.find(e=>e.id===t);e&&o(e)},[t,s]);let d=(0,u.useMemo)(()=>
45{if(!l)return null;let{program:e,diagnostics:t}=fl(l.script,r),n=t.filter(e=>"error"===e.severity);if(n.length)return{errors:n,notes:[],patched:null};let i=new Map(s.map(e=>[e.id,fl(e.script,r).program])),o=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=structuredClone(e);return{userData:a,...function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=[],r=new Set;return!function e(t,s,a,r){let n=a.limits??gH,{notes:l,touchedRoots:i,visiting:o,budget:d}=r,c=e=>{l.length<100&&l.push(e)};for(let g of s.statements){var u,m,h,p,x;if(d.instructions<=0){d.exhausted||(d.exhausted=!0,l.push(fx(g,`this request ran past the limit of ${n.maxTotalInstructions} variant instructions; everything after this was skipped`,"limit")));return}if(d.instructions--,"useVariant"===g.op){if(o.has(g.id)){c(fx(g,`variant "${g.id}" is already being applied`,"unknown-variant"));continue}let s=null==(u=a.resolveVariant)?void 0:u.call(a,g.id);if(!s){c(fx(g,`unknown variant "${g.id}"`,"unknown-variant"));continue}o.add(g.id),e(t,s,a,r),o.delete(g.id);continue}if("useFormatter"===g.op){let e=null==t||null==(p=t.formatter)||null==(h=p.definitions)||null==(m=h.saved)?void 0:m[g.name];if(!e){c(fx(g,`no saved formatter named "${g.name}"`,"unknown-formatter"));continue}t.formatter={...t.formatter,id:"custom",selectedSaved:void 0,definitions:{...null==(x=t.formatter)?void 0:x.definitions,custom:{
45name:e.name,description:e.description}}},i.add("formatter");continue}if("insert"===g.op){let e=function(e,t,s,a){let r=[{kind:"key",name:t.root},...t.segments],n=r[r.length-1],l=[e];for(let e=0;e<r.length-1;e++){let t="key"===r[e+1].kind?{}:[];if(0===(l=fh(l,r[e],t)).length)return{kind:"no-match"}}let i=!1,o=0,d=[];for(let e of l){var c;let t,r,l=1;if("key"===n.kind){if(!fi(e))continue;let a=e[n.name];if(void 0===a&&(a=[],fc(e,n.name,a)),!Array.isArray(a)){i=!0;continue}t=a,r="after"===s?a.length-1:0}else if(Array.isArray(e))if("index"===n.kind)t=e,r=n.index<0?e.length+n.index:n.index;else{if("filter"!==n.kind)continue;let s=[];if(e.forEach((e,t)=>{fm(e,n)&&s.push(t)}),0===s.length)continue;t=e,r=s[0],l=s.length}else{i=!0;continue}let u=(c=r,"after"===s?c+a:c-(a-1));u<0||u>t.length||(d.push({array:t,index:u}),o+=l)}return 0===d.length?i?{kind:"not-a-list"}:{kind:"no-match"}:{kind:"ok",positions:d,ambiguity:o>d.length?{count:o}:void 0}}(t,g.path,g.placement,g.count);if("not-a-list"===e.kind){c(fx(g,`"${g.path.raw}" is not a list, insert skipped`,"no-match"));continue}if("no-match"===e.kind){c(fx(g,`"${g.path.raw}" matched no position, instruction skipped`,"no-match"));continue}if(e.ambiguity){let t=e.positions.length>1?"inserted at the first in each list":"inserted at the first";c(fx(g,`"${g.path.raw}" matched ${e.ambiguity.count} entries, ${t}`,"ambiguous"))}for(let{array:t,index:s}of e.positions)t.splice(s,0,...g.values.map(fo));i.add(g.path.root);continue}let s="set"===g.op||"merge"===g.op||"add"===g.op||"prepend"===g.op||"enable"===g.op||"disable"===g.op,f=function(e,t,s){let a=[{kind:"key",name:t.root},...t.segments],r=a[a.length-1],n=[e];for(let e=0;e<a.length-1;e++){let t=s?"key"===a[e+1].kind?{}:[]:void 0;if(0===(n=fh(n,a[e],t)).length)return[]}let l=[];for(let e of n)switch(r.kind){case"key":fi(e)&&l.push({container:e,ke
45y:r.name});break;case"index":{if(!Array.isArray(e))break;let t=fu(r.index,e.length);void 0!==t&&l.push({container:e,key:t});break}case"all":if(Array.isArray(e))e.forEach((t,s)=>l.push({container:e,key:s}));else if(fi(e))for(let t of Object.keys(e))l.push({container:e,key:t});break;case"filter":Array.isArray(e)&&e.forEach((t,s)=>{fm(t,r)&&l.push({container:e,key:s})})}return l}(t,"enable"===g.op||"disable"===g.op?{...g.path,segments:[...g.path.segments,{kind:"key",name:"enabled"}]}:g.path,s);if(0===f.length){c(fx(g,`"${g.path.raw}" matched nothing, instruction skipped`,"no-match"));continue}if(f.length>n.maxPathMatches){c(fx(g,`"${g.path.raw}" matched ${f.length} places, over the limit of ${n.maxPathMatches}`,"limit"));continue}switch(g.op){case"set":for(let e of f)fc(e.container,e.key,fo(g.value));break;case"enable":case"disable":for(let e of f)fc(e.container,e.key,"enable"===g.op);break;case"merge":for(let e of f)fc(e.container,e.key,function e(t,s){if(!fi(s))return fo(s);let a=fi(t)?{...t}:{};for(let[t,r]of Object.entries(s))gY.has(t)||(null===r?delete a[t]:a[t]=e(a[t],r));return a}(e.container[e.key],g.value));break;case"unset":fp(f);break;case"clear":for(let e of f){let t=e.container[e.key];Array.isArray(t)?fc(e.container,e.key,[]):fi(t)?fc(e.container,e.key,{}):c(fx(g,`"${g.path.raw}" is not a list or object, clear skipped`,"no-match"))}break;case"add":case"prepend":for(let e of f){let t=e.container[e.key];if(void 0===t&&(t=[],fc(e.container,e.key,t)),!Array.isArray(t)){c(fx(g,`"${g.path.raw}" is not a list, ${g.op} skipped`,"no-match"));continue}let s=g.values.filter(e=>!t.some(t=>fd(t,e))).map(fo);"add"===g.op?t.push(...s):t.unshift(...s)}break;case"remove":if(0===g.values.length){fp(f);break}for(let e of f){let t=e.container[e.key];if(!Array.isArray(t)){c(fx(g,`"${g.path.raw}" is not a list, remove skipped`,"no-match"));continue}fc(e.container,e.key,t.filter(e=>!g.values.some(t=>fd(e,t))))}}i.add(g.path.root)}}(e,t,s,{notes:a,touchedRoots:r,visiting:new Set(s.activeVariants??[]),budget:s.budget??function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:gH;return{instructions:e.maxTotalInstructions,exhausted:!1}}(s.limits)}),{notes:a,touchedRoots:r}}(a,t,s)}}(a,e,{resolveVariant:e=>i.get(e),limits:r});return{errors:[],notes:o.notes,patched:o.userData}},[l,s,a,r]);return(0,i.jsx)(sl,{open:null!==t,onOpenChange:e=>!e&&n(),title:`Preview: ${(null==l?void 0:l.name)||(null==l?void 0:l.id)||""}`,contentClass:"max-w-4xl",children:(null==d?void 0:d.errors.length)?(0,i.jsx)(lB,{intent:"alert",title:"This script does not parse",description:d.errors.map(e=>`Line ${e.line}: ${e.message}`).join("\n")}):(0,i.jsxs)("div",{className:"space-y-3",children:[(null==d?void 0:d.notes.length)?(0,i.jsx)(lB,{intent:"warning",title:"Some instructions matched nothing",description:d.notes.map(e=>`Line ${e.line}: ${e.message}`).join("\n")}):null,(0,i.jsx)(mn,{oldConfig:a,newConfig:(null==d?void 0:d.patched)??null})]})})}let fU=/^[a-z0-9][a-z0-9_-]{0,31}$/;function fF(){let{userData:e,setUserData:t}=ri(),{status:s}=tj(),a=null==s?void 0:s.settings.healthChecks,r=e.healthChecks??[],n=(null==a?void 0:a.max)??5,[l,o]=(0,u.useState)(null),[d,c]=(0,u.useState)(null),h=e=>t(t=>({...t,healthChecks:e}));return(null==a?void 0:a.access)==="none"?(0,i.jsx)(lB,{intent:"info-basic",title:"Health checks are disabled",description:"This instance has turned off health checks."}):(null==a?void 0:a.access)!=="trusted"||e.trusted?(0,i.jsxs)("div",{className:"space-y-4",id:"healthChecks",children:[(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("p",{className:"text-sm text-[--muted]",children:["A health check is a URL this instance calls to decide whether something is up. Use the result as"," ",(0,i.jsx)("code",{className:"text-xs px-1 py-0.5 rounded bg-[--subtle]",children:"health('id')"})," ","in a variant's activation condition, a group condition, or any stream expression, and drop a service while it is down. Results are cached for the interval you set and shared with anyone else checking the same URL."]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,i.jsx)(v,{size:"sm",intent:"white",rounded:!0,leftIcon:(0,i.jsx)(lV.GGD,{}),onClick:()=>{r.length>=n?m.oR.error(`This instance allows at most ${n} health checks.`):(c((e=>{let t="check";for(let s=2;e.some(e=>e.id===t);s++)t=`check-${s}`;return{id:t,url:""}})(r)),o(r.length))},disabled:r.length>=n,children:"Add health check"}),(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:[r.length," of ",n," used"]})]})]}),r.map((e,t)=>(0,i.jsx)(fz,{check:e,onEdit:()=>{c({...r[t]}),o(t)},onDelete:()=>h(r.filter((e,s)=>s!==t))},t)),0===r.length&&(0,i.jsx)(lB,{intent:"info-basic",title:"No health checks yet",description:"Add one to let a condition react to whether a service is reachable."}),(0,i.jsx)(fV,{draft:d,limits:a,onChange:c,onClose:()=>{o(null),c(null)},onSave:()=>{if(!d)return;if(!fU.test(d.id))return void m.oR.error('Use 1-32 characters: lowercase letters, digits, "-" or "_".');if(r.some((e,t)=>e.id===d.id&&t!==l))return void m.oR.error("Another health check already uses this id.");if(!d.url.trim())return void m.oR.error("A health check needs a URL.");let e=[...r];null!==l&&l<r.length?e[l]=d:e.push(d),h(e),o(null),c(null)}})]}):(0,i.jsx)(lB,{intent:"info-basic",title:"Health checks are limited to trusted users",description:"This instance only lets trusted users define health checks. Ask the instance owner to add you."})}function fz(e){let{check:t,onEdit:s,onDelete:a}=e;return(0,i.jsx)(mK,{title:t.name||t.id,description:t.url,action:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(lV.WXf,{}),onClick:s}),(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(lV.IXo,{}),onClick:a})]}),children:(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["Referenced as"," ",(0,i.jsxs)("span",{className:"font-mono",children:["health('",t.id,"')"]})]})})}function fV(e){var t,s,a,r;let{draft:n,limits:l,onChange:o,onClose:d,onSave:c}=e,{uuid:h,password:p}=ri(),[x,g]=(0,u.useState)(null),[f,b]=(0,u.useState)(!1);if(!n)return null;let y=e=>o({...n,...e}),j=e=>o({...n,expect:{...n.expect,...e}}),w=async()=>
45{if(!h)return void m.oR.error("Save this configuration before testing a health check.");b(!0);try{g(await ev(h,p,n))}catch(e){g(null),m.oR.error((null==e?void 0:e.message)??"Could not run the health check")}finally{b(!1)}};return(0,i.jsx)(sl,{open:!0,onOpenChange:d,title:"Health check",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,i.jsx)(K,{label:"Id",help:"Used as health('id') in conditions.",value:n.id,onValueChange:e=>y({id:e.toLowerCase()})}),(0,i.jsx)(K,{label:"Name",help:"A label for this list.",value:n.name??"",onValueChange:e=>y({name:e||void 0})})]}),(0,i.jsx)(K,{label:"URL",placeholder:"https://status.example.com/api/health",value:n.url,onValueChange:e=>y({url:e})}),(0,i.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,i.jsx)(nc,{label:"Method",value:n.method??"GET",onValueChange:e=>y({method:e}),options:[{label:"GET",value:"GET"},{label:"HEAD",value:"HEAD"}]}),(0,i.jsx)(K,{label:"Expected status",help:"A code (200), a class (2xx) or a range (200-299).",placeholder:"2xx",value:(null==(t=n.expect)?void 0:t.status)??"",onValueChange:e=>j({status:e||void 0})})]}),(0,i.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,i.jsx)(K,{label:"JSON path",help:"Optional. A dotted path into a JSON body, e.g. data.status.",value:(null==(s=n.expect)?void 0:s.jsonPath)??"",onValueChange:e=>j({jsonPath:e||void 0})}),(0,i.jsx)(K,{label:"Expected value",help:"Optional. Compared to the value at that path. Leave empty to require any truthy value.",value:(null==(a=n.expect)?void 0:a.jsonValue)===void 0?"":String(n.expect.jsonValue),onValueChange:e=>{if(!e)return j({jsonValue:void 0});if("true"===e||"false"===e)return j({jsonValue:"true"===e});let t=Number(e);j({jsonValue:""===e.trim()||Number.isNaN(t)?e:t})}})]}),(0,i.jsx)(K,{label:"Body contains",help:"Optional. Text the response body must contain, ignoring case.",placeholder:"operational",value:(null==(r=n.expect)?void 0:r.bodyContains)??"",onValueChange:e=>j({bodyContains:e||void 0})}),(0,i.jsxs)("div",{className:"grid gap-3 md:grid-cols-3",children:[(0,i.jsx)(lm,{label:"Interval (seconds)",help:`How long a result is reused. Minimum ${(null==l?void 0:l.minTtl)??60}.`,value:n.ttl??300,onValueChange:e=>y({ttl:e||void 0})}),(0,i.jsx)(lm,{label:"Timeout (ms)",help:`Maximum ${(null==l?void 0:l.maxTimeout)??1e4}.`,value:n.timeout??3e3,onValueChange:e=>y({timeout:e||void 0})}),(0,i.jsx)(nc,{label:"If the check fails",help:"When the request times out or cannot be made at all.",value:n.onError??"unhealthy",onValueChange:e=>y({onError:e}),options:[{label:"Treat as down",value:"unhealthy"},{label:"Treat as up",value:"healthy"}]})]}),x&&(0,i.jsx)(lB,{intent:x.ok?"success-basic":"warning-basic",title:x.ok?"Healthy":"Not healthy",description:[x.status?`HTTP ${x.status}`:null,x.error,`${x.latencyMs} ms`].filter(Boolean).join(" \xb7 ")}),(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"white-subtle",leftIcon:(0,i.jsx)(lV.z1n,{}),onClick:w,disabled:f||!n.url.trim(),children:f?"Testing...":"Test now"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",onClick:d,children:"Cancel"}),(0,i.jsx)(v,{size:"sm",intent:"primary",onClick:c,children:"Save"})]})]})]})})}function fq(){return(0,i.jsx)(ng,{className:"space-y-4 p-4 sm:p-8",children:(0,i.jsx)(fB,{})})}function fB(){let{mode:e}=sF(),{tab:t,setTab:s}=rv("miscellaneous");return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex items-center w-full",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Miscellaneous"}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Additional settings and configurations."})]}),(0,i.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,i.jsx)(mg,{})})]}),(0,i.jsx)(mv,{tabs:[{value:"background",label:"Background",icon:(0,i.jsx)(lZ.uoG,{className:"w-4 h-4"}),content:(0,i.jsx)(gI,{})},{value:"playback",label:"Playback",icon:(0,i.jsx)(lZ.gSK,{className:"w-4 h-4"}),content:"pro"===e?(0,i.jsx)(gE,{}):(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,i.jsx)(lV.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,i.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Playback settings are only available in Advanced mode."})]})},{value:"display",label:"Display",icon:(0,i.jsx)(lZ.Ny1,{className:"w-4 h-4"}),content:"pro"===e?(0,i.jsx)(gM,{}):(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,i.jsx)(lV.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,i.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Display settings are only available in Advanced mode."})]})},{value:"parent",label:"Parent Config",icon:(0,i.jsx)(lV.ayE,{className:"w-4 h-4"}),content:(0,i.jsx)(gK,{})},{value:"variants",label:"Variants",icon:(0,i.jsx)(lV.s_k,{className:"w-4 h-4"}),content:"pro"===e?(0,i.jsx)(fD,{}):(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,i.jsx)(lV.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,i.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Variants are only available in Advanced mode."})]})},{value:"health-checks",label:"Health Checks",icon:(0,i.jsx)(lV.z1n,{className:"w-4 h-4"}),content:"pro"===e?(0,i.jsx)(fF,{}):(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,i.jsx)(lV.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,i.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Health checks are only available in Advanced mode."})]})}],activeTab:t,onTabChange:s})]})}function fK(e){var t;let{serverUrl:s}=e,{userData:a,setUserData:r,uuid:n,password:l}=ri(),o=(null==(t=a.jellyfin)?void 0:t.apiKeys)??[],[d,c]=(0,u.useState)(""),[h,p]=(0,u.useState)({}),[x,g]=(0,u.useState)(null),[f,b]=(0,u.useState)(null),y=e=>r(t=>({...t,jellyfin:{...t.jellyfin,apiKeys:e.length?e:void 0}})),j=()=>{let e=d.trim();e?o.length>=10?m.oR.error("At most 10 keys."):(y([...o,{id:Array.from(crypto.getRandomValues(new Uint8Array(8)),e=>e.toString(16).padStart(2,"0")).join(""),name:e,createdAt:new Date().toISOString()}]),c(""),m.oR.info("Save your configuration, then copy the key.")):m.oR.error("A key needs a name.")},N=async e=>{let t=h[e.id];if(!t){if(!n)return void m.oR.error("Save your configuration to activate this key.");g(e.id);try{({token:t}=await e1({uuid:n,password:l||null},e.id)),p(s=>({...s,[e.id]:t}))}
45catch(e){m.oR.error(e instanceof es&&e.detail?e.detail:e instanceof Error?e.message:"Failed to get the key");return}finally{g(null)}}await nf(t,{onSuccess:()=>m.oR.success(`Copied ${e.name}`),onError:()=>m.oR.error("Copy failed; select the key and copy it.")})},k=sd({title:"Revoke key",description:f?`Tools using ${f.name} lose access once you save.`:void 0,actionText:"Revoke",onConfirm:()=>{f&&y(o.filter(e=>e.id!==f.id)),b(null)}});return(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("p",{className:"text-xs text-gray-400",children:["Give a tool a key and the server address"," ",(0,i.jsx)("span",{className:"font-mono text-gray-300",children:s})," instead of your password. A key acts as the administrator, so it sees every user's activity and history, though it can't act as a household user with a PIN. Changing your password stops every key; copy them again afterwards."]}),o.length>0&&(0,i.jsx)("ul",{className:"divide-y divide-gray-800 rounded-md border border-gray-800",children:o.map(e=>(0,i.jsxs)("li",{className:"space-y-2 px-3 py-2",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)(lV.Fv0,{className:"shrink-0 text-[--muted]"}),(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsx)("p",{className:"truncate text-sm text-white",children:e.name}),(0,i.jsxs)("p",{className:"truncate text-xs text-[--muted]",children:["Created ",nI(e.createdAt)]})]}),(0,i.jsx)(w,{size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(lV.nxz,{}),"aria-label":`Copy ${e.name}`,loading:x===e.id,onClick:()=>N(e)}),(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(lV.IXo,{}),"aria-label":`Revoke ${e.name}`,onClick:()=>{b(e),k.open()}})]}),h[e.id]&&(0,i.jsx)(K,{type:"text",readOnly:!0,value:h[e.id],className:"font-mono text-sm",onClick:e=>e.currentTarget.select()})]},e.id))}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{placeholder:"Key name",value:d,maxLength:64,onValueChange:c,onKeyDown:e=>{"Enter"===e.key&&j()},className:"flex-1"}),(0,i.jsx)(v,{intent:"white",rounded:!0,onClick:j,disabled:o.length>=10,className:"shrink-0",children:"Create"})]}),(0,i.jsx)(sc,{...k})]})}let fH=e=>x("px-2.5 py-1 text-xs font-medium rounded-full border transition-colors",e?"bg-[--brand]/20 text-[--brand] border-[--brand]/50":"bg-transparent text-[--muted] border-[--border] hover:bg-[--subtle]");function fW(e){let{variants:t,value:s,onChange:a,className:r}=e;return(0,i.jsxs)("div",{className:x("flex flex-wrap gap-1.5",r),children:[(0,i.jsx)("button",{type:"button",onClick:()=>a([]),className:fH(0===s.length),children:"Base config"}),t.map(e=>(0,i.jsxs)("button",{type:"button",onClick:()=>{let t;return t=e.id,a(s.includes(t)?s.filter(e=>e!==t):[...s,t])},className:fH(s.includes(e.id)),title:e.when?"Also applies on its own when its condition matches":void 0,children:[e.name||e.id,e.when?(0,i.jsx)("span",{className:"ml-1 opacity-60",children:"auto"}):null]},e.id))]})}let fG=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,fY=[];function fJ(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,28)||"user"}let fZ=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase();function fQ(e){return(null==e?void 0:e.length)?`Variants ${e.join(", ")}`:"Base config"}function fX(e){return e.length?1===e.length?"1 tracker":`${e.length} trackers`:"no trackers"}function f0(e){let{name:t,avatar:s}=e;return s?(0,i.jsx)("img",{src:s,alt:"",className:"h-8 w-8 shrink-0 rounded-full object-cover"}):(0,i.jsx)("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[--subtle] text-xs font-semibold uppercase text-[--muted]",children:t.trim().charAt(0)||"?"})}function f1(e){let{name:t,avatar:s,summary:a,onEdit:r,onDelete:n}=e;return(0,i.jsxs)("li",{className:"flex items-center gap-3 px-3 py-2",children:[(0,i.jsx)(f0,{name:t,avatar:s}),(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsx)("p",{className:"truncate text-sm text-white",children:t}),(0,i.jsx)("p",{className:"truncate text-xs text-[--muted]",children:a})]}),(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(lV.WXf,{}),"aria-label":`Edit ${t}`,onClick:r}),n&&(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(lV.IXo,{}),"aria-label":`Remove ${t}`,onClick:n})]})}function f2(e){let{variants:t,value:s,onChange:a}=e;return(0,i.jsxs)("div",{className:"space-y-1.5",children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:"Variants"}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Applied while this user is signed in, in the order picked."}),(0,i.jsx)(fW,{variants:t,value:s,onChange:a})]})}function f3(e){let{choices:t,value:s,onChange:a,automatic:r,note:n,loading:l,maxTrackers:o}=e;return(0,i.jsxs)("div",{className:"space-y-1.5",children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:"Trackers"}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:s?s.length?"Syncs only with the tracker addons picked.":"Syncs with
45no trackers.":r}),l?(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Loading tracker addonsâ¦"}):(0,i.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,i.jsx)("button",{type:"button",onClick:()=>a(void 0),className:fH(void 0===s),children:"Automatic"}),(0,i.jsx)("button",{type:"button",onClick:()=>a([]),className:fH(!!s&&!s.length),children:"None"}),t.map(e=>{let t=!!(null==s?void 0:s.includes(e.presetId));return(0,i.jsxs)("button",{type:"button",disabled:!t&&!!e.takenBy,onClick:()=>{var t;let r;return t=e.presetId,void a((r=s??[]).includes(t)?r.filter(e=>e!==t):[...r,t])},className:x(fH(t),"disabled:cursor-not-allowed disabled:opacity-50"),title:e.takenBy?`${e.takenBy} syncs with this tracker`:void 0,children:[e.addon,e.takenBy&&(0,i.jsx)("span",{className:"ml-1 opacity-60",children:e.takenBy})]},e.presetId)})]}),n&&(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:n}),void 0!==o&&s&&s.length>o&&(0,i.jsxs)("p",{className:"text-xs text-[--orange]",children:["This instance syncs each user with at most ",o," trackers, so only ",o," of these are used."]}),(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["A tracker syncs with one history at a time, unless it keeps each user apart, and moving it to another user brings along what it already recorded."," ",l||t.length?"Added a tracker addon? Save, and it shows here.":"No tracker addons in your saved configuration yet; add one and save."]})]})}let f5=/^\d{4,12}$/,f4=RegExp("^\\d{6,12}$");function f6(e){return!!e&&e.startsWith("$2")}function f9(e){let{value:t,onChange:s,help:a="Signing in as this user needs it, typed after the password as password/PIN. Anyone who can edit this configuration can still change or remove it."}=e,[r]=(0,u.useState)(f6(t)?t:void 0),[n,l]=(0,u.useState)(r?"saved":"edit");return"edit"!==n?(0,i.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,i.jsxs)("div",{className:"min-w-0",children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:"PIN"}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"saved"===n?"Set. "+a:"Removed when you save."})]}),(0,i.jsx)("div",{className:"flex flex-none gap-2",children:"saved"===n?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{size:"sm",intent:"gray-outline",rounded:!0,onClick:()=>l("edit"),children:"Change"}),(0,i.jsx)(v,{size:"sm",intent:"alert-subtle",rounded:!0,onClick:()=>{l("removed"),s(void 0)},children:"Remove"})]}):(0,i.jsx)(v,{size:"sm",intent:"gray-outline",rounded:!0,onClick:()=>{l("saved"),s(r)},children:"Undo"})})]}):(0,i.jsx)(K,{label:"PIN",type:"password",inputMode:"numeric",autoComplete:"new-password",placeholder:r?"Unchanged":"None",help:`Optional, 4 to 12 digits. ${a}`,value:f6(t)?"":t??"",onValueChange:e=>{s(e.replace(/\D/g,"").slice(0,12)||r)}})}function f8(){var e,t,s,a,r,n,l,o,d;let{userData:c,setUserData:h,uuid:p,password:x}=ri(),g=u.useMemo(()=>p?{uuid:p,password:x}:null,[p,x]),f=(0,ty.I)(tx(g)),b=!f.data||f.data.push||f.data.pull,y=(null==(e=f.data)?void 0:e.available)??fY,j=!!g&&f.isPending,{status:w}=tj(),N=(null==w||null==(s=w.settings)||null==(t=s.jellyfin)?void 0:t.maxPersonas)??20,k=null==w||null==(r=w.settings)||null==(a=r.jellyfin)?void 0:a.maxTrackers,S=(null==w||null==(l=w.settings)||null==(n=l.jellyfin)?void 0:n.pinSignIn)??!1,C=(null==(o=c.jellyfin)?void 0:o.personas)??[],_=null==(d=c.jellyfin)?void 0:d.primary,A=(null==_?void 0:_.name)||c.addonName||"Primary user",R=(c.variants??[]).filter(e=>!1!==e.enabled).map(e=>({id:e.id,name:e.name,enabled:e.enabled,when:e.when?String(e.when):void 0})),[T,I]=(0,u.useState)(null),[E,M]=(0,u.useState)(null),[P,$]=(0,u.useState)(null),[D,L]=(0,u.useState)(null),O=new Set(y.filter(e=>e.viewers).map(e=>e.presetId)),U=(e,t)=>{let s=new Map;if(null!==e)for(let e of(null==_?void 0:_.trackers)?_.trackers:t?y.filter(e=>""===e.user).map(e=>e.presetId):[])O.has(e)||s.set(e,A);
45return C.forEach((t,a)=>{if(a!==e&&"shared"!==t.history)for(let e of t.trackers??[])O.has(e)||s.has(e)||s.set(e,t.name)}),s},F=(e,t)=>{let s=y.filter(t=>t.user===e);return(s.length?s:y.filter(e=>""===e.user)).map(e=>({...e,takenBy:t.get(e.presetId)}))},z=e=>{var t;return(null==(t=y.find(t=>t.presetId===e))?void 0:t.addon)??e},V=e=>h(t=>({...t,jellyfin:{...t.jellyfin,...e}})),q=()=>{I(null),M(null)},B=null!==D?C[D]:void 0,H=sd({title:"Remove user",description:B?`${B.name} will stop appearing on the sign-in picker once you save. ${"shared"===B.history?"It shares the primary userâs history, so nothing is lost.":"Its watch history is kept, and a user added again under the same name gets it back."}`:void 0,actionText:"Remove",onConfirm:()=>{null!==D&&(V({personas:C.length>1?C.filter((e,t)=>t!==D):void 0}),m.oR.info("Removed. A user with the same name gets its history back.")),L(null)}});return(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("p",{className:"text-xs text-gray-400",children:["Shown as users of the server. Everyone signs in with this configuration's password, and a user with a PIN also needs that, typed after the password as password/PIN. The primary user is this configuration itself; each other user can keep a history and trackers of its own.",S&&" On the sign-in picker address, a user with a PIN of 6 or more digits can sign in with that PIN alone, so each person needs only their own PIN."]}),(0,i.jsxs)("ul",{className:"divide-y divide-gray-800 rounded-md border border-gray-800",children:[(0,i.jsx)(f1,{name:A,avatar:null==_?void 0:_.avatar,summary:["Primary user",fQ(null==_?void 0:_.variants),(null==_?void 0:_.trackers)?fX(_.trackers):"all trackers",(null==_?void 0:_.lock)?"PIN":null].filter(Boolean).join(" \xb7 "),onEdit:()=>$({..._})}),C.map((e,t)=>(0,i.jsx)(f1,{name:e.name,avatar:e.avatar,summary:[fQ(e.variants),"shared"===e.history?"shares the primary user's history":"own history","shared"!==e.history&&e.trackers?fX(e.trackers):null,"shared"!==e.history&&e.id!==fJ(e.name)?`tracker id ${e.id}`:null,e.hidden?"hidden from the picker":null,e.lock?"PIN":null].filter(Boolean).join(" \xb7 "),onEdit:()=>{M({...e}),I(t)},onDelete:()=>{L(t),H.open()}},e.id))]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[N>0?(0,i.jsx)(v,{size:"sm",intent:"white",rounded:!0,leftIcon:(0,i.jsx)(lV.GGD,{}),onClick:()=>{C.length>=N?m.oR.error(`At most ${N} users.`):(M({id:"",name:"",history:"own"}),I(C.length))},disabled:C.length>=N,children:"Add user"}):(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"This instance does not allow extra users."}),C.length>0&&(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:[C.length," of ",N]})]}),P&&(0,i.jsx)(sl,{open:!0,onOpenChange:()=>$(null),title:"Primary user",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(K,{label:"Name",help:"Shown in apps. Defaults to your addon name.",placeholder:c.addonName||"Primary user",value:P.name??"",onValueChange:e=>$({...P,name:e||void 0})}),(0,i.jsx)(f2,{variants:R,value:P.variants??[],onChange:e=>$({...P,variants:e.length?e:void 0})}),b&&(0,i.jsx)(f3,{choices:F("",U(null,!0)),value:P.trackers,onChange:e=>$({...P,trackers:e}),automatic:"Syncs with every tracker addon.",loading:j,maxTrackers:k}),(0,i.jsx)(K,{label:"Avatar URL",help:"Optional. Shown on the sign-in picker.",placeholder:"https://",value:P.avatar??"",onValueChange:e=>$({...P,avatar:e||void 0})}),(0,i.jsx)(f9,{value:P.lock,onChange:e=>$({...P,lock:e}),help:"Needed every time someone signs in as the primary user, even with your configuration password (typed after it as password/PIN), and asked whenever someone switches to it in the web app, so other users can't reach your history. Anyone who can edit this configuration can still change or remove it."}),(0,i.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",onClick:()=>$(null),children:"Cancel"}),(0,i.jsx)(v,{size:"sm",intent:"primary",onClick:()=>{var e,t,s,a;if(!P)return;if(P.lock&&!f6(P.lock)&&!f5.test(P.lock))return void m.oR.error("A PIN is 4 to 12 digits.");let r=(null==(e=P.name)?void 0:e.trim())||"";if(r&&C.some(e=>fZ(e.name,r)))return void m.oR.error("Another user already has this name.");let n=U(null,!1),l=null==(t=P.trackers)?void 0:t.find(e=>n.has(e));if(l)return void m.oR.error(`${n.get(l)} already syncs with ${z(l)}.`);!P.trackers&&C.some(e=>{var t;return"shared"!==e.history&&(null==(t=e.trackers)?void 0:t.some(e=>!O.has(e)))})&&m.oR.warning("Trackers picked for other users stay unused while the primary user syncs with every tracker.");
45let i={name:r||void 0,avatar:(null==(s=P.avatar)?void 0:s.trim())||void 0,variants:(null==(a=P.variants)?void 0:a.length)?P.variants:void 0,trackers:P.trackers,lock:P.lock||void 0};V({primary:Object.values(i).some(Boolean)?i:void 0}),$(null)},children:"Save"})]})]})}),E&&(0,i.jsx)(sl,{open:!0,onOpenChange:q,title:"User",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(K,{label:"Name",help:"Shown in apps, and typed to sign in.",value:E.name,onValueChange:e=>M({...E,name:e})}),(0,i.jsx)(nc,{label:"History",help:"Own: a separate Continue Watching. Shared: the primary user's.",moreHelp:"Sharing the primary user's history means sharing its trackers too. With its own history, a user syncs with the trackers chosen for it.",value:E.history,onValueChange:e=>M({...E,history:e,trackers:"shared"===e?void 0:E.trackers}),options:[{label:"Own",value:"own"},{label:"Shared with the primary user",value:"shared"}]}),(0,i.jsx)(f2,{variants:R,value:E.variants??[],onChange:e=>M({...E,variants:e.length?e:void 0})}),b&&"shared"!==E.history&&(0,i.jsx)(f3,{choices:F(E.id,U(T,!0)),value:E.trackers,onChange:e=>M({...E,trackers:e}),automatic:"Syncs with a tracker addon its variants add, and with any that keeps each user apart.",note:(null==_?void 0:_.trackers)?void 0:"The primary user syncs with every tracker. Choose its trackers to free the rest.",loading:j,maxTrackers:k}),(0,i.jsx)(K,{label:"Avatar URL",help:"Optional. Shown on the sign-in picker.",placeholder:"https://",value:E.avatar??"",onValueChange:e=>M({...E,avatar:e||void 0})}),(0,i.jsx)(ni,{label:"Hide from the sign-in picker",help:"Still signs in by name.",side:"right",value:E.hidden??!1,onValueChange:e=>M({...E,hidden:e||void 0})}),(0,i.jsx)(f9,{value:E.lock,onChange:e=>M({...E,lock:e}),help:S?"Signing in as this user needs it, typed after the password as password/PIN. On the sign-in picker address, a PIN of 6 or more digits also works on its own, without your configuration password. Anyone who can edit this configuration can still change or remove it.":void 0}),(0,i.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",onClick:q,children:"Cancel"}),(0,i.jsx)(v,{size:"sm",intent:"primary",onClick:()=>{var e,t;if(!E)return;let s=E.name.trim();if(!s)return void m.oR.error("A user needs a name.");if(fG.test(s))return void m.oR.error("A name cannot look like a configuration id.");if(fZ(s,A)||C.some((e,t)=>fZ(e.name,s)&&t!==T))return void m.oR.error("Another user already has this name.");let a=new Set(R.map(e=>e.id));if((E.variants??[]).some(e=>!a.has(e)))return void m.oR.error("A linked variant no longer exists or is disabled.");if(E.lock&&!f6(E.lock)&&!f5.test(E.lock))return void m.oR.error("A PIN is 4 to 12 digits.");S&&E.lock&&!f6(E.lock)&&!f4.test(E.lock)&&m.oR.warning("A PIN under 6 digits cannot sign in without your password.");let r="shared"===E.history?void 0:E.trackers,n=U(T,!1),l=null==r?void 0:r.find(e=>n.has(e));if(l)return void m.oR.error(`${n.get(l)} already syncs with ${z(l)}.`);let i=[...C],o={...E,id:E.id||function(e,t){let s=fJ(e),a=s;for(let e=2;t.some(e=>e.id===a);e++)a=`${s}-${e}`;return a}(s,C),name:s,avatar:(null==(e=E.avatar)?void 0:e.trim())||void 0,variants:(null==(t=E.variants)?void 0:t.length)?E.variants:void 0,trackers:r,hidden:E.hidden||void 0,lock:E.lock||void 0};null!==T&&T<C.length?i[T]=o:i.push(o),V({personas:i}),q()},children:"Save"})]})]})}),(0,i.jsx)(sc,{...H})]})}var f7=s(40220),be=s(25612),bt=s(96182);let bs=`${e6}/reference/addon-protocol/watch-state`;function ba(e){let{title:t,children:s,action:a}=e;return(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 py-10 text-center",children:[(0,i.jsx)(f7.A,{className:"h-10 w-10 text-[--muted]"}),(0,i.jsx)("p",{className:"text-lg font-semibold",children:t}),(0,i.jsx)("p",{className:"max-w-sm text-sm text-[--muted]",children:s}),a&&(0,i.jsx)("div",{className:"pt-2",children:a})]})}function br(e){let{icon:t,label:s,exchange:a,verb:r,idle:n}=e;return(0,i.jsxs)("p",{className:"flex min-w-0 items-center gap-1.5 text-xs",children:[(0,i.jsx)("span",{className:"shrink-0 text-gray-500",children:t}),(0,i.jsx)("span",{className:"shrink-0 text-gray-300",children:s}),(0,i.jsxs)("span",{className:a.error?"truncate text-[--orange]":"truncate text-gray-500",title:a.error??void 0,children:["\xb7"," ",a.error?`Failed: ${a.error}`:a.lastAt?`${r} ${nE(a.lastAt)}`:n]})]})}function bn(e){let{tracker:t,owner:s}=e;return(0,i.jsxs)("li",{className:"flex items-start gap-3 px-3 py-2.5",children:[(0,i.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,i.jsxs)("p",{className:"truncate text-sm text-white",children:[t.addon,s&&(0,i.jsxs)("span",{className:"text-[--muted]",children:[" \xb7 ",s]})]}),t.refused&&(0,i.jsx)("p",{className:"text-xs text-[--orange]",children:"Not used: this addon is on a private address, and this instance doesn't connect to private addresses."}),!t.refused&&t.push&&(0,i.jsx)(br,{icon:(0,i.jsx)(be.A,{className:"h-3.5 w-3.5"}),label:"Records your plays",exchange:t.push,verb:"Last sent",idle:"Nothing played yet"}),!t.refused&&t.pull&&(0,i.jsx)(br,{icon:(0,i.jsx)(bt.A,{className:"h-3.5 w-3.5"}),label:"Imports your history",exchange:t.pull,verb:"Last read",idle:"Read when a client opens"})]}),!t.refused&&"connected"!==t.status&&(0,i.jsx)("span",{className:"shrink-0 rounded-full border border-amber-400/30 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-amber-300",title:"auth_expired"===t.status?"The addon rejected its credentials. Sign in to it again, then save.":"Paused after repeated failures. It is retried every so often.",children:"auth_expired"===t.status?"Reconnect":"Paused"})]})}function bl(){var e,t,s;let{uuid:a,password:r,userData:n}=ri(),l=u.useMemo(()=>a?{uuid:a,password:r}:null,[a,r]),{data:o,isPending:d,isError:c,refetch:m,isFetching:h}=(0,ty.I)(tx(l));if(!l)return(0,i.jsx)(ba,{title:"Save to see your trackers",children:"Trackers are found from your saved configuration."});if(d)return(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(uD,{className:"h-16 w-full"}),(0,i.jsx)(uD,{className:"h-16 w-full"})]});if(c)return(0,i.jsx)(ba,{title:"Couldn't load your trackers",action:(0,i.jsx)(v,{intent:"gray-outline",size:"sm",loading:h,onClick:()=>m(),children:"Try again"}),children:"Your addons may be slow to answer."});if(!o.push&&!o.pull)return(0,i.jsx)(ba,{title:"Watch state sync is off",children:"This instance doesn't exchange watch state with addons."});if(!o.trackers.length)return(0,i.jsx)(ba,{title:"No tracker addons",action:(0,i.jsx)(v,{intent:"gray-outline",size:"sm",rightIcon:(0,i.jsx)(lV.HaR,{}),onClick:()=>window.open(bs,"_blank","noopener,noreferrer"),children:"Build one"}),children:"An addon that supports Watch State can record what you play in the apps and bring in what you watched elsewhere. None of yours do yet."});let p=(null==(e=n.jellyfin)?void 0:e.personas)??[],x=(null==(s=n.jellyfin)||null==(t=s.primary)?void 0:t.name)||n.addonName||"Primary user",g=o.trackers.some(e=>e.persona);return(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsx)("p",{className:"text-xs text-gray-400",children:o.push&&o.pull?"Addons that record what you play here and bring in what you watched elsewhere, for Continue Watching and Next Up.":o.push?"Addons that record what you play here. This instance does not import history from them.":"Addons that bring in what you watched elsewhere, for Continue Watching and Next Up. This instance does not send them your plays."}),(0,i.jsx)("ul",{className:"divide-y divide-gray-800 rounded-md border border-gray-800",children:o.trackers.map(e=>{var t;return(0,i.jsx)(bn,{tracker:e,owner:g?e.persona?(null==(t=p.find(t=>
45t.id===e.persona))?void 0:t.name)??e.persona:x:void 0},`${e.persona??""}|${e.addon}`)})}),(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"From your saved configuration. To choose which trackers each user syncs with, edit them under Users. To stop an addon syncing, untick Watch State in its Resources option."})]})}var bi=s(30028),bo=s(62116),bd=s(41460),bc=s(42017),bu=s(44522),bm=s(55560),bh=s(41131),bp=s(41896),bx=s(69799);let bg=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;function bf(e){return e.split(",").map(e=>decodeURIComponent(e).trim()).filter(Boolean)}function bb(e){let t=/\/v\/([^/?]+)/.exec(e),s=/[?&]v=([^&]+)/.exec(e),a=(null==t?void 0:t[1])??(null==s?void 0:s[1]);return a?bf(a):[]}function bv(){let{user:e}=su(),{uuid:t,password:s}=ri(),a=(0,e3.jE)(),{data:r}=(0,ty.I)({...tu,enabled:!!e}),n=(null==r?void 0:r.profiles.find(e=>e.uuid===t))??null,[l,o]=u.useState(""),[d,c]=u.useState(""),[h,p]=u.useState(""),[x,g]=u.useState(!1);if(u.useEffect(()=>{o((null==n?void 0:n.label)??""),c((null==n?void 0:n.alias)??"")},[null==n?void 0:n.id,null==n?void 0:n.label,null==n?void 0:n.alias]),!e||!t)return null;let f=s||h,b=async(e,t)=>{g(!0);try{await e(),await a.invalidateQueries({queryKey:tu.queryKey}),m.oR.success(t)}catch(e){m.oR.error(e instanceof Error?e.message:"Something went wrong")}finally{g(!1)}};return(0,i.jsx)(mK,{title:"Profile",description:n?`Saved to ${e.username}. Pick it from Load Configuration to reopen it without the password.`:`Save this configuration to ${e.username} so you can reopen it without the password.`,children:n?(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end gap-2",children:[(0,i.jsx)(K,{label:"Name",value:l,onValueChange:o,className:"flex-1"}),(0,i.jsx)(v,{intent:"gray-subtle",rounded:!0,loading:x,disabled:!l.trim()||l.trim()===n.label,onClick:()=>b(()=>eS(n.id,{label:l.trim()}),"Renamed"),children:"Rename"})]}),(0,i.jsxs)("div",{className:"space-y-1.5",children:[(0,i.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end gap-2",children:[(0,i.jsx)(K,{label:"Share alias",value:d,onValueChange:c,placeholder:"Optional, e.g. living-room",className:"flex-1"}),(0,i.jsx)(v,{intent:"gray-subtle",rounded:!0,loading:x,disabled:d.trim().toLowerCase()===(n.alias??""),onClick:()=>b(()=>eS(n.id,{alias:d.trim()?d.trim():null}),d.trim()?"Alias set":"Alias removed"),children:d.trim()?"Set alias":"Clear alias"})]}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:n.alias?"Your manifest URL and sign-in picker address use this alias. Anyone with it can install this configuration, so treat it like the long URL, and keep it hard to guess.":"An alias shortens your manifest URL and sign-in picker address. It replaces the UUID and password in them, so it grants the same access."})]}),(0,i.jsx)(v,{intent:"alert-subtle",rounded:!0,size:"sm",loading:x,onClick:()=>b(()=>eC(n.id),"Profile deleted. The configuration itself is untouched."),children:"Delete profile"})]}):(0,i.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end gap-2",children:[(0,i.jsx)(K,{label:"Name",value:l,onValueChange:o,placeholder:"Optional",className:"flex-1"}),!s&&(0,i.jsx)(G,{label:"Password",value:h,onValueChange:p,placeholder:"This configuration's password",className:"flex-1"}),(0,i.jsx)(v,{intent:"white",rounded:!0,loading:x,disabled:!f,onClick:()=>b(()=>ek(t,f,l.trim()||void 0),"Saved to your profile"),children:"Save as profile"})]})})}function by(e,t){return Array.from(new Set(e.map(e=>(function(e){let{baseUrl:t,uuid:s,encryptedPassword:a,alias:r,variantIds:n=[],location:l="path"}=e;if(!s)return"";let i=r??(bg.test(s)?null:s)??null,o=i?`${t}/stremio/u/${i}`:`${t}/stremio/${s}/${a}`,d=n.map(encodeURIComponent).join(","),c=d&&"path"===l?`/v/${d}`:"",u=d&&"query"===l?`?v=${d}`:"";return`${o}${c}/manifest.json${u}`})({...t,variantIds:e})).filter(Boolean)))}function bj(e){let{variants:t,value:s,onChange:a,baseUrl:r,uuid:n,encryptedPassword:l,alias:o}=e,d=t.filter(e=>!1!==e.enabled);if(0===d.length)return null;let c=s.length>0?s:[[]],u=by(c,{baseUrl:r,uuid:n,encryptedPassword:l,alias:o});return(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"What to push"}),(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"Each row is installed as its own addon. Pick more than one variant in a row to combine them into a single addon."})]}),(0,i.jsx)("div",{className:"space-y-2",children:c.map((e,t)=>(0,i.jsx)("div",{className:"rounded-lg border border-gray-700 bg-gray-800/40 p-2.5",children:(0,i.jsxs)("div",{className:"flex items-start gap-2",children:[(0,i.jsx)(fW,{className:"flex-1",variants:d,value:e,onCh
45ange:e=>a(c.map((s,a)=>a===t?e:s))}),c.length>1&&(0,i.jsx)(w,{intent:"gray-basic",size:"sm","aria-label":"Remove",icon:(0,i.jsx)(W.SXS,{}),onClick:()=>a(c.filter((e,s)=>s!==t))})]})},t))}),(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsxs)("button",{type:"button",onClick:()=>a([...c,[]]),className:"flex items-center gap-1 text-xs text-gray-400 hover:text-[--brand]",children:[(0,i.jsx)(W._rf,{className:"h-3 w-3"})," Add another addon"]}),(0,i.jsxs)("span",{className:"text-xs text-gray-500",children:[u.length," addon",1===u.length?"":"s"]})]})]})}function bw(e){var t;return{mode:(null==(t=e.authMethods[0])?void 0:t.id)??"",values:{}}}function bN(e,t){let s=e.authMethods.find(e=>e.id===t.mode);return[...e.commonFields??[],...(null==s?void 0:s.fields)??[]]}function bk(e,t){let s={mode:t.mode};for(let a of bN(e,t))s[a.key]=(t.values[a.key]??"").trim();return s}function bS(e,t){return bN(e,t).every(e=>e.optional||(t.values[e.key]??"").trim())}function bC(e){let{platform:t,value:s,onChange:a}=e,r=t.authMethods.find(e=>e.id===s.mode),n=e=>{let t={key:e.key,label:e.label,help:e.help,placeholder:e.placeholder,value:s.values[e.key]??"",onValueChange:t=>{let r;return r=e.key,a({...s,values:{...s.values,[r]:t}})}};return"password"===e.type?(0,i.jsx)(G,{...t}):(0,i.jsx)(K,{...t,type:"email"===e.type?"email":"text"})};return(0,i.jsxs)(i.Fragment,{children:[(t.commonFields??[]).map(n),t.authMethods.length>1&&(0,i.jsx)(nc,{label:"Sign in with",value:s.mode,onValueChange:e=>a({...s,mode:e,values:s.values}),options:t.authMethods.map(e=>({value:e.id,label:e.label}))}),((null==r?void 0:r.fields)??[]).map(n),(null==r?void 0:r.note)&&(0,i.jsx)("p",{className:"text-xs text-gray-500",children:r.note})]})}function b_(e,t){return e instanceof Error&&e.message?e.message:t}function bA(e){var t,s,a;let{manifestUrl:r}=e,{uuid:n,password:l,encryptedPassword:o,userData:d}=ri(),{currentManifestFingerprint:c,currentManifestUrl:h}=mx(),{status:p}=tj(),x={baseUrl:(null==p||null==(t=p.settings)?void 0:t.baseUrl)||("u">typeof window?window.location.origin:""),uuid:n??"",encryptedPassword:o??void 0},g=d.variants??[],f=n?{uuid:n,password:l}:null,b=(0,e3.jE)(),{data:y,isPending:j}=(0,ty.I)(tm(f)),{data:w=[]}=(0,ty.I)(tg(f)),N=e=>w.find(t=>t.id===e)??null,[k,C]=u.useState(null),[_,A]=u.useState(null),R=so(!1),T=()=>b.invalidateQueries({queryKey:th});if(!f)return null;let I=async e=>{C(e.id);try{await eJ(f,e.id),m.oR.success(`Pushed to ${e.label}`)}catch(t){m.oR.error(b_(t,`Could not push to ${e.label}`))}finally{C(null),T()}},E=((null==y?void 0:y.length)??0)>0,M=null==p||null==(a=p.settings)||null==(s=a.limits)?void 0:s.maxLinkedAccounts,P=void 0!==M&&((null==y?void 0:y.length)??0)>=M;return(0,i.jsxs)("div",{id:"linked-accounts",children:[(0,i.jsxs)("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 flex items-center gap-2",children:[(0,i.jsx)("div",{className:"h-px bg-gray-700 flex-1"}),"Linked accounts",(0,i.jsx)("div",{className:"h-px bg-gray-700 flex-1"})]}),j?(0,i.jsx)("div",{className:"flex justify-center py-4",children:(0,i.jsx)(S,{})}):E?(0,i.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(y??[]).map(e=>{var t;let s;return(0,i.jsx)(bR,{account:e,platform:N(e.platform),stale:(s=(null==(t=e.config)?void 0:t.manifestUrls)??[],!!h&&!!c&&!!e.lastPushedManifestHash&&1===s.length&&s[0]===h&&e.lastPushedManifestHash!==c),busy:k===e.id,onPush:()=>I(e),onManage:()=>A(e)},e.id)}),(0,i.jsxs)("button",{type:"button",onClick:R.open,disabled:P,className:"group flex items-center justify-center gap-2 rounded-xl border-2 border-dashed border-gray-700 p-3 text-sm text-gray-400 transition-colors enabled:hover:border-brand-400 enabled:hover:text-brand-400 disabled:cursor-not-allowed disabled:opacity-60",children:[(0,i.jsx)(W.sDI,{className:"h-4 w-4"}),P?`Limit of ${M} linked accounts reached`:"Link another account"]})]}):(0,i.jsxs)("div",{className:"flex flex-col gap-3 rounded-xl border border-gray-700/70 bg-gray-800/30 px-4 py-3 sm:flex-row sm:items-center",children:[(0,i.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,i.jsx)(W.sDI,{
45className:"h-4 w-4 shrink-0 text-gray-500"}),(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsx)("p",{className:"text-sm text-gray-300",children:"Keep AIOStreams up to date automatically"}),(0,i.jsxs)("p",{className:"text-xs text-gray-500",children:["Optional. Link ",`to one of the supported platforms (e.g. ${w.slice(0,3).map(e=>e.name).join(", ")})`," and AIOStreams can push config changes for you, instead of you reinstalling by hand."]})]})]}),(0,i.jsx)(v,{intent:"gray-outline",className:"w-full sm:w-auto",onClick:R.open,children:"Link an account"})]}),(0,i.jsx)(bT,{variants:g,urlParts:x,open:R.isOpen,onOpenChange:e=>e?R.open():R.close(),credentials:f,manifestUrl:r,onLinked:()=>{R.close(),T()}}),(0,i.jsx)(bI,{variants:g,urlParts:x,account:_,platform:_?N(_.platform):null,credentials:f,onClose:()=>A(null),onChanged:()=>{A(null),T()}})]})}function bR(e){let{account:t,platform:s,stale:a,busy:r,onPush:n,onManage:l}=e,o="error"===t.lastStatus,d="expired"===t.lastStatus,c="ok"===t.lastStatus,[u,m]=d?["bg-red-300","Sign in again"]:o?["bg-red-300",t.lastError??"Last push failed"]:a?["bg-amber-400","Changes not pushed"]:c?["bg-emerald-400",`Pushed ${function(e){if(!e)return"never";let t=Math.round((Date.now()-e)/1e3);if(t<60)return"just now";let s=Math.round(t/60);if(s<60)return`${s}m ago`;let a=Math.round(s/60);return a<24?`${a}h ago`:`${Math.round(a/24)}d ago`}(t.lastSyncedAt)}`]:["bg-gray-600","Not pushed yet"];return(0,i.jsxs)("div",{className:"flex flex-col gap-3 rounded-xl border-2 border-gray-700 bg-gradient-to-br from-gray-800/50 to-gray-800/30 p-3 lg:flex-row lg:items-center",children:[(0,i.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,i.jsx)("div",{className:"flex-shrink-0 h-8 w-8 rounded-lg overflow-hidden flex items-center justify-center",children:(null==s?void 0:s.logo)&&(0,i.jsx)("img",{src:s.logo,alt:s.name,className:"h-full w-full object-contain"})}),(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,i.jsx)("span",{className:"truncate text-sm font-medium text-white",children:t.label}),(0,i.jsx)("span",{title:m,className:`h-1.5 w-1.5 shrink-0 rounded-full ${u}`})]}),(0,i.jsx)("p",{className:"truncate text-xs text-gray-500",children:m})]})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2 lg:shrink-0",children:[(0,i.jsx)(v,{intent:"primary-subtle",size:"sm",className:"flex-1 lg:flex-none",loading:r,onClick:n,leftIcon:(0,i.jsx)(W.JbZ,{className:"h-3.5 w-3.5"}),children:"Push"}),(0,i.jsx)(w,{intent:"gray-basic",size:"sm","aria-label":`Manage ${t.label}`,icon:(0,i.jsx)(W.xPd,{}),onClick:l})]})]})}function bT(e){let{variants:t,urlParts:s,open:a,onOpenChange:r,credentials:n,manifestUrl:l,onLinked:o}=e,{data:d=[]}=(0,ty.I)(tg(n)),[c,h]=u.useState(null),p=d.find(e=>e.id===c)??d[0]??null,[x,g]=u.useState(null),[f,b]=u.useState([[]]),[y,j]=u.useState(!1),[w,N]=u.useState({state:"idle"});u.useEffect(()=>{g(p?bw(p):null),N({state:"idle"})},[null==p?void 0:p.id]);let k=(null==p?void 0:p.probeOn)?((null==x?void 0:x.values[p.probeO
45n])??"").trim().replace(/\/+$/,""):"";u.useEffect(()=>{if(!(null==p?void 0:p.probeOn)||!a||!k)return void N({state:"idle"});let e=!1;N({state:"checking"});let t=setTimeout(async()=>{try{let t=await eH(n,p.id,k);e||N({state:t.ok?"ok":"bad",message:t.ok?`Reachable${t.version?` (${p.name} ${t.version})`:""}`:t.message})}catch(t){e||N({state:"bad",message:b_(t,"Could not reach that address.")})}},400);return()=>{e=!0,clearTimeout(t)}},[null==p?void 0:p.id,null==p?void 0:p.probeOn,a,k]);let S=async()=>{if(!p||!x)return;let e=t.length?by(f,s):[l];j(!0);try{let t=await eW(n,{platform:p.id,input:bk(p,x),manifestUrls:e});m.oR.success(`Linked ${t.label}`),o()}catch(e){m.oR.error(b_(e,"Could not link that account"))}finally{j(!1)}},C=!!p&&!!x&&bS(p,x)&&(!p.probeOn||"ok"===w.state);return(0,i.jsx)(sl,{open:a,onOpenChange:r,title:"Link an account",description:"AIOStreams will push this configuration's manifest URL to the account you link. Nothing else on that account is changed.",contentClass:"max-w-lg",children:(0,i.jsxs)("div",{className:"min-w-0 space-y-4",children:[d.length>1&&(0,i.jsx)(nc,{label:"Platform",value:(null==p?void 0:p.id)??"",onValueChange:h,options:d.map(e=>({value:e.id,label:e.name}))}),p&&x&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("p",{className:"text-xs text-gray-400",children:p.description}),(0,i.jsx)(bC,{platform:p,value:x,onChange:g}),"checking"===w.state&&(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"Checkingâ¦"}),"bad"===w.state&&(0,i.jsx)(lB,{intent:"warning",description:w.message}),"ok"===w.state&&(0,i.jsx)("p",{className:"text-xs text-emerald-400",children:w.message})]}),t.length>0?(0,i.jsx)(bj,{variants:t,value:f,onChange:b,...s}):(0,i.jsxs)("div",{className:"min-w-0 rounded-lg bg-gray-900/40 p-3",children:[(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"Will keep this URL up to date"}),(0,i.jsx)("p",{className:"break-all font-mono text-xs text-gray-400",children:l})]}),(0,i.jsx)(v,{className:"w-full",intent:"primary",disabled:!C,loading:y,onClick:S,children:"Link account"})]})})}function bI(e){var t;let{variants:s,urlParts:a,account:r,platform:n,credentials:l,onClose:o,onChanged:d}=e,[c,h]=u.useState(""),[p,x]=u.useState(!0),[g,f]=u.useState([[]]),[b,y]=u.useState(!1),j=sd({title:"Unlink account",description:(null==r||null==(t=r.config)?void 0:t.mintedSession)?"AIOStreams will stop pushing updates and sign out the session it created, so the stored credential stops working. The addon stays installed there.":"AIOStreams will stop pushing updates and forget the credential you gave it. The addon stays installed there.",onConfirm:async()=>{if(r)try{await eY(l,r.id),m.oR.success("Account unlinked"),d()}catch(e){m.oR.error(b_(e,"Could not unlink that account"))}}});u.useEffect(()=>{var e;if(!r)return;h(r.label),x(r.autoPush);let t=(null==(e=r.config)?void 0:e.manifestUrls)??[];f(t.length?t.map(bb):[[]])},[r]);let w=async()=>{if(r){y(!0);try{await eG(l,r.id,{label:c,autoPush:p,...s.length?{manifestUrls:by(g,a)}:{}}),m.oR.success("Saved"),d()}catch(e){m.oR.error(b_(e,"Could not save those changes"))}finally{y(!1)}}};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(sl,{open:null!==r,onOpenChange:e=>{e||o()},title:(null==n?void 0:n.name)??(null==r?void 0:r.label)??"",description:(null==r?void 0:r.identity)??void 0,contentClass:"max-w-md",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(K,{label:"Name",value:c,onValueChange:h}),(0,i.jsx)(bj,{variants:s,value:g,onChange:f,...a}),(0,i.jsxs)("div",{className:"flex items-center justify-between rounded-lg bg-gray-800/50 p-3",children:[(0,i.jsxs)("div",{className:"flex-1 pr-3",children:[(0,i.jsx)("div",{className:"text-sm font-medium text-white",children:"Include in automatic pushes"}),(0,i.jsx)("div",{className:"mt-1 text-xs text-gray-400",children:"Only applies when you have turned automatic pushing on."})]}),(0,i.jsx)(ni,{id:"linked-account-auto-push",value:p,onValueChange:x})]}),(0,i.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,i.jsx)(v,{intent:"alert-subtle",onClick:j.open,children:"Unlink"}),(0,i.jsx)(v,{intent:"primary",loading:b,onClick:w,children:"Save"})]})]})}),(0,i.jsx)(sc,{...j})]})}let bE="aiostreams:linked-accounts:offer-dismissed";function bM(e){let{open:t,onOpenChange:s,credentials:a,manifestUrl:r}=e,n=(0,e3.jE)(),{data:l=[]}
45=(0,ty.I)(tg(a)),o=l.filter(e=>"client"===e.kind),[d,c]=u.useState(null),h=o.find(e=>e.id===d)??o[0]??null,[p,x]=u.useState(null),[g,f]=u.useState(!1),[b,y]=u.useState(null);u.useEffect(()=>{x(h?bw(h):null)},[null==h?void 0:h.id]);let j=e=>{e&&localStorage.setItem(bE,"true"),s(!1)},w=async()=>{if(h&&p){f(!0);try{let e=await eW(a,{platform:h.id,input:bk(h,p),manifestUrls:[r]});await eJ(a,e.id),await n.invalidateQueries({queryKey:th}),y(e.identity??h.name),m.oR.success(`AIOStreams installed to ${e.identity??h.name}`)}catch(e){m.oR.error(e instanceof Error?e.message:`Could not link your ${h.name} account`)}finally{f(!1)}}};return h?(0,i.jsx)(sl,{open:t,onOpenChange:e=>{e||j(!1)},title:b?"All set":`Install to ${h.name}?`,description:b?void 0:h.description,contentClass:"max-w-lg",children:b?(0,i.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,i.jsx)(lB,{intent:"success",title:`AIOStreams is installed to ${b}.`,description:" Whenever you change your configuration you will be offered the chance to push the update, so you never have to reinstall by hand. "}),(0,i.jsx)(v,{intent:"primary",className:"w-full",onClick:()=>j(!1),children:"Done"})]}):(0,i.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,i.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-gray-700 bg-gray-800/40 p-3",children:[h.logo&&(0,i.jsx)("img",{src:h.logo,alt:h.name,className:"h-8 w-8 shrink-0 object-contain"}),(0,i.jsx)("p",{className:"text-xs text-gray-400",children:"This is optional. You can close it and install from the links on this page instead."})]}),o.length>1&&(0,i.jsx)(nc,{label:"Install to",value:h.id,onValueChange:c,options:o.map(e=>({value:e.id,label:e.name}))}),p&&(0,i.jsx)(bC,{platform:h,value:p,onChange:x}),(0,i.jsx)(lB,{intent:"info-basic",description:(0,i.jsx)("div",{children:"Installing somewhere else, want to install manually or not sure yet? Skip this. Your install links are on this page whenever you need them."})}),(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsxs)(v,{intent:"primary",className:"w-full",disabled:!p||!bS(h,p),loading:g,onClick:w,leftIcon:(0,i.jsx)(W.JbZ,{className:"h-4 w-4"}),children:["Install to ",h.name]}),(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsx)("button",{type:"button",onClick:()=>j(!1),className:"text-xs text-gray-400 hover:text-white",children:"Not now"}),(0,i.jsx)("button",{type:"button",onClick:()=>j(!0),className:"text-xs text-gray-500 hover:text-white",children:"Don't show this again"})]})]})]})}):null}function bP(e){let{onClick:t,icon:s,title:a,description:r}=e;return(0,i.jsxs)("button",{onClick:t,className:"group relative flex flex-col items-center gap-4 roun
45ded-xl border-2 border-gray-700 bg-gradient-to-br from-gray-800/50 to-gray-800/30 p-6 text-center transition-all hover:border-brand-400 hover:from-brand-400/10 hover:to-brand-400/5 focus:outline-none focus-visible:ring-1 focus-visible:ring-brand-400",children:[(0,i.jsx)("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-gradient-to-br from-brand-500 to-brand-600 text-white shadow-lg transition-transform group-hover:scale-110",children:s}),(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"text-lg font-bold text-white",children:a}),(0,i.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-gray-400",children:r})]})]})}function b$(e){let{logoSrc:t,icon:s,name:a,description:r,onClick:n,unofficial:l,beta:o,author:d,disabled:c,disabledReason:u}=e;return(0,i.jsxs)("button",{onClick:n,disabled:c,className:`group relative flex items-center gap-3 rounded-xl border-2 border-gray-700 bg-gradient-to-br from-gray-800/50 to-gray-800/30 p-3 text-left transition-all focus:outline-none focus-visible:ring-1 focus-visible:ring-brand-400 ${c?"cursor-not-allowed opacity-60":"hover:border-brand-400 hover:from-brand-400/10 hover:to-brand-400/5"}`,children:[(0,i.jsx)("div",{className:"flex-shrink-0 h-8 w-8 rounded-lg overflow-hidden flex items-center justify-center text-brand-400",children:t?(0,i.jsx)("img",{src:t,alt:a,className:"h-full w-full object-contain"}):s}),(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,i.jsx)("span",{className:"text-sm font-medium text-white",children:a}),o&&(0,i.jsx)("span",{className:"rounded-full border border-amber-400/30 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-amber-300",children:"Beta"}),l&&(0,i.jsx)("span",{className:"rounded-full border border-gray-600 bg-gray-800/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-300",children:"Unofficial"})]}),(0,i.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:r}),d&&(0,i.jsxs)("p",{className:"text-[11px] text-gray-500 mt-0.5",children:["Integration author: ",d]}),u&&(0,i.jsx)("p",{className:"text-[11px] text-amber-300 mt-1",children:u})]})]})}function bD(e){let{onSubmit:t,passwordRequirements:s,newPassword:a,confirmNewPassword:r,onNewPasswordChange:n,onConfirmNewPasswordChange:l,staySignedIn:o,onStaySignedInChange:d,createLoading:c}=e;return(0,i.jsx)(mK,{title:"Create Configuration",description:"Set up your personalised addon configuration",children:(0,i.jsxs)("form",{onSubmit:t,className:"space-y-4",children:[(0,i.jsxs)("div",{children:[s.length>0&&(null==a?void 0:a.length)>0&&(0,i.jsx)(lB,{intent:"alert",title:"Password Requirements",description:(0,i.jsx)("ul",{className:"list-disc list-inside",children:s.map(e=>(0,i.jsx)("li",{children:e},e))})}),(0,i.jsx)(G,{label:"Password",id:"password",name:"new-password",value:a,onValueChange:n,placeholder:"Enter a password to protect your configuration",required:!0,autoComplete:"new-password"}),(0,i.jsx)("div",{className:"pt-2",children:(0,i.jsx)(G,{label:"Confirm Password",id:"confirm-password",name:"confirm-new-password",value:r,onValueChange:l,placeholder:"Re-enter your password",required:!0,autoComplete:"new-password"})}),(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"This is the password you will use to access and update your configuration later. You can change your password later using the Change Password option, but please remember your current password as it is required to make changes."})]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[(0,i.jsx)(v,{intent:"white",type:"submit",loading:c,rounded:!0,children:"Create"}),null!==o&&(0,i.jsx)(lt,{label:"Remember me",fieldClass:"flex w-auto gap-2",value:o,onValueChange:e=>d(!0===e)})]})]})})}function bL(e){let{open:t,onOpenChange:s,showChanges:a,onShowChangesChange:r,manifestNotice:n,onManifestNoticeChange:l,pushBehaviour:o,onPushBehaviourChange:d,hasLinkedAccounts:c}=e;return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Save preferences",description:"These apply wherever you open this configuration. Remember to save.",contentClass:"max-w-lg",children:(0,i.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,i.jsxs)("div",{className:"flex-1 pr-3",children:[(0,i.jsx)("div",{className:"text-sm font-medium text-white",children:"Show changes before saving"}),(0,i.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Review a diff of what you changed before it is
45written"})]}),(0,i.jsx)(ni,{id:"show-changes",value:a,onValueChange:r})]}),(0,i.jsx)(nc,{label:"Manifest change notices",help:"Some clients (e.g. Stremio) cache your manifest, so a change can need a reinstall. This is when you get told.",value:n,onValueChange:e=>l(e),options:[{value:"always",label:"On every change"},{value:"significant",label:"Only significant changes"},{value:"never",label:"Never"}]}),c&&(0,i.jsx)(nc,{label:"Push to linked accounts",help:"What happens when a saved change means your linked accounts need the update.",value:o,onValueChange:e=>d(e),options:[{value:"ask",label:"Ask each time"},{value:"auto",label:"Push automatically"},{value:"never",label:"Never push"}]})]})})}function bO(e){let{uuid:t,onCopyUuid:s,onSave:a,saveLoading:r,onOpenPreferences:n}=e;return(0,i.jsxs)(mK,{title:"Save Configuration",description:"Save your configuration to your account by clicking Save below.",children:[(0,i.jsx)("div",{className:"flex items-start gap-1",children:(0,i.jsx)(lB,{intent:"info",isClosable:!1,description:(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsxs)("span",{className:"text-md text-[--primary]",children:["Your UUID: ",(0,i.jsx)("span",{className:"font-bold",children:t})]}),(0,i.jsx)(sm.Xpf,{className:"min-h-5 min-w-5 cursor-pointer",onClick:s})]}),(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"Save your UUID and password - you'll need them to update your configuration later"})]}),className:"flex-1"})}),(0,i.jsx)("form",{onSubmit:a,children:(0,i.jsxs)("div",{className:"flex items-center justify-between gap-4 mt-4",children:[(0,i.jsx)(v,{type:"submit",intent:"white",loading:r,rounded:!0,children:"Save"}),(0,i.jsx)(v,{type:"button",intent:"gray-outline",size:"sm",rounded:!0,leftIcon:(0,i.jsx)(bi.A,{className:"h-4 w-4"}),onClick:n,children:"Preferences"})]})})]})}let bU=[{name:"Nuvio",logoSrc:"https://nuvio.tv/assets/Logo_1080x1080.png",url:"https://nuvio.tv/"},{name:"RealStream",logoSrc:"https://rstream.app/logo-realstream.png",url:"https://rstream.app/",imgClassName:"scale-150"},{name:"Aurora",logoSrc:"https://auroramediacenter.com/logo.png",url:"https://auroramediacenter.com/",imgClassName:"scale-150"},{name:"Fusion",logoSrc:"https://fusionapp.dev/FUSN_dark-iOS.png",url:"https://fusionapp.dev/"},{name:"Omni",logoSrc:"https://omni.stkc.win/favicon.ico",url:"https://omni.stkc.win/"}];function bF(){return(0,i.jsx)("div",{className:"flex flex-wrap items-center gap-2 pt-1.5 ml-1",children:bU.map(e=>(0,i.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",title:e.name,"aria-label":`${e.name} (opens in a new tab)`,className:"flex-shrink-0 h-7 w-7 rounded-md overflow-hidden transition-transform hover:scale-110 focus:outline-none focus-visible:ring-1 focus-visible:ring-brand-400",children:(0,i.jsx)("img",{src:e.logoSrc,alt:e.name,className:`h-full w-full object-contain ${e.imgClassName??""}`})},e.name))})}function bz(e){let{variants:t,selected:s,onChange:a,location:r,onLocationChange:n}=e;return(0,i.jsxs)("div",{className:"w-full rounded-xl border border-gray-700 bg-gray-800/30 p-5 shadow-inner",children:[(0,i.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Variant"}),(0,i.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"The links below install the selected variant. Each one appears as a separate addon in your client; pick more than one to combine them."}),(0,i.jsx)(fW,{className:"mt-4",variants:t,value:s,onChange:a}),s.length>0&&(0,i.jsx)("div",{className:"mt-5 pt-4 border-t border-gray-700/50 max-w-md",children:(0,i.jsx)(nc,{label:"Selector location",help:"path"===r?"In the path, as /v/id. Survives clients that rebuild request URLs from the base and would drop a query string.":"In the query string, as ?v=id. Some clients drop it after the manifest.",value:r,onValueChange:e=>n(e),options:[{value:"path",label:"Path segment (/v/)"},{value:"query",label:"Query parameter (?v=)"}]})})]})}function bV(e){let{icon:t,title:s,children:a}=e;return(0,i.jsxs)("div",{className:"flex items-start gap-3 p-3",children:[(0,i.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-brand-400/10 text-brand-400",children:t}),(0,i.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:s}),a]})]})}function bq(e){let{maxLibraries:t,maxCatalogItems:s,maxVersions:a}=e,r=e=>(0,i.jsx)("span",{className:"font-medium tabular-nums text-gray-300",children:e});return(0,i.jsxs)("div",{className:"grid grid-cols-1 divide-y divide-gray-800 rounded-md border border-gray-800 sm:grid-cols-2 sm:divide-x sm:divide-y-0",children:[(0,i.jsxs)(bV,{icon:(0,i.jsx)(bo.A,{className:"h-4 w-4"}),title:"Catalogs become libraries",children:[(0,i.jsx)("p",{className:"text-xs text-gray-400",children:"In the order from the Catalogs page."}),(t>0||s>0)&&(0,i.jsx)("p",{className:"text-xs text-gray-500",children:t>0?(0,i.jsxs)(i.Fragment,{children:["This instance shows your first ",r(t),s>0&&(0,i.jsxs)(i.Fragment,{children:[", up to ",r(s)," titles each"]}),"."]}):(0,i.jsxs)(i.Fragment,{children:["This instance lists up to ",r(s)," titles in each."]})})]}),(0,i.jsxs)(bV,{icon:(0,i.jsx)(bd.A,{className:"h-4 w-4"}),title:"Streams become versions",children:[(0,i.jsx)("p",{className:"text-xs text-gray-400",children:"Opening or playing a title searches your addons, as in Stremio."}),(0,i.jsxs)("p",{className:"text-xs text-gray-500",children:["Up to ",r(a)," per title, in your sort order. Played directly; nothing is transcoded."]})]})]})}function bB(e){let{icon:t,children:s}=e;return(0,i.jsxs)("li",{className:"flex items-start gap-2.5",children:[(0,i.jsx)("span",{className:"mt-0.5 shrink-0 text-brand-400",children:t}),(0,i.jsx)("span",{className:"text-sm text-gray-400",children:s})]})}function bK(e){let{webAppUrl:t,desktopLink:s,onOpenServer:a,disabled:r,disabledReason:n}=e,l=function(){let[e,t]=u.useState(()=>/aarch64|arm64/i.test(navigator.userAgent)?"arm64":void 0);u.useEffect(()=>{var e,s;null==(s=navigator.userAgentData)||null==(e=s.getHighEntropyValues)||e.call(s,["architecture"]).then(e=>{let{architecture:s}=e;"arm"===s?t("arm64"):"x86"===s&&t("x64")}).catch(()=>{})},[]);let s=function(){var e;let t=null==(e=navigator.userAgentData)?void 0:e.platform;if(t)return/^windows$/i.test(t)?"windows":/^macos$/i.test(t)?"mac":/^linux$/i.test(t)?"linux":void 0;let s=navigator.userAgent;
45if(!/iPhone|iPad|iPod|Android/.test(s)){if(/Macintosh/.test(s))return navigator.maxTouchPoints>1?void 0:"mac";if(/Windows/.test(s))return"windows";if(/Linux/.test(s))return"linux"}}();return{...function(e,t){switch(e){case"windows":return{label:"Download for Windows",url:`${bZ}win-${t??"x64"}.exe`};case"mac":return{label:"Download for Mac",url:t?`${bZ}osx-${t}.pkg`:bJ};case"linux":return{label:"Download for Linux",url:`${bZ}linux-${t??"x64"}.flatpak`};default:return{label:"Download desktop app",url:bJ}}}(s,e),os:s}}();return(0,i.jsx)("div",{className:"w-full rounded-xl border border-gray-700 bg-gray-800/30 p-5 shadow-inner",children:(0,i.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-8 lg:items-center",children:[(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsxs)("div",{className:"flex items-center gap-4",children:[(0,i.jsx)("div",{className:"flex-shrink-0 h-12 w-12 rounded-lg bg-gray-900 flex items-center justify-center p-2 shadow-sm",children:(0,i.jsx)("img",{src:"/logo.png",alt:"AIOStreams",className:"h-full w-full object-contain"})}),(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"text-lg font-semibold text-white",children:"AIOStreams app"}),(0,i.jsx)("p",{className:"text-sm text-gray-400",children:"Browse your catalogs and play in your browser, or on your computer with the desktop app. Nothing else to install or host."})]})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,i.jsx)(v,{onClick:()=>window.open(t,"_blank","noopener"),intent:"primary",className:"w-full shadow-md sm:col-span-2",leftIcon:(0,i.jsx)(bc.A,{className:"h-4 w-4"}),disabled:r,children:"Open in browser"}),l.os&&(0,i.jsx)(v,{onClick:()=>window.open(s),intent:"gray-outline",className:"w-full",leftIcon:(0,i.jsx)(bu.A,{className:"h-4 w-4"}),disabled:r,children:"Open in desktop app"}),(0,i.jsx)(v,{onClick:()=>window.open(l.url,"_blank","noopener"),intent:"gray-outline",className:l.os?"w-full":"w-full sm:col-span-2",leftIcon:(0,i.jsx)(xc.A,{className:"h-4 w-4"}),disabled:r,children:l.label})]}),n&&(0,i.jsx)("p",{className:"text-xs text-amber-300",children:n})]}),(0,i.jsxs)("div",{className:"space-y-3 lg:border-l lg:border-gray-700/50 lg:pl-8",children:[(0,i.jsxs)("ul",{className:"space-y-2",children:[(0,i.jsx)(bB,{icon:(0,i.jsx)(bo.A,{className:"h-4 w-4"}),children:"Your catalogs become libraries and your streams become versions, sorted and named as in Stremio. Debrid and Usenet streams play; P2P torrents don't."}),(0,i.jsx)(bB,{icon:(0,i.jsx)(bm.A,{className:"h-4 w-4"}),children:"A profile for everyone in your household, with progress kept across devices."}),(0,i.jsxs)(bB,{icon:(0,i.jsx)(bu.A,{className:"h-4 w-4"}),children:["The desktop app for Windows, Mac and Linux plays what a browser can't."," ",(0,i.jsx)("span",{className:"rounded-full border border-amber-400/30 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-amber-300",children:"Alpha"})]})]}),(0,i.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs",children:[(0,i.jsx)("button",{type:"button",onClick:()=>a("connect"),disabled:r,className:"text-brand-400 hover:underline disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:no-underline",children:"Sign-in addresses"}),(0,i.jsx)("button",{type:"button",onClick:()=>a("users"),disabled:r,className:"text-brand-400 hover:underline disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:no-underline",children:"Users, trackers and playback"}),(0,i.jsx)("a",{href:bQ,target:"_blank",rel:"noopener noreferrer",className:"text-brand-400 hover:underline",children:"All downloads"})]})]})]})})}function bH(e){let{encodedManifest:t,manifestUrl:s,usingAlias:a,webAppUrl:r,desktopLink:n,variantSelector:l,onCopyManifestUrl:o,onOpenChillio:d,onOpenSeanime:c,onOpenJellyfin:u,onOpenAniyomi:m,onOpenNabIndexer:h,onOpenSearchApi:p,disableSeanimeCard:x,seanimeDisabledReason:g,disableJellyfinCard:f,jellyfinDisabledReason:b,disableNabIndexerCard:y,nabIndexerDisabledReason:j,disableSearchApiCard:w,searchApiDisabledReason:N}=e;return(0,i.jsx)(mK,{title:"Installation Options",description:"Install your addon using your preferred method. If a reinstall is necessary, a pop-up will tell you â otherwise, you do not need to reinstall.",children:(0,i.jsxs)("div",{className:"flex flex-col gap-6",children:[l,(0,i.jsx)("div",{className:"w-full rounded-xl border border-gray-700 bg-gray-800/30 p-5 shadow-inner",children:(0,i.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-8 lg:items-center",children:[(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsxs)("div",{className:"flex items-center gap-4",children:[(0,i.jsx)("div",{className:"flex-shrink-0 h-12 w-12 rounded-lg bg-gray-900 flex items-center justify-center p-2 shadow-sm",children:(0,i.jsx)("img",{src:"https://raw.githubusercontent.com/Stremio/stremio-brand/refs/heads/master/logos/PNG/stremio-logo-800px.png",alt:"Stremio",className:"h-full w-full object-contain"})}),(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Stremio"}),(0,i.jsx)("p",{className:"text-sm text-gray-400",children:"Install to Stremio or other Stremio addon compatible clients using the Manifest URL."})]})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,i.jsx)(v,{onClick:()=>window.open(s.replace(/^https?:\/\//,"stremio://")),intent:"primary",className:"w-full shadow-md",children:"Install to Stremio"}),(0,i.jsx)(v,{onClick:()=>window.open(`https://web.stremio.com/#/addons?addon=${t}`),intent:"gray-outline",className:"w-full",children:"Install to Stremio Web"})]})]}),(0,i.jsxs)("div",{className:"space-y-1.5 lg:border-l lg:border-gray-700/50 lg:pl-8",children:[(0,i.jsx)("label",{className:"text-xs font-medium text-gray-400 ml-1",children:a?"Manifest URL (alias)":"Direct Manifest URL"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:s,className:"flex-1 font-mono text-sm bg-black/20",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:o,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy install link",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]}),(0,i.jsxs)("p",{className:"text-xs text-gray-500 ml-1",children:["Install manually to Stremio or any Stremio addon compatible client.",a&&" Your profile alias stands in for the UUID and password; the long URL still works."]}),(0,i.jsx)(bF,{})]})]})}),(0,i.jsx)(bK,{webAppUrl:r,desktopLink:n,onOpenServer:u,disabled:f,disabledReason:b}),(0,i.jsx)(bA,{manifestUrl:s}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 flex items-center gap-2",children:[(0,i.jsx)("div",{className:"h-px bg-gray-700 flex-1"}),"Other apps",(0,i.jsx)("div",{className:"h-px bg-gray-700 flex-1"})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,i.jsx)(b$,{logoSrc:"https://seanime.app/seanime-logo.png",name:"Seanime",description:"Anime-focused client",onClick:c,disabled:x,disabledReason:g}),(0,i.jsx)(b$,{logoSrc:"https://raw.githubusercontent.com/jellyfin/jellyfin-ux/refs/heads/master/logos/PNG-4x/jellyfin-icon--color-on-dark.png",name:"Jellyfin apps",description:"Use your configuration in any Jellyfin app",beta:!0,onClick:()=>u("connect"),disabled:f,disabledReason:b}),(0,i.jsx)(b$,{logoSrc:"https://link.chillio.app/app-icon.png",name:"Chillio",description:"Via ChillLink protocol",onClick:d}),(0,i.jsx)(b$,{logoSrc:"https://aniyomi.org/img/logo-128px.png",name:"Aniyomi / Animiru",description:"Extension-based integration",unofficial:!0,author:"worldInColors",onClick:m})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 flex items-center gap-2",children:[(0,i.jsx)("div",{className:"h-px bg-gray-700 flex-1"}),"Programmatic / API access",(0,i.jsx)("div",{className:"h-px bg-gray-700 flex-1"})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,i.jsx)(b$,{icon:(0,i.jsx)(bp.A,{className:"h-5 w-5"}),name:"Newznab / Torznab",description:"Indexer for Prowlarr, NZBHydra & *Arr apps",onClick:h,disabled:y,disabledReason:j}),(0,i.jsx)(b$,{icon:(0,i.jsx)(bx.A,{className:"h-5 w-5"}),name:"Search API",description:"JSON stream search endpoint",onClick:p,disabled:w,disabledReason:N})]})]})]})})}function bW(e){let{onExportOpen:t,onImportOpen:s,onImport:a,importFileRef:r}=e;return(0,i.jsx)(mK,{title:"Backups",description:"Export your settings or restore from a backup file",children:(0,i.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,i.jsx)(v,{onClick:t,leftIcon:(0,i.jsx)(hZ.A,{}),intent:"gray",children:"Export"}),(0,i.jsx)("input",{type:"file",accept:".json",className:"hidden",id:"import-file",onChange:a,ref:r}),(0,i.jsx)(v,{onClick:s,leftIcon:(0,i.jsx)(xc.A,{}),intent:"gray",children:"Import"})]})})}function bG(e){let{hasUser:t,onChangePasswordOpen:s,onDeleteUserOpen:a,onResetOpen:r}=e;return(0,i.jsx)(mK,{title:"Danger Zone",description:"Perform potentially destructive actions that cannot be undone",className:"lg:bg-red-700/70 border-red-500/20",titleClassName:"group-hover/settings-card:from-red-500/10 group-hover/settings-card:to-red-700/20",children:(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[t&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{intent:"alert",rounded:!0,onClick:s,children:"Change Password"}),(0,i.jsx)(v,{intent:"alert",rounded:!0,onClick:a,children:"Delete User"})]}),(0,i.jsx)(v,{intent:"alert",rounded:!0,onClick:r,children:"Reset Configuration"})]})})}let bY="{catalog.name} - {catalog.type}",bJ="https://github.com/Viren070/AIOStreams/releases/tag/desktop",bZ="https://github.com/Viren070/AIOStreams/releases/download/desktop/aiostreams-desktop-",bQ="https://docs.aiostreams.viren070.me/guides/desktop-app#download",bX="aiostreams:install:variant-location",b0="aiostreams:seanime:stremio-custom-source:manifest-url",b1="aiostreams:seanime:stremio-custom-source:name-template",b2="aiostreams:seanime:stremio-custom-source:catalog-selections",b3={title:e=>e.split(" ").map(e=>e.toLowerCase()).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),upper:e=>e.toUpperCase(),lower:e=>e.toLowerCase(),length:e=>e.length.toString()},b5=e=>`${e.type}::${e.id}`,b4=e=>{if("u"<typeof window)return null;try{return window.localStorage.getItem(e)}catch{return null}},b6=(e,t)=>{if("u">typeof window)try{window.localStorage.setItem(e,t)}catch{}},b9=e=>{if("u">typeof window)try{window.localStorage.removeItem(e)}catch{}};function b8(e,t){let s={addon:{name:t.addonName},catalog:{name:t.catalogName,type:t.catalogType}};return e.replace(/\{([a-z]+)\.([a-z]+)((?:::[^{}:\s]+)*)\}/gi,(e,t,a,r)=>{var n;let l=null==(n=s[t])?void 0:n[a];return"string"!=typeof l?e:("string"==typeof r&&r.length>0?r.split("::").map(e=>
45e.trim().toLowerCase()).filter(Boolean):[]).reduce((e,t)=>{let s=b3[t];return s?s(e):e},l)})}function b7(e){let{open:t,onOpenChange:s,baseUrl:a,initialManifestUrl:r}=e,[n,l]=u.useState("url"),[o,d]=u.useState(r),[c,h]=u.useState(null),[p,x]=u.useState([]),[g,f]=u.useState(!1),[b,y]=u.useState(null),[j,N]=u.useState(""),[k,S]=u.useState(bY);u.useEffect(()=>{if(!t){l("url"),h(null),x([]),y(null),N("");return}let e=b4(b1),s=b4(b0);s===r&&b9(b0),d(s&&s!==r?s:r),S(e||bY)},[t,r]),u.useEffect(()=>{t&&b6(b1,k)},[k,t]),u.useEffect(()=>{if(!t)return;let e=o.trim();e&&e!==r?b6(b0,e):b9(b0)},[o,r,t]),u.useEffect(()=>{t&&0!==p.length&&b6(b2,JSON.stringify(p.reduce((e,t)=>(e[b5(t)]={selected:t.selected,displayName:t.displayName},e),{})))},[p,t]);let C=async()=>{let e=o.trim();if(e){f(!0),y(null);try{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);let s=await t.json();if(!Array.isArray(s.catalogs)||0===s.catalogs.length)return void y("This manifest has no catalogs.");h(s);let a=(()=>{let e=b4(b2);if(!e)return{};try{let t=JSON.parse(e);return"object"==typeof t&&null!==t?t:{}}catch{return{}}})();x(s.catalogs.map(e=>{var t,r;let n=null==(t=e.extra)?void 0:t.find(e=>"search"===e.name),l=a[b5(e)],i=b8(k,{addonName:s.name,catalogName:e.name,catalogType:e.type}),o=(null==l?void 0:l.selected)??(null==(r=e.extra)?void 0:r.find(e=>"search"!==e.name&&!0===e.isRequired))===void 0;return{id:e.id,type:e.type,name:e.name,hasSearch:!!n,searchRequired:(null==n?void 0:n.isRequired)===!0,displayName:(null==l?void 0:l.displayName)||i,selected:o}})),l("catalogs")}catch(e){y(e instanceof Error?e.message:"Failed to fetch manifest. Check the URL and try again.")}finally{f(!1)}}},_=e=>{var t;let s=(null==c||null==(t=c.logo)?void 0:t.startsWith("http"))?c.logo:"https://raw.githubusercontent.com/Stremio/stremio-brand/refs/heads/master/logos/PNG/stremio-logo-800px.png",r=btoa(unescape(encodeURIComponent(JSON.stringify({id:e.id,type:e.type,name:e.displayName,addonManifestUrl:o.trim(),addonLogo:s})))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${a}/seanime/extensions/${r}/stremio-custom-source.json`},A=p.filter(e=>e.selected).length,R=p.length>0&&p.every(e=>e.selected),T={url:"Enter a Stremio addon manifest URL to browse its catalogs.",catalogs:c?`${p.length} catalog${1!==p.length?"s":""} from ${c.name}. Pick the ones to expose as Seanime custom sources.`:"",import:"Paste this URL list in Seanime under Extensions â Add Extensions â Import from repository â Import all."},I={initial:{opacity:0,x:12},animate:{opacity:1,x:0},exit:{opacity:0,x:-12},transition:{duration:.18,ease:"easeOut"}};return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Stremio Custom Source",description:T[n],contentClass:"max-w-2xl",children:(0,i.jsxs)(t7.N,{mode:"wait",initial:!1,children:["url"===n&&(0,i.jsxs)(se.P.div,{...I,className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(K,{value:o,onValueChange:d,placeholder:"https://â¦/manifest.json",className:"flex-1 font-mono text-sm",onKeyDown:e=>{"Enter"===e.key&&C()}}),(0,i.jsx)(v,{intent:"white",rounded:!0,onClick:C,loading:g,className:"shrink-0",children:"Continue"})]}),b&&(0,i.jsx)(lB,{intent:"alert",description:b,isClosable:!1})]},"url"),"catalogs"===n&&(0,i.jsxs)(se.P.div,{...I,className:"space-y-4",children:[c&&(0,i.jsxs)("div",{className:"flex items-center gap-3 pb-3 border-b border-gray-700/50",children:[c.logo&&(0,i.jsx)("img",{src:c.logo,alt:c.name,className:"h-8 w-8 rounded object-contain bg-gray-900 p-1"}),(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-gray-100 truncate",children:c.name}),(0,i.jsxs)("p",{className:"text-xs text-gray-500",children:[A," of ",p.length," selected"]})]}),(0,i.jsx)(w,{size:"sm",rounded:!0,intent:R?"primary":"primary-subtle",icon:R?(0,i.jsx)(W.Pqg,{className:"w-4 h-4"}):(0,i.jsx)(W.hpl,{className:"w-4 h-4"}),onClick:()=>{x(e=>e.map(e=>({...e,selected:!R})))},title:R?"Deselect all":"Select all"})]}),(0,i.jsx)("div",{className:"flex flex-col gap-1 max-h-80 overflow-y-auto -mx-1 px-1",children:p.map((e,t)=>(0,i.jsxs)("div",{className:`flex items-center gap-3 rounded-lg px-3 py-2 transition-colors ${e.selected?"bg-[--brand]/5 hover:bg-[--brand]/10":"hover:bg-gray-800/40"}`,children:[(0,i.jsx)("div",{className:"flex-shrink-0",children:(0,i.jsx)(lt,{id:`cat-${t}`,size:"sm",value:e.selected,onValueChange:e=>x(s=>s.map((s,a)=>a===t?{...s,selected:!0===e}:s))})}
45),(0,i.jsxs)("div",{className:"flex-shrink-0 w-36 cursor-pointer",onClick:()=>x(e=>e.map((e,s)=>s===t?{...e,selected:!e.selected}:e)),children:[(0,i.jsx)("p",{className:"text-sm font-medium text-gray-100 truncate",children:e.name}),(0,i.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 text-[11px] text-gray-500",children:[(0,i.jsx)("span",{className:"capitalize",children:e.type}),e.hasSearch&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"text-gray-700",children:"\xb7"}),(0,i.jsxs)("span",{className:`flex items-center gap-0.5 ${e.searchRequired?"text-amber-400/80":"text-gray-500"}`,children:[(0,i.jsx)(mX.A,{className:"h-2.5 w-2.5"}),e.searchRequired?"search only":"searchable"]})]})]})]}),(0,i.jsx)("div",{className:"flex-1 min-w-0",children:(0,i.jsx)(K,{value:e.displayName,onValueChange:e=>x(s=>s.map((s,a)=>a===t?{...s,displayName:e}:s)),className:"w-full text-xs",placeholder:"Display name in Seanime"})})]},`${e.type}-${e.id}`))}),(0,i.jsx)(t7.N,{initial:!1,children:A>0&&(0,i.jsx)(se.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.18,ease:"easeOut"},className:"overflow-hidden",children:(0,i.jsxs)("div",{className:"rounded-lg border border-gray-700/60 bg-gray-800/30 p-3 space-y-2",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{value:k,onValueChange:S,placeholder:bY,className:"flex-1 font-mono text-xs",leftIcon:(0,i.jsx)(W.Uth,{className:"w-3.5 h-3.5"})}),(0,i.jsxs)(v,{intent:"primary-subtle",size:"sm",onClick:()=>{c&&(x(e=>e.map(e=>e.selected?{...e,displayName:b8(k,{addonName:c.name,catalogName:e.name,catalogType:e.type})}:e)),m.oR.success(`Renamed ${A} catalog${1!==A?"s":""}`))},className:"shrink-0",children:["Apply to ",A]})]}),(0,i.jsxs)("p",{className:"text-[11px] text-gray-500",children:["Variables:"," ",(0,i.jsx)("code",{className:"text-gray-400",children:"{addon.name}"}),","," ",(0,i.jsx)("code",{className:"text-gray-400",children:"{catalog.name}"}),","," ",(0,i.jsx)("code",{className:"text-gray-400",children:"{catalog.type}"})," \xb7 ","Modifiers:"," ",(0,i.jsx)("code",{className:"text-gray-400",children:"{catalog.type::title}"})]})]})},"rename-bar")}),b&&(0,i.jsx)(lB,{intent:"alert",description:b,isClosable:!1}),(0,i.jsxs)("div",{className:"flex justify-between pt-2",children:[(0,i.jsx)(v,{intent:"gray-outline",rounded:!0,onClick:()=>{l("url"),y(null)},children:"Back"}),(0,i.jsxs)(v,{intent:"white",rounded:!0,onClick:()=>{let e=p.filter(e=>e.selected);e.length?(y(null),N(JSON.stringify({urls:e.map(_)})),l("import")):y("Select at least one catalog.")},disabled:0===A,children:["Continue with ",A," catalog",1!==A?"s":""]})]})]},"catalogs"),"import"===n&&(0,i.jsxs)(se.P.div,{...I,className:"space-y-4",children:[(0,i.jsxs)("div",{className:"space-y-1.5",children:[(0,i.jsx)("label",{className:"text-xs font-medium text-gray-400 ml-1",children:"URL list JSON"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:j,className:"flex-1 font-mono text-sm bg-black/20",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:()=>nf(j,{onSuccess:()=>m.oR.success("Copied to clipboard"),onError:()=>m.oR.error("Failed to copy")}),intent:"primary",className:"shrink-0 px-3","aria-label":"Copy URL list",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]})]}),(0,i.jsx)("div",{className:"flex justify-between pt-2",children:(0,i.jsx)(v,{intent:"gray-outline",rounded:!0,onClick:()=>{l("catalogs"),y(null)},children:"Back"})})]},"import")]})})}function ve(){return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(ng,{className:"space-y-4 p-4 sm:p-8",children:(0,i.jsx)(vt,{})})})}function vt(){var e,t,s,a,r,n,l,o,d,c,h,p,x,g,f,b,y,j,w,N,k,S,C,_,A,R,T,I,E;let M,{userData:P,setUserData:$,uuid:D,setUuid:L,password:O,setPassword:U,encryptedPassword:F,setEncryptedPassword:z}=ri(),{data:V}=(0,ty.I)(tm(D?{uuid:D,password:O}:null)),q=so(!1),[B,H]=u.useState(""),[W,Y]=u.useState(""),[J,Z]=u.useState(!0),[Q,X]=u.useState(!1),[ee,et]=u.useState(null),[es,ea]=u.useState([]),{status:er}=tj(),en=(null==er?void 0:er.settings.configSessionsEnabled)!==!1,{user:el}=su(),{data:ei}=(0,ty.I)({...tu,enabled:!!el}),eo=(null==ei||null==(e=ei.profiles.find(e=>e.uuid===D))?void 0:e.alias)??null,ed=(null==er||null==(t=er.settings)?void 0:t.baseUrl)||window.location.origin,eu=!!er,em=(null==er||null==(s=er.settings)?void 0:s.searchApiDisabled)??!1,eh=(null==er||null==(a=er.settings)?void 0:a.nabApiDisabled)??!1,ep=null==er||null==(r=er.settings)?void 0:r.jellyfin,eg=(null==ep?void 0:ep.enabled)??!1,ef=(null==ep?void 0:ep.maxVersions)??10,eb=(null==ep?void 0:ep.segments.enabled)??!1,ev=(null==ep?void 0:ep.segments.providers)??[],ey=(null==(n=ev.find(e=>"pmdb"===e.id))?void 0:n.key)??null,eN=(null==ep?void 0:ep.resolveOnOpen)&&"user"!==ep.resolveOnOpen?"always"===ep.resolveOnOpen:null,ek=(null==er||null==(l=er.settings)?void 0:l.seanimeExtensionVersion)??null,eS=eu&&!em&&!ek,eC=em||eS,e_=em?"Requires Search API (disabled on this instance)":eS?"Unavailable on this instance. Please ask your instance hoster.":void 0,eA=u.useRef(null),eR=so(!1),[eT,eI]=u.useState(""),{setSelectedMenu:eE,firstMenu:eM}=rh(),eP=so(!1),e$=so(!1),eD=so(!1),eL=so(!1),[eO,eU]=u.useState(!0),eF=u.useMemo(()=>"u"<typeof window?null:function(e,t){let s=/\/v\/([^/]+)\/configure\/?$/.exec(e);if(s){let e=bf(s[1]);if(e.length)return{ids:e,location:"path"}}let a=null;try{a=new URLSearchParams(t).get("v")}catch{a=null}if(a){let e=bf(a);if(e.length)return{ids:e,location:"query"}}return null}(window.location.pathname,window.location.search),[]),[ez,eV]=u.useState((null==eF?void 0:eF.ids)??[]),[eq,eB]=u.useState(()=>eF?eF.location:"query"===b4(bX)?"query":"path");u.useEffect(()=>{b6(bX,eq)},[eq]);let eK=so(!1),eH=so(!1),eW=so(!1),eG=so(!1),eY=so(!1),[eJ,eZ]=u.useState("connect"),[eQ,eX]=u.useState(""),[e1,e3]=u.useState(null),[e5,e4]=u.useState(null),[e6,e9]=u.useState(!1),[e8,e7]=u.useState(""),[te,tt]=u.useState(""),[ts,ta]=u.useState(!1),tr=so(!1),tn=so(!1),tl=so(!1),{handleSave:ti,loading:to}=mx(),td=sd({title:"Confirm Reset",description:`Are you sure you want to reset your configuration? This will clear all your settings${D?" but keep your user account":""}. This action cannot be undone.`,actionText:"Reset",actionIntent:"alert",onConfirm:()=>{$(null),eE(eM),m.oR.success("Configuration reset successfully")}}),tc=sd({title:"Confirm Deletion",description:"Are you sure you want to delete your configuration? This will permanently remove all your data. This action cannot be undone.",actionText:"Delete",actionIntent:"alert",onConfirm:()=>{X(!0),t2()}});u.useEffect(()=>{let e=[];D?ea([]):(B.length<6&&e.push("Password must be at least 6 characters long"),W.length>0&&B!==W&&e.push("Passwords do not match"),ea(e))},[B,W,D,O]);let th=async e=>{if(null==e||e.preventDefault(),es.length>0)return void m.oR.error("Password requirements not met");X(!0);try{let e=await ex(P,B);m.oR.success("Configuration created successfully, your UUID and password are below"),L(e.uuid),z(e.encryptedPassword),U(B),en&&ec(e.uuid,B,J).catch(()=>{}),"u"<typeof window||"true"===localStorage.getItem(bE)||et({uuid:e.uuid,password:B})}catch(e){m.oR.error(e instanceof Error?e.message:"Failed to create configuration")}finally{X(!1)}},tp=e=>hY(e,e=>{var t;return null==er||null==(t=er.settings.presets.find(t=>t.ID===e))?void 0:t.OPTIONS}),tx=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i,tg=D?tx.test(D)?eo??null:D:null,tf=(P.variants??[]).filter(e=>
45!1!==e.enabled),tb=ez.filter(e=>tf.some(t=>t.id===e)),tv=tb.map(encodeURIComponent).join(","),tw=tb.length&&"path"===eq?`/v/${tv}`:"",tN=tb.length&&"query"===eq?`?v=${tv}`:"",tk=D?tg?`${ed}/stremio/u/${tg}${tw}/manifest.json${tN}`:`${ed}/stremio/${D}/${F}${tw}/manifest.json${tN}`:"",tS=D?`${ed}/chilllink/${D}/${F}${tw}${tN}`:"",tC=encodeURIComponent(tk),t_=!!D&&!!F&&tx.test(D),tA=t_?`${ed}/seanime/${D}/${F}${tw}/extensions/aiostreams-plugin.json${tN}`:`${ed}/seanime/extensions/aiostreams-plugin.json`,tR=t_?`${ed}/seanime/${D}/${F}${tw}/extensions/aiostreams-torrent-provider.json${tN}`:`${ed}/seanime/extensions/aiostreams-torrent-provider.json`,tT=async()=>{await nf(tk,{onSuccess:()=>m.oR.success("Manifest URL copied to clipboard"),onError:()=>m.oR.error("Failed to copy manifest URL")})},tI=async()=>{await nf(tS,{onSuccess:()=>m.oR.success("ChillLink URL copied to clipboard"),onError:()=>m.oR.error("Failed to copy ChillLink URL")})},tE=async()=>{await nf(tA,{onSuccess:()=>m.oR.success("Plugin URL copied to clipboard"),onError:()=>m.oR.error("Failed to copy URL")})},tM=async()=>{await nf(tR,{onSuccess:()=>m.oR.success("Torrent provider URL copied to clipboard"),onError:()=>m.oR.error("Failed to copy URL")})},tP=`${ed}/jellyfin`,t$=eo??D??"",tD=async()=>{await nf(tP,{onSuccess:()=>m.oR.success("Server address copied to clipboard"),onError:()=>m.oR.error("Failed to copy address")})},tL=async()=>{await nf(t$,{onSuccess:()=>m.oR.success("Username copied to clipboard"),onError:()=>m.oR.error("Failed to copy username")})},tO=(null==(o=P.jellyfin)?void 0:o.personas)??[],tU=(null==(c=P.jellyfin)||null==(d=c.primary)?void 0:d.name)||P.addonName||"Primary user",tF=e8?(null==(h=tO.find(e=>e.id===e8))?void 0:h.name)??e8:null,tz=e8?!!(null==(p=tO.find(e=>e.id===e8))?void 0:p.lock):!!(null==(g=P.jellyfin)||null==(x=g.primary)?void 0:x.lock),tV=tg?`${ed}/jellyfin/u/${tg}`:D&&F?`${ed}/jellyfin/${D}/${F}`:"",tq=`${tV||tP}/web/`,tB=`aiostreams://server?url=${encodeURIComponent(tV||tP)}`,tK=async()=>{await nf(tV,{onSuccess:()=>m.oR.success("Server address copied to clipboard"),onError:()=>m.oR.error("Failed to copy address")})};u.useEffect(()=>{if(e3(null),e4(null),!D||6!==eQ.length)return void e9(!1);let e=!1;e9(!0);let t=setTimeout(()=>{e2({uuid:D,password:O||null},eQ).then(t=>{e||e3(t)}).catch(t=>{e||e4(t instanceof Error?t.message:"No device is waiting on this code")}).finally(()=>{e||e9(!1)})},300);return()=>{e=!0,clearTimeout(t)}},[eQ,D,O]);let tH=()=>{eX(""),e3(null),e7(""),tt("")},tW=async()=>{if(D&&6===eQ.length){ta(!0);try{var e;let t=await e0({uuid:D,password:O||null},eQ,e8||void 0,tz?te:void 0);m.oR.success((null==(e=t.device)?void 0:e.app)?`Signed in ${t.device.app} on ${t.device.name}${tF?` as ${tF}`:""}`:"Quick Connect approved"),tH()}catch(e){m.oR.error(e instanceof Error?e.message:"Failed to approve the code")}finally{ta(!1)}}},tG=`${ed}/api/v1/newznab/api`,tY=`${ed}/api/v1/torznab/api`,tJ=D&&F?btoa(`${D}:${F}`):"",tZ=`${ed}/api/v1/search`,tQ=async()=>{await nf(tG,{onSuccess:()=>m.oR.success("Newznab URL copied to clipboard"),onError:()=>m.oR.error("Failed to copy URL")})},tX=async()=>{await nf(tY,{onSuccess:()=>m.oR.success("Torznab URL copied to clipboard"),onError:()=>m.oR.error("Failed to copy URL")})},t0=async()=>{await nf(tJ,{onSuccess:()=>m.oR.success("API key copied to clipboard"),onError:()=>m.oR.error("Failed to copy API key")})},t1=async()=>{await nf(tZ,{onSuccess:()=>m.oR.success("Search API URL copied to clipboard"),onError:()=>m.oR.error("Failed to copy URL")})},t2=async()=>{try{if(!D)return void m.oR.error("No UUID found");await ej(D,eT),m.oR.success("Configuration deleted successfully"),L(null),z(null),U(null),$(null),eE(eM),eR.close()}catch(e){m.oR.error(e instanceof Error?e.message:"Failed to delete configuration")}finally{X(!1)}},t3=so(!1),[t5,t4]=u.useState(!1),[t6,t9]=u.useState({currentPassword:"",newPassword:"",confirmNewPassword:""}),t8=async e=>{if(e.preventDefault(),!D)return void m.oR.error("No UUID found");if(t6.newPassword.length<6)return void m.oR.error("New password must be at least 6 characters long");if(t6.newPassword!==t6.confirmNewPassword)return void m.oR.error("New passwords do not match");if(t6.newPassword===t6.currentPassword)return void m.oR.error("New password cannot be the same as current password");t4(!0);try{let e=await ew(D,t6.currentPassword,t6.newPassword);m.oR.success("Password changed successfully. Please reinstall AIOStreams."),U(t6.newPassword),z(e.encryptedPassword),t3.close(),t9({currentPassword:"",newPassword:"",confirmNewPassword:""})}catch(e){m.oR.error(e instanceof Error?e.message:"Failed to change password")}finally{t4(!1)}};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex items-center w-full",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Install Addon"}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Configure and install your personalized addon"})]}),(0,i.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,i.jsx)(mg,{})})]}
45),(0,i.jsxs)("div",{className:"space-y-4 mt-6",children:[D?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(bO,{uuid:D,onCopyUuid:()=>nf(D,{onSuccess:()=>m.oR.success("UUID copied to clipboard"),onError:()=>m.oR.error("Failed to copy UUID")}),onSave:e=>{e.preventDefault(),ti()},saveLoading:to,onOpenPreferences:q.open}),(0,i.jsx)(bH,{encodedManifest:tC,manifestUrl:tk,usingAlias:!!tg,webAppUrl:tq,desktopLink:tB,variantSelector:tf.length>0?(0,i.jsx)(bz,{variants:tf,selected:tb,onChange:eV,location:eq,onLocationChange:eB}):void 0,onCopyManifestUrl:tT,onOpenChillio:eK.open,onOpenSeanime:eH.open,onOpenJellyfin:e=>{eZ(e),eG.open()},onOpenAniyomi:tr.open,onOpenNabIndexer:tn.open,onOpenSearchApi:tl.open,disableSeanimeCard:eC,seanimeDisabledReason:e_,disableJellyfinCard:!eg,jellyfinDisabledReason:eg?void 0:"Disabled on this instance",disableNabIndexerCard:eh,nabIndexerDisabledReason:eh?"Newznab/Torznab API (disabled on this instance)":void 0,disableSearchApiCard:em,searchApiDisabledReason:em?"Search API (disabled on this instance)":void 0}),(0,i.jsx)(bv,{})]}):(0,i.jsx)(bD,{onSubmit:th,passwordRequirements:es,newPassword:B,confirmNewPassword:W,onNewPasswordChange:H,onConfirmNewPasswordChange:Y,staySignedIn:en?J:null,onStaySignedInChange:Z,createLoading:Q}),(0,i.jsx)(bW,{onExportOpen:eD.open,onImportOpen:eL.open,onImport:e=>{var t;let s=null==(t=e.target.files)?void 0:t[0];if(!s)return;let a=new FileReader;a.onload=e=>{try{var t;let s=JSON.parse(null==(t=e.target)?void 0:t.result);if(s.metadata)return void m.oR.error("The imported file is a template, please use the template import option instead.");delete s.uuid,delete s.trusted,$(e=>({...e,...a8(s)})),m.oR.success("Configuration imported successfully")}catch(e){m.oR.error("Failed to import configuration: Invalid JSON file")}},a.readAsText(s)},importFileRef:eA}),(0,i.jsx)(bG,{hasUser:!!D,onChangePasswordOpen:t3.open,onDeleteUserOpen:eR.open,onResetOpen:td.open}),(0,i.jsx)(sl,{open:t3.isOpen,onOpenChange:e=>{!t5&&(t3.toggle(),e||t9({currentPassword:"",newPassword:"",confirmNewPassword:""}))},title:"Change Password",description:(0,i.jsx)(lB,{intent:"warning",description:"Changing your password will invalidate ALL existing installations. You will need to re-install AIOStreams after this change."}),children:(0,i.jsxs)("form",{onSubmit:t8,className:"space-y-4",children:[(0,i.jsx)("input",{type:"text",name:"username",autoComplete:"username",value:D??"",readOnly:!0,"aria-hidden":"true",tabIndex:-1,className:"sr-only"}),(0,i.jsx)(G,{id:"change-current-password",label:"Current Password",name:"current-password",autoComplete:"current-password",value:t6.currentPassword,required:!0,placeholder:"Enter your current password",onValueChange:e=>t9(t=>({...t,currentPassword:e}))}),(0,i.jsx)(G,{id:"change-new-password",label:"New Password",name:"new-password",autoComplete:"new-password",value:t6.newPassword,required:!0,placeholder:"Enter your new password",onValueChange:e=>t9(t=>({...t,newPassword:e}))}),(0,i.jsx)(G,{id:"change-confirm-new-password",label:"Confirm New Password",name:"confirm-new-password",autoComplete:"new-password",value:t6.confirmNewPassword,required:!0,placeholder:"Re-enter your new password",onValueChange:e=>t9(t=>({...t,confirmNewPassword:e}))}),(0,i.jsxs)("div",{className:"pt-2 flex justify-end gap-3",children:[(0,i.jsx)(v,{type:"button",intent:"gray-outline",onClick:()=>{t5||t3.close()},disabled:t5,children:"Cancel"}),(0,i.jsx)(v,{type:"submit",intent:"alert",loading:t5,children:"Change Password"})]})]})}),(0,i.jsx)(sl,{open:eR.isOpen,onOpenChange:eR.toggle,title:"Delete Configuration",description:(0,i.jsx)(lB,{intent:"warning",description:"Please enter your password to confirm deletion of your user and all associated data. This action cannot be undone."}),children:(0,i.jsx)("form",{onSubmit:e=>{(e.preventDefault(),eT)?tc.open():m.oR.error("Please enter your password")},children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(G,{label:"Password",id:"delete-confirm-password",name:"password",value:eT,required:!0,placeholder:"Enter your password to confirm deletion",onValueChange:e=>eI(e)}),(0,i.jsx)("div",{className:"pt-2",children:(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-3 w-full",children:[(0,i.jsx)(v,{type:"button",intent:"gray-outline",onClick:eR.close,className:"w-full",children:"Cancel"}),(0,i.jsx)(v,{type:"submit",intent:"alert",loading:Q,className:"w-full",children:"Delete"})]})})]})})}),(0,i.jsx)(sl,{open:eK.isOpen,onOpenChange:eK.toggle,title:"Install in Chillio",description:"Add your AIOStreams addon via the ChillLink protocol",children:(0,i.jsx)("div",{className:"flex flex-col gap-4",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:tS,className:"flex-1",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:tI,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy ChillLink URL",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]})})}),(0,i.jsx)(sl,{open:eH.isOpen,onOpenChange:eH.toggle,title:"Install in Seanime",description:"Stream AIOStreams content directly within Seanime",children:(0,i.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,i.jsxs)("span",{className:"text-gray-400",children:["Seanime integration is in"," ",(0,i.jsx)("span",{className:"font-medium text-amber-300",children:"beta"})]}),(0,i.jsxs)("span",{className:"text-gray-400",children:["Extension ver
45sion:"," ",(0,i.jsx)("span",{className:"font-medium text-gray-200",children:ek?`v${ek}`:"Unavailable"})]})]}),(0,i.jsxs)("p",{className:"text-xs text-gray-400",children:["In Seanime, go to"," ",(0,i.jsx)("span",{className:"text-gray-200",children:"Extensions â Add Extensions â Install from URL"}),". Install one of the two extensions below."]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("p",{className:"text-sm font-medium text-white",children:["AIOStreams Plugin"," ",(0,i.jsx)("span",{className:"text-xs text-gray-500 font-normal",children:"â recommended for most"})]}),(0,i.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:"Adds a dedicated results panel and tab to Seanime. Works with any URL or P2P based stream."})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:tA,className:"flex-1",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:tE,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy plugin URL",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]}),!t_&&(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"After installing, open the extension settings and enter your Manifest URL."})]}),(0,i.jsx)("div",{className:"border-t border-gray-700/60"}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"AIOStreams Torrent Provider"}),(0,i.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:"For native torrent integration. Only use this if you want a simpler extension and/or want Seanime to handle debrid."})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:tR,className:"flex-1",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:tM,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy torrent provider URL",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]}),!t_&&(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"After installing, open the extension settings and enter your Manifest URL."})]}),(0,i.jsx)("div",{className:"border-t border-gray-700/60"}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Stremio Custom Source"}),(0,i.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:"Expose any Stremio addon catalog as a Seanime custom source to browse its library directly inside Seanime."})]}),(0,i.jsx)(v,{intent:"white",rounded:!0,className:"w-full",onClick:eW.open,children:"Configure"})]})]})}),(0,i.jsx)(b7,{open:eW.isOpen,onOpenChange:eW.toggle,baseUrl:ed,initialManifestUrl:tk}),(0,i.jsx)(sl,{open:tn.isOpen,onOpenChange:tn.toggle,title:"Newznab / Torznab Indexer",description:"Use AIOStreams as a newznab/torznab indexer in Prowlarr, Sonarr or Radarr",children:(0,i.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,i.jsxs)("p",{className:"text-xs text-gray-400",children:["Add a ",(0,i.jsx)("span",{className:"text-gray-200",children:"Generic Newznab"})," ","(usenet) or ",(0,i.jsx)("span",{className:"text-gray-200",children:"Generic Torznab"})," ","(torrent) indexer. Only ID and season/episode searches are supported â free-text searches return no results."]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Newznab URL"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:tG,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:tQ,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy Newznab URL",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Torznab URL"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:tY,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:tX,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy Torznab URL",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"API Key"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:tJ,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:t0,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy API key",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]}),(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"Paste this into the indexer's API Key field."})]})]})}),(0,i.jsx)(sl,{open:tl.isOpen,onOpenChange:tl.toggle,title:"Search API",description:"Query your stream pipeline as JSON",children:(0,i.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,i.jsxs)("p",{className:"text-xs text-gray-400",children:[(0,i.jsxs)("span",{className:"font-mono text-gray-200",children:["GET ",tZ]})," ","with query params ",(0,i.jsx)("span",{className:"text-gray-200",children:"type"})," and"," ",(0,i.jsx)("span",{className:"text-gray-200",children:"id"}),", authenticated with an"," ",(0,i.jsx)("span",{className:"text-gray-200",children:"Authorization: Basic base64(uuid:password)"})," ","header."]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Endpoint"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:tZ,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:t1,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy Search API URL",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]})]})]})}),(0,i.jsxs)(sl,{open:eG.isOpen,onOpenChange:eG.toggle,title:"Media server",description:"Your configuration as a server for the AIOStreams app and Jellyfin apps, such as Swiftfin, Findroid, Streamyfin, Android T
45V, Kodi and Infuse.",contentClass:"max-w-2xl w-full",children:[(0,i.jsx)(mv,{activeTab:eJ,onTabChange:eZ,defaultMobileOpen:"connect",animated:!1,tabs:[{value:"connect",label:"Connect",content:(0,i.jsxs)("div",{className:"space-y-5",children:[(0,i.jsx)(bq,{maxLibraries:(null==ep?void 0:ep.maxLibraries)??0,maxCatalogItems:(null==ep?void 0:ep.maxCatalogItems)??0,maxVersions:Math.min((null==(f=P.jellyfin)?void 0:f.maxVersions)??ef,ef)}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Server address"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:tP,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:tD,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy server address",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]}),(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"Add this as a server in the desktop app or any Jellyfin app."})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Username"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:t$,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:tL,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy username",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]}),(0,i.jsxs)("p",{className:"text-xs text-gray-500",children:["The password is your configuration password.",tO.length>0&&" Add /<user> to sign in as a user.",(tO.some(e=>e.lock)||!!(null==(y=P.jellyfin)||null==(b=y.primary)?void 0:b.lock))&&" For a user with a PIN, add /<PIN> to the password."]})]}),tV&&(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Address with a sign-in picker"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{type:"text",readOnly:!0,value:tV,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,i.jsx)(v,{onClick:tK,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy server address with user picker",children:(0,i.jsx)(bh.A,{className:"h-4 w-4"})})]}),(0,i.jsxs)("p",{className:"text-xs text-gray-500",children:["Lists this configuration's users at sign-in, so there is no UUID to type."," ",(null==ep?void 0:ep.pinSignIn)?"A user with a PIN of 6 or more digits signs in here with that PIN alone; everyone else still needs your password.":"Signing in still needs your password."," ","It holds the same secret as your install links, so keep it within your household.",tg?" Your alias stands in for the UUID and password; the long address still works.":el?" A share alias in your profile makes it short enough to type on a TV.":""]})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Quick Connect"}),(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"For TVs: choose Quick Connect on the client and enter its code here."}),(0,i.jsx)(K,{type:"text",inputMode:"numeric",placeholder:"123456",maxLength:6,value:eQ,onValueChange:e=>eX(e.replace(/\D/g,"").slice(0,6)),className:"font-mono text-sm"}),6===eQ.length&&!e1&&(0,i.jsx)("p",{className:"text-xs text-gray-500",children:e6?"Looking up the code...":e5??"No device is waiting on this code."}),e1&&(0,i.jsxs)("div",{className:"space-y-3 rounded-md border border-gray-800 p-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("p",{className:"text-sm text-white",children:[e1.device.app," on"," ",e1.device.name]}),(0,i.jsxs)("p",{className:"text-xs text-gray-500",children:["Version ",e1.device.version,", asked"," ",(E=e1.requestedAt,(M=Math.max(0,Math.round((Date.now()-Date.parse(E))/1e3)))<5?"just now":M<120?`${M}s ago`:`${Math.round(M/60)}m ago`),"."]})]}),tO.length>0&&(0,i.jsx)(nc,{label:"Sign in as",value:e8||"__account__",onValueChange:e=>{e7("__account__"===e?"":e),tt("")},options:[{label:tU,value:"__account__"},...tO.map(e=>({label:e.name,value:e.id}))]}),tz&&(0,i.jsx)(K,{label:"PIN",type:"password",inputMode:"numeric",autoComplete:"off",help:"This user has a PIN.",value:te,onValueChange:e=>tt(e.replace(/\D/g,"").slice(0,12))}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsxs)(v,{onClick:tW,intent:"primary",disabled:ts||tz&&te.length<4,loading:ts,children:["Approve",tF?` as ${tF}`:""]}),(0,i.jsx)(v,{intent:"primary-subtle",onClick:tH,children:"Cancel"})]})]})]}),(0,i.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[(0,i.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Web app"}),(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"Browse, see what is playing and manage watch history in your browser."})]}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",rounded:!0,className:"w-full shrink-0 sm:w-auto",leftIcon:(0,i.jsx)(bc.A,{className:"h-4 w-4"}),onClick:()=>window.open(tq,"_blank","noopener"),children:"Open"})]}),(0,i.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[(0,i.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Desktop app"}),(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"The app for Windows, Mac and Linux, with a player that plays what a browser can't. Sign in with one of the addresses above."})]}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",rounded:!0,className:"w-full shrink-0 sm:w-auto",leftIcon:(0,i.jsx)(xc.A,{className:"h-4 w-4"}),onClick:()=>window.open(bJ,"_blank","noopener"),children:"Download"})]}),(0,i.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[(0,i.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"API keys"}),(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"Let other tools use this server's API without your password."})]}),(0,i.jsxs)(v,{size:"sm",intent:"gray-outline",rounded:!0,className:"w-full shrink-0 sm:w-auto",leftIcon:(0,i.jsx)(pT.A,{className:"h-4 w-4"}),onClick:eY.open,children:["Manage",(null==(w=P.jellyfin)||null==(j=w.apiKeys)?void 0:j.length)?` (${P.jellyfin.apiKeys.length})`:""]}),(0,i.jsx)(sl,{open:eY.isOpen,onOpenChange:eY.toggle,title:"API keys",children:(0,i.jsx)(fK,{serverUrl:tP})})]})]})},{value:"users",label:"Users",content:(0,i.jsx)(f8,{})},{value:"trackers",label:"Trackers",content:(0,i.jsx)(bl,{})},{value:"playback",label:"Playback",content:(0,i.jsxs)("div",{className:"space-y-5",children:[(0,i.jsx)(ni,{label:"Resolve streams when an item opens",help:null===eN?"Fills the client's version list before you press play.":"Set by this instance.",moreHelp:null===eN?"Off, streams are fetched when playback starts or an app asks for the version list: lighter, but the list shows a placeholder until then.":void 0,side:"right",disabled:null!==eN,value:eN??(null==(N=P.jellyfin)?void 0:N.resolveOnOpen)??!0,defaultValue:!0,onValueChange:e=>$(t=>({...t,jellyfin:{...t.jellyfin,resolveOnOpen:e}}))}),(0,i.jsx)(lm,{label:"Versions per item",help:`Up to ${ef} on this instance.`,moreHelp:"Version names come from your formatter.",min:1,max:ef,value:Math.min((null==(k=P.jellyfin)?void 0:k.maxVersions)??ef,ef),onValueChange:e=>$(t=>({...t,jellyfin:{...t.jellyfin,maxVersions:void 0===e?void 0:e}}))}),(0,i.jsx)(ni,{label:"Mark unaired episodes",help:"Clients show upcoming episodes as unaired and won't offer to play them.",moreHelp:"Turn off if your client hides unaired episodes.",side:"right",value:(null==(S=P.jellyfin)?void 0:S.markUnaired)??!0,defaultValue:!0,onValueChange:e=>$(t=>({...t,jellyfin:{...t.jellyfin,markUnaired:e}}))}),eb&&(0,i.jsxs)("div",{className:"space-y-3 border-t border-gray-800 pt-4",children:[(0,i.jsx)(ni,{label:"Skip intro and credits",help:"Offers your client markers so it can show a skip button.",moreHelp:"Timestamps come from community databases and are submitted against one release of an episode, so on a differently cut copy a marker can be a few seconds out. Whether your client skips automatically or asks first is a setting inside that client, not here.",side:"right",value:(null==(C=P.jellyfin)?void 0:C.segments)??!0,defaultValue:!0,onValueChange:e=>$(t=>({...t,jellyfin:{...t.jellyfin,segments:e}}))}),((null==(_=P.jellyfin)?void 0:_.segments)??!0)&&(0,i.jsx)(la,{label:"Markers to offer",help:"Turning off credits keeps the next-episode countdown some clients build from it.",options:[{value:"Intro",label:"Intro"},{value:"Recap",label:"Recap"},{value:"Outro",label:"Credits"}],value:(null==(A=P.jellyfin)?void 0:A.segmentTypes)??["Intro","Recap","Outro"],onValueChange:e=>$(t=>({...t,jellyfin:{...t.jellyfin,segmentTypes:e}}))}),((null==(R=P.jellyfin)?void 0:R.segments)??!0)&&ev.length>0&&(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-white",children:"Sources"}),(0,i.jsx)("ul",{className:"space-y-1",children:ev.map(e=>{let t="pmdb"===e.id&&!!P.pmdbApiKey,s="configuration"===e.key&&!t;return(0,i.jsxs)("li",{className:"flex items-center justify-between gap-3 text-xs",children:[(0,i.jsx)("span",{className:"truncate text-gray-300",children:e.name}),(0,i.jsx)("span",{className:s?"shrink-0 text-[--orange]":"shrink-0 text-gray-500",children:s?"Needs your key":t?"Using your key":"Included"})]},e.id)})}),(0,i.jsx)("p",{className:"text-xs text-gray-500",children:"Asked in this order; the first with a marker for a type supplies it."})]}),((null==(T=P.jellyfin)?void 0:T.segments)??!0)&&ey&&(0,i.jsx)(G,{autoComplete:"new-password",label:"PublicMetaDB API Key",help:(0,i.jsxs)("span",{children:["instance"===ey?"This instance already asks PublicMetaDB for markers; your own key makes those lookups as your account instead. ":"Adds markers from PublicMetaDB, which also covers movies. ","Create a key under Settings â API on"," ",(0,i.jsx)("a",{href:"https://publicmetadb.com",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"publicmetadb.com"}),"."]}),placeholder:"instance"===ey?"Provided by this instance (enter your own to override)":"Enter your PublicMetaDB API key",value:P.pmdbApiKey,onValueChange:e=>$(t=>({...t,pmdbApiKey:e||void 0}))})]})]})}]}),(0,i.jsx)("p",{className:"mt-4 text-xs text-gray-500",children:"Save to apply changes."})]}),(0,i.jsx)(sl,{open:tr.isOpen,onOpenChange:tr.toggle,title:"AIOStreams for Aniyomi / Animiru",description:"Install the extension to use AIOStreams in Aniyomi and Animiru",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)("p",{className:"text-sm text-gray-300",children:"This unofficial extension brings AIOStreams support to Aniyomi and forks (e.g. Animiru)."}),(0,i.jsx)(v,{intent:"primary",className:"w-full",leftIcon:(0,i.jsx)(lV.HaR,{}),onClick:()=>window.open("https://github.com/worldInColors/aiostreams-extension","_blank"),children:"Open extension on GitHub"})]})}),(0,i.jsx)(bL,{open:q.isOpen,onOpenChange:e=>e?q.open():q.close(),showChanges:(null==P?void 0:P.showChanges)??!1,onShowChangesChange:e=>$(t=>({...t,showChanges:e})),manifestNotice:(null==P?void 0:P.manifestNotice)??"always",onManifestNoticeChange:e=>$(t=>({...t,manifestNotice:e})),pushBehaviour:(null==P||null==(I=P.linkedAccounts)?void 0:I.pushBehaviour)??"ask",onPushBehaviourChange:e=>$(t=>({...t,linkedAccounts:{...t.linkedAccounts,pushBehaviour:e}})),hasLinkedAccounts:((null==V?void 0:V.length)??0)>0}
45),ee&&(0,i.jsx)(bM,{open:!0,onOpenChange:e=>{e||et(null)},credentials:ee,manifestUrl:tk}),(0,i.jsx)(sc,{...tc}),(0,i.jsx)(sc,{...td}),(0,i.jsx)(sl,{open:eD.isOpen,onOpenChange:eD.toggle,title:"Export Configuration",description:"Choose how to export your configuration",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,i.jsx)(bP,{onClick:()=>{try{let e=eO?tp(P):structuredClone(P),t=JSON.stringify(e,null,2),s=new Blob([t],{type:"application/json"}),a=URL.createObjectURL(s),r=document.createElement("a");r.href=a;let n=new Date,l=e=>e.toString().padStart(2,"0"),i=`${n.getFullYear()}-${l(n.getMonth()+1)}-${l(n.getDate())}.${l(n.getHours())}-${l(n.getMinutes())}-${l(n.getSeconds())}`;r.download=`aiostreams-config-${i}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a),m.oR.success("Configuration exported successfully"),eD.close()}catch(e){m.oR.error("Failed to export configuration")}},icon:(0,i.jsx)(hZ.A,{className:"h-8 w-8"}),title:"Export Config",description:"Download as JSON file for backup or sharing"}),(0,i.jsx)(bP,{onClick:()=>{eD.close(),eP.open()},icon:(0,i.jsx)(m3.A,{className:"h-8 w-8"}),title:"Export as Template",description:"Create reusable template with custom metadata"})]}),(0,i.jsxs)("div",{className:"flex flex-col gap-3 mt-6 p-3 bg-gray-800/50 rounded-lg",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsxs)("div",{className:"flex-1",children:[(0,i.jsx)("div",{className:"text-sm font-medium text-white",children:"Exclude Credentials"}),(0,i.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Remove sensitive API keys and passwords from the export"})]}),(0,i.jsx)(ni,{value:eO,onValueChange:eU})]}),(0,i.jsx)(lB,{intent:"warning",isClosable:!1,description:"While excluding credentials removes your API keys, custom addon URLs, manually overridden URLs and variant scripts are left as written. These may contain sensitive information - double-check before sharing."})]})]})}),(0,i.jsx)(sl,{open:eL.isOpen,onOpenChange:eL.toggle,title:"Import Configuration",description:"Choose what type of configuration to import",children:(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,i.jsx)(bP,{onClick:()=>{var e;eL.close(),null==(e=eA.current)||e.click()},icon:(0,i.jsx)(xc.A,{className:"h-8 w-8"}),title:"Import Config",description:"Restore from a backup JSON file"}),(0,i.jsx)(bP,{onClick:()=>{eL.close(),e$.open()},icon:(0,i.jsx)(m3.A,{className:"h-8 w-8"}),title:"Import Template",description:"Load a pre-configured template"})]})}),(0,i.jsx)(h3,{open:eP.isOpen,onOpenChange:eP.toggle,userData:P,filterCredentials:tp}),(0,i.jsx)(xr,{open:e$.isOpen,onOpenChange:e$.toggle,openImportModal:!0})]})]})}var vs=s(3046);let va={torrentio:{name:`{stream.proxied["ðµï¸ââï¸ "||""]}{stream.private["ð "||""]}{stream.type::=p2p["[P2P] "||""]}{service.id::exists["[{service.shortName}"||""]}{service.cached["+] "||" download] "]}{addon.name} {stream.resolution::exists["{stream.resolution}"||"Unknown"]} 46{?{stream.visualTags::join(' | ')}?}`,description:`{?â¹ï¸{stream.message}?} 47{?{stream.folderName}?} 48{?{stream.filename}?} 49{stream.size::>0["ð¾{stream.size::bytes2} "||""]}{stream.folderSize::>0["/ ð¾{stream.folderSize::bytes2}"||""]}{stream.seeders::>=0["ð¤{stream.seeders} "||""]}{?ð {stream.age} ?}{?âï¸{stream.indexer}?} 50{?{stream.languageEmojis::join(' / ')}?}{stream.subtitles::exists::and::stream.languageEmojis::exists[" "||""]}{stream.subtitles::exists["Subs / {stream.subtitleEmojis::join(' / ')}"||""]} 51`},torbox:{name:`{stream.proxied["ðµï¸ââï¸ "||""]}{stream.private["ð "||""]}{stream.type::=p2p["[P2P] "||""]}{addon.name}{stream.library[" (Your Media) "||""]}{service.cached[" (Instant "||" ("]}{service.id::exists["{service.shortName})"||""]}{? ({stream.resolution})?}`,description:`Quality: {stream.quality::exists["{stream.quality}"||"Unknown"]} 52Name: {stream.filename::exists["{stream.filename}"||"Unknown"]} 53Size: {stream.size::>0["{stream.size::bytes} "||""]}{stream.folderSize::>0["/ {stream.folderSize::bytes} "||""]}{?| Source: {stream.indexer} ?}{stream.duration::>0["| Duration: {stream.duration::time} "||""]} 54Languages: {?{stream.languages::join(', ')}?}{stream.subtitles::exists::and::stream.languages::exists[" | "||""]}{?Subtitles: {stream.subtitles::join(', ')}?} 55{?Message: {stream.message}?}`},gdrive:{name:`{stream.proxied["ðµï¸ "||""]}{stream.private["ð "||""]}{stream.type::=p2p["[P2P] "||""]}{?[{service.shortName}?}{service.cached["â¡] "||"â³] "]}{addon.name}{stream.library[" (Your Media)"||""]} {?{stream.resolution}?}{stream.seadexBest[" (Best)"||""]}{stream.seadex::and::stream.seadexBest::isfalse[" (SeaDex Alt.)"||""]}{stream.rseMatched::exists::and::stream.seadex::isfalse::and::stream.rseMatched::string::~T1::or::stream.rseMatched::string::~T2::or::stream.rseMatched::string::~T3::or::stream.rseMatched::string::~T4::or::stream.rseMatched::string::~T5::or::stream.rseMatched::string::~T6::or::stream.rseMatched::string::~T7::or::stream.rseMatched::string::~T8[" ({stream.rseMatched::first})"||""]}{stream.regexMatched::exists::and::stream.rseMatched::exists::isfalse::and::stream.seadex::isfalse[" ({stream.regexMatched})"||""]}`,description:`{?ð¥ {stream.quality} ?}
55{?ðï¸ {stream.encode} ?}{?ð·ï¸ {stream.releaseGroup} ?}{?ð¡ {stream.network} ?}{stream.editions::exists["ð {stream.editions::join(' | ')} "||""]} 56{?ðº {stream.visualTags::join(' | ')} ?}{?ð§ {stream.audioTags::join(' | ')} ?}{?ð {stream.audioChannels::join(' | ')}?} 57{stream.size::>0["ð¦ {stream.size::sbytes} "||""]}{stream.folderSize::>0["/ {stream.folderSize::sbytes} "||""]}{stream.bitrate::>0["({stream.bitrate::sbitrate})"||""]}{stream.duration::>0["â±ï¸ {stream.duration::time} "||""]}{stream.seeders::>0["ð¥ {stream.seeders} "||""]}{?ð {stream.age} ?}{?ð {stream.indexer}?} 58{?ð {stream.languages::join(' | ')}?}{?ð {stream.subtitles::join(' | ')}?} 59{stream.filename::exists["ð"||""]} {?{stream.folderName}/?}{?{stream.filename}?} 60{?â¹ï¸ {stream.message}?} 61 `},lightgdrive:{name:`{stream.proxied["ðµï¸ "||""]}{stream.private["ð "||""]}{stream.type::=p2p["[P2P] "||""]}{?[{service.shortName}?}{stream.library["âï¸"||""]}{service.cached["â¡] "||"â³] "]}{addon.name}{? {stream.resolution}?}{stream.seadexBest[" (Best)"||""]}{stream.seadex::and::stream.seadexBest::isfalse[" (SeaDex Alt.)"||""]}{stream.rseMatched::exists::and::stream.seadex::isfalse::and::stream.rseMatched::string::~T1::or::stream.rseMatched::string::~T2::or::stream.rseMatched::string::~T3::or::stream.rseMatched::string::~T4::or::stream.rseMatched::string::~T5::or::stream.rseMatched::string::~T6::or::stream.rseMatched::string::~T7::or::stream.rseMatched::string::~T8[" ({stream.rseMatched::first})"||""]}{stream.regexMatched::exists::and::stream.rseMatched::exists::isfalse::and::stream.seadex::isfalse[" ({stream.regexMatched})"||""]}`,description:`{?ð {stream.title::title}?}{? ({stream.year})?}{? {stream.seasonEpisode::join(' ⢠')}?} 62{?ð¥ {stream.quality} ?}{?ðï¸ {stream.encode} ?}{?ð·ï¸ {stream.releaseGroup}?}{?ð¡ {stream.network} ?}{stream.editions::exists[" ð {stream.editions::join(' ⢠')}"||""]} 63{?ðº {stream.visualTags::join(' ⢠')} ?}{?ð§ {stream.audioTags::join(' ⢠')} ?}{?ð {stream.audioChannels::join(' ⢠')}?} 64{stream.size::>0["ð¦ {stream.size::sbytes} "||""]}{stream.folderSize::>0["/ {stream.folderSize::sbytes} "||""]}{stream.duration::>0["â±ï¸ {stream.duration::time} "||""]}{?ð {stream.age} ?}{?ð {stream.indexer}?} 65{?ð {stream.languageEmojis::join(' / ')}?}{stream.subtitles::exists["ð {stream.subtitleEmojis::join(' / ')}"||""]} 66{?â¹ï¸ {stream.message}?}`},minimalisticgdrive:{name:`{stream.resolution::exists["{stream.resolution::replace('2160p','⨠4K')::replace('1440p','ð 2K')::replace('1080p','ð§¿1080p')::replace('720p','ð¿720p')}"||"N/A"]}{service.cached[" ð« "||" ðï¸ "]} 67{?{stream.quality::upper}?} 68`,description:`{?ð {stream.visualTags::join(' ⢠')} ?}{?ð {stream.audioTags::join(' ⢠')}?} 69{stream.size::>0["ð¦ {stream.size::sbytes} "||""]} 70{?ð {stream.languages::join(' ⢠')}?}{?ð {stream.subtitles::join(' ⢠')}?} 71`},prism:{name:`{stream.resolution::exists["{stream.resolution::replace('2160p', 'ð¥4K UHD')::replace('1440p','⨠QHD')::replace('1080p','ð FHD')::replace('720p','ð¿ HD')::replace('576p','ð© Low Quality')::replace('480p','ð© Low Quality')::replace('360p','ð© Low Quality')::replace('240p','ð© Low Quality')::replace('144p','ð© Low Quality')}"||"ð© Unknown"]}`,description:`{?ð¬ {stream.title::title} ?}{?({stream.year}) ?}{?ð {stream.formattedSeasons} ?}{?ðï¸ {stream.formattedEpisodes}?}{stream.seadexBest["ðï¸ Best "||""]}{stream.seadex::and::stream.seadexBest::isfalse["ðï¸ Alternative"||""]}{stream.rseMatched::exists::and::stream.seadex::isfalse::and::stream.rseMatched::string::~T1::or::stream.rseMatched::string::~T2::or::stream.rseMatched::string::~T3::or::stream.rseMatched::string::~T4::or::stream.rseMatched::string::~T5::or::stream.rseMatched::string::~T6::or::stream.rseMatched::string::~T7::or::stream.rseMatched::string::~T8[" ðï¸ {stream.rseMatched::first}"||""]}{stream.regexMatched::exists::and::stream.rseMatched::exists::isfalse::and::stream.seadex::isfalse["ðï¸ {stream.regexMatched} "||""]} 72{?ð¥ {stream.quality} ?}
72{?ðº {stream.visualTags::join(' | ')} ?}{?ðï¸ {stream.encode} ?}{stream.duration::>0["â±ï¸ {stream.duration::time} "||""]}{stream.editions::exists["ð {stream.editions::join(' | ')} "||""]} 73{?ð§ {stream.audioTags::join(' | ')} ?}{?ð {stream.audioChannels::join(' | ')} ?}{stream.languages::exists["ð£ï¸ {stream.languageEmojis::join(' / ')}"||""]}{stream.subtitles::exists["ð {stream.subtitleEmojis::join(' / ')}"||""]} 74{stream.size::>0["ð¦ {stream.size::sbytes} "||""]}{stream.folderSize::>0["/ {stream.folderSize::sbytes} "||""]}{stream.bitrate::>0["ð {stream.bitrate::sbitrate} "||""]}{service.cached::isfalse::or::stream.type::=p2p::and::stream.seeders::>0["ð± {stream.seeders} "||""]}{stream.type::=usenet::and::stream.age::exists["ð {stream.age} "||""]} 75{?ð·ï¸ {stream.releaseGroup} ?}{?ð¡ {stream.indexer} ?}{?ð {stream.network}?} 76{service.cached["â¡Ready "||"â Not Ready "]}{service.id::exists["({service.shortName}) "||""]}{stream.library["ð Library "||""]}{stream.type::=Usenet["ð° Usenet "||""]}{stream.type::=p2p["â ï¸ P2P "||""]}{stream.type::=http["ð» Web Link "||""]}{stream.type::=youtube["â¶ï¸ Youtube "||""]}{stream.type::=live["ðº Live "||""]}{stream.proxied["ð Proxied "||""]}{stream.private["ð Private "||""]}ð{addon.name} 77{?â¹ï¸ {stream.message}?} 78`},tamtaro:{name:`{stream.resolution::exists["{stream.resolution::replace('2160p','\xa0\xa0\xa04K\xa0')::replace('1440p','\xa0\xa0\xa0\xa02K\xa0')::replace('p','P')}â"||"â\xa0\xa0\xa0\xa0\xa0"]}{?â{stream.type::replace('debrid','\xa0\xa0\xa0\xa0')::replace('p2p','â½áµ\xb2áµâ¾')::replace('live','â½Ë¡á¶¦áµáµâ¾')::replace('http','â½Ê·áµáµâ¾')::replace('usenet','ââ½â¿á¶»áµâ¾â')::replace('stremio-usenet','ââ½â¿á¶»áµâ¾')::replace('info','â½á¶¦â¿á¶ áµâ¾')::replace('statistic','â½Ë¢áµáµáµË¢â¾')::replace('external','â½áµË£áµâ¾')::replace('error','â½áµÊ³Ê³áµÊ³â¾')::replace('youtube','â½Ê¸áµâ¾')}âââ?}{service.cached["â¡"||"ââ³ââ"||""]}{?ââ 79\xa0\xa0â©{stream.quality::title::replace('Bluray Remux','Remux')::replace('Web-dl','Webâ-âdl')::replace('Hc Hd-rip','HC\xa0HDRip')::replace('Hdrip','HDRip')}âªâ\xa0\xa0\xa0\xa0\xa0?}{stream.message::~Download["{tools.removeLine} 80"||""]}{?â 81\xa0\xa0{stream.nSeScore::star::replace('⯪','â')}\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0?}{stream.message::~Download["{tools.removeLine} 82"||""]}`,description:`{stream.title::exists["{stream.library::istrue["âï¸"||"{stream.preloading::istrue["â¤"||"â"]}"]} {stream.date::exists["{stream.title::title::truncate(20)}"||"{stream.title::title::truncate(15)}"]}"||""]}{? \xb7 {stream.country} ?}{metadata.queryType::~series["{stream.date::exists[" \xb7 {stream.date::date('%-d %b %Y')} "||""]}"||"{stream.date::exists[" \xb7 {stream.date::date('%-d %b %Y')} "||"{? ({stream.year::replace('-20', '-')::replace('-19', '-')}) ?}"]}"]}{? {stream.seasonEpisode::join('\xb7')::replace('E','á´')::replace('S','s')::translate('0123456789','ââââââ ââââ')}?} 83{?⣠{stream.encode} ?}{stream.visualTags::exists["{stream.visualTags::in('DV','HLG','HDR','HDR10','HDR10+')["⦠"||"â§ "]}{stream.visualTags::sort::join(' \xb7 ')::replace('HDR \xb7 HDR','HDR')::replace('HDR10 \xb7 HDR10','HDR10')} "||""]}{stream.visualTags::length::<=1::and::stream.audioTags::length::=1::and::stream.audioChannels::length::<=1["⬠{stream.audioTags::lsort::join(' \xb7 ')::replace('DD \xb7 DD','DD')::replace('DTS \xb7 DTS','DTS')}{? ⯠{stream.audioChannels::rsort::join(' \xb7 ')}?}"||""]} 84{stream.visualTags::length::>1::or::stream.audioTags::length::=0::or::stream.audioTags::length::>1::or::stream.audioChannels::length::>1["{stream.audioTags::length::>0["⬠{stream.audioTags::lsort::join(' \xb7 ')::replace('DD \xb7 DD','DD')::replace('DTS \xb7 DTS','DTS')} "||""]}{stream.audioChannels::length::>0["⯠{stream.audioChannels::rsort::join(' \xb7 ')} "||""]}"||""]} 85{stream.size::>0["{stream.seasonPack["â "||"â "||""]}{stream.size::>0::and::stream.folderSize::>0::and::stream.size::sbytes::~GB::and::stream.folderSize::sbytes::~GB["{stream.size::sbytes::replace(' GB','')}"||"{stream.size::sbytes}"]}"||""]}{stream.folderSize::>0[" / {stream.folderSize::sbytes}"||""]}{? \xb7 {stream.bitrate::sbitrate::replace('Mbps','á´¹áµáµË¢')::replace('Kbps','á´·áµáµË¢')} ?}{stream.message::~Download["{tools.removeLine}"||""]}{service.cached::isfalse::or::stream.type::=p2p::and::stream.seeders::>0["â {stream.seeders}⦠"||""]}{?\xb7 {stream.age}?} 86{stream.proxied::istrue["â "||"â "]}{?[{service.shortName}] ?}{addon.name}{stream.private[" â¿ á´Êɪᴠá´á´á´ "||""]}{? \xb7 {stream.releaseGroup::truncate(13)}?}{stream.indexer::exists::and::stream.type::~usenet[" \xb7 {stream.indexer::truncate(13)}"||""]}{stream.message::~Download["{tools.removeLine} 87"||""]} 88{?{stream.subtitles::exists["â"||"â¿"]} {stream.uSmallLanguageCodes::join(' \xb7 ')::replace('ê±','s')::replace('á´ á´á´Ê á´á´á´ ɪá´','á´ á´á´')::replace('á´ á´ÊÊá´á´ ','á´ á´Ê')} ?}{stream.subbed["{stream.uLanguages::exists["\xb7 sá´Ê "||"â¿ sá´Ê "]}"||""]}{?({stream.uSmallSubtitleCodes::join(' \xb7 ')::replace('ê±','s')}) ?}{stream.seadex::or::stream.message::length::>0::or::stream.rseMatched::length::>0::or::stream.editions::exists::or::stream.network::exists::or::stream.seScore::>0::or::stream.seScore::<0["{stream.uSmallLanguageCodes::length::>2::or::stream.uSmallSubtitleCodes::length::>2::or::stream.rseMatched::remove('TrueHD ATMOS','DD+ ATMOS','ATMOS','TrueHD','DTS-HD MA','FLAC','DTS-HD HRA','DD+','DD','DTS-ES','DTS X','DTS','AAC','Opus','DV (Disk)','DV','HDR10+ Boost','HDR','IMAX Enhanced','IMAX','UHD Streaming Boost','HD Streaming Boost','INTERNAL','No-RlsGroup','FHD','UHD','HD','4K','126811','SiC','FraMeSToR','TheFarm','hallowed','BHDStudio','FLUX','Season Pack')::join(' ')::length::>10[" 89\xbb "||" \xbb "]}"||""]}{stream.seadex["{stream.seadexBest[" Êá´sá´ Êá´Êá´á´sá´ "||" á´Êá´ Êá´sá´ Êá´Êá´á´sá´ "]}"||""]}{stream.seadex::isfalse::and::stream.rseMatched::length::>0["{stream.rseMatched::remove('TrueHD ATMOS','DD+ ATMOS','ATMOS','TrueHD','DTS-HD MA','FLAC','DTS-HD HRA','DD+','DD','DTS-ES','DTS X','DTS','AAC','Opus','DV (Disk)','DV','HDR10+ Boost','HDR','IMAX Enhanced','IMAX','UHD Streaming Boost','HD Streaming Boost','INTERNAL','No-RlsGroup','FHD','UHD','HD','4K','126811','SiC','FraMeSToR','TheFarm','hallowed','BHDStudio','FLUX','Season Pack')::join(' ')::replace('UHD ','')::replace('HD ','')::replace('Movies Anywhere','MA')::translate('0123456789','ââââââ ââââ')::smallcaps::replace('ê±','s')} "||""]}{stream.seadex::isfalse::and::stream.rseMatched::length::>0::isfalse::and::stream.network::exists["{stream.network::smallcaps::replace('ê±','s')} "||""]}{stream.seadex::isfalse::and::stream.rseMatched::length::>0::isfalse::and::stream.network::exists::isfalse::and::stream.editions::exists["{stream.editions::join(' ')::remove('Edition')::smallcaps::replace('ê±','s')} "||""]}{stream.message::length::>0["{stream.message::replace('NZB Health: â ','â É´á´¢Ê')::replace('NZB Health: ð§','ð§ É´á´¢Ê')::replace('AvailNZB ð','ð É´á´¢Ê')::replace('NZB Health: â ï¸','á´É´á´ á´ÊɪÒɪá´á´ É´á´¢Ê')::replace('NZB Health: ð«','âÉ´á´¢Ê')::smallcaps} "||""]}{stream.seScore::>0::or::stream.seScore::<0["{stream.seScore::string::translate('0123456789','ââââââ ââââ')}"||""]}{stream.message::~Download["{tools.removeLine}"||""]}{service.cached::istrue::and::stream.message::~Download::istrue[" 90⥠DL Stream"||""]}`}},vr={config:["addonName"],stream:["filename","folderName","size","bitrate","folderSize","library","quality","resolution","subbed","dubbed","languages","mediaInfoQuality","uLanguages","subtitles","uSubtitles","languageEmojis","uLanguageEmojis","subtitleEmojis","uSubtitleEmojis","languageCodes","uLanguageCodes","subtitleCodes","uSubtitleCodes","smallLanguageCodes","uSmallLanguageCodes","smallSubtitleCodes","uSmallSubtitleCodes","wedontknowwhatakilometeris","uWedontknowwhatakilometeris","visualTags","audioTags","audioTracks","subtitleTracks","releaseGroup","regexMatched","rankedRegexMatched","regexScore","nRegexScore","encode","audioChannels","edition","editions","remastered","regraded","repack","proper","uncensored","unrated","upscaled","hasChapters","network","site","container","extension","indexer","year","title","country","episodeTitle","date","folderSeasons","formattedFolderSeasons","seasons","season","formattedSeasons","episodes","episode","formattedEpisodes","folderEpisodes","formattedFolderEpisodes","seasonEpisode","seasonPack","seeders","private","freeleech","age","ageHours","duration","infoHash","type","message","proxied","seadex","seadexBest","seScore","nSeScore","seMatched","rseMatched","preloading","idMatched"],metadata:["queryType","type","isAnime","title","titles","year","yearEnd","runtime","episodeRuntime","genres","originalLanguage","country","season","episode","absoluteEpisode","relativeAbsoluteEpisode","episodeTitle","episodeTitles","latestSeason","daysSinceRelease","daysSinceFirstAired","daysSinceLastAired","hasNextEpisode","daysUntilNextEpisode","anilistId","malId","hasSeaDex"],user:["languages","subtitles","resolutions","qualities","visualTags","audioTags","audioChannels","encodes","streamTypes","releaseGroups","keywords"],track:["lang","codec","tag","channels","title","default","forced","commentary","dub","original","hearingImpaired","visualImpaired"],service:["id","shortName","name","cached"],addon:["name","presetId","manifestUrl"],debug:["json","jsonf"]},vn=new Set(["stream.audioTracks","stream.subtitleTracks"]),vl=new Map(Object.entries(vr).flatMap(e=>{let[t,s]=e;return s.map(e=>[`${t}.${e}`.toLowerCase(),[t,e]])}));function vi(e,t){return vl.get(`${e}.${t}`.toLowerCase())}let vo=(()=>{let e=new Map;for(let[t,s]of Object.entries(vr))for(let a of s){let s=a.toLowerCase(),r=e.get(s);r?r.push(`${t}.${a}`):e.set(s,[`${t}.${a}`])}return e})();function vd(e,t){let s=Math.min(2,Math.floor(e.length/3));if(s<1)return[];let a=e.toLowerCase(),r=s+1,n=[];for(let e of t){let t=function(e,t,s){if(Math.abs(e.length-t.length)>s)return;let a=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let n=[r],l=r;
90for(let s=1;s<=t.length;s++){let i=+(e[r-1]!==t[s-1]);n[s]=Math.min(a[s]+1,n[s-1]+1,a[s-1]+i),l=Math.min(l,n[s])}if(l>s)return;a=n}let r=a[t.length];return r<=s?r:void 0}(a,e.toLowerCase(),s);void 0===t||t>r||(t<r&&(r=t,n=[]),n.push(e))}return n}function vc(e,t){let s=vo.get(t.toLowerCase());if(s)return[...s];let a=Object.keys(vr),r=a.find(t=>t.toLowerCase()===e.toLowerCase());return r?vd(t,vr[r]).map(e=>`${r}.${e}`):vd(e,a).map(e=>vi(e,t)).filter(e=>void 0!==e).map(e=>{let[t,s]=e;return`${t}.${s}`})}function vu(e,t){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(0===e)return"0 B";let a=Math.floor(Math.log(e)/Math.log(t)),r=parseFloat((e/Math.pow(t,a)).toFixed(2));return s&&(r=Math.round(r)),r+" "+(1024===t?["B","KiB","MiB","GiB","TiB"]:["B","KB","MB","GB","TB"])[a]}function vm(e,t){let s;if(0===e)return"0 B";let a=Math.floor(Math.log(e)/Math.log(t)),r=e/Math.pow(t,a),n=Math.floor(r);return(n>=100?(s=Math.round(r)).toString():n>=10?(s=parseFloat(r.toFixed(1)))%1==0?s.toFixed(0):s.toFixed(1):(s=parseFloat(r.toFixed(2))).toString())+" "+(1024===t?["B","KiB","MiB","GiB","TiB"]:["B","KB","MB","GB","TB"])[a]}function vh(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Number.isFinite(e)||e<=0)return"0 bps";let s=["bps","Kbps","Mbps","Gbps","Tbps"],a=Math.min(s.length-1,Math.max(0,Math.floor(Math.log(e)/Math.log(1e3)))),r=e/Math.pow(1e3,a);return r=t?Math.round(r):parseFloat(r.toFixed(2)),`${r} ${s[a]}`}function vp(e,t){let s=[{text:"",zero:!0,sawToken:!1}],a=()=>{let e=s.pop(),t=s[s.length-1];e.sawToken&&e.zero||(t.text+=e.text,t.sawToken||(t.sawToken=e.sawToken),e.zero||(t.zero=!1))};for(let r=0;r<e.length;r++){let n=e[r],l=s[s.length-1];if("%"===n){let s=e[r+1];if(void 0===s){l.text+="%";break}if("%"===s||"["===s||"]"===s){l.text+=s,r+=1;continue}let a="-"===s?e.slice(r+1,r+3):s,n=t(a);void 0===n?l.text+=`%${a}`:(l.text+=n.text,l.sawToken=!0,n.zero||(l.zero=!1)),r+=a.length;continue}if("["===n){s.push({text:"",zero:!0,sawToken:!1});continue}if("]"===n&&s.length>1){a();continue}l.text+=n}for(;s.length>1;)a();return s[0].text}let vx=["H","M","S"];function vg(e){return e<0?0:e<1e3?60*e*1e3:e}let vf=["January","February","March","April","May","June","July","August","September","October","November","December"],vb=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function vv(e){return e.split("").map(e=>vy[e.toUpperCase()]||e).join("")}let vy={A:"á´",B:"Ê",C:"á´",D:"á´
",E:"á´",F:"Ò",G:"É¢",H:"Ê",I:"ɪ",J:"á´",K:"á´",L:"Ê",M:"á´",N:"É´",O:"á´",P:"á´",Q:"Ç«",R:"Ê",S:"ê±",T:"á´",U:"á´",V:"á´ ",W:"á´¡",X:"x",Y:"Ê",Z:"á´¢"},vj=[{iso_639_1:"aa",iso_639_2:"aar",iso_3166_1:"ET",flag:"\uD83C\uDDEA\uD83C\uDDF9",english_name:"Afar",name:"Qaf\xe1r af"},{iso_639_1:"ab",iso_639_2:"abk",iso_3166_1:"GE",flag:"\uD83C\uDDEC\uD83C\uDDEA",english_name:"Abkhazian",name:"ÐÒ§ÑÑа бÑзÑÓа"},{iso_639_1:"ae",iso_639_2:"ave",iso_3166_1:"IR",flag:"\uD83C\uDDEE\uD83C\uDDF7",english_name:"Avestan",name:"Avesta"},{iso_639_1:"af",iso_639_2:"afr",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Afrikaans",name:"Afrikaans"},{iso_639_1:"ak",iso_639_2:"aka",iso_3166_1:"GH",flag:"\uD83C\uDDEC\uD83C\uDDED",english_name:"Akan",name:"Akan"},{iso_639_1:"am",iso_639_2:"amh",iso_3166_1:"ET",flag:"\uD83C\uDDEA\uD83C\uDDF9",english_name:"Amharic",name:"á ááá"},{iso_639_1:"an",iso_639_2:"arg",iso_3166_1:"ES",flag:"\uD83C\uDDEA\uD83C\uDDF8",english_name:"Aragonese",name:"Aragon\xe9s"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"SA",flag:"\uD83C\uDDF8\uD83C\uDDE6",flag_priority:!0,english_name:"Arabic",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"AE",flag:"\uD83C\uDDE6\uD83C\uDDEA",english_name:"Arabic (UAE)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"EG",flag:"\uD83C\uDDEA\uD83C\uDDEC",english_name:"Arabic (Egypt)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"as",iso_639_2:"asm",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Assamese",name:"à¦
সমà§à¦¯à¦¼à¦¾"},{iso_639_1:"av",iso_639_2:"ava",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Avaric",name:"ÐÐ²Ð°Ñ Ð¼Ð°ÑÓ"},{iso_639_1:"ay",iso_639_2:"aym",iso_3166_1:"BO",flag:"\uD83C\uDDE7\uD83C\uDDF4",english_name:"Aymara",name:"Aymar aru"},{iso_639_1:"az",iso_639_2:"aze",iso_3166_1:"AZ",flag:"\uD83C\uDDE6\uD83C\uDDFF",english_name:"Azerbaijani",name:"AzÉrbaycan"},{iso_639_1:"ba",iso_639_2:"bak",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Bashkir",name:"ÐаÑҡоÑÑ Ñеле"},{iso_639_1:"be",iso_639_2:"bel",iso_3166_1:"BY",flag:"\uD83C\uDDE7\uD83C\uDDFE",english_name:"Belarusian",name:"ÐелаÑÑÑÐºÐ°Ñ Ð¼Ð¾Ð²Ð°"},{iso_639_1:"bg",iso_639_2:"bul",iso_3166_1:"BG",flag:"\uD83C\uDDE7\uD83C\uDDEC",english_name:"Bulgarian",name:"ÐÑлгаÑÑки език"},{iso_639_1:"bi",iso_639_2:"bis",iso_3166_1:"VU",flag:"\uD83C\uDDFB\uD83C\uDDFA",english_name:"Bislama",name:"Bislama"},{iso_639_1:"bm",iso_639_2:"bam",iso_3166_1:"ML",flag:"\uD83C\uDDF2\uD83C\uDDF1",english_name:"Bambara",name:"Bamanankan"},{iso_639_1:"bn",iso_639_2:"ben",iso_3166_1:"BD",flag:"\uD83C\uDDE7\uD83C\uDDE9",flag_priority:!0,english_name:"Bengali",name:"বাà¦à¦²à¦¾"},{iso_639_1:"bo",iso_639_2:"bod",iso_3166_1:"CN",flag:"\uD83C\uDDE8\uD83C\uDDF3",english_name:"Tibetan",name:"à½à½¼à½à¼à½¡à½²à½"},{iso_639_1:"br",iso_639_2:"bre",iso_3166_1:"FR",flag:"\uD83C\uDDEB\uD83C\uDDF7",english_name:"Breton",name:"Brezhoneg"},{iso_639_1:"bs",iso_639_2:"bos",iso_3166_1:"BA",flag:"\uD83C\uDDE7\uD83C\uDDE6",english_name:"Bosnian",name:"Bosanski"},{iso_639_1:"ca",iso_639_2:"cat",iso_3166_1:"ES",flag:"\uD83C\uDDEA\uD83C\uDDF8",english_name:"Catalan",name:"Catal\xe0"},{iso_639_1:"ce",iso_639_2:"che",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Chechen",name:"ÐоÑ
Ñийн моÑÑ"},{iso_639_1:"ch",iso_639_2:"cha",iso_3166_1:"MP",flag:"\uD83C\uDDF2\uD83C\uDDF5",english_name:"Chamorro",name:"Finu' Chamorro"},{iso_639_1:"co",iso_639_2:"cos",iso_3166_1:"FR",flag:"\uD83C\uDDEB\uD83C\uDDF7",english_name:"Corsican",name:"Corsu"},{iso_639_1:"cr",iso_639_2:"cre",iso_3166_1:"CA",flag:"\uD83C\uDDE8\uD83C\uDDE6",english_name:"Cree",name:"áá¦ááááá£"},{iso_639_1:"cs",iso_639_2:"ces",iso_3166_1:"CZ",flag:"\uD83C\uDDE8\uD83C\uDDFF",english_name:"Czech",name:"Äesk\xfd"},{iso_639_1:"cu",iso_639_2:"chu",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Church Slavic",name:"СловѣнÑÑкÑ"},{iso_639_1:"cv",iso_639_2:"chv",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Chuvash",name:"ЧÓÐ²Ð°Ñ ÑÓлÑ
и"},{iso_639_1:"cy",iso_639_2:"cym",iso_3166_1:"GB",flag:"\uD83C\uDDEC\uD83C\uDDE7",english_name:"Welsh",name:"Cymraeg"},{iso_639_1:"da",iso_639_2:"dan",iso_3166_1:"DK",flag:"\uD83C\uDDE9\uD83C\uDDF0",flag_priority:!0,english_name:"Danish",name:"Dansk"},{iso_639_1:"de",iso_639_2:"deu",iso_3166_1:"DE",flag:"\uD83C\uDDE9\uD83C\uDDEA",flag_priority:!0,english_name:"German",name:"Deutsch"},{iso_639_1:"dv",iso_639_2:"div",iso_3166_1:"MV",flag:"\uD83C\uDDF2\uD83C\uDDFB",english_name:"Divehi",name:"ÞÞ¨ÞÞ¬ÞÞ¨"},{iso_639_1:"dz",iso_639_2:"dzo",iso_3166_1:"BT",flag:"\uD83C\uDDE7\uD83C\uDDF9",english_name:"Dzongkha",name:"རྫོà½à¼à½"},{iso_639_1:"ee",iso_639_2:"ewe",iso_3166_1:"GH",flag:"\uD83C\uDDEC\uD83C\uDDED",english_name:"Ewe",name:"\xc8Êegbe"},{iso_639_1:"el",iso_639_2:"ell",iso_3166_1:"GR",flag:"\uD83C\uDDEC\uD83C\uDDF7",english_name:"Greek",name:"Îλληνικά"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"GB",flag:"\uD83C\uDDEC\uD83C\uDDE7",flag_priority:!0,english_name:"English (UK)",name:"English"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"US",flag:"\uD83C\uDDFA\uD83C\uDDF8",english_name:"English (US)",name:"English"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"AU",flag:"\uD83C\uDDE6\uD83C\uDDFA",english_name:"English (Australia)",name:"English"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"CA",flag:"\uD83C\uDDE8\uD83C\uDDE6",english_name:"English (Canad
90a)",name:"English"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"IE",flag:"\uD83C\uDDEE\uD83C\uDDEA",english_name:"English (Ireland)",name:"English"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"NZ",flag:"\uD83C\uDDF3\uD83C\uDDFF",english_name:"English (New Zealand)",name:"English"},{iso_639_1:"eo",iso_639_2:"epo",iso_3166_1:null,flag:"\uD83C\uDF10",english_name:"Esperanto",name:"Esperanto"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"ES",flag:"\uD83C\uDDEA\uD83C\uDDF8",flag_priority:!0,english_name:"Spanish",name:"Espa\xf1ol"},{iso_639_1:"et",iso_639_2:"est",iso_3166_1:"EE",flag:"\uD83C\uDDEA\uD83C\uDDEA",english_name:"Estonian",name:"Eesti"},{iso_639_1:"eu",iso_639_2:"eus",iso_3166_1:"ES",flag:"\uD83C\uDFF4",english_name:"Basque",name:"Euskera"},{iso_639_1:"fa",iso_639_2:"fas",iso_3166_1:"IR",flag:"\uD83C\uDDEE\uD83C\uDDF7",english_name:"Persian",name:"ÙØ§Ø±Ø³Û"},{iso_639_1:"ff",iso_639_2:"ful",iso_3166_1:"SN",flag:"\uD83C\uDDF8\uD83C\uDDF3",english_name:"Fulah",name:"Fulfulde"},{iso_639_1:"fi",iso_639_2:"fin",iso_3166_1:"FI",flag:"\uD83C\uDDEB\uD83C\uDDEE",english_name:"Finnish",name:"Suomi"},{iso_639_1:"fj",iso_639_2:"fij",iso_3166_1:"FJ",flag:"\uD83C\uDDEB\uD83C\uDDEF",english_name:"Fijian",name:"Vosa Vakaviti"},{iso_639_1:"fo",iso_639_2:"fao",iso_3166_1:"FO",flag:"\uD83C\uDDEB\uD83C\uDDF4",english_name:"Faroese",name:"F\xf8royskt"},{iso_639_1:"fr",iso_639_2:"fra",iso_3166_1:"FR",flag:"\uD83C\uDDEB\uD83C\uDDF7",flag_priority:!0,english_name:"French",name:"Fran\xe7ais"},{iso_639_1:"fy",iso_639_2:"fry",iso_3166_1:"NL",flag:"\uD83C\uDDF3\uD83C\uDDF1",english_name:"Western Frisian",name:"Frysk"},{iso_639_1:"ga",iso_639_2:"gle",iso_3166_1:"IE",flag:"\uD83C\uDDEE\uD83C\uDDEA",english_name:"Irish",name:"Gaeilge"},{iso_639_1:"gd",iso_639_2:"gla",iso_3166_1:"GB",flag:"\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74\uDB40\uDC7F",english_name:"Scottish Gaelic",name:"G\xe0idhlig"},{iso_639_1:"gl",iso_639_2:"glg",iso_3166_1:"ES",flag:"\uD83C\uDDEA\uD83C\uDDF8",english_name:"Galician",name:"Galego"},{iso_639_1:"gn",iso_639_2:"grn",iso_3166_1:"PY",flag:"\uD83C\uDDF5\uD83C\uDDFE",english_name:"Guarani",name:"Ava\xf1e'ẽ"},{iso_639_1:"gu",iso_639_2:"guj",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Gujarati",name:"àªà«àªàª°àª¾àª¤à«"},{iso_639_1:"gv",iso_639_2:"glv",iso_3166_1:"IM",flag:"\uD83C\uDDEE\uD83C\uDDF2",english_name:"Manx",name:"Gaelg"},{iso_639_1:"ha",iso_639_2:"hau",iso_3166_1:"NG",flag:"\uD83C\uDDF3\uD83C\uDDEC",english_name:"Hausa",name:"Hausa"},{iso_639_1:"he",iso_639_2:"heb",iso_3166_1:"IL",flag:"\uD83C\uDDEE\uD83C\uDDF1",flag_priority:!0,english_name:"Hebrew",name:"×¢Ö´×ְרִ×ת"},{iso_639_1:"hi",iso_639_2:"hin",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",flag_priority:!0,english_name:"Hindi",name:"हिनà¥à¤¦à¥"},{iso_639_1:"ho",iso_639_2:"hmo",iso_3166_1:"PG",flag:"\uD83C\uDDF5\uD83C\uDDEC",english_name:"Hiri Motu",name:"Hiri Motu"},{iso_639_1:"hr",iso_639_2:"hrv",iso_3166_1:"HR",flag:"\uD83C\uDDED\uD83C\uDDF7",english_name:"Croatian",name:"Hrvatski"},{iso_639_1:"ht",iso_639_2:"hat",iso_3166_1:"HT",flag:"\uD83C\uDDED\uD83C\uDDF9",english_name:"Haitian; Haitian Creole",name:"Krey\xf2l ayisyen"},{iso_639_1:"hu",iso_639_2:"hun",iso_3166_1:"HU",flag:"\uD83C\uDDED\uD83C\uDDFA",english_name:"Hungarian",name:"Magyar"},{iso_639_1:"hy",iso_639_2:"hye",iso_3166_1:"AM",flag:"\uD83C\uDDE6\uD83C\uDDF2",english_name:"Armenian",name:"ÕÕ¡ÕµÕ¥ÖÕ¥Õ¶"},{iso_639_1:"hz",iso_639_2:"her",iso_3166_1:"NA",flag:"\uD83C\uDDF3\uD83C\uDDE6",english_name:"Herero",name:"Otjiherero"},{iso_639_1:"ia",iso_639_2:"ina",iso_3166_1:null,flag:"\uD83C\uDF10",english_name:"Interlingua",name:"Interlingua"},{iso_639_1:"id",iso_639_2:"ind",iso_3166_1:"ID",flag:"\uD83C\uDDEE\uD83C\uDDE9",flag_priority:!0,english_name:"Indonesian",name:"Bahasa Indonesia"},{iso_639_1:"ie",iso_639_2:"ile",iso_3166_1:null,flag:"\uD83C\uDF10",english_name:"Interlingue",name:"Interlingue"},{iso_639_1:"ig",iso_639_2:"ibo",iso_3166_1:"NG",flag:"\uD83C\uDDF3\uD83C\uDDEC",english_name:"Igbo",name:"Asụsụ Igbo"},{iso_639_1:"ii",iso_639_2:"iii",iso_3166_1:"CN",flag:"\uD83C\uDDE8\uD83C\uDDF3",english_name:"Sichuan Yi; Nuosu",name:"êê ê"},{iso_639_1:"ik",iso_639_2:"ipk",iso_3166_1:"US",flag:"\uD83C\uDDFA\uD83C\uDDF8",english_name:"Inupiaq",name:"I\xf1upiaq"},{iso_639_1:"io",iso_639_2:"ido",iso_3166_1:null,flag:"\uD83C\uDF10",english_name:"Ido",name:"Ido"},{iso_639_1:"is",iso_639_2:"isl",iso_3166_1:"IS",flag:"\uD83C\uDDEE\uD83C\uDDF8",english_name:"Icelandic",name:"\xcdslenska"},{iso_639_1:"it",iso_639_2:"ita",iso_3166_1:"IT",flag:"\uD83C\uDDEE\uD83C\uDDF9",flag_priority:!0,english_name:"Italian",name:"Italiano"},{iso_639_1:"iu",iso_639_2:"iku",iso_3166_1:"CA",flag:"\uD83C\uDDE8\uD83C\uDDE6",english_name:"Inuktitut",name:"áááááá¦"},{iso_639_1:"ja",iso_639_2:"jpn",iso_3166_1:"JP",flag:"\uD83C\uDDEF\uD83C\uDDF5",english_name:"Japanese",name:"æ¥æ¬èª"},{iso_639_1:"jv",iso_639_2:"jav",iso_3166_1:"ID",flag:"\uD83C\uDDEE\uD83C\uDDE9",english_name:"Javanese",name:"Basa Jawa"}
90,{iso_639_1:"ka",iso_639_2:"kat",iso_3166_1:"GE",flag:"\uD83C\uDDEC\uD83C\uDDEA",english_name:"Georgian",name:"á¥áá áá£áá"},{iso_639_1:"kg",iso_639_2:"kon",iso_3166_1:"CD",flag:"\uD83C\uDDE8\uD83C\uDDE9",english_name:"Kongo",name:"KiKongo"},{iso_639_1:"ki",iso_639_2:"kik",iso_3166_1:"KE",flag:"\uD83C\uDDF0\uD83C\uDDEA",english_name:"Kikuyu; Gikuyu",name:"GÄ©kÅ©yÅ©"},{iso_639_1:"kj",iso_639_2:"kua",iso_3166_1:"AO",flag:"\uD83C\uDDE6\uD83C\uDDF4",english_name:"Kuanyama; Kwanyama",name:"Kuanyama"},{iso_639_1:"kk",iso_639_2:"kaz",iso_3166_1:"KZ",flag:"\uD83C\uDDF0\uD83C\uDDFF",english_name:"Kazakh",name:"ÒазаÒ"},{iso_639_1:"kl",iso_639_2:"kal",iso_3166_1:"GL",flag:"\uD83C\uDDEC\uD83C\uDDF1",english_name:"Kalaallisut; Greenlandic",name:"Kalaallisut"},{iso_639_1:"km",iso_639_2:"khm",iso_3166_1:"KH",flag:"\uD83C\uDDF0\uD83C\uDDED",english_name:"Central Khmer",name:"áá¶áá¶ááááá"},{iso_639_1:"kn",iso_639_2:"kan",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Kannada",name:"à²à²¨à³à²¨à²¡"},{iso_639_1:"ko",iso_639_2:"kor",iso_3166_1:"KR",flag:"\uD83C\uDDF0\uD83C\uDDF7",english_name:"Korean",name:"íêµì´/ì¡°ì ë§"},{iso_639_1:"kr",iso_639_2:"kau",iso_3166_1:"NE",flag:"\uD83C\uDDF3\uD83C\uDDEA",english_name:"Kanuri",name:"Kanuri"},{iso_639_1:"ks",iso_639_2:"kas",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Kashmiri",name:"à¤à¤¶à¥à¤®à¥à¤°à¥"},{iso_639_1:"ku",iso_639_2:"kur",iso_3166_1:"TR",flag:"\uD83C\uDDF9\uD83C\uDDF7",english_name:"Kurdish",name:"Kurd\xee"},{iso_639_1:"kv",iso_639_2:"kom",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Komi",name:"Ðоми кÑв"},{iso_639_1:"kw",iso_639_2:"cor",iso_3166_1:"GB",flag:"\uD83C\uDDEC\uD83C\uDDE7",english_name:"Cornish",name:"Kernewek"},{iso_639_1:"ky",iso_639_2:"kir",iso_3166_1:"KG",flag:"\uD83C\uDDF0\uD83C\uDDEC",english_name:"Kirghiz; Kyrgyz",name:"ÐÑÑгÑзÑа"},{iso_639_1:"la",iso_639_2:"lat",iso_3166_1:"VA",flag:"\uD83C\uDDFB\uD83C\uDDE6",english_name:"Latin",name:"Latine"},{iso_639_1:"lb",iso_639_2:"ltz",iso_3166_1:"LU",flag:"\uD83C\uDDF1\uD83C\uDDFA",english_name:"Luxembourgish; Letzeburgesch",name:"L\xebtzebuergesch"},{iso_639_1:"lg",iso_639_2:"lug",iso_3166_1:"UG",flag:"\uD83C\uDDFA\uD83C\uDDEC",english_name:"Ganda",name:"Luganda"},{iso_639_1:"li",iso_639_2:"lim",iso_3166_1:"NL",flag:"\uD83C\uDDF3\uD83C\uDDF1",english_name:"Limburgan; Limburger; Limburgish",name:"Limburgs"},{iso_639_1:"ln",iso_639_2:"lin",iso_3166_1:"CD",flag:"\uD83C\uDDE8\uD83C\uDDE9",english_name:"Lingala",name:"Ling\xe1la"},{iso_639_1:"lo",iso_639_2:"lao",iso_3166_1:"LA",flag:"\uD83C\uDDF1\uD83C\uDDE6",english_name:"Lao",name:"àºàº²àºªàº²àº¥àº²àº§"},{iso_639_1:"lt",iso_639_2:"lit",iso_3166_1:"LT",flag:"\uD83C\uDDF1\uD83C\uDDF9",english_name:"Lithuanian",name:"Lietuvių"},{iso_639_1:"lu",iso_639_2:"lub",iso_3166_1:"CD",flag:"\uD83C\uDDE8\uD83C\uDDE9",english_name:"Luba-Katanga",name:"Tshiluba"},{iso_639_1:"lv",iso_639_2:"lav",iso_3166_1:"LV",flag:"\uD83C\uDDF1\uD83C\uDDFB",english_name:"Latvian",name:"LatvieÅ¡u"},{iso_639_1:"mg",iso_639_2:"mlg",iso_3166_1:"MG",flag:"\uD83C\uDDF2\uD83C\uDDEC",english_name:"Malagasy",name:"Malagasy"},{iso_639_1:"mh",iso_639_2:"mah",iso_3166_1:"MH",flag:"\uD83C\uDDF2\uD83C\uDDED",english_name:"Marshallese",name:"Kajin M̧ajeļ"},{iso_639_1:"mi",iso_639_2:"mri",iso_3166_1:"NZ",flag:"\uD83C\uDDF3\uD83C\uDDFF",english_name:"Maori",name:"Te Reo MÄori"},{iso_639_1:"mk",iso_639_2:"mkd",iso_3166_1:"MK",flag:"\uD83C\uDDF2\uD83C\uDDF0",english_name:"Macedonian",name:"ÐакедонÑки Ñазик"},{iso_639_1:"ml",iso_639_2:"mal",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Malayalam",name:"മലയാളà´"},{iso_639_1:"mn",iso_639_2:"mon",iso_3166_1:"MN",flag:"\uD83C\uDDF2\uD83C\uDDF3",english_name:"Mongolian",name:"Ðонгол"},{iso_639_1:"mr",iso_639_2:"mar",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Marathi",name:"मराठà¥"},{iso_639_1:"ms",iso_639_2:"msa",iso_3166_1:"MY",flag:"\uD83C\uDDF2\uD83C\uDDFE",english_name:"Malay",name:"Bahasa Melayu"},{iso_639_1:"mt",iso_639_2:"mlt",iso_3166_1:"MT",flag:"\uD83C\uDDF2\uD83C\uDDF9",english_name:"Maltese",name:"Malti"},{iso_639_1:"my",iso_639_2:"mya",iso_3166_1:"MM",flag:"\uD83C\uDDF2\uD83C\uDDF2",english_name:"Burmese",name:"ááá¬á
á¬"},{iso_639_1:"na",iso_639_2:"nau",iso_3166_1:"NR",flag:"\uD83C\uDDF3\uD83C\uDDF7",english_name:"Nauru",name:"Dorerin Naoero"},{iso_639_1:"nb",iso_639_2:"nob",iso_3166_1:"NO",flag:"\uD83C\uDDF3\uD83C\uDDF4",english_name:"Bokm\xe5l, Norwegian; Norwegian Bokm\xe5l",internal_english_name:"Norwegian",name:"Bokm\xe5l"},{iso_639_1:"nd",iso_639_2:"nde",iso_3166_1:"ZW",flag:"\uD83C\uDDFF\uD83C\uDDFC",english_name:"Ndebele, North; North Ndebele",name:"IsiNdebele"},{iso_639_1:"ne",iso_639_2:"nep",iso_3166_1:"NP",flag:"\uD83C\uDDF3\uD83C\uDDF5",english_name:"Nepali",name:"नà¥à¤ªà¤¾à¤²à¥"},{iso_639_1:"ng",iso_639_2:"ndo",iso_3166_1:"NA",flag:"\uD83C\uDDF3\uD83C\uDDE6",english_name:"Ndonga",name:"Owambo"},{iso_639_1:"nl",iso_639_2:"nld",iso_3166_1:"NL",flag:"\uD83C\uDDF3\uD83C\uDDF1",flag_priority:!0,english_name:"Dutch; Flemish",name:"Nederlands"},{iso_639_1:"nn",iso_639_2:"nno",iso_3166_1:"NO",flag:"\uD83C\uDDF3\uD83C\uDDF4",english_name:"Norwegian Nynorsk; Nynorsk, Norwegian",internal_english_name:"Norwegian",name:"Nynorsk"},{iso_639_1:"no",iso_639_2:"nor",iso_3166_1:"NO",flag:"\uD83C\uDDF3\uD83C\uDDF4",flag_priority:!0,english_name:"Norwegian",name:"Norsk"},{iso_639_1:"nr",iso_639_2:"nbl",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Ndebele, South; South Ndebele",name:"IsiNdebele"},{iso_639_1:"nv",iso_639_2:"nav",iso_3166_1:"US",flag:"\uD83C\uDDFA\uD83C\uDDF8",english_name:"Navajo; Navaho",name:"Din\xe9 bizaad"},{iso_639_1:"ny",iso_639_2:"nya",iso_3166_1:"MW",flag:"\uD83C\uDDF2\uD83C\uDDFC",english_name:"Chichewa;
90 Chewa; Nyanja",name:"ChiCheŵa"},{iso_639_1:"oc",iso_639_2:"oci",iso_3166_1:"FR",flag:"\uD83C\uDDEB\uD83C\uDDF7",english_name:"Occitan (post 1500)",name:"Occitan"},{iso_639_1:"oj",iso_639_2:"oji",iso_3166_1:"CA",flag:"\uD83C\uDDE8\uD83C\uDDE6",english_name:"Ojibwa",name:"ááááá¯á§áá"},{iso_639_1:"om",iso_639_2:"orm",iso_3166_1:"ET",flag:"\uD83C\uDDEA\uD83C\uDDF9",english_name:"Oromo",name:"Afaan Oromoo"},{iso_639_1:"or",iso_639_2:"ori",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Oriya",name:"à¬à¬¡à¬¼à¬¿à¬"},{iso_639_1:"os",iso_639_2:"oss",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Ossetian; Ossetic",name:"ÐÑон \xe6взаг"},{iso_639_1:"pa",iso_639_2:"pan",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Panjabi; Punjabi",name:"ਪੰà¨à¨¾à¨¬à©"},{iso_639_1:"pi",iso_639_2:"pli",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Pali",name:"पाऴि"},{iso_639_1:"pl",iso_639_2:"pol",iso_3166_1:"PL",flag:"\uD83C\uDDF5\uD83C\uDDF1",english_name:"Polish",name:"Polski"},{iso_639_1:"ps",iso_639_2:"pus",iso_3166_1:"AF",flag:"\uD83C\uDDE6\uD83C\uDDEB",english_name:"Pushto; Pashto",name:"Ù¾ÚØªÙ"},{iso_639_1:"pt",iso_639_2:"por",iso_3166_1:"PT",flag:"\uD83C\uDDF5\uD83C\uDDF9",flag_priority:!0,english_name:"Portuguese",name:"Portugu\xeas"},{iso_639_1:"pt",iso_639_2:"por",iso_3166_1:"BR",flag:"\uD83C\uDDE7\uD83C\uDDF7",english_name:"Portuguese (Brazil)",internal_english_name:"Portuguese (Brazil)",name:"Portugu\xeas"},{iso_639_1:"qu",iso_639_2:"que",iso_3166_1:"PE",flag:"\uD83C\uDDF5\uD83C\uDDEA",english_name:"Quechua",name:"Runa Simi"},{iso_639_1:"rm",iso_639_2:"roh",iso_3166_1:"CH",flag:"\uD83C\uDDE8\uD83C\uDDED",english_name:"Romansh",name:"Rumantsch grischun"},{iso_639_1:"rn",iso_639_2:"run",iso_3166_1:"BI",flag:"\uD83C\uDDE7\uD83C\uDDEE",english_name:"Rundi",name:"Kirundi"},{iso_639_1:"ro",iso_639_2:"ron",iso_3166_1:"RO",flag:"\uD83C\uDDF7\uD83C\uDDF4",english_name:"Romanian",name:"Rom\xe2nÄ"},{iso_639_1:"ru",iso_639_2:"rus",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",flag_priority:!0,english_name:"Russian",name:"PÑÑÑкий"},{iso_639_1:"rw",iso_639_2:"kin",iso_3166_1:"RW",flag:"\uD83C\uDDF7\uD83C\uDDFC",english_name:"Kinyarwanda",name:"Ikinyarwanda"},{iso_639_1:"sa",iso_639_2:"san",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Sanskrit",name:"सà¤à¤¸à¥à¤à¥à¤¤à¤®à¥"},{iso_639_1:"sc",iso_639_2:"srd",iso_3166_1:"IT",flag:"\uD83C\uDDEE\uD83C\uDDF9",english_name:"Sardinian",
90name:"Sardu"},{iso_639_1:"sd",iso_639_2:"snd",iso_3166_1:"PK",flag:"\uD83C\uDDF5\uD83C\uDDF0",english_name:"Sindhi",name:"सिनà¥à¤§à¥"},{iso_639_1:"se",iso_639_2:"sme",iso_3166_1:"NO",flag:"\uD83C\uDDF3\uD83C\uDDF4",english_name:"Northern Sami",name:"Davvis\xe1megiella"},{iso_639_1:"sg",iso_639_2:"sag",iso_3166_1:"CF",flag:"\uD83C\uDDE8\uD83C\uDDEB",english_name:"Sango",name:"Y\xe2ng\xe2 t\xee s\xe4ng\xf6"},{iso_639_1:"sh",iso_639_2:"hbs",iso_3166_1:"RS",flag:"\uD83C\uDDF7\uD83C\uDDF8",english_name:"Serbo-Croatian",name:"Srpskohrvatski"},{iso_639_1:"si",iso_639_2:"sin",iso_3166_1:"LK",flag:"\uD83C\uDDF1\uD83C\uDDF0",english_name:"Sinhala; Sinhalese",name:"à·à·à¶à·à¶½"},{iso_639_1:"sk",iso_639_2:"slk",iso_3166_1:"SK",flag:"\uD83C\uDDF8\uD83C\uDDF0",flag_priority:!0,english_name:"Slovak",name:"SlovenÄina"},{iso_639_1:"sl",iso_639_2:"slv",iso_3166_1:"SI",flag:"\uD83C\uDDF8\uD83C\uDDEE",english_name:"Slovenian",name:"SlovenÅ¡Äina"},{iso_639_1:"sm",iso_639_2:"smo",iso_3166_1:"WS",flag:"\uD83C\uDDFC\uD83C\uDDF8",english_name:"Samoan",name:"Gagana fa'a Samoa"},{iso_639_1:"sn",iso_639_2:"sna",iso_3166_1:"ZW",flag:"\uD83C\uDDFF\uD83C\uDDFC",english_name:"Shona",name:"ChiShona"},{iso_639_1:"so",iso_639_2:"som",iso_3166_1:"SO",flag:"\uD83C\uDDF8\uD83C\uDDF4",english_name:"Somali",name:"Af Soomaali"},{iso_639_1:"sq",iso_639_2:"sqi",iso_3166_1:"AL",flag:"\uD83C\uDDE6\uD83C\uDDF1",english_name:"Albanian",
90name:"Shqip"},{iso_639_1:"sr",iso_639_2:"srp",iso_3166_1:"RS",flag:"\uD83C\uDDF7\uD83C\uDDF8",flag_priority:!0,english_name:"Serbian",name:"Srpski"},{iso_639_1:"ss",iso_639_2:"ssw",iso_3166_1:"SZ",flag:"\uD83C\uDDF8\uD83C\uDDFF",english_name:"Swati",name:"SiSwati"},{iso_639_1:"st",iso_639_2:"sot",iso_3166_1:"LS",flag:"\uD83C\uDDF1\uD83C\uDDF8",english_name:"Sotho, Southern",name:"Sesotho"},{iso_639_1:"su",iso_639_2:"sun",iso_3166_1:"ID",flag:"\uD83C\uDDEE\uD83C\uDDE9",english_name:"Sundanese",name:"Basa Sunda"},{iso_639_1:"sv",iso_639_2:"swe",iso_3166_1:"SE",flag:"\uD83C\uDDF8\uD83C\uDDEA",english_name:"Swedish",name:"Svenska"},{iso_639_1:"sw",iso_639_2:"swa",iso_3166_1:"KE",flag:"\uD83C\uDDF0\uD83C\uDDEA",english_name:"Swahili",name:"Kiswahili"},{iso_639_1:"ta",iso_639_2:"tam",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Tamil",name:"தமிழà¯"},{iso_639_1:"te",iso_639_2:"tel",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Telugu",name:"à°¤à±à°²à±à°à±"},{iso_639_1:"tg",iso_639_2:"tgk",iso_3166_1:"TJ",flag:"\uD83C\uDDF9\uD83C\uDDEF",english_name:"Tajik",name:"Ñоҷикӣ"},{iso_639_1:"th",iso_639_2:"tha",iso_3166_1:"TH",flag:"\uD83C\uDDF9\uD83C\uDDED",english_name:"Thai",name:"ภาษาà¹à¸à¸¢"},{iso_639_1:"ti",iso_639_2:"tir",iso_3166_1:"ER",flag:"\uD83C\uDDEA\uD83C\uDDF7",english_name:"Tigrinya",name:"áµááá"},{iso_639_1:"tk",iso_639_2:"tuk",iso_3166_1:"TM",flag:"\uD83C\uDDF9\uD83C\uDDF2",english_name:"Turkmen",name:"T\xfcrkmen"},{iso_639_1:"tl",iso_639_2:"tgl",iso_3166_1:"PH",flag:"\uD83C\uDDF5\uD83C\uDDED",english_name:"Tagalog",name:"Wikang Tagalog"},{iso_639_1:"tn",iso_639_2:"tsn",iso_3166_1:"BW",flag:"\uD83C\uDDE7\uD83C\uDDFC",english_name:"Tswana",name:"Setswana"},{iso_639_1:"to",iso_639_2:"ton",iso_3166_1:"TO",flag:"\uD83C\uDDF9\uD83C\uDDF4",english_name:"Tonga (Tonga Islands)",name:"Faka Tonga"},{iso_639_1:"tr",iso_639_2:"tur",iso_3166_1:"TR",flag:"\uD83C\uDDF9\uD83C\uDDF7",english_name:"Turkish",name:"T\xfcrk\xe7e"},{iso_639_1:"ts",iso_639_2:"tso",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Tsonga",name:"Xitsonga"},{iso_639_1:"tt",iso_639_2:"tat",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Tatar",name:"ТаÑÐ°Ñ Ñеле"},{iso_639_1:"tw",iso_639_2:"twi",iso_3166_1:"GH",flag:"\uD83C\uDDEC\uD83C\uDDED",english_name:"Twi",name:"Twi"},{iso_639_1:"ty",iso_639_2:"tah",iso_3166_1:"PF",flag:"\uD83C\uDDF5\uD83C\uDDEB",english_name:"Tahitian",name:"Reo Tahiti"},{iso_639_1:"ug",iso_639_2:"uig",iso_3166_1:"CN",flag:"\uD83C\uDDE8\uD83C\uDDF3",english_name:"Uighur; Uyghur",name:"UyÆ£urqÉ"}
90,{iso_639_1:"uk",iso_639_2:"ukr",iso_3166_1:"UA",flag:"\uD83C\uDDFA\uD83C\uDDE6",english_name:"Ukrainian",name:"УкÑаÑнÑÑкий"},{iso_639_1:"ur",iso_639_2:"urd",iso_3166_1:"PK",flag:"\uD83C\uDDF5\uD83C\uDDF0",english_name:"Urdu",name:"اردÙ"},{iso_639_1:"uz",iso_639_2:"uzb",iso_3166_1:"UZ",flag:"\uD83C\uDDFA\uD83C\uDDFF",english_name:"Uzbek",name:"OÊ»zbek"},{iso_639_1:"ve",iso_639_2:"ven",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Venda",name:"Tshivená¸a"},{iso_639_1:"vi",iso_639_2:"vie",iso_3166_1:"VN",flag:"\uD83C\uDDFB\uD83C\uDDF3",english_name:"Vietnamese",name:"Tiếng Viá»t"},{iso_639_1:"vo",iso_639_2:"vol",iso_3166_1:null,flag:"\uD83C\uDF10",english_name:"Volap\xfck",name:"Volap\xfck"},{iso_639_1:"wa",iso_639_2:"wln",iso_3166_1:"BE",flag:"\uD83C\uDDE7\uD83C\uDDEA",english_name:"Walloon",name:"Walon"},{iso_639_1:"wo",iso_639_2:"wol",iso_3166_1:"SN",flag:"\uD83C\uDDF8\uD83C\uDDF3",english_name:"Wolof",name:"Wolof"},{iso_639_1:"xh",iso_639_2:"xho",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Xhosa",name:"IsiXhosa"},{iso_639_1:"yi",iso_639_2:"yid",iso_3166_1:"IL",flag:"\uD83C\uDDEE\uD83C\uDDF1",english_name:"Yiddish",name:"××Ö´××ש"},{iso_639_1:"yo",iso_639_2:"yor",iso_3166_1:"NG",flag:"\uD83C\uDDF3\uD83C\uDDEC",english_name:"Yoruba",name:"\xc8d\xe8 Yor\xf9b\xe1"},{iso_639_1:"za",iso_639_2:"zha",iso_3166_1:"CN",flag:"\uD83C\uDDE8\uD83C\uDDF3",english_name:"Zhuang; Chuang",name:"Saɯ cueÅÆ
"},{iso_639_1:"zh",iso_639_2:"zho",iso_3166_1:"CN",flag:"\uD83C\uDDE8\uD83C\uDDF3",flag_priority:!0,english_name:"Chinese (Simplified)",name:"䏿 (ç®ä½)"},{iso_639_1:"zh",iso_639_2:"zho",iso_3166_1:"TW",flag:"\uD83C\uDDF9\uD83C\uDDFC",english_name:"Chinese (Traditional)",name:"䏿 (ç¹é«)"},{iso_639_1:"zh",iso_639_2:"zho",iso_3166_1:"HK",flag:"\uD83C\uDDED\uD83C\uDDF0",english_name:"Chinese (Hong Kong)",name:"䏿 (馿¸¯)"},{iso_639_1:"zh",iso_639_2:"zho",iso_3166_1:"SG",flag:"\uD83C\uDDF8\uD83C\uDDEC",english_name:"Chinese (Singapore)",name:"䏿 (æ°å å¡)"},{iso_639_1:"zu",iso_639_2:"zul",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Zulu",name:"IsiZulu"},{iso_639_1:"sw",iso_639_2:"swa",iso_3166_1:"TZ",flag:"\uD83C\uDDF9\uD83C\uDDFF",english_name:"Swahili (Tanzania)",name:"Kiswahili"},{iso_639_1:"fr",iso_639_2:"fra",iso_3166_1:"CA",flag:"\uD83C\uDDE8\uD83C\uDDE6",english_name:"French (Canada)",name:"Fran\xe7ais"},{iso_639_1:"fr",iso_639_2:"fra",iso_3166_1:"BE",flag:"\uD83C\uDDE7\uD83C\uDDEA",english_name:"French (Belgium)",name:"Fran\xe7ais"},{iso_639_1:"fr",iso_639_2:"fra",iso_3166_1:"CH",flag:"\uD83C\uDDE8\uD83C\uDDED",english_name:"French (Switzerland)",name:"Fran\xe7ais"},{iso_639_1:"de",iso_639_2:"deu",iso_3166_1:"AT",flag:"\uD83C\uDDE6\uD83C\uDDF9",english_name:"German (Austria)",name:"Deutsch"},{iso_639_1:"de",iso_639_2:"deu",iso_3166_1:"CH",flag:"\uD83C\uDDE8\uD83C\uDDED",english_name:"German (Switzerland)",name:"Deutsch"},{iso_639_1:"it",iso_639_2:"ita",iso_3166_1:"CH",flag:"\uD83C\uDDE8\uD83C\uDDED",english_name:"Italian (Switzerland)",name:"Italiano"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"MX",flag:"\uD83C\uDDF2\uD83C\uDDFD",english_name:"Spanish (Mexico)",internal_english_name:"Latino",name:"Espa\xf1ol"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"AR",flag:"\uD83C\uDDE6\uD83C\uDDF7",english_name:"Spanish (Argentina)",name:"Espa\xf1ol"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"CO",flag:"\uD83C\uDDE8\uD83C\uDDF4",english_name:"Spanish (Colombia)",name:"Espa\xf1ol"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"CL",flag:"\uD83C\uDDE8\uD83C\uDDF1",english_name:"Spanish (Chile)",name:"Espa\xf1ol"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"PE",flag:"\uD83C\uDDF5\uD83C\uDDEA",english_name:"Spanish (Peru)",name:"Espa\xf1ol"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"VE",flag:"\uD83C\uDDFB\uD83C\uDDEA",english_name:"Spanish (Venezuela)",name:"Espa\xf1ol"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"MA",flag:"\uD83C\uDDF2\uD83C\uDDE6",english_name:"Arabic (Morocco)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"DZ",flag:"\uD83C\uDDE9\uD83C\uDDFF",english_name:"Arabic (Algeria)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"TN",flag:"\uD83C\uDDF9\uD83C\uDDF3",english_name:"Arabic (Tunisia)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"LY",flag:"\uD83C\uDDF1\uD83C\uDDFE",english_name:"Arabic (Libya)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"JO",flag:"\uD83C\uDDEF\uD83C\uDDF4",english_name:"Arabic (Jordan)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"SY",flag:"\uD83C\uDDF8\uD83C\uDDFE",english_name:"Arabic (Syria)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"LB",flag:"\uD83C\uDDF1\uD83C\uDDE7",english_name:"Arabic (Lebanon)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"IQ",flag:"\uD83C\uDDEE\uD83C\uDDF6",english_name:"Arabic (Iraq)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"KW",flag:"\uD83C\uDDF0\uD83C\uDDFC",english_name:"Arabic (Kuwait)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"BH",flag:"\uD83C\uDDE7\uD83C\uDDED",english_name:"Arabic (Bahrain)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"QA",flag:"\uD83C\uDDF6\uD83C\uDDE6",english_name:"Arabic (Qatar)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"OM",flag:"\uD83C\uDDF4\uD83C\uDDF2",english_name:"Arabic (Oman)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"YE",flag:"\uD83C\uDDFE\uD83C\uDDEA",english_name:"Arabic (Yemen)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"SD",flag:"\uD83C\uDDF8\uD83C\uDDE9",english_name:"Arabic (Sudan)",name:"Ø§ÙØ¹Ø±Ø¨ÙØ©"},{iso_639_1:null,iso_639_2:"ace",iso_3166_1:"ID",flag:"\uD83C\uDDEE\uD83C\uDDE9",english_name:"Achinese",name:"Bahsa Ac\xe8h"},{iso_639_1:null,iso_639_2:"ach",iso_3166_1:"UG",flag:"\uD83C\uDDFA\uD83C\uDDEC",english_name:"Acoli",name:"Lwo"},{iso_639_1:null,iso_639_2:"ada",iso_3166_1:"GH",flag:"\uD83C\uDDEC\uD83C\uDDED",english_name:"Adangme",name:"Adangme"},{iso_639_1:null,iso_639_2:"ady",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Adyghe; Adygei",name:"ÐдÑгÑбзÑ"},{iso_639_1:null,iso_639_2:"afa",iso_3166_1:"ET",flag:"\uD83C\uDDEA\uD83C\uDDF9",english_name:"Afro-Asiatic languages",name:"Afro-Asiatic"},{iso_639_1:null,iso_639_2:"afh",iso_3166_1:"GH",flag:"\uD83C\uDDEC\uD83C\uDDED",english_name:"Afrihili",name:"Afrihili"},{iso_639_1:null,iso_639_2:"agq",iso_3166_1:"CM",flag:"\uD83C\uDDE8\uD83C\uDDF2",english_name:"Aghem",name:"Aghem"},{iso_639_1:null,iso_639_2:"ain",iso_3166_1:"JP",flag:"\uD83C\uDDEF\uD83C\uDDF5",english_name:"Ainu",n
90ame:"ã¢ã¤ã ã¤ã¿ã°"},{iso_639_1:null,iso_639_2:"akk",iso_3166_1:"IQ",flag:"\uD83C\uDDEE\uD83C\uDDF6",english_name:"Akkadian",name:"Akkadian"},{iso_639_1:null,iso_639_2:"ale",iso_3166_1:"US",flag:"\uD83C\uDDFA\uD83C\uDDF8",english_name:"Aleut",name:"Unangam Tunuu"},{iso_639_1:null,iso_639_2:"alt",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Southern Altai",name:"ÐлÑай Ñил"},{iso_639_1:null,iso_639_2:"ang",iso_3166_1:"GB",flag:"\uD83C\uDDEC\uD83C\uDDE7",english_name:"English, Old (ca.450-1100)",name:"Englisc"},{iso_639_1:null,iso_639_2:"anp",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Angika",name:"à¤
à¤à¤à¤¿à¤à¤¾"},{iso_639_1:null,iso_639_2:"arc",iso_3166_1:"SY",flag:"\uD83C\uDDF8\uD83C\uDDFE",english_name:"Aramaic",name:"ÜܪܡÜÜ"},{iso_639_1:null,iso_639_2:"arn",iso_3166_1:"CL",flag:"\uD83C\uDDE8\uD83C\uDDF1",english_name:"Mapudungun; Mapuche",name:"Mapudungun"},{iso_639_1:null,iso_639_2:"arp",iso_3166_1:"US",flag:"\uD83C\uDDFA\uD83C\uDDF8",english_name:"Arapaho",name:"Hin\xf3noʼeit\xed\xedt"},{iso_639_1:null,iso_639_2:"arw",iso_3166_1:"GY",flag:"\uD83C\uDDEC\uD83C\uDDFE",english_name:"Arawak",name:"Arawak"},{iso_639_1:null,iso_639_2:"ast",iso_3166_1:"ES",flag:"\uD83C\uDDEA\uD83C\uDDF8",english_name:"Asturian; Bable; Leonese; Asturleonese",name:"Asturianu"}];function vw(e){return e.internal_english_name?e.internal_english_name:e.english_name.split(/;|\(/)[0].trim()}let vN={fre:"fra",ger:"deu",cze:"ces",slo:"slk",rum:"ron",dut:"nld",gre:"ell",alb:"sqi",baq:"eus",bur:"mya",chi:"zho",per:"fas",arm:"hye",geo:"kat",ice:"isl",mac:"mk
90d",mao:"mri",may:"msa",tib:"bod",wel:"cym"},vk=new Map(aF.map(e=>[e.toLowerCase(),e])),vS=new Map;for(let e of vj)for(let t of[e.internal_english_name,e.english_name,...e.english_name.split(";").map(e=>e.split("(")[0])]){let s=null==t?void 0:t.trim().toLowerCase();if(!s)continue;let a=vS.get(s);a&&(a.flag_priority||!e.flag_priority)||vS.set(s,e)}let vC={"latin america":"419",latam:"419",la:"419"},v_=/^(.*\S)\s*\(([^()]+)\)$/,vA=new Map;function vR(e){if(!e)return;let t=vw(e);return aF.includes(t)?t:void 0}function vT(e){let t,s=vI(vN[t=e.toLowerCase().trim()]??t).toLowerCase().split("-"),a=vj.filter(e=>{var t,a,r,n;return 2===s.length?(null==(r=e.iso_639_1)?void 0:r.toLowerCase())===s[0]&&(null==(n=e.iso_3166_1)?void 0:n.toLowerCase())===s[1]:(null==(t=e.iso_639_1)?void 0:t.toLowerCase())===s[0]||(null==(a=e.iso_639_2)?void 0:a.toLowerCase())===s[0]});return a.find(e=>e.flag_priority)??a[0]}function vI(e){switch(e.toLowerCase()){case"zh-tw":case"zh-hans":return"zh";case"es-419":return"es-MX";default:return e}}function vE(e){if("string"!=typeof e)return;if(e.length>64)return vM(e);let t=vA.get(e);if(void 0!==t||vA.has(e))return t;let s=vM(e);return vA.size>=1e3&&vA.clear(),vA.set(e,s),s}function vM(e){let t=e.trim();if(!(t.length>64))for(;t;){var s,a;let e=vk.get(t.toLowerCase());if(e)return e;let r=vR(vS.get(t.toLowerCase()));if(r)return r;let n=vR(vT(t));if(n)return n;let l=v_.exec(t);if(!l)break;let i=l[1].trim(),o=l[2].trim(),d=(null==(s=vS.get(i.toLowerCase()))?void 0:s.iso_639_1)??(null==(a=vT(i))?void 0:a.iso_639_1),c=vC[o.toLowerCase()]??(/^[a-z]{2}$/i.test(o)?o:void 0);if(d&&c){let e=vR(vT(`${d}-${c}`));if(e)return e}t=i}}let vP=new Set(["Latino","Portuguese (Brazil)"].map(e=>e.toLowerCase()));function v$(e){let t=vD.get(e);if(void 0!==t||vD.has(e))return t;let s=function(e){var t,s,a;let r=vj.filter(t=>t.english_name.split(";").some(t=>t.split("(")[0].trim().toLowerCase()===e.toLowerCase())||t.internal_english_name&&t.internal_english_name.toLowerCase()===e.toLowerCase()||t.name.toLowerCase()===e.toLowerCase());if(0===r.length)return;let n=r.find(e=>e.flag_priority)??r[0];return vP.has(vw(n).toLowerCase())?`${null==(s=n.iso_639_1)?void 0:s.toUpperCase()}-${null==(a=n.iso_3166_1)?void 0:a.toUpperCase()}`:null==(t=n.iso_639_1)?void 0:t.toUpperCase()}(e);return vD.size>=vL&&vD.clear(),vD.set(e,s),s}let vD=new Map,vL=1e3,vO={multi:"\uD83C\uDF0E",english:"\uD83C\uDDEC\uD83C\uDDE7",japanese:"\uD83C\uDDEF\uD83C\uDDF5",chinese:"\uD83C\uDDE8\uD83C\uDDF3",russian:"\uD83C\uDDF7\uD83C\uDDFA",arabic:"\uD83C\uDDF8\uD83C\uDDE6",portuguese:"\uD83C\uDDF5\uD83C\uDDF9","portuguese (brazil)":"\uD83C\uDDE7\uD83C\uDDF7",spanish:"\uD83C\uDDEA\uD83C\uDDF8",french:"\uD83C\uDDEB\uD83C\uDDF7",german:"\uD83C\uDDE9\uD83C\uDDEA",italian:"\uD83C\uDDEE\uD83C\uDDF9",korean:"\uD83C\uDDF0\uD83C\uDDF7",hindi:"\uD83C\uDDEE\uD83C\uDDF3",bengali:"\uD83C\uDDE7\uD83C\uDDE9",punjabi:"\uD83C\uDDF5\uD83C\uDDF0",marathi:"\uD83C\uDDEE\uD83C\uDDF3",gujarati:"\uD83C\uDDEE\uD83C\uDDF3",tamil:"\uD83C\uDDEE\uD83C\uDDF3",telugu:"\uD83C\uDDEE\uD83C\uDDF3",kannada:"\uD83C\uDDEE\uD83C\uDDF3",malayalam:"\uD83C\uDDEE\uD83C\uDDF3",thai:"\uD83C\uDDF9\uD83C\uDDED",vietnamese:"\uD83C\uDDFB\uD83C\uDDF3",indonesian:"\uD83C\uDDEE\uD83C\uDDE9",turkish:"\uD83C\uDDF9\uD83C\uDDF7",hebrew:"\uD83C\uDDEE\uD83C\uDDF1",persian:"\uD83C\uDDEE\uD83C\uDDF7",ukrainian:"\uD83C\uDDFA\uD83C\uDDE6",greek:"\uD83C\uDDEC\uD83C\uDDF7",lithuanian:"\uD83C\uDDF1\uD83C\uDDF9",latvian:"\uD83C\uDDF1\uD83C\uDDFB",estonian:"\uD83C\uDDEA\uD83C\uDDEA",polish:"\uD83C\uDDF5\uD83C\uDDF1",czech:"\uD83C\uDDE8\uD83C\uDDFF",slovak:"\uD83C\uDDF8\uD83C\uDDF0",hungarian:"\uD83C\uDDED\uD83C\uDDFA",romanian:"\uD83C\uDDF7\uD83C\uDDF4",bulgarian:"\uD83C\uDDE7\uD83C\uDDEC",serbian:"\uD83C\uDDF7\uD83C\uDDF8",croatian:"\uD83C\uDDED\uD83C\uDDF7",slovenian:"\uD83C\uDDF8\uD83C\uDDEE",dutch:"\uD83C\uDDF3\uD83C\uDDF1",danish:"\uD83C\uDDE9\uD83C\uDDF0",finnish:"\uD83C\uDDEB\uD83C\uDDEE",swedish:"\uD83C\uDDF8\uD83C\uDDEA",norwegian:"\uD83C\uDDF3\uD83C\uDDF4",malay:"\uD83C\uDDF2\uD83C\uDDFE",latino:"\uD83D\uDC83\uD83C\uDFFB",Latino:"\uD83C\uDDF2\uD83C\uDDFD"};function vU(e){return vO[e.toLowerCase()]}let vF=/^(!?)\s*([A-Za-z]+)\s*(?:([=~])(.*))?$/,vz=/^\{\s*([A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*)\s*\}$/;function vV(e){let t=e.map(vq);
90return(e,s)=>t.every(t=>t(e,s))}function vq(e){let t=vF.exec(e.trim());if(!t)throw Error(`invalid condition '${e}'`);let[,s,a,r,n]=t,l="!"===s;if(!r)return e=>!!e[a]!==l;let i=n.split("|").map(e=>e.trim()),o=i.map(e=>{var t;return null==(t=vz.exec(e))?void 0:t[1]}).filter(e=>void 0!==e),d=i.filter(e=>!vz.test(e)).map(e=>e.toLowerCase()).filter(Boolean),c="="===r?(e,t)=>e.includes(t):(e,t)=>e.some(e=>t.includes(e));return(e,t)=>{let s=o.length?[...d,...o.flatMap(e=>((null==t?void 0:t(e))??[]).map(e=>e.toLowerCase()))]:d,r=e[a];return(null!=r&&c(s,String(r).toLowerCase()))!==l}}let vB=/[\u0011\u0012]/g;function vK(e){return e.includes("\x11")||e.includes("\x12")}function vH(e){return vK(e)?e.replace(vB,""):e}function vW(e){return e.replaceAll("{tools.newLine}","\x11").replaceAll("{tools.removeLine}","\x12")}var vG=s(8963).Buffer;let vY=e=>{let t=vE(e)??e;return v$(t)||t.toUpperCase()},vJ=e=>vU(vE(e)??e)??"",vZ=(e,t)=>[...new Set(e.map(e=>t(String(e))).filter(Boolean))],vQ={upper:e=>e.toUpperCase(),lower:e=>e.toLowerCase(),trim:e=>e.trim(),title:e=>e.split(" ").map(e=>e.toLowerCase()).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),length:e=>e.length.toString(),reverse:e=>e.split("").reverse().join(""),base64:e=>vG.from(e,"utf8").toString("base64"),string:e=>e,smallcaps:e=>vv(e),subscript:e=>v2(e,vX,v0),superscript:e=>v2(e,vX,v1),languagecode:vY,languageemoji:vJ},vX="0123456789+-=()",v0="ââââââ
âââââââââ",v1="â°\xb9\xb2\xb3â´âµâ¶â·â¸â¹âºâ»â¼â½â¾";function v2(e,t,s){let a=new Map,r=[...t],n=[...s];for(let e=0;e<r.length&&e<n.length;e++)a.set(r[e],n[e]);return[...e].map(e=>a.get(e)??e).join("")}function v3(e){return Array.isArray(e)&&"object"==typeof e[0]&&null!==e[0]}let v5=new Set(["length","reverse"]),v4=(e,t)=>e.length>0?String(e[t]):"",v6=e=>t=>[...t].sort((t,s)=>{let a="number"==typeof t&&"number"==typeof s?t-s:String(t).localeCompare(String(s),void 0,{numeric:!0});return e?a:-a}),v9=e=>t=>{let s=Math.floor(t/20),a=+(t%20>=10);return"â
".repeat(s)+"⯪".repeat(a)+(e?"â".repeat(5-s-a):"")},v8={join:e=>e.join(", "),length:e=>e.length.toString(),first:e=>v4(e,0),last:e=>v4(e,e.length-1),random:e=>v4(e,Math.floor(Math.random()*e.length)),sort:v6(!0),rsort:v6(!1),lsort:e=>[...e].sort(),reverse:e=>[...e].reverse(),unique:e=>{let t=new Set;return e.filter(e=>{let s=String(e).toLowerCase();return!t.has(s)&&(t.add(s),!0)})},languagecode:e=>vZ(e,vY),languageemoji:e=>vZ(e,vJ),string:e=>e.toString()},v7={comma:e=>e.toLocaleString(),hex:e=>e.toString(16),octal:e=>e.toString(8),binary:e=>e.toString(2),bytes:e=>vu(e,1e3),sbytes:e=>vm(e,1e3),sbytes10:e=>vm(e,1e3),sbytes2:e=>vm(e,1024),rbytes:e=>vu(e,1e3,!0),bytes10:e=>vu(e,1e3),rbytes10:e=>vu(e,1e3,!0),bytes2:e=>vu(e,1024),rbytes2:e=>vu(e,1024,!0),bitrate:e=>vh(e),rbitrate:e=>vh(e,!0),sbitrate:e=>(function(e){let t,s;if(!Number.isFinite(e)||e<=0)return"0 bps";let a=["bps","Kbps","Mbps","Gbps","Tbps"],r=Math.min(a.length-1,Math.max(0,Math.floor(Math.log(e)/Math.log(1e3)))),n=e/Math.pow(1e3,r),l=Math.floor(n);return s=l>=100?(t=Math.round(n)).toString():l>=10?(t=parseFloat(n.toFixed(1)))%1==0?t.toFixed(0):t.toFixed(1):(t=parseFloat(n.toFixed(2))).toString(),`${s} ${a[r]}`})(e),string:e=>e.toString(),time:e=>{let t,s,a,r,n;return a=Math.floor((s=Math.floor((t=Math.floor(vg(e)/1e3))/60))/60),r=t%60,n=s%60,a>0?`${a}h:${n}m:${r}s`:r>0?`${n}m:${r}s`:`${n}m`},star:v9(!1),pstar:v9(!0)},ye={string:e=>String(e)},yt={istrue:e=>!0===e,isfalse:e=>!1===e,exists:e=>null!=e&&("string"==typeof e?/\S/.test(e):!Array.isArray(e)||e.length>0)},ys={$:(e,t)=>"string"==typeof e?e.startsWith(t):(null==e?void 0:e[0])===t,"^":(e,t)=>"string"==typeof e?e.endsWith(t):(null==e?void 0:e[e.length-1])===t,"~":(e,t)=>e.includes(t),"=":(e,t)=>e===t,">=":(e,t)=>
90e>=t,">":(e,t)=>e>t,"<=":(e,t)=>e<=t,"<":(e,t)=>e<t},ya=Object.keys(vQ),yr=Object.keys(v7),yn=Object.keys(v8),yl=Object.keys(ye),yi=Object.keys(yt),yo=[...ya,...yl,...yr,...yn,...yi],yd=Object.keys(ys).sort((e,t)=>t.length-e.length);function yc(e){let t,s=[],a=/"([^"]*)"|'([^']*)'/g;for(;null!==(t=a.exec(e));)s.push(t[1]??t[2]??"");return s}function yu(e){let t,s=e.replace(/"[^"]*"|'[^']*'/g,""),a=/\{\s*([A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*)\s*\}/g,r=new Set;for(;null!==(t=a.exec(s));)r.add(t[1]);return[...r]}function ym(e,t,s,a){let r=!(arguments.length>4)||void 0===arguments[4]||arguments[4];if(!t.length)return e;let n=[...e];for(let e of t)for(let t of a.resolveValues(e,s)??[])n.push(r?t.toLowerCase():t);return n}function yh(e){let t=e[0];return e.length>=2&&("'"===t||'"'===t)&&e.endsWith(t)?e.slice(1,-1):void 0}let yp=e=>"string"==typeof e||Array.isArray(e)&&!v3(e);function yx(e,t,s){if("string"==typeof e){if(!t)return e;let a=s.length-t.length;if((a<=0?e.length:e.length+Math.floor(e.length/t.length)*a)<=8e3)return e.replaceAll(t,s);let r="",n=0;for(;r.length<8e3;){let a=e.indexOf(t,n);if(-1===a){r+=e.slice(n);break}r+=e.slice(n,a)+s,n=a+t.length}return r.length>8e3?r.slice(0,8e3):r}let a=t.toLowerCase();return e.map(e=>String(e).toLowerCase()===a?s:e)}let yg={and:(e,t)=>e&&t,or:(e,t)=>e||t,xor:(e,t)=>
90(e||t)&&!(e&&t),neq:(e,t)=>e!==t,equal:(e,t)=>e===t,left:e=>e,right:(e,t)=>t},yf=Object.keys(yg),yb=()=>yf,yv=[...yo].map(e=>e.toLowerCase()).sort((e,t)=>t.length-e.length),yy=[["replace","replaceArgs"],["remove","loose"],["keep","loose"],["join","quoted"],["truncate","digits"],["slice","digitsOrPair"],["time","quoted"],["date","quoted"],["default","quoted"],["in","loose"],["translate","quotedPair"],["trim","quoted"],["where","quotedList"],["pluck","quoted"],["each","template"]],yj=/^\s*[A-Za-z_][A-Za-z0-9_]*\s*\.\s*[A-Za-z_][A-Za-z0-9_]*/,yw=new Set(["unknown-field","unknown-modifier","modifier-arguments"]),yN=new Set(["where","in","keep","remove"]);class yk{get atEnd(){return this.pos>=this.input.length}peek(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.input[this.pos+e]}eat(e){return this.input.substr(this.pos,e.length).toLowerCase()===e.toLowerCase()&&(this.pos+=e.length,!0)}startsWith(e){return this.input.substr(this.pos,e.length).toLowerCase()===e.toLowerCase()}slice(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.pos;return this.input.slice(e,t)}constructor(e,t=0){(0,et._)(this,"input",void 0),(0,et._)(this,"pos",void 0),this.input=e,this.pos=t}}function yS(e){return void 0!==e&&/[A-Za-z0-9_]/.test(e)}function yC(e){for(;!e.atEnd;){let t=e.peek();if("}"===t||"["===t||"]"===t||":"===t&&":"===e.peek(1))break;e.pos+=1}}function y_(e){let t=e.peek();if("'"!==t&&'"'!==t)return!1;for(e.pos+=1;!e.atEnd;){if(e.peek()===t){let t=e.peek(1);if(void 0===t||","===t||")"===t||/\s/.test(t))return e.pos+=1,!0}e.pos+=1}return!1}function yA(e,t){let s=e[t];if('"'!==s&&"'"!==s)return;let a="",r=[],n=0,l=t+1;for(;l<e.length;){let t=e[l];if("\\"===t&&e[l+1]===s){r.push(l),a+=s,l+=2;continue}if("{"===t)n+=1;else if("}"===t)n=Math.max(0,n-1);else if(t===s&&0===n)return{content:a,offsets:r,end:l+1};r.push(l),a+=t,l+=1}}function yR(e){return t=>t>=0&&t<e.offsets.length?e.offsets[t]:e.end-1}function yT(e){if(!/^each\(/i.test(e))return;let t=5;for(;/\s/.test(e[t]??"");)t+=1;return yA(e,t)}function yI(e){let t=e.pos;for(;void 0!==e.peek()&&/\d/.test(e.peek());)e.pos+=1;return e.pos>t}function yE(e){for(;void 0!==e.peek()&&/\s/.test(e.peek());)e.pos+=1}let yM=/^\{\s*[A-Za-z_][A-Za-z0-9_]*\s*\.\s*[A-Za-z_][A-Za-z0-9_]*\s*\}$/;function yP(e,t){if(!e.eat("("))return!1;switch(t){case"quoted":if(!y_(e))return!1;break;case"quotedPair":if(!y_(e)||(yE(e),!e.eat(","))||(yE(e),!y_(e)))return!1;break;case"quotedList":do{if(yE(e),!y_(e))return!1;yE(e)}while(e.eat(","));break;case"template":{yE(e);let t=yA(e.input,e.pos);if(!t)return!1;e.pos=t.end,yE(e);break}case"replaceArgs":if("{"===e.peek()){for(;!e.atEnd&&"}"!==e.peek();)e.pos+=1;if(!e.eat("}"))return!1}else if(!y_(e))return!1;if(yE(e),!e.eat(",")||(yE(e),!y_(e)))return!1;break;case"digits":if(!yI(e))return!1;break;case"digitsOrPair":if(yE(e),!yI(e))return!1;if(yE(e),e.eat(",")){if(yE(e),!yI(e))return!1;yE(e)}break;case"loose":return function(e){let t=-1;for(;!e.atEnd;){let s=e.peek();if("'"===s||'"'===s){let t=e.input.indexOf(s,e.pos+1);if(-1!==t){e.pos=t+1;continue}}if("{"===s){let t=e.input.indexOf("}",e.pos),s=-1===t?"":e.slice(e.pos,t+1);if(!yM.test(s))break;e.pos=t+1;continue}if("}"===s||"["===s||"]"===s||":"===s&&":"===e.peek(1))break;")"===s&&(t=e.pos),e.pos+=1}return -1!==t&&(e.pos=t,!0)}(e)&&e.eat(")")}return e.eat(")")}function y$(e){let t=e.pos;for(let[s,a]of yy)if(e.startsWith(`${s}(`)){if(e.pos+=s.length,yP(e,a))return e.slice(t);e.pos=t;break}for(let s of yd)if(e.startsWith(s))return e.pos+=s.length,yC(e),e.slice(t);for(let s of yv)if(e.startsWith(s)&&!yS(e.peek(s.length)))return e.pos+=s.length,e.slice(t);e.pos=t}function yD(e){let t;if("'"===e.peek()||'"'===e.peek()){let s=e.peek(),a=e.pos;e.pos+=1;let r=e.pos;for(;!e.atEnd&&e.peek()!==s;)e.pos+=1;if(e.atEnd){e.pos=a;return}let n=e.slice(r);e.pos+=1,t={section:"",property:"",literal:n}}else t=function(e){let t=e.pos;for(;yS(e.peek());)e.pos+=1;let s=e.slice(t);if(!s||"."!==e.peek()){e.pos=t;return}e.pos+=1;let a=e.pos;for(;yS(e.peek());)e.pos+=1;let r=e.slice(a);if(!r){e.pos=t;return}let n=vi(s,r);if(!n){e.pos=t;return}return[s,r]=n,{section:s,property:r}}(e);if(!t)return;let s=[];for(;e.startsWith("::");){let t=e.pos;if(e.pos+=2,yb().some(t=>e.startsWith(`${t}::`))){e.pos=t;break}let a=y$(e);if(void 0===a){e.pos=t;break}s.push(a)}return{...t,modifiers:s}}function yL(e,t){let s,a,r=e.pos,n=s=>{null==t||t(s,e.pos),e.pos=r};if(!e.eat("["))return n("no-open");let l=()=>{if(!e.eat('"'))return;let t="",s=0;for(;!e.atEnd;){let a=e.peek();if("\\"===a&&'"'===e.peek(1)){t+='"',e.pos+=2;continue}if("{"===a)s+=1;else if("}"===a)s=Math.max(0,s-1);else if('"'===a&&0===s)return e.pos+=1,t;t+=a,e.pos+=1}},i=e.pos+1,o=l();if(void 0===o)return n("true-branch");if(!e.eat("||"))return n("missing-or");let d=e.pos+1,c=l();return void 0===c?n("false-branch"):e.startsWith("||")&&(e.pos+=2,a=e.pos+1,void 0===(s=l()))?n("absent-branch"):e.eat("]")?{trueTemplate:o,falseTemplate:c,trueStart:i,falseStart:d,...void 0!==s?{absentTemplate:s,absentStart:a}:{}}:n("missing-close")}function yO(e){let t=e.pos,s=()=>{e.pos=t};if(!e.eat("{"))return s();yE(e);let a=[],r=[],n=yD(e);if(!n)return s();for(a.push(n);e.startsWith("::");){let t=e.pos;e.pos+=2;let n=yb().find(t=>e.startsWith(`${t}::`));if(!n){e.pos=t;break}e.pos+=n.length+2;let l=yD(e);if(!l)return s();r.push(n.toLowerCase()),a.push(l)}let l="["===e.peek()?yL(e):void 0;return(yE(e),e.eat("}"))?{kind:"expression",source:e.slice(t),operands:a,comparators:r,start:t,end:e.pos,...l?{check:l}:{}}:s()}function yU(e){let t=new yk(e),s=[],a=[],r=0,n=0,l=t=>{if(t>r){let a={kind:"raw",text:e.slice(r,t)};a.start=r,a.end=t,s.push(a)}};for(;!t.atEnd;){if("{"!==t.peek()){t.pos+=1;continue}let i=t.pos;if(t.startsWith("{?")){let n=function(e){let t=e.pos;if(!e.eat("{?"))return;let s=e.pos,a=1;for(;!e.atEnd;){if(e.startsWith("{?")){a+=1,e.pos+=2;continue}if(e.startsWith("?}")){if(0==(a-=1)){let t=e.slice(s);return e.pos+=2,t}e.pos+=2;continue}e.pos+=1}e.pos=t}(t);if(void 0!==n){l(i);let e=yU(n),o=i+2;a.push(...e.diagnostics.map(e=>({...e,index:e.index+o}))),function e(t,s){for(let a of t)if(void 0!==a.start&&(a.start+=s),void 0!==a.end&&(a.end+=s),"group"===a.kind&&e(a.nodes,s),"expression"===a.kind&&a.check){let e=a.check;void 0!==e.trueStart&&(e.trueStart+=s),void 0!==e.falseStart&&(e.falseStart+=s),void 0!==e.absentStart&&(e.absentStart+=s)}}(e.nodes,o),s.push({kind:"group",nodes:e.nodes,start:i,end:t.pos}),r=t.pos;continue}a.length<25&&a.push({index:i,message:"unterminated group: no matching `?}`",source:e.slice(i,i+2),category:"unterminated-group"})}let o=function(e){let t=e.pos;for(let s of["newLine","removeLine"]){if(e.eat(`{tools.${s}}`))return{kind:"tool",tool:s};e.pos=t}}(t)??yO(t);if(!o){let o=e.indexOf("}",i),d=-1===o?"":e.slice(i+1,o);if(a.length<25){let t=function(e,t){let{end:s,terminated:a}=yz(e,t),r=e.slice(t,a?s+1:s),n=a?r.slice(1,-1):r.slice(1);if(!yj.test(n))return;let l=(e,s,a)=>({index:t,message:s,source:r,category:e,...a?{suggestion:a}:{}}),i=e=>{let t=e.toLowerCase(),s=yy.find(e=>{let[s]=e;return s===t});return l("modifier-arguments",s?`modifier \`${e}
90\` has invalid arguments; expected \`${t}${yF[s[1]]}\``:`modifier \`${e}\` takes no arguments`)},o=new yk(r);o.eat("{"),yE(o);let d=()=>{let e=o.pos;for(;yS(o.peek());)o.pos+=1;let t=o.slice(e);if(!t||"."!==o.peek()){o.pos=e;return}o.pos+=1;let s=o.pos;for(;yS(o.peek());)o.pos+=1;let a=o.slice(s);if(!a||vi(t,a))return;let r=vc(t,a),n=r.length?` â did you mean \`${r.join("` or `")}\`?`:"";return l("unknown-field",`unknown field \`${t}.${a}\`${n}`,r[0])},c=()=>{for(;o.startsWith("::");){let e=o.pos;if(o.pos+=2,yb().some(e=>o.startsWith(`${e}::`))){o.pos=e;break}let t=o.pos;if(y$(o)){if("("===o.peek())return i(o.slice(t));continue}if(yd.some(e=>o.startsWith(e))){o.pos=e;break}let s=o.pos;for(;yS(o.peek());)o.pos+=1;let a=o.slice(s);if(!a)break;if(yV().includes(a.toLowerCase()))return i(a);let r=vd(a.toLowerCase(),yV())[0];return l("unknown-modifier",`unknown modifier \`${a}\`${r?` â did you mean \`${r}\`?`:""}`)}};for(;;){let e=d();if(e)return e;let t=c();if(t)return t;if(!o.startsWith("::"))break;let s=o.pos;o.pos+=2;let a=yb().find(e=>o.startsWith(`${e}::`));if(!a){o.pos=s;break}o.pos+=a.length+2}if("["===o.peek()){let e;if(yL(o,(t,s)=>{e??(e={reason:t,at:s})}),e){let t=function(e,t,s){if("no-open"!==t)return"missing-close"===t?"conditional is missing its closing `]`":"missing-or"===t?"conditional branches must be separated by `||`":s>=e.length?'unterminated conditional branch: a nested `{` is missing its `}`, or the branch is missing its closing `"`':"\\"===e[s]&&'"'===e[s+1]?'conditional branch starts with an escaped quote `\\"` â escapes only apply one nesting level deeper':'conditional branch must start with `"`'}(r,e.reason,e.at);if(t)return l("conditional",t)}}return a?l("unparseable",`unparseable expression: {${n}}`):l("unterminated","unterminated expression: no closing `}`")}(e,i),s=i<n;t&&(!s||yw.has(t.category))&&a.push(t)}if(n=Math.max(n,yz(e,i).end),!d.includes("{")&&yj.test(d)){l(i),s.push({kind:"raw",text:`{invalid_expression(${d.trim()})}`,start:i,end:o+1}),t.pos=o+1,r=t.pos;continue}t.pos=i+1;continue}l(i),void 0===o.start&&(o.start=i),void 0===o.end&&(o.end=t.pos),s.push(o),r=t.pos}return l(e.length),{nodes:s,diagnostics:a}}let yF={quoted:"('text')",quotedPair:"('from', 'to')",quotedList:"('forced', 'lang=English')",replaceArgs:"('find', 'replaceWith')",digits:"(3)",digitsOrPair:"(0, 3)",loose:"('a', 'b')",template:'("{track.lang}")'};function yz(e,t){let s=0,a=Math.min(e.length,t+4e3);for(let r=t;r<a;r++){let t=e[r];if("{"===t)s+=1;else if("}"===t&&0==(s-=1))return{end:r,terminated:!0}}return{end:a,terminated:!1}}function yV(){return[...new Set([...yv,...yy.map(e=>{let[t]=e;return t})])]}let yq=e=>e;function yB(e,t,s,a,r,n){if(a<=s)return;let l=t(s),i=t(a-1)+1;i>l&&e.push({start:l,end:i,kind:r,depth:n})}function yK(e,t,s,a,r,n){let l=t,i=t,o=e=>yB(n,a,i,e,"text",r);for(;l<s;){if("{"!==e[l]){l+=1;continue}let t=l,d=function(e,t,s){for(let a of["{tools.newline}","{tools.removeline}"]){let r=t+a.length;if(r<=s&&e.slice(t,r).toLowerCase()===a)return r}}(e,t,s);if(void 0!==d){o(t),yB(n,a,t,d,"tool",r),i=l=d;continue}if(e.startsWith("{?",t)){let d=function(e,t,s){let a=t+2,r=1;for(;a<s;){if(e.startsWith("{?",a)){r+=1,a+=2;continue}if(e.startsWith("?}",a)){if(0==(r-=1))return{bodyEnd:a,end:a+2};a+=2;continue}a+=1}}(e,t,s);if(void 0!==d){o(t),yB(n,a,t,t+2,"group-brace",r),yK(e,t+2,d.bodyEnd,a,r+1,n),yB(n,a,d.bodyEnd,d.end,"group-brace",r),i=l=d.end;continue}}let c=new yk(e,t);if(yO(c)&&c.pos<=s){o(t),function(e,t,s,a,r,n){let l=new yk(e,t+1);for(yB(n,a,t,t+1,"brace",r),yE(l),yH(l,s,a,r,n);l.pos<s&&l.startsWith("::");){let e=l.pos;l.pos+=2;let t=yb().find(e=>l.startsWith(`${e}::`));if(!t){l.pos=e;break}let i=e+2;yB(n,a,e,i,"separator",r),yB(n,a,i,i+t.length,"comparator",r),yB(n,a,i+t.length,i+t.length+2,"separator",r),l.pos=i+t.length+2,yH(l,s,a,r,n)}l.pos<s&&"["===l.peek()&&function(e,t,s,a,r){yB(r,s,e.pos,e.pos+1,"bracket",a),e.pos+=1;for(let n=0;n<3&&(function(e,t,s,a,r){if('"'!==e.peek())return;yB(r,s,e.pos,e.pos+1,"quote",a),e.pos+=1;let n="",l=[],i=0;for(;e.pos<t;){let t=e.peek();if("\\"===t&&'"'===e.peek(1)){l.push(e.pos),n+='"',e.pos+=2;continue}if("{"===t)i+=1;else if("}"===t)i=Math.max(0,i-1);else if('"'===t&&0===i)break;l.push(e.pos),n+=t,e.pos+=1}let o=e.pos;yK(n,0,n.length,e=>s(e>=0&&e<l.length?l[e]:o),a+1,r),'"'===e.peek()&&(yB(r,s,o,o+1,"quote",a),e.pos+=1)}(e,t,s,a,r),e.startsWith("||"));n++)yB(r,s,e.pos,e.pos+2,"pipe",a),e.pos+=2;"]"===e.peek()&&(yB(r,s,e.pos,e.pos+1,"bracket",a),e.pos+=1)}(l,s,a,r,n),"}"===e[s-1]&&yB(n,a,s-1,s,"brace",r)}(e,t,c.pos,a,r,n),i=l=c.pos;continue}o(t);let u=yz(e,t),m=Math.min(u.terminated?u.end+1:u.end,s);m>
90t?(yB(n,a,t,m,"invalid",r),l=m):l=t+1,i=l}o(s)}function yH(e,t,s,a,r){let n=e.peek();if("'"===n||'"'===n){let l=e.pos;for(e.pos+=1;e.pos<t&&e.peek()!==n;)e.pos+=1;e.peek()===n&&(e.pos+=1),yB(r,s,l,e.pos,"literal",a)}else{let t=e.pos;for(;yS(e.peek());)e.pos+=1;if(yB(r,s,t,e.pos,"section",a),"."===e.peek()){yB(r,s,e.pos,e.pos+1,"dot",a),e.pos+=1;let t=e.pos;for(;yS(e.peek());)e.pos+=1;yB(r,s,t,e.pos,"property",a)}}for(;e.pos<t&&e.startsWith("::");){let t=e.pos;if(e.pos+=2,yb().some(t=>e.startsWith(`${t}::`))){e.pos=t;break}yB(r,s,t,t+2,"separator",a);let n=e.pos;if(function(e,t,s,a){let r=e.pos;for(let[n,l]of yy){if(!e.startsWith(`${n}(`))continue;let i=r+n.length;e.pos=i;let o=e.pos;if(yP(e,l)){yB(a,t,r,i,"modifier",s),"template"===l?function(e,t,s,a,r,n){let l=t+1;for(;/\s/.test(e[l]??"");)l+=1;let i=yA(e,l);if(!i)return yB(n,a,t,s,"call-args",r);let o=yR(i);yB(n,a,t,l,"call-args",r),yB(n,a,l,l+1,"quote",r),yK(i.content,0,i.content.length,e=>a(o(e)),r+1,n),yB(n,a,i.end-1,i.end,"quote",r),yB(n,a,i.end,s,"call-args",r)}(e.input,o,e.pos,t,s,a):yB(a,t,o,e.pos,"call-args",s);return}e.pos=r;break}for(let n of yd){if(!e.startsWith(n))continue;let l=r+n.length;yB(a,t,r,l,"prefix-op",s),e.pos=l;let i=e.pos;yC(e),yB(a,t,i,e.pos,"call-args",s);return}for(let n of yv)if(e.startsWith(n)&&!yS(e.peek(n.length))){yB(a,t,r,r+n.length,"modifier",s),e.pos=r+n.length;return}}(e,s,a,r),e.pos<=n)break}}let yW=8e3,yG=256;function yY(e,t){if(yW<=0)return"";let s=e(t);return yW-=s.length,s}function yJ(e,t,s,a){return{node:e,modifiers:e.modifiers.map(e=>{let r;return{source:e,apply:function(e,t,s,a){let r=yT(e);if(!r)return;if(a)return()=>void 0;let n=y1(r.content,t,s+1,!0);return(e,t)=>{if(!Array.isArray(e)||e.length&&!v3(e))return;let s=[],a=0;for(let r of e){if(yG<=0||a>=8e3)break;yG-=1;let e=n({...t,track:r});a+=e.length,/\S/.test(e)&&s.push(e)}return s}}(e,t,s,a)??function(e){let t=Object.prototype.hasOwnProperty.call(yt,e),s=yd.find(t=>e.startsWith(t));if(!t&&!s)return;let a=s?e.slice(s.length):"",r=!!s&&["$","^","~"].includes(s),n=!!s&&["<","<=",">",">=","="].includes(s);return l=>{try{if(!yt.exists(l))return!1;if(t)return yt[e](l);if(v3(l))return;let i=Array.isArray(l)&&l.every(e=>"string"==typeof e)?l.map(e=>e.toLowerCase()):void 0,o=String(l).toLowerCase(),d=/\s/.test(o)?a:a.replace(/\s/g,""),c=Number(o.replace(/,\s/g,"")),u=Number(d.replace(/,\s/g,"")),m=n&&!isNaN(c)&&!isNaN(u);return(0,ys[s])(m?c:(r?i:void 0)??o,m?u:d)}catch{return!1}}}(r=e.toLowerCase())??function(e,t){let s=e.indexOf("(");if(-1===s||!e.endsWith(")"))return;let a=t.slice(0,s),r=e.slice(s+1,-1);switch(a){case"replace":{let t=/^\s*\{([^}]+)\}\s*,\s*(['"])([\s\S]*)\2\s*$/.exec(r);if(t){let[,e,,s]=t,a=vW(s);return(t,s,r)=>{if(!yp(t))return;let n=r.resolveVariable(e,s);return n?yx(t,n,a):t}}let s=e.charAt(8),a=e.charAt(e.length-2),[n,l,i]=e.slice(9,-2).split(RegExp(`${s}\\s*,\\s*${a}`));if(void 0!==i||!n||void 0===l)return e=>yp(e)?e:void 0;let o=n.startsWith("{")&&n.endsWith("}")?n.slice(1,-1):void 0,d=vW(l);return(e,t,s)=>{if(!yp(e))return;if(!o)return yx(e,n,d);let a=s.resolveVariable(o,t);return a?yx(e,a,d):e}}case"remove":case"keep":{let e=yc(r),t=yu(r);if(0===e.length&&0===t.length)return()=>void 0;let s=e.filter(Boolean),n=new Set(s.map(e=>e.toLowerCase())),l=[...n],i="keep"===a;return(e,a,r)=>{if("string"==typeof e){if(i)return;let n=e;for(let e of ym(s,t,a,r,!1))n=n.replaceAll(e,"");return n}if(Array.isArray(e)&&!v3(e)){let s=t.length?new Set(ym(l,t,a,r)):n;return e.filter(e=>s.has(String(e).toLowerCase())===i)}}}case"join":{let e=yh(r);if(void 0===e)return;let t=vW(e);return e=>Array.isArray(e)&&!v3(e)?e.join(t):void 0}case"where":{let e;try{e=vV(yc(r))}catch{return()=>void 0}return(t,s,a)=>Array.isArray(t)&&(!t.length||v3(t))?t.filter(t=>e(t,e=>a.resolveValues(e,s))):void 0}case"pluck":{let e=yh(r);if(void 0===e)return;return t=>{if(!Array.isArray(t)||t.length&&!v3(t))return;let s=new Set;for(let a of t){let t=a[e];"string"==typeof t&&t&&s.add(vH(t))}return[...s]}}case"truncate":{let e=parseInt(r,10);if(isNaN(e)||e<0)return;let t=new Intl.Segmenter;return s=>{if("string"!=typeof s)return;let a=[...t.segment(s)];return a.length<=e?s:a.slice(0,e).map(e=>e.segment).join("").replace(/\s+$/,"")+"â¦"}}case"slice":{let e=r.split(",").map(e=>parseInt(e.trim(),10));if(isNaN(e[0]))return;let[t,s]=[e[0],e.length>1&&!isNaN(e[1])?e[1]:void 0];return e=>Array.isArray(e)?e.slice(t,s):void 0}case"default":{let e=yh(r);if(void 0===e)return;return t=>yt.exists(t)?t:e}case"trim":{let e=yh(r);if(void 0===e)return;let t=new Set(e);return e=>{if("string"!=typeof e)return;let s=[...e],a=0,r=s.length;for(;a<r&&t.has(s[a]);)a+=1;for(;r>a&&t.has(s[r-1]);)r-=1;return s.slice(a,r).join("")}}case"translate":{let[e,t]=yc(r);if(void 0===e||void 0===t)return;return s=>"string"==typeof s?v2(s,e,t):void 0}case"in":{let e=yc(r).map(e=>e.toLowerCase()),t=yu(r);if(0===e.length&&0===t.length)return;let s=new Set(e);return(a,r,n)=>{if(null==a)return!1;if(v3(a))return;let l=t.length?new Set(ym(e,t,r,n)):s;return Array.isArray(a)?a.some(e=>"string"==typeof e&&l.has(e.toLowerCase())):l.has(String(a).toLowerCase())}}case"time":{let e=yh(r);if(void 0===e)return;return t=>{var s;let a,r,n,l;return"number"==typeof t?(s=vg(t),a=new Set,vp(e,e=>{let t=e.startsWith("-")?e.slice(1):e;if(vx.includes(t))return a.add(t),{text:""}}
90),n=Math.floor((r=Math.max(0,Math.floor(s/1e3)))/60),l={H:Math.floor(r/3600),M:a.has("H")?n%60:n,S:a.has("H")||a.has("M")?r%60:r},vp(e,e=>{let t=!e.startsWith("-"),s=l[t?e:e.slice(1)];if(void 0!==s)return{text:t?String(s).padStart(2,"0"):String(s),zero:0===s}})):void 0}}case"date":{let e=yh(r);if(void 0===e)return;return t=>"string"==typeof t?function(e,t){let s=/^(\d{4})-(\d{1,2})-(\d{1,2})/.exec(e.trim());if(!s)return e;let[a,r,n]=[Number(s[1]),Number(s[2])-1,Number(s[3])],l=new Date(Date.UTC(a,r,n));if(l.getUTCFullYear()!==a||l.getUTCMonth()!==r||l.getUTCDate()!==n)return e;let i={Y:String(a),y:String(a%100).padStart(2,"0"),m:String(r+1).padStart(2,"0"),"-m":String(r+1),d:String(n).padStart(2,"0"),"-d":String(n),o:function(e){let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}(n),B:vf[r],b:vf[r].slice(0,3),A:vb[l.getUTCDay()],a:vb[l.getUTCDay()].slice(0,3)};return vp(t,e=>void 0!==i[e]?{text:i[e]}:void 0)}(t,e):void 0}default:return}}(e,r)??(e=>{if("string"==typeof e){let t=vQ[r];return t?t(e):void 0}if(Array.isArray(e)){if(v3(e)&&!v5.has(r))return;let t=v8[r];return t?t(e):void 0}if("number"==typeof e){let t=v7[r];return t?t(e):void 0}if("boolean"==typeof e){let t=ye[r];return t?t(e):void 0}})}})}}function yZ(e,t){return{resolveVariable:s=>t.resolveVariable(s,e),resolveValues:s=>t.resolveValues(s,e)}}function yQ(e,t,s){if(void 0!==e.node.literal){let a=yZ(t,s),r=e.node.literal;for(let{apply:s}of e.modifiers){let e=s(r,t,a);if(void 0===e)break;if("string"==typeof(r=e)&&r.length>8e3){r=r.slice(0,8e3);break}}return{result:r,present:!0}}let a=t[e.node.section];if(!a)return{error:`{unknown_variableType(${e.node.section})}`};let r=a[e.node.property];if(void 0===r)return{error:`{unknown_propertyName(${e.node.section}.${e.node.property})}`};let n=yZ(t,s),l=r;"string"==typeof r?l=vH(r):Array.isArray(r)&&r.some(e=>"string"==typeof e&&vK(e))&&(l=r.map(e=>"string"==typeof e?vH(e):e));let i=y0(r)||e.modifiers.some(e=>{let{source:t}=e;return t.toLowerCase().startsWith("default(")});for(let{source:s,apply:a}of e.modifiers){let e=l;if(void 0!==(l=a(e,t,n))){if("string"==typeof l&&l.length>8e3){l=l.slice(0,8e3);break}continue}if(null==e)return{result:"",present:i};return{error:`{unknown_${Array.isArray(e)?"array":typeof e}_modifier(${s})}`}}return v3(l)?{error:`{unrenderable_list(${e.node.section}.${e.node.property})}`}:{result:l,present:i}}function yX(e,t,s,a){if(1===t.length)return yQ(t[0],s,a);let r=i(t[0]);for(let s=1;s<t.length;s++){let a=i(t[s]);r="or"===e.comparators[s-1]?r||a:r&&a}let n=e.comparators.every(t=>t===e.comparators[0])&&("and"===e.comparators[0]||"or"===e.comparators[0]),l=yQ(t[0],s,a);for(let i=1;i<t.length;i++){if(void 0!==l.error)return l;let o=e.comparators[i-1];if(n){if("and"===o&&!1===l.result)return{result:!1,present:r};if("or"===o&&!0===l.result)return{result:!0,present:r}}let d=yQ(t[i],s,a);if(void 0!==d.error)return d;try{l={result:a.comparators[o](l.result,d.result)}}catch(e){return{error:`{unable_to_compare(<${l.result}>::${o}::<${d.result}>, ${e})}`}}}return{result:l.result,present:r};function i(e){if(void 0!==e.node.literal||e.modifiers.some(e=>{let{source:t}=e;return t.toLowerCase().startsWith("default(")}))return!0;let t=s[e.node.section];return!!t&&y0(t[e.node.property])}}function y0(e){return null!=e&&("string"==typeof e?/\S/.test(e):!Array.isArray(e)||e.length>0)}function y1(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(s>5){var r;return null==(r=t.onDepthExceeded)||r.call(t,5),()=>e}let n=e;for(let[e,s]of Object.entries(t.debugMacros??{}))n=n.replace(`{debug.${e}}`,s);let{nodes:l}=yU(n),i=l.map(e=>(function e(t,s,a,r){if("raw"===t.kind){let e=t.text.replace(/\\n
90/g,"\n");return()=>e}if("tool"===t.kind){let e="newLine"===t.tool?"\x11":"\x12";return()=>e}if("group"===t.kind){var n,l,i,o;let d;return n=t,l=s,i=a,o=r,d=n.nodes.map(t=>({node:t,render:e(t,l,i,o),operands:"expression"!==t.kind||t.check?void 0:t.operands.map(e=>yJ(e,l,i,o))})),e=>{let t="";for(let{node:s,render:a,operands:r}of d){if(r){let t=yX(s,r,e,l);if(void 0===t.error&&!1===t.present)return""}t+=yY(a,e)}return t}}let d=t.operands.map(e=>yJ(e,s,a,r));if(!t.check)return e=>{let a=yX(t,d,e,s);return a.error??String(a.result??"")};let c=e=>y1(e,s,a+1,r),u=c(t.check.trueTemplate),m=c(t.check.falseTemplate),h=void 0===t.check.absentTemplate?void 0:c(t.check.absentTemplate);return e=>{let a=yX(t,d,e,s);return void 0!==a.error?a.error:y0(a.result)?!0!==a.result&&!1!==a.result?`{cannot_coerce_boolean_for_check_from(${a.result})}`:a.result?u(e):m(e):h?h(e):""}})(e,t,s,a)),o=1===i.length?i[0]:e=>{let t="";for(let s of i)t+=yY(s,e);return t};return s>0?o:e=>(yW=8e3,yG=256,o(e))}function y2(e){let t=new Set;return e&&!function e(t,s,a){for(let r of t){if("group"===r.kind){e(r.nodes,s,a);continue}if("expression"===r.kind){for(let t of r.operands){if(a<5)for(let r of t.modifiers){let t=yT(r);t&&e(yU(t.content).nodes,s,a+1)}void 0===t.literal&&t.section&&s.add(`${t.section}.${t.property}`)}if(r.check&&!(a>=5))for(let t of[r.check.trueTemplate,r.check.falseTemplate,r.check.absentTemplate])t&&e(yU(t).nodes,s,a+1)}}}(yU(e).nodes,t,0),t}let y3={section:"cmf-section",property:"cmf-property",dot:"cmf-dot",literal:"cmf-literal",modifier:"cmf-modifier","call-args":"cmf-args",comparator:"cmf-comparator","prefix-op":"cmf-prefix",tool:"cmf-tool",separator:"cmf-sep",quote:"cmf-quote",pipe:"cmf-pipe",invalid:"cmf-invalid"},y5=new Set(["brace","bracket","group-brace"]);function y4(e){var t;let s,a=new fv.vB;for(let r of(s=[],yK(t=e.state.doc.toString(),0,t.length,yq,0,s),s.sort((e,t)=>e.start-t.start),s)){let e=y5.has(r.kind)?`cmf-d${r.depth%5}`:y3[r.kind];e&&a.add(r.start,r.end,ff.NZ.mark({class:e}))}return a.finish()}let y6=ff.Z9.fromClass(class{update(e){e.docChanged&&(this.decorations=y4(e.view))}constructor(e){(0,et._)(this,"decorations",void 0),this.decorations=y4(e)}},{decorations:e=>e.decorations}),y9=new Set(["unterminated","unterminated-group","unparseable"]),y8=(0,fk.bu)(e=>{let t=e.state.doc.toString(),s=t.length;return(function(e){let{nodes:t,diagnostics:s}=yU(e),a=[...s,...function e(t,s,a){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(r>5)return[];let l=[];for(let i of t){if("group"===i.kind){l.push(...e(i.nodes,s,a,r+1,n));continue}if("expression"===i.kind){if(l.push(...function(t,s,a,r,n){let l=[],i=t.start??0,o=t.source.toLowerCase(),d=0,c=e=>{let t=o.indexOf(e.toLowerCase(),d);return -1===t?d:(d=t+e.length,t)},u=(e,t,s,r)=>({index:a(i+e),message:r,source:t,category:s});for(let o of t.operands){let t=`${o.section}.${o.property}`;if(void 0===o.literal){let e=c(t);"track"!==o.section||n||l.push(u(e,t,"unknown-field",`\`${t}\` is only set inside \`::each(...)\``))}let d=void 0===o.literal&&vn.has(t);for(let t of o.modifiers){let o=c(t),m=t.indexOf("("),h=(-1===m?t:t.slice(0,m)).toLowerCase();if(-1!==m&&yN.has(h)){let e=t.slice(m+1,-1);for(let s of"where"===h?function(e){let t=new Set;for(let s of e){let e=vF.exec(s.trim());if(null==e?void 0:e[4])for(let s of e[4].split("|")){let e=vz.exec(s.trim());e&&t.add(e[1])}}return[...t]}(yc(e)):yu(e)){let[e,a]=s.split(".");if(vi(e,a))continue;let r=vc(e,a)[0];l.push({...u(o,t,"unknown-field",`\`::${h}\`: unknown field \`${s}\``),...r?{suggestion:r}:{}})}}if("where"!==h&&"pluck"!==h&&"each"!==h){"slice"!==h&&"reverse"!==h&&(d=!1);continue}let p=e=>l.push(u(o,t,"modifier-arguments",e));if(d){if("where"===h)try{vV(yc(t.slice(m+1,-1)))}catch(e){p(`\`::where\`: ${e.message}`)}else if("each"===h&&n)p("`::each` cannot be used inside another `::each`");else if("each"===h){let n=yT(t);if(n){let t=yR(n),d=e=>a(i+o+t(e)),c=yU(n.content);l.push(...c.diagnostics.map(e=>({...e,index:d(e.index),message:`inside each(): ${e.message}`}))),l.push(...e(c.nodes,s,d,r+1,!0))}}}else p(`\`::${h}\` only applies to a list of objects, such as \`stream.audioTracks\``);"where"!==h&&(d=!1)}}return l}(i,s,a,r,n)),i.check)for(let[t,o]of[[i.check.trueTemplate,i.check.trueStart],[i.check.falseTemplate,i.check.falseStart],[i.check.absentTemplate,i.check.absentStart]]){if(void 0===t||void 0===o)continue;let i=function(e,t){let s=[],a=t,r=0;for(;a<e.length;){let t=e[a];if("\\"===t&&'"'===e[a+1]){s.push(a),a+=2;continue}if("{"===t)r+=1;else if("}"===t)r=Math.max(0,r-1);else if('"'===t&&0===r)break;s.push(a),a+=1}let n=a;return e=>e>=0&&e<s.length?s[e]:n}(s,a(o)),d=yU(t);l.push(...d.diagnostics.map(e=>({...e,index:i(e.index),message:`inside conditional branch: ${e.message}`}))),l.push(...e(d.nodes,s,i,r+1,n))}}}return l}(t,e,e=>e)],r=new Set;return a.filter(e=>{let t=`${e.index}:${e.message}`;return!r.has(t)&&(r.add(t),!0)})})(t).map(e=>{let t=Math.max(0,Math.min(e.index,s)),a=Math.max(t+1,Math.min(e.index+(e.source?e.source.length:1),s)),r={from:t,to:a,severity:y9.has(e.category)?"error":"warning",message:e.message};if(e.suggestion){var n;let t=e.suggestion,s=null==(n=/`([^`]+)`/.exec(e.message))?void 0:n[1];r.actions=[{name:`Replace with ${t}`,apply(e,a,r){let n=e.state.doc.sliceString(a,r),l=s?n.indexOf(s):-1;s&&l>=0&&e.dispatch({changes:{from:a+l,to:a+l+s.length,insert:t}})}}]}return r})},{delay:200}),y7=Object.keys(vr),je=y7.map(e=>({label:e,type:"namespace",apply:`${e}.`})),jt=[...yy.map(e=>{let[t,s]=e;
90return{label:t,type:"function",detail:yF[s],apply:`${t}${yF[s]}`}}),...yi.map(e=>({label:e,type:"keyword",detail:"conditional"})),...[...new Set([...ya,...yr,...yn,...yl])].map(e=>({label:e,type:"method"})),...yf.map(e=>({label:e,type:"operator",detail:"comparator",apply:`${e}::`}))],js=/^[A-Za-z]*$/,ja=(0,fS.yU)({override:[function(e){let t=e.state.doc.sliceString(0,e.pos),s=t.lastIndexOf("{");if(s<0||t.lastIndexOf("}")>s)return null;let a=t.slice(s),r=/::([A-Za-z]*)$/.exec(a);if(r)return{from:e.pos-r[1].length,options:jt,validFor:js};let n=/([A-Za-z]+)\.([A-Za-z]*)$/.exec(a);if(n){var l;let t,s=(l=n[1],(t=y7.find(e=>e.toLowerCase()===l.toLowerCase()))?vr[t].map(e=>({label:e,type:"property"})):[]);if(s.length)return{from:e.pos-n[2].length,options:s,validFor:js}}let i=/\{\s*([A-Za-z]*)$/.exec(a);return i?{from:e.pos-i[1].length,options:je,validFor:js}:null}],icons:!1});function jr(e){let{value:t,onValueChange:s,placeholder:a,disabled:r,className:n,initialHeight:l="11rem",minHeight:o="6rem",onFocusView:d,onViewReady:c}=e,m=(0,u.useRef)(null),h=(0,u.useRef)(d);h.current=d;let p=(0,u.useMemo)(()=>[y6,y8,ja,fg.Lz.lineWrapping,(0,ff.qf)(a??""),fg.Lz.domEventHandlers({focus:(e,t)=>{var s;return null==(s=h.current)||s.call(h,t),!1}})],[a]);return(0,i.jsx)("div",{style:{height:l,minHeight:o},className:x("w-full rounded-[--radius] border border-[--border] bg-[--paper] shadow-sm overflow-hidden transition","resize-y","focus-within:ring-1 focus-within:ring-[--ring] focus-within:border-brand",r&&"opacity-60 pointer-events-none",n),children:(0,i.jsx)(fg.Ay,{ref:m,className:"h-full",value:t,onChange:s,onCreateEditor:e=>null==c?void 0:c(e),editable:!r,theme:fb,indentWithTab:!1,height:"100%",basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1,highlightActiveLineGutter:!1,autocompletion:!1,bracketMatching:!0,closeBrackets:!0,searchKeymap:!1,highlightSelectionMatches:!1,indentOnInput:!1,drawSelection:!1},extensions:p})})}function jn(e){let{onInsert:t}=e,s=so(!1);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{intent:"white",size:"sm",onClick:s.open,children:"Snippets"}),(0,i.jsx)(sl,{open:s.isOpen,onOpenChange:s.close,title:"Formatter Snippets",children:(0,i.jsx)("div",{className:"space-y-4",children:az.map((e,a)=>(0,i.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between border rounded-md p-3 bg-gray-900 border-gray-800 gap-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"font-semibold text-base mb-1",children:e.name}),(0,i.jsx)("div",{className:"text-sm text-muted-foreground mb-1 break-words",children:e.description}),(0,i.jsx)("div",{className:"font-mono text-xs bg-gray-800 rounded px-2 py-1 inline-block break-all",children:e.value})]}),(0,i.jsxs)("div",{className:"flex gap-2 sm:ml-4 flex-shrink-0",children:[t&&(0,i.jsx)(v,{size:"sm",intent:"primary",onClick:()=>{t(e.value)?(m.oR.success("Snippet inserted"),s.close()):m.oR.message("Click into a template first")},title:"Insert at cursor",children:(0,i.jsx)(m3.A,{className:"w-5 h-5"})}),(0,i.jsx)(v,{size:"sm",intent:"primary-outline",onClick:async()=>{await nf(e.value,{onSuccess:()=>m.oR.success("Snippet copied to clipboard"),onError:()=>m.oR.error("Failed to copy snippet to clipboard")})},title:"Copy snippet",children:(0,i.jsx)(bh.A,{className:"w-5 h-5"})})]})]},a))})})]})}var jl=s(46290);function ji(e){var t,s;let a=e.formatter.id,r=e.formatter.definitions;if(a===sQ){let t=e.formatter.selectedSaved,a=(t?null==r||null==(s=r.saved)?void 0:s[t]:void 0)??(null==r?void 0:r.custom);return{name:(null==a?void 0:a.name)??"",description:(null==a?void 0:a.description)??""}}let n=null==r||null==(t=r.overrides)?void 0:t[a];if(n)return{name:n.name,description:n.description};let l=va[a];return{name:(null==l?void 0:l.name)??"",description:(null==l?void 0:l.description)??""}}function jo(e){var t,s;let a=e.formatter.selectedSaved;if(e.formatter.id===sQ&&a&&(null==(s=e.formatter.definitions)||null==(t=s.saved)?void 0:t[a]))return a}function jd(e){let{name:t,description:s,compact:a=!1,className:r}=e;return(0,i.jsxs)("div",{className:x("bg-gray-900 rounded-md border border-gray-800",a?"p-3":"p-4",r),children:[(0,i.jsx)("div",{className:x("font-bold mb-1 overflow-x-auto",a?"text-sm":"text-xl"),style:{whiteSpace:"pre"},children:t}),(0,i.jsx)("div",{className:x("text-muted-foreground overflow-x-auto",a?"text-xs":"text-base"),style:{whiteSpace:"pre"},children:s})]})}function jc(e){let{title:t,description:s,badge:a,preview:r,active:n=!1,actions:l,tags:o,header:d}=e;return(0,i.jsxs)(pK,{glowSize:"350px",glowOpacity:.08,transitionDuration:"0.3s",className:x("flex flex-col gap-3 bg-gray-900 border-gray-800 hover:border-gray-600 transition-colors duration-200 rounded-lg p-4",n&&"border-[--brand] ring-1 ring-[--brand]/40"),children:[d??(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[(0,i.jsx)("h3",{className:"flex-1 min-w-[8rem] text-base font-semibold text-white truncate",children:t}),(n||a)&&(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[n&&(0,i.jsx)("span",{className:"text-xs bg-brand-500/20 text-brand-300 px-2 py-0.5 rounded border border-brand-500/30",children:"Active"}),a]})]}),s&&(0,i.jsx)("div",{className:"text-xs text-gray-400 max-h-28 overflow-y-auto whitespace-pre-wrap break-words pr-1",children:s})]}),o&&o.length>0&&(0,i.jsx)("div",{className:"flex flex-wrap gap-1",children:o.map(e=>(0,i.jsx)("span",{className:"text-[10px] uppercase tracking-wide bg-gray-800/80 text-gray-300 px-1.5 py-0.5 rounded border border-gray-700",children:e},e))}),(null==r?void 0:r.error)?(0,i.jsx)("div",{className:"rounded-md border border-red-600/60 bg-red-700/30 p-3 text-xs text-red-300 break-words",children:r.error}):(0,i.jsx)(jd,{compact:!0,name:(null==r?void 0:r.name)??" ",description:(null==r?void 0:r.description)??" ",className:x(!r&&"animate-pulse")}),l&&(0,i.jsx)("div",{className:"flex items-center gap-2 flex-wrap mt-auto",children:l})]})}var ju=s(21123),jm=s(2020);function jh(e){let{saved:t,previews:s,activeName:a,onSelect:r,onSaveCurrent:n,onRename:l,onDelete:o}=e,d=(0,u.useMemo)(()=>Object.keys(t).sort((e,t)=>
90e.localeCompare(t)),[t]);return 0===d.length?(0,i.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-gray-800 px-4 py-10 text-center",children:[(0,i.jsx)("span",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-gray-800/60 text-[--muted]",children:(0,i.jsx)(jl.A,{className:"h-5 w-5"})}),(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsx)("p",{className:"text-sm font-medium",children:"No saved formatters yet"}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Keep a named copy of the formatter in the editor so you can switch back to it later."})]}),(0,i.jsx)(jp,{existing:d,onSave:n,intent:"primary"})]}):(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)("p",{className:"flex-1 min-w-[12rem] text-xs text-[--muted]",children:"Saved formatters live in your config. Pick one to edit it in place."}),(0,i.jsx)(jp,{existing:d,onSave:n})]}),(0,i.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[560px] overflow-y-auto pr-2",children:d.map(e=>(0,i.jsx)(jx,{name:e,existingNames:d,preview:s[`saved:${e}`],active:a===e,onSelect:r,onRename:l,onDelete:o},e))})]})}function jp(e){let{existing:t,onSave:s,intent:a="primary-subtle"}=e,[r,n]=(0,u.useState)(!1),[l,o]=(0,u.useState)(""),d=l.trim(),c=d.length>0&&t.includes(d),m=()=>{n(!1),o("")},h=()=>{d&&(s(d),m())};return(0,i.jsx)(P,{open:r,onOpenChange:e=>e?n(!0):m(),align:"end",className:"w-80",onOpenAutoFocus:()=>{},trigger:(0,i.jsx)(v,{size:"sm",intent:a,leftIcon:(0,i.jsx)(ju.A,{className:"w-4 h-4"}),children:"Save current formatter"}),children:(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("div",{className:"space-y-0.5",children:[(0,i.jsx)("p",{className:"text-sm font-semibold",children:"Save current formatter"}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Keeps a named copy of the templates in the editor and switches to it."})]}),(0,i.jsx)(K,{value:l,onValueChange:o,placeholder:"Name",className:"text-sm",onKeyDown:e=>{"Enter"===e.key&&h()}}),c&&(0,i.jsxs)("p",{className:"text-xs text-yellow-400 break-all",children:["Replaces the existing â",d,"â."]}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"gray-outline",onClick:m,children:"Cancel"}),(0,i.jsx)(v,{size:"sm",intent:"primary",disabled:!d,onClick:h,children:"Save"})]})]})})}function jx(e){let{name:t,existingNames:s,preview:a,active:r,onSelect:n,onRename:l,onDelete:o}=e,[d,c]=(0,u.useState)(!1),[m,h]=(0,u.useState)(t);(0,u.useEffect)(()=>{h(t)},[t]);let p=sd({title:"Delete formatter",description:(0,i.jsxs)("span",{className:"break-all",children:["Are you sure you want to delete â",t,"â?"]}),actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>o(t)}),x=()=>{let e=m.trim();if(e&&e!==t){if(s.includes(e))return;l(t,e)}else h(t);c(!1)},g=()=>{h(t),c(!1)},f=d&&m.trim()!==t&&s.includes(m.trim());return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(sc,{...p}),(0,i.jsx)(jc,{title:t,preview:a,active:r,header:d?(0,i.jsxs)("div",{className:"space-y-1",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(K,{value:m,onValueChange:h,autoFocus:!0,className:"flex-1 min-w-0 text-sm",onKeyDown:e=>{"Enter"===e.key&&x(),"Escape"===e.key&&g()}}),(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,i.jsx)(pk.A,{className:"h-3.5 w-3.5"}),disabled:f,onClick:x}),(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,i.jsx)(jm.A,{className:"h-3.5 w-3.5"}),onClick:g})]}),f&&(0,i.jsx)("p",{className:"text-xs text-red-300",children:"A saved formatter with this name already exists."})]}):void 0,badge:(0,i.jsx)("span",{className:"text-xs bg-sky-500/20 text-sky-300 px-2 py-0.5 rounded border border-sky-500/30",children:"Saved"}),actions:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{size:"sm",intent:r?"gray-outline":"primary-subtle",disabled:r,onClick:()=>n(t),children:r?"In use":"Use"}),(0,i.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,i.jsx)(xn.A,{className:"h-3.5 w-3.5"}),onClick:()=>c(!0)}),children:"Rename"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"alert-subtle",icon:(0,i.jsx)(hX.A,{className:"h-3.5 w-3.5"}),onClick:p.open}),children:"Delete"})]})]})})]})}function jg(e){let{open:t,onOpenChange:s,credentials:a,definition:r,existing:n,moderated:l}=e,o=(0,e3.jE)(),[d,c]=(0,u.useState)(""),[h,p]=(0,u.useState)(""),[x,g]=(0,u.useState)(""),[f,b]=(0,u.useState)("");(0,u.useEffect)(()=>{var e;t&&(c((null==n?void 0:n.name)??""),p((null==n?void 0:n.description)??""),g((null==n?void 0:n.author)??""),b((null==n||null==(e=n.tags)?void 0:e.join(", "))??""))},[t,n]);let y=h0(f),j=(0,e5.n)({mutationFn:()=>n?eV(a,n.id,{name:d.trim(),description:h.trim(),author:x.trim(),tags:y,payload:r}):eF(a,{name:d.trim(),description:h.trim(),author:x.trim(),tags:y,payload:r}),onSuccess:e=>{o.invalidateQueries({queryKey:tf}),o.invalidateQueries({queryKey:tb}),e.draft?m.oR.success("Update submitted for review"):"pending"===e.status?m.oR.success("Submitted for review"):m.oR.success(n?"Update published":"Published"),s(!1)},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to share")}),w=d.trim().length>0&&x.trim().length>0,N=n?hU(n.version):"1.0.0";return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:n?"Update shared formatter":"Share formatter",description:n?`Publishes the formatter currently in the editor as v${N} of "${n.name}".`:"Publishes the formatter currently in the editor for everyone on this instance.",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(L,{label:"Name",children:(0,i.jsx)(K,{value:d,onValueChange:c,placeholder:"A short, recognisable name",maxLength:100})}),(0,i.jsx)(L,{label:"Description",help:"What makes it different, what it shows.",children:(0,i.jsx)(ly,{value:h,onValueChange:p,placeholder:"Optional",maxLength:1e3})}),(0,i.jsx)(L,{label:"Author",help:"Shown on the card. Up to 20 characters.",children:(0,i.jsx)(K,{value:x,onValueChange:g,placeholder:"Your name or handle",maxLength:20})}),(0,i.jsxs)(L,{label:"Tags",help:"Comma separated, up to 5. Used to filter the community list.",children:[(0,i.jsx)(K,{value:f,onValueChange:b,placeholder:"minimal, emoji, anime"}),y.length>0&&(0,i.jsx)("div",{className:"flex flex-wrap gap-1 mt-2",children:y.map(e=>(0,i.jsx)("span",{className:"text-xs bg-gray-800 text-gray-300 px-2 py-0.5 rounded border border-gray-700",children:e},e))})]}),l&&(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["This instance reviews submissions before they appear to others.",n&&" The current version stays published meanwhile."]}),(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",size:"sm",onClick:()=>s(!1),children:"Cancel"}),(0,i.jsx)(v,{intent:"primary",size:"sm",disabled:!w,loading:j.isPending,onClick:()=>j.mutate(),children:n?`Publish v${N}`:"Share"})]})]})})}let jf={lang:null,codec:null,tag:null,channels:null,title:null,default:!1,forced:!1,commentary:!1,dub:!1,original:!1,hearingImpaired:!1,visualImpaired:!1};function jb(e){return(e??[]).filter(e=>Object.keys(e).length>0).map(e=>({...jf,...e}))}function jv(e,t){var s;let[a,r]=e.trim().split(".");if(!a||!r)return;let n=vi(a,r);if(n)return null==t||null==(s=t[n[0]])?void 0:s[n[1]]}
90class jy{async compileTemplatesAsync(){this.precompiledNameFunction=await this.getCompiledTemplate(this.config.name),this.precompiledDescriptionFunction=await this.getCompiledTemplate(this.config.description)}async getCompiledTemplate(e){let t=jy.compiledTemplates,s=t.get(e);if(s)return s.uses+=1,t.delete(e),t.set(e,s),s.compiled;let a=await this.compileTemplate(e);if(e.length>jy.MAX_CACHED_TEMPLATE_CHARS)return a;for(t.set(e,{compiled:a,chars:e.length,uses:1}),jy.cachedTemplateChars+=e.length;jy.cachedTemplateChars>jy.MAX_CACHED_TEMPLATE_CHARS&&jy.evictOne(););return a}static evictOne(){let e=jy.compiledTemplates,t=[];for(let s of e)if(t.push(s),t.length>=jy.EVICTION_SAMPLE)break;if(!t.length)return!1;let[s,a]=t[0];for(let[e,r]of t)r.uses<a.uses&&([s,a]=[e,r]);for(let[e,a]of t)e!==s&&a.uses>1&&(a.uses-=1);return e.delete(s),jy.cachedTemplateChars-=a.chars,!0}async format(e){if(await this._compilationPromise,!this.precompiledNameFunction||!this.precompiledDescriptionFunction)throw Error("Template compilation failed - formatter not ready");let t=this.convertStreamToParseValue(e);return{name:this.precompiledNameFunction(t),description:this.precompiledDescriptionFunction(t)}}convertStreamToParseValue(e){var t,s,a,r,n,l,i,o,d,c,u,m,h,p,x,g,f,b,v,y,j,w,N,k,S,C,_,A,R,T,I,E,M,P,$,D,L,O,U,F,z,V,q,B,K,H,W,G,Y,J,Z,Q,X,ee,et,es,ea,er,en,el,ei,eo,ed,ec,eu,em,eh,ep,ex,eg,ef,eb,ev;let ey=(e,t)=>e.toString().padStart(t,"0"),ej=(null==(s=e.parsedFile)||null==(t=s.seasons)?void 0:t.length)?1===e.parsedFile.seasons.length?`S${ey(e.parsedFile.seasons[0],2)}`:`S${ey(e.parsedFile.seasons[0],2)}-${ey(e.parsedFile.seasons[e.parsedFile.seasons.length-1],2)}
90`:void 0,ew=(null==(r=e.parsedFile)||null==(a=r.episodes)?void 0:a.length)?1===e.parsedFile.episodes.length?`E${ey(e.parsedFile.episodes[0],2)}`:`E${ey(e.parsedFile.episodes[0],2)}-${ey(e.parsedFile.episodes[e.parsedFile.episodes.length-1],2)}`:void 0,eN=[ej,ew].filter(e=>void 0!==e),ek=(null==(l=e.parsedFile)||null==(n=l.folderSeasons)?void 0:n.length)?1===e.parsedFile.folderSeasons.length?`S${ey(e.parsedFile.folderSeasons[0],2)}`:`S${ey(e.parsedFile.folderSeasons[0],2)}-${ey(e.parsedFile.folderSeasons[e.parsedFile.folderSeasons.length-1],2)}`:void 0,eS=(null==(o=e.parsedFile)||null==(i=o.folderEpisodes)?void 0:i.length)?1===e.parsedFile.folderEpisodes.length?`E${ey(e.parsedFile.folderEpisodes[0],2)}`:`E${ey(e.parsedFile.folderEpisodes[0],2)}-${ey(e.parsedFile.folderEpisodes[e.parsedFile.folderEpisodes.length-1],2)}`:void 0,eC=e=>{let t=e.charAt(0).toUpperCase()+e.slice(1);return[...this.userData[`preferred${t}`]||[],...this.userData[`required${t}`]||[],...this.userData[`included${t}`]||[]]},e_=e=>[...new Set(eC(e))],eA=(e,t)=>e?t.length?[...e].sort((e,s)=>{let a=t.indexOf(e),r=t.indexOf(s),n=-1!==a,l=-1!==r;return n&&l?a-r:n?-1:+!!l}):e:null,eR=[...new Set(eC("languages").map(e=>"Original"===e&&this.formatterContext.originalLanguage?this.formatterContext.originalLanguage:e))],eT=[...new Set(eC("subtitles").map(e=>"Original"===e&&this.formatterContext.originalLanguage?this.formatterContext.originalLanguage:e))],eI=(e,t)=>{let s=eA(e,t),a=s?s.filter(e=>t.includes(e)):null,r=function(e){for(var t=arguments.length,s=Array(t>1?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];return e?[...new Set(e.map(e=>s.reduce((e,t)=>void 0!==e?t(e)??e:void 0,e)).filter(Boolean))]:null},n=r(s,vU),l=r(a,vU),i=r(s,e=>v$(e)||e.toUpperCase()),o=r(a,e=>v$(e)||e.toUpperCase()),d=r(s,v$,vv),c=r(a,v$,vv),u=r(s,vU,e=>e.replace("\uD83C\uDDEC\uD83C\uDDE7","\uD83C\uDDFA\uD83C\uDDF8\uD83E\uDD85")),m=r(a,vU,e=>e.replace("\uD83C\uDDEC\uD83C\uDDE7","\uD83C\uDDFA\uD83C\uDDF8\uD83E\uDD85"));return{sortedValues:s,userValues:a,emojis:n,userEmojis:l,codes:i,userCodes:o,smallCodes:d,userSmallCodes:c,usEmojis:u,userUsEmojis:m}},eE=e=>{let t,s=!1;return()=>(s||(t=e(),s=!0),t)},eM=eE(()=>{var t;return eI(null==(t=e.parsedFile)?void 0:t.languages,eR)}),eP=eE(()=>{var t;return eI(null==(t=e.parsedFile)?void 0:t.subtitles,(null==eT?void 0:eT.length)?eT:eR)}),e$=eE(()=>({languages:eR,subtitles:eT.length?eT:eR,resolutions:e_("resolutions"),qualities:e_("qualities"),visualTags:e_("visualTags"),audioTags:e_("audioTags"),audioChannels:e_("audioChannels"),encodes:e_("encodes"),streamTypes:e_("streamTypes"),releaseGroups:e_("releaseGroups"),keywords:e_("keywords")})),eD=eA(null==(d=e.parsedFile)?void 0:d.audioChannels,eC("audioChannels")),eL=eA(null==(c=e.parsedFile)?void 0:c.audioTags,eC("audioTags")),eO=eA(null==(u=e.parsedFile)?void 0:u.visualTags,eC("visualTags")),eU=e.age?function(e){if(e<24)return`${e}h`;let t=Math.floor(e/24);return`${t}d`}(e.age):null,eF={get user(){return e$()},config:{addonName:this.userData.addonName||this.formatterContext.addonName||"AIOStreams"},stream:{filename:e.filename||null,folderName:e.folderName||null,size:e.size||null,folderSize:e.folderSize||null,library:e.library??!1,quality:(null==(m=e.parsedFile)?void 0:m.quality)||null,resolution:(null==(h=e.parsedFile)?void 0:h.resolution)||null,subbed:(null==(p=e.parsedFile)?void 0:p.subbed)||!!(null==(g=e.parsedFile)||null==(x=g.subtitles)?void 0:x.length),dubbed:(null==(f=e.parsedFile)?void 0:f.dubbed)||!1,mediaInfoQuality:(null==(b=e.parsedFile)?void 0:b.mediaInfoQuality)??null,get languages(){return eM().sortedValues},get uLanguages(){return eM().userValues},get subtitles(){return eP().sortedValues},get uSubtitles(){return eP().userValues},get languageEmojis(){return eM().emojis},get uLanguageEmojis(){return eM().userEmojis},get subtitleEmojis(){return eP().emojis},get uSubtitleEmojis(){return eP().userEmojis},get languageCodes(){return eM().codes},get uLanguageCodes(){return eM().userCodes},get subtitleCodes(){return eP().codes},get uSubtitleCodes(){return eP().userCodes},get smallLanguageCodes(){return eM().smallCodes},get uSmallLanguageCodes(){return eM().userSmallCodes},get smallSubtitleCodes(){return eP().smallCodes},get uSmallSubtitleCodes(){return eP().userSmallCodes},get wedontknowwhatakilometeris(){return eM().usEmojis},get uWedontknowwhatakilometeris(){return eM().userUsEmojis},visualTags:eO,audioTags:eL,audioTracks:jb(null==(v=e.parsedFile)?void 0:v.audioTracks),subtitleTracks:jb(null==(y=e.parsedFile)?void 0:y.subtitleTracks),releaseGroup:(null==(j=e.parsedFile)?void 0:j.releaseGroup)||null,regexMatched:(null==(w=e.regexMatched)?void 0:w.name)||(null==(N=e.rankedRegexesMatched)?void 0:N[0])||null,rankedRegexMatched:(null==(k=e.rankedRegexesMatched)?void 0:k.filter(e=>"string"==typeof e))||[],regexScore:e.regexScore??null,nRegexScore:void 0!=e.regexScore&&void 0!=this.formatterContext.maxRegexScore&&this.formatterContext.maxRegexScore>0?Math.max(0,Math.min(100,Math.round(e.regexScore/this.formatterContext.maxRegexScore*100))):null,encode:(null==(S=e.parsedFile)?void 0:S.encode)||null,audioChannels:eD||null,indexer:e.indexer||null,seeders:(null==(C=e.torrent)?void 0:C.seeders)??null,private:(null==(_=e.torrent)?void 0:_.private)??!1,freeleech:(null==(A=e.torrent)?void 0:A.freeleech)??null,year:(null==(R=e.parsedFile)?void 0:R.year)||null,type:e.type||null,title:(null==(T=e.parsedFile)?void 0:T.title)||null,country:(null==(I=e.parsedFile)?void 0:I.country)||null,episodeTitle:(null==(E=e.parsedFile)?void 0:E.episodeTitle)||null,date:(null==(M=e.parsedFile)?void 0:M.date)||null,season:(null==($=e.parsedFile)||null==(P=$.seasons)?void 0:P[0])||null,formattedSeasons:ej||null,seasons:(null==(D=e.parsedFile)?void 0:D.seasons)||null,folderSeasons:(null==(L=e.parsedFile)?void 0:L.folderSeasons)||null,formattedFolderSeasons:ek||null,episode:(null==(U=e.parsedFile)||null==(O=U.episodes
90)?void 0:O[0])||null,formattedEpisodes:ew||null,episodes:(null==(F=e.parsedFile)?void 0:F.episodes)||null,formattedFolderEpisodes:eS||null,folderEpisodes:(null==(z=e.parsedFile)?void 0:z.folderEpisodes)||null,seasonEpisode:eN||null,seasonPack:(null==(V=e.parsedFile)?void 0:V.seasonPack)??!1,duration:e.duration||null,bitrate:e.bitrate??null,infoHash:(null==(q=e.torrent)?void 0:q.infoHash)||null,age:eU,ageHours:e.age||null,message:e.message||null,proxied:e.proxied??!1,edition:(null==(K=e.parsedFile)||null==(B=K.editions)?void 0:B[0])||null,editions:(null==(H=e.parsedFile)?void 0:H.editions)||null,regraded:(null==(W=e.parsedFile)?void 0:W.regraded)??!1,remastered:null,repack:(null==(G=e.parsedFile)?void 0:G.repack)??!1,proper:(null==(Y=e.parsedFile)?void 0:Y.proper)??!1,uncensored:(null==(J=e.parsedFile)?void 0:J.uncensored)??!1,unrated:(null==(Z=e.parsedFile)?void 0:Z.unrated)??!1,upscaled:(null==(Q=e.parsedFile)?void 0:Q.upscaled)??!1,hasChapters:(null==(X=e.parsedFile)?void 0:X.hasChapters)??!1,network:(null==(ee=e.parsedFile)?void 0:ee.network)||null,site:(null==(et=e.parsedFile)?void 0:et.site)||null,container:(null==(es=e.parsedFile)?void 0:es.container)||null,extension:(null==(ea=e.parsedFile)?void 0:ea.extension)||null,seadex:(null==(er=e.seadex)?void 0:er.isSeadex)??!1,seadexBest:(null==(en=e.seadex)?void 0:en.isBest)??!1,nSeScore:void 0!=e.streamExpressionScore&&void 0!=this.formatterContext.maxSeScore&&this.formatterContext.maxSeScore>0?Math.max(0,Math.min(100,Math.round(e.streamExpressionScore/this.formatterContext.maxSeScore*100))):null,seScore:e.streamExpressionScore??null,seMatched:(null==(el=e.streamExpressionMatched)?void 0:el.name)||null,rseMatched:(null==(ei=e.rankedStreamExpressionsMatched)?void 0:ei.filter(e=>"string"==typeof e))||[],preloading:e.preloading??!1,idMatched:e.idMatched??!1},metadata:{queryType:this.formatterContext.queryType||null,type:this.formatterContext.type||null,isAnime:this.formatterContext.
90isAnime??!1,title:this.formatterContext.title||null,titles:this.formatterContext.titles||null,year:this.formatterContext.year||null,yearEnd:this.formatterContext.yearEnd||null,runtime:this.formatterContext.runtime||null,episodeRuntime:this.formatterContext.episodeRuntime||null,genres:this.formatterContext.genres||null,originalLanguage:this.formatterContext.originalLanguage||null,country:this.formatterContext.country||null,season:this.formatterContext.season??null,episode:this.formatterContext.episode??null,absoluteEpisode:this.formatterContext.absoluteEpisode??null,relativeAbsoluteEpisode:this.formatterContext.relativeAbsoluteEpisode??null,episodeTitle:(null==(eo=this.formatterContext.episodeTitles)?void 0:eo[0])||null,episodeTitles:this.formatterContext.episodeTitles||null,latestSeason:this.formatterContext.latestSeason??null,daysSinceRelease:this.formatterContext.daysSinceRelease??null,daysSinceFirstAired:this.formatterContext.daysSinceFirstAired??null,daysSinceLastAired:this.formatterContext.daysSinceLastAired??null,hasNextEpisode:this.formatterContext.hasNextEpisode??!1,daysUntilNextEpisode:this.formatterContext.daysUntilNextEpisode??null,anilistId:this.formatterContext.anilistId??null,malId:this.formatterContext.malId??null,hasSeaDex:this.formatterContext.hasSeaDex??!1},addon:{name:(null==(ed=e.addon)?void 0:ed.name)||null,presetId:(null==(eu=e.addon)||null==(ec=eu.preset)?void 0:ec.type)||null,manifestUrl:(null==(em=e.addon)?void 0:em.manifestUrl)||null},service:{id:(null==(eh=e.service)?void 0:eh.id)||null,shortName:(null==(ep=e.service)?void 0:ep.id)&&(null==(ex=Object.values(ap).find(t=>{var s;return t.id===(null==(s=e.service)?void 0:s.id)}))?void 0:ex.shortName)||null,name:(null==(eg=e.service)?void 0:eg.id)&&(null==(ef=Object.values(ap).find(t=>{var s;return t.id===(null==(s=e.service)?void 0:s.id)}))?void 0:ef.name)||null,cached:(null==(eb=e.service)?void 0:eb.cached)!==void 0?null==(ev=e.service)?void 0:ev.cached:null}};return eF.debug={get json(){return JSON.stringify({...eF,debug:void 0})},get jsonf(){return JSON.stringify({...eF,debug:void 0},(e,t)=>t,2)}},eF}async compileTemplate(e){let t=this.compileWithEngine(e);return e=>t(e).split("\n").filter(e=>""!==e.trim()&&!e.includes("\x12")).join("\n").replaceAll("\x11","\n")}compileWithEngine(e){let t=this.formatterContext.onWarning,s=y1(e,{resolveVariable:(e,t)=>
90{let s=jv(e,t);return null==s?void 0:String(s)},resolveValues:(e,t)=>{let s=jv(e,t);if(null!=s)return Array.isArray(s)?s.filter(e=>"string"==typeof e):[String(s)]},comparators:yg,onDepthExceeded:e=>null==t?void 0:t(`Template nesting depth exceeded (max ${e}). Returning literal text.`)});return t=void 0,s}constructor(e,t){(0,et._)(this,"config",void 0),(0,et._)(this,"userData",void 0),(0,et._)(this,"formatterContext",void 0),(0,et._)(this,"precompiledNameFunction",null),(0,et._)(this,"precompiledDescriptionFunction",null),(0,et._)(this,"_compilationPromise",void 0),this.config=e,this.userData=t.userData,this.formatterContext=t,this._compilationPromise=this.compileTemplatesAsync()}}(0,et._)(jy,"compiledTemplates",new Map),(0,et._)(jy,"cachedTemplateChars",0),(0,et._)(jy,"MAX_CACHED_TEMPLATE_CHARS",1e6),(0,et._)(jy,"EVICTION_SAMPLE",16);class jj extends jy{static fromConfig(e,t){return new jj(e.name,e.description,t)}updateTemplate(e,t){this.config={name:e,description:t}}getTemplate(){return this.config}constructor(e,t,s){super({name:e,description:t},s)}}let jw=e=>RegExp(`(?<![^\\s\\[(_\\-.,])(${e})(?=[\\s\\[(\\)\\]_.\\-,]|$)`,"i"),jN=e=>jw(`${e}(?![ .\\-_]?sub(title)?s?)`),jk={resolutions:{"2160p":jw("(bd|hd|m)?(4k|2160(p|i)?)|u(ltra)?[ .\\-_]?hd|3840\\s?x\\s?(\\d{4})"),"1440p":jw("(bd|hd|m)?(1440(p|i)?)|2k|w?q(uad)?[ .\\-_]?hd|2560\\s?x(\\d{4})"),"1080p":jw("(bd|hd|m)?(1080(p|i)?)|f(ull)?[ .\\-_]?hd|1920\\s?x\\s?(\\d{3,4})"),"720p":jw("(bd|hd|m)?((720|800)(p|i)?)|hd|1280\\s?x\\s?(\\d{3,4})"),"576p":jw("(bd|hd|m)?((576|534)(p|i)?)"),"480p":jw("(bd|hd|m)?(480(p|i)?)|sd"),"360p":jw("(bd|hd|m)?(360(p|i)?)"),"240p":jw("(bd|hd|m)?(240(p|i)?)"),"144p":jw("(bd|hd|m)?(144(p|i)?)")},qualities:{"BluRay REMUX":jw("(?<!dvd.*)(bd|br|b|uhd)?remux(?!.*dvd)"),BluRay:jw("(?<!remux.*)((bd|blu[ .\\-_]?ray)([ .\\-_]?rip)?|br[ .\\-_]?rip)(?!.*remux)"),"WEB-DL":jw("web[ .\\-_]?(dl)?(?![ .\\-_]?(rip|DLRip|cam))"),WEBRip:jw("web[ .\\-_]?rip"),HDRip:jw("hd[ .\\-_]?rip|web[ .\\-_]?dl[ .\\-_]?rip"),"HC HD-Rip":jw("hc|hd[ .\\-_]?rip"),"DVD REMUX":jw("(hd[ .\\-_]?)?dvd.*remux|remux.*(hd[ .\\-_]?)?dvd"),DVDRip:jw("dvd[ .\\-_]?(rip|mux|r|full|5|9)?"),HDTV:jw("(hd|pd)tv|tv[ .\\-_]?rip|hdtv[ .\\-_]?rip|dsr(ip)?|sat[ .\\-_]?rip"),CAM:jw("cam|hdcam|cam[ .\\-_]?rip"),TS:jw("telesync|ts|hd[ .\\-_]?ts|pdvd|predvd(rip)?"),TC:jw("telecine|tc|hd[ .\\-_]?tc"),SCR:jw("((dvd|bd|web|hd)?[ .\\-_]?)?(scr(eener)?)")},visualTags:{"10bit":jw("10[ .\\-_]?bit|hi10p?"),"HDR10+":jw("hdr[ .\\-_]?10[ .\\-_]?(p(lus)?|[+])"),HDR10:jw("hdr[ .\\-_]?10(?![ .\\-_]?(?:\\+|p(?:lus)?|bit|hi))"),HDR:jw("hdr(?![ .\\-_]?(?:10(?![ .\\-_]?(?:bit|hi))|\\+|p(?:lus)?))"),HLG:jw("hlg"),DV:jw("do?(lby)?[ .\\-_]?vi?(sion)?(?:[ .\\-_]?atmos)?|dv"),"3D":jw("(bd)?(3|three)[ .\\-_]?(d(imension)?(al)?)"),IMAX:jw("imax"),AI:jw("ai|ai(enhanced?|re[ .\\-_]?graded?)"),Upscaled:jw("(ai)?(uprez|ups(uhd|cal(ed?|ing)(uhd)?))(ai)?"),SDR:jw("sdr"),"H-OU":jw("h?(alf)?[ .\\-_]?(ou|over[ .\\-_]?under)"),"H-SBS":jw("h?(alf)?[ .\\-_]?(sbs|side[ .\\-_]?by[ .\\-_]?side)")},audioTags:{Atmos:jw("atmos|ddpa\\d?"),"DD+":jw("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)(?:[ .\\-_]?(2[ .\\-_]?0|5[ .\\-_]?1|7[ .\\-_]?1))?)|e[ .\\-_]?ac[ .\\-_]?3"),DD:jw("(d(olby)?[ .\\-_]?d(igital)?(?:[ .\\-_]?(5[ .\\-_]?1|7[ .\\-_]?1|2[ .\\-_]?0?))?)|(?<!e[ .\\-_]?)ac[ .\\-_]?3"),"DTS:X":jw("dts[ .\\-:_]?x"),"DTS-HD MA":jw("dts[ .\\-_]?hd[ .\\-_]?ma"),"DTS-HD":jw("dts[ .\\-_]?hd(?![ .\\-_]?ma)"),"DTS-ES":jw("dts[ .\\-_]?es"),DTS:jw("dts(?![ .\\-:_]?(x(?=[\\s\\[(\\)\\]_.\\-,]|$)|hd[ .\\-_]?(ma)?|es))"),TrueHD:jw("true[ .\\-_]?hd"),PCM:jw("l?pcm"),OPUS:jw("opus"),AAC:jw("q?aac(?:[ .\\-_]?2)?"),FLAC:jw("flac(?:[ .\\-_]?(lossless|2\\.0|x[2-4]))?")},audioChannels:{"2.0":jw("(d(olby)?[ .\\-_]?d(igital)?)?2[ .\\-_]?0(ch)?"),"5.1":jw("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)?)?5[ .\\-_]?1(ch)?"),"6.1":jw("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)?)?6[ .\\-_]?1(ch)?"),"7.1":jw("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)?)?7[ .\\-_]?1(ch)?")},encodes:{HEVC:jw("hevc[ .\\-_]?(10)?|[xh][ .\\-_]?265"),AVC:jw("avc|[xh][ .\\-_]?264"),AV1:jw("av1"),"VC-1":jw("vc[ .\\-_]?1"),XviD:jw("xvid"),DivX:jw("divx|dvix"),"MPEG-4":jw("mpeg[ .\\-_]?4")},languages:{Multi:jN("multi"),"Dual Audio":jN("dual[ .\\-_]?(audio|lang(uage)?|flac|ac3|aac2?)"),Dubbed:jN("dub(s|bed|bing)?"),English:jN("english|eng"),Japanese:jN("japanese|jap|jpn"),Chinese:jN("chinese|chi"),Russian:jN("russian|rus"),Arabic:jN("arabic|ara"),Portuguese:jN("portuguese"),"Portuguese (Brazil)":jN("portuguese[ .\\-_]?brazil|pt[ .\\-_]?br"),Spanish:jN("spanish|spa|esp"),French:jN("french|fra|fr|vf|vff|vfi|vf2|vfq|truefrench"),German:jN("deu(tsch)?(land)?|ger(man)?"),Italian:jN("italian|ita"),Korean:jN("korean|kor"),Hindi:jN("hindi|hin"),Bengali:jN("bengali|ben(?![ .\\-_]?the[ .\\-_]?men)"),Punjabi:jN("punjabi|pan"),Marathi:jN("marathi|mar"),Gujarati:jN("gujarati|guj"),Tamil:jN("tamil|tam"),Telugu:jN("telugu|tel"),Kannada:jN("kannada|kan"),Malayalam:jN("malayalam|mal"),Thai:jN("thai|tha"),Vietnamese:jN("vietnamese|vie"),Indonesian:jN("indonesian|ind"),Turkish:jN("turkish|tur"),Hebrew:jN("hebrew|heb"),Persian:jN("persian|per"),Ukrainian:jN("ukrainian|ukr"),Greek:jN("greek|ell"),Lithuanian:jN("lithuanian|lit"),Latvian:jN("latvian|lav"),Estonian:jN("estonian|est"),Polish:jN("polish|pol"),Czech:jN("czech|cze"),Slovak:jN("slovak|slo"),Hungarian:jN("hungarian|hun"),Romanian:jN("romanian|rum"),Bulgarian:jN("bulgarian|bul"),Serbian:jN("serbian|srp"),Croatian:jN("croatian|hrv"),Slovenian:jN("slovenian|slv"),Dutch:jN("dutch|dut"),Danish:jN("danish|dan"),Finnish:jN("finnish|fin"),Swedish:jN("swedish|swe"),Norwegian:jN("norwegian|nor"),Malay:jN("malay"),Latino:jN("latino|lat")}};var jS=s(69459);let jC=new Map,j_=function(e){let t=e.map(e=>
90e.trim()).filter(Boolean).map(e=>e.endsWith("*")?`${jA(e.slice(0,-1))}[a-z0-9]*`:jA(e));if(t.length)return RegExp(`(?:-(?:${t.join("|")}))+(?=(?:\\.[a-z0-9]{2,4})?$)`,"i")}(["RP","1","NZBGeek","[N-Z-B]","Obfuscated","Obfuscation","Scrambled","sample","Pre","postbot","xpost","Rakuv*","WhiteRev","BUYMORE","AsRequested","AlternativeToRequested","GEROV","Z0iDS3N","Chamele0n","4P","4Planet","AlteZachen","RePACKPOST","FTP","xpo"]);function jA(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}let jR=new WeakMap;function jT(e){let t=jR.get(e);return t||(t=Object.entries(e),jR.set(e,t)),t}function jI(e,t){var s;return null==(s=jT(t).find(t=>{let[s,a]=t;return a.test(e)}))?void 0:s[0]}function jE(e,t){return jT(t).filter(t=>{let[s,a]=t;return a.test(e)}).map(e=>{let[t]=e;return t})}let jM=new Map,jP=class{static parse(e){var t,s,a;let r=function(e){let t=j_?e.replace(j_,""):e,s=jC.get(t);if(void 0!==s)return jC.delete(t),jC.set(t,s),s;let a=(0,jS.OI)(t);if(jC.size>=1e4){let e=jC.keys().next().value;void 0!==e&&jC.delete(e)}return jC.set(t,a),a}(e),n=r.title;if(n&&n.length>4){let t;e=(e=e.replace((!(t=jM.get(n))&&(t=RegExp(n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/ /g,"[._ ]"),"i"),jM.size>=2e3&&jM.delete(jM.keys().next().value),jM.set(n,t)),t),"").trim()).replace(/\s+/g,".").replace(/^\.+|\.+$/g,"")}let l=function(e){if(!e)return;let t=e.toLowerCase();if("4k"===t)return"2160p";if(ak.includes(t))return t;let s=t.match(/^(\d+)p$/);if(s){let e=parseInt(s[1],10);return ak.filter(e=>"Unknown"!==e).map(e=>[e,parseInt(e,10)]).reduce((t,s)=>Math.abs(s[1]-e)<Math.abs(t[1]-e)?s:t)[0]}}(r.resolution)||jI(e,jk.resolutions),i=jI(e,jk.qualities),o=jI(e,jk.encodes),d=jE(e,jk.audioChannels),c=jE(e,jk.visualTags),u=jE(e,jk.audioTags),m=e;(null==(t=r.group)?void 0:t.toLowerCase())==="ind"&&(m=m.replace(/ind/i,""));let h=[...new Set([...jE(m,jk.languages),...(r.languages||[]).map(e=>{switch(e.toLowerCase()){case"multi audio":return"Multi";case"dual audio":return"Dual Audio";case"multi subs":return;default:return function(e){let t=e.split("-"),s=vj.filter(e=>{var s,a,r;return 2===t.length?(null==(a=e.iso_639_1)?void 0:a.toLowerCase())===t[0].toLowerCase()&&(null==(r=e.iso_3166_1)?void 0:r.toLowerCase())===t[1].toLowerCase():(null==(s=e.iso_639_1)?void 0:s.toLowerCase())===t[0].toLowerCase()}),a=s.find(e=>e.flag_priority)||s[0];if(!a)return;let r=vw(a);return aF.includes(r)?r:void 0}(vI(e))}}).filter(e=>!!e)])],p=r.group,x=r.year?r.year.toString():void 0;return{resolution:l,quality:i,languages:h,subtitles:[],encode:o,audioChannels:d,audioTags:u,visualTags:c,releaseGroup:p,title:n,year:x,country:r.country,episodeTitle:r.episodeTitle,subbed:r.subbed??!1,dubbed:r.dubbed??!1,editions:r.editions,regraded:r.regraded??!1,repack:r.repack??!1,proper:r.proper??!1,uncensored:r.uncensored??!1,unrated:r.unrated??!1,upscaled:r.upscaled??!1,network:r.network,site:r.site,container:r.container,extension:r.extension,seasons:r.seasons,volumes:r.volumes,episodes:r.episodes,date:r.date,seasonPack:!!((null==(s=r.seasons)?void 0:s.length)&&!(null==(a=r.episodes
90)?void 0:a.length))}}};function j$(e,t){return Array.from(new Set([...e??[],...t??[]]))}let jD={type:aM,isAnime:!1,title:"Sample Movie",titles:"Sample Movie, Sample Movie Alt Title",year:2024,yearEnd:void 0,season:void 0,episode:void 0,episodeTitles:"",genres:"Action, Thriller",runtime:120,episodeRuntime:void 0,absoluteEpisode:void 0,relativeAbsoluteEpisode:void 0,originalLanguage:"English",country:"US",latestSeason:void 0,daysSinceRelease:30,daysSinceFirstAired:void 0,daysSinceLastAired:void 0,hasNextEpisode:!1,daysUntilNextEpisode:void 0,anilistId:void 0,malId:void 0,hasSeaDex:!1},jL={scenario:"movie",filename:"Movie.Title.2023.2160p.BluRay.HEVC.DV.TrueHD.Atmos.7.1.iTA.ENG-GROUP.mkv",folderName:"Movie.Title.2023.2160p.BluRay.HEVC.DV.TrueHD.Atmos.7.1.iTA.ENG-GROUP",parsedFileOverrides:{},type:"debrid",serviceId:"none",cached:!0,addonName:"Torrentio",presetId:"custom",manifestUrl:"http://localhost:2000/manifest.json",indexer:"RARBG",seeders:125,age:"10d",duration:912e4,size:625e8,folderSize:125e9,bitrate:void 0,infoHash:"dd8255ecdc7ca55fb0bbf8
901323d87062db1f6d1c",message:"This is a message",library:!1,proxied:!1,private:!1,freeleech:!1,preloading:!1,metadata:jD,regexMatched:"",regexScore:25,maxRegexScore:50,rankedRegexMatched:"",seMatched:"",seScore:150,maxSeScore:100,rseMatched:"",seadex:!1,seadexBest:!1},jO=["stream.filename","stream.folderName"],jU=["stream.type","stream.indexer","stream.seeders","stream.age","stream.ageHours","stream.duration","stream.size","stream.folderSize","stream.bitrate","stream.infoHash","stream.message","stream.library","stream.private","stream.freeleech","stream.proxied","stream.preloading","service.id","service.name","service.shortName","service.cached","addon.name","addon.presetId","addon.manifestUrl"],jF=["stream.regexMatched","stream.regexScore","stream.nRegexScore","stream.rankedRegexMatched","stream.seMatched","stream.seScore","stream.nSeScore","stream.rseMatched","stream.seadex","stream.seadexBest"],jz={source:jO,stream:jU,scoring:jF,metadata:[],parsed:[]},jV=[{id:"movie",label:"Movie",input:{}},{id:"series",label:"Series episode",input:{filename:"Series.Title.S02E05.The.Episode.Name.1080p.WEB-DL.DDP5.1.H.264-GROUP.mkv",folderName:"Series.Title.S02.1080p.WEB-DL.DDP5.1.H.264-GROUP",size:35e8,folderSize:35e9,duration:27e5,metadata:{type:aP,title:"Series Title",titles:"Series Title, Series Title (US)",year:2019,yearEnd:2024,season:2,episode:5,episodeTitles:"The Episode Name",genres:"Drama, Mystery",runtime:3e3,episodeRuntime:45,latestSeason:4,daysSinceRelease:2,daysSinceFirstAired:1830,daysSinceLastAired:2,hasNextEpisode:!0,daysUntilNextEpisode:5}}},{id:"anime",label:"Anime episode",input:{filename:"[SubsPlease] Anime Title - 13 (1080p) [A1B2C3D4].mkv",folderName:"[SubsPlease] Anime Title (01-24) (1080p)",size:14e8,folderSize:336e8,duration:144e4,seadex:!0,metadata:{type:aP,isAnime:!0,title:"Anime Title",titles:"Anime Title, ã¢ãã¡ã¿ã¤ãã«",year:2024,season:2,episode:1,absoluteEpisode:13,relativeAbsoluteEpisode:1,episodeTitles:"The Episode Name",genres:"Action, Fantasy",originalLanguage:"Japanese",country:"JP",runtime:576,episodeRuntime:24,anilistId:21,malId:21,hasSeaDex:!0,daysSinceRelease:1,hasNextEpisode:!0,daysUntilNextEpisode:7}}},{id:"season-pack",label:"Season pack",input:{filename:"Series.Title.S02.COMPLETE.2160p.WEB-DL.DV.HDR10.DDP5.1.H.265-GROUP",size:84e9,folderSize:84e9,duration:void 0,type:"p2p",seeders:42,metadata:{type:aP,title:"Series Title",titles:"Series Title",year:2019,season:2,genres:"Drama, Mystery",latestSeason:4,daysSinceRelease:400}}},{id:"usenet",label:"Usenet release",input:{filename:"Movie.Title.2023.2160p.UHD.BluRay.REMUX.DV.HDR.TrueHD.7.1.Atmos-GROUP.mkv",folderName:"Movie.Title.2023.2160p.UHD.BluRay.REMUX.DV.HDR.TrueHD.7.1.Atmos-GROUP",type:"usenet",serviceId:"aiostreams",indexer:"NZBGeek",addonName:"Newznab",age:"400d",seeders:void 0,size:82e9,folderSize:82e9}}],jq="aiostreams:formatter-preview";function jB(){try{var e,t;let s=localStorage.getItem(jq);if(!s)return jL;let a=JSON.parse(s);if((null==a?void 0:a.version)!==2)return jL;return{...jL,...a.input,metadata:{...jD,...null==(e=a.input)?void 0:e.metadata},parsedFileOverrides:(null==(t=a.input)?void 0:t.parsedFileOverrides)??{}}}catch{return jL}}function jK(e){try{return new URL(e),!0}catch{return!1}}function jH(e){return e.split(",").map(e=>e.trim()).filter(Boolean)}function jW(e){let t=function(e,t,s){if(!e&&!t)return;function a(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];for(let e of t)if(e&&e.length>0)return e}let r=(null==t?void 0:t.seasonPack)||(null==e?void 0:e.seasonPack),n=a(null==e?void 0:e.episodes,null==t?void 0:t.episodes),l=a(null==e?void 0:e.seasons,null==t?void 0:t.seasons),i=function(e,t){if(!e)return t;if(!t)return e;let s=["title","year","country","episodeTitle","seasons","episodes","resolution","quality","encode","releaseGroup","editions","regraded","repack","proper","uncensored","unrated","upscaled","network","container","extension","visualTags","audioTags","audioChannels","languages","subtitles","seasonPack"];return s.reduce((t,s)=>t+ +!!e[s],0)>=s.reduce((e,s)=>e+ +!!t[s],0)?e:t}(e,t);
90return{title:(null==i?void 0:i.title)||(null==t?void 0:t.title)||(null==e?void 0:e.title),year:(null==e?void 0:e.year)||(null==t?void 0:t.year),country:(null==e?void 0:e.country)||(null==t?void 0:t.country),episodeTitle:(null==e?void 0:e.episodeTitle)||(null==t?void 0:t.episodeTitle),folderSeasons:l!==(null==t?void 0:t.seasons)?null==t?void 0:t.seasons:void 0,folderEpisodes:n!==(null==t?void 0:t.episodes)?null==t?void 0:t.episodes:void 0,seasons:l,episodes:n,date:(null==e?void 0:e.date)||(null==t?void 0:t.date),resolution:(null==e?void 0:e.resolution)||(null==t?void 0:t.resolution),quality:(null==e?void 0:e.quality)||(null==t?void 0:t.quality),encode:(null==e?void 0:e.encode)||(null==t?void 0:t.encode),releaseGroup:(null==e?void 0:e.releaseGroup)||(null==t?void 0:t.releaseGroup),editions:j$(null==t?void 0:t.editions,null==e?void 0:e.editions),regraded:(null==e?void 0:e.regraded)||(null==t?void 0:t.regraded),repack:(null==e?void 0:e.repack)||(null==t?void 0:t.repack),proper:(null==e?void 0:e.proper)||(null==t?void 0:t.proper),uncensored:(null==e?void 0:e.uncensored)||(null==t?void 0:t.uncensored),unrated:(null==e?void 0:e.unrated)||(null==t?void 0:t.unrated),upscaled:(null==e?void 0:e.upscaled)||(null==t?void 0:t.upscaled),network:(null==e?void 0:e.network)||(null==t?void 0:t.network),site:(null==e?void 0:e.site)||(null==t?void 0:t.site),container:(null==e?void 0:e.container)||(null==t?void 0:t.container),extension:(null==e?void 0:e.extension)||(null==t?void 0:t.extension),visualTags:j$(null==t?void 0:t.visualTags,null==e?void 0:e.visualTags),audioTags:j$(null==t?void 0:t.audioTags,null==e?void 0:e.audioTags),audioChannels:j$(null==t?void 0:t.audioChannels,null==e?void 0:e.audioChannels),languages:j$(null==t?void 0:t.languages,null==e?void 0:e.languages),subtitles:j$(null==t?void 0:t.subtitles,null==e?void 0:e.subtitles),audioTracks:(null==e?void 0:e.audioTracks)??(null==t?void 0:t.audioTracks),subtitleTracks:(null==e?void 0:e.subtitleTracks)??(null==t?void 0:t.subtitleTracks),subbed:(null==e?void 0:e.subbed)||(null==t?void 0:t.subbed)||!1,dubbed:(null==e?void 0:e.dubbed)||(null==t?void 0:t.dubbed)||!1,seasonPack:r,...s}}(e.filename?jP.parse(e.filename):void 0,e.folderName?jP.parse(e.folderName):void 0,e.parsedFileOverrides);if(t){var s,a;return s={size:e.size,folderSize:e.folderSize},!t.seasonPack&&(null==(a=t.episodes)?void 0:a.length)&&(s.folderSize&&s.size&&s.folderSize>2*s.size?t.seasonPack=!0:t.episodes.length>5&&(t.seasonPack=!0)),t}}function jG(e){return e.size&&e.duration?Math.floor(8*e.size/(e.duration/1e3)):void 0}function jY(e){return void 0===e||""===e?null:e}function jJ(e){let t=jH(e);return t.length?t:null}async function jZ(e,t,s){let a,r,n,l,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:jB(),o=Object.fromEntries(Object.entries({type:r=jY((a=i.metadata).type),queryType:r?a.isAnime?`anime.${r}`:r:null,isAnime:a.isAnime,title:jY(a.title),titles:jJ(a.titles),year:jY(a.year),yearEnd:jY(a.yearEnd),season:jY(a.season),episode:jY(a.episode),episodeTitles:jJ(a.episodeTitles),genres:jJ(a.genres),runtime:jY(a.runtime),episodeRuntime:jY(a.episodeRuntime),absoluteEpisode:jY(a.absoluteEpisode),relativeAbsoluteEpisode:jY(a.relativeAbsoluteEpisode),originalLanguage:jY(a.originalLanguage),country:jY(a.country),latestSeason:jY(a.latestSeason),daysSinceRelease:jY(a.daysSinceRelease),daysSinceFirstAired:jY(a.daysSinceFirstAired),daysSinceLastAired:jY(a.daysSinceLastAired),hasNextEpisode:a.hasNextEpisode,daysUntilNextEpisode:jY(a.daysUntilNextEpisode),anilistId:jY(a.anilistId),malId:jY(a.malId),hasSeaDex:a.hasSeaDex,maxRegexScore:jY(i.maxRegexScore),maxSeScore:jY(i.maxSeScore)}).map(e=>{let[t,s]=e;return[t,s??void 0]}));return jj.fromConfig(e,{...o,userData:t,addonName:s}).format((n=jW(i),l=i.bitrate??jG(i),{id:"preview",type:i.type,addon:{name:i.addonName,preset:{type:i.presetId,id:i.presetId,options:{}},enabled:!0,manifestUrl:jK(i.manifestUrl)?i.manifestUrl:jL.manifestUrl,timeout:1e4},library:i.library,parsedFile:n,filename:i.filename,folderName:i.folderName,folderSize:i.folderSize,indexer:i.indexer,regexMatched:{name:i.regexMatched||void 0,index:0}
90,torrent:{infoHash:"p2p"===i.type&&i.infoHash||void 0,seeders:i.seeders,private:i.private,freeleech:i.freeleech},service:"none"===i.serviceId?void 0:{id:i.serviceId,cached:i.cached},age:function(e){let t=e.match(/^(\d+)([a-zA-Z])$/);if(!t)return;let s=parseInt(t[1],10);switch(t[2].toLowerCase()){case"d":return 24*s;case"h":return s;case"m":return s/60;case"y":return 24*s*365;default:return}}(i.age),duration:i.duration,size:i.size,bitrate:l,proxied:i.proxied,preloading:i.preloading,message:i.message,seadex:{isSeadex:i.seadex,isBest:i.seadex&&i.seadexBest},streamExpressionScore:i.seScore,streamExpressionMatched:i.seMatched?{name:i.seMatched,index:0}:void 0,rankedStreamExpressionsMatched:jH(i.rseMatched),regexScore:i.regexScore,rankedRegexesMatched:jH(i.rankedRegexMatched)}))}function jQ(e,t){let{userData:s}=ri(),{status:a}=tj(),r=null==a?void 0:a.settings.addonName,[n,l]=(0,u.useState)({}),i=(0,u.useMemo)(()=>jB(),[t]);return(0,u.useEffect)(()=>{if(!t)return;if(0===Object.keys(e).length)return void l(e=>0===Object.keys(e).length?e:{});let a=!1;return(async()=>{let t=await Promise.all(Object.entries(e).map(async e=>{let[t,a]=e;try{return[t,await jZ(a,s,r,i)]}catch(e){return[t,{error:e instanceof Error?e.message:String(e)}]}}));a||l(Object.fromEntries(t))})(),()=>{a=!0}},[e,t,s,r,i]),n}let jX=[],j0=[],j1={approved:"bg-green-500/20 text-green-400 border-green-500/30",pending:"bg-yellow-400/20 text-yellow-400 border-yellow-400/30",rejected:"bg-red-400/20 text-red-300 border-red-400/30"};function j2(e,t){return(0,i.jsx)("span",{className:x("text-xs px-2 py-0.5 rounded border whitespace-nowrap",e),children:t})}function j3(e){var t;let s,{enabled:a,onInstall:r}=e,n=(0,e3.jE)(),{userData:l,uuid:o,password:d}=ri(),{status:c}=tj(),h=(null==c||null==(t=c.settings.community)?void 0:t.formatters)??"off",p=o?{uuid:o,password:d}:null,[g,f]=(0,u.useState)(!1),[b,y]=(0,u.useState)(""),[j,w]=(0,u.useState)(null),[N,k]=(0,u.useState)(null),S=(0,ty.I)({...(s="formatter",(0,e4.j)({queryKey:[...tf,s],queryFn:()=>eO(s),staleTime:6e4,retry:!1})),enabled:a&&"off"!==h}),C=(0,ty.I)({...tv(p),enabled:a&&g&&!!p}),_=S.data??jX,A=(0,u.useMemo)(()=>(C.data??j0).filter(e=>"formatter"===e.kind),[C.data]),R=(0,u.useMemo)(()=>{let e=new Map;
90for(let t of _)for(let s of t.tags??[])e.set(s,(e.get(s)??0)+1);return[...e.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(e=>{let[t]=e;return t})},[_]),T=(0,u.useMemo)(()=>{let e=b.trim().toLowerCase();return _.filter(t=>(!j||!!(t.tags??[]).includes(j))&&(!e||[t.name,t.description,t.author,...t.tags??[]].join(" ").toLowerCase().includes(e)))},[_,b,j]),I=jQ((0,u.useMemo)(()=>{let e={};for(let t of[..._,...A])e[`community:${t.id}`]=t.payload;return e},[_,A]),a),E=()=>{n.invalidateQueries({queryKey:tf}),n.invalidateQueries({queryKey:tb})},M=(0,e5.n)({mutationFn:e=>eK(p,e),onSuccess:E,onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to like")}),P=(0,e5.n)({mutationFn:e=>eq(p,e),onSuccess:()=>{m.oR.success("Update withdrawn"),E()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to withdraw")}),$=(0,e5.n)({mutationFn:e=>eB(p,e),onSuccess:()=>{m.oR.success("Removed from the community"),E()},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed to delete")});if("off"===h)return(0,i.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"Community formatters are turned off on this instance."});let D="Create or load your configuration (UUID and password) first; sharing and likes are tied to it",L=(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",leftIcon:(0,i.jsx)(pU.A,{className:"w-4 h-4"}),disabled:!p,onClick:()=>k({}),children:"Share current formatter"});return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)("p",{className:"text-xs text-[--muted] flex-1 min-w-[12rem]",children:"approval"===h?"Submissions are reviewed by an admin before they appear here.":"Anyone with a saved configuration can share a formatter here."}),p&&(0,i.jsx)(v,{size:"sm",intent:g?"primary":"gray-outline",onClick:()=>f(e=>!e),children:"Mine"}),p?L:(0,i.jsx)(t5,{trigger:(0,i.jsx)("span",{children:L}),children:D})]}),!g&&_.length>0&&(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(K,{value:b,onValueChange:y,placeholder:"Search by name, author or tag",leftIcon:(0,i.jsx)(mX.A,{className:"w-4 h-4"}),className:"text-sm"}),R.length>0&&(0,i.jsx)("div",{className:"flex flex-wrap gap-1.5",children:R.map(e=>(0,i.jsx)("button",{type:"button",onClick:()=>w(j===e?null:e),className:x("text-xs px-2 py-0.5 rounded-full border transition-colors",j===e?"border-[--brand] bg-brand/10 text-[--brand]":"bg-gray-800/60 border-gray-700 text-gray-300 hover:border-gray-500"),children:e},e))})]}),g?(0,i.jsx)(j4,{items:A,loading:C.isPending,previews:I,onUpdate:e=>k({existing:e}),onWithdraw:e=>P.mutate(e.id),onDelete:e=>$.mutate(e.id)}):S.isPending?(0,i.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"Loading..."}):0===_.length?(0,i.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"Nothing shared yet. Be the first."}):0===T.length?(0,i.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"No formatters match this filter."}):(0,i.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[560px] overflow-y-auto pr-2",children:T.map(e=>(0,i.jsx)(jc,{title:e.name,description:e.description||`by ${e.author}`,preview:I[`community:${e.id}`],badge:(0,i.jsxs)(i.Fragment,{children:[e.federated&&j2("bg-gray-500/20 text-gray-300 border-gray-500/30",`From ${e.origin}`),j2("bg-gray-800 text-gray-400 border-gray-700",`v${e.version}`)]}),tags:e.tags,actions:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",onClick:()=>r(e.name,e.payload),children:"Install"}),(0,i.jsxs)("span",{className:"text-xs text-[--muted] truncate",children:["by ",e.author]}),(0,i.jsx)("div",{className:"ml-auto",children:(0,i.jsx)(j5,{item:e,disabledReason:e.federated?"Likes only work for items published on this instance":p?void 0:D,pending:M.isPending,onClick:()=>M.mutate(e.id)})})]})},e.id))}),p&&N&&(0,i.jsx)(jg,{open:!0,onOpenChange:e=>!e&&k(null),credentials:p,definition:ji(l),existing:N.existing,moderated:"approval"===h})]})}function j5(e){let{item:t,disabledReason:s,pending:a,onClick:r}=e,n=(0,i.jsxs)("button",{type:"button",disabled:!!s||a,onClick:r,className:x("flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs transition-colors",s?"border-gray-800 text-gray-500 cursor-not-allowed":"border-pink-500/30 text-pink-300 hover:bg-pink-500/10"),children:[(0,i.jsx)(pL.A,{className:"w-3.5 h-3.5"}),t.likes]});return s?(0,i.jsx)(t5,{trigger:(0,i.jsx)("span",{children:n}),children:s}):n}function j4(e){let{items:t,loading:s,previews:a,onUpdate:r,onWithdraw:n,onDelete:l}=e;return s?(0,i.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"Loading..."}):0===t.length?(0,i.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"You have not shared a formatter yet."}):(0,i.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[560px] overflow-y-auto pr-2",children:t.map(e=>(0,i.jsx)(j6,{item:e,preview:a[`community:${e.id}`],onUpdate:()=>r(e),onWithdraw:()=>n(e),onDelete:()=>l(e)},e.id))})}function j6(e){let{item:t,preview:s,onUpdate:a,onWithdraw:r,onDelete:n}=e,l=sd({title:"Remove shared formatter",description:`Remove "${t.name}" from the community? People who installed it keep their copy.`,actionText:"Remove",actionIntent:"alert-subtle",onConfirm:n}),o=t.draftRejectionReason??t.rejectionReason;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(sc,{...l}),(0,i.jsx)(jc,{title:t.name,description:(0,i.jsxs)(i.Fragment,{children:["v",t.version,t.likes>0&&` \xb7 ${t.likes} likes`,o&&(0,i.jsxs)("span",{className:"block text-red-200 mt-0.5",children:[t.draftRejectionReason?"Update rejected: ":"Rejected: ",o]})]}),preview:s,tags:t.tags,badge:(0,i.jsxs)(i.Fragment,{children:[j2(j1[t.status],t.status),t.draft&&j2(j1.pending,`v${t.draft.version} pending review`)]}),actions:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{size:"sm",intent:"primary-subtle",leftIcon:(0,i.jsx)(hZ.A,{className:"w-3.5 h-3.5"}),onClick:a,children:"Update with current"}),(0,i.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[t.draft&&(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,i.jsx)(hQ.A,{className:"h-3.5 w-3.5"}),onClick:r}),children:"Withdraw pending update"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"alert-subtle",icon:(0,i.jsx)(hX.A,{className:"h-3.5 w-3.5"}),onClick:l.open}),children:"Remove from community"})]})]})})]})}let j9=[sK,sJ,sZ,sH,sW,sG,sY,sQ].filter(e=>e!==sQ);function j8(e){let{open:t,onOpenChange:s,onSelectBuiltin:a,onSelectSaved:r,onSelectCustom:n,onSaveCurrent:l,onRename:o,onDelete:d,onInstall:c}=e,{userData:m}=ri(),[h,p]=(0,u.useState)("builtin"),x=m.formatter.id,g=m.formatter.definitions,f=null==g?void 0:g.overrides,b=null==g?void 0:g.saved,y=null==g?void 0:g.custom,j=jo(m),w=x===sQ&&!j,N=jQ((0,u.useMemo)(()=>{let e={};for(let t of j9){let s=(null==f?void 0:f[t])??va[t];
90s&&(e[t]=s)}for(let[t,s]of Object.entries(b??{}))e[`saved:${t}`]=s;return y&&(e.custom=y),e},[f,b,y]),t),k=(0,i.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[560px] overflow-y-auto pr-2",children:[j9.map(e=>{let t=sX[e],s=x===e,r=!!(null==f?void 0:f[e]);return(0,i.jsx)(jc,{title:t.name,description:t.description,preview:N[e],active:s,badge:r?(0,i.jsx)("span",{className:"text-xs bg-yellow-400/20 text-yellow-400 px-2 py-0.5 rounded border border-yellow-400/30",children:"Customised"}):void 0,actions:(0,i.jsx)(v,{size:"sm",intent:s?"gray-outline":"primary-subtle",disabled:s,onClick:()=>a(e),children:s?"In use":"Use"})},e)}),(0,i.jsx)(jc,{title:sX[sQ].name,description:sX[sQ].description,preview:y?N.custom:{name:"Start from the active formatter",description:""},active:w,actions:(0,i.jsx)(v,{size:"sm",intent:w?"gray-outline":"primary-subtle",disabled:w,onClick:n,children:w?"In use":"Use"})})]}),S=[{value:"builtin",label:"Built-in",icon:(0,i.jsx)(bd.A,{className:"w-4 h-4"}),content:k},{value:"saved",label:`Saved (${Object.keys(b??{}).length})`,icon:(0,i.jsx)(jl.A,{className:"w-4 h-4"}),content:(0,i.jsx)(jh,{saved:b??{},previews:N,activeName:j,onSelect:r,onSaveCurrent:l,onRename:o,onDelete:d})},{value:"community",label:"Community",icon:(0,i.jsx)(bm.A,{className:"w-4 h-4"}),content:(0,i.jsx)(j3,{enabled:t&&"community"===h,onInstall:c})}];return(0,i.jsx)(sl,{open:t,onOpenChange:s,title:"Formatters",description:"Pick a built-in formatter, one you saved, or one shared by the community. Previews use the sample from the preview panel.",contentClass:"max-w-5xl w-full",children:(0,i.jsx)(mv,{tabs:S,activeTab:h,onTabChange:p,animated:!1})})}var j7=s(34670),we=s(87903);let wt={builtin:{label:"Built-in",icon:bd.A,badge:"bg-green-500/20 text-green-400 border-green-500/30"},customised:{label:"Customised",icon:bd.A,badge:"bg-yellow-400/20 text-yellow-400 border-yellow-400/30"},saved:{label:"Saved",icon:jl.A,badge:"bg-sky-500/20 text-sky-300 border-sky-500/30"},custom:{label:"Custom",icon:j7.A,badge:"bg-purple-500/20 text-purple-300 border-purple-500/30"}};function ws(e){let{name:t,kind:s,detail:a,onOpen:r}=e,{label:n,icon:l,badge:o}=wt[s];return(0,i.jsxs)("button",{type:"button",onClick:r,"aria-haspopup":"dialog",className:x("group/picker flex w-full items-center gap-3 rounded-lg border border-gray-800 bg-gray-900/60 px-3 py-3 text-left sm:px-4","transition-colors hover:border-gray-600 hover:bg-gray-900","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[--ring] ring-offset-2 ring-offset-[--background]"),children:[(0,i.jsx)("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-brand-500/20 bg-brand-500/10 text-[--brand]",children:(0,i.jsx)(l,{className:"h-5 w-5"})}),(0,i.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,i.jsxs)("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[(0,i.jsx)("span",{className:"truncate text-sm font-semibold text-[--foreground]",children:t}),(0,i.jsx)("span",{className:x("shrink-0 rounded-full border px-2 py-0.5 text-xs font-medium",o),children:n})]}),a&&(0,i.jsx)("span",{className:"mt-0.5 block text-xs text-[--muted] line-clamp-2",children:a})]}),(0,i.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5 text-xs font-medium text-[--muted] transition-colors group-hover/picker:text-[--brand]",children:[(0,i.jsx)("span",{className:"hidden sm:inline",children:"Change"}),(0,i.jsx)(we.A,{className:"h-4 w-4"})]})]})}var wa=s(8170),wr=s(80757),wn=s(25611),wl=s(57216);function wi(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:44,s=e.replace(/\s+/g," ").trim();return s.length>t?`${s.slice(0,t-1)}â¦`:s}let wo={expression:(0,i.jsx)(wa.A,{className:"w-3.5 h-3.5 text-[--sky]"}),group:(0,i.jsx)(bd.A,{className:"w-3.5 h-3.5 text-[--violet]"}),branch:(0,i.jsx)(wr.A,{className:"w-3.5 h-3.5 text-[--amber]"}),tool:(0,i.jsx)(wn.A,{className:"w-3.5 h-3.5 text-[--teal]"})};function wd(e){let{item:t,depth:s,onJump:a}=e,[r,n]=(0,u.useState)(s<2),l=t.children.length>0;return(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center gap-1 rounded px-1 py-0.5 hover:bg-[--subtle] cursor-pointer text-xs",style:{paddingLeft:`${12*s+4}px`},children:[l?(0,i.jsx)("button",{type:"button",onClick:()=>n(e=>!e),className:"shrink-0 text-[--muted] hover:text-[--foreground]",children:r?(0,i.jsx)(mt.A,{className:"w-3.5 h-3.5"}):(0,i.jsx)(wl.A,{className:"w-3.5 h-3.5"})}):(0,i.jsx)("span",{className:"w-3.5 shrink-0"}),wo[t.kind],(0,i.jsx)("button",{type:"button",onClick:()=>a(t),className:"min-w-0 truncate font-mono text-left text-[--muted-highlight] hover:text-[--foreground]",title:"Jump to this part of the template",children:t.label})]}),l&&r&&(0,i.jsx)("div",{children:t.children.map((e,t)=>(0,i.jsx)(wd,{item:e,depth:s+1,onJump:a},t))})]})}function wc(e){let{template:t,getView:s}=e,[a,r]=(0,u.useState)(!1),n=(0,u.useMemo)(()=>(function e(t,s){let a=[];for(let r of t){if("raw"===r.kind)continue;let t=(r.start??0)+s,n=(r.end??0)+s;if("tool"===r.kind)a.push({label:`{tools.${r.tool}}`,from:t,to:n,kind:"tool",children:[]});else if("group"===r.kind)a.push({label:"optional group",from:t,to:n,kind:"group",children:e(r.nodes,s)});else if("expression"===r.kind){let s=[];if(r.check)for(let[t,a,n]of[["true",r.check.trueTemplate,r.check.trueStart],["false",r.check.falseTemplate,r.check.falseStart],["absent",r.check.absentTemplate,r.check.absentStart]])void 0!==a&&void 0!==n&&s.push({label:`${t}: "${wi(a,28)}"`,from:n,to:n+a.length,kind:"branch",children:e(yU(a).nodes,n)});a.push({label:wi(r.source),from:t,to:n,kind:"expression",children:s})}}return a})(yU(t).nodes,0),[t]),l=e=>{let t=s();if(!t)return;let a=t.state.doc.length;t.dispatch({selection:{anchor:Math.min(e.from,a),head:Math.min(e.to,a)},scrollIntoView:!0}),t.focus()};return 0===n.length?null:(0,i.jsxs)("div",{className:"mt-1.5",children:[(0,i.jsxs)("button",{type:"button",onClick:()=>r(e=>!e),className:"flex items-center gap-1 text-xs text-[--muted] hover:text-[--foreground]",children:[a?(0,i.jsx)(mt.A,{className:"w-3.5 h-3.5"}):(0,i.jsx)(wl.A,{className:"w-3.5 h-3.5"}),"Structure (",n.length,")"]}),a&&(0,i.jsx)("div",{className:"mt-1 max-h-56 overflow-y-auto rounded-md border border-[--border] bg-[--subtle] p-1",children:n.map((e,t)=>(0,i.jsx)(wd,{item:e,depth:0,onJump:l},t))})]})}let wu="aiostreams:formatter-simple-editor";function wm(){try{return"1"===localStorage.getItem(wu)}catch{return!1}}function wh(e,t,s){var a,r;let n=e.formatter.id;if(n===sQ){let a=jo(e);return a?{...e,formatter:{...e.formatter,definitions:{...e.formatter.definitions,saved:{...null==(r=e.formatter.definitions)?void 0:r.saved,[a]:{name:t,description:s}}}}}:{...e,formatter:{...e.formatter,definitions:{...e.formatter.definitions,custom:{
90name:t,description:s}}}}}let l=va[n],i=!!l&&t===l.name&&s===l.description,o={...(null==(a=e.formatter.definitions)?void 0:a.overrides)??{}};return i?delete o[n]:o[n]={name:t,description:s},{...e,formatter:{...e.formatter,definitions:{...e.formatter.definitions,overrides:Object.keys(o).length>0?o:void 0}}}}function wp(){var e,t,s;let{userData:a,setUserData:r}=ri(),n=so(!1),l=so(!1),o=(0,u.useRef)(null),d=(0,u.useRef)(null),c=(0,u.useRef)(null),[h,p]=(0,u.useState)(wm);function x(e,t,s,a){return h?(0,i.jsx)(ly,{value:e,onValueChange:t,placeholder:s}):(0,i.jsx)(jr,{value:e,onValueChange:t,placeholder:s,onViewReady:e=>a.current=e,onFocusView:e=>c.current=e})}(0,u.useEffect)(()=>{try{localStorage.setItem(wu,h?"1":"0")}catch{}},[h]);let g=a.formatter.id,f=a.formatter.definitions,{name:b,description:y}=ji(a),j=g===sQ,N=!j&&!!(null==f||null==(e=f.overrides)?void 0:e[g]),k=jo(a),S=j||!!va[g],C=k?{name:k,kind:"saved",detail:"Saved in your config. Edits below update it in place."}:j?{name:"Custom",kind:"custom",detail:"Your own templates, edited below."}:{name:(null==(t=sX[g])?void 0:t.name)??g,kind:N?"customised":"builtin",detail:null==(s=sX[g])?void 0:s.description};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(mK,{title:"Formatter Selection",id:"formatter",description:"Pick a built-in, saved or community formatter, then tune its templates below",children:[(0,i.jsx)(ws,{...C,onOpen:l.open}),S&&(0,i.jsxs)("div",{className:"space-y-4 mt-4",children:[(0,i.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,i.jsxs)("div",{className:"text-sm text-gray-400",children:["Type ",(0,i.jsx)("span",{className:"font-mono",children:"{debug.jsonf}"})," to see all available variables. See the"," ",(0,i.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/custom-formatter",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:text-[--brand]/80 hover:underline",children:"docs"})," ","for a full reference."]}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{rounded:!0,size:"sm",intent:"primary-subtle",className:"shrink-0",icon:h?(0,i.jsx)(bx.A,{className:"w-4 h-4"}):(0,i.jsx)(vs.A,{className:"w-4 h-4"}),onClick:()=>p(e=>!e)}),children:h?"Switch to the rich editor":"Switch to a plain textarea"})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{className:"text-sm font-medium mb-2 block",children:"Name Template"}),x(b,e=>r(t=>wh(t,e,ji(t).description)),"Enter a template for the stream name",o),!h&&(0,i.jsx)(wc,{template:b,getView:()=>o.current})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{className:"text-sm font-medium mb-2 block",children:"Description Template"}),x(y,e=>r(t=>wh(t,ji(t).name,e)),"Enter a template for the stream description",d),!h&&(0,i.jsx)(wc,{template:y,getView:()=>d.current})]}),(0,i.jsxs)("div",{className:"flex gap-2 items-center flex-wrap",children:[(0,i.jsx)(jn,{onInsert:h?void 0:function(e){let t=c.current;return!!t&&(t.dispatch(t.state.replaceSelection(e)),t.focus(),!0)}}),N&&(0,i.jsx)(v,{intent:"white",size:"sm",onClick:function(){r(e=>{var t;let s=e.formatter.id,a={...(null==(t=e.formatter.definitions)?void 0:t.overrides)??{}};return delete a[s],{...e,formatter:{...e.formatter,definitions:{...e.formatter.definitions,overrides:Object.keys(a).length>0?a:void 0}}}})},children:"Reset to built-in"}),(0,i.jsxs)("div",{className:"ml-auto flex gap-2",children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(lZ.PiR,{}),onClick:n.open}),children:"Import"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,i.jsx)(lZ.Mbn,{}),onClick:function(){let e=new Blob([JSON.stringify({name:b,description:y},null,2)],{type:"application/json"}),t=URL.createObjectURL(e),s=document.createElement("a");s.href=t,s.download="formatter.json",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(t),m.oR.success("Formatter exported successfully")}}),children:"Export"})]})]})]})]}),(0,i.jsx)(xO,{open:n.isOpen,onOpenChange:n.toggle,onImport:function(e){"string"==typeof e.name&&"string"==typeof e.description?(r(t=>wh(t,e.name,e.description)),m.oR.success("Formatter imported successfully")):m.oR.error("Invalid formatter format")}}),(0,i.jsx)(j8,{open:l.isOpen,onOpenChange:l.toggle,onSelectBuiltin:function(e){r(t=>({...t,formatter:{...t.formatter,id:e,selectedSaved:void 0}})),l.close()},onSelectSaved:function(e){r(t=>{var s,a;return(null==(a=t.formatter.definitions)||null==(s=a.saved)?void 0:s[e])?{...t,formatter:{...t.formatter,id:sQ,selectedSaved:e}}:t}),l.close()},onSelectCustom:function(){r(e=>{var t;let s=(null==(t=e.formatter.definitions)?void 0:t.custom)??ji(e);return{...e,formatter:{...e.formatter,id:sQ,selectedSaved:void 0,definitions:{...e.formatter.definitions,custom:s}}}}),l.close()},onSaveCurrent:function(e){let t=e.trim();t?(r(e=>{var s;let{name:a,description:r}=ji(e);return{...e,formatter:{...e.formatter,id:sQ,selectedSaved:t,definitions:{...e.formatter.definitions,saved:{...(null==(s=e.formatter.definitions)?void 0:s.saved)??{},[t]:{name:a,description:r}}}}}}),m.oR.success(`Saved and switched to "${t}"`)):m.oR.error("Please enter a name")},onRename:function(e,t){var s;let a=t.trim();if(!a)return void m.oR.error("Name cannot be empty");if(a!==e){if(null==f||null==(s=f.saved)?void 0:s[a])return void m.oR.error("A saved formatter with this name already exists");r(t=>{var s;let r=(null==(s=t.formatter.definitions)?void 0:s.saved)??{};if(!r[e])return t;let n=Object.entries(r).map(t=>{let[s,r]=t;return s===e?[a,r]:[s,r]});return{...t,formatter:{...t.formatter,selectedSaved:t.formatter.selectedSaved===e?a:t.formatter.selectedSaved,definitions:{...t.formatter.definitions,saved:Object.fromEntries(n)}}}}),m.oR.success("Saved formatter renamed")}},onDelete:function(e){r(t=>{var s,a;let r={...(null==(s=t.formatter.definitions)?void 0:s.saved)??{}},n=r[e];if(!n)return t;delete r[e];let l=jo(t)===e;return{...t,formatter:{...t.formatter,selectedSaved:l?void 0:t.formatter.selectedSaved,definitions:{...t.formatter.definitions,custom:l?n:null==(a=t.formatter.definitions)?void 0:a.custom,saved:Object.keys(r).length>0?r:void 0}}}}),m.oR.success("Saved formatter deleted")},onInstall:function(e,t){let s=e.trim()||"Community formatter";r(a=>{var r;let n=(null==(r=a.formatter.definitions)?void 0:r.saved)??{},l=2;for(;n[s];)s=`${e} (${l++})`;return{...a,formatter:{...a.formatter,id:sQ,selectedSaved:s,definitions:{...a.formatter.definitions,saved:{...n,[s]:{...t}}}}}}),l.close(),m.oR.success(`Installed as "${s}"`)}})]})}var wx=s(77090),wg=s(47198),wf=s(38498),wb=s(1142),wv=s(58749),wy=s(85227);class wj{enqueue(e){this.queue=[e],this.process()}async process(){if(!this.processing){for(this.processing=!0;this.queue.length>0;){let e=this.queue.shift();if(e){try{await e()}catch(e){console.error("Error in format queue:",e)}await new Promise(e=>setTimeout(e,this.delay))}}this.processing=!1}}constructor(e){(0,et._)(this,"queue",[]),(0,et._)(this,"processing",!1),(0,et._)(this,"delay",void 0),this.delay=e}}let ww=(0,u.createContext)({used:new Set,onlyUsed:!1});function wN(e){let{used:t,onlyUsed:s,children:a}=e,r=(0,u.useMemo)(()=>({used:t,onlyUsed:s}),[t,s]);return(0,i.jsx)(ww.Provider,{value:r,children:a})}function wk(e){return"string"==typeof e?[e]:e}function wS(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{used:s,onlyUsed:a}=(0,u.useContext)(ww),r=wk(e).some(e=>s.has(e));return{isUsed:r,visible:t||r||!a}}function wC(e){let{label:t,field:s,isUsed:a}=e,r=wk(s);return(0,i.jsxs)("span",{className:"flex items-center gap-1.5 min-w-0",children:[(0,i.jsx)("span",{className:"truncate",children:t}),a&&(0,i.jsx)("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-[--brand]",title:`Used by your template (${r.join(", ")})`})]})}
90function w_(e){let{cols:t=3,children:s}=e;return(0,i.jsx)("div",{className:x("grid grid-cols-1 gap-4",{2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"}[t]),children:s})}function wA(e){let{children:t}=e;return(0,i.jsx)("div",{className:"flex flex-wrap justify-center gap-x-6 gap-y-3 pt-1",children:t})}function wR(e){let{fields:t,children:s}=e,[a,r]=(0,u.useState)(""),n=function(e){let{used:t,onlyUsed:s}=(0,u.useContext)(ww);return s?e.filter(e=>wk(e).some(e=>t.has(e))).length:e.length}(t);return 0===n?null:(0,i.jsx)(uI,{type:"single",collapsible:!0,value:a,onValueChange:r,className:"pt-1",children:(0,i.jsxs)(uE,{value:"advanced",className:"border border-[--border] rounded-[--radius-md] overflow-hidden",children:[(0,i.jsxs)(uM,{className:"py-2 text-sm text-[--muted-highlight]",children:["Advanced (",n,")"]}),(0,i.jsx)(uP,{className:"space-y-4",children:s})]})})}function wT(e){let{children:t}=e;return(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:t})}function wI(e){let{field:t,label:s,help:a,disabled:r,always:n,value:l,onChange:o,placeholder:d,error:c}=e,{visible:u,isUsed:m}=wS(t,n);return u?(0,i.jsx)(K,{label:(0,i.jsx)(wC,{label:s,field:t,isUsed:m}),moreHelp:a,error:c,disabled:r,value:l,placeholder:d,onValueChange:e=>o(e??""),className:"w-full"}):null}function wE(e){let{field:t,label:s,help:a,disabled:r,value:n,onChange:l,min:o,max:d,step:c,placeholder:u}=e,{visible:m,isUsed:h}=wS(t);return m?(0,i.jsx)(lm,{label:(0,i.jsx)(wC,{label:s,field:t,isUsed:h}),moreHelp:a,disabled:r,allowEmpty:!0,value:n??"",placeholder:u,min:o,max:d,step:c,onValueChange:(e,t)=>
90l(""===t||Number.isNaN(e)?void 0:e),className:"w-full"}):null}function wM(e){let{field:t,label:s,help:a,disabled:r,value:n,onChange:l,options:o}=e,{visible:d,isUsed:c}=wS(t);return d?(0,i.jsx)(nc,{label:(0,i.jsx)(wC,{label:s,field:t,isUsed:c}),moreHelp:a,disabled:r,value:n,options:o,onValueChange:l,className:"w-full"}):null}function wP(e){let{field:t,label:s,help:a,disabled:r,value:n,onChange:l}=e,{visible:o,isUsed:d}=wS(t);return o?(0,i.jsx)(ni,{label:(0,i.jsx)(wC,{label:s,field:t,isUsed:d}),moreHelp:a,disabled:r,value:n,onValueChange:l}):null}function w$(e){let{field:t,label:s,help:a,disabled:r,value:n,onChange:l,placeholder:o}=e;return(0,i.jsx)(wI,{field:t,label:s,help:a??"Comma separated",disabled:r,value:n,onChange:l,placeholder:o})}function wD(e){let{input:t,patch:s}=e;return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(wI,{field:"stream.filename",label:"Filename",always:!0,value:t.filename,onChange:e=>s({filename:e})}),(0,i.jsx)(wI,{field:"stream.folderName",label:"Folder name",always:!0,value:t.folderName,onChange:e=>s({folderName:e})}),(0,i.jsx)(wT,{children:"Both names are parsed and merged exactly as they are for a real stream. Everything they produce is on the Parsed File tab, where you can also override it."})]})}let wL="__none__",wO="__auto__",wU=[{key:"title",label:"Title",field:"stream.title",kind:"text"},{key:"year",label:"Year",field:"stream.year",kind:"text"},{key:"seasons",label:"Seasons",field:["stream.seasons","stream.season","stream.formattedSeasons","stream.seasonEpisode"],kind:"numberList"},{key:"episodes",label:"Episodes",field:["stream.episodes","stream.episode","stream.formattedEpisodes","stream.seasonEpisode"],kind:"numberList"},{key:"resolution",label:"Resolution",field:"stream.resolution",kind:"enum",options:ak},{key:"quality",label:"Quality",field:"stream.quality",kind:"enum",options:aS},{key:"encode",label:"Encode",field:"stream.encode",kind:"enum",options:aR},{key:"releaseGroup",label:"Release group",field:"stream.releaseGroup",kind:"text"},{key:"visualTags",label:"Visual tags",field:"stream.visualTags",kind:"enumList",options:aC},{key:"audioTags",label:"Audio tags",field:"stream.audioTags",kind:"enumList",options:a_},{key:"audioChannels",label:"Audio channels",field:"stream.audioChannels",kind:"enumList",options:aA},{key:"languages",label:"Languages",field:["stream.languages","stream.uLanguages","stream.languageEmojis","stream.uLanguageEmojis","stream.languageCodes","stream.uLanguageCodes","stream.smallLanguageCodes","stream.uSmallLanguageCodes","stream.wedontknowwhatakilometeris","stream.uWedontknowwhatakilometeris"],kind:"enumList",options:aF},{key:"mediaInfoQuality",label:"Media info quality",field:"stream.mediaInfoQuality",kind:"enum",options:["probe","indexer","addon"],help:"Set when media info is confirmed, rather than guessed"},{key:"subtitles",label:"Subtitles",field:["stream.subtitles","stream.uSubtitles","stream.subtitleEmojis","stream.uSubtitleEmojis","stream.subtitleCodes","stream.uSubtitleCodes","stream.smallSubtitleCodes","stream.uSmallSubtitleCodes","stream.subbed"],kind:"enumList",options:aF,help:"Only media info fills this in, so overriding is the only way to preview it"},{key:"editions",label:"Editions",field:["stream.edition","stream.editions"],kind:"textList"},{key:"seasonPack",label:"Season pack",field:"stream.seasonPack",kind:"bool"}],wF=[{key:"audioTracks",label:"Audio tracks",field:"stream.audioTracks",kind:"tracks",help:'Only media info fills this in. A JSON array, e.g. [{"lang": "English", "codec": "truehd", "tag": "TrueHD", "channels": "7.1", "title": "Commentary", "commentary": true}]'},{key:"subtitleTracks",label:"Subtitle tracks",field:"stream.subtitleTracks",kind:"tracks",help:'Only media info fills this in. A JSON array, e.g. [{"lang": "English", "codec": "subrip", "title": "SDH", "hearingImpaired": true}]'},{key:"country",label:"Country",field:"stream.country",kind:"text"},{key:"episodeTitle",label:"Episode title",field:"stream.episodeTitle",kind:"text"},{key:"date",label:"Date",field:"stream.date",kind:"text"},{key:"folderSeasons",label:"Folder seasons",field:["stream.folderSeasons","stream.formattedFolderSeasons"],kind:"numberList"},{key:"folderEpisodes",label:"Folder episodes",field:["stream.folderEpisodes","stream.formattedFolderEpisodes"],kind:"numberList"},{key:"volumes",label:"Volumes",field:[],kind:"numberList",help:"Parsed but not exposed to templates"},{key:"network",label:"Network",field:"stream.network",kind:"text"},{key:"site",label:"Site",field:"stream.site",kind:"text"},{key:"container",label:"Container",field:"stream.container",kind:"text"},{key:"extension",label:"Extension",field:"stream.extension",kind:"text"},{key:"subbed",label:"Subbed",field:"stream.subbed",kind:"bool"},{key:"dubbed",label:"Dubbed",field:"stream.dubbed",kind:"bool"},{key:"regraded",label:"Regraded",field:"stream.regraded",kind:"bool"},{key:"repack",label:"Repack",field:"stream.repack",kind:"bool"},{key:"proper",label:"Proper",field:"stream.proper",kind:"bool"},{key:"uncensored",label:"Uncensored",field:"stream.uncensored",kind:"bool"},{key:"unrated",label:"Unrated",field:"stream.unrated",kind:"bool"},{key:"upscaled",label:"Upscaled",field:"stream.upscaled",kind:"bool"},{key:"hasChapters",label:"Has chapters",field:"stream.hasChapters",kind:"bool",help:"Only media info fills this in, so overriding is the only way to preview it"}];function wz(e){return null==e||""===e||Array.isArray(e)&&0===e.length}function wV(e,t){return!!(wz(e)&&wz(t))||(Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,s)=>e===t[s]):e===t)}function wq(e){return null==e?"":Array.isArray(e)?e.join(", "):String(e)}function wB(e){return Array.isArray(e)&&e.length?JSON.stringify(e,null,2):""}function wK(e){let{label:t,help:s,value:a,onChange:r}=e,n=wB(a),[l,o]=(0,u.useState)(n),[d,c]=(0,u.useState)(),m=(0,u.useRef)(n);return(0,u.useEffect)(()=>{n!==m.current&&(m.current=n,o(n),c(void 0))},[n]),(0,i.jsx)(ly,{label:t,moreHelp:s,error:d,value:l,placeholder:"Not detected",onValueChange:e=>{var t;o(e);let s=[];try{s=e.trim()?JSON.parse(e):[]}catch{c("Invalid JSON");return}Array.isArray(t=s)&&t.every(e=>"object"==typeof e&&null!==e&&!Array.isArray(e))?(c(void 0),m.current=wB(s),r(s)):c("E
90xpected an array of track objects")},className:"w-full font-mono text-xs"})}function wH(e){let t,{row:s,parsed:a,overrides:r,setOverride:n}=e,{visible:l,isUsed:o}=wS(s.field);if(!l)return null;let d=s.key in r,c=d?r[s.key]:null==a?void 0:a[s.key],u=(0,i.jsx)(wC,{label:s.label,field:s.field,isUsed:o});switch(s.kind){case"enum":t=(0,i.jsx)(nc,{label:u,moreHelp:s.help,value:null==c?wL:String(c),options:[{label:"Not detected",value:wL},...(s.options??[]).map(e=>({label:e,value:e}))],onValueChange:e=>n(s.key,e===wL?"":e),className:"w-full"});break;case"enumList":t=(0,i.jsx)(li,{label:u,moreHelp:s.help,multiple:!0,value:Array.isArray(c)?c.map(String):[],onValueChange:e=>n(s.key,e),options:(s.options??[]).map(e=>({label:e,value:e})),emptyMessage:"No matches",placeholder:"None",className:"w-full"});break;case"bool":t=(0,i.jsx)(nc,{label:u,moreHelp:s.help,value:d?String(c??!1):wO,options:[{label:`Auto (${(null==a?void 0:a[s.key])?"yes":"no"})`,value:wO},{label:"Yes",value:"true"},{label:"No",value:"false"}],onValueChange:e=>n(s.key,e===wO?void 0:"true"===e,!1),className:"w-full"});break;case"numberList":t=(0,i.jsx)(K,{label:u,moreHelp:s.help??"Comma separated",value:wq(c),placeholder:"Not detected",onValueChange:e=>n(s.key,jH(e??"").map(Number).filter(e=>!Number.isNaN(e))),className:"w-full"});break;case"textList":t=(0,i.jsx)(K,{label:u,moreHelp:s.help??"Comma separated",value:wq(c),placeholder:"Not detected",onValueChange:e=>n(s.key,jH(e??"")),className:"w-full"});break;case"tracks":t=(0,i.jsx)(wK,{label:u,help:s.help,value:c,onChange:e=>n(s.key,e)});break;default:t=(0,i.jsx)(K,{label:u,moreHelp:s.help,value:wq(c),placeholder:"Not detected",onValueChange:e=>n(s.key,e??""),className:"w-full"})}return(0,i.jsxs)("div",{className:x("flex items-end gap-1.5","tracks"===s.kind&&"sm:col-span-3"),children:[(0,i.jsx)("div",{className:"min-w-0 flex-1",children:t}),(0,i.jsx)(w,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,i.jsx)(wy.A,{className:"w-3.5 h-3.5"}),"aria-label":`Reset ${s.label}`,className:d?void 0:"invisible",onClick:()=>n(s.key,void 0)})]})}function wW(e){let{input:t,patch:s,parsed:a,effective:r}=e,[n,l]=(0,u.useState)(!1),o=t.parsedFileOverrides,d=Object.keys(o).length,c=function(e,t){let r,n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],l={...o};void 0===t||n&&wV(t,null==a?void 0:a[e])?delete l[e]:l[e]=t,(r=Object.keys(l)).length===Object.keys(o).length&&r.every(e=>wV(l[e],o[e]))||s({parsedFileOverrides:l})};return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:d>0?`${d} override${1===d?"":"s"} applied on top of the parser`:"Straight from the parser. Editing any value overrides it."}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsxs)(v,{size:"sm",intent:"gray-subtle",onClick:()=>l(e=>!e),children:[n?"Hide":"Show"," raw JSON"]}),(0,i.jsx)(v,{size:"sm",intent:"alert-subtle",disabled:0===d,onClick:()=>s({parsedFileOverrides:{}}),children:"Clear overrides"})]})]}),n&&(0,i.jsx)("pre",{className:"max-h-72 overflow-auto rounded-md border border-[--border] bg-[--subtle] p-3 text-xs",children:JSON.stringify(r??null,null,2)}),(0,i.jsx)(w_,{cols:3,children:wU.map(e=>(0,i.jsx)(wH,{row:e,parsed:a,overrides:o,setOverride:c},e.key))}),(0,i.jsx)(wR,{fields:wF.map(e=>e.field),children:(0,i.jsx)(w_,{cols:3,children:wF.map(e=>(0,i.jsx)(wH,{row:e,parsed:a,overrides:o,setOverride:c},e.key))})}),(0,i.jsx)(wT,{children:"Overrides stand in for the media info the engine folds in at this same point, which is the only source for subtitles and chapters."})]})}let wG=["service.id","service.name","service.shortName"],wY=["stream.infoHash","stream.bitrate","addon.presetId","addon.manifestUrl"];function wJ(e){let{input:t,patch:s}=e,a="none"===t.serviceId,r=jG(t);return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)(w_,{cols:3,children:[(0,i.jsx)(wM,{field:"stream.type",label:"Stream type",value:t.type,onChange:e=>s({type:e}),options:aE.map(e=>({label:e.charAt(0).toUpperCase()+e.slice(1),value:e}))}),(0,i.jsx)(wM,{field:wG,label:"Service",value:t.serviceId,onChange:e=>s({serviceId:e}),options:[{label:"None",value:"none"},...Object.values(ap).map(e=>({label:e.name,value:e.id}))]}),(0,i.jsx)(wI,{field:"addon.name",label:"Addon name",value:t.addonName,onChange:e=>s({addonName:e})}),(0,i.jsx)(wI,{field:"stream.indexer",label:"Indexer",value:t.indexer,onChange:e=>s({indexer:e})}),(0,i.jsx)(wE,{field:"stream.seeders",label:"Seeders",value:t.seeders,onChange:e=>s({seeders:e}),min:0}),(0,i.jsx)(wI,{field:["stream.age","stream.ageHours"],label:"Age",help:"e.g. 30m, 12h, 10d, 2y",value:t.age,onChange:e=>s({age:e})}),(0,i.jsx)(wE,{field:"stream.duration",label:"Duration (seconds)",value:t.duration?t.duration/1e3:void 0,onChange:e=>s({duration:void 0===e?void 0:1e3*e}),min:0,step:60}),(0,i.jsx)(wE,{field:"stream.size",label:"Size (bytes)",help:t.size?ny(t.size):void 0,value:t.size,onChange:e=>s({size:e}),min:0,step:1e9}),(0,i.jsx)(wE,{field:"stream.folderSize",label:"Folder size (bytes)",help:t.folderSize?ny(t.folderSize):void 0,value:t.folderSize,onChange:e=>s({folderSize:e}),min:0,step:1e9})]}),(0,i.jsx)(wI,{field:"stream.message",label:"Message",value:t.message,onChange:e=>s({message:e}),placeholder:"This is a message"}),(0,i.jsxs)(wA,{children:[(0,i.jsx)(wP,{field:"service.cached",label:"Cached",disabled:a,help:a?"Needs a service":void 0,value:t.cached,onChange:e=>s({cached:e})}),(0,i.jsx)(wP,{field:"stream.library",label:"Library",value:t.library,onChange:e=>s({library:e})}),(0,i.jsx)(wP,{field:"stream.private",label:"Private",value:t.private,onChange:e=>s({private:e})}),(0,i.jsx)(wP,{field:"stream.freeleech",label:"Freeleech",value:t.freeleech,onChange:e=>s({freeleech:e})}),(0,i.jsx)(wP,{field:"stream.proxied",label:"Proxied",value:t.proxied,onChange:e=>s({proxied:e})}),(0,i.jsx)(wP,{field:"stream.preloading",label:"Preloading",value:t.preloading,onChange:e=>s({preloading:e})})]}
90),(0,i.jsx)(wR,{fields:wY,children:(0,i.jsxs)(w_,{cols:2,children:[(0,i.jsx)(wI,{field:"stream.infoHash",label:"Info hash",help:"Only sent for p2p streams",value:t.infoHash,onChange:e=>s({infoHash:e})}),(0,i.jsx)(wE,{field:"stream.bitrate",label:"Bitrate (bps)",help:"Blank derives it from size and duration",value:t.bitrate,onChange:e=>s({bitrate:e}),min:0,step:1e6,placeholder:r?`Auto: ${nw(r)}`:"Auto"}),(0,i.jsx)(wI,{field:"addon.presetId",label:"Preset ID",value:t.presetId,onChange:e=>s({presetId:e})}),(0,i.jsx)(wI,{field:"addon.manifestUrl",label:"Manifest URL",value:t.manifestUrl,onChange:e=>s({manifestUrl:e}),error:jK(t.manifestUrl)?void 0:"Must be a valid URL"})]})})]})}let wZ=["metadata.titles","metadata.yearEnd","metadata.episodeRuntime","metadata.absoluteEpisode","metadata.relativeAbsoluteEpisode","metadata.originalLanguage","metadata.country","metadata.latestSeason","metadata.daysSinceRelease","metadata.daysSinceFirstAired","metadata.daysSinceLastAired","metadata.hasNextEpisode","metadata.daysUntilNextEpisode","metadata.anilistId","metadata.malId","metadata.hasSeaDex"];function wQ(e){let{input:t,patch:s}=e,a=t.metadata,r=e=>s({metadata:{...a,...e}}),n=a.type?a.isAnime?`anime.${a.type}`:a.type:"";return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)(w_,{cols:3,children:[(0,i.jsx)(wM,{field:"metadata.type",label:"Type",value:a.type,onChange:e=>r({type:e}),options:aL.map(e=>({label:aO[e],value:e}))}),(0,i.jsx)(wI,{field:"metadata.queryType",label:"Query type",help:"Derived from type and anime",disabled:!0,value:n,onChange:()=>void 0}),(0,i.jsx)(wI,{field:"metadata.title",label:"Title",value:a.title,onChange:e=>r({title:e})}),(0,i.jsx)(wE,{field:"metadata.year",label:"Year",value:a.year,onChange:e=>r({year:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.season",label:"Season",value:a.season,onChange:e=>r({season:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.episode",label:"Episode",value:a.episode,onChange:e=>r({episode:e}),min:0}),(0,i.jsx)(w$,{field:["metadata.episodeTitle","metadata.episodeTitles"],label:"Episode titles",help:"Comma separated; the first is metadata.episodeTitle",value:a.episodeTitles,onChange:e=>r({episodeTitles:e})}),(0,i.jsx)(w$,{field:"metadata.genres",label:"Genres",value:a.genres,onChange:e=>r({genres:e})}),(0,i.jsx)(wE,{field:"metadata.runtime",label:"Runtime (minutes)",value:a.runtime,onChange:e=>r({runtime:e}),min:0})]}),(0,i.jsx)(wA,{children:(0,i.jsx)(wP,{field:"metadata.isAnime",label:"Anime",value:a.isAnime,onChange:e=>r({isAnime:e})})}),(0,i.jsxs)(wR,{fields:wZ,children:[(0,i.jsxs)(w_,{cols:3,children:[(0,i.jsx)(w$,{field:"metadata.titles",label:"Titles",value:a.titles,onChange:e=>r({titles:e})}),(0,i.jsx)(wE,{field:"metadata.yearEnd",label:"End year",value:a.yearEnd,onChange:e=>r({yearEnd:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.episodeRuntime",label:"Episode runtime (minutes)",value:a.episodeRuntime,onChange:e=>r({episodeRuntime:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.absoluteEpisode",label:"Absolute episode",value:a.absoluteEpisode,onChange:e=>r({absoluteEpisode:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.relativeAbsoluteEpisode",label:"Relative absolute episode",value:a.relativeAbsoluteEpisode,onChange:e=>r({relativeAbsoluteEpisode:e}),min:0}),(0,i.jsx)(wI,{field:"metadata.originalLanguage",label:"Original language",help:"Also resolves the 'Original' entry in your language preferences",value:a.originalLanguage,onChange:e=>r({originalLanguage:e})}),(0,i.jsx)(wI,{field:"metadata.country",label:"Country",value:a.country,onChange:e=>r({country:e})}),(0,i.jsx)(wE,{field:"metadata.latestSeason",label:"Latest season",value:a.latestSeason,onChange:e=>r({latestSeason:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.daysSinceRelease",label:"Days since release",value:a.daysSinceRelease,onChange:e=>r({daysSinceRelease:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.daysSinceFirstAired",label:"Days since first aired",value:a.daysSinceFirstAired,onChange:e=>r({daysSinceFirstAired:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.daysSinceLastAired",label:"Days since last aired",value:a.daysSinceLastAired,onChange:e=>r({daysSinceLastAired:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.daysUntilNextEpisode",label:"Days until next episode",value:a.daysUntilNextEpisode,onChange:e=>r({daysUntilNextEpisode:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.anilistId",label:"AniList ID",value:a.anilistId,onChange:e=>r({anilistId:e}),min:0}),(0,i.jsx)(wE,{field:"metadata.malId",label:"MyAnimeList ID",value:a.malId,onChange:e=>r({malId:e}),min:0})]}),(0,i.jsxs)(wA,{children:[(0,i.jsx)(wP,{field:"metadata.hasNextEpisode",label:"Has next episode",value:a.hasNextEpisode,onChange:e=>r({hasNextEpisode:e})}),(0,i.jsx)(wP,{field:"metadata.hasSeaDex",label:"Has SeaDex entry",value:a.hasSeaDex,onChange:e=>r({hasSeaDex:e})})]})]})]})}let wX=["stream.rankedRegexMatched","stream.rseMatched"];
90function w0(e){let{input:t,patch:s}=e;return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)(w_,{cols:3,children:[(0,i.jsx)(wI,{field:"stream.regexMatched",label:"Regex matched",value:t.regexMatched,onChange:e=>s({regexMatched:e}),placeholder:"e.g. 2160p"}),(0,i.jsx)(wE,{field:"stream.regexScore",label:"Regex score",value:t.regexScore,onChange:e=>s({regexScore:e}),min:-1e6,max:1e6,step:5}),(0,i.jsx)(wE,{field:"stream.nRegexScore",label:"Highest regex score",help:"Normalises stream.nRegexScore",value:t.maxRegexScore,onChange:e=>s({maxRegexScore:e}),min:1,step:10}),(0,i.jsx)(wI,{field:"stream.seMatched",label:"Stream expression matched",value:t.seMatched,onChange:e=>s({seMatched:e}),placeholder:"e.g. high-quality"}),(0,i.jsx)(wE,{field:"stream.seScore",label:"Stream expression score",value:t.seScore,onChange:e=>s({seScore:e}),min:-1e6,max:1e6,step:10}),(0,i.jsx)(wE,{field:"stream.nSeScore",label:"Highest expression score",help:"Normalises stream.nSeScore",value:t.maxSeScore,onChange:e=>s({maxSeScore:e}),min:1,step:25})]}),(0,i.jsxs)(wA,{children:[(0,i.jsx)(wP,{field:"stream.seadex",label:"SeaDex",value:t.seadex,onChange:e=>s({seadex:e})}),(0,i.jsx)(wP,{field:"stream.seadexBest",label:"SeaDex best",disabled:!t.seadex,value:t.seadex&&t.seadexBest,onChange:e=>s({seadexBest:e})})]}),(0,i.jsx)(wR,{fields:wX,children:(0,i.jsxs)(w_,{cols:2,children:[(0,i.jsx)(w$,{field:"stream.rankedRegexMatched",label:"Ranked regexes matched",value:t.rankedRegexMatched,onChange:e=>s({rankedRegexMatched:e}),placeholder:"2160p, HDR10+, REMUX"}),(0,i.jsx)(w$,{field:"stream.rseMatched",label:"Ranked expressions matched",value:t.rseMatched,onChange:e=>s({rseMatched:e}),placeholder:"high-quality, best-match"})]})})]})}function w1(){let{userData:e}=ri(),{status:t}=tj(),s=null==t?void 0:t.settings.addonName,a=(0,u.useRef)(new wj(200)),[r,n]=(0,u.useState)(jB),[l,o]=(0,u.useState)("source"),[d,c]=(0,u.useState)(!1),[h,p]=(0,u.useState)(null),x=(0,u.useCallback)(e=>{n(t=>({...t,...e}))},[]);(0,u.useEffect)(()=>{try{localStorage.setItem(jq,JSON.stringify({version:2,input:r}))}catch{}},[r]);let g=ji(e),f=(0,u.useMemo)(()=>new Set([...y2(g.name),...y2(g.description)]),[g.name,g.description]),b=(0,u.useMemo)(()=>jW({...r,parsedFileOverrides:{}}),[r]),v=(0,u.useMemo)(()=>jW(r),[r]),y=(0,u.useCallback)(async()=>{try{let t=await jZ(g,e,s,r);p(t)}catch(e){console.error("Error formatting stream:",e),m.oR.error(`Failed to format stream: ${e}`)}},[r,e,g.name,g.description,s]);(0,u.useEffect)(()=>{a.current.enqueue(y)},[y]);let j=[{value:"source",label:"Source",icon:(0,i.jsx)(wx.A,{className:"w-4 h-4"}),content:(0,i.jsx)(wD,{input:r,patch:x})},{value:"stream",label:"Stream",icon:(0,i.jsx)(wg.A,{className:"w-4 h-4"}),content:(0,i.jsx)(wJ,{input:r,patch:x})},{value:"parsed",label:"Parsed File",icon:(0,i.jsx)(wa.A,{className:"w-4 h-4"}),content:(0,i.jsx)(wW,{input:r,patch:x,parsed:b,effective:v})},{value:"scoring",label:"Scoring",icon:(0,i.jsx)(wf.A,{className:"w-4 h-4"}),content:(0,i.jsx)(w0,{input:r,patch:x})},{value:"metadata",label:"Metadata",icon:(0,i.jsx)(wb.A,{className:"w-4 h-4"}),content:(0,i.jsx)(wQ,{input:r,patch:x})}],w=d?j.filter(e=>(function(e,t){if("metadata"===e)return[...t].some(e=>e.startsWith("metadata."));if("parsed"===e){let e=new Set([...jO,...jU,...jF]);return[...t].some(t=>t.startsWith("stream.")&&!e.has(t))}return(jz[e]??[]).some(e=>t.has(e))})(e.value,f)):j;(0,u.useEffect)(()=>{w.length&&!w.some(e=>e.value===l)&&o(w[0].value)},[w,l]);let N=JSON.stringify(r)===JSON.stringify(jL);return(0,i.jsx)(mK,{title:"Preview",description:"See how your streams would be formatted based on controllable variables",children:(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(jd,{name:null==h?void 0:h.name,description:null==h?void 0:h.description}),(0,i.jsx)(w2,{scenario:r.scenario,onScenario:e=>{let t;return n((t=jV.find(t=>t.id===e))?{...jL,...t.input,metadata:{...jD,...t.input.metadata},scenario:e}:{...jL,scenario:e})},onlyUsed:d,onOnlyUsed:c,usedCount:f.size,onReset:()=>n(jL),resetDisabled:N}),(0,i.jsx)(wN,{used:f,onlyUsed:d,children:w.length?(0,i.jsx)(mv,{tabs:w,activeTab:l,onTabChange:o,revealOnChange:!0}):(0,i.jsx)("p",{className:"text-center text-sm text-[--muted] py-6",children:"This formatter reads no controllable fields."})})]})})}function w2(e){let{scenario:t,onScenario:s,onlyUsed:a,onOnlyUsed:r,usedCount:n,onReset:l,resetDisabled:o}=e;return(0,i.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-gray-800 bg-gray-900/60 p-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,i.jsx)("span",{className:"shrink-0 text-xs font-medium uppercase tracking-wide text-[--muted]",children:"Scenario"}),(0,i.jsx)(nc,{className:"w-full sm:w-56",value:t,options:jV.map(e=>({label:e.label,value:e.id})),onValueChange:s})]}),(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:justify-end",children:[(0,i.jsx)(t5,{trigger:(0,i.jsxs)("button",{type:"button",onClick:()=>r(!a),className:x("flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition-colors",a?"border-[--brand] bg-brand/10 text-[--brand]":"border-gray-800 text-[--muted] hover:text-[--foreground]"),children:[(0,i.jsx)(wv.A,{className:"w-4 h-4"}),"Used only",(0,i.jsx)("span",{className:"rounded-full bg-gray-800 px-2 py-0.5 text-xs leading-none",children:n})]}),children:"Show only the fields this formatter reads"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{intent:"gray-subtle",icon:(0,i.jsx)(wy.A,{className:"w-4 h-4"}
90),"aria-label":"Reset preview inputs",disabled:o,onClick:l}),children:"Reset all preview inputs"})]})]})}function w3(){return(0,i.jsx)(ng,{className:"space-y-4 p-4 sm:p-8",children:(0,i.jsx)(w5,{})})}function w5(){let{isInherited:e,hasParent:t}=ro();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex items-center w-full",children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("h2",{children:"Formatter"}),t&&e("formatter")&&(0,i.jsx)(my,{section:"formatter"})]}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Format your streams to your liking."})]}),(0,i.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,i.jsx)(mg,{})})]}),(0,i.jsx)(wp,{}),(0,i.jsx)(w1,{})]})}function w4(){return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(ng,{className:"space-y-4 p-4 sm:p-8",children:(0,i.jsx)(w6,{})})})}function w6(){var e,t,s,a,r,n,l,o,d,c,u,m,h,p,x,g,f,b,v,y;let{status:j}=tj(),{userData:w,setUserData:N}=ri(),{mode:k}=sF(),{isInherited:S,hasParent:C}=ro(),_=Object.entries(ah).map(e=>{let[t,s]=e;return{label:s.name,value:t}}),A=[...Object.values(ap).map(e=>({label:e.name,value:e.id,textValue:e.name})),{label:"None",value:"none",textValue:"None"}],R=w.presets.map(e=>({label:e.options.name||e.type,value:e.instanceId,textValue:e.options.name})),T=null==j?void 0:j.settings.forced.proxy,I=(null==T?void 0:T.enabled)!==null,E=(null==T?void 0:T.url)!==null,M=(null==T?void 0:T.publicUrl)!==null,P=(null==T?void 0:T.id)!==null,$=(null==T?void 0:T.publicIp)!==null,D=(null==T?void 0:T.credentials)!==null,L=(null==T?void 0:T.proxiedServices)!==null,O=null==T?void 0:T.disableProxiedAddons,U=(null==(e=w.proxy)?void 0:e.id)?ah[w.proxy.id]:void 0;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex items-center w-full",children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("h2",{children:"Proxy"}),C&&S("proxy")&&(0,i.jsx)(my,{section:"proxy"})]}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Configure a proxy for your streams to bypass IP restrictions or improve compatibility"})]}),(0,i.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,i.jsx)(mg,{})})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(mK,{children:(0,i.jsx)(ni,{side:"right",label:"Enable",value:(null==(t=w.proxy)?void 0:t.enabled)??!1,onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,enabled:e}}))},disabled:I})}),(0,i.jsxs)(mK,{children:[(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(nc,{label:"Proxy Service",value:null==(s=w.proxy)?void 0:s.id,onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,id:e}}))},options:_,disabled:P||!(null==(a=w.proxy)?void 0:a.enabled)}),U&&(0,i.jsx)("p",{className:"text-[--muted] text-sm",children:(0,i.jsx)(l6,{children:U.description})})]}),(null==(r=w.proxy)?void 0:r.id)!=="builtin"&&(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(G,{label:"URL",autoComplete:"new-password",value:(null==(n=w.proxy)?void 0:n.url)??"",onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,url:e}}))},placeholder:"Enter proxy URL",disabled:E||!(null==(l=w.proxy)?void 0:l.enabled)}),(0,i.jsx)("p",{className:"text-[--muted] text-sm",children:"The URL of your hosted proxy service."})]}),(null==(o=w.proxy)?void 0:o.id)!=="builtin"&&(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(G,{label:"Public URL (optional)",autoComplete:"new-password",value:(null==(d=w.proxy)?void 0:d.publicUrl)??"",onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,publicUrl:e}}))},placeholder:"Enter proxy public URL",disabled:M||!(null==(c=w.proxy)?void 0:c.enabled)}),(0,i.jsxs)("p",{className:"text-[--muted] text-sm",children:["The public URL of your hosted proxy service. Provide this only if you want to use a local URL for requests but a publicly accessible URL is needed for streams. e.g. setting http://",(null==(u=w.proxy)?void 0:u.id)&&"stremthru"===w.proxy.id?"stremthru:8080":"mediaflow-proxy:8888","as the URL above but then using https://",(null==(m=w.proxy)?void 0:m.id)&&"stremthru"===w.proxy.id?"stremthru.yourdomain.com":"mediaflow-proxy.yourdomain.com","as the public URL."]})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(G,{label:"Credentials",autoComplete:"new-password",value:(null==(h=w.proxy)?void 0:h.credentials)??"",onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,credentials:e}}))},placeholder:"Enter proxy credentials",disabled:D||!(null==(p=w.proxy)?void 0:p.enabled)}),U&&(0,i.jsx)("p",{className:"text-[--muted] text-sm",children:(0,i.jsx)(l6,{children:U.credentialDescription})})]}),"pro"===k&&(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(K,{label:"Public IP",value:(null==(x=w.proxy)?void 0:x.publicIp)??"",onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,publicIp:e||void 0}}))},placeholder:"Enter public IP",disabled:$||!(null==(g=w.proxy)?void 0:g.enabled)}),(0,i.jsxs)("p",{className:"text-[--muted] text-sm",children:["Configure this only when running ",null==U?void 0:U.name," ","locally with a proxy service. Leave empty if"," ",null==U?void 0:U.name," is configured locally without a proxy server or if it's hosted on a remote server."]})]})]}),"pro"===k&&(0,i.jsxs)(mK,{title:"Proxy Controls",description:"Optionally, specify services and addons that should be proxied. These options are applied conjunctively.",children:[(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(li,{label:"Proxied Services",value:(null==(f=w.proxy)?void 0:f.proxiedServices)??[],onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,proxiedServices:e}}))},options:A,placeholder:"Select services to proxy",multiple:!0,disabled:L||!(null==(b=w.proxy)?void 0:b.enabled),emptyMessage:"No services available"}),(0,i.jsx)("p",{className:"text-[--muted] text-sm",children:"Only streams (that are detected to be) from these services will be proxied. Select None to enable proxying of streams that are not detected to be from a service."})]}),(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)(li,{label:"Proxied Addons",value:(null==(v=w.proxy)?void 0:v.proxiedAddons)??[],onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,proxiedAddons:e}}))},options:R,placeholder:"Select addons to proxy",multiple:!0,disabled:O||!(null==(y=w.proxy)?void 0:y.enabled),emptyMessage:"No addons available"}),(0,i.jsx)("p",{className:"text-[--muted] text-sm",children:"Only streams from these addons will be proxied"})]})]})]})]})}function w9(){return(0,i.jsx)(ng,{className:"space-y-4 p-4 sm:p-8",children:(0,i.jsx)(w8,{})})}function w8(){let{status:e}=tj(),t=ri(),[s,a]=u.useState("7d"),r=!!(t.uuid&&t.password),n=(null==e?void 0:e.settings.userAnalyticsEnabled)===!0,l=(0,ty.I)({queryKey:["user-analytics",t.uuid,s],queryFn:()=>eP(t.uuid,t.password,s),enabled:r&&n,refetchOnWindowFocus:!1,staleTime:3e4});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"flex items-center w-full",children:(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Stats"}),(0,i.jsxs)("p",{className:"text-[--muted]",children:["Per-user breakdown of how your addons performed across recent stream requests. Data window is up to"," ",(0,i.jsx)("strong",{children:"24h"===s?"24 hours":"7 days"}),"; older events are pruned automatically."]})]})}),!r&&(0,i.jsx)(lB,{intent:"info",title:"Sign in to see your stats",description:"The Stats tab queries data attributed to your config UUID. Sign in to your config to view it."}),r&&!n&&(0,i.jsx)(lB,{intent:"warning",title:"Per-user analytics is disabled",description:"The owner of this instance has disabled per-user analytics. Ask them to enable it in Settings â Analytics."}),r&&n&&(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(nG,{value:s,onValueChange:e=>a(e??"7d"),children:[(0,i.jsxs)(nY,{children:[(0,i.jsx)(nJ,{value:"24h",children:"Last 24h"}),(0,i.jsx)(nJ,{value:"7d",children:"Last 7 days"})]}
90),(0,i.jsxs)(nZ,{value:s,className:"space-y-4 mt-4",children:[l.isLoading&&(0,i.jsx)(w7,{}),l.error&&(0,i.jsx)(lB,{intent:"alert",title:"Failed to load analytics",description:l.error.message}),l.data&&(0,i.jsx)(Ne,{data:l.data})]})]})})]})}function w7(){return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Array.from({length:4}).map((e,t)=>(0,i.jsx)(uD,{className:"h-24 rounded-md"},t))}),(0,i.jsx)(uD,{className:"h-64 rounded-md"})]})}function Ne(e){let{data:t}=e,{status:s}=tj(),a=ri(),r=u.useMemo(()=>{let e=new Map;for(let t of(null==s?void 0:s.settings.presets)??[])e.set(t.ID,t.NAME);return e},[null==s?void 0:s.settings.presets]),n=u.useMemo(()=>{let e=new Set;for(let t of a.userData.presets??[])e.add(t.type);return e},[a.userData.presets]);if(0===t.totals.requests)return(0,i.jsx)(lB,{intent:"info",title:"No stream requests yet",description:"Once you start requesting streams, your stats will start populating. You can refresh this page after watching a few items."});let l=[],o=[];for(let e of t.perAddon)n.has(e.presetType)?l.push(e):o.push(e);return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(Nt,{data:t}),(0,i.jsx)(mK,{title:"Per-addon performance",description:"One row per (preset, addon instance). Quality metrics use only requests that contributed to your final list â addons whose results were dropped because the exit condition fired aren't penalised.",children:(0,i.jsx)(Ns,{rows:l,presetNameByType:r})}),o.length>0&&(0,i.jsx)(mK,{title:"Removed addons (still in retention)",description:"These addons used to be in your config and still have stats within the retention window. They will disappear naturally once their data ages out.",titleClassName:"text-[--muted]",children:(0,i.jsx)(Ns,{rows:o,presetNameByType:r,muted:!0}
90)}),t.perService.length>0&&(0,i.jsx)(mK,{title:"Per-service breakdown",description:"Surviving streams attributed to each debrid/cdn service across all merged contributions.",children:(0,i.jsx)(Na,{rows:t.perService})}),t.latencyLeaderboard.length>0&&(0,i.jsx)(mK,{title:"Slowest addons",description:"Average response time across the window. Only includes addons with at least 3 successful requests.",children:(0,i.jsx)("ul",{className:"text-sm divide-y divide-[--border]",children:t.latencyLeaderboard.map((e,t)=>{var s;return(0,i.jsxs)("li",{className:"flex justify-between py-2",children:[(0,i.jsx)("span",{children:(null==(s=e.addonName)?void 0:s.trim())||r.get(e.presetType)||e.presetType}),(0,i.jsxs)("span",{className:"font-mono text-[--muted]",children:[(e.avgLatencyMs/1e3).toFixed(2),"s"]})]},`${e.presetType}-${e.instanceHash}-${t}`)})})})]})}function Nt(e){let{data:t}=e,s=[{label:"Requests",value:t.totals.requests.toLocaleString()},{label:"Avg final per request",value:t.totals.finalCountAvg.toFixed(1)},{label:"Cut-off rate",value:`${t.totals.cutOffRate}%`,muted:t.totals.cutOffRate<5},{label:"Error rate",value:`${t.totals.errorRate}%`,alert:t.totals.errorRate>10}];return(0,i.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:s.map(e=>(0,i.jsx)(J,{children:(0,i.jsxs)(ee,{className:"p-4",children:[(0,i.jsx)("div",{className:"text-xs text-[--muted] uppercase tracking-wide",children:e.label}),(0,i.jsx)("div",{className:x("text-2xl font-semibold mt-1",e.alert&&"text-red-300",e.muted&&"text-[--muted]"),children:e.value})]})},e.label))})}function Ns(e){let{rows:t,presetNameByType:s,muted:a}=e;return 0===t.length?(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No data in this window."}):(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:x("w-full text-sm border-collapse",a&&"text-[--muted]"),children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,i.jsx)(Nr,{children:"Addon"}),(0,i.jsx)(Nr,{align:"right",children:"Requests"}),(0,i.jsx)(Nr,{align:"right",children:"Avg final"}),(0,i.jsx)(Nr,{align:"right",children:"Final share"}),(0,i.jsx)(Nr,{align:"right",children:"Cut-off"}),(0,i.jsx)(Nr,{align:"right",children:"Errors"}),(0,i.jsx)(Nr,{align:"right",children:"Avg latency"}),(0,i.jsx)(Nr,{children:"Notes"})]})}),(0,i.jsx)("tbody",{children:t.map(e=>{var t;let a=s.get(e.presetType)??e.presetType,r=(null==(t=e.addonName)?void 0:t.trim())||a,n=!!e.addonName&&e.addonName.trim()!==a,l=[];return e.redundant&&l.push("Redundant"),e.slow&&l.push("Slow"),e.errorRate>25&&l.push("Unstable"),(0,i.jsxs)("tr",{className:"border-b border-[--border] last:border-0 hover:bg-[--subtle]/30",children:[(0,i.jsxs)(Nn,{children:[(0,i.jsx)("div",{className:"font-medium",children:r}),(0,i.jsxs)("div",{className:"text-xs text-[--muted]",children:[n&&(0,i.jsx)("span",{className:"mr-2",children:a}),(0,i.jsxs)("span",{className:"font-mono",children:[e.instanceHash.slice(0,10),"â¦"]})]})]}),(0,i.jsx)(Nn,{align:"right",children:e.requests}),(0,i.jsx)(Nn,{align:"right",children:e.avgFinalContribution.toFixed(1)}),(0,i.jsxs)(Nn,{align:"right",children:[e.finalShare.toFixed(1),"%"]}),(0,i.jsx)(Nn,{align:"right",children:(0,i.jsxs)("span",{className:x(e.cutOffRate>30&&"text-amber-400"),children:[e.cutOffRate.toFixed(0),"%"]})}),(0,i.jsx)(Nn,{align:"right",children:(0,i.jsxs)("span",{className:x(e.errorRate>10&&"text-red-300"),children:[e.errorRate.toFixed(0),"%"]})}),(0,i.jsx)(Nn,{align:"right",children:null==e.avgLatencyMs?"â":`${(e.avgLatencyMs/1e3).toFixed(2)}s`}),(0,i.jsx)(Nn,{children:l.length>0?(0,i.jsx)("span",{className:"text-xs",children:l.join(" \xb7 ")}):(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"OK"})})]},`${e.presetType}-${e.instanceHash}`)})})]})})}function Na(e){let{rows:t}=e;return(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm border-collapse",children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,i.jsx)(Nr,{children:"Service"}),(0,i.jsx)(Nr,{align:"right",children:"Streams"}),(0,i.jsx)(Nr,{align:"right",children:"Cached"}),(0,i.jsx)(Nr,{align:"right",children:"Cached share"}),(0,i.jsx)(Nr,{children:"Contributing addons"})]})}),(0,i.jsx)("tbody",{children:t.map(e=>(0,i.jsxs)("tr",{className:"border-b border-[--border] last:border-0 hover:bg-[--subtle]/30",children:[(0,i.jsx)(Nn,{children:(0,i.jsx)("span",{className:"font-medium",children:e.serviceId})}),(0,i.jsx)(Nn,{align:"right",children:e.finalCount}),(0,i.jsx)(Nn,{align:"right",children:e.cachedCount}),(0,i.jsxs)(Nn,{align:"right",children:[e.cachedShare.toFixed(0),"%"]}),(0,i.jsx)(Nn,{children:(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:e.contributingAddons.join(", ")})})]},e.serviceId))})]})})}function Nr(e){let{children:t,align:s}=e;return(0,i.jsx)("th",{className:x("py-2 px-3 text-xs font-semibold text-[--muted] uppercase tracking-wide","right"===s&&"text-right"),children:t})}function Nn(e){let{children:t,align:s}=e;return(0,i.jsx)("td",{className:x("py-2 px-3","right"===s&&"text-right"),children:t})}function Nl(){let{selectedMenu:e}=rh();switch(e){case"about":return(0,i.jsx)(xR,{});case"services":return(0,i.jsx)(mZ,{});case"addons":return(0,i.jsx)(hP,{});case"filters":return(0,i.jsx)(gu,{});case"sorting":return(0,i.jsx)(gR,{});case"formatter":return(0,i.jsx)(w3,{});case"proxy":return(0,i.jsx)(w4,{});case"miscellaneous":return(0,i.jsx)(fq,{});case"stats":return(0,i.jsx)(w9,{});case"save-install":return(0,i.jsx)(ve,{});default:return(0,i.jsxs)("div",{className:"p-8",children:[(0,i.jsx)("h2",{className:"text-2xl font-bold mb-4",children:e}),(0,i.jsx)("p",{className:"text-gray-400",children:"This section is under construction."})]})}}function Ni(e){let{selectedMenu:t}=rh(),{open:s}=rS(),{isSignedIn:a,toggleSession:r}=uY(),n=so(!1);return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)("div",{"data-top-navbar":!0,className:x("w-full h-[5rem] relative overflow-hidden flex items-center","lg:hidden"),children:[(0,i.jsx)("div",{"data-top-navbar-content-container":!0,className:"relative z-10 px-4 w-full flex flex-row md:items-center overflow-x-auto overflow-y-hidden",children:(0,i.jsxs)("div",{"data-top-navbar-content":!0,className:"flex items-center w-full gap-3",children:[(0,i.jsx)(tW,{}),(0,i.jsx)(nt,{label:"Search settings",onOpen:s}),"about"===t?(0,i.jsxs)("div",{className:"flex items-center gap-2 lg:hidden ml-auto",children:[(0,i.jsx)(w,{icon:(0,i.jsx)(sm.uoR,{}),intent:"alert-outline",rounded:!0,size:"md",onClick:n.open}),(0,i.jsx)(w,{icon:a?(0,i.jsx)(sm.eZR,{}):(0,i.jsx)(sm.XzR,{}),intent:"white-outline",rounded:!0,size:"md",onClick:r})]}):(0,i.jsx)("div",{className:"flex items-center gap-2 lg:hidden",children:(0,i.jsx)(mg,{})})]})}),(0,i.jsx)(uX,{open:n.isOpen,onOpenChange:n.toggle}),(0,i.jsx)(sh,{})]})})}function No(){var e,t;
90let{userData:s,pendingDraft:a,restoreDraft:r,discardDraft:n,disableDrafts:l,uuid:o}=ri(),{status:d}=tj(),[c,m]=u.useState(!1),h=u.useMemo(()=>{if(!c||!a)return null;try{return rs(a,d)}catch{return null}},[c,a,d]);if(!a)return null;let p=null==(e=a.addonName)?void 0:e.trim(),x=p&&p!==((null==d||null==(t=d.settings)?void 0:t.addonName)||"AIOStreams")?p:null,g=[`Last edited ${nE(a.savedAt)}`,x&&`"${x}"`,null===o&&"Not signed in"].filter(Boolean);return(0,i.jsxs)("div",{className:"px-4 pt-4 sm:px-8",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-3 rounded-xl border border-[--border] bg-gray-900/60 p-3 sm:flex-nowrap sm:p-4",children:[(0,i.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-brand-500/20 text-[--brand]",children:(0,i.jsx)(W.Eyn,{className:"size-[18px]"})}),(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsx)("p",{className:"truncate text-sm font-medium text-white",children:"Restore unsaved changes?"}),(0,i.jsx)("p",{className:"truncate text-xs text-[--muted]",children:g.join(" \xb7 ")})]}),(0,i.jsxs)("div",{className:"order-last grid w-full grid-cols-3 gap-2 sm:order-none sm:flex sm:w-auto",children:[(0,i.jsx)(v,{intent:"gray-basic",size:"sm",rounded:!0,leftIcon:(0,i.jsx)(W.ZT8,{}),onClick:()=>m(!0),children:"Review"}),(0,i.jsx)(v,{intent:"gray-outline",size:"sm",rounded:!0,onClick:n,children:"Discard"}),(0,i.jsx)(v,{intent:"white",size:"sm",rounded:!0,onClick:r,children:"Restore"})]}),(0,i.jsx)(iN,{align:"end",trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-basic",icon:(0,i.jsx)(sm.voe,{}),"aria-label":"More draft options"}),children:(0,i.jsx)(ik,{onSelect:l,children:"Don't keep drafts on this browser"})})]}),(0,i.jsx)(sl,{open:c,onOpenChange:m,title:"Unsaved changes",description:"What restoring would change in the configuration currently loaded.",contentClass:"max-w-4xl",children:(0,i.jsxs)("div",{className:"space-y-4",children:[h?(0,i.jsx)(mn,{oldConfig:s,newConfig:h}):(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"This draft can't be read, so there is nothing to compare."}),(0,i.jsxs)("div",{className:"flex flex-col-reverse gap-2 pt-4 sm:flex-row sm:justify-end",children:[(0,i.jsx)(v,{intent:"gray-outline",rounded:!0,className:"w-full sm:w-auto",onClick:()=>{m(!1),n()},children:"Discard"}),(0,i.jsx)(v,{intent:"white",rounded:!0,className:"w-full sm:w-auto",onClick:()=>{m(!1),r()},children:"Restore"})]})]})})]})}function Nd(e){let{error:t}=e,s=(0,e3.jE)();return(0,i.jsx)(A,{showSpinner:!1,children:(0,i.jsx)(N,{title:"Something went wrong!",reset:()=>s.refetchQueries({queryKey:td.queryKey}),children:(0,i.jsx)("p",{children:t})})})}function Nc(){let{status:e,loading:t,error:s}=tj();return t?(0,i.jsx)(u5,{title:"Launching. . ."}):s||!e?(0,i.jsx)(Nd,{error:s}):(0,i.jsx)(uZ,{children:(0,i.jsx)(rm,{children:(0,i.jsx)(rb,{children:(0,i.jsx)(r_,{children:(0,i.jsxs)(rk,{children:[(0,i.jsx)(mp,{children:(0,i.jsx)(tG,{children:(0,i.jsxs)(tE,{withSidebar:!0,sidebarSize:"slim",children:[(0,i.jsx)(tM,{children:(0,i.jsx)(u0,{})}),(0,i.jsx)(tE,{children:(0,i.jsx)(tP,{children:(0,i.jsxs)("div",{"data-main-layout-container":!0,className:"h-auto",children:[(0,i.jsx)(Ni,{}),(0,i.jsx)(No,{}),(0,i.jsx)("div",{"data-main-layout-content":!0,children:(0,i.jsx)(Nl,{})})]})})})]})})}),(0,i.jsx)(rz,{})]})})})})})}function Nu(){return(0,i.jsx)(rl,{children:(0,i.jsx)(sU,{children:(0,i.jsx)(Nc,{})})})}function Nm(){return(0,i.jsx)(Nu,{})}var Nh=s(73160);let Np=(0,r.un)({getParentRoute:()=>R,path:"/",component:function(){let e=(0,T.Z)();return(0,i.jsxs)("main",{className:"min-h-screen flex flex-col items-center justify-center gap-8 px-6 text-center",children:[(0,i.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,i.jsx)("img",{src:"/logo.png",alt:"AIOStreams",className:"max-h-[90px] object-contain"}),(0,i.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"AIOStreams"}),(0,i.jsx)("p",{className:"max-w-md text-[--muted]",children:"The all-in-one addon for Stremio. Configure your addon or manage this instance from the dashboard."})]}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[(0,i.jsx)(v,{intent:"primary",onClick:()=>{e({to:"/stremio/configure"})},children:"Configure"}),(0,i.jsx)(v,{intent:"primary-outline",onClick:()=>e({to:"/dashboard"}),children:"Dashboard"}),(0,i.jsx)(v,{intent:"gray-outline",onClick:()=>window.open("https://docs.aiostreams.viren070.me","_blank"),children:"Documentation"})]})]})}}),Nx=(0,r.un)({getParentRoute:()=>R,path:"/login",beforeLoad:async()=>{let e=await Nh.q.ensureQueryData(to).catch(()=>null);if(e){let t=tw(new URLSearchParams(window.location.search).get("next"));if(!e.isAdmin&&t.startsWith("/dashboard"))return;throw(0,n.V2)({href:t})}},component:function(){let e=(0,e3.jE)(),{status:t}=tj(),[s,a]=u.useState(""),[r,n]=u.useState(""),l=new URLSearchParams(window.location.search),o=u.useRef(l.get("error")).current,d=null==t?void 0:t.settings.oidc,c=(null==d?void 0:d.localLoginEnabled)!==!1,h=`/api/v1/auth/oidc/start?next=${encodeURIComponent(tw(l.get("next")))}`;u.useEffect(()=>{let e=o?tN[o]:void 0;if(e){m.oR.error(e.title,{description:e.description}),l.delete("error");let t=l.toString();window.history.replaceState(null,"",t?`?${t}`:window.location.pathname)}},[]),u.useEffect(()=>{(null==d?void 0:d.enabled)&&d.autoRedirect&&(l.has("local")||o||window.location.assign(h))},[null==d?void 0:d.enabled,null==d?void 0:d.autoRedirect]);let{mutate:p,isPending:x}=(0,e5.n)({mutationFn:e=>{let{username:t,password:s}=e;return er(t,s)},onSuccess:t=>{e.setQueryData(to.queryKey,t);let s=new URLSearchParams(window.location.search);window.location.href=tw(s.get("next"))},onError:e=>{e instanceof es&&e.is("UNAUTHORIZED")?m.oR.error("Invalid username or password"):e instanceof es&&e.is("RATE_LIMIT_EXCEEDED")?m.oR.error("Too many attempts. Please try again later."):m.oR.error(e instanceof Error?e.message:"Failed to log in")}});return(0,i.jsx)("main",{className:"min-h-screen flex items-center justify-center px-6",children:(0,i.jsxs)(J,{className:"w-full max-w-sm p-6",children:[(0,i.jsxs)("div",{className:"flex flex-col items-center gap-2 mb-6",children:[(0,i.jsx)("img",{src:"/logo.png",alt:"AIOStreams",className:"max-h-[60px] object-contain"}),(0,i.jsx)("h1",{className:"text-xl font-semibold",children:"Sign in"}),(0,i.jsx)("p",{className:"text-sm text-[--muted] text-center",children:"Log in to access this AIOStreams instance."}),c&&(0,i.jsxs)("p",{className:"text-xs text-[--muted] text-center",children:["Use a username and password from your instance's"," ",(0,i.jsx)("code",{className:"text-[--foreground]",children:"AIOSTREAMS_AUTH"})," ","environment variable"]})]}),(null==d?void 0:d.enabled)&&(0,i.jsxs)("div",{className:"flex flex-col gap-4 mb-4",children:[(0,i.jsx)(v,{intent:"primary-outline",className:"w-full",onClick:()=>window.location.assign(h),children:d.buttonLabel}),c&&(0,i.jsxs)("div",{className:"flex items-center gap-3",children:[(0,i.jsx)("span",{className:"h-px flex-1 bg-[--border]"}),(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"or"}),(0,i.jsx)("span",{className:"h-px flex-1 bg-[--border]"})]})]}),c&&(0,i.jsxs)("form",{onSubmit:e=>{e.preventDefault(),s&&r&&p({username:s,password:r})},className:"flex flex-col gap-4",children:[(0,i.jsx)(K,{label:"Username",id:"username",name:"username",autoComplete:"username",autoCapitalize:"none",spellCheck:!1,value:s,required:!0,autoFocus:!0,placeholder:"Enter your username",onValueChange:a}),(0,i.jsx)(G,{label:"Password",id:"password",name:"password",value:r,required:!0,placeholder:"Enter your password",onValueChange:n}),(0,i.jsx)(v,{type:"submit",intent:"primary",loading:x,disabled:x,className:"w-full",children:"Sign in"})]})]})})}}),Ng=(0,r.un)({getParentRoute:()=>R,path:"/oauth/callback/gdrive",component:function(){let{mutate:e,isPending:t,data:s,error:a}=(0,e5.n)({mutationFn:e=>eE(e)});(0,u.useEffect)(()=>{let t=new URLSearchParams(window.location.search),s=t.get("error"),a=t.get("code");!s&&a&&e(a)},[]);let r=async()=>{(null==s?void 0:s.refreshToken)&&await nf(s.refreshToken,{onSuccess:()=>m.oR.success("Copied!"),onError:()=>m.oR.error("Failed to copy")})},n=new URLSearchParams(window.location.search).get("error")||(a?a.message:new URLSearchParams(window.location.search).get("code")?null:"No authorization code found in URL");return t?(0,i.jsx)(A,{showSpinner:!0,children:(0,i.jsx)(u3,{words:"Processing OAuth callback...",className:"text-2xl"})}):n?(0,i.jsx)(A,{showSpinner:!1,children:(0,i.jsx)(N,{title:"OAuth Error",showRefreshButton:!0,children:(0,i.jsx)("p",{children:n})})}):(0,i.jsx)("div",{className:"flex items-center justify-center min-h-screen p-4",children:(0,i.jsxs)(J,{className:"w-full max-w-lg p-6",children:[(0,i.jsx)("h1",{className:"text-2xl font-bold mb-4",children:"Google Drive Authorisation"}),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"text-[--muted] space-y-2",children:[(0,i.jsx)("p",{children:"Authorisation successful! Please follow these steps:"}),(0,i.jsxs)("ol",{className:"list-decimal list-inside space-y-1",children:[(0,i.jsx)("li",{children:"Copy the refresh token below"}),(0,i.jsx)("li",{children:"Return to the previous tab"}),(0,i.jsx)("li",{children:"Paste the refresh token into the Refresh Token field"})]})]}),(null==s?void 0:s.refreshToken)&&(0,i.jsx)("div",{className:"relative",children:(0,i.jsxs)("div",{className:"p-4 pr-12 bg-[--subtle] rounded-md relative",children:[(0,i.jsx)("p",{className:"text-sm font-mono break-all",children:s.refreshToken}),(0,i.jsx)(w,{icon:(0,i.jsx)(sm.Xpf,{}),intent:"primary-subtle",className:"absolute top-1/2 -translate-y-1/2 right-2",onClick:r,"aria-label":"Copy authorization code"})]})})]})]})})}}),Nf=(0,r.un)({getParentRoute:()=>R,path:"/splashscreen",component:function(){return(0,i.jsxs)(A,{showSpinner:!1,children:[(0,i.jsx)("img",{src:"/logo_2.png",alt:"Launching...",width:180,height:180,className:"animate-pulse"}),"Launching..."]})}});async function Nb(e){var t;let{location:s}=e,a=await Nh.q.ensureQueryData(td).catch(()=>null);if((null==a||null==(t=a.settings)?void 0:t.protected)&&!await Nh.q.ensureQueryData(to).catch(()=>null))throw(0,n.V2)({to:"/login",search:{next:s.href}})}let Nv=(0,r.un)({getParentRoute:()=>R,path:"/stremio/configure",beforeLoad:Nb,component:Nm}),Ny=(0,r.un)({getParentRoute:()=>R,path:"/stremio/$uuid/$encryptedPassword/configure",beforeLoad:Nb,component:Nm}),Nj=(0,r.un)({getParentRoute:()=>R,path:"/stremio/$uuid/$encryptedPassword/v/$variantSelector/configure",beforeLoad:Nb,component:Nm}),Nw=(0,r.un)({getParentRoute:()=>R,path:"/dashboard",beforeLoad:async e=>{let{location:t}=e,s=await Nh.q.ensureQueryData(to).catch(()=>null);if(!s)throw(0,n.V2)({to:"/login",search:{next:t.href}});if(!s.isAdmin)throw(0,n.V2)({to:"/login",search:{next:t.href,error:"forbidden"}})},component:function(){let{signOut:e}=su(),{pathname:t}=(0,tk.z)(),s=(0,T.Z)(),a=sd({title:"Sign Out",description:"Are you sure you want to sign out?",onConfirm:async()=>{await e(),window.location.href="/login"}}),r=sb.map(e=>{let a=sv[e.href];if(a){let r=t.startsWith(e.href);return{name:e.label,iconType:e.icon,isCurrent:r,expanded:r,onClick:()=>s({to:e.href}),subItems:a.map(a=>({name:a.label,iconType:a.icon,isCurrent:t===`${e.href}/${a.id}`,onClick:()=>s({to:`${e.href}/${a.id}`})}))}}return{name:e.label,iconType:e.icon,isCurrent:t===e.href||t===`${e.href}/`,onClick:()=>s({to:e.href})}}),n=[{name:"Configure",iconType:sm.Wyp,onClick:()=>s({to:"/stremio/configure"})},{name:"Sign Out",iconType:sm.eZR,onClick:()=>a.open()}];return(0,i.jsxs)(sw,{children:[(0,i.jsxs)(tG,{children:[(0,i.jsxs)(tE,{withSidebar:!0,sidebarSize:"slim",children:[(0,i.jsx)(tM,{children:(0,i.jsx)(sr,{header:(0,i.jsx)(ns,{}),items:r,footerItems:n})}),(0,i.jsx)(tE,{children:(0,i.jsxs)(tP,{children:[(0,i.jsxs)("div",{"data-dashboard-top-navbar":!0,className:"lg:hidden w-full h-[5rem] relative overflow-hidden flex items-center gap-3 px-4",children:[(0,i.jsx)(tW,{}),(0,i.jsx)(na,{}),(0,i.jsx)(sh,{})]}),(0,i.jsx)(o.s,{})]})})]}),(0,i.jsx)(sc,{...a})]}),(0,i.jsx)(r6,{})]})}}),NN=(0,r.un)({getParentRoute:()=>Nw,path:"/",component:function(){var e,t,s,a,r;let n=(0,ty.I)({queryKey:["dashboard","overview"],queryFn:()=>ea("/dashboard/analytics/overview"),staleTime:3e4}),l=(0,ty.I)({queryKey:["dashboard","tasks"],queryFn:()=>ea("/dashboard/tasks"),refetchInterval:1e4}),o=(0,ty.I)({queryKey:["dashboard","overview","logs"],queryFn:()=>ea("/dashboard/logs?order=desc&limit=10&level=error,warn"),refetchInterval:15e3}),{metrics:d}=oH(),{status:c}=tj(),m=(null==(e=c8({pending:!0,limit:1}).data)?void 0:e.total)??0,h=(0,ty.I)({queryKey:[...i3,"live","glance"],queryFn:()=>ea("/dashboard/usenet/live"),staleTime:5e3,refetchInterval:1e4}).data,p=((null==h?void 0:h.pool.providers.length)??0)>0,g=u.useMemo(()=>{var e;let t=(null==(e=l.data)?void 0:e.tasks)??[];return 0===t.length?null:Math.round(t.filter(e=>"error"===e.lastStatus).length/t.length*100)},[l.data]),f=u.useMemo(()=>{var e;let t=((null==(e=l.data)?void 0:e.tasks)??[]).filter(e=>e.lastRunAt);return t.sort((e,t)=>
90(t.lastRunAt??0)-(e.lastRunAt??0)),t.slice(0,5)},[l.data]);return(0,i.jsxs)(ng,{className:"space-y-6 p-4 sm:p-8",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Dashboard"}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Live overview of this AIOStreams instance."})]}),(0,i.jsxs)("div",{className:x("grid grid-cols-2 gap-3",m>0?"lg:grid-cols-5":"lg:grid-cols-4"),children:[(0,i.jsx)(uH,{label:"Users",value:(null==(t=n.data)?void 0:t.totalUsers)??"â",hint:n.data?`+${n.data.newUsers.d1} today \xb7 +${n.data.newUsers.d7} this week`:void 0}),(0,i.jsx)(uH,{label:"Active 24h",value:(null==(s=n.data)?void 0:s.activeUsers.d1)??"â",hint:n.data?`${n.data.activeUsers.d7} this week`:void 0}),(0,i.jsx)(uH,{label:"Requests 24h",value:(null==(a=n.data)?void 0:a.requests24h)??"â"}),(0,i.jsx)(uH,{label:"Task failures",value:null==g?"â":`${g}%`,intent:null==g?void 0:g>0?"err":"ok",hint:l.data?`${l.data.tasks.length} tasks tracked`:void 0}),m>0&&(0,i.jsx)(uu.N_,{to:"/dashboard/community/pending",className:"group col-span-2 block rounded-xl lg:col-span-1",children:(0,i.jsx)(uH,{label:"Review queue",value:m,intent:"warn",hint:"Community submissions waiting",className:"h-full transition-colors group-hover:border-[--muted]/40 group-hover:bg-[--subtle]/50"})})]}),(0,i.jsxs)("div",{className:"space-y-3",children:[d&&(0,i.jsx)(uv,{metrics:d}),c&&(0,i.jsx)(uK,{status:c})]}),(0,i.jsxs)("div",{className:x("grid grid-cols-1 gap-3 sm:grid-cols-2",p&&"xl:grid-cols-3"),children:[(0,i.jsx)(ug,{}),(0,i.jsx)(uf,{}),p&&h&&(0,i.jsx)(uj,{data:h})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,i.jsx)(um,{to:"/dashboard/tasks",icon:sm.grf,title:"Recent task runs",children:l.isError?(0,i.jsx)(up,{children:"Failed to load tasks."}):0===f.length?(0,i.jsx)(up,{children:"No task runs yet."}):(0,i.jsx)("ul",{className:"space-y-1.5 text-sm",children:f.map(e=>(0,i.jsxs)("li",{className:"flex items-center gap-2 justify-between",children:[(0,i.jsx)("span",{className:"truncate",children:e.label}),(0,i.jsxs)("span",{className:"flex items-center gap-2 text-xs text-[--muted]",children:[(0,i.jsx)("span",{className:x("inline-block w-2 h-2 rounded-full","ok"===e.lastStatus&&"bg-emerald-500","error"===e.lastStatus&&"bg-red-400","skipped"===e.lastStatus&&"bg-amber-500",!e.lastStatus&&"bg-[--muted]")}),(0,i.jsx)("span",{children:(e=>{if(!e)return"never";let t=(Date.now()-e)/1e3;return t<0?`in ${nS(-t)}`:`${nS(t)} ago`})(e.lastRunAt)}),null!=e.lastDurationMs&&(0,i.jsxs)("span",{children:["\xb7 ",e.lastDurationMs,"ms"]})]})]},e.id))})}),(0,i.jsx)(um,{to:"/dashboard/logs",icon:sm.m4U,title:"Recent warnings & errors",children:o.isError?(0,i.jsx)(up,{children:"Failed to load recent logs."}):(null==(r=o.data)?void 0:r.logs.length)?(0,i.jsx)("ul",{className:"space-y-1 text-xs",children:o.data.logs.slice(0,8).map(e=>{let t=function(e){try{let t=JSON.parse(e),s="string"==typeof t.level?t.level:"info",a="string"==typeof t.module?t.module:void 0,r="string"==typeof t.msg?t.msg:e;return{level:s,module:a,msg:r}}catch{return{level:"info",msg:e}}}(e.line);return(0,i.jsxs)("li",{className:"truncate",title:e.line,children:[(0,i.jsx)("span",{className:x("inline-block w-1.5 h-1.5 rounded-full align-middle mr-1.5","error"===t.level||"fatal"===t.level?"bg-red-400":"bg-amber-500")}),t.module&&(0,i.jsxs)("span",{className:"text-[--muted-highlight] font-mono",children:["[",t.module,"]"," "]}),(0,i.jsx)("span",{className:"text-[--foreground]",children:t.msg})]},e.seq)})}):(0,i.jsx)(up,{children:"No recent warnings."})})]}),(0,i.jsx)(ub,{})]})}}),Nk=(0,r.un)({getParentRoute:()=>Nw,path:"analytics",component:function(){let[e,t]=u.useState("7d"),[s,a]=u.useState(null),r=(0,ty.I)({queryKey:["dashboard","analytics","overview"],queryFn:()=>ea("/dashboard/analytics/overview"),staleTime:3e4}),n=(0,ty.I)({queryKey:["dashboard","analytics","users",e],queryFn:()=>ea(`/dashboard/analytics/users?range=${e}`),staleTime:3e4}),l=(0,ty.I)({queryKey:["dashboard","analytics","requests",e],queryFn:()=>ea(`/dashboard/analytics/requests?range=${e}`),staleTime:3e4}),o=(0,ty.I)({queryKey:["dashboard","analytics","addons",e],queryFn:()=>ea(`/dashboard/analytics/addons?range=${e}`),staleTime:3e4}),d=(0,ty.I)({queryKey:["dashboard","analytics","features",e],queryFn:()=>ea(`/dashboard/analytics/features?range=${e}`),staleTime:3e4}),c=r.data;return(0,i.jsxs)(ng,{className:"p-4 sm:p-8 space-y-6",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Analytics"}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Usage, requests and addon health. Only anonymized IP prefixes (first 3 octets) are stored."})]}
90),(0,i.jsx)(oV,{value:e,onChange:t})]}),(0,i.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,i.jsx)(oU,{label:"Configured users",value:c?(0,i.jsx)(oF,{value:c.totalUsers}):"â",hint:c?`+${nT(c.newUsers.d7)} this week`:""}),(0,i.jsx)(oU,{label:"New users (24h)",value:c?(0,i.jsx)(oF,{value:c.newUsers.d1}):"â",hint:c?`${nT(c.newUsers.d30)} in 30d`:""}),(0,i.jsx)(oU,{label:"Active users (24h)",value:c?(0,i.jsx)(oF,{value:c.activeUsers.d1}):"â",hint:c?`${nT(c.activeUsers.d7)} in 7d`:""}),(0,i.jsx)(oU,{label:"Requests (24h)",value:c?(0,i.jsx)(oF,{value:c.requests24h}):"â"})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"User growth"}),(0,i.jsx)(oh,{query:n,errorTitle:"Failed to load user analytics",children:e=>(0,i.jsx)(o$,{data:e.growth,xKey:"day",series:[{key:"total",label:"Total",color:"var(--brand)"},{key:"new",label:"New"}],height:260})})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Requests by resource"}),(0,i.jsx)(oh,{query:l,errorTitle:"Failed to load request analytics",children:e=>(0,i.jsx)(oD,{data:e.series,xKey:"day",stacked:!0,series:e.resources.map(e=>({key:e})),height:260})})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,i.jsxs)("h3",{className:"text-sm font-semibold",children:["Addon usage & errors"," ",(0,i.jsx)("span",{className:"text-[--muted] font-normal",children:"(marketplace defaults only)"})]}),o.data&&(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:[o.data.customEndpoints," custom endpoint",1===o.data.customEndpoints?"":"s"," excluded"]})]}),(0,i.jsx)(oh,{query:o,errorTitle:"Failed to load addon analytics",children:e=>e.addons.length?(0,i.jsxs)("div",{className:"grid lg:grid-cols-[1fr,240px] gap-6 items-center",children:[(0,i.jsx)("div",{className:"overflow-x-auto -mx-4 px-4 lg:mx-0 lg:px-0",children:(0,i.jsxs)("table",{className:"w-full text-sm min-w-[560px]",children:[(0,i.jsx)("thead",{className:"text-[--muted] text-xs uppercase",children:(0,i.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,i.jsx)("th",{className:"py-2 pr-3",children:"Addon"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Requests"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Share"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Errors"}),(0,i.jsx)("th",{className:"py-2 px-3 text-right",children:"Err %"}),(0,i.jsx)("th",{className:"py-2 pl-3 text-right",children:"Avg ms"})]})}),(0,i.jsx)("tbody",{children:e.addons.map(e=>(0,i.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,i.jsx)("td",{className:"py-2 pr-3 font-medium",children:e.presetId}),(0,i.jsx)("td",{className:"py-2 px-3 text-right",children:(0,i.jsx)(oF,{value:e.requests})}),(0,i.jsxs)("td",{className:"py-2 px-3 text-right tabular-nums",children:[e.share,"%"]}),(0,i.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:e.errors}),(0,i.jsxs)("td",{className:x("py-2 px-3 text-right tabular-nums",e.errorRate>10&&"text-red-400"),children:[e.errorRate,"%"]}),(0,i.jsx)("td",{className:"py-2 pl-3 text-right tabular-nums",children:e.avgLatencyMs??"â"})]},e.presetId))})]})}),(0,i.jsx)("div",{className:"mx-auto w-full max-w-[240px] aspect-square",children:(0,i.jsx)(oL,{data:e.addons.slice(0,6).map(e=>({name:e.presetId,value:e.requests})),centerLabel:"requests",centerValue:nT(e.total),height:240})})]}):(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No addon data for this range."})})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,i.jsx)("h3",{className:"text-sm font-semibold",children:"Feature usage"}),(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"distinct users per day, summed"})]}),(0,i.jsx)(oh,{query:d,errorTitle:"Failed to load feature analytics",children:e=>(0,i.jsxs)("div",{className:"grid lg:grid-cols-3 gap-6",children:[(0,i.jsx)(oq,{title:"Services",rows:e.service}),(0,i.jsx)(oq,{title:"Formatters",rows:e.formatter}),(0,i.jsx)(oq,{title:"Presets",rows:e.preset})]})})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Most active users (hashed)"}),(0,i.jsx)(oh,{query:n,errorTitle:"Failed to load top users",children:e=>e.topUsers.length?(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsx)("table",{className:"w-full text-sm",children:(0,i.jsx)("tbody",{children:e.topUsers.map(e=>(0,i.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,i.jsx)("td",{className:"py-1.5 font-mono text-xs text-[--muted] break-all",children:e.uuidHash.slice(0,16)}),(0,i.jsx)("td",{className:"py-1.5 pl-3 text-right whitespace-nowrap",children:(0,i.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,i.jsx)(oF,{value:e.requests}),(0,i.jsx)(t5,{trigger:(0,i.jsx)("button",{onClick:()=>a(e.uuidHash),"aria-label":"View user activity",className:"text-[--muted] transition-colors hover:text-brand",children:(0,i.jsx)(lV.S8s,{className:"size-4"})}),children:"View activity"})]})})]},e.uuidHash))})})}):(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:"No data for this range."})})]}),(0,i.jsx)(oB,{uuidHash:s,range:e,onClose:()=>a(null)})]})}}),NS=(0,r.un)({getParentRoute:()=>Nw,path:"logs",component:function(){let e=(0,u.useMemo)(nO,[]),[t,s]=(0,u.useState)(e.autoscroll),[a,r]=(0,u.useState)(e.wrap),[n,l]=(0,u.useState)(e.levels),[o,d]=(0,u.useState)(void 0),[c,h]=(0,u.useState)(""),[p,g]=(0,u.useState)(!1),f=np(c,250),[b,y]=(0,u.useState)(new Set),j=sd({title:"Clear logs",description:"This permanently removes all retained logs. This cannot be undone.",actionText:"Clear",actionIntent:"alert-subtle",onConfirm:async()=>{try{await ea("POST /dashboard/logs/clear",{body:{confirm:!0}}),I(),m.oR.success("Logs cleared")}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to clear logs")}}}),k=(0,u.useMemo)(()=>
90{if(!p||!c)return null;try{return new RegExp(c),null}catch(e){return e instanceof Error?e.message:"Invalid regex"}},[p,c]);(0,u.useEffect)(()=>{localStorage.setItem(nL,JSON.stringify({autoscroll:t,wrap:a,levels:n}))},[t,a,n]);let S=(0,u.useMemo)(()=>({q:f,regex:p&&!k,levels:n,module:o}),[f,p,k,n,o]),{rows:_,loading:A,connected:R,error:T,clear:I,retry:E}=function(e){let[t,s]=(0,u.useState)([]),[a,r]=(0,u.useState)(!0),[n,l]=(0,u.useState)(!1),[i,o]=(0,u.useState)(null),[d,c]=(0,u.useState)(0),m=(0,u.useRef)(0),h=nm(e),p=(0,u.useCallback)(()=>c(e=>e+1),[]);return(0,u.useEffect)(()=>{let e=!1,t=null;return r(!0),o(null),s([]),m.current=0,(async()=>{try{let t=h?`&${h}`:"",a=await ea(`/dashboard/logs?order=asc&limit=2000${t}`);if(e)return;let r=a.logs.map(e=>nu(e.seq,e.line));s(r),m.current=r.length?r[r.length-1].seq:a.nextSeq}catch(t){e||o(t instanceof Error?t.message:"Failed to load logs")}finally{e||r(!1)}if(e)return;let a=`since=${m.current}${h?`&${h}`:""}`;(t=new EventSource(`/api/v1/dashboard/logs/stream?${a}`,{withCredentials:!0})).onopen=()=>!e&&l(!0),t.onerror=()=>!e&&l(!1),t.onmessage=t=>{if(e||!t.data)return;let a=Number(t.lastEventId);if(Number.isFinite(a)&&a<=m.current)return;Number.isFinite(a)&&(m.current=a);let r=nu(a||m.current,t.data);s(e=>{let t=e.length>=1e4?e.slice(1):e.slice();return t.push(r),t})}})(),()=>{e=!0,null==t||t.close(),l(!1)}},[h,d]),{rows:t,loading:a,connected:n,error:i,clear:(0,u.useCallback)(()=>s([]),[]),retry:p}}(S),[M,$]=(0,u.useState)(!1);(0,u.useEffect)(()=>{let e=setTimeout(()=>$(!0),400);return()=>clearTimeout(e)},[]);let D=(0,u.useMemo)(()=>{let e=new Set;return _.forEach(t=>t.module&&e.add(t.module)),[{value:nD,label:"All modules"},...[...e].sort().map(e=>({value:e,label:e}))]},[_]),L=(0,u.useRef)(null),O=(0,u.useRef)(!0),[U,F]=(0,u.useState)(!0),z=(0,u.useRef)(0),V=(0,nr.T)({count:_.length,getScrollElement:()=>L.current,estimateSize:()=>30,overscan:20}),q=(0,u.useCallback)(()=>{let e=()=>{let e=L.current;e&&_.length&&(V.scrollToIndex(_.length-1,{align:"end"}),e.scrollTop=e.scrollHeight,z.current=e.scrollTop)};e(),requestAnimationFrame(()=>{e(),requestAnimationFrame(e)})},[_.length,V]);(0,u.useEffect)(()=>{M&&!A&&!T&&t&&O.current&&q()},[_.length,M,A,T,t,q]);let B=(0,u.useCallback)(()=>{let e=L.current;if(!e)return;let t=e.scrollTop,s=e.scrollHeight-t-e.clientHeight,a=t<z.current-2;z.current=t,s<80?O.current||(O.current=!0,F(!0)):a&&O.current&&(O.current=!1,F(!1))},[]),H=()=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ni,{label:"Auto-scroll",labelClass:"whitespace-nowrap",side:"right",value:t,onValueChange:e=>{s(e),e&&(O.current=!0,F(!0),q())}}),(0,i.jsx)(ni,{label:"Wrap",side:"right",value:a,onValueChange:r})]}),W=V.getVirtualItems();return(0,i.jsx)(ng,{className:"space-y-4 p-4 sm:p-8",children:(0,i.jsxs)("div",{className:"flex flex-col h-[calc(100vh-6rem)]",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Logs"}),(0,i.jsxs)("p",{className:"text-[--muted]",children:["Live tail of recent logs."," ",(0,i.jsx)("span",{className:x("inline-block w-2 h-2 rounded-full align-middle",R?"bg-emerald-500":"bg-[--muted]")})," ",(0,i.jsxs)("span",{className:"text-xs",children:[R?"streaming":"disconnected"," \xb7 ",_.length," shown"]})]})]}),(0,i.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,i.jsx)(w,{size:"sm",intent:"gray-outline",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Clear logs",onClick:()=>j.open()}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",leftIcon:(0,i.jsx)(sm.Ah9,{}),onClick:()=>window.open(nh(S,"log"),"_blank"),children:".log"}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",leftIcon:(0,i.jsx)(sm.Ah9,{}),onClick:()=>window.open(nh(S,"json"),"_blank"),children:".json"})]})]}),(0,i.jsxs)(J,{className:"p-3 mb-3 flex flex-col gap-3",children:[(0,i.jsxs)("div",{className:"flex flex-wrap gap-3 items-center",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-[240px] flex flex-col gap-1",children:[(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)(K,{leftIcon:(0,i.jsx)(sm.iyI,{}),placeholder:p?"Regex patternâ¦":"Search all retained logsâ¦",value:c,onValueChange:h,className:x("flex-1",k&&"border-red-400 focus-within:border-red-400")}),(0,i.jsx)("button",{type:"button",title:"Toggle regex search",onClick:()=>g(e=>!e),className:x("shrink-0 h-9 px-2 rounded-md border text-xs font-mono transition-colors",p&&!k?"border-brand bg-brand/10 text-brand":p&&k?"border-red-400 bg-red-500/10 text-red-400":"border-[--border] text-[--muted] hover:text-[--foreground] hover:border-[--foreground]"),children:".*"})]}
90),k&&(0,i.jsx)("p",{className:"text-xs text-red-400 pl-1",children:k})]}),(0,i.jsxs)("div",{className:"flex flex-1 md:flex-none items-center gap-2",children:[(0,i.jsx)("div",{className:"flex-1 md:min-w-[180px]",children:(0,i.jsx)(nc,{options:D,value:o??nD,onValueChange:e=>d(e===nD?void 0:e)})}),(0,i.jsx)("div",{className:"lg:hidden shrink-0",children:(0,i.jsx)(P,{trigger:(0,i.jsx)(w,{size:"sm",intent:"gray-outline",icon:(0,i.jsx)(sm.voe,{}),"aria-label":"Log view options"}),children:(0,i.jsx)("div",{className:"flex flex-col gap-4 p-1 min-w-[180px]",children:H()})})})]})]}),(0,i.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[nM.map(e=>(0,i.jsx)("button",{onClick:()=>l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:x("px-2 py-0.5 rounded text-xs uppercase font-semibold border transition-colors",n.includes(e)?"border-brand bg-brand/10":"border-[--border] text-[--muted] hover:text-[--foreground]",n.includes(e)&&nP[e]),children:e},e)),(0,i.jsx)("div",{className:"flex-1"}),(0,i.jsx)("div",{className:"hidden lg:flex items-center gap-5",children:H()})]})]}),(0,i.jsxs)(J,{className:"flex-1 relative overflow-hidden p-0",children:[(!M||A)&&(0,i.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 z-10",children:[(0,i.jsx)(C,{className:"w-8 h-8"}),(0,i.jsx)("p",{className:"text-[--muted] text-sm",children:"Loading logsâ¦"})]}),T&&M&&!A&&(0,i.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:(0,i.jsx)(N,{title:"Failed to load logs",reset:E,children:(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:T})})}),M&&!A&&!T&&0===_.length&&(0,i.jsx)("div",{className:"absolute inset-0 flex items-center justify-center text-[--muted] text-sm",children:"No logs match the current filters."}),(0,i.jsx)("div",{ref:L,onScroll:B,className:"h-full overflow-auto",children:M&&!A&&!T&&(0,i.jsx)("div",{style:{height:V.getTotalSize(),position:"relative"},children:W.map(e=>{let t=_[e.index];return(0,i.jsx)("div",{"data-index":e.index,ref:V.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${e.start}px)`},children:(0,i.jsx)(nF,{row:t,wrap:a,expanded:b.has(t.seq),onToggle:()=>{let e;return e=t.seq,y(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})}})},t.seq)})})}),t&&!U&&(0,i.jsx)(v,{size:"sm",intent:"primary",className:"absolute bottom-4 right-4 shadow-lg",leftIcon:(0,i.jsx)(sm.oVj,{}),onClick:()=>{O.current=!0,F(!0),q()},children:"Jump to latest"})]}),(0,i.jsx)(sc,{...j})]})})}}),NC=(0,r.un)({getParentRoute:()=>Nw,path:"system",component:function(){let{metrics:e,connected:t,history:s,windowMs:a,error:r,retry:n}=oH(),[l,o]=u.useState("system"),[d,c]=u.useState("average"),[h,p]=u.useState(!1),x=sd({title:"Stop AIOStreams",description:"This halts the AIOStreams process only (never the host). It stays down until something starts it again.",actionText:"Stop",actionIntent:"alert-subtle",onConfirm:()=>{p(!0),ea("POST /dashboard/system/stop",{body:{confirm:"STOP"}}).then(()=>{m.oR.success("Process stopping â it stays down until something starts it again.")}).catch(e=>{m.oR.error((null==e?void 0:e.message)??"Failed to stop")}).finally(()=>p(!1))}});if(!e)return r?(0,i.jsx)(ng,{className:"p-4 sm:p-8",children:(0,i.jsx)(om,{title:"Failed to load system metrics",message:r,onRetry:n})}):(0,i.jsx)(ng,{className:"p-4 sm:p-8",children:(0,i.jsx)(ou,{})});let g=e.memory.used/e.memory.total*100,f=e.disk?e.disk.used/e.disk.total*100:0,b=function(e,t,s){var a;if("process"===t||"average"===s){let s="process"===t?"process":"total";return{data:e.map(e=>({t:oG(e.ts),[s]:e.cpu[s]})),series:[{key:s,label:"process"===t?"Process":"System"}]}}let r=(null==(a=e.at(-1))?void 0:a.cpu.perCore.length)??0;return{data:e.map(e=>{let t={t:oG(e.ts)};for(let s=0;s<r;s++)t[`c${s}`]=e.cpu.perCore[s]??0;return t}),series:Array.from({length:r},(e,t)=>({key:`c${t}`,label:`Core ${t}`}))}}(s,l,d),y="process"===l?e.cpu.process??0:e.cpu.total;return(0,i.jsxs)(ng,{className:"p-4 sm:p-8 space-y-6",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"System"}),(0,i.jsxs)("p",{className:"text-[--muted]",children:[(0,i.jsx)("span",{className:`inline-block w-2 h-2 rounded-full align-middle ${t?"bg-emerald-500":"bg-[--muted]"}`})," ",(0,i.jsx)("span",{className:"text-xs",children:t?"live":"reconnecting"})]})]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(v,{intent:"alert-outline",size:"sm",disabled:!e.lifecycleEnabled||h,loading:h,leftIcon:(0,i.jsx)(sm.ES$,{}),onClick:x.open,children:"STOP"}),(0,i.jsx)(sc,{...x})]})]}),!e.lifecycleEnabled&&(0,i.jsx)(lB,{intent:"info",description:"Stop is disabled. Set SYSTEM_LIFECYCLE_ENABLED=true to enable process lifecycle c
90ontrols."}),(0,i.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,i.jsx)(oW,{label:"CPU",pct:e.cpu.total,detail:`${e.cpu.cores} cores${e.cpu.loadavg?` \xb7 load ${e.cpu.loadavg[0].toFixed(2)}`:""}`}),(0,i.jsx)(oW,{label:"Memory",pct:g,detail:`${ny(e.memory.used)} / ${ny(e.memory.total)}`}),(0,i.jsx)(oW,{label:"Disk (data)",pct:f,detail:e.disk?`${ny(e.disk.used)} / ${ny(e.disk.total)}`:"unavailable"})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsxs)("div",{className:"flex items-start sm:items-center justify-between flex-col sm:flex-row gap-2 mb-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"text-sm font-semibold",children:"CPU utilisation"}),(0,i.jsxs)("p",{className:"text-xs text-[--muted]",children:["Last ",Math.round(a/6e4)," minutes \xb7 live \xb7 now"," ",(0,i.jsxs)("span",{className:"text-[--foreground] tabular-nums",children:[y,"%"]})]})]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(oQ,{value:l,onChange:e=>{o(e),"process"===e&&"per-core"===d&&c("average")},options:[{value:"system",label:"System"},{value:"process",label:"Process"}]}),(0,i.jsx)(oQ,{value:d,onChange:c,options:[{value:"average",label:"Average"},{value:"per-core",label:"Per-core",disabled:"process"===l,title:"process"===l?"Process CPU is reported as a single aggregate â per-core is only available for system scope.":void 0}]})]})]}),(0,i.jsx)(oP,{data:b.data,xKey:"t",series:b.series,height:220,hideLegend:"per-core"!==d||"process"===l,valueFormatter:e=>`${e}%`})]}),(0,i.jsx)(oZ,{memory:e.memory,history:s}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Process"}),(0,i.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[["Uptime",nS(e.process.uptimeSec)],["Node",e.process.nodeVersion],["PID",String(e.process.pid)],["Platform",e.process.platform]].map(e=>{let[t,s]=e;return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-[--muted]",children:t}),(0,i.jsx)("div",{className:"font-medium break-all",children:s})]},t)})})]})]})}}),N_=e=>"string"==typeof e&&e?e:void 0,NA=(0,r.un)({getParentRoute:()=>Nw,path:"settings",validateSearch:e=>({tab:N_(e.tab),field:N_(e.field)}),component:function(){var e,t;let s,{data:a,isLoading:r,error:n,refetch:l}=r0(),o=u.useMemo(()=>a?function(e){let t=new Map;for(let s of e){let e=rW(s.key);(t.get(e)??t.set(e,[]).get(e)).push(s)}let s=[];for(let[e,a]of t){let t=rK[e]??{label:rZ(e),icon:rY,group:"Other",order:9999};if(t.cards){s.push({section:e,...t,groups:function(e,t){let s=new Map(t.map(e=>[e.key,e])),a=new Set,r=new Map;for(let t of e){if("editor"in t)continue;let e=t.keys.map(e=>{let t=s.get(e);return t&&a.add(e),t}).filter(e=>!!e);e.length&&r.set(t.title,e)}let n=t.filter(e=>!a.has(e.key));return n.length&&r.set("Other",n),r}(t.cards,a),curated:!0});continue}let r=t.sections?[...a].sort((t,s)=>rG(e,t.key)-rG(e,s.key)):a,n=new Map;for(let t of r){let s=function(e,t){var s;let a=null==(s=rK[e])?void 0:s.sections,r=t.split(".").slice(0,-1),n=a?function(e){if(0===e.length)return 0;let t=e[0].split("."),s=0;for(;s<t.length&&e.every(e=>e.split(".")[s]===t[s]);)s++;return s}(a):1;return r.slice(n).join(".")}(e,t.key);(n.get(s)??n.set(s,[]).get(s)).push(t)}s.push({section:e,...t,groups:n})}return s.sort((e,t)=>e.order-t.order||e.label.localeCompare(t.label))}(a.keys):[],[a]),d=u.useMemo(()=>{let e=new Set(o.flatMap(e=>e.editors??[]));return((null==a?void 0:a.managed)??[]).filter(t=>e.has(t.key))},[a,o]),c=(0,nz.S)({from:"/dashboard/settings"}),m=(0,T.Z)({from:"/dashboard/settings"}),[h,p]=u.useState("");u.useEffect(()=>{var e;if(!o.length)return;let t=c.tab?rK[e=c.tab]?e:rH.get(e)??e:void 0;t&&o.some(e=>e.section===t)?p(t):h||p(o[0].section)},[o,c.tab]);let g=u.useCallback(()=>{m({to:".",search:e=>({...e,field:void 0}),replace:!0,resetScroll:!1})},[m]);if(e=c.field,t=!!h&&o.length>0,s=(0,u.useRef)(null),(0,u.useEffect)(()=>{if(!e){s.current=null;return}t&&s.current!==e&&(s.current=e,g(),rw([`setting-${e}`]))},[e,t,g]),r)return(0,i.jsx)(ng,{className:"p-8 flex items-center justify-center",children:(0,i.jsx)(C,{className:"w-8 h-8"})});if(n||!a)return(0,i.jsx)(ng,{className:"p-8",children:(0,i.jsx)(N,{title:"Failed to load settings",reset:()=>l(),children:(0,i.jsx)("p",{className:"text-sm text-[--muted]",children:String(n)})})});let f=new Map;for(let e of o)(f.get(e.group)??f.set(e.group,[]).get(e.group)).push(e);return(0,i.jsx)(ng,{className:"p-4 sm:p-8 space-y-4 relative",children:(0,i.jsxs)(nG,{value:h,onValueChange:e=>{p(e),m({to:".",search:t=>({...t,tab:e}),replace:!0,resetScroll:!1})},variant:"pill",className:x("w-full grid grid-cols-1 lg:grid lg:grid-cols-[280px,1fr] gap-4"),triggerClass:x("text-base px-6 rounded-[--radius-md] w-fit lg:w-full rounded-lg border-0","data-[state=active]:bg-[--subtle] data-[state=active]:text-white","dark:hover:text-white","h-9 lg:justify-start px-3 transition-all duration-200 hover:bg-[--subtle]/50 hover:transform"),listClass:x("w-full flex flex-wrap lg:flex-nowrap h-fit","lg:block p-2 lg:p-0"),children:[(0,i.jsx)(nY,{className:"flex-wrap max-w-full lg:space-y-2 lg:sticky lg:top-4",children:(0,i.jsx)(lU,{children:(0,i.jsx)("div",{className:"overflow-x-none overflow-y-hidden rounded-[--radius-md] space-y-1 lg:space-y-3 flex justify-center flex-wrap lg:block",children:[...f.entries()].map(e=>{let[t,s]=e;return(0,i.jsxs)(J,{className:"lg:p-2 contents lg:block border-0 bg-transparent lg:border lg:bg-gray-950/5 dark:lg:bg-gray-950/40",children:[(0,i.jsx)("p",{className:"hidden lg:block px-3 py-1 text-[10px] uppercase tracking-wider text-[--muted] font-semibold",children:t}),s.map(e=>(0,i.jsxs)(nJ,{value:e.section,className:"group",children:[(0,i.jsx)(e.icon,{className:"text-xl mr-3 transition-transform duration-200 group-hover:translate-x-0.5"}),e.label]},e.section))]},t)})})})}),(0,i.jsx)("div",{children:o.map(e=>(0,i.jsx)(nZ,{value:e.section,className:"space-y-4 animate-in fade-in-0 slide-in-from-bottom-2 duration-300",children:h===e.section&&(0,i.jsx)(oc,{tab:e,allKeys:a.keys,managed:d})},e.section))})]})})}}),NR=(0,r.un)({getParentRoute:()=>Nw,path:"streams",component:function(){var e,t;let s=(0,T.Z)(),{pathname:a}=(0,tk.z)(),r=dq(),n=null==(e=r.data)?void 0:e.summary,l=dF(r.data),d=(null==(t=sg.find(e=>a===`/dashboard/streams/${e.id}`))?void 0:t.id)??"active";return(0,i.jsxs)(ng,{className:"space-y-6 p-4 sm:p-8",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Streams"}),(0,i.jsx)("p",{className:"text-[--muted]",children:n?(0,i.jsxs)(i.Fragment,{children:[n.streaming," streaming \xb7 ",n.paused+n.idle," ","paused \xb7"," ",(0,i.jsx)(dD,{value:n.totalBytesPerSec,format:nj,durationSec:l/1e3})]}):"Everything being served through the proxy and the usenet engine"})]}),(0,i.jsx)(dY,{})]}),(0,i.jsx)(o3,{sections:sg,value:d,onChange:e=>s({to:`/dashboard/streams/${e}`})}),(0,i.jsx)("div",{className:"min-w-0",children:(0,i.jsx)(se.P.div,{initial:{opacity:0,y:6}
90,animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,i.jsx)(o.s,{})},a)})]})}}),NT=(0,r.un)({getParentRoute:()=>NR,path:"/",beforeLoad:()=>{throw(0,n.V2)({to:"/dashboard/streams/active"})}}),NI=(0,r.un)({getParentRoute:()=>NR,path:"active",component:function(){var e,t;let s=dq(),a=dF(s.data),r=(null==(e=s.data)?void 0:e.streams)??[],n=null==(t=s.data)?void 0:t.summary,[l,o]=u.useState(null),[d,c]=u.useState(()=>Date.now());return u.useEffect(()=>{let e=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:[(0,i.jsx)(oU,{label:"Streaming",value:String((null==n?void 0:n.streaming)??0),hint:(null==n?void 0:n.connectionLimit)?`Pushing bytes right now \xb7 ${n.connectionLimit} concurrent streams allowed`:"Pushing bytes right now"}),(0,i.jsx)(oU,{label:"Paused",value:String(((null==n?void 0:n.paused)??0)+((null==n?void 0:n.idle)??0)),hint:"Connected or waiting, but nothing moving"}),(0,i.jsx)(oU,{label:"Combined speed",className:"col-span-2 lg:col-span-1",value:(0,i.jsx)(dD,{value:(null==n?void 0:n.totalBytesPerSec)??0,format:nj,durationSec:a/1e3})})]}),(0,i.jsx)(oh,{query:s,errorTitle:"Failed to load active streams",children:()=>0===r.length?(0,i.jsx)(J,{className:"p-8",children:(0,i.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"Nothing streaming right now â rows appear as soon as a player starts pulling bytes through the proxy or the usenet engine."})}):(0,i.jsx)("div",{className:"space-y-2",children:r.map(e=>(0,i.jsx)(d8,{stream:e,now:d,frameMs:a,onBlock:o},e.id))})}),(0,i.jsx)(d7,{target:l,onClose:()=>o(null)})]})}}),NE=(0,r.un)({getParentRoute:()=>NR,path:"history",component:function(){var e,t;let s,[a,r]=u.useState("all"),[n,l]=u.useState(""),[o,d]=u.useState(1),[c,h]=u.useState(new Set);u.useEffect(()=>{d(1),h(new Set)},[a,n]);let p=function(e){let{limit:t=50,offset:s=0,username:a="",transport:r="",search:n=""}=e,l=n.trim(),i=new URLSearchParams({limit:String(t),offset:String(s)});return a&&i.set("username",a),r&&i.set("transport",r),l&&i.set("q",l),(0,ty.I)({queryKey:[...dL,"history",t,s,a,r,l],queryFn:()=>ea(`/dashboard/streams/history?${i.toString()}`),placeholderData:i1.rX,staleTime:1e4})}({limit:50,offset:(o-1)*50,transport:"all"===a?"":a,search:n}),g=(s=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea("DELETE /dashboard/streams/history",{body:e?{ids:e}:void 0}),onSuccess:()=>s.invalidateQueries({queryKey:[...dL,"history"]})})),f=(null==(e=p.data)?void 0:e.entries)??[],b=(null==(t=p.data)?void 0:t.total)??0,y=Math.max(1,Math.ceil(b/50)),j=f.length>0&&f.every(e=>c.has(e.id)),w=()=>{h(e=>{let t=new Set(e);if(j)for(let e of f)t.delete(e.id);else for(let e of f)t.add(e.id);return t})},N=(e,t)=>g.mutateAsync(e).then(e=>{m.oR.success(`${t} (${e.deleted})`),h(new Set),d(1)}).catch(e=>m.oR.error((null==e?void 0:e.message)??"Failed to delete")),k=sd({title:"Clear stream history",description:`Delete all ${b} finished stream${1===b?"":"s"}. Bandwidth totals are stored separately and are not affected.`,actionText:"Clear all",actionIntent:"alert-subtle",onConfirm:()=>void N(void 0,"History cleared")}),S=sd({title:"Delete selected streams",description:`Delete ${c.size} stream${1===c.size?"":"s"} from the history. Bandwidth totals are not affected.`,actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>void N([...c],"Deleted")}),C=c.size>0;return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,i.jsx)(K,{leftIcon:(0,i.jsx)(sm.iyI,{}),placeholder:"Search title or URLâ¦",value:n,onValueChange:l,fieldClass:"sm:flex-1 sm:min-w-0"}),(0,i.jsx)(nc,{value:a,options:ct,onValueChange:e=>r(e),fieldClass:"sm:w-40 sm:shrink-0"}),(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:shrink-0",children:[(0,i.jsx)("span",{className:"text-xs tabular-nums text-[--muted]",children:C?`${c.size} selected`:`${b.toLocaleString()} ${1===b?"entry":"entries"}`}),(0,i.jsx)(v,{size:"sm",intent:"alert-subtle",leftIcon:(0,i.jsx)(sm.id1,{}),loading:g.isPending,disabled:0===b&&!C,onClick:()=>C?S.open():k.open(),children:C?"Delete selected":"Clear all"})]})]}),(0,i.jsx)(oh,{query:p,errorTitle:"Failed to load stream history",children:()=>0===f.length?(0,i.jsx)(J,{className:"p-8",children:(0,i.jsxs)("p",{className:"text-center text-sm text-[--muted]",children:["No finished streams",n||"all"!==a?" match this filter":" yet","."]})}):(0,i.jsxs)(J,{className:"overflow-hidden p-0",children:[(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"w-10 p-3",children:(0,i.jsx)(lt,{value:j,onValueChange:w,"aria-label":"Select all on this page"})}),(0,i.jsx)("th",{className:"p-3",children:"Stream"}),(0,i.jsx)("th",{className:"p-3",children:"User"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Served"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Reqs"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Duration"}),(0,i.jsx)("th",{className:"p-3",children:"Ended"})]})}),(0,i.jsx)("tbody",{children:f.map(e=>{let t=e.endReason?ce[e.endReason]:void 0,s=c.has(e.id);return(0,i.jsxs)("tr",{className:x("border-t border-[--border]/50 hover:bg-[--subtle]/30",s&&"bg-brand/[0.06]"),children:[(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(lt,{value:s,onValueChange:()=>{var t;return t=e.id,void h(e=>{let s=new Set(e);return s.delete(t)||s.add(t),s})},"aria-label":"Select stream"})}),(0,i.jsx)("td",{className:"max-w-[420px] p-3",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(dZ,{transport:e.transport}),(0,i.jsx)("span",{className:"truncate",title:e.filename||e.displayUrl||e.targetKey,children:e.filename||e.displayUrl||e.targetKey})]})}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("span",{children:d4(e.username)}),e.clientIp&&(0,i.jsx)(d1,{ip:e.clientIp})]})}),(0,i.jsx)("td",{className:"p-3 text-right tabular-nums",children:ny(e.bytesServed)}),(0,i.jsx)("td",{className:"p-3 text-right tabular-nums",children:e.requests}),(0,i.jsx)("td",{className:"p-3 text-right tabular-nums text-[--muted]",children:nR((e.endedAt??e.lastSeenAt)-e.startedAt)}),(0,i.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[e.endedAt&&(0,i.jsx)("span",{className:"whitespace-nowrap",children:d6(e.endedAt)}),(null==t?void 0:t.className)&&(0,i.jsx)(dX,{className:t.className,children:t.label})]})})]},e.id)})})]})}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t border-[--border]/50 p-3 text-xs text-[--muted]",children:[(0,i.jsxs)("span",{className:"tabular-nums",children:["Showing ",(o-1)*50+1,"â",Math.min(50*o,b)," of ",b]}),y>1&&(0,i.jsxs)(dp,{children:[(0,i.jsx)(dg,{direction:"previous",isDisabled:o<=1,onClick:()=>d(e=>Math.max(1,e-1))}),db(o,y).map((e,t)=>"â¦"===e?(0,i.jsx)(df,{},`e${t}`):(0,i.jsx)(dx,{value:e,"data-selected":e===o,onClick:()=>d(e)},e)),(0,i.jsx)(dg,{direction:"next",isDisabled:o>=y,onClick:()=>d(e=>Math.min(y,e+1))})]})]})]})}),(0,i.jsx)(sc,{...k}),(0,i.jsx)(sc,{...S})]})}}),NM=(0,r.un)({getParentRoute:()=>NR,path:"bandwidth",component:function(){let[e,t]=u.useState("30d"),[s,a]=u.useState("total"),r=dB(e),n=r.data,l=(null==n?void 0:n.periodMode)==="monthly",o=u.useMemo(()=>{let e;if(!n)return{rows:[],userSeries:[]};let t=n.seriesByUser.map((e,t)=>({key:`u${t}`,label:e.aggregated?"Others":d4(e.username),color:e.aggregated?"var(--muted)":oR[t%oR.length]})),s=n.seriesByUser.map(e=>new Map(e.series.map(e=>[e.bucketMs,e.bytes])));return{rows:(e=new Map(n.series.map(e=>[e.bucketMs,e.bytes])),(function(e){let t=e.bucketMs>0?e.bucketMs:864e5,s=Math.floor(e.sinceMs/t)*t,a=Math.floor(e.generatedAt/t)*t,r=[];for(let e=s;e<=a&&r.length<400;e+=t)r.push(e);return r})(n).map(t=>{var s;let a;return{ms:t,t:(s=n.bucketMs,a=new Date(t),s<864e5?`${String(a.getHours()).padStart(2,"0")}:00`:cs.format(a)),at:n.bucketMs<864e5?cr.format(new Date(t)):ca.format(new Date(t)),bytes:e.get(t)??0}})).map(e=>(s.forEach((t,s)=>{e[`u${s}`]=t.get(e.ms)??0}),e)),userSeries:t}},[n]),d=l&&n?`since ${new Date(n.periodStart).toLocaleDateString()}`:"rolling 30 days",c=((null==n?void 0:n.globalLimit)??0)>0&&"30d"!==e;return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Bytes served through AIOStreams. Unproxied links are not counted."}
90),(0,i.jsx)(d2,{value:e,onChange:t,options:[{value:"24h",label:"24h"},{value:"7d",label:"7d"},{value:"30d",label:l?"This month":"30d"}]})]}),(0,i.jsx)(oh,{query:r,errorTitle:"Failed to load bandwidth",children:e=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:x("grid grid-cols-2 gap-3",c?"lg:grid-cols-4":"lg:grid-cols-3"),children:[(0,i.jsx)(oU,{label:"Total",value:ny(e.total)}),(0,i.jsx)(oU,{label:"Usenet",value:ny(e.byTransport.usenet??0),hint:e.total>0?nN((e.byTransport.usenet??0)/e.total):void 0}),(0,i.jsx)(oU,{label:"Proxy",value:ny(e.byTransport.proxy??0),hint:e.total>0?nN((e.byTransport.proxy??0)/e.total):void 0}),c&&(0,i.jsx)(oU,{label:"This period",value:ny(e.periodTotal),hint:e.globalLimit>0?`of ${ny(e.globalLimit)} \xb7 ${d}`:d})]}),e.globalLimit>0&&(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Shared bandwidth pool"}),(0,i.jsx)(cn,{used:e.periodTotal,limit:e.globalLimit})]}),(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,i.jsx)("h3",{className:"text-sm font-semibold",children:"Served over time"}),o.userSeries.length>0&&(0,i.jsx)(d2,{value:s,onChange:a,options:cl})]}),0===e.total?(0,i.jsx)("p",{className:"py-8 text-center text-sm text-[--muted]",children:"Nothing served in this window."}):"user"===s&&o.userSeries.length>0?(0,i.jsx)(oP,{data:o.rows,xKey:"t",series:o.userSeries,height:240,tooltipLabelKey:"at",valueFormatter:e=>ny(Number(e)),yTickFormatter:e=>ny(Number(e))}):(0,i.jsx)(o$,{data:o.rows,xKey:"t",series:[{key:"bytes",label:"Served",color:"var(--brand)"}],height:240,tooltipLabelKey:"at",valueFormatter:e=>ny(Number(e)),yTickFormatter:e=>ny(Number(e))})]}),(0,i.jsxs)(J,{className:"overflow-hidden p-0",children:[(0,i.jsx)("h3",{className:"p-4 pb-3 text-sm font-semibold",children:"By user"}),0===e.byUser.length?(0,i.jsx)("p",{className:"p-8 pt-0 text-center text-sm text-[--muted]",children:"No usage recorded in this window."}):(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"p-3",children:"User"}),(0,i.jsx)("th",{className:"p-3",children:"Usage this window"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Streams"})]})}),(0,i.jsx)("tbody",{children:e.byUser.map(e=>(0,i.jsxs)("tr",{className:"border-t border-[--border]/50",children:[(0,i.jsx)("td",{className:"p-3 font-medium",children:d4(e.username)}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(cn,{used:e.bytes,limit:e.limit})}),(0,i.jsx)("td",{className:"p-3 text-right text-xs tabular-nums text-[--muted]",children:e.connectionLimit>0?(0,i.jsx)(t5,{trigger:(0,i.jsxs)("span",{children:["max ",e.connectionLimit]}),children:"Concurrent stream limit"}):"unlimited"})]},e.username||"(unidentified)"))})]})})]})]})})]})}}),NP=(0,r.un)({getParentRoute:()=>NR,path:"bans",component:function(){var e;let t,s=(0,ty.I)({queryKey:dU,queryFn:()=>ea("/dashboard/streams/bans"),staleTime:1e4}),a=(t=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea(`DELETE /dashboard/streams/bans/${encodeURIComponent(e)}`),onSuccess:()=>t.invalidateQueries({queryKey:dU})})),r=(null==(e=s.data)?void 0:e.bans)??[];return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"A block refuses new streams. Stopping a stream on its own only ends the current one â a player will reopen it."}),(0,i.jsx)(ci,{})]}),(0,i.jsx)(oh,{query:s,errorTitle:"Failed to load blocks",children:()=>0===r.length?(0,i.jsx)(J,{className:"p-8",children:(0,i.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"No blocks in force."})}):(0,i.jsx)(J,{className:"overflow-hidden p-0",children:(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"p-3",children:"User"}),(0,i.jsx)("th",{className:"p-3",children:"Scope"}),(0,i.jsx)("th",{className:"p-3",children:"Reason"}),(0,i.jsx)("th",{className:"p-3",children:"Added"}),(0,i.jsx)("th",{className:"p-3",children:"Expires"}),(0,i.jsx)("th",{className:"p-3"})]})}),(0,i.jsx)("tbody",{children:r.map(e=>(0,i.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,i.jsx)("td",{className:"p-3 font-medium",children:e.username}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(dX,{children:"user"===e.scope?"All streams":"One title"})}),(0,i.jsx)("td",{className:"max-w-[280px] truncate p-3 text-[--muted]",children:e.reason||"â"}),(0,i.jsxs)("td",{className:"p-3 text-xs text-[--muted]",children:[d6(e.createdAt),e.createdBy?` by ${e.createdBy}`:""]}),(0,i.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:function(e){if(!e.expiresAt)return"Until lifted";let t=e.expiresAt-Date.now();if(t<=0)return"Expired";let s=Math.round(t/6e4);if(s<60)return`${s}m left`;let a=Math.round(s/60);return a<48?`${a}h left`:`${Math.round(a/24)}d left`}(e)}),(0,i.jsx)("td",{className:"p-3 text-right",children:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Lift block",disabled:a.isPending,onClick:()=>a.mutateAsync(e.id).then(()=>m.oR.success("Block lifted")).catch(e=>m.oR.error((null==e?void 0:e.message)??"Failed to lift"))})})]},e.id))})]})})})})]})}}),N$=(0,r.un)({getParentRoute:()=>Nw,path:"community",component:function(){var e;let t=(0,T.Z)(),{pathname:s}=(0,tk.z)(),a=(null==(e=sf.find(e=>s===`/dashboard/community/${e.id}`))?void 0:e.id)??"pending";return(0,i.jsxs)(ng,{className:"space-y-6 p-4 sm:p-8",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Community"}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Formatters and templates shared by users of this instance."})]}),(0,i.jsx)(o3,{sections:sf,value:a,onChange:e=>t({to:`/dashboard/community/${e}`})}),(0,i.jsx)("div",{className:"min-w-0",children:(0,i.jsx)(se.P.div,{initial:{opacity:0,y:6}
90,animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,i.jsx)(o.s,{})},s)})]})}}),ND=(0,r.un)({getParentRoute:()=>N$,path:"/",beforeLoad:()=>{throw(0,n.V2)({to:"/dashboard/community/pending"})}}),NL=(0,r.un)({getParentRoute:()=>N$,path:"pending",component:function(){let e=c8({pending:!0,limit:200});return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Approving a template does not whitelist its regex patterns or synced URLs; users apply it under their own access level unless you approve it as trusted."}),(0,i.jsx)(oh,{query:e,errorTitle:"Failed to load the review queue",children:e=>0===e.entries.length?(0,i.jsx)(J,{className:"p-8",children:(0,i.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"Nothing waiting for review."})}):(0,i.jsx)("div",{className:"space-y-4",children:e.entries.map(e=>(0,i.jsx)(ui,{item:e},e.id))})})]})}}),NO=(0,r.un)({getParentRoute:()=>N$,path:"published",component:function(){let[e,t]=(0,u.useState)("all"),[s,a]=(0,u.useState)(""),[r,n]=(0,u.useState)(0),l=c8({status:"approved",kind:"all"===e?void 0:e,search:s.trim()||void 0,limit:50,offset:r});return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)(ud,{}),(0,i.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,i.jsx)(K,{value:s,onValueChange:e=>{a(e),n(0)},placeholder:"Search name, description, author",leftIcon:(0,i.jsx)(sm.iyI,{}),className:"w-full sm:w-72"}),(0,i.jsx)(d2,{value:e,onChange:e=>{t(e),n(0)},options:[{value:"all",label:"All"},{value:"formatter",label:"Formatters"},{value:"template",label:"Templates"}]})]}),(0,i.jsx)(oh,{query:l,errorTitle:"Failed to load published items",children:e=>0===e.entries.length?(0,i.jsx)(J,{className:"p-8",children:(0,i.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"Nothing published yet."})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(J,{className:"overflow-hidden p-0",children:(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"p-3",children:"Item"}),(0,i.jsx)("th",{className:"p-3",children:"Author"}),(0,i.jsx)("th",{className:"p-3",children:"Tags"}),(0,i.jsx)("th",{className:"p-3",children:"Likes"}),(0,i.jsx)("th",{className:"p-3",children:"Trusted"}),(0,i.jsx)("th",{className:"p-3",children:"Updated"}),(0,i.jsx)("th",{className:"p-3"})]})}),(0,i.jsx)("tbody",{children:e.entries.map(e=>(0,i.jsx)(uc,{item:e},e.id))})]})})}),e.total>50&&(0,i.jsxs)("div",{className:"flex items-center justify-between text-xs text-[--muted]",children:[(0,i.jsxs)("span",{children:[r+1,"â",Math.min(r+50,e.total)," of"," ",e.total]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"gray-outline",disabled:0===r,onClick:()=>n(Math.max(0,r-50)),children:"Previous"}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",disabled:r+50>=e.total,onClick:()=>n(r+50),children:"Next"})]})]})]})})]})}}),NU=(0,r.un)({getParentRoute:()=>N$,path:"blocks",component:function(){let e=(0,ty.I)({queryKey:[...c9,"blocks"],queryFn:()=>ea("/dashboard/community/blocks"),staleTime:1e4}),t=c7(e=>ea(`DELETE /dashboard/community/blocks/${encodeURIComponent(e)}`));return(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Blocked configurations and addresses cannot upload, update or like community items. Add a block from an item in the review queue."}),(0,i.jsx)(oh,{query:e,errorTitle:"Failed to load blocks",children:e=>0===e.blocks.length?(0,i.jsx)(J,{className:"p-8",children:(0,i.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"No blocks in force."})}):(0,i.jsx)(J,{className:"overflow-hidden p-0",children:(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"p-3",children:"Kind"}),(0,i.jsx)("th",{className:"p-3",children:"Hash"}),(0,i.jsx)("th",{className:"p-3",children:"Reason"}),(0,i.jsx)("th",{className:"p-3",children:"Added"}),(0,i.jsx)("th",{className:"p-3"})]})}),(0,i.jsx)("tbody",{children:e.blocks.map(e=>(0,i.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(dX,{children:"owner"===e.kind?"Configuration":"Address"})}),(0,i.jsxs)("td",{className:"p-3 font-mono text-xs text-[--muted]",children:[e.hash.slice(0,12),"â¦"]}),(0,i.jsx)("td",{className:"max-w-[320px] truncate p-3 text-[--muted]",children:e.reason||"â"}),(0,i.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:d6(e.createdAt)}),(0,i.jsx)("td",{className:"p-3 text-right",children:(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Lift block",disabled:t.isPending,onClick:()=>t.mutateAsync(e.hash).then(()=>m.oR.success("Block lifted")).catch(e=>m.oR.error((null==e?void 0:e.message)??"Failed to lift"))})})]},e.hash))})]})})})})]})}}),NF=(0,r.un)({getParentRoute:()=>Nw,path:"users",component:function(){let e=(0,e3.jE)(),[t,s]=u.useState(1),[a,r]=u.useState(25),[n,l]=u.useState(""),[o,d]=u.useState("created_at"),[c,h]=u.useState("desc"),p=np(n,300),[x,g]=u.useState(null),[f,b]=u.useState(new Set),[y,j]=u.useState(""),[N,k]=u.useState(!1),[S,C]=u.useState(1);u.useEffect(()=>C(t),[t]);let _=(0,ty.I)({queryKey:["dashboard","users",t,a,p,o,c],queryFn:()=>ea(`/dashboard/users?page=${t}&limit=${a}&q=${encodeURIComponent(p)}&sort=${o}&dir=${c}`),staleTime:1e4}),A=(0,e5.n)({mutationFn:e=>ea(`DELETE /dashboard/users/${e}`),onSuccess:()=>
90{m.oR.success("User config deleted."),e.invalidateQueries({queryKey:["dashboard","users"]})},onError:e=>m.oR.error((null==e?void 0:e.message)??"Delete failed")}),R=(0,e5.n)({mutationFn:e=>ea("DELETE /dashboard/users",{body:e}),onSuccess:t=>{m.oR.success(`Deleted ${t.deleted} user config${1===t.deleted?"":"s"}.`),b(new Set),e.invalidateQueries({queryKey:["dashboard","users"]})},onError:e=>m.oR.error((null==e?void 0:e.message)??"Batch delete failed")}),[T,I]=u.useState(null),E=sd({title:"Delete user config",description:"This permanently deletes this user configuration. This cannot be undone.",actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>{T&&A.mutate(T)}}),M=sd({title:`Delete ${f.size} selected`,description:`This permanently deletes ${f.size} user configurations. This cannot be undone.`,actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>R.mutate({uuids:[...f]})}),P=async e=>{try{g(await ea(`/dashboard/users/${e}`))}catch(e){m.oR.error((null==e?void 0:e.message)??"Failed to load user")}},$=_.data,D=(null==$?void 0:$.items)??[],L=D.length>0&&D.every(e=>f.has(e.uuid)),O=D.some(e=>f.has(e.uuid))&&!L,U=e=>{b(t=>{let s=new Set(t);if(!0===e)for(let e of D)s.add(e.uuid);else for(let e of D)s.delete(e.uuid);return s})};return(0,i.jsxs)(ng,{className:"p-4 sm:p-8 space-y-4",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Users"}),(0,i.jsx)("p",{className:"text-[--muted]",children:$?`${$.total} configured users`:"Browse user configs"})]}),(0,i.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 sm:items-center",children:[(0,i.jsx)(K,{leftIcon:(0,i.jsx)(sm.iyI,{}),placeholder:"Search by UUIDâ¦",value:n,onValueChange:e=>{l(e),s(1)},className:"flex-1"}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)("span",{className:"text-xs text-[--muted]",children:"Per page"}),(0,i.jsx)(nc,{value:String(a),options:oX.map(e=>({label:e,value:e})),onValueChange:e=>{r(Number(e)||25),s(1)},className:"w-24"})]})]}),f.size>0&&(0,i.jsxs)(J,{className:"p-3 flex flex-wrap items-center gap-3 border-brand/30 bg-brand/5",children:[(0,i.jsxs)("span",{className:"text-sm",children:[f.size," selected"]}),(0,i.jsx)(v,{size:"sm",intent:"gray-subtle",onClick:()=>b(new Set),children:"Clear"}),(0,i.jsx)(v,{size:"sm",intent:"alert-subtle",leftIcon:(0,i.jsx)(sm.id1,{}),loading:R.isPending,onClick:()=>M.open(),children:"Delete selected"}),p&&(0,i.jsx)(v,{size:"sm",intent:"alert-outline",onClick:()=>{j(""),k(!0)},children:"Delete all matching filter"})]}),(0,i.jsx)(oh,{query:_,errorTitle:"Failed to load users",children:()=>(0,i.jsx)(J,{className:"p-0 overflow-hidden",children:(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"p-3 w-10",children:(0,i.jsx)(lt,{value:!!L||!!O&&"indeterminate",onValueChange:U,"aria-label":"Select all on page"})}),(0,i.jsx)("th",{className:"p-3",children:"UUID"}),[["created_at","Created"],["accessed_at","Last accessed"]].map(e=>{let[t,s]=e;return(0,i.jsxs)("th",{className:"p-3 cursor-pointer select-none",onClick:()=>{o===t?h(e=>"asc"===e?"desc":"asc"):(d(t),h("desc"))},children:[s,o===t?"asc"===c?" â²":" â¼":""]},t)}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Req 24h"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,i.jsxs)("tbody",{children:[D.map(e=>(0,i.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)(lt,{value:f.has(e.uuid),onValueChange:t=>{var s;return s=e.uuid,void b(e=>{let a=new Set(e);return!0===t?a.add(s):a.delete(s),a})},"aria-label":`Select ${e.uuid}`})}),(0,i.jsxs)("td",{className:"p-3 font-mono text-xs cursor-pointer",title:e.uuid,onClick:()=>void nf(e.uuid,{onSuccess:()=>m.oR.success("UUID copied"),onError:()=>m.oR.error("Copy failed")}),children:[e.uuid.slice(0,8),"â¦",e.uuid.slice(-4)]}),(0,i.jsx)("td",{className:"p-3",children:nI(e.createdAt)}),(0,i.jsx)("td",{className:"p-3",children:nI(e.accessedAt)}),(0,i.jsx)("td",{className:"p-3 text-right tabular-nums",children:e.requests24h}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,i.jsx)(w,{size:"sm",intent:"gray-subtle",icon:(0,i.jsx)(sm.wfp,{}),"aria-label":"Details",onClick:()=>P(e.uuid)}),(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Delete",onClick:()=>{I(e.uuid),E.open()}})]})})]},e.uuid)),$&&0===D.length&&(0,i.jsx)("tr",{children:(0,i.jsx)("td",{colSpan:6,className:"p-8 text-center text-[--muted]",children:"No users found."})})]})]})})})}),$&&(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,i.jsxs)("span",{className:"text-xs text-[--muted]",children:["Showing ",($.page-1)*$.limit+ +(D.length>0),"â",Math.min($.page*$.limit,$.total)," of ",$.total]}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"gray-outline",disabled:t<=1,onClick:()=>s(1),children:"\xab"}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",disabled:t<=1,onClick:()=>s(e=>Math.max(1,e-1)),children:"Prev"}),(0,i.jsxs)("div",{className:"flex items-center gap-1 text-xs text-[--muted]",children:["Page",(0,i.jsx)(lm,{value:S,min:1,max:Math.max(1,$.pages),onValueChange:e=>C(Number(e)||1),onKeyDown:e=>{"Enter"===e.key&&s(Math.max(1,Math.min($.pages||1,Number(S)||1)))},className:"w-20"}),"/ ",$.pages||1]}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",disabled:t>=$.pages,onClick:()=>s(e=>Math.min($.pages||1,e+1)),children:"Next"}),(0,i.jsx)(v,{size:"sm",intent:"gray-outline",disabled:t>=$.pages,onClick:()=>s($.pages||1),children:"\xbb"})]})]}),(0,i.jsx)(sl,{open:!!x,onOpenChange:e=>!e&&g(null),title:"User detail",children:x&&(0,i.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-[--muted]",children:"UUID"}),(0,i.jsx)("div",{className:"font-mono break-all",children:x.uuid})]}),(0,i.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-[--muted]",children:"Created"}),nI(x.createdAt)]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-[--muted]",children:"Updated"}),nI(x.updatedAt)]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-[--muted]",children:"Last accessed"}),nI(x.accessedAt)]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-[--muted]",children:"Requests 24h"}),x.requests24h]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"text-xs text-[--muted] mb-1",children:"Recent error stages"}),x.recentErrorStages.length?(0,i.jsx)("ul",{className:"space-y-1",children:x.recentErrorStages.map(e=>(0,i.jsxs)("li",{className:"flex justify-between",children:[(0,i.jsx)("span",{children:e.stage}),(0,i.jsx)("span",{className:"tabular-nums text-[--muted]",children:e.count})]},e.stage))}):(0,i.jsx)("span",{className:"text-[--muted]",children:"None"})]})]})}),(0,i.jsx)(sc,{...E}),(0,i.jsx)(sc,{...M}),(0,i.jsx)(sl,{open:N,onOpenChange:k,title:"Delete all users matching filter",footer:(0,i.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,i.jsx)(v,{intent:"gray-outline",size:"sm",onClick:()=>k(!1),children:"Cancel"}),(0,i.jsx)(v,{intent:"alert-subtle",size:"sm",disabled:"DELETE"!==y||R.isPending,loading:R.isPending,onClick:()=>{R.mutate({allMatching:!0,q:p}),k(!1)},children:"Delete"})]}),children:(0,i.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,i.jsxs)("p",{children:["This permanently deletes ",(0,i.jsx)("strong",{children:"every"})," user configuration matching your current search (",(0,i.jsx)("code",{className:"font-mono",children:p||"<empty>"}),"). This cannot be undone."]}),(0,i.jsxs)("p",{className:"text-[--muted]",children:["Type ",(0,i.jsx)("code",{className:"font-mono",children:"DELETE"})," to confirm."]}),(0,i.jsx)(K,{value:y,onValueChange:j,placeholder:"DELETE"})]})})]})}}),Nz=(0,r.un)({getParentRoute:()=>Nw,path:"tasks",component:function(){let e=(0,e3.jE)(),t=(0,ty.I)({queryKey:["dashboard","tasks"],queryFn:()=>ea("/dashboard/tasks"),refetchInterval:5e3}),s=(0,e5.n)({mutationFn:e=>{let{id:t,confirm:s}=e;return ea(`POST /dashboard/tasks/${t}/run`,{body:{confirm:s}})},onSuccess:t=>{m.oR.success((null==t?void 0:t.message)||"Task finished"),e.invali
90dateQueries({queryKey:["dashboard","tasks"]})},onError:e=>m.oR.error((null==e?void 0:e.message)??"Task failed")}),[a,r]=u.useState(null),n=sd({title:"Run destructive task",description:"This task is destructive and cannot be undone. Run it now?",actionText:"Run",actionIntent:"alert-subtle",onConfirm:()=>a&&s.mutate({id:a,confirm:!0})});return(0,i.jsxs)(ng,{className:"p-4 sm:p-8 space-y-6",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Tasks"}),(0,i.jsx)("p",{className:"text-[--muted]",children:"Background & scheduled work. Run manual tasks on demand."})]}),(0,i.jsx)(oh,{query:t,errorTitle:"Failed to load tasks",children:e=>(0,i.jsx)("div",{className:"space-y-6",children:(e=>{let t=new Map;for(let s of e)(t.get(s.category)??t.set(s.category,[]).get(s.category)).push(s);return[...t.entries()]})(e.tasks).map(e=>{let[t,l]=e;return(0,i.jsxs)("div",{className:"space-y-2",children:[(0,i.jsx)("h3",{className:"text-xs uppercase tracking-wider text-[--muted] font-semibold",children:t}),(0,i.jsx)("div",{className:"grid gap-2",children:l.map(e=>{var t;return(0,i.jsxs)(J,{className:"p-4",children:[(0,i.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[(0,i.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,i.jsx)("span",{className:"font-medium",children:e.label}),e.destructive&&(0,i.jsx)("span",{className:"text-[10px] uppercase px-1.5 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-400/20",children:"destructive"}),(0,i.jsx)("span",{className:x("text-[10px] uppercase px-1.5 py-0.5 rounded border",e.enabled?"bg-emerald-500/10 text-emerald-500 border-emerald-500/20":"bg-[--subtle] text-[--muted] border-[--border]"),children:e.enabled?"enabled":"disabled"}),e.claimedBy&&(0,i.jsxs)("span",{className:"text-[10px] uppercase px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400 border border-blue-400/20",children:["running on ",e.claimedBy.slice(0,8)]})]}),(0,i.jsx)("p",{className:"text-xs text-[--muted] mt-0.5",children:e.description})]}),(0,i.jsxs)("div",{className:"text-xs text-[--muted] grid grid-cols-2 gap-x-6 gap-y-0.5 sm:min-w-[220px]",children:[(0,i.jsx)("span",{children:"Schedule"}),(0,i.jsx)("span",{className:"text-[--foreground]",children:(t=e.intervalMs)?`every ${nS(t/1e3)}`:"manual"}),(0,i.jsx)("span",{children:"Last run"}),(0,i.jsxs)("span",{className:x("error"===e.lastStatus&&"text-red-400","ok"===e.lastStatus&&"text-emerald-500"),children:[o0(e.lastRunAt),null!=e.lastDurationMs&&` \xb7 ${o1(e.lastDurationMs)}`]}),"scheduled"===e.kind&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{children:"Next run"}),(0,i.jsx)("span",{className:"text-[--foreground]",children:o0(e.nextRunAt)})]})]}),(0,i.jsx)(v,{size:"sm",intent:e.destructive?"alert-outline":"gray-outline",leftIcon:e.running?void 0:(0,i.jsx)(sm.UIR,{}),loading:e.running||s.isPending&&a===e.id,disabled:e.running,className:"w-full sm:w-auto",onClick:()=>{r(e.id),e.destructive?n.open():s.mutate({id:e.id})},children:"Run now"})]}),e.runs.length>1&&(0,i.jsxs)("details",{className:"mt-3 group",children:[(0,i.jsxs)("summary",{className:"cursor-pointer text-xs text-[--muted] flex items-center gap-1 list-none [&::-webkit-details-marker]:hidden",children:[(0,i.jsx)(sm.nwe,{className:"transition-transform group-open:rotate-180"}),e.runs.length," replicas"]}),(0,i.jsx)("div",{className:"mt-2 grid gap-1",children:e.runs.map(e=>(0,i.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,i.jsx)("span",{className:"font-mono text-[--muted]",children:e.instanceId.slice(0,8)}),e.self&&(0,i.jsx)("span",{className:"text-[10px] text-[--muted]",children:"this one"}),(0,i.jsxs)("span",{className:x("ml-auto","error"===e.lastStatus&&"text-red-400","ok"===e.lastStatus&&"text-emerald-500"),children:[o0(e.lastRunAt),null!=e.lastDurationMs&&` \xb7 ${o1(e.lastDurationMs)}`]})]},e.instanceId))})]}),"error"===e.lastStatus&&e.lastError&&(0,i.jsxs)("details",{className:"mt-3 group",children:[(0,i.jsxs)("summary",{className:"cursor-pointer text-xs text-red-400 flex items-center gap-1 list-none [&::-webkit-details-marker]:hidden",children:[(0,i.jsx)(sm.nwe,{className:"transition-transform group-open:rotate-180"}),"Last error"]}),(0,i.jsx)("pre",{className:"mt-2 p-2 text-[11px] font-mono whitespace-pre-wrap break-words bg-red-500/5 border border-red-400/20 rounded text-red-400/90",children:e.lastError})]})]},e.id)})})]},t)})})}),(0,i.jsx)(sc,{...n})]})}}),NV=(0,r.un)({getParentRoute:()=>Nw,path:"cache",component:function(){let e=(0,e3.jE)(),t=(0,ty.I)({queryKey:["dashboard","cache"],queryFn:()=>ea("/dashboard/cache"),refetchInterval:1e4}),s=t.data,[a,r]=u.useState({}),[n,l]=u.useState(null),o=async e=>{l(e);try{let t=await ea("POST /dashboard/cache/scan",{body:{prefix:e}});r(s=>({...s,[e]:t}))}catch(e){m.oR.error((null==e?void 0:e.message)??"Scan failed")}finally{l(null)}},d=(0,e5.n)({mutationFn:e=>ea("POST /dashboard/cache/clear",{body:{confirm:!0,prefix:e}}),onSuccess:()=>
90{m.oR.success("Cache cleared"),e.invalidateQueries({queryKey:["dashboard","cache"]})},onError:e=>m.oR.error((null==e?void 0:e.message)??"Clear failed")}),c=(0,e5.n)({mutationFn:()=>ea("POST /dashboard/tasks/clear-expired-cache/run",{body:{}}),onSuccess:t=>{m.oR.success((null==t?void 0:t.message)||"Expired keys cleared"),e.invalidateQueries({queryKey:["dashboard","cache"]})},onError:e=>m.oR.error((null==e?void 0:e.message)??"Failed")}),[h,p]=u.useState(),g=sd({title:"Clear cache",description:"This permanently removes cached entries. This cannot be undone.",actionText:"Clear",actionIntent:"alert-subtle",onConfirm:()=>d.mutate(h)}),f=null==s?void 0:s.totals;return(0,i.jsxs)(ng,{className:"p-4 sm:p-8 space-y-4",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Cache"}),(0,i.jsx)("p",{className:"text-[--muted]",children:f?`${f.instances} instances \xb7 ${f.items??"â"} items${null!=f.redisDbSize?` \xb7 Redis DBSIZE ${f.redisDbSize}`:""}`:"Cache backends & prefixes"})]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[(0,i.jsx)(v,{size:"sm",intent:"gray-outline",leftIcon:(0,i.jsx)(sm.Zxy,{}),loading:c.isPending,onClick:()=>c.mutate(),children:"Clear expired"}),(0,i.jsx)(v,{size:"sm",intent:"alert-outline",leftIcon:(0,i.jsx)(sm.id1,{}),onClick:()=>{p(void 0),g.open()},children:"Clear all"})]})]}),(0,i.jsx)(oh,{query:t,errorTitle:"Failed to load cache",children:e=>(0,i.jsx)(J,{className:"p-0 overflow-hidden",children:(0,i.jsx)("div",{className:"overflow-x-auto",children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,i.jsxs)("tr",{className:"text-left",children:[(0,i.jsx)("th",{className:"p-3",children:"Prefix"}),(0,i.jsx)("th",{className:"p-3",children:"Backend"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Items"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Max"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Est. size"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Expired"}),(0,i.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,i.jsx)("tbody",{children:e.instances.map(e=>(0,i.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,i.jsx)("td",{className:"p-3 font-mono text-xs",children:e.name}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsx)("span",{className:x("text-[10px] uppercase px-1.5 py-0.5 rounded border",o2[e.backend]),children:e.backend})}),(0,i.jsx)("td",{className:"p-3 text-right tabular-nums",children:null!=e.items?e.items:a[e.name]?(0,i.jsxs)(i.Fragment,{children:[a[e.name].capped?"â¥":"",a[e.name].count]}):"â"}),(0,i.jsx)("td",{className:"p-3 text-right tabular-nums",children:"disk"===e.backend?ny(e.maxSize):e.maxSize??"â"}),(0,i.jsx)("td",{className:"p-3 text-right tabular-nums",children:ny(e.estBytes)}),(0,i.jsx)("td",{className:"p-3 text-right tabular-nums",children:e.expired??"â"}),(0,i.jsx)("td",{className:"p-3",children:(0,i.jsxs)("div",{className:"flex justify-end gap-1",children:["redis"===e.backend&&null==e.items&&(0,i.jsx)(v,{size:"sm",intent:"gray-subtle",leftIcon:(0,i.jsx)(sm.LUJ,{}),loading:n===e.name,onClick:()=>o(e.name),title:"May be slow on large Redis instances",children:"Scan"}),(0,i.jsx)(w,{size:"sm",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Clear prefix",onClick:()=>{p(e.name),g.open()}})]})})]},e.name))})]})})})}),(0,i.jsx)("p",{className:"text-xs text-[--muted]",children:"Redis per-prefix counts are opt-in (the âScanâ button) and rate-limited â a SCAN can be slow on large Redis instances."}),(0,i.jsx)(sc,{...g})]})}}),Nq=(0,r.un)({getParentRoute:()=>Nw,path:"blocklist",component:function(){var e;let t=(0,T.Z)(),{pathname:s}=(0,tk.z)(),a=ds().data,r=(null==(e=sx.find(e=>s===`/dashboard/blocklist/${e.id}`))?void 0:e.id)??"sources";return(0,i.jsxs)(ng,{className:"p-4 sm:p-8 space-y-6",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Release Blocklists"}),(0,i.jsx)("p",{className:"text-[--muted]",children:a?`${a.counts.total} entries across ${a.sources.length} sources \xb7 ${a.counts.overrides} overrides`:"Shared verdicts about dead, defective, fake and mislabeled releases"})]}),(0,i.jsx)(o3,{sections:sx,value:r,onChange:e=>t({to:`/dashboard/blocklist/${e}`})}),(0,i.jsx)("div",{className:"min-w-0",children:(0,i.jsx)(se.P.div,{initial:{opacity:0,y:6}
90,animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,i.jsx)(o.s,{})},s)})]})}}),NB=(0,r.un)({getParentRoute:()=>Nq,path:"/",beforeLoad:()=>{throw(0,n.V2)({to:"/dashboard/blocklist/sources"})}}),NK=(0,r.un)({getParentRoute:()=>Nq,path:"sources",component:function(){let e=ds(),t=da();return(0,i.jsx)(oh,{query:e,errorTitle:"Failed to load the blocklist",children:e=>(0,i.jsx)(dr,{snapshot:e,invalidate:t})})}}),NH=(0,r.un)({getParentRoute:()=>Nq,path:"entries",component:function(){let e=ds(),t=da();return(0,i.jsx)(oh,{query:e,errorTitle:"Failed to load the blocklist",children:e=>(0,i.jsx)(dv,{snapshot:e,invalidate:t})})}}),NW=(0,r.un)({getParentRoute:()=>Nq,path:"publishing",component:function(){let e=ds(),t=da();return(0,i.jsx)(oh,{query:e,errorTitle:"Failed to load the blocklist",children:e=>(0,i.jsx)(dC,{snapshot:e,invalidate:t})})}}),NG=(0,r.un)({getParentRoute:()=>Nw,path:"usenet",component:function(){var e;let t=(0,T.Z)(),{pathname:s}=(0,tk.z)(),a=(null==(e=sp.find(e=>s===`/dashboard/usenet/${e.id}`))?void 0:e.id)??"library";return(0,i.jsxs)(ng,{className:"p-4 sm:p-8 space-y-6",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{children:"Usenet"}),(0,i.jsx)("p",{className:"text-[--muted]",children:"The built-in usenet engine â your library, live activity, provider performance and settings."})]}),(0,i.jsx)(o3,{sections:sp,value:a,onChange:e=>t({to:`/dashboard/usenet/${e}`})}),(0,i.jsx)("div",{className:"min-w-0",children:(0,i.jsx)(se.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,i.jsx)(o.s,{})},s)})]})}}),NY=(0,r.un)({getParentRoute:()=>NG,path:"/",beforeLoad:()=>{throw(0,n.V2)({to:"/dashboard/usenet/library"})}}),NJ=(0,r.un)({getParentRoute:()=>NG,path:"library",component:function(){var e,t,s,a;let r,n,l,o,d,c,h;r=(0,e3.jE)(),u.useEffect(()=>{let e=new EventSource("/api/v1/dashboard/usenet/library/stream",{withCredentials:!0});return e.onmessage=()=>{r.invalidateQueries({queryKey:[...i3,"library"]})},()=>e.close()},[r]);let[p,g]=u.useState("all"),[f,b]=u.useState(""),v=np(f,300),[y,j]=u.useState(null),[N,k]=u.useState(null),[S,C]=u.useState(!1),[_,A]=u.useState(new Map),[R,T]=u.useState(c_),I=co("(min-width: 640px)")?R:"grid",[E,M]=u.useState("activity"),[P,$]=u.useState("desc"),[D,L]=u.useState(1),[O,U]=u.useState(cA);u.useEffect(()=>L(1),[p,v,E,P,O]);let F=function(e){let{limit:t=50,offset:s=0,status:a="all",statuses:r=[],search:n="",sort:l,dir:i}=e,o=[...r].sort().join(","),d=n.trim(),c=new URLSearchParams({limit:String(t),offset:String(s),status:a});return o&&c.set("statuses",o),d&&c.set("q",d),l&&c.set("sort",l),i&&c.set("dir",i),(0,ty.I)({queryKey:[...i3,"library",t,s,a,o,d,l??"",i??""],queryFn:()=>ea(`/dashboard/usenet/library?${c.toString()}`),placeholderData:i1.rX,staleTime:1e4})}({statuses:"all"===p?[]:[p],search:v,sort:E,dir:P,limit:O,offset:(D-1)*O}),z=(n=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea(`DELETE /dashboard/usenet/library/${encodeURIComponent(e)}`),onSuccess:()=>n.invalidateQueries({queryKey:[...i3,"library"]})})),V=(l=(0,e3.jE)(),(0,e5.n)({mutationFn:()=>ea("DELETE /dashboard/usenet/library"),onSuccess:()=>l.invalidateQueries({queryKey:[...i3,"library"]})})),q=(o=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea("POST /dashboard/blocklist/mark",{body:{releases:e.map(i2).filter(e=>e.length>0),verdict:"dead"}}),onSuccess:()=>{o.invalidateQueries({queryKey:[...i3,"library"]}),o.invalidateQueries({queryKey:["dashboard","blocklist"]})}})),B=(d=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea("POST /dashboard/blocklist/unmark",{body:{releases:e.map(i2).filter(e=>e.length>0)}}),onSuccess:()=>{d.invalidateQueries({queryKey:[...i3,"library"]}),d.invalidateQueries({queryKey:["dashboard","blocklist"]})}})),H=(c=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea("POST /dashboard/usenet/library/requeue",{body:{hashes:e}}),onSuccess:()=>c.invalidateQueries({queryKey:[...i3,"library"]})})),W=(h=(0,e3.jE)(),(0,e5.n)({mutationFn:e=>ea(`POST /dashboard/arr/repairs/${encodeURIComponent(e)}`),onSuccess:()=>h.invalidateQueries({queryKey:[...i3,"library"]})})),G=u.useRef([]),[Y,Z]=u.useState({mode:"block",entries:[]}),Q=(null==(e=F.data)?void 0:e.entries)??[],X=(null==(t=F.data)?void 0:t.total)??0,ee=Math.max(1,Math.ceil(X/O));u.useEffect(()=>{D>ee&&L(ee)},[D,ee]);let et=sd({title:"Delete library entries",description:"Remove the selected NZB(s) from the library/history. Failed entries are retried on the next request.",actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>{let e=G.current;0!==e.length&&Promise.allSettled(e.map(e=>z.mutateAsync(e))).then(t=>{let s=t.filter(e=>"rejected"===e.status).length;s?m.oR.error(`${s} entr${1===s?"y":"ies"} failed to delete`):m.oR.success(1===e.length?"Entry deleted":"Entries deleted"),ex()})}}),es=sd({title:"Delete all library entries",description:"This will remove every entry from the library, including active imports. This action cannot be undone.",actionText:"Delete all",actionIntent:"alert-subtle",onConfirm:()=>{V.mutateAsync(void 0).then(()=>{m.oR.success("Library cleared"),ex()}).catch(e=>{m.oR.error((null==e?void 0:e.message)??"Failed to clear library")})}}),er=Y.entries.length,en="unblock"===Y.mode,el=(null==(s=Y.entries[0])?void 0:s.name)??(null==(a=Y.entries[0])?void 0:a.nzbHash)??"",ei=sd({title:`${en?"Unblock":"Block"} release${er>1?"s":""}`,description:en?er>1?`Allow ${er} releases again on this instance? Any local verdict is dropped and remote lists stop filtering them.`:`Allow "${el}" again on this instance? Any local verdict is dropped and remote lists stop filtering it.`:er>1?`Mark ${er} releases as dead on this instance's release blocklist? Their streams stop appearing in results; undo from the Blocklist page.`:`Mark "${el}" as dead on this instance's release blocklist? Its streams stop appearing in results; undo from the Blocklist page.`,actionText:en?"Unblock":"Block",actionIntent:en?"primary-subtle":"alert-subtle",onConfirm:()=>{0!==er&&(en?B:q).mutateAsync(Y.entries).then(()=>{let e=en?"unblocked":"blocked";m.oR.success(1===er?`Release ${e}`:`${er} releases ${e}`),ex()}).catch(e=>m.oR.error((null==e?void 0:e.message)??`${en?"Unblock":"Block"} failed`))}}),eo=e=>{Z({mode:"block",entries:[e]}),ei.open()},ed=e=>{Z({mode:"unblock",entries:[e]}),ei.open()},ec=e=>{W.mutateAsync(e.nzbHash).then(e=>{let{outcome:t}=e;"repaired"===t?m.oR.success("Release marked failed; the arr will replace it"):"already-handled"===t?m.oR.info("The arr had already failed this release"):"not-linked"===t?m.oR.error("No Sonarr/Radarr instance has a grab for this download"):"deferred"===t?m.oR.warning("Repair is backing off after an earlier error"):m.oR.error("Repair gave up; see the entry details")}).catch(e=>m.oR.error((null==e?void 0:e.message)??"Repair failed"))},eu=e=>{0!==e.length&&H.mutateAsync(e).then(e=>{0===e.requeued?m.oR.error(e.error??"Requeue failed"):(e.failed>0?m.oR.warning(`${e.requeued} requeued, ${e.failed} failed: ${e.error??""}`):m.oR.success(1===e.requeued?"Entry requeued":`${e.requeued} entries requeued`),ex())}).catch(e=>m.oR.error((null==e?void 0:e.message)??"Requeue failed"))},em=e=>{G.current=[e],et.open()},eh=(e,t)=>A(s=>{let a=new Map(s);return t?a.set(e.nzbHash,e):a.delete(e.nzbHash),a}),ep=Q.length>0&&Q.every(e=>_.has(e.nzbHash)),ex=()=>{C(!1),A(new Map)};return(0,i.jsxs)("div",{className:"space-y-4 overflow-x-hidden",children:[(0,i.jsx)(cE,{}),(0,i.jsxs)("div",{className:"flex flex-col gap-2 xl:flex-row xl:items-center",children:[(0,i.jsx)(K,{leftIcon:(0,i.jsx)(sm.iyI,{}),placeholder:"Search by nameâ¦",value:f,onValueChange:b,fieldClass:"xl:flex-1 xl:min-w-0"}),(0,i.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center xl:shrink-0",children:[(0,i.jsx)(nc,{value:p,options:cy,onValueChange:e=>g(e),fieldClass:"sm:w-36 sm:flex-auto xl:flex-none"}),(0,i.jsxs)("div",{className:"flex items-stretch gap-2 sm:flex-auto xl:flex-none",children:[(0,i.jsx)(nc,{value:E,options:cj,onValueChange:e=>{M(e),$(cw[e])},fieldClass:"sm:w-40 sm:flex-auto xl:flex-none"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"md",intent:"gray-outline",icon:"asc"===P?(0,i.jsx)(sm.rH8,{}):(0,i.jsx)(sm.stI,{}),"aria-label":"asc"===P?"Ascending":"Descending",onClick:()=>$(e=>"asc"===e?"desc":"asc")}),children:"asc"===P?"Ascending":"Descending"})]}),(0,i.jsx)(nc,{value:String(O),options:ck,onValueChange:e=>(e=>{U(e);try{localStorage.setItem(cC,String(e))}catch{}})(Number(e)),fieldClass:"sm:w-32 sm:flex-auto xl:flex-none"}),(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:justify-start sm:shrink-0",children:[(0,i.jsx)("div",{className:"hidden sm:block",children:(0,i.jsx)(cR,{value:R,onChange:e=>{T(e);try{localStorage.setItem(cS,e)}catch{}}})}),(0,i.jsx)("div",{className:"flex items-center gap-1.5",children:S?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("span",{className:"text-xs text-[--muted] tabular-nums",children:[_.size," selected"]}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"md",intent:"gray-subtle",icon:ep?(0,i.jsx)(sm.B_A,{}):(0,i.jsx)(sm.aJB,{}),"aria-label":ep?"Clear selection":"Select all",disabled:0===Q.length,onClick:()=>A(e=>{let t=new Map(e);if(ep)for(let e of Q)t.delete(e.nzbHash);else for(let e of Q)t.set(e.nzbHash,e);return t})}),children:ep?"Clear selection":"Select all"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"md",intent:"gray-subtle",icon:(0,i.jsx)(sm.Zxy,{}),"aria-label":"Requeue selected",loading:H.isPending,disabled:0===_.size,onClick:()=>eu([..._.keys()])}),children:"Requeue selected"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"md",intent:"gray-subtle",icon:(0,i.jsx)(sm.PLI,{}),"aria-label":"Block selected",loading:q.isPending,disabled:0===_.size,onClick:()=>{let e=[..._.values()].filter(e=>i2(e).length>0);0===e.length?m.oR.error("None of the selected entries can be blocked"):(Z({mode:"block",entries:e}),ei.open())}}),children:"Block selected releases"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"md",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Delete selected",disabled:0===_.size,onClick:()=>{0!==_.size&&(G.current=[..._.keys()],et.open())}}),children:"Delete selected"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"md",intent:"gray-outline",icon:(0,i.jsx)(sm.Gsv,{}),"aria-label":"Done selecting",onClick:ex}),children:"Done"})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"md",intent:"alert-subtle",icon:(0,i.jsx)(sm.id1,{}),"aria-label":"Delete all entries",loading:V.isPending,onClick:es.open}),children:"Delete all"}),(0,i.jsx)(t5,{trigger:(0,i.jsx)(w,{size:"md",intent:"gray-outline",icon:(0,i.jsx)(sm.ekd,{}),"aria-label":"Select entries",disabled:0===Q.length,onClick:()=>C(!0)}),children:"Select"})]})})]})]})]}),(0,i.jsx)(oh,{query:F,errorTitle:"Failed to load library",children:e=>0===e.entries.length?(0,i.jsx)(J,{className:"p-6 text-center text-sm text-[--muted]",children:v.trim()?"No entries match your search.":"No entries for this filter."}):(0,i.jsx)("div",{className:x("grid"===I?"grid gap-3 sm:grid-cols-2 xl:grid-cols-3 3xl:grid-cols-4 5xl:grid-cols-5":"flex flex-col gap-2"),children:e.entries.map(e=>(0,i.jsx)(cP,{entry:e,view:I,selectMode:S,selected:_.has(e.nzbHash),onToggleSelect:eh,onBrowse:j,onInfo:k,onBlock:eo,onUnblock:ed,onRequeue:eu,onRepair:ec,onDelete:em},e.nzbHash))})}),ee>1&&(0,i.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,i.jsxs)("span",{className:"text-xs text-[--muted] tabular-nums",children:["Showing ",(D-1)*O+ +(Q.length>0),"â",Math.min(D*O,X)," of ",X]}),(0,i.jsxs)(dp,{children:[(0,i.jsx)(dg,{direction:"previous",isDisabled:D<=1,onClick:()=>L(e=>Math.max(1,e-1))}),db(D,ee).map((e,t)=>"â¦"===e?(0,i.jsx)(df,{},`e${t}`):(0,i.jsx)(dx,{value:e,"data-selected":e===D,onClick:()=>L(e)},e)),(0,i.jsx)(dg,{direction:"next",isDisabled:D>=ee,onClick:()=>L(e=>Math.min(ee,e+1))})]})]}
90),(0,i.jsx)(cc,{hash:(null==y?void 0:y.nzbHash)??null,name:null==y?void 0:y.name,open:null!==y,onOpenChange:e=>!e&&j(null)}),(0,i.jsx)(cb,{entry:N,open:null!==N,onOpenChange:e=>!e&&k(null)}),(0,i.jsx)(sc,{...et}),(0,i.jsx)(sc,{...es}),(0,i.jsx)(sc,{...ei})]})}}),NZ=(0,r.un)({getParentRoute:()=>NG,path:"stats",component:function(){let[e,t]=u.useState("24h"),[s,a]=u.useState(null),r=(0,ty.I)({queryKey:[...i3,"stats",e],queryFn:()=>ea(`/dashboard/usenet/stats?window=${e}`),staleTime:15e3,refetchInterval:3e4});return(0,i.jsxs)("div",{className:"space-y-6",children:[(0,i.jsx)("div",{className:"flex justify-end",children:(0,i.jsx)(cU,{value:e,onChange:t})}),(0,i.jsx)(cB,{}),(0,i.jsx)(oh,{query:r,errorTitle:"Failed to load usenet stats",children:e=>(0,i.jsx)(cZ,{data:e,onReset:a})}),(0,i.jsx)(cL,{target:s,onClose:()=>a(null)})]})}}),NQ=(0,r.un)({getParentRoute:()=>NG,path:"providers",component:function(){var e;let t=(0,ty.I)({queryKey:[...i3,"providers"],queryFn:()=>ea("/dashboard/usenet/providers"),staleTime:1e4});return t.isLoading?(0,i.jsx)(ou,{}):t.isError?(0,i.jsx)(J,{className:"p-6 text-sm text-red-400",children:"Failed to load providers."}):(0,i.jsx)(c2,{providers:(null==(e=t.data)?void 0:e.providers)??[]})}}),NX=R.addChildren([Np,Nv,Ny,Nj,Nx,Ng,Nf,Nw.addChildren([NN,Nk,NS,NC,NA,NF,Nz,NV,NR.addChildren([NT,NI,NE,NM,NP]),Nq.addChildren([NB,NK,NH,NW]),NG.addChildren([NY,NJ,NZ,NQ]),N$.addChildren([ND,NL,NO,NU])])]),N0=(0,l.a)({routeTree:NX,context:{queryClient:Nh.q},trailingSlash:"never",defaultPreload:"intent"})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.