PageSourceSearch

https://avidenie-aiostreams.hf.space/assets/js/index.2030e751.js

js avidenie-aiostreams.hf.space collected 2026-10-03 16:42:19 UTC 1,263,172 bytes, 90 lines download raw bytes

1(()=>{"use strict";var e,t,s,a,r,n,l={27010(e,t,s){var a,r=s(49793);s(15261),s(48760),s(17267),s(65222);var n=s(50405),l=s(17541),i=s(73135),o=s(51650),d=s(81172),c=s(48348),u=s(31265),m=s(49435),p=s(49342),h=s(15445),x=s(31531),g=s(70851),f=s(83455);function b(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,f.QP)((0,g.$)(t))}let v={toaster:(0,h.F)(["group toaster z-[150]"]),toast:(0,h.F)(["group/toast","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]: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,h.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,h.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,h.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"])},y=e=>{let{position:t="top-center",...s}=e,a=n.useMemo(()=>({position:t,visibleToasts:4,className:b(v.toaster()),toastOptions:{classNames:{toast:b(v.toast()),description:b(v.description()),actionButton:b(v.actionButton()),cancelButton:b(v.cancelButton())}},...s}),[]);return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(x.l$,{theme:"dark",...a})})};y.displayName="Toaster";let j={root:(0,h.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,h.F)(["UI-Button__icon","inline-flex self-center flex-shrink-0"])},w=n.forwardRef((e,t)=>
1{let{children:s,size:a,className:n,rounded:l=!1,contentWidth:i=!1,intent:o,leftIcon:d,rightIcon:c,iconSpacing:u="0.5rem",loading:m,iconClass:p,disabled:h,hideTextOnSmallScreen:x,hideTextOnLargeScreen:g,...f}=e;return(0,r.jsx)("button",{type:"button",className:b(j.root({size:a,intent:o,rounded:l,contentWidth:i}),n),disabled:h||m,"aria-disabled":h,...f,ref:t,children:m?(0,r.jsxs)(r.Fragment,{children:[(0,r.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:x?0:u},children:(0,r.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,r.jsxs)(r.Fragment,{children:[d&&(0,r.jsx)("span",{className:b(j.icon(),p),style:{marginInlineEnd:x?0:u},children:d}),(0,r.jsx)("span",{className:b(x&&b("hidden",d&&"pl-[0.5rem]",c&&"pr-[0.5rem]"),g?"inline-block lg:hidden":"md:inline-block"),children:s}),c&&(0,r.jsx)("span",{className:b(j.icon(),p),style:{marginInlineStart:x?0:u},children:c})]})})});w.displayName="Button";let N=e=>{let{children:t,reset:s,className:a,title:n="Oops!",showRefreshButton:l=!1,...i}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{"data-luffy-error":!0,className:b("w-full flex flex-col items-center mt-10 space-y-4",a),children:[(0,r.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,r.jsx)("img",{"data-luffy-error-image":!0,src:"/logo.png",alt:"",className:"absolute inset-0 w-full h-full object-contain object-top"})}),(0,r.jsxs)("div",{"data-luffy-error-content":!0,className:"text-center space-y-4",children:[!!n&&(0,r.jsx)("h3",{"data-luffy-error-title":!0,children:n}),(0,r.jsx)("div",{"data-luffy-error-content-children":!0,children:t}),(0,r.jsxs)("div",{"data-luffy-error-content-buttons":!0,children:[l&&!s&&(0,r.jsx)(w,{"data-luffy-error-content-button-refresh":!0,intent:"warning-subtle",onClick:()=>window.location.reload(),children:"Retry"}),!!s&&(0,r.jsx)(w,{"data-luffy-error-content-button-reset":!0,intent:"warning-subtle",onClick:s,children:"Retry"})]})]})]})})},k={container:(0,h.F)(["UI-LoadingSpinner__container","flex flex-col w-full items-center h-24 justify-center"]),icon:(0,h.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,h.F)(["UI-LoadingSpinner__title","text-base font-medium text-[--foreground] py-2"])},S=n.forwardRef((e,t)=>{let{children:s,className:a,containerClass:n,iconClass:l,spinner:i,title:o,...d}=e;return(0,r.jsxs)("div",{className:b(k.container(),n),...d,ref:t,children:[i||(0,r.jsx)(C,{className:l}),o&&(0,r.jsx)("p",{className:k.title(),children:o})]})});S.displayName="LoadingSpinner";let C=n.forwardRef((e,t)=>{let{children:s,className:a,...n}=e;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:b(k.icon(),a),viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,...n,children:[(0,r.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,r.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.
11071C47.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,h.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=n.forwardRef((e,t)=>{let{children:s,hide:a=!1,showSpinner:n=!0,className:l,...i}=e;return a?null:(0,r.jsxs)("div",{ref:t,className:b(_.overlay(),l),...i,children:[n&&(0,r.jsx)(S,{className:"justify-auto"}),s]})});A.displayName="LoadingOverlay";let R=(0,d.hy)()({component:function(){return(0,r.jsxs)(p.N,{attribute:"class",defaultTheme:"dark",forcedTheme:"dark",children:[(0,r.jsx)(y,{swipeDirections:["top","right"]}),(0,r.jsx)(m.s,{}),null]})},notFoundComponent:function(){return(0,r.jsx)(A,{showSpinner:!1,children:(0,r.jsx)(N,{title:"Page not found",showRefreshButton:!1,children:(0,r.jsx)("p",{children:"The page you are looking for does not exist."})})})}}),T=n.forwardRef((e,t)=>{let{className:s,icon:a,...n}=e;return(0,r.jsx)(E,{type:"button",intent:"gray-basic",size:"sm",className:b("rounded-full text-2xl flex-none",s),icon:a||(0,r.jsx)("span",{children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor",children:(0,r.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"})})}),...n,ref:t})});T.displayName="CloseButton";let I={root:(0,h.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"}})},E=n.forwardRef((e,t)=>{let{className:s,icon:a,size:n,loading:l,...i}=e;return(0,r.jsx)(w,{className:b(I.root({size:n}),s),loading:l,iconSpacing:"0",...i,ref:t,children:!l&&a})});E.displayName="IconButton";var M=s(84121),P=s(85989),D=s(98427);let $={root:(0,h.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"])},L=n.forwardRef((e,t)=>{let{trigger:s,triggerProps:a,defaultOpen:n,open:l,onOpenChange:i,modal:o=!0,className:d,align:c="center",sideOffset:u=8,...m}=e;return(0,r.jsxs)(D.bL,{defaultOpen:n,open:l,onOpenChange:i,modal:o,children:[(0,r.jsx)(D.l9,{asChild:!0,...a,children:s}),(0,r.jsx)(D.ZL,{children:(0,r.jsx)(D.UC,{ref:t,align:c,sideOffset:u,className:b($.root(),d),onOpenAutoFocus:e=>e.preventDefault(),...m})})]})});L.displayName="Popover";let O={fieldLabel:(0,h.F)(["UI-BasicField__fieldLabel","text-base w-fit font-semibold self-start","data-[error=true]:text-red-500"]),fieldAsterisk:(0,h.F)("UI-BasicField__fieldAsterisk ml-1 text-red-500 text-sm"),fieldDetails:(0,h.F)("UI-BasicField__fieldDetails"),field:(0,h.F)("UI-BasicField__field relative w-full space-y-1"),fieldHelpText:(0,h.F)("UI-BasicField__fieldHelpText text-sm text-[--muted]"),fieldErrorText:(0,h.F)("UI-BasicField__fieldErrorText text-sm text-red-500")};function U(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:p,fieldClass:h,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:p,fieldErrorTextClass:x,fieldHelpTextClass:g,fieldDetailsClass:u,fieldLabelClass:m,fieldClass:h,labelProps:r}]}let F=n.memo(n.forwardRef((e,t)=>
1{let{children:s,className:a,labelProps:n,id:l,label:i,error:o,help:d,moreHelp:c,disabled:u,readonly:m,required:p,fieldClass:h,fieldDetailsClass:x,fieldLabelClass:g,fieldAsteriskClass:f,fieldErrorTextClass:v,fieldHelpTextClass:y,...j}=e;return(0,r.jsxs)("div",{className:b(O.field(),a,h),...j,ref:t,children:[!!i&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)("label",{htmlFor:u?void 0:l,className:b(O.fieldLabel(),g),"data-error":!!o,...n,children:[i,p&&(0,r.jsx)("span",{className:b(O.fieldAsterisk(),f),children:"*"})]}),!!c&&(0,r.jsx)(L,{className:"text-sm",trigger:(0,r.jsx)(P.ExT,{className:"transition-opacity opacity-45 hover:opacity-90"}),children:c})]}),s,(!!d||!!o)&&(0,r.jsxs)("div",{className:b(O.fieldDetails(),x),children:[!!d&&(0,r.jsx)("div",{className:b(O.fieldHelpText(),y),children:d}),!!o&&(0,r.jsx)("div",{className:b(O.fieldErrorText(),v),children:o})]})]})}));F.displayName="BasicField";let z={root:(0,h.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}})},V=b("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,h.F)(["UI-Input__inputContainer","flex relative"]);let q=e=>{let{className:t,children:s}=e;return(0,r.jsx)("div",{className:b("UI-Input__inputContainer flex relative",t),children:s})},B={icon:(0,h.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,h.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}})},K=e=>{let{icon:t,size:s="md",side:a,props:n,className:l}=e;return t?(0,r.jsx)("span",{className:b(B.icon({isRightIcon:"right"===a,isLeftIcon:"left"===a,size:s}),l),...n,children:t}):null},H=e=>{let{addon:t,leftIcon:s,rightIcon:a,size:n="md",side:l,props:i,className:o}=e;return t?(0,r.jsx)("span",{className:b(B.addon({isRightAddon:"right"===l,isLeftAddon:"left"===l,hasRightIcon:!!a,hasLeftIcon:!!s,size:n}),o),...i,children:t}):null};function W(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 G=n.forwardRef((e,t)=>{let[s,a]=U(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,onValueChange:p,onChange:h,...x},{inputContainerProps:g,leftAddonProps:f,leftIconProps:v,rightAddonProps:y,rightIconProps:j}]=W({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),w=n.useCallback(e=>{null==p||p(e.target.value),null==h||h(e)},[p,h]);return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...g,children:[(0,r.jsx)(H,{...f}),(0,r.jsx)(K,{...v}),(0,r.jsx)("input",{id:a.id,name:a.name,className:b("form-input",z.root({size:l,intent:i,hasError:!!a.error,isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,onChange:w,...x,ref:t}),(0,r.jsx)(H,{...y}),(0,r.jsx)(K,{...j})]})})});G.displayName="TextInput";var Y=s(36603),J=s(34038);let Z=n.forwardRef((e,t)=>{let[s,a]=U(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,onValueChange:p,onChange:h,autoComplete:x="current-password",...g},{inputContainerProps:f,leftAddonProps:v,leftIconProps:y,rightAddonProps:j,rightIconProps:w}]=W({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),N=n.useCallback(e=>{null==p||p(e.target.value),null==h||h(e)},[p,h]);return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...f,children:[(0,r.jsx)(H,{...v}),(0,r.jsx)(K,{...y}),(0,r.jsx)("div",{className:"relative flex-1",children:(0,r.jsxs)(Y.bL,{children:[(0,r.jsx)(Y.pd,{id:a.id,name:a.name,className:b("form-input",z.root({size:l,intent:i,hasError:!!a.error,
1isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,onChange:N,autoComplete:x,...g,ref:t}),(0,r.jsx)(Y.lM,{className:b("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,r.jsx)(Y.In,{visible:(0,r.jsx)(J.ZT8,{className:"h-6 w-6"}),hidden:(0,r.jsx)(J.Fnz,{className:"h-6 w-6"})})})]})}),(0,r.jsx)(H,{...j}),(0,r.jsx)(K,{...w})]})})});Z.displayName="PasswordInput";let Q={root:(0,h.F)(["UI-Card__root","rounded-xl border bg-[--paper] shadow-sm"]),header:(0,h.F)(["UI-Card__header","flex flex-col space-y-1.5 p-4"]),title:(0,h.F)(["UI-Card__title","text-2xl font-semibold leading-none tracking-tight"]),description:(0,h.F)(["UI-Card__description","text-sm text-[--muted]"]),content:(0,h.F)(["UI-Card__content","p-4 pt-0"]),footer:(0,h.F)(["UI-Card__footer","flex items-center p-4 pt-0"])},X=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(Q.root(),s),...a})});X.displayName="Card";let ee=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(Q.header(),s),...a})});ee.displayName="CardHeader";let et=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("h3",{ref:t,className:b(Q.title(),s),...a})});et.displayName="CardTitle";let es=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(Q.description(),s),...a})});es.displayName="CardDescription";let ea=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(Q.content(),s),...a})});ea.displayName="CardContent",n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(Q.footer(),s),...a})}).displayName="CardFooter";var er=s(57215);class en extends Error{is(e){return this.code===e}constructor(e,t,s,a=null,r){super(s),(0,er._)(this,"status",void 0),(0,er._)(this,"code",void 0),(0,er._)(this,"detail",void 0),(0,er._)(this,"issues",void 0),this.name="APIError",this.status=e,this.code=t,this.detail=a,this.issues=r}}async function el(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,p,h;let e=(null==(m=u.error)?void 0:m.code)||"UNKNOWN_ERROR",t=(null==(p=u.error)?void 0:p.message)||"An unknown error occurred",s=u.detail,a=null==(h=u.error)?void 0:h.issues;throw new en(d.status,e,t,s,a)}return u.data}async function ei(e,t){return el("POST /auth/login",{body:{username:e,password:t}})}async function eo(){return el("POST /auth/logout")}async function ed(){return el("/auth/me")}function ec(e,t){let s=new TextEncoder().encode(`${e}:${t}`),a="";for(let e of s)a+=String.fromCharCode(e);return`Basic ${btoa(a)}`}function eu(e,t){return null===t?{}:{headers:{Authorization:ec(e,t)}}}function em(){return!("u"<typeof document)&&document.cookie.split(";").some(e=>e.trim().startsWith("aiostreams.has-config-session="))}async function ep(e,t,s){return el("POST /user/session",{body:{remember:s},headers:{Authorization:ec(e,t)}})}async function eh(){return el("DELETE /user/session")}async function ex(){return el("DELETE /user/sessions")}async function eg(e,t){return el("GET /user?raw=true",eu(e,t))}async function ef(){return el("GET /user?raw=true")}async function eb(e,t){return el("POST /user",{body:{config:e,password:t}})}
1async function ev(e,t,s){return el("PUT /user",{body:{config:t},...eu(e,s)})}async function ey(e,t){return el("GET /user/client-agents",eu(e,t))}async function ej(e,t,s){return el("POST /user/variants/evaluate",{body:s,...eu(e,t)})}async function ew(e,t,s){return el("POST /user/health-checks/test",{body:s,...eu(e,t)})}async function eN(e,t){return el("POST /user/verify",{headers:{Authorization:ec(e,t)}})}async function ek(e,t){return el("DELETE /user",{headers:{Authorization:ec(e,t)}})}async function eS(e,t,s){return el("POST /user/password",{body:{newPassword:s},headers:{Authorization:ec(e,t)}})}async function eC(){return el("/profiles")}async function e_(e,t,s){return el("POST /profiles",{body:{uuid:e,password:t,label:s}})}async function eA(e,t){return el(`PATCH /profiles/${e}`,{body:t})}async function eR(e){return el(`DELETE /profiles/${e}`)}async function eT(e){return el(`POST /profiles/${e}/open`)}async function eI(e,t){return el("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 eE(e,t){let s=await eI({regexUrls:e},t);return{patterns:s.patterns||[],errors:s.errors}}async function eM(e,t){let s=await eI({selUrls:e},t);return{expressions:s.expressions||[],errors:s.errors}}async function eP(e){return el("POST /catalogs",{body:{userData:e}})}async function eD(e){return el("POST /oauth/exchange/gdrive",{body:{code:e}})}async function e$(){return el("GET /templates")}async function eL(e,t,s){return el(`GET /user/analytics?range=${s}`,eu(e,t))}function eO(e){return eu(e.uuid,e.password)}async function eU(e){return el("GET /linked-accounts/platforms",eO(e))}async function eF(e){return el("GET /linked-accounts",eO(e))}async function ez(e){return el(`GET /community/${e}s`)}async function eV(e){return el("GET /community/mine",eO(e))}async function eq(e,t){return el("POST /community/formatters",{...eO(e),body:t})}async function eB(e,t){return el("POST /community/templates",{...eO(e),body:{template:t}})}async function eK(e,t,s){return el(`PUT /community/items/${encodeURIComponent(t)}`,{...eO(e),body:s})}async function eH(e,t){return el(`DELETE /community/items/${encodeURIComponent(t)}/draft`,eO(e))}async function eW(e,t){return el(`DELETE /community/items/${encodeURIComponent(t)}`,eO(e))}async function eG(e,t){return el(`POST /community/items/${encodeURIComponent(t)}/like`,eO(e))}async function eY(e,t,s){return el("POST /linked-accounts/probe",{...eO(e),body:{platform:t,instanceUrl:s}})}async function eJ(e,t){return el("POST /linked-accounts",{...eO(e),body:t})}async function eZ(e,t,s){return el(`PATCH /linked-accounts/${t}`,{...eO(e),body:s})}async function eQ(e,t){return el(`DELETE /linked-accounts/${t}`,eO(e))}async function eX(e,t){return el(`POST /linked-accounts/${t}/push`,eO(e))}async function e0(e){return el("POST /linked-accounts/push",eO(e))}async function e1(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch manifest: ${t.status} ${t.statusText}`);return t.json()}var e2=s(19217),e3=s(83620);let e5=(0,e3.j)({queryKey:["session"],queryFn:ed,staleTime:6e4,retry:!1}),e4=(0,e3.j)({queryKey:["status"],queryFn:()=>el("/status"),staleTime:6e4,retry:!1}),e6=(0,e3.j)({queryKey:["config-profiles"],queryFn:eC,staleTime:3e4,retry:!1}),e9=e=>(0,e3.j)({queryKey:["linked-accounts",(null==e?void 0:e.uuid)??null],queryFn:()=>e?eF(e):Promise.resolve([]),enabled:!!e,staleTime:3e4,retry:!1}),e8=["linked-accounts"],e7=e=>(0,e3.j)({queryKey:["linked-account-platforms"],queryFn:()=>e?eU(e):Promise.resolve([]),enabled:!!e,staleTime:1/0,retry:!1}),te=["community"],tt=["community-mine"],ts=e=>(0,e3.j)({queryKey:[...tt,(null==e?void 0:e.uuid)??null],queryFn:()=>e?eV(e):Promise.resolve([]),enabled:!!e,staleTime:15e3,retry:!1});var ta=s(88949);function tr(){let{data:e,isLoading:t,error:s}=(0,ta.I)(e4);return{status:e??null,loading:t,error:s?s.message:null}}function tn(e){if(!e)return"/dashboard/";try{let t=decodeURIComponent(e);if(t.startsWith("/")&&!t.startsWith("//")&&!t.startsWith("/\\"))return t}catch{}return"/dashboard/"}let tl={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 ti=s(86505);let to={root:(0,h.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]"}]})},td={root:(0,h.F)(["UI-AppLayoutHeader__root","relative w-full"])},tc={root:(0,h.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]"])},tu={root:(0,h.F)(["UI-AppLayoutContent__root","relative"])},tm={root:(0,h.F)(["UI-AppLayoutFooter__root","relative"])},tp={root:(0,h.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"}})},th={root:(0,h.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"}]})},tx=n.forwardRef((e,t)=>
1{let{children:s,className:a,withSidebar:l=!1,sidebarSize:i,...o}=e,d=n.useContext(tw);return(0,r.jsx)("div",{ref:t,className:b(to.root({withSidebar:l,sidebarSize:d.size||i}),!1,a),...o,children:s})});tx.displayName="AppLayout",n.forwardRef((e,t)=>{let{children:s,className:a,...n}=e;return(0,r.jsx)("header",{ref:t,className:b(td.root(),a),...n,children:s})}).displayName="AppLayoutHeader";let tg=n.forwardRef((e,t)=>{let{children:s,className:a,...n}=e;return(0,r.jsx)("aside",{ref:t,className:b(tc.root(),a),...n,children:s})});tg.displayName="AppLayoutSidebar";let tf=n.forwardRef((e,t)=>{let{children:s,className:a,...n}=e;return(0,r.jsx)("main",{ref:t,className:b(tu.root(),a),...n,children:s})});tf.displayName="AppLayoutContent",n.forwardRef((e,t)=>{let{children:s,className:a,breakBelow:n,cols:l,spacing:i,...o}=e;return(0,r.jsx)("section",{ref:t,className:b(th.root({breakBelow:n,cols:l,spacing:i}),a),...o,children:s})}).displayName="AppLayoutGrid",n.forwardRef((e,t)=>{let{children:s,className:a,...n}=e;return(0,r.jsx)("footer",{ref:t,className:b(tm.root(),a),...n,children:s})}).displayName="AppLayoutFooter",n.forwardRef((e,t)=>{let{children:s,className:a,spacing:n,...l}=e;return(0,r.jsx)("div",{ref:t,className:b(tp.root({spacing:n}),a),...l,children:s})}).displayName="AppLayoutStack";var tb=s(95045),tv=s(59484);let ty={overlay:(0,h.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,h.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,h.F)(["UI-Drawer__close","absolute right-4 top-4"]),header:(0,h.F)(["UI-Drawer__header","flex flex-col space-y-1.5 text-center sm:text-left"]),footer:(0,h.F)(["UI-Drawer__footer","flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2"]),title:(0,h.F)(["UI-Drawer__title","text-xl font-semibold leading-none tracking-tight"]),description:(0,h.F)(["UI-Drawer__description","text-sm text-[--muted]"])};function tj(e){let{allowOutsideInteraction:t=!1,trigger:s,title:a,footer:l,description:i,children:o,closeButton:d,overlayClass:c,contentClass:u,closeClass:m,headerClass:p,footerClass:h,titleClass:x,descriptionClass:g,hideCloseButton:f,side:v="right",size:y,open:j,onOpenAutoFocus:w,onCloseAutoFocus:N,onEscapeKeyDown:k,onPointerDownCapture:S,onInteractOutside:C,portalContainer:_,mangaReader:A,...R}=e;return!function(e,t){let[s,a]=(0,n.useState)([]);n.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])}(n.useId(),j),(0,r.jsxs)(tb.bL,{modal:!t,open:j,...R,children:[s&&(0,r.jsx)(tb.l9,{asChild:!0,children:s}),(0,r.jsxs)(tb.ZL,{container:_,children:[(0,r.jsx)(tb.hJ,{className:b(ty.overlay(),c)}),(0,r.jsxs)(tb.UC,{className:b(ty.content({size:y,side:A?"mangaReader":v}),!A&&"lg:m-[10px] rounded-[--radius]",u),style:{marginTop:void 0,height:void 0},onOpenAutoFocus:w,onCloseAutoFocus:N,onEscapeKeyDown:k,onPointerDownCapture:S,onInteractOutside:C,tabIndex:-1,
1children:[a||i?(0,r.jsxs)("div",{className:b(ty.header(),p),children:[(0,r.jsx)(tb.hE,{className:b(ty.title(),!1,x),children:a}),i&&(0,r.jsx)(tb.VY,{className:b(ty.description(),g),children:i})]}):(0,r.jsx)(tv.s6,{children:(0,r.jsx)(tb.hE,{children:"Drawer"})}),o,l&&(0,r.jsx)("div",{className:b(ty.footer(),h),children:l}),!f&&(0,r.jsx)(tb.bm,{className:b(ty.close(),m),asChild:!0,children:d||(0,r.jsx)(T,{})})]})]})]})}tj.displayName="Drawer";let tw=n.createContext({open:!1,setOpen:()=>{},setSize:()=>{},size:"md",isBelowBreakpoint:!1});function tN(){let e=n.useContext(tw);if(!e)throw Error("useAppSidebarContext must be used within a AppSidebarProvider");return e}let tk={sidebar:(0,h.F)(["UI-AppSidebar__sidebar","flex flex-grow flex-col overflow-y-auto border-r border-transparent bg-[--background]"])},tS={trigger:(0,h.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]"])},tC=n.forwardRef((e,t)=>{let{children:s,className:a,...l}=e,i=n.useContext(tw);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{ref:t,className:b(tk.sidebar(),a),...l,children:s}),(0,r.jsx)(tj,{open:i.open,onOpenChange:e=>i.setOpen(e),side:"left",children:s})]})});tC.displayName="AppSidebar";let t_=n.forwardRef((e,t)=>{let{children:s,className:a,...l}=e,i=n.useContext(tw);return(0,r.jsxs)("button",{ref:t,className:b(tS.trigger(),a),onClick:()=>i.setOpen(!i.open),...l,children:[(0,r.jsx)("span",{className:"sr-only",children:"Open main menu"}),i.open?(0,r.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,r.jsx)("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]}):(0,r.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,r.jsx)("line",{x1:"4",x2:"20",y1:"12",y2:"12"}),(0,r.jsx)("line",{x1:"4",x2:"20",y1:"6",y2:"6"}),(0,r.jsx)("line",{x1:"4",x2:"20",y1:"18",y2:"18"})]})]})});t_.displayName="AppSidebarTrigger";let tA=e=>{let{children:t,onOpenChange:s,onSizeChange:a}=e,[l,i]=n.useState(!1),[o,d]=n.useState(void 0),[c,u]=n.useState(!1);return n.useEffect(()=>{let e=()=>u(window.innerWidth<1024);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[c]),(0,r.jsx)(tw.Provider,{value:{open:l,setOpen:e=>{null==s||s(e),i(e)},setSize:e=>{null==a||a(e),d(e)},size:o,isBelowBreakpoint:c},children:t})};tA.displayName="AppSidebarProvider";var tR=s(5976);let tT={item:(0,h.F)(["UI-Disclosure__item"]),contentContainer:(0,h.F)(["UI-Disclosure__contentContainer","overflow-hidden transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"]),content:(0,h.F)(["UI-Disclosure__content"])},tI=n.createContext({}),tE=n.forwardRef((e,t)=>{let{contentContainerClass:s,contentClass:a,itemClass:n,...l}=e;return(0,r.jsx)(tI.Provider,{value:{itemClass:n,contentContainerClass:s,contentClass:a},children:(0,r.jsx)(tR.bL,{ref:t,...l})})});tE.displayName="Disclosure";let tM=n.forwardRef((e,t)=>{let{className:s,...a}=e,{itemClass:l}=n.useContext(tI);return(0,r.jsx)(tR.q7,{ref:t,className:b(tT.item(),l,s),...a})});tM.displayName="DisclosureItem";let tP=n.forwardRef((e,t)=>(0,r.jsx)(tR.Y9,{asChild:!0,children:(0,r.jsx)(tR.l9,{ref:t,asChild:!0,...e})}));tP.displayName="DisclosureTrigger";let tD=n.forwardRef((e,t)=>{let{className:s,contentContainerClass:a,children:l,...i}=e,{contentContainerClass:o,contentClass:d}=n.useContext(tI);return(0,r.jsx)(tR.UC,{ref:t,className:b(tT.contentContainer(),o,a),...i,children:(0,r.jsx)("div",{className:b(tT.content(),d,s),children:l})})});tD.displayName="DisclosureContent";var t$=s(15191);let tL={root:(0,h.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]:sli
1de-in-from-left-1 data-[side=top]:slide-in-from-bottom-1"])},tO=n.forwardRef((e,t)=>{let{children:s,className:a,trigger:n,delayDuration:l=50,disableHoverableContent:i,defaultOpen:o,open:d,onOpenChange:c,...u}=e;return(0,r.jsx)(tU,{children:(0,r.jsxs)(t$.bL,{delayDuration:l,disableHoverableContent:i,defaultOpen:o,open:d,onOpenChange:c,children:[(0,r.jsx)(t$.l9,{asChild:!0,children:n}),(0,r.jsx)(t$.ZL,{children:(0,r.jsx)(t$.UC,{ref:t,className:b(tL.root(),a),...u,children:s})})]})})});tO.displayName="Tooltip";let tU=t$.Kq;var tF=s(32248);let tz={root:(0,h.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"])},tV=n.forwardRef((e,t)=>{let{className:s,align:a="center",sideOffset:n=8,openDelay:l=1e3,closeDelay:i=0,trigger:o,...d}=e;return(0,r.jsxs)(tF.bL,{openDelay:l,closeDelay:i,children:[(0,r.jsx)(tF.l9,{asChild:!0,children:o}),(0,r.jsx)(tF.ZL,{children:(0,r.jsx)(tF.UC,{ref:t,align:a,sideOffset:n,className:b(tz.root(),s),...d})})]})});tV.displayName="HoverCard";var tq=s(15591),tB=s(68364);let tK={root:(0,h.F)(["UI-VerticalMenu__root","flex flex-col gap-1"]),item:(0,h.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,h.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,h.F)(["UI-VerticalMenu__parentItem","group/verticalMenu_parentItem","cursor-pointer w-full"]),itemChevron:(0,h.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,h.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,h.F)(["UI-VerticalMenu__subContent","border-b py-1"])},tH=n.createContext({}),tW=n.forwardRef((e,t)=>{let{children:s,size:a="md",collapsed:l,onItemSelect:i,itemClass:o,itemIconClass:d,parentItemClass:c,subContentClass:u,itemChevronClass:m,itemContentClass:p,itemTooltipProps:h,className:x,items:g,isSidebar:f,...v}=e,{onItemSelect:y,collapsed:j,isSidebar:w}=(0,n.useContext)(tH),N=l??j??!1,k=f??w??!1,S=e=>t=>{var s;null==i||i(e),null==y||y(e),null==(s=e.onClick)||s.call(e,t)},C=n.useCallback(e=>N?e.flyout?(0,r.jsx)(tV,{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,r.jsx)(tO,{trigger:e.children,side:"right",...h,children:e.name}):e.children,[N,h]),_=n.useCallback(e=>(0,r.jsx)(C,{name:e.name,flyout:e.flyout,children:(0,r.jsxs)("div",{"data-vertical-menu-item":e.name,className:b(tK.itemContent({size:a,c
1ollapsed:N,isSidebar:k}),p),children:[e.iconType&&(0,r.jsx)(e.iconType,{className:b(tK.itemIcon({size:a,collapsed:N,isSidebar:k}),d),"aria-hidden":"true","data-current":e.isCurrent}),!N&&(0,r.jsx)("span",{children:e.name}),e.addon]})}),[N,a,p,d,k]);return(0,r.jsx)("nav",{ref:t,className:b(tK.root(),x),role:"navigation",...v,children:(0,r.jsx)(tH.Provider,{value:{onItemSelect:i,collapsed:l??!1,isSidebar:f??!1},children:g.map((e,t)=>(0,r.jsx)(n.Fragment,{children:e.subItems&&e.subItems.length>0?(0,r.jsxs)("div",{className:b("flex flex-col",k&&e.expanded&&"gap-1 rounded-3xl border border-[--border] bg-[--paper] p-1 shadow-sm"),children:[(0,r.jsx)("button",{className:b(tK.item({collapsed:N,isSidebar:k}),o),"data-current":e.isCurrent,onClick:S(e),"data-vertical-menu-item-button":e.name,children:(0,r.jsx)(_,{...e})}),(0,r.jsx)(tq.N,{initial:!1,children:e.expanded&&(0,r.jsx)(tB.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,r.jsx)("button",{className:b(tK.item({collapsed:N,isSidebar:k}),o),"data-current":e.isCurrent,onClick:S(e),"data-vertical-menu-item-button":e.name,children:(0,r.jsx)(_,{...e})},e.name+t))},"subitems")})]}):e.subContent?(0,r.jsx)(tE,{type:"multiple",children:(0,r.jsxs)(tM,{value:e.name,children:[(0,r.jsx)(tP,{children:(0,r.jsxs)("button",{className:b(tK.item({collapsed:N,isSidebar:k}),o,tK.parentItem(),c),"aria-current":e.isCurrent?"page":void 0,"data-current":e.isCurrent,onClick:S(e),children:[(0,r.jsx)(_,{...e}),(0,r.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:b(tK.itemChevron({size:a,collapsed:N}),m),children:(0,r.jsx)("polyline",{points:"9 18 15 12 9 6"})})]})}),(0,r.jsx)(tD,{className:b(tK.subContent(),u),children:e.subContent})]})}):(0,r.jsx)("button",{className:b(tK.item({collapsed:N,isSidebar:k}),o),"data-current":e.isCurrent,onClick:S(e),"data-vertical-menu-item-button":e.name,children:(0,r.jsx)(_,{...e})})},e.name+t))})})});function tG(e){let{header:t,items:s,footerItems:a,footer:n,onItemSelect:l,onFooterItemSelect:i,className:o}=e,d=tN(),c=!d.isBelowBreakpoint;return(0,r.jsxs)(tC,{className:b("h-full flex flex-col justify-between w-full",!d.isBelowBreakpoint&&"bg-transparent",o),children:[(0,r.jsxs)("div",{children:[t,(0,r.jsx)(tW,{className:"px-4",collapsed:c,isSidebar:!0,itemClass:"relative",items:s,onItemSelect:e=>{null==l||l(e),d.setOpen(!1)}})]}),((null==a?void 0:a.length)||n)&&(0,r.jsxs)("div",{className:"p-4 gap-2 flex flex-col",children:[a&&a.length>0&&(0,r.jsx)(tW,{collapsed:c,isSidebar:!0,itemClass:"relative",items:a,onItemSelect:e=>{null==i||i(e),d.setOpen(!1)}}),n]})]})}tW.displayName="VerticalMenu";let tY={overlay:(0,h.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,h.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,h.F)(["UI-Modal__close","absolute right-4 top-4 !mt-0"]),header:(0,h.F)(["UI-Modal__header","flex flex-col space-y-1.5 min-w-0 text-center sm:text-left"]),footer:(0,h.F)(["UI-Modal__footer","flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"]),title:(0,h.F)(["UI-Modal__title","text-xl font-semibold leading-snug tracking-tight break-words"]),description:(0,h.F)(["UI-Modal__description","text-sm text-[--muted]"])};function tJ(e){let{allowOutsideInteraction:t=!1,trigger:s,title:a,footer:l,description:i,children:o,closeButton:d,overlayClass:c,contentClass:u,closeClass:m,headerClass:p,footerClass:h,titleClass:x,descriptionClass:g,hideCloseButton:f,onOpenAutoFocus:v,onCloseAutoFocus:y,onEscapeKeyDown:j,onPointerDownCapture:w,onInteractOutside:N,...k}=e,S=n.useRef(!1);return(0,r.jsxs)(tb.bL,{modal:!t,...k,children:[s&&(0,r.jsx)(tb.l9,{asChild:!0,children:s}
1),(0,r.jsxs)(tb.ZL,{children:[(0,r.jsx)(tZ,{targetRef:S}),(0,r.jsx)(tb.hJ,{className:b(tY.overlay(),c),children:(0,r.jsx)("div",{className:b("overflow-y-auto absolute inset-0 grid place-items-center p-0 md:p-4",!1),children:(0,r.jsxs)(tb.UC,{className:b(tY.content(),u),onOpenAutoFocus:v,onCloseAutoFocus:y,onEscapeKeyDown:j,onPointerDownCapture:w,onInteractOutside:e=>{if(S.current){S.current=!1,e.preventDefault();return}null==N||N(e)},children:[a||i?(0,r.jsxs)("div",{className:b(tY.header(),p),children:[(0,r.jsx)(tb.hE,{className:b(tY.title(),x),children:a}),i&&(0,r.jsx)(tb.VY,{className:b(tY.description(),g),children:i})]}):(0,r.jsx)(tv.s6,{children:(0,r.jsx)(tb.hE,{children:"Dialog"})}),o,l&&(0,r.jsx)("div",{className:b(tY.footer(),h),children:l}),!f&&(0,r.jsx)(tb.bm,{className:b(tY.close(),m),asChild:!0,children:d||(0,r.jsx)(T,{})})]})})})]})]})}function tZ(e){let{targetRef:t}=e;return n.useEffect(()=>{let e=()=>{t.current=!!document.querySelector('[role="listbox"][data-state="open"],[role="menu"][data-state="open"],[data-radix-popper-content-wrapper]:not(:has([role="tooltip"]))')};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[t]),null}function tQ(e,t){let[s,a]=(0,n.useState)(e),r=()=>{if(!s){var e;a(!0),null==t||null==(e=t.onOpen)||e.call(t)}},l=()=>{if(s){var e;a(!1),null==t||null==(e=t.onClose)||e.call(t)}};return{isOpen:s,open:r,close:l,toggle:()=>{s?l():r()}}}function tX(e){return{...tQ(!1),...e}}tJ.displayName="Modal";let t0=e=>{let{isOpen:t,close:s,onConfirm:a,title:n,description:l="Are you sure you want to continue?",actionText:i="Confirm",actionIntent:o="alert-subtle"}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(tJ,{title:n,titleClass:"text-center",open:t,onOpenChange:s,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-center break-words",children:l}),(0,r.jsxs)("div",{className:"flex gap-2 justify-center items-center",children:[(0,r.jsx)(w,{intent:o,onClick:()=>{a(),s()},children:i}),(0,r.jsx)(w,{intent:"white",onClick:s,children:"Cancel"})]})]})})})};function t1(){let e=(0,o.jE)(),{data:t,isLoading:s}=(0,ta.I)(e5),a=(0,n.useCallback)(async()=>{await e.invalidateQueries({queryKey:e5.queryKey})},[e]),{mutateAsync:r}=(0,e2.n)({mutationFn:eo,onSettled:()=>{e.removeQueries({queryKey:e5.queryKey})}});return{user:t??null,loading:s,refresh:a,signOut:(0,n.useCallback)(async()=>{await r()},[r])}}var t2=s(28368);function t3(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-layout-header-background":!0,className:b("bg-[#000] opacity-50 bg-contain bg-center bg-repeat z-[-2] w-full h-[20rem] absolute bottom-0")}),(0,r.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 t5=[{id:"library",label:"Library",icon:t2.X6x},{id:"stats",label:"Stats",icon:t2.yWU},{id:"providers",label:"Providers",icon:t2.nmg}],t4=[{id:"sources",label:"Sources",icon:t2.Azn},{id:"publishing",label:"Publishing",icon:t2.K0Y},{id:"entries",label:"Entries",icon:t2.XfR}],t6=[{id:"active",label:"Active",icon:t2.U2S},{id:"history",label:"History",icon:t2.grf},{id:"bandwidth",label:"Bandwidth",icon:t2.yWU},{id:"bans",label:"Blocks",icon:t2.PLI}],t9=[{id:"pending",label:"Review queue",icon:t2.FOv},{id:"published",label:"Published",icon:t2.By1},{id:"blocks",label:"Blocks",icon:t2.PLI}],t8=[{label:"Overview",href:"/dashboard",icon:t2.fiy},{label:"Analytics",href:"/dashboard/analytics",icon:t2.yWU,desc:"User & request trends"},{label:"Logs",href:"/dashboard/logs",icon:t2.XfR,desc:"Live log stream"},{label:"System",href:"/dashboard/system",icon:t2.nmg,desc:"CPU, memory & lifecycle"},{label:"Users",href:"/dashboard/users",icon:t2.hTi,desc:"Accounts & their configs"},{label:"Tasks",href:"/dashboard/tasks",icon:t2.bZV,desc:"Scheduled & manual work"},{label:"Cache",href:"/dashboard/cache",icon:t2.Wwx,desc:"Cache stats & flush"},{label:"Streams",href:"/dashboard/streams",icon:t2.U2S,desc:"Active, history & bandwidth"},{label:"Usenet",href:"/dashboard/usenet",icon:t2.hQe,desc:"Library, providers & stats"},{label:"Blocklists",href:"/dashboard/blocklist",icon:t2.PLI,desc:"Sources, entries & publishing"},{label:"Community",href:"/dashboard/community",icon:t2.e7V,desc:"Shared formatters & templates"},{label:"Settings",href:"/dashboard/settings",icon:t2.nMM,desc:"Ru
1ntime configuration"}],t7={"/dashboard/streams":t6,"/dashboard/usenet":t5,"/dashboard/blocklist":t4,"/dashboard/community":t9};function se(){let[e,t]=(0,n.useState)(!1),s=(0,n.useCallback)(()=>t(!0),[]),a=(0,n.useCallback)(()=>t(!1),[]),r=(0,n.useCallback)(()=>t(e=>!e),[]);return(0,n.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 st=(0,n.createContext)({isOpen:!1,open:()=>{},close:()=>{},toggle:()=>{}});function ss(e){let{children:t}=e,s=se();return(0,r.jsx)(st.Provider,{value:s,children:t})}let sa=()=>(0,n.useContext)(st);var sr=s(90988);let sn={root:(0,h.F)(["UI-Command__root","flex h-full w-full flex-col overflow-hidden rounded-[--radius-md] bg-[--paper] text-[--foreground]"]),inputContainer:(0,h.F)(["UI-Command__input","flex items-center px-3 py-2","cmdk-input-wrapper"]),inputIcon:(0,h.F)(["UI-Command__inputIcon","mr-2 h-5 w-5 shrink-0 opacity-50"]),list:(0,h.F)(["UI-Command__list","max-h-[300px] overflow-y-auto overflow-x-hidden"]),empty:(0,h.F)(["UI-Command__empty","py-6 text-center text-base text-[--muted]"]),group:(0,h.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,h.F)(["UI-Command__separator","-mx-1 h-px bg-[--border]"]),item:(0,h.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,h.F)(["UI-Command__itemIconContainer","mr-2 text-base shrink-0 w-4"]),shortcut:(0,h.F)(["UI-Command__shortcut","ml-auto text-xs tracking-widest text-[--muted]"])},sl={content:(0,h.F)(["UI-CommandDialog__content","overflow-hidden p-0"]),command:(0,h.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"])},si=n.createContext({}),so=n.forwardRef((e,t)=>{let{className:s,inputContainerClass:a,inputIconClass:n,listClass:l,emptyClass:i,groupClass:o,separatorClass:d,itemClass:c,itemIconContainerClass:u,shortcutClass:m,loop:p=!0,...h}=e;return(0,r.jsx)(si.Provider,{value:{inputContainerClass:a,inputIconClass:n,listClass:l,emptyClass:i,groupClass:o,separatorClass:d,itemClass:c,itemIconContainerClass:u,shortcutClass:m},children:(0,r.jsx)(sr.uB,{ref:t,className:b(sn.root(),s),loop:p,...h})})});so.displayName=sr.uB.displayName;let sd=n.forwardRef((e,t)=>{let{className:s,inputContainerClass:a,inputIconClass:l,...i}=e,{inputContainerClass:o,inputIconClass:d}=n.useContext(si);return(0,r.jsxs)("div",{className:b(sn.inputContainer(),o,a),"cmdk-input-wrapper":"",children:[(0,r.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:b(sn.inputIcon(),d,l),children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,r.jsx)(sr.uB.Input,{ref:t,className:b(z.root({intent:"unstyled",size:"sm",isDisabled:i.disabled}),s),...i})]})});sd.displayName="CommandInput";let sc=n.forwardRef((e,t)=>{let{className:s,...a}=e,{listClass:l}=n.useContext(si);return(0,r.jsx)(sr.uB.List,{ref:t,className:b(sn.list(),l,s),...a})});sc.displayName="CommandList";let su=n.forwardRef((e,t)=>{let{className:s,...a}=e,{emptyClass:l}=n.useContext(si);return(0,r.jsx)(sr.uB.Empty,{ref:t,className:b(sn.empty(),l,s),...a}
1)});su.displayName="CommandEmpty";let sm=n.forwardRef((e,t)=>{let{className:s,...a}=e,{groupClass:l}=n.useContext(si);return(0,r.jsx)(sr.uB.Group,{ref:t,className:b(sn.group(),l,s),...a})});sm.displayName="CommandGroup",n.forwardRef((e,t)=>{let{className:s,...a}=e,{separatorClass:l}=n.useContext(si);return(0,r.jsx)(sr.uB.Separator,{ref:t,className:b(sn.separator(),l,s),...a})}).displayName="CommandSeparator";let sp=n.forwardRef((e,t)=>{let{className:s,itemIconContainerClass:a,leftIcon:l,children:i,...o}=e,{itemClass:d,itemIconContainerClass:c}=n.useContext(si),u=n.useRef(null);n.useEffect(()=>{let e=u.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=n.useCallback(e=>{u.current=e,t&&"function"==typeof t&&t(e)},[t]);return(0,r.jsxs)(sr.uB.Item,{ref:m,className:b(sn.item(),d,s),...o,"data-cmdkvalue":o.id,children:[l&&(0,r.jsx)("span",{className:b(sn.itemIconContainer(),c,a),children:l}),i]})});sp.displayName="CommandItem";let sh=n.forwardRef((e,t)=>{let{className:s,...a}=e,{shortcutClass:l}=n.useContext(si);return(0,r.jsx)("span",{ref:t,className:b(sn.shortcut(),l,s),...a})});sh.displayName="CommandShortcut";let sx=e=>{let{children:t,commandClass:s,contentClass:a,commandProps:n,...l}=e;return(0,r.jsx)(tJ,{...l,contentClass:b(sl.content(),a),children:(0,r.jsx)(so,{shouldFilter:!1,className:b(sl.command(),s),...n,children:t})})};sx.displayName="CommandDialog";let sg=n.createContext(void 0),sf="aiostreams-mode",sb="aiostreams-first-time";function sv(e){let{children:t}=e,[s,a]=n.useState(()=>"u">typeof window&&localStorage.getItem(sf)||"noob"),[l,i]=n.useState(()=>!("u">typeof window)||null===localStorage.getItem(sb)),o=n.useCallback(e=>{a(e),"u">typeof window&&localStorage.setItem(sf,e)},[]),d=n.useCallback(e=>{i(e),"u">typeof window&&!e&&localStorage.setItem(sb,"false")},[]);return(0,r.jsx)(sg.Provider,{value:{mode:s,setMode:o,isFirstTime:l,setIsFirstTime:d},children:t})}function sy(){let e=n.useContext(sg);if(void 0===e)throw Error("useMode must be used within a ModeProvider");return e}let sj={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"]},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"},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"},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"},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 sw="count(cached(streams)) == 0 ? uncached(streams) : []",sN=["usenet"],sk=["languages","subtitles","library","seadex","sizes","idMatched"],sS="gdrive",sC="lightgdrive",s_="minimalisticgdrive",sA="torrentio",sR="torbox",sT="prism",sI="tamtaro",sE="custom",sM={[sS]:{id:sS,name:"Google Drive",description:"Uses the formatting from the Stremio GDrive addon"},[sT]:{id:sT,name:"Prism",description:"An aesthetic formatter with every detail within 5 lines."},[sI]:{id:sI,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."},[sC]:{id:sC,name:"Light Google Drive",description:"A lighter version of the GDrive formatter, focused on asthetics"},[s_]:{id:s_,name:"Minimalistic",description:"A minimalistic formatter which shows only the bare minimum"},[sA]:{id:sA,name:"Torrentio",description:"Uses the formatting from the Torrentio addon"},[sR]:{id:sR,name:"Torbox",description:"Uses the formatting from the TorBox Stremio addon"},[sE]:{id:sE,name:"Custom",description:"Define your own formatter"}},sP="realdebrid",sD="debridlink",s$="premiumize",sL="alldebrid",sO="torbox",sU="easydebrid",sF="debrider",sz="putio",sV="pikpak",sq="offcloud",sB="seedr",sK="easynews",sH="nzbdav",sW="altmount",sG="stremio_nntp",sY="stremthru_newz",sJ="aiostreams",sZ="torrin",sQ=[sP,sD,s$,sL,sO,sU,sF,sz,sV,sq,sB,sK,sH,sW,sG,sY,sJ,sZ],sX=[sP,sD,s$,sL,sO,sU,sF,sV,sq,sH,sW,sG,sK,sY,sJ,sZ],s0="mediaflow",s1="stremthru",s2="builtin",s3={[s2]:{id:s2,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."},[s1]:{id:s1,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."},[s0]:{id:s0,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."}},s5={[sP]:{id:sP,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}]},[sL]:{id:sL,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}]},[s$]:{id:s$,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}]},[sD]:{id:sD,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}]},[sO]:{id:sO,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}]},[sG]:{id:sG,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}]},[sH]:{id:sH,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}]},[sJ]:{id:sJ,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}]},[sW]:{id:sW,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}]},[sq]:{id:sq,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}]},[sz]:{id:sz,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,[sK]:{id:sK,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}]},[sU]:{id:sU,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}]},[sF]:{id:sF,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}]},[sV]:{id:sV,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}]},[sB]:{id:sB,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}]},[sY]:{id:sY,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"}]},[sZ]:{id:sZ,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}]}},s4={tmdbApiKey:{name:"TMDB API Key",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",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",description:"Get your free API key from [here](https://ratingposterdb.com/api-key/) for posters with ratings."},topPosterApiKey:{name:"TOP Posters API Key",description:"Get your free API key from [here](https://api.top-posters.com/user/register) for posters with ratings."},tvdbApiKey:{name:"TVDB API Key",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",description:"Get your API key from [here](https://aioratings.com) for custom posters with ratings."},aioratingsProfileId:{name:"AIOratings Profile ID",description:'Use "default" for the default profile, or enter a custom profile UUID from your AIOratings dashboard.'},openposterdbApiKey:{name:"OpenPosterDB API Key",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",description:"Custom base URL for a self-hosted OpenPosterDB instance. Leave empty to use the default public instance."},openposterdbParameters:{name:"OpenPosterDB Custom Parameters",description:"Optional query string (without the leading `?`) appended to every poster to customise it, e.g. `ratings_limit=2&badge_size=l&position=br`."}},s6=["filename","infoHash","smartDetect"],s9=["torrent_seeders","usenet_age"],s8=["size","bitrate","resolution","quality","encode","releaseGroup","edition","remastered","network","container","visualTags","audioTags","audioChannels","languages","repack","proper","country"],s7=["size","resolution","quality","visualTags","audioTags","audioChannels","languages","encode","edition","network","remastered","releaseGroup"],ae=["service","addon","proxied","resolution","quality","encode","audioTags","visualTags","languages","releaseGroup","type","infoHash","size"],at=["resolution","quality","releaseGroup"],as=["matchingFile","matchingIndex","firstFile"],aa={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."}},ar=["2160p","1440p","1080p","720p","576p","480p","360p","240p","144p","Unknown"],an=["BluRay REMUX","BluRay","WEB-DL","WEBRip","HDRip","HC HD-Rip","DVD REMUX","DVDRip","HDTV","CAM","TS","TC","SCR","Unknown"],al=["HDR+DV","DV Only","HDR Only","HDR10+","HDR10","DV","HDR","HLG","10bit","3D","IMAX","AI","Upscaled","SDR","H-OU","H-SBS","Unknown"],ai=["Atmos","DD+","DD","DTS:X","DTS-HD MA","DTS-HD","DTS-ES","DTS","TrueHD","PCM","OPUS","FLAC","AAC","Unknown"],ao=["2.0","5.1","6.1","7.1","Unknown"],ad=["AV1","HEVC","AVC","VC-1","XviD","DivX","MPEG-4","Unknown"],ac=["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"],au={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"}},am=["p2p","live","stremio-usenet","archive","usenet","debrid","http","external","youtube","error","statistic","info"],ap="movie",ah="series",ax="channel",ag="anime",af=[ap,ah,ax,"tv",ag],ab={[ap]:"Movie",[ah]:"Series",[ax]:"Channel",tv:"TV",[ag]:"Anime"},av=["stream","subtitles","catalog","meta","addon_catalog"],ay=["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"],aj=[{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 aw(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function aN(e){return null==e||Array.isArray(e)&&0===e.length||aw(e)&&0===Object.keys(e).length}function ak(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||aN(e)&&aN(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(!aw(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(...ak(t,e,[...s,`[${l}]`]))}else a.push({path:[...s,`[${l}]`],type:"ADD",newValue:e})});let m=o.filter(e=>c.includes(e)),p=c.filter(e=>o.includes(e));return(m.length!==p.length||m.some((e,t)=>e!==p[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=ak(e[c],t[u],[...s,`[${u}]`]);if(0===r.length){c++,u++;continue}let n=!1;c+1<e.length&&0===ak(e[c+1],t[u],[]).length&&(n=!0);let l=!1;u+1<t.length&&0===ak(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(!aw(e)||!aw(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(...ak(e[l],t[l],[...s,l]));else{if(null==e[l]||aN(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]||aN(t[n]))continue;a.push({path:[...s,n],type:"ADD",newValue:t[n]})}return a}function aS(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):aw(t)?Object.keys(t).sort().reduce((s,a)=>(s[a]=e(t[a]),s),{}):t}(s)}function aC(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 a_(e,t){let s=[...(null==e?void 0:e.presets)??[],...(null==t?void 0:t.presets)??[]],a=aS(e),r=aS(t),n=aC(a,s),l=aC(r,s);return{diffs:ak(n,l),processedOld:n,processedNew:l}}let aA="aiostreams-draft-session",aR="aiostreams-draft:",aT="aiostreams-draft-opt-out",aI="aiostreams-user-data";function aE(e){return`${aR}${e??"anon"}`}function aM(e,t){try{return e.getItem(t)}catch{return null}}function aP(e,t,s){try{e.setItem(t,s)}catch{}}function aD(e,t){try{e.removeItem(t)}catch{}}function a$(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 aL(e,t,s){return JSON.stringify({v:1,savedAt:Date.now(),uuid:t,addonName:s,data:e})}function aO(){return"1"===aM(localStorage,aT)}function aU(){return a$(aM(sessionStorage,aA))}function aF(e){aD(sessionStorage,aA),aD(localStorage,aE(e))}function az(e){let t,s,a=aU();return a&&a.uuid===e?a:!(s=a$(aM(localStorage,t=aE(e))))||Date.now()-s.savedAt>6048e5?(aD(localStorage,t),null):s}function aV(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) : []":sw),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:[...sN],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 aq(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 aB={services:Object.values(s5).map(e=>({id:e.id,enabled:!1,credentials:{}})),presets:[],formatter:{id:"gdrive"},preferredQualities:Object.values(an),preferredResolutions:Object.values(ar),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:s7,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:sw,enableSeadex:!0,regexOverrides:[],checkOwned:!0};function aK(e,t){var s,a,r,n,l,i,o;let d=t.settings.forced,c=t.settings.defaults,u=t.settings.services,m={...e};return m.proxy={...m.proxy,enabled:d.proxy.enabled??(null==(s=c.proxy)?void 0:s.enabled)??void 0,id:d.proxy.id??(null==(a=c.proxy)?void 0:a.id)??"builtin",url:d.proxy.url??(null==(r=c.proxy)?void 0:r.url)??void 0,publicUrl:d.proxy.publicUrl??(null==(n=c.proxy)?void 0:n.publicUrl)??void 0,publicIp:d.proxy.publicIp??(null==(l=c.proxy)?void 0:l.publicIp)??void 0,credentials:d.proxy.credentials??(null==(i=c.proxy)?void 0:i.credentials)??void 0,proxiedServices:d.proxy.proxiedServices??(null==(o=c.proxy)?void 0:o.proxiedServices)??[]},m.services=(e.services??[]).map(e=>{let t=u[e.id];if(!t)return e;let s={...e.credentials};return t.credentials.forEach(e=>{e.forced?s[e.id]=e.forced:e.default&&(s[e.id]=e.default)}),{...e,credentials:s,enabled:t.credentials.every(e=>e.forced||e.default||void 0!==s[e.id])}}),m}function aH(e){return(e.presets??[]).length>0||(e.services??[]).some(e=>e.enabled)}let aW=n.createContext(void 0);function aG(e){let{children:t}=e,{status:s}=tr(),[a]=n.useState(()=>{!function(e){let t=aM(localStorage,aI);if(null!==t&&(aD(localStorage,aI),!aO()))try{let s=JSON.parse(t);if(!s||!e(s))return;aP(localStorage,aE(null),aL(s,null))}catch{}}(aH);try{for(let e=localStorage.length-1;e>=0;e--){let t=localStorage.key(e);if(!(null==t?void 0:t.startsWith(aR)))continue;let s=a$(aM(localStorage,t));(!s||Date.now()-s.savedAt>6048e5)&&aD(localStorage,t)}}catch{}let e=aU();if(e&&null===e.uuid)try{return{initial:aV(e.data),pending:null}}catch{}return{initial:aB,pending:az(null)}}),[l,i]=n.useState(a.initial),[o,d]=n.useState(a.pending),[c,u]=n.useState(null),[m,p]=n.useState(null),[h,x]=n.useState(null),g=n.useRef(aB),f=n.useRef(aB),[b,v]=n.useState(!1),y=n.useCallback(e=>{g.current=e},[]),j=n.useRef(!1);n.useEffect(()=>{if(!s||j.current)return;j.current=!0;let e=aK(aB,s);f.current=e,g.current=e,i(e=>aK(e,s)),v(!0)},[s]);let w=n.useRef(null);n.useEffect(()=>{w.current!==c&&(w.current=c,d(az(c)))},[c]),n.useEffect(()=>{if(!b)return;let e=setTimeout(()=>{var e,t;(e=g.current,JSON.stringify(aS(l))===JSON.stringify(aS(e)))?aF(c):(aP(sessionStorage,aA,aL(l,c,l.addonName)),t=l.addonName,aO()||aP(localStorage,aE(c),aL(l,c,t)))},400);return()=>clearTimeout(e)},[l,c,b]);let N=n.useCallback(()=>{d(e=>{if(e)try{let t=aV(e.data);i(()=>s?aK(t,s):t)}catch{}return null})},[s]),k=n.useCallback(()=>{d(e=>(e&&aF(e.uuid),null))},[]),S=o&&o.uuid===c?o:null,C=n.useCallback(()=>{aP(localStorage,aT,"1"),function(){try{let e=[];for(let t=0;t<localStorage.length;t++){let s=localStorage.key(t);(null==s?void 0:s.startsWith(aR))&&e.push(s)}
13e.forEach(e=>aD(localStorage,e))}catch{}}(),d(e=>(e&&aF(e.uuid),null))},[]);return(0,r.jsx)(aW.Provider,{value:{userData:l,setUserData:e=>{let t=()=>(g.current=f.current,f.current);null===e?i(t):i(s=>{let a=e(s);return null===a?t():a})},uuid:c,setUuid:u,password:m,setPassword:p,encryptedPassword:h,setEncryptedPassword:x,setBaseline:y,pendingDraft:S,restoreDraft:N,discardDraft:k,disableDrafts:C},children:t})}function aY(){let e=n.useContext(aW);if(void 0===e)throw Error("useUserData must be used within a UserDataProvider");return e}function aJ(){let{userData:e}=aY(),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 aZ=["about","services","addons","filters","sorting","formatter","proxy","miscellaneous","stats","save-install"],aQ=["sorting"],aX=(0,n.createContext)({selectedMenu:"about",setSelectedMenu:()=>{},nextMenu:()=>{},previousMenu:()=>{},firstMenu:"about",lastMenu:"save-install"});function a0(e){let{children:t}=e,{mode:s}=sy(),{status:a}=tr(),l=aY(),i=(null==a?void 0:a.settings.userAnalyticsEnabled)===!0&&!!(l.uuid&&l.password),o=(0,n.useMemo)(()=>{let e=aZ;return"noob"===s&&(e=e.filter(e=>!aQ.includes(e))),i||(e=e.filter(e=>"stats"!==e)),e},[s,i]),d=(()=>{if("u">typeof window){let e=new URL(window.location.href).searchParams.get("menu");if(e&&o.includes(e))return e}return"about"}
13)(),[c,u]=(0,n.useState)(d),m=e=>{window.scrollTo(0,0),u(e)},p=o[0],h=o[o.length-1];return(0,n.useEffect)(()=>{let e=new URL(window.location.href);"about"!==c?e.searchParams.set("menu",c):e.searchParams.delete("menu"),window.history.replaceState({},"",e.toString())},[c]),(0,r.jsx)(aX.Provider,{value:{selectedMenu:c,setSelectedMenu:m,nextMenu:()=>{let e=(o.indexOf(c)+1)%o.length;m(o[e])},previousMenu:()=>{let e=(o.indexOf(c)-1+o.length)%o.length;m(o[e])},firstMenu:p,lastMenu:h},children:t})}let a1=()=>(0,n.useContext)(aX),a2={filters:"filter",miscellaneous:"misc-tab",services:"service-tab",addons:"addons-tab"},a3={filters:"cache",miscellaneous:"background",services:"services",addons:"addons"},a5=(0,n.createContext)({subTabs:{},setSubTab:()=>{},getUrlKey:()=>void 0});function a4(){let e={...a3};if("u"<typeof window)return e;let t=new URL(window.location.href);for(let[s,a]of Object.entries(a2)){let r=t.searchParams.get(a);r&&(e[s]=r)}return e}function a6(e){let{children:t}=e,[s,a]=(0,n.useState)(a4),l=(0,n.useCallback)((e,t)=>{if(a(s=>({...s,[e]:t})),"u">typeof window){let s=a2[e];if(s){let e=new URL(window.location.href);e.searchParams.set(s,t),window.history.replaceState({},"",e.toString())}}},[]),i=(0,n.useCallback)(e=>a2[e],[]);(0,n.useEffect)(()=>{let e=()=>a(a4());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let o=(0,n.useMemo)(()=>({subTabs:s,setSubTab:l,getUrlKey:i}),[s,l,i]);return(0,r.jsx)(a5.Provider,{value:o,children:t})}function a9(e){let t=(0,n.useContext)(a5);return{tab:t.subTabs[e]??a3[e]??"",setTab:(0,n.useCallback)(s=>t.setSubTab(e,s),[t,e])}}let a8=null,a7=null;function re(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,a8&&a8.removeAttribute("data-command-target"),null!==a7&&window.clearTimeout(a7),o.setAttribute("data-command-target","true"),a8=o,a7=window.setTimeout(()=>{o.removeAttribute("data-command-target"),a8=null,a7=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 p=c-a;!(l>=3&&p>=120)&&p<1500&&requestAnimationFrame(i)};requestAnimationFrame(i)}let rt=(0,n.createContext)({isOpen:!1,open:()=>{},close:()=>{},toggle:()=>{},navigate:()=>{}});function rs(e){let{children:t}=e,{isOpen:s,open:a,close:l,toggle:i}=se(),{selectedMenu:o,setSelectedMenu:d}=a1(),{setSubTab:c}=(0,n.useContext)(a5),u=(0,n.useCallback)(e=>{e.subTab&&c(e.menu,e.subTab),o!==e.menu&&d(e.menu),l();let t=[e.sectionId,...e.fallbackSectionIds??[]].filter(e=>!!e);t.length>0&&re(t)},[o,d,c,l]);return(0,r.jsx)(rt.Provider,{value:{isOpen:s,open:a,close:l,toggle:i,navigate:u},children:t})}let ra=()=>(0,n.useContext)(rt),rr=(0,n.createContext)({actions:[],register:()=>()=>{}});function rn(e){let{children:t}=e,[,s]=(0,n.useState)(0),a=(0,n.useRef)(new Map),l=(0,n.useCallback)(e=>(a.current.set(e.id,e),s(e=>e+1),()=>{a.current.delete(e.id),s(e=>e+1)}),[]),i=(0,n.useMemo)(()=>({actions:Array.from(a.current.values()),register:l}),[l,a.current.size,...Array.from(a.current.keys())]);return(0,r.jsx)(rr.Provider,{value:i,children:t})}let rl=()=>(0,n.useContext)(rr);function ri(e,t){let{register:s}=rl();(0,n.useEffect)(()=>{if(e)return s(e)},t)}function ro(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function rd(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=ro(s);e&&t.push(e)}return t};return{primary:s(e),secondary:s(t)}}function rc(e){let t=ro(e);return{phrase:t,terms:t?t.split(" "):[]}}function ru(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 rm(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(ru(e.primary,t,r),.5*ru(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 rp(e){let{open:t,onClose:s,label:a,placeholder:n,emptyHint:l,query:i,onQueryChange:o,isIdle:d,results:c,idleGroup:u}=e;return(0,r.jsxs)(sx,{open:t,onOpenChange:e=>{e||s()}
13,hideCloseButton:!0,contentClass:"max-w-2xl p-0",commandProps:{shouldFilter:!1,label:a},children:[(0,r.jsx)(sd,{placeholder:n,autoFocus:!0,value:i,onValueChange:o}),(0,r.jsxs)(sc,{className:"max-h-[60vh]",children:[(0,r.jsx)(su,{children:d?l:"No matches."}),d?u:c.length>0&&(0,r.jsx)(sm,{children:c.slice(0,50).map(e=>(0,r.jsxs)(sp,{value:e.id,leftIcon:e.icon,onSelect:e.onSelect,children:[(0,r.jsx)("span",{children:e.label}),(0,r.jsx)("span",{className:"ml-auto text-xs text-[--muted] capitalize",children:e.trail}),e.shortcut&&(0,r.jsx)(sh,{children:e.shortcut})]},e.id))})]})]})}let rh=[{id:"about",label:"About",icon:(0,r.jsx)(t2.wfp,{})},{id:"services",label:"Services",icon:(0,r.jsx)(t2.V0M,{})},{id:"addons",label:"Addons",icon:(0,r.jsx)(t2.DT2,{})},{id:"filters",label:"Filters",icon:(0,r.jsx)(t2.Jw7,{})},{id:"sorting",label:"Sorting",icon:(0,r.jsx)(t2.MFA,{}),proOnly:!0},{id:"formatter",label:"Formatter",icon:(0,r.jsx)(t2.fSy,{})},{id:"proxy",label:"Proxy",icon:(0,r.jsx)(t2.nmg,{})},{id:"miscellaneous",label:"Miscellaneous",icon:(0,r.jsx)(t2.nMM,{})},{id:"stats",label:"Stats",icon:(0,r.jsx)(t2.yWU,{}),requiresStats:!0},{id:"save-install",label:"Save & Install",icon:(0,r.jsx)(t2.Ruw,{})}],rx={about:"About",services:"Services",addons:"Addons",filters:"Filters",sorting:"Sorting",stats:"Stats",formatter:"Formatter",proxy:"Proxy",miscellaneous:"Miscellaneous","save-install":"Save & Install"};function rg(e){return e.replace(/-/g," ")}let rf=Object.entries(sj).filter(e=>{let[,t]=e;return!t.ignoreForCommandPalette}).map(e=>{let[t,s]=e,a=void 0!==s.subTab?`${rg(s.menu)} → ${rg(s.subTab)}`:rx[s.menu]??rg(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:rd([s.label,t,s.menu,s.subTab,...s.keywords??[]])}}),rb=[{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:rd(["filter tab",e.label,e.id])}));function rv(){let{isOpen:e,close:t,navigate:s}=ra(),{actions:a}=rl(),{mode:l}=sy(),{status:i}=tr(),o=aY(),d=(null==i?void 0:i.settings.userAnalyticsEnabled)===!0&&!!(o.uuid&&o.password),[c,u]=(0,n.use
13State)(""),m=(0,n.useDeferredValue)(c),p=0===m.trim().length,h=(0,n.useMemo)(()=>rh.filter(e=>("pro"===l||!e.proOnly)&&(!e.requiresStats||d)).map(e=>({...e,haystack:rd([e.label,e.id])})),[l,d]),x=(0,n.useMemo)(()=>a.map(e=>({action:e,haystack:rd([e.label,...e.keywords??[]],[e.description])})),[a]),g=(0,n.useMemo)(()=>{if(p)return[];let e=rc(m),a=[];for(let{action:s,haystack:r}of x){let n=rm(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(),u(""),s.onSelect()}})}for(let t of h){let r=rm(t.haystack,e);r>0&&a.push({id:`menu-${t.id}`,label:t.label,trail:"Page",icon:t.icon,score:r,onSelect:()=>{u(""),s({menu:t.id})}})}for(let t of rb){let n=rm(t.haystack,e);n>0&&a.push({id:`filter-tab-${t.id}`,label:`Filters → ${t.label}`,trail:"Filter Tab",icon:(0,r.jsx)(t2.Jw7,{}),score:n,onSelect:()=>{u(""),s({menu:"filters",subTab:t.id,sectionId:`filter-tab-${t.id}`})}})}for(let t of rf){let r=rm(t.haystack,e);r>0&&a.push({id:t.key,label:t.label,trail:t.trail,score:r,onSelect:()=>{u(""),s({menu:t.menu,subTab:t.subTab,sectionId:t.sectionId,fallbackSectionIds:t.fallbackSectionIds})}})}return a.sort((e,t)=>t.score-e.score)},[m,p,x,h,s,t]);return(0,r.jsx)(rp,{open:e,onClose:()=>{t(),u("")},label:"Settings search",placeholder:"Search settings, pages, actions…",emptyHint:"Enter a setting to search for…",query:c,onQueryChange:u,isIdle:p,results:g,idleGroup:a.length>0&&(0,r.jsx)(sm,{heading:"Quick actions",children:a.map(e=>(0,r.jsxs)(sp,{value:`action-${e.id}`,leftIcon:e.icon,onSelect:()=>{t(),u(""),e.onSelect()},children:[(0,r.jsx)("span",{children:e.label}),e.shortcut&&(0,r.jsx)(sh,{children:e.shortcut})]},e.id))})})}let ry={key:"usenet.recheck.scope",not:"off"},rj={key:"shares.fuse.enabled",equals:!0},rw={key:"shares.nfs.enabled",equals:!0},rN={general:{label:"General",icon:t2.nMM,group:"General",order:10,sections:["api","templates","linkedAccounts"]},branding:{label:"Branding",icon:t2.pFm,group:"General",order:20},logging:{label:"Logging",icon:t2.XfR,group:"General",order:30},oidc:{label:"SSO / OIDC",icon:t2.$_m,group:"General",order:35},retention:{label:"Data & Retention",icon:t2.Wwx,group:"General",order:40,sections:["tasks","analytics"]},presets:{label:"Presets",icon:t2.Z_P,group:"Core",order:110},community:{label:"Community",icon:t2.e7V,group:"Core",order:115},builtins:{label:"Built-ins",icon:t2.oNA,group:"Core",order:120},resources:{label:"Addon Resources",icon:t2.z2t,group:"Core",order:130},metadata:{label:"Metadata",icon:t2.wfp,group:"Core",order:140,sections:["metadata","poster"]},releaseBlocklist:{label:"Blocklists",icon:t2.PLI,group:"Core",order:150},usenet:{fieldVisibility:{"usenet.recheck.schedule":ry,"usenet.recheck.window":ry,"usenet.recheck.depth":ry,"usenet.recheck.concurrency":ry,"usenet.recheck.batchSize":ry,"usenet.recheck.sampleSegments":[ry,{key:"usenet.recheck.depth",equals:"sample"}],"usenet.arrCensusHoldTimeout":{key:"usenet.arrWaitForCensus",equals:!0}},label:"Usenet",icon:t2.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.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:t2.uwC,group:"Usenet",order:170,fieldVisibility:{"shares.fuse.mountPath":rj,"shares.fuse.allowOther":rj,"shares.fuse.owner":rj,"shares.nfs.port":rw,"shares.nfs.bindAddress":rw,"shares.nfs.allowedClients":rw,"shares.nfs.owner":rw},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:t2.Ah9,group:"Usenet",order:180,editors:["arr.instances","arr.queueCleanup.rules"]},userDefaults:{label:"User Defaults",icon:t2.jlq,group:"Users",order:210,sections:["services","proxy.default","proxy.force"]},userLimits:{label:"User Limits",icon:t2.hTi,group:"Users",order:220},rateLimits:{label:"Rate Limits",icon:t2.I2B,group:"Users",order:230,sections:["rateLimits","recursion"]},http:{label:"Outbound Requests",icon:t2.IS1,group:"Traffic",order:310},proxy:{label:"Proxy",icon:t2.koG,group:"Traffic",order:320,sections:["proxy.encryption","proxy.ip"]},streams:{label:"Streams",icon:t2.U2S,group:"Traffic",order:330}},rk=new Map(Object.entries(rN).flatMap(e=>{let[t,s]=e;return(s.sections??[t]).map(e=>[e,t])}));function rS(e){let t=e.split(".");for(let e=t.length-1;e>=1;e--){let s=rk.get(t.slice(0,e).join("."));if(s)return s}return t[0]}function rC(e,t){var s;let a=null==(s=rN[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 r_=t2.Wwx,rA={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 rR(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(Boolean).map(e=>{let t=e.toLowerCase();return rA[t]?rA[t]:t.charAt(0).toUpperCase()+t.slice(1)}).join(" "):""}let rT=["dashboard","settings"],rI=["dashboard"];function rE(e){return(0,ta.I)({queryKey:rT,queryFn:()=>el("/dashboard/settings"),staleTime:1e4,enabled:(null==e?void 0:e.enabled)??!0})}let rM=["dashboard","shares","fuse"],rP=["dashboard","arr","instances"],rD=["dashboard","arr","queue-rules"];async function r$(){return el("GET /dashboard/settings/export")}let rL=[...t8.map(e=>({id:`page-${e.href}`,label:e.label,trail:"Page",icon:n.createElement(e.icon),target:{kind:"page",href:e.href},haystack:rd([e.label,e.href])})),...Object.entries(t7).flatMap(e=>{let[t,s]=e,a=t8.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:n.createElement(e.icon),target:{kind:"page",href:`${t}/${e.id}`},haystack:rd([e.label,e.id,null==a?void 0:a.label,`${null==a?void 0:a.label} ${e.label}`])}))}),...Object.entries(rN).map(e=>{let[t,s]=e;return{id:`settings-${t}`,label:s.label,trail:`Settings → ${s.group}`,icon:n.createElement(s.icon),target:{kind:"settings",tab:t},haystack:rd([s.label,t,s.group])}})];function rO(){let{isOpen:e,close:t}
17=sa(),s=(0,M.Z)(),[a,l]=(0,n.useState)(""),i=(0,n.useDeferredValue)(a),o=0===i.trim().length,{data:d}=rE({enabled:e}),c=(0,n.useMemo)(()=>((null==d?void 0:d.keys)??[]).map(e=>{let t=e.key.split("."),s=t[0],a=rS(e.key),r=rN[a],l=(null==r?void 0:r.label)??rR(s),i=t.slice(1,-1).map(rR).join(" → "),o=`Settings → ${l}`;return{id:`field-${e.key}`,label:e.label,trail:i?`${o} → ${i}`:o,icon:n.createElement((null==r?void 0:r.icon)??t2.nMM),target:{kind:"settings",tab:a,field:e.key},haystack:rd([e.label,e.key,e.env,l,i,`${l} ${e.label}`,...t.slice(1)],[e.description])}}),[null==d?void 0:d.keys]),u=e=>{switch(t(),l(""),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,n.useMemo)(()=>{if(o)return[];let e=rc(i),t=[];for(let s of[...rL,...c]){let a=rm(s.haystack,e);a>0&&t.push({id:s.id,label:s.label,trail:s.trail,icon:s.icon,score:a,onSelect:()=>u(s.target)})}return t.sort((e,t)=>t.score-e.score)},[i,o,c]);return(0,r.jsx)(rp,{open:e,onClose:()=>{t(),l("")},label:"Dashboard search",placeholder:"Search dashboard pages, sections, settings…",emptyHint:"Enter a page or section to search for…",query:a,onQueryChange:l,isIdle:o,results:m})}let rU="u"<typeof navigator?"":(null==(a=navigator.userAgentData)?void 0:a.platform)||navigator.platform||"",rF=/mac|ios|iphone|ipad|ipod/i.test(rU)?"⌘K":"Ctrl K",rz="flex items-center rounded-md border border-[--border] bg-[--subtle]/50 hover:bg-[--subtle] text-[--muted] hover:text-[--foreground] transition-colors";function rV(e){let{label:t,onOpen:s}=e,a=tN(),n=!a.isBelowBreakpoint,l=()=>{s(),a.setOpen(!1)};return(0,r.jsx)("div",{className:b("mb-3",n?"flex justify-center":"px-4"),children:n?(0,r.jsxs)(tO,{side:"right",trigger:(0,r.jsx)("button",{type:"button",onClick:l,"aria-label":t,className:b(rz,"w-11 h-10 justify-center"),children:(0,r.jsx)(t2.iyI,{className:"text-base shrink-0"})}),children:[t," (",rF,")"]}):(0,r.jsxs)("button",{type:"button",onClick:l,"aria-label":t,className:b(rz,"w-full h-9 gap-2 px-3 text-sm"),children:[(0,r.jsx)(t2.iyI,{className:"text-base shrink-0"}),(0,r.jsxs)("span",{className:"flex-1 text-left",children:[t,"…"]}),(0,r.jsx)("kbd",{className:"font-mono text-xs px-1.5 py-0.5 rounded border border-[--border] bg-[--background] text-[--muted] leading-none",children:rF})]})})}function rq(e){let{label:t,onOpen:s}=e;return(0,r.jsxs)("button",{type:"button",onClick:s,"aria-label":t,className:b(rz,"flex-1 h-9 gap-2 px-3 text-sm truncate"),children:[(0,r.jsx)(t2.iyI,{className:"text-base shrink-0"}),(0,r.jsxs)("span",{className:"flex-1 text-left",children:[t,"…"]})]})}function rB(){let{open:e}=sa();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-4 p-4 pb-0 flex flex-col items-center w-full",children:[(0,r.jsx)("img",{src:"/logo.png",alt:"AIOStreams",className:"max-w-[90px] max-h-[60px] object-contain p-4"}),(0,r.jsx)("span",{className:"text-xs text-gray-500 mb-3",children:"Dashboard"})]}),(0,r.jsx)(rV,{label:"Search dashboard",onOpen:e})]})}function rK(){let{open:e}=sa();return(0,r.jsx)(rq,{label:"Search dashboard",onOpen:e})}var rH=s(79620),rW=s(49877);function rG(e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}}let rY=e=>[Object,Array].includes((e||{}).constructor)&&!Object.entries(e||{}).length,rJ={root:(0,h.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,h.F)(["UI-Switch__container","inline-flex gap-2 items-center"],{variants:{side:{left:"",right:"w-full flex-row-reverse"}},defaultVariants:{side:"left"}}),thumb:(0,h.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,h.F)(["UI-Switch__label","relative font-normal text-sm","data-[disabled=true]:text-gray-300 cursor-pointer user-select-none select-none"])},rZ=n.forwardRef((e,t)=>
17{let[{size:s,value:a,className:l,onValueChange:i,labelClass:o,containerClass:d,thumbClass:c,defaultValue:u,inputRef:m,side:p,...h},{label:x,moreHelp:g,...f}]=U(e,n.useId()),v=n.useRef(!0),y=n.useRef(null),[j,w]=n.useState(a??u??!1),N=n.useCallback(e=>{w(e),null==i||i(e)},[i]);return n.useEffect(()=>{u&&v.current||w(a),v.current=!1},[a]),(0,r.jsx)(F,{...f,id:f.id,fieldClass:b("w-fit","right"===p&&"w-full group/switch hover:bg-white/5 rounded-[--radius] p-2 w-[calc(100%_+_1rem)] -ml-2"),fieldHelpTextClass:b(""),children:(0,r.jsxs)("div",{className:b(rJ.container({side:p}),d),children:[(0,r.jsx)(rW.bL,{ref:rG([y,t]),id:f.id,className:b(rJ.root({size:s}),l),disabled:f.disabled||f.readonly,"data-disabled":f.disabled,"data-readonly":f.readonly,"data-error":!!f.error,checked:j,onCheckedChange:N,defaultChecked:u,...h,children:(0,r.jsx)(rW.zi,{className:b(rJ.thumb({size:s}),c)})}),(0,r.jsx)("div",{className:"flex flex-1"}),!!x&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("label",{className:b(rJ.label(),o,"right"===p&&"font-semibold transition-transform __group-hover/switch:-translate-y-0.5"),htmlFor:f.id,"data-disabled":f.disabled,children:x}),g&&(0,r.jsx)(L,{className:"text-sm",trigger:(0,r.jsx)(P.ExT,{className:"transition-opacity opacity-45 hover:opacity-90"}),children:g})]}),(0,r.jsx)("input",{ref:m,type:"checkbox",name:f.name,className:V,value:j?"on":"off",checked:!f.required||j,"aria-hidden":"true",required:void 0===a&&f.required,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=y.current)?void 0:e.focus()}})]})})});rZ.displayName="Switch";var rQ=s(45748);let rX={root:(0,h.F)(["UI-Select__root","inline-flex items-center justify-between relative whitespace-nowrap truncate"]),chevronIcon:(0,h.F)(["UI-Combobox__chevronIcon","ml-2 h-4 w-4 shrink-0 opacity-50"]),scrollButton:(0,h.F)(["UI-Select__scrollButton","flex items-center justify-center h-[25px] bg-[--paper] text-base cursor-default"]),content:(0,h.F)(["UI-Select__content","w-full overflow-hidden rounded-[--radius] shadow-md bg-[--paper] border leading-none z-50"]),viewport:(0,h.F)(["UI-Select__viewport","p-1 z-10"]),item:(0,h.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,h.F)(["UI-Select__checkIcon","absolute left-2 w-4 inline-flex items-center justify-center"])},r0=n.forwardRef((e,t)=>{let[s,a]=U(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,placeholder:p,options:h,chevronIconClass:x,scrollButtonClass:g,contentClass:f,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}]=W({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),P=n.useRef(!0),D=n.useRef(null),[$,L]=n.useState(N??C),O=n.useCallback(e=>{if("__placeholder__"===e){L(""),null==k||k("");return}L(e),null==k||k(e)},[k]);return n.useEffect(()=>{C&&P.current||L(N),P.current=!1},[N]),(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...R,children:[(0,r.jsx)(H,{...T}),(0,r.jsx)(K,{...I}),(0,r.jsxs)(rQ.bL,{dir:w,value:$,onValueChange:O,onOpenChange:S,defaultValue:C,children:[(0,r.jsxs)(rQ.l9,{ref:rG([D,t]),id:a.id,className:b(z.root({size:l,intent:i,hasError:!!a.error,
17isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),rX.root(),m),"aria-label":a.name||"Select",...A,children:[(0,r.jsx)(rQ.WT,{placeholder:p}),(0,r.jsx)(rQ.In,{className:b(!!u&&"hidden"),children:(0,r.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:b(rX.chevronIcon(),x),children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})})]}),(0,r.jsx)(rQ.ZL,{children:(0,r.jsxs)(rQ.UC,{className:b(rX.content(),f),children:[(0,r.jsx)(rQ.PP,{className:b(rX.scrollButton(),g),children:(0,r.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:b(rX.chevronIcon(),"rotate-180",x),children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,r.jsxs)(rQ.LM,{className:b(rX.viewport(),v),children:[!!p&&!a.required&&(0,r.jsx)(rQ.q7,{className:b(rX.item(),j),value:"__placeholder__",children:(0,r.jsx)(rQ.p4,{className:"flex-none whitespace-nowrap truncate",children:p})}),null==h?void 0:h.map(e=>(0,r.jsxs)(rQ.q7,{className:b(rX.item(),j),value:e.value,disabled:e.disabled,"data-disabled":e.disabled,children:[(0,r.jsx)(rQ.p4,{className:"flex-none whitespace-nowrap truncate",children:e.label}),(0,r.jsx)(rQ.VF,{asChild:!0,children:(0,r.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:b(rX.checkIcon(),y),children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})})})]},e.value))]}),(0,r.jsx)(rQ.wn,{className:b(rX.scrollButton(),g),children:(0,r.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:b(rX.chevronIcon(),x),children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})})]})})]}),(0,r.jsxs)("select",{ref:_,name:a.name,className:V,"aria-hidden":"true",required:a.required,disabled:a.disabled,value:$,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=D.current)?void 0:e.focus()},children:[(0,r.jsx)("option",{value:""}),null==h?void 0:h.map(e=>(0,r.jsx)("option",{value:e.value,disabled:e.disabled},e.value))]}),(0,r.jsx)(H,{...E}),(0,r.jsx)(K,{...M})]})})});function r1(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 r2(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 r3(e,t){let s=r2(e);return`/api/v1/dashboard/logs/export?format=${t}${s?`&${s}`:""}`}function r5(e,t){let[s,a]=(0,n.useState)(e);return(0,n.useEffect)(()=>{let s=setTimeout(()=>a(e),t||500);return()=>{clearTimeout(s)}},[e,t]),s}r0.displayName="Select";let r4={initial:{opacity:0,y:60},animate:{opacity:1,y:0},exit:{opacity:0,y:60},transition:{type:"spring",damping:20,stiffness:100}};function r6(e){let{children:t,className:s,...a}=e;return(0,r.jsx)("div",{"data-page-wrapper-container":!0,children:(0,r.jsx)(tB.P.div,{"data-page-wrapper":!0,...r4,...a,className:b("z-[5] relative",s),children:t})})}async function r9(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 navigator.clipboard.writeText(e),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 r8=["B","KB","MB","GB","TB","PB"],r7=["bps","Kbps","Mbps","Gbps","Tbps"];function ne(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(r8.length-1,Math.max(0,Math.floor(Math.log(Math.abs(e))/Math.log(1e3))));return`${(e/1e3**s).toFixed(+(0!==s))} ${r8[s]}`}function nt(e,t){return null!=e&&Number.isFinite(e)?`${ne(e,t)}/s`:ne(e,t)}function ns(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(r7.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} ${r7[s]}`}function na(e){return Number.isFinite(e)?`${(100*e).toFixed(e>0&&e<.001?2:1)}%`:"0%"}let nr=[["w",604800],["d",86400],["h",3600],["m",60],["s",1]];function nn(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<nr.length;e++){let[s,a]=nr[e],r=Math.floor(t/a);if(r>0){let n=t-r*a,l=nr[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 nl={ms:1,s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function ni(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])*nl[t[2]],l+=t[0].length;return 0===l||l!==a.length?null:Math.round(n)}function no(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 nd(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 nc(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 nu(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}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"},nh={trace:"bg-gray-400",debug:"bg-sky-500",info:"bg-emerald-500",warn:"bg-amber-500",error:"bg-red-400",fatal:"bg-red-400"},nx="__all__",ng="aiostreams.logs.prefs";function nf(){try{let e=localStorage.getItem(ng);if(e)return{...nb,...JSON.parse(e)}}catch{}return nb}let nb={autoscroll:!0,wrap:!1,levels:[]};function nv(e){let{row:t,wrap:s,expanded:a,onToggle:l}=e,i=nu(t.time),o=Object.keys(t.obj).length>
170,[d,c]=(0,n.useState)(!1),u=a?JSON.stringify(JSON.parse(t.raw)):[i,t.level,t.module?`[${t.module}]`:"",t.msg,o?Object.entries(t.obj).map(e=>{let[t,s]=e;return`${t}=${"object"==typeof s?JSON.stringify(s):s}`}).join(" "):""].filter(Boolean).join(" ");return(0,r.jsxs)("div",{className:b("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:l,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded-full bg-brand/15 text-brand font-medium tabular-nums",children:i})," ",(0,r.jsx)("span",{className:b("inline-block w-2 h-2 rounded-full align-middle",nh[t.level]??"bg-[--muted]"),title:t.level})," ",t.module&&(0,r.jsxs)("span",{className:"text-[--muted-highlight]",children:["[",t.module,"]"]})," ",(0,r.jsx)("span",{className:"text-[--foreground]",children:t.msg}),o&&!a&&(0,r.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,r.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)}),d&&(0,r.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(),r9(u,{onSuccess:()=>x.oR.success("Copied log line"),onError(e){x.oR.error("Failed to copy: "+e),console.error("Failed to copy log line:",e)}})},children:(0,r.jsx)(t2.Xpf,{className:"text-sm"})})]})}var ny=s(90730),nj=s(89623),nw=s(82436),nN=s(53366),nk=s(33017);let nS={root:(0,h.F)(["UI-Tabs__root"]),list:(0,h.F)(["UI-Tabs__list","inline-flex h-12 items-center justify-center w-full"]),trigger:(0,h.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,h.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"])},nC=n.createContext({}),n_=n.forwardRef((e,t)=>{let{className:s,listClass:a,triggerClass:l,contentClass:i,variant:o="underline",indicatorClass:d,value:c,defaultValue:u,onValueChange:m,...p}=e,[h,x]=n.useState(c??u);n.useEffect(()=>{void 0!==c&&x(c)},[c]);let g=n.useCallback(e=>{void 0===c&&x(e),null==m||m(e)},[m,c]),f=n.useId(),v=n.useMemo(()=>`tab-indicator-${f.replace(/:/g,"")}`,[f]);return(0,r.jsx)(nC.Provider,{value:{listClass:a,triggerClass:l,contentClass:i,activeTab:h,layoutId:v,variant:o,indicatorClass:d},children:(0,r.jsx)(nN.bL,{ref:t,value:c,defaultValue:u,onValueChange:g,className:b(nS.root(),s),...p})})});n_.displayName="Tabs";let nA=n.forwardRef((e,t)=>{let{className:s,...a}=e,{listClass:l}=n.useContext(nC);return(0,r.jsx)(nN.B8,{ref:t,className:b(nS.list(),l,s),...a})});nA.displayName="TabsList";let nR=n.forwardRef((e,t)=>{let{className:s,children:a,...l}=e,{triggerClass:i,activeTab:o,layoutId:d,variant:c,indicatorClass:u}=n.useContext(nC),m=(0,nk.I)(),p=o===l.value,h=!m&&!!d,x=h?"pill"===c?"data-[state=active]:bg-transparent":"data-[state=active]:border-transparent":"";return(0,r.jsxs)(nN.l9,{ref:t,className:b(nS.trigger(),i,s,x,h&&"relative z-0"),...l,children:[a,h&&p&&(0,r.jsx)(tB.P.span,{layoutId:d,transition:{type:"spring",stiffness:500,damping:38},className:b("pill"===c?"absolute inset-0 -z-10 rounded-[inherit] bg-[--subtle]":"absolute bottom-0 left-0 right-0 h-0.5 bg-[--brand]",u)})]})});nR.displayName="TabsTrigger";let nT=n.forwardRef((e,t)=>
17{let{className:s,...a}=e,{contentClass:l}=n.useContext(nC);return(0,r.jsx)(nN.UC,{ref:t,className:b(nS.content(),l,s),...a})});nT.displayName="TabsContent";let nI={root:(0,h.F)(["UI-StaticTabs__root","flex w-full overflow-hidden overflow-x-auto gap-2 py-1"]),trigger:(0,h.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,h.F)(["UI-StaticTabs__icon","-ml-0.5 mr-2 h-4 w-4"])},nE=n.forwardRef((e,t)=>{let{children:s,className:a,triggerClass:l,iconClass:i,items:o,pillClass:d,...c}=e,u=(0,nk.I)(),m=n.useId(),p=`static-tab-indicator-${m.replace(/:/g,"")}`,h=!u,x=e=>h&&e?(0,r.jsx)(tB.P.span,{layoutId:p,transition:{type:"spring",stiffness:500,damping:38},className:b("absolute inset-0 -z-10 rounded-[inherit] bg-[--subtle]",d)}):null;return(0,r.jsx)("nav",{ref:t,className:b(nI.root(),a),role:"navigation",...c,children:o.map(e=>e.href?(0,r.jsxs)("a",{href:e.href??"#",className:b("cursor-pointer",nI.trigger(),l,h?"relative z-0":"data-[current=true]:bg-[--subtle]"),"aria-current":e.isCurrent?"page":void 0,"data-current":e.isCurrent,children:[x(!!e.isCurrent),e.iconType&&(0,r.jsx)(e.iconType,{className:b(nI.icon(),i),"aria-hidden":"true","data-current":e.isCurrent}),(0,r.jsx)("span",{children:e.name})]},e.name):(0,r.jsxs)("div",{className:b(nI.trigger(),"cursor-pointer",l,h?"relative z-0":"data-[current=true]:bg-[--subtle]"),"aria-current":e.isCurrent?"page":void 0,"data-current":e.isCurrent,onClick:e.onClick,children:[x(!!e.isCurrent),e.iconType&&(0,r.jsx)(e.iconType,{className:b(nI.icon(),i),"aria-hidden":"true","data-current":e.isCurrent}),(0,r.jsx)("span",{children:e.name})]},e.name))})});nE.displayName="StaticTabs";var nM=s(52979);function nP(e){return Object.fromEntries(Object.entries(e.shape).map(e=>{let[t,s]=e;return s instanceof nj.Xi?[t,s.parse(void 0)]:[t,void 0]}))}let nD=n.createContext(void 0),n$=e=>{let{mode:t="onSubmit",resolver:s,reValidateMode:a,shouldFocusError:l,shouldUnregister:i,shouldUseNativeValidation:o,criteriaMode:d,delayError:c,schema:u,defaultValues:m,onChange:p,onSubmit:h,onError:x,formRef:g,children:f,mRef:v,stackClass:y,...j}=e,w=n.useMemo(()=>{if(!(rY(nP(u))&&rY(m)))return{...nP(u),...m}},[]),N=(0,nw.mN)({mode:t,resolver:(0,nM.u)(u),defaultValues:w,reValidateMode:a,shouldFocusError:l,shouldUnregister:i,shouldUseNativeValidation:o,criteriaMode:d,delayError:c}),{handleSubmit:k}=N;return n.useImperativeHandle(v,()=>N,[v,N]),n.useEffect(()=>{let e;return p&&(e=N.watch(p)),()=>null==e?void 0:e.unsubscribe()},[N,p]),(0,r.jsx)(nw.Op,{...N,children:(0,r.jsx)(nD.Provider,{value:{schema:u,shape:u.shape},children:(0,r.jsx)("form",{ref:g,onSubmit:k(h,x),...j,children:(0,r.jsx)("div",{className:b("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}(f,N)})})})})};n$.displayName="Form";var nL=s(5070),nO=s(27680),nU=s(55807);let nF={root:(0,h.F)(["UI-Autocomplete__root"]),popover:(0,h.F)(["UI-Autocomplete__popover","w-[--radix-popover-trigger-width] p-0"]),checkIcon:(0,h.F)(["UI-Autocomplete__checkIcon","h-4 w-4","data-[selected=true]:opacity-100 data-[selected=false]:opacity-0"]),container:(0,h.F)(["UI-Autocomplete__container","relative w-full"]),command:(0,h.F)(["UI-Autocomplete__command","focus-within:ring-2 ring-[--ring] transition"])},nz=n.forwardRef((e,t)=>{let[s,a]=U(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,popoverClass:p,checkIconClass:h,containerClass:x,commandClass:g,commandProps:f,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:P,rightIconProps:D}]=W({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),$=n.useRef(!0),O=n.useRef(!1),B=n.useRef((null==w?void 0:w.label)||(null==C?void 0:C.label)||""),[G,Y]=n.useState((null==w?void 0:w.label)||(null==C?void 0:C.label)||""),J=n.useDeferredValue(G);B.current=G;let Z=n.useRef(w||C||void 0),[Q,X]=n.useState(w||C||void 0),[ee,et]=n.useState(!1),es=n.useMemo(()=>_?v.filter(e=>e.label.toLowerCase().includes(J.toLowerCase())):v,[_,v,J]),ea=!!y||v.length>0&&es.length>0,er=n.useCallback((e,t)=>e.toLowerCase()===t.toLowerCase(),[]),en=n.useRef(null),el=n.useRef(null);n.useEffect(()=>{O.current||(C&&$.current||(Y((null==w?void 0:w.label)??""),X(w),eu(w)),$.current=!1)},[w]);let ei=n.useCallback(e=>{a.disabled||a.readonly||0===v.length&&e||(B.current!==G||!e||0!==es.length)&&(et(e),e||n.startTransition(()=>{var e;null==(e=en.current)||e.focus()}))},[v,G,a.disabled,a.readonly]),eo=n.useCallback(e=>{O.current=!0,null==S||S(e),Y(e.target.value),_&&es.length>0&&et(!0)},[es]);n.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),O.current=!1},[J,_]);let ed=n.useCallback(e=>{X(e),null==N||N(e),null==k||k((null==e?void 0:e.label)??""),eu(e)},[N,k]),ec=n.useCallback(e=>{if(ee||et(!0),"ArrowDown"===e.key){var t;
17e.preventDefault(),null==(t=el.current)||t.focus()}},[ee]),eu=n.useCallback(e=>{((null==e?void 0:e.value)||void 0===e)&&(Z.current=e)},[]),em=n.useCallback(()=>{"options"===R&&n.startTransition(()=>{Z.current?Y(Z.current.label):Y("")})},[]);return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...I,children:[(0,r.jsx)(H,{...E}),(0,r.jsx)(K,{...M}),(0,r.jsx)(L,{open:ee&&ea,onOpenChange:ei,className:b(nF.popover(),p),onOpenAutoFocus:e=>e.preventDefault(),trigger:(0,r.jsx)("div",{className:b(nF.container(),x),children:(0,r.jsx)("input",{ref:rG([en,t]),id:a.id,name:a.name,value:G,onChange:eo,onBlur:em,placeholder:j,className:b(z.root({size:l,intent:i,hasError:!!a.error,isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),nF.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,r.jsxs)(so,{className:b(nF.command(),g),inputContainerClass:"py-1",shouldFilter:_,...f,children:[A&&G.length>0&&(0,r.jsx)("div",{className:"w-full absolute top-0 left-0 px-1",children:(0,r.jsx)("div",{className:"h-1 w-full bg-[--subtle] overflow-hidden relative rounded-full",children:(0,r.jsx)("div",{className:"animate-indeterminate-progress absolute left-0 w-full h-full bg-brand origin-left-right"})})}),(0,r.jsx)(sd,{value:G,onValueChange:Y,inputContainerClass:V,"aria-hidden":"true",ref:el}),(0,r.jsxs)(sc,{children:[!!y&&(0,r.jsx)(su,{children:y}),(0,r.jsx)(sm,{children:v.map(e=>(0,r.jsx)(sp,{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))),n.startTransition(()=>{var e;null==(e=en.current)||e.focus()})},leftIcon:(0,r.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:b(nF.checkIcon(),h),"data-selected":er(e.label,G),children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})}),children:e.label},e.value))})]})]})}),(0,r.jsx)(H,{...P}),(0,r.jsx)(K,{...D})]})})});nz.displayName="Autocomplete";var nV=s(10251);let nq={container:(0,h.F)("UI-Checkbox__container inline-flex gap-2 items-center"),root:(0,h.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,h.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,h.F)(["UI-Checkbox__indicator","flex h-full w-full items-center justify-center relative"]),checkIcon:(0,h.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"}})},nB=n.forwardRef((e,t)=>{let[{className:s,hideError:a,containerClass:l,checkIconClass:i,labelClass:o,indicatorClass:d,onValueChange:c,defaultValue:u,value:m,size:p,inputRef:h,...x},{label:g,...f}]=U(e,n.useId()),v=n.useContext(nK),y=(null==v?void 0:v.group_size)??p,j=n.useRef(!0),w=n.useRef(null),[N,k]=n.useState(m??u??!1),S=n.useCallback(e=>{k(e),null==c||c(e)},[c]);return n.useEffect(()=>{u&&j.current||k(m??!1),j.current=!1},[m]),(0,r.jsx)(F,{fieldClass:"flex gap-2",...f,error:a?void 0:f.error,children:(0,r.jsxs)("label",{className:b(nq.container(),l),htmlFor:f.id,children:[(0,r.jsx)(nV.bL,{ref:rG([w,t]),id:f.id,className:b(nq.root
17({size:y}),s),disabled:f.disabled||f.readonly,"data-error":!!f.error,"data-disabled":f.disabled,"aria-readonly":f.readonly,"data-readonly":f.readonly,checked:N,onCheckedChange:S,...x,children:(0,r.jsxs)(nV.P7,{className:b(nq.indicator(),d),children:["indeterminate"!==N&&(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",stroke:"currentColor",fill:"currentColor",className:b(nq.checkIcon({size:y}),i),children:(0,r.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,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",className:b(nq.checkIcon({size:y}),i),children:(0,r.jsx)("line",{x1:"5",x2:"19",y1:"12",y2:"12"})})]})}),!!g&&(0,r.jsx)("label",{className:b(nq.label({size:y}),o),htmlFor:f.id,"data-disabled":f.disabled,"data-checked":!0===N,children:g}),(0,r.jsx)("input",{ref:h,type:"checkbox",name:f.name,className:V,value:"indeterminate"===N?"indeterminate":N?"on":"off",checked:!f.required||!0===N,"aria-hidden":"true",required:void 0===m&&f.required,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=w.current)?void 0:e.focus()}})]})})});nB.displayName="Checkbox";let nK=n.createContext(null),nH=n.forwardRef((e,t)=>{let[{value:s,defaultValue:a=[],onValueChange:l,stackClass:i,itemLabelClass:o,itemClass:d,itemContainerClass:c,itemCheckIconClass:u,options:m,size:p},h]=U(e,n.useId()),[x,g]=n.useState(s??a),f=n.useCallback(e=>t=>{g(s=>{let a=!0===t?[...s,...s.includes(e)?[]:[e]]:!1===t?s.filter(t=>t!==e):[...s];return null==l||l(a),a})},[l]);return n.useEffect(()=>{void 0!==s&&g(s)},[s]),(0,r.jsx)(nK.Provider,{value:{group_size:p},children:(0,r.jsxs)(F,{...h,children:[(0,r.jsx)("div",{className:b("UI-CheckboxGroup__stack space-y-1",i),children:m.map(e=>(0,r.jsx)(nB,{label:e.label,value:x.includes(e.value),onValueChange:f(e.value),hideError:!0,error:h.error,className:d,labelClass:o,containerClass:c,checkIconClass:u,disabled:h.disabled||e.disabled,readonly:h.readonly||e.readonly,tabIndex:0},e.value))}),(0,r.jsx)("input",{ref:t,type:"text",id:h.name,name:h.name,className:V,value:h.required?x.length?JSON.stringify(x):"":JSON.stringify(x),"aria-hidden":"true",required:h.required,tabIndex:-1,onChange:()=>{}})]})})});nH.displayName="CheckboxGroup";var nW=s(67371),nG=s.n(nW);let nY={root:(0,h.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,h.F)(["UI-Combobox__popover","w-[--radix-popover-trigger-width] p-0"]),checkIcon:(0,h.F)(["UI-Combobox__checkIcon","h-4 w-4","data-[selected=true]:opacity-100 data-[selected=false]:opacity-0"]),item:(0,h.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,h.F)(["UI-Combobox__placeholder","text-[--muted] truncate"]),inputValuesContainer:(0,h.F)(["UI-Combobox__inputValuesContainer","grow flex overflow-hidden gap-2 flex-wrap"]),chevronIcon:(0,h.F)(["UI-Combobox__chevronIcon","ml-2 h-4 w-4 shrink-0 opacity-50"]),removeItemButton:(0,h.F)(["UI-Badge__removeItemButton","text-lg cursor-pointer transition ease-in hover:opacity-60"])},nJ=n.forwardRef((e,t)=>{let[s,a]=U(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,popoverClass:p,checkIconClass:h,itemClass:x,placeholderClass:g,inputValuesContainerClass:f,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,...P},{inputContainerProps:D,leftAddonProps:$,leftIconProps:O,rightAddonProps:B,rightIconProps:G}]=W({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),Y=n.useRef(null),J=n.useRef(S||R||[]),[Z,Q]=n.useState(S||R||[]),[X,ee]=n.useState(!1),et=n.useCallback(e=>{Q(e),J.current=e},[]);n.useEffect(()=>{void 0===S||nG()(S,J.current)||et(S)},[S]),n.useEffect(()=>{null==C||C(Z)},[Z]);let es={},ea=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 es[a]=(es[a]||0)+1,{...e,label:es[a]>1?`${r} (${es[a]})`:r,textValue:es[a]>1?`${a} (${es[a]})`:a}}),er=ea.filter(e=>Z.includes(e.value)),en=A&&"number"==typeof E&&Z.length>=E,el=A&&"number"==typeof M?er.slice(0,Math.max(0,M)):er,ei=er.length-el.length,eo=Z.length&&er.length?A?(0,r.jsxs)(r.Fragment,{children:[el.map(e=>(0,r.jsxs)("div",{className:b(nY.item(),x),children:[(0,r.jsx)("span",{className:"truncate",children:e.textValue||e.value}),(0,r.jsx)("span",{className:b(nY.removeItemButton(),"rounded-full",y),onClick:t=>{t.preventDefault(),et(Z.filter(t=>t!==e.value)),ee(!1)},children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor",children:(0,r.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)),ei>0&&(0,r.jsxs)("div",{className:b(nY.item(),"text-[--muted] pr-2",x),children:["+",ei," more"]})]}):(0,r.jsx)("span",{className:"truncate",children:er[0].label}):(0,r.jsx)("span",{className:b(nY.placeholder(),g),children:k});return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...D,children:[(0,r.jsx)(H,{...$}),(0,r.jsx)(K,{...O}),(0,r.jsx)(L,{open:X,onOpenChange:ee,className:b(nY.popover(),p),trigger:(0,r.jsxs)("button",{ref:rG([Y,t]),id:a.id,role:"combobox","aria-expanded":X,className:b(z.root({size:l,intent:i,hasError:!!a.error,
17isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),nY.root({size:l})),...P,children:[(0,r.jsx)("div",{className:b(nY.inputValuesContainer()),children:eo}),(0,r.jsxs)("div",{className:"flex items-center",children:[!!Z.length&&!!er.length&&!A&&(0,r.jsx)("span",{className:b(nY.removeItemButton(),y),onClick:e=>{e.preventDefault(),et([]),ee(I)},children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor",children:(0,r.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,r.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:b(nY.chevronIcon(),v),children:[(0,r.jsx)("path",{d:"m7 15 5 5 5-5"}),(0,r.jsx)("path",{d:"m7 9 5-5 5 5"})]})]})]}),children:(0,r.jsxs)(so,{inputContainerClass:"py-1",...j,children:[(0,r.jsx)(sd,{placeholder:k,onValueChange:_}),(0,r.jsxs)(sc,{children:[(0,r.jsx)(su,{children:N}),(0,r.jsx)(sm,{children:ea.map(e=>{let t=en&&!Z.includes(e.value);return(0,r.jsx)(sp,{value:e.textValue||e.value,disabled:t,className:b(t&&"opacity-50 cursor-not-allowed pointer-events-none"),onSelect:e=>{let t=ea.find(t=>(t.textValue||t.value).toLowerCase()===e.toLowerCase());t&&(A?et(Z.includes(t.value)?Z.filter(e=>e!==t.value):[...Z,t.value]):et(Z.includes(t.value)?[]:[t.value])),ee(I)},leftIcon:(0,r.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:b(nY.checkIcon(),h),"data-selected":Z.includes(e.value),children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})}),children:e.label},e.value)})})]})]})}),(0,r.jsx)("input",{ref:T,type:"text",name:a.name,className:V,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,r.jsx)(H,{...B}),(0,r.jsx)(K,{...G})]})})});nJ.displayName="Combobox";let nZ=n.forwardRef((e,t)=>{let[s,a]=U(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,placeholder:p,options:h,...x},{inputContainerProps:g,leftAddonProps:f,leftIconProps:v,rightAddonProps:y,rightIconProps:j}]=W({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon});return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...g,children:[(0,r.jsx)(H,{...f}),(0,r.jsx)(K,{...v}),(0,r.jsxs)("select",{id:a.id,name:a.name,className:b("form-select",z.root({size:l,intent:i,hasError:!!a.error,
17isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,...x,ref:t,children:[p&&(0,r.jsx)("option",{value:"",children:p}),null==h?void 0:h.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label??e.value},e.value))]}),(0,r.jsx)(H,{...y}),(0,r.jsx)(K,{...j,className:b(j.className,c?null:"mr-8")})]})})});nZ.displayName="NativeSelect";var nQ=s(63121),nX=s(82523);let n0={root:(0,h.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,h.F)(["UI-NumberInput__control","rounded-none h-[50%] ring-inset"]),controlsContainer:(0,h.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,h.F)(["UI-Combobox__chevronIcon","h-4 w-4 shrink-0"])},n1=n.forwardRef((e,t)=>{let[s,a]=U(e,n.useId()),[{controlClass:l,controlsContainerClass:i,chevronIconClass:o,className:d,children:c,size:u,intent:m,leftAddon:p,leftIcon:h,rightAddon:x,rightIcon:g,placeholder:f,onValueChange:v,hideControls:y,value:j,min:w=0,max:N,step:k,allowMouseWheel:S=!0,formatOptions:C={maximumFractionDigits:2},clampValueOnBlur:_=!0,allowEmpty:A=!1,translations:R,locale:T,dir:I,defaultValue:M,...P},{inputContainerProps:D,leftAddonProps:$,leftIconProps:L,rightAddonProps:O,rightIconProps:V}]=W({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),B=null==j||""===j,G=(0,nX.zl)(nQ.Aq,{id:a.id,name:a.name,disabled:a.disabled,readOnly:a.readonly,value:A&&B?"":null!=j?String(j):null!=M?String(M):void 0,min:w,max:N,step:k,allowMouseWheel:S,formatOptions:C,clampValueOnBlur:!A&&_,translations:R,locale:T,dir:I,onValueChange:e=>{null==v||v(e.valueAsNumber,e.value)}}),Y=nQ.Ng(G,nX._B),J=n.useRef(!0);return n.useEffect(()=>{J.current||(A&&B?Y.clearValue():"string"!=typeof j||isNaN(Number(j))?"number"==typeof j?Y.setValue(j):void 0===j&&Y.setValue(w):Y.setValue(Number(j))),J.current=!1},[j]),(0,r.jsx)(F,{...a,id:Y.getInputProps().id,children:(0,r.jsxs)(q,{...D,children:[(0,r.jsx)(H,{...$}),(0,r.jsx)(K,{...L}),(0,r.jsx)("input",{ref:t,type:"number",name:a.name,className:b("form-input",z.root({size:u,intent:m,hasError:!!a.error,
17isDisabled:!!a.disabled,hasRightAddon:!!x||!y,hasRightIcon:!!g,hasLeftAddon:!!p,hasLeftIcon:!!h}),n0.root({hideControls:y,intent:m,size:u}),d),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,...Y.getInputProps(),...P,placeholder:f}),!y&&(0,r.jsxs)("div",{className:b(z.root({size:u,intent:m,hasError:!!a.error,isDisabled:!!a.disabled,hasRightAddon:!!x,hasRightIcon:!!g,hasLeftAddon:!0}),n0.controlsContainer({size:u,intent:m,hasRightAddon:!!x}),i),children:[(0,r.jsx)(E,{intent:"gray-basic",size:"sm",className:b(n0.control(),l),...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,r.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:b(n0.chevronIcon(),"rotate-180",o),children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,r.jsx)(E,{intent:"gray-basic",size:"sm",className:b(n0.control(),l),...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,r.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:b(n0.chevronIcon(),o),children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})})]}),(0,r.jsx)(H,{...O}),(0,r.jsx)(K,{...V,className:b("z-3",V.className,x?null:"mr-6")})]})})});n1.displayName="NumberInput";var n2=s(37403);let n3={root:(0,h.F)(["UI-RadioGroup__root"]),item:(0,h.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,h.F)(["UI-RadioGroup__itemIndicator","flex items-center justify-center"]),itemLabel:(0,h.F)(["UI-Checkbox_itemLabel","font-normal block","data-[disabled=true]:opacity-50"],{variants:{size:{md:"text-md",lg:"text-lg"}},defaultVariants:{size:"md"}}),itemContainer:(0,h.F)(["UI-RadioGroup__itemContainer","flex gap-2 items-center relative"]),itemCheckIcon:(0,h.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"}})},n5=n.forwardRef((e,t)=>{let s=n.useId(),[{size:a,className:l,stackClass:i,value:o,onValueChange:d,options:c,inputRef:u,defaultValue:m,itemClass:p,itemIndicatorClass:h,itemLabelClass:x,itemContainerClass:g,itemCheckIcon:f,itemCheckIconClass:v},y]=U(e,s),j=n.useRef(!0),w=n.useRef(null),[N,k]=n.useState(o??m),S=n.useCallback(e=>{k(e),null==d||d(e)},[d]);return n.useEffect(()=>{m&&j.current||k(o),j.current=!1},[o]),(0,r.jsxs)(F,{...y,children:[(0,r.jsx)(n2.bL,{value:N,onValueChange:S,defaultValue:m,className:b(n3.root(),l),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,r.jsx)("div",{className:b("UI-RadioGroup__stack space-y-1",i),children:c.map(e=>(0,r.jsxs)("label",{className:b(n3.itemContainer(),g),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,r.jsx)(n2.q7,{ref:rG([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:b(n3.item({size:a}),p),children:(0,r.jsx)(n2.C1,{className:b(n3.itemIndicator(),h),"data-error":!!y.error,"data-disabled":y.disabled||e.disabled,"data-readonly":y.readonly||e.readonly,children:f||(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",stroke:"currentColor",fill:"
17currentColor",className:b(n3.itemCheckIcon({size:a}),v),children:(0,r.jsx)("path",{d:"M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z"})})})},e.value),(0,r.jsx)("label",{className:b(n3.itemLabel(),x),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,r.jsx)("input",{ref:u,type:"radio",name:y.name,className:V,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()}})]})});n5.displayName="RadioGroup";var n4=s(1628);let n6={root:(0,h.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,h.F)(["UI-SimpleDropzone__list","flex rounded-[--radius-md] flex-wrap divide-y divide-[--border]"]),listItem:(0,h.F)(["UI-SimpleDropzone__listItem","flex items-center justify-space-between relative p-1 hover:bg-[--subtle] w-full overflow-hidden"]),listItemDetailsContainer:(0,h.F)(["UI-SimpleDropzone__listItemDetailsContainer","flex items-center gap-2 truncate w-full"]),listItemTitle:(0,h.F)(["UI-SimpleDropzone__listItemTitle","truncate max-w-[180px] text-[.9rem]"]),listItemSize:(0,h.F)(["UI-SimpleDropzone__listItemSize","text-xs uppercase text-center font-semibold align-center text-[--muted]"]),listItemRemoveButton:(0,h.F)(["UI-SimpleDropzone__listItemRemoveButton","ml-2 rounded-full"]),imagePreviewGrid:(0,h.F)(["UI-SimpleDropzone__imagePreviewGrid","flex gap-2 flex-wrap place-content-center pt-4"]),imagePreviewContainer:(0,h.F)(["UI-SimpleDropzone__imagePreviewContainer","col-span-1 row-span-1 aspect-square w-36 h-auto"]),imagePreview:(0,h.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,h.F)(["UI-SimpleDropzone__imagePreviewRemoveButton","absolute top-1 right-1"]),fileIcon:(0,h.F)(["UI-SimpleDropzone__fileIcon","w-5 h-5 flex-none"]),maxSizeText:(0,h.F)(["UI-SimpleDropzone__maxSizeText","text-sm text-[--muted] font-medium"])},n9=n.forwardRef((e,t)=>{let[{children:s,className:a,listClass:l,listItemClass:i,listItemDetailsContainerClass:o,listItemRemoveButtonClass:d,listItemSizeClass:c,listItemTitleClass:u,imagePreviewGridClass:m,imagePreviewContainerClass:p,imagePreviewRemoveButtonClass:h,imagePreviewClass:x,maxSizeTextClass:g,fileIconClass:f,onValueChange:v,withImagePreview:y,dropzoneText:j,accept:w,minSize:N,maxSize:k,maxFiles:S,preventDropOnDocument:C,noClick:_,noDrag:A,onError:R,onDropRejected:I,validator:M,multiple:P,value:D,...$},L]=U(e,n.useId()),O=n.useRef(null),[z,q]=n.useState([]),B=n.useCallback(e=>{q(e.map(e=>Object.assign(e,{preview:URL.createObjectURL(e)})))},[]),K=n.useCallback(e=>{q(t=>t.toSpliced(e,1))},[]);n.useEffect(()=>{null==v||v(z)},[z]),n.useEffect(()=>()=>{z.forEach(e=>URL.revokeObjectURL(e.preview))},[z]);let{getRootProps:H,getInputProps:W,isDragActive:G,isDragReject:Y}=(0,n4.VB)({onDrop:B,multiple:P,minSize:N,maxSize:k,maxFiles:S,preventDropOnDocument:C,noClick:_,noDrag:A,validator:M,accept:w,onError:R,onDropRejected:I});return(0,r.jsxs)(F,{...L,children:[(0,r.jsxs)("button",{ref:O,className:b(n6.root(),a),"data-drag-active":G,"data-drag-reject":Y,...H(),tabIndex:0,children:[(0,r.jsx)("input",{ref:t,id:L.id,name:L.name??"files",value:"",onFocusCapture:()=>{var e;return null==(e=O.current)?void 0:e.focus()},"aria-hidden":"true",...W(),...$,className:b("block",V),style:{display:"block"}}),(0,r.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,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}),(0,r.jsx)("span",{children:j??"Click or drag file to this area to upload"})]}
17),k&&(0,r.jsxs)("div",{className:b(n6.maxSizeText(),g),children:["≤"," ",ne(k)]}),!y&&(0,r.jsx)("div",{className:b(n6.list(),l),children:null==z?void 0:z.map((e,t)=>{let s;return s=["image/jpeg","image/png","image/jpg","image/webm"].includes(e.type)?(0,r.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:b(n6.fileIcon(),f),children:[(0,r.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,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("circle",{cx:"10",cy:"13",r:"2"}),(0,r.jsx)("path",{d:"m20 17-1.09-1.09a2 2 0 0 0-2.82 0L10 22"})]}):e.type.includes("video")?(0,r.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:b(n6.fileIcon(),f),children:[(0,r.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,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("path",{d:"m10 11 5 3-5 3v-6Z"})]}):e.type.includes("audio")?(0,r.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:b(n6.fileIcon(),f),children:[(0,r.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,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("path",{d:"M10 20v-1a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0Z"}),(0,r.jsx)("path",{d:"M6 20v-1a2 2 0 1 0-4 0v1a2 2 0 1 0 4 0Z"}),(0,r.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,r.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:b(n6.fileIcon(),f),children:[(0,r.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,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("line",{x1:"16",x2:"8",y1:"13",y2:"13"}),(0,r.jsx)("line",{x1:"16",x2:"8",y1:"17",y2:"17"}),(0,r.jsx)("line",{x1:"10",x2:"8",y1:"9",y2:"9"})]}):e.type.includes("compressed")||e.type.includes("zip")||e.type.includes("archive")?(0,r.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:b(n6.fileIcon(),f),children:[(0,r.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,r.jsx)("circle",{cx:"16",cy:"19",r:"2"}),(0,r.jsx)("path",{d:"M16 11v-1"}),(0,r.jsx)("path",{d:"M16 17v-2"})]}):(0,r.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:b(n6.fileIcon(),f),children:[(0,r.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,r.jsx)("polyline",{points:"14 2 14 8 20 8"})]}),(0,r.jsxs)("div",{className:b(n6.listItem(),i),children:[(0,r.jsxs)("div",{className:b(n6.listItemDetailsContainer(),o),children:[s,(0,r.jsx)("p",{className:b(n6.listItemTitle(),u),children:e.name}),(0,r.jsx)("p",{className:b(n6.listItemSize(),c),children:ne(e.size)})]}),(0,r.jsx)(E,{size:"xs",intent:"gray-basic",icon:(0,r.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,r.jsx)("path",{d:"M3 6h18"}),(0,r.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,r.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),(0,r.jsx)("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),(0,r.jsx)("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]}),className:b(n6.listItemRemoveButton(),d),onClick:()=>K(t)})]},e.name)})}),y&&!!z.length&&(0,r.jsx)("div",{className:b(n6.imagePreviewGrid(),m),
17children:null==z?void 0:z.map((e,t)=>(0,r.jsxs)("div",{className:b(n6.imagePreviewContainer(),p),children:[(0,r.jsx)("div",{className:b(n6.imagePreview(),x),style:{backgroundImage:e?`url(${e.preview})`:void 0},children:(0,r.jsx)(T,{intent:"alert",size:"xs",className:b(n6.imagePreviewRemoveButton(),h),onClick:()=>K(t)})}),(0,r.jsxs)("div",{className:b(n6.listItemDetailsContainer(),o),children:[(0,r.jsx)("p",{className:b(n6.listItemTitle(),u),children:e.name}),(0,r.jsx)("p",{className:b(n6.listItemSize(),c),children:ne(e.size)})]})]},e.name))})]})});n9.displayName="SimpleDropzone";let n8={root:(0,h.F)(["UI-Textarea__root","w-full p-2"],{variants:{size:{sm:"h-20",md:"h-32",lg:"h-64"}},defaultVariants:{size:"md"}})},n7=n.forwardRef((e,t)=>{let[s,a]=U(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,onValueChange:p,onChange:h,...x},{inputContainerProps:g,leftAddonProps:f,leftIconProps:v,rightAddonProps:y,rightIconProps:j}]=W({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),w=n.useCallback(e=>{null==p||p(e.target.value),null==h||h(e)},[p,h]);return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...g,children:[(0,r.jsx)(H,{...f}),(0,r.jsx)(K,{...v}),(0,r.jsx)("textarea",{id:a.id,name:a.name,className:b("form-textarea",z.root({size:l,intent:i,hasError:!!a.error,
17isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),n8.root({size:l}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,onChange:w,...x,ref:t}),(0,r.jsx)(H,{...y}),(0,r.jsx)(K,{...j})]})})});n7.displayName="Textarea";let le=n.forwardRef((e,t)=>{let{children:s,loading:a,disabled:n,role:l="save",disableOnSuccess:i="create"===l,disableIfInvalid:o=!1,showLoadingOverlayOnSuccess:d=!1,showLoadingOverlayOnCreate:c=!0,loadingOverlay:u,...m}=e,{formState:p}=(0,nw.xW)(),h=!!i&&p.isSubmitSuccessful,x=!!o&&!p.isValid;return(0,r.jsxs)(r.Fragment,{children:[d&&u&&(0,r.jsx)(A,{hide:!p.isSubmitSuccessful}),"create"===l&&u&&(0,r.jsx)(A,{hide:!p.isSubmitSuccessful}),(0,r.jsx)(w,{type:"submit",loading:p.isSubmitting||a,disabled:x||n||h,ref:t,...m,children:s})]})});function lt(e){return(0,n.forwardRef)((t,s)=>{let{control:a,formState:l,...i}=(0,nw.xW)(),{shape:o}=n.useContext(nD);return(0,n.useMemo)(()=>{var e,s;return!!(0,nw.Jt)(o,t.name)&&!(null==(e=(0,nw.Jt)(o,t.name))?void 0:e.isOptional())&&!(null==(s=(0,nw.Jt)(o,t.name))?void 0:s.isNullable())},[o]),(0,r.jsx)(nw.xI,{name:t.name,control:a,rules:{required:t.required},render:a=>{var i;let{field:{ref:o,...d}}=a;return(0,r.jsx)(e,{value:d.value,onChange:lf(t.onChange,d.onChange),onBlur:lf(t.onBlur,d.onBlur),...t,error:null==(i=lg(d.name,l))?void 0:i.message,ref:function(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,n.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,o)})}})})}let ls=n.memo(lt((0,n.forwardRef)((e,t)=>(0,r.jsx)(G,{...e,value:e.value??"",ref:t})))),la=n.memo(lt((0,n.forwardRef)((e,t)=>(0,r.jsx)(Z,{...e,value:e.value??"",ref:t})))),lr=n.memo(lt((0,n.forwardRef)((e,t)=>(0,r.jsx)(n7,{...e,value:e.value??"",ref:t})))),ln=n.memo(lt((0,n.forwardRef)((e,t)=>{let s=(0,nw.xW)(),a=(0,nw.as)({name:e.name});return n.useEffect(()=>{if(!(0,nw.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,r.jsx)(nZ,{...e,ref:t})}))),ll=n.memo(lt((0,n.forwardRef)((e,t)=>{let s=(0,nw.xW)(),a=(0,nw.as)({name:e.name}),l=n.useRef("#000"),[i,o]=n.useState((0,nw.Jt)(s.formState.defaultValues,e.name)||"#000"),d=r5(i,200),c=n.useRef(i);n.useEffect(()=>{a.field.onChange(d),(0,nL.Mj)(d).isValid()&&(l.current=d)},[d]);let u=n.useCallback(()=>{(0,nL.Mj)(i).isValid()?o(i):o(l.current),c.current=i},[l.current,i]);return(0,nU.A)(()=>{a.field.value!==c.current&&(o(a.field.value),c.current=a.field.value)},[a.field.value]),(0,r.jsx)(G,{...e,ref:t,value:i,onValueChange:o,onBlur:u,rightAddon:(0,r.jsx)(L,{className:"flex justify-center",trigger:(0,r.jsx)("div",{className:"cursor-pointer size-7 rounded-[--radius-md]",style:{backgroundColor:i}}),children:(0,r.jsx)(nO.jI,{color:i,onChange:e=>{o(e)}})}),className:"w-full"})}))),li=n.memo(lt((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(r0,{...a,onValueChange:s,ref:t})}))),lo=n.memo(lt((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(n1,{...a,onValueChange:s,ref:t})}))),ld=n.memo(lt((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(nJ,{...a,onValueChange:s,ref:t})}))),lc=n.memo(lt((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(rZ,{...a,onValueChange:s,ref:t})}))),lu=n.memo(lt((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(nB,{...a,onValueChange:s,ref:t})}))),lm=n.memo(lt((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(nH,{...a,onValueChange:s,ref:t})}))),lp=n.memo(lt((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(n5,{...a,onValueChange:s,ref:t})}))),lh=n.memo(lt((0,n.forwardRef)((e,t)=>{let{onChange:s,itemContainerClass:a,itemClass:n,radioGroupStackClass:l,...i}=e;return(0,r.jsx)(n5,{itemContainerClass:b("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:b("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",n),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",...i,onValueChange:s,stackClass:b("flex flex-col md:flex-row gap-2 space-y-0",l),ref:t})}))),lx={Text:ls,Password:la,Textarea:lr,Select:li,NativeSelect:ln,Switch:lc,Checkbox:lu,CheckboxGroup:lm,RadioGroup:lp,Number:lo,Combobox:ld,Autocomplete:n.memo(lt((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(nz,{...a,onValueChange:s,ref:t})}))),SimpleDropzone:n.memo(lt((0,n.forwardRef)((e,t)=>{let{onChange:s,value:a,...l}=e,i=(0,nw.as)({name:l.name});return n.useEffect(()=>{i.field.onChange([])},[]),(0,r.jsx)(n9,{...l,onValueChange:s,ref:t})}))),ColorPicker:ll,RadioCards:lh,Submit:le};lx.displayName="Field";let lg=(e,t)=>(0,nw.Jt)(t.errors,e);function lf(){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 lb(e){let{children:t}=e;return(0,r.jsx)("div",{className:"pb-4",children:t})}function lv(e){let{title:t,description:s,children:a,className:n}=e;return(0,r.jsxs)(X,{className:b("group/settings-card relative lg:bg-gray-950/5 dark:lg:bg-gray-950/40 rounded-xl transition-colors",n),children:[t&&(0,r.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,r.jsx)("span",{className:b("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,r.jsx)("span",{className:"px-4 py-2 lg:py-0 w-fit text-sm text-[--muted]",children:s})]}),(0,r.jsx)("div",{className:b(!t&&"pt-4","p-4 space-y-4"),children:a})]})}function ly(e){let{title:t,description:s,icon:a,size:n="lg"}=e,l="lg"===n;return(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.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,r.jsx)(a,{className:b("text-brand-600 dark:text-brand-400",l?"text-2xl":"text-xl")})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:b("font-semibold",l?"text-xl":"text-lg"),children:t}),(0,r.jsx)("p",{className:b("text-[--muted]",l?"text-base":"text-sm"),children:s})]})]})}nj.Yj().min(2).trim(),nj.Yj().min(1),nj.YO(nj.Yj()),nj.YO(nj.Yj()),nj.Ik({label:nj.Yj(),value:nj.Yj().nullable()}),nj.Ik({label:nj.Yj(),value:nj.Yj({error:"Invalid address"})}),nj.Ik({hour:nj.ai().min(0).max(23),minute:nj.ai().min(0).max(59)}),nj.Yj().min(10,"Invalid phone number"),nj.YO(nj.Ie()).refine(e=>e.every(e=>e instanceof File),{message:"Expected a file"}),nj.YO(nj.Ie()).min(0).refine(e=>e.every(e=>e instanceof File),{message:"Expected a file"}),nj.Ik({from:nj.p6(),to:nj.p6()}),nj.p6(),(0,h.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,h.F)(["UI-DangerZone__icon","place-self-center sm:place-self-start text-[--red] w-4 mt-2"]),(0,h.F)(["UI-DangerZone__title","text-lg text-[--red] font-semibold"]),(0,h.F)(["UI-DangerZone__dialogTitle","text-lg font-medium leading-6"]),(0,h.F)(["UI-DangerZone__dialogBody","mt-2 text-base text-[--muted]"]),(0,h.F)(["UI-DangerZone__dialogAction","mt-2 flex gap-2 justify-end"]);var lj=s(43356);let lw={root:(0,h.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,h.F)(["UI-Alert__detailsContainer","flex w-full items-start"]),textContainer:(0,h.F)(["UI-Alert__textContainer","flex flex-col self-start ml-3 gap-0.5"]),title:(0,h.F)(["UI-Alert__title","font-semibold text-gray-900 dark:text-[--foreground] mb-0.5"]),description:(0,h.F)(["UI-Alert__description","text-xs md:text-sm text-[--muted] dark:text-gray-200"]),icon:(0,h.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,h.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"])},lN=n.forwardRef((e,t)=>{let{children:s,className:a,title:n,description:l,isClosable:i,onClose:o,intent:d="info-basic",iconClass:c,detailsContainerClass:u,textContainerClass:m,titleClass:p,descriptionClass:h,closeButtonClass:x,icon:g,...f}=e,v=null;return"info-basic"===d||"info"===d?v=(0,r.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,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M12 16v-4"}),(0,r.jsx)("path",{d:"M12 8h.01"})]}):"alert-basic"===d||"alert"===d?v=(0,r.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,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),(0,r.jsx)("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}):"warning-basic"===d||"warning"===d?v=(0,r.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,r.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,r.jsx)("line",{x1:"12",x2:"12",y1:"9",y2:"13"}),(0,r.jsx)("line",{x1:"12",x2:"12.01",y1:"17",y2:"17"})]}):("success-basic"===d||"success"===d)&&(v=(0,r.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,r.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,r.jsx)("path",{d:"m9 12 2 2 4-4"})]})),(0,r.jsxs)("div",{className:b(lw.root({intent:d}),a),...f,ref:t,children:[(0,r.jsxs)("div",{className:b(lw.detailsContainer(),!n&&"items-center",u),children:[g||(0,r.jsx)("div",{className:b(lw.icon({intent:d}),c),children:v&&v}),(0,r.jsxs)("div",{className:b(lw.textContainer(),!n&&"self-center",m),children:[!!n&&(0,r.jsx)("span",{className:b(lw.title(),p),children:n}),!!(l||s)&&(0,r.jsx)("div",{className:b(lw.description(),h),children:l||s})]})]}),o&&(0,r.jsx)("button",{className:b(lw.closeButton(),x),onClick:o,children:(0,r.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,r.jsx)("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]})})]})});function lk(e){let{isPending:t}=e,{isDirty:s}=(0,nw.lN)();return(0,r.jsx)(lx.Submit,{role:"save",size:"md",className:b("text-md group",s&&"animate-pulse"),intent:"primary",rounded:!0,loading:t,leftIcon:(0,r.jsx)(lj.Bc_,{}),children:"Save"})}function lS(e){let{isPending:t,className:s}=e,{isDirty:a,isSubmitting:n,isValidating:l}=(0,nw.lN)(),{reset:i}=(0,nw.xW)();return a?(0,r.jsx)(lN,{intent:"info",detailsContainerClass:"items-center",className:b("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,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"flex-1 text-sm lg:flex-none",children:"You have unsaved changes."}),(0,r.jsx)(w,{size:"sm",intent:"gray-link",onClick:()=>i(),leftIcon:(0,r.jsx)(lj.cO3,{}),children:"Reset"}),(0,r.jsx)(lx.Submit,{role:"save",size:"sm",intent:"primary-link",disabled:n||l,loading:t,leftIcon:(0,r.jsx)(lj.Bc_,{}),children:"Save"})]})}):null}function lC(e,t){let s=/(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\([^\)]+\))/g,a=e.split(s),n=e.match(s)||[],l=0;return a.map((e,s)=>{if(s===a.length-1&&""===e)return null;if(s%2==0)return e;{let e=n[l++];if(!e)return null;if(e.startsWith("**")&&e.endsWith("**"))return(0,r.jsx)("strong",{className:"font-semibold",children:e.slice(2,-2)},s);{if(e.startsWith("*")&&e.endsWith("*")&&!e.startsWith("**"))return(0,r.jsx)("em",{className:"italic",children:e.slice(1,-1)},s);if(e.startsWith("`")&&e.endsWith("`"))return(0,r.jsx)("code",{onClick:async s=>{t&&s.stopPropagation(),await r9(e.slice(1,-1),{onSuccess:()=>x.oR.success("Copied to clipboard"),onError:()=>x.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,n]=a;return(0,r.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",onClick:e=>t&&e.stopPropagation(),children:e},s)}}return e}})}lN.displayName="Alert";let l_=e=>{let t,{children:s,className:a,stopPropagation:l=!1}=e;if(!s)return null;t=s.includes("\\n")?s.split("\\n"):s.split("\n");let i=[],o=0;for(;o<t.length;){let e=t[o],s=e.trim(),a=s.match(/^(#{1,3})\s+(.+)$/),d=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
17-2 mb-0.5"],r=1===e?"h1":2===e?"h2":"h3";i.push(n.createElement(r,{key:`h-${o}`,className:s[e-1]},lC(t,l))),o++}else if(d){let e=[];for(;o<t.length&&t[o].trim().startsWith("* ")&&!t[o].trim().startsWith("**");)e.push(t[o]),o++;i.push((0,r.jsx)("ul",{className:"list-none space-y-1 mt-2 mb-1",children:e.map((e,t)=>(0,r.jsxs)("li",{className:"flex items-start gap-2",children:[(0,r.jsx)("span",{className:"text-gray-400",children:"•"}),(0,r.jsx)("span",{children:lC(e.slice(2),l)})]},t))},`bullets-${o}`))}else o>0&&i.push((0,r.jsx)("br",{},`br-${o}`)),i.push(lC(e,l)),o++}return(0,r.jsx)("span",{className:a,children:i})},lA="\0CLEAR\0",lR=e=>e?(0,r.jsx)(l_,{children:e}):void 0;function lT(e){let{value:t,disabled:s,onValueChange:a}=e,l="number"==typeof t?t:Number(t??0)||0,[i,o]=n.useState(()=>lU(l)),[d,c]=n.useState(!1);return n.useEffect(()=>{lF(i)!==l&&(o(lU(l)),c(!1))},[l]),(0,r.jsx)(G,{value:i,disabled:s,placeholder:'e.g. "500GB"',error:d?"Invalid size":void 0,onValueChange:e=>{o(e);let t=lF(e);c(null==t),null!=t&&a(t)}})}function lI(e){let{name:t,label:s,help:a,disabled:l,valueKind:i="string",width:o="equal",min:d=0}=e,{control:c}=(0,nw.xW)(),{field:u}=(0,nw.as)({name:t,control:c}),m=n.useCallback(()=>{let e=u.value;return e&&"object"==typeof e&&!Array.isArray(e)?Object.entries(e):[]},[u.value]),[p,h]=n.useState(m);n.useEffect(()=>{let e=m(),t={};for(let[e,s]of p)e&&(t[e]=s);let s=Object.fromEntries(e);JSON.stringify(t)!==JSON.stringify(s)&&h(e)},[u.value]);let x=e=>{h(e);let t={};for(let[s,a]of e)s&&(t[s]=a);u.onChange(t)},g=(e,t,s)=>{x(p.map((a,r)=>r===e?[t,s]:a))},f="wide-key"===o?"basis-2/3 grow shrink-0":"wide-value"===o?"basis-1/3 grow shrink-0":"basis-1/2 grow shrink-0",b="wide-value"===o?"basis-2/3 grow shrink-0":"wide-key"===o?"basis-1/3 grow shrink-0":"basis-1/2 grow shrink-0";return(0,r.jsx)(F,{label:s,help:lR(a),children:(0,r.jsxs)("div",{className:"space-y-2",children:[0===p.length&&(0,r.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No entries."}),p.map((e,t)=>{let[s,a]=e;return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{placeholder:"key",value:s,disabled:l,onValueChange:e=>g(t,e,a),className:f}),(0,r.jsx)("span",{className:"text-[--muted]",children:"="}),(0,r.jsx)("div",{className:b,children:"boolean"===i?(0,r.jsx)(rZ,{value:!!a,disabled:l,onValueChange:e=>g(t,s,e)}):"size"===i?(0,r.jsx)(lT,{value:a,disabled:l,onValueChange:e=>g(t,s,e)}):"number"===i?(0,r.jsx)(n1,{value:"number"==typeof a?a:Number(a)||0,disabled:l,onValueChange:e=>g(t,s,e),min:d}):(0,r.jsx)(G,{placeholder:"value",value:null==a?"":String(a),disabled:l,onValueChange:e=>{let a=e;"numberOrBool"===i&&("true"===e?a=!0:"false"===e?a=!1:/^\d+$/.test(e)&&(a=Number(e))),g(t,s,a)}})}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),disabled:l,onClick:()=>x(p.filter((e,s)=>s!==t)),"aria-label":"Remove entry"})]},t)}),(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",rounded:!0,icon:(0,r.jsx)(t2.Ca6,{}),disabled:l,onClick:()=>x([...p,["","boolean"!==i&&("number"===i||"size"===i?0:"")]]),"aria-label":"Add entry"})]})})}function lE(e){let{name:t,label:s,help:a,disabled:l}=e,{control:i}=(0,nw.xW)(),{field:o}=(0,nw.as)({name:t,control:i}),d=n.useCallback(()=>Array.isArray(o.value)?[...o.value]:[],[o.value]),[c,u]=n.useState(d);n.useEffect(()=>{let e=d();JSON.stringify(c)!==JSON.stringify(e)&&u(e)},[o.value]);let m=e=>{u(e),o.onChange(e)};return(0,r.jsx)(F,{label:s,help:lR(a),children:(0,r.jsxs)("div",{className:"space-y-2",children:[0===c.length&&(0,r.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No entries."}),c.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{value:e,disabled:l,onValueChange:e=>m(c.map((s,a)=>a===t?e:s)),className:"flex-1"}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),disabled:l,onClick:()=>m(c.filter((e,s)=>s!==t)),"aria-label":"Remove"})]},t)),(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",rounded:!0,icon:(0,r.jsx)(t2.Ca6,{}),disabled:l,onClick:()=>m([...c,""]),"aria-label":"Add"})]})})}function lM(e){let{name:t,label:s,help:a,disabled:l}=e,{control:i}=(0,nw.xW)(),{field:o}=(0,nw.as)({name:t,control:i}),d=o.value,c=Array.isArray(d),u="boolean"==typeof d,[m,p]=n.useState(c);return n.useEffect(()=>{c&&p(!0)},[c]),(0,r.jsx)(F,{label:s,help:lR(a),children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(rZ,{value:!!c||!!d,disabled:l,onValueChange:e=>{m?o.onChange(!!e&&(c?d:[])):o.onChange(e)}}),(0,r.jsx)("button",{type:"button",disabled:l,className:"text-xs text-[--muted] underline-offset-2 hover:underline",onClick:()=>{let e=!m;p(e),e&&!c&&o.onChange([]),!e&&c&&o.onChange(d.length>0)},children:m?"Use simple toggle":"Use allow-list"})]}),m&&(0,r.jsx)(lE,{name:t,label:"",help:void 0,disabled:l||!Array.isArray(o.value)}),!m&&u&&(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:d?"Enabled for everything.":"Disabled."})]})})}function lP(e){return!Number.isFinite(e)||e<0?"":0===e?"0s":no(1e3*Math.round(e))}function lD(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=ni(t);return null==s?null:Math.round(s/1e3)}function l$(e){let{name:t,label:s,help:a,disabled:l}=e,{control:i}=(0,nw.xW)(),{field:o}=(0,nw.as)({name:t,control:i}),d="number"==typeof o.value?o.value:Number(o.value??0)||0,[c,u]=n.useState(()=>lP(d)),[m,p]=n.useState(null);return n.useEffect(()=>{lD(c)!==d&&(u(lP(d)),p(null))},[d]),(0,r.jsx)(F,{label:s,help:lR(a),error:m??void 0,children:(0,r.jsx)(G,{value:c,disabled:l,placeholder:'e.g. "30m", "1h", "1d"',onValueChange:e=>{u(e);let t=lD(e);null==t?p("Invalid duration. Use e.g. 30s, 5m, 1h, 1d, 2w."):(p(null),o.onChange(t))}})})}function lL(e){let{name:t,label:s,help:a,disabled:n,secretSet:l}=e,{control:i}=(0,nw.xW)(),{field:o}=(0,nw.as)({name:t,control:i}),d=o.value===lA,c=d?`${a?a+" \xb7 ":""}Will be cleared on save.`:a;return(0,r.jsxs)(F,{label:s,help:lR(c),children:[l&&(0,r.jsx)("div",{className:"flex justify-end mb-1",children:(0,r.jsx)(w,{size:"sm",intent:d?"gray-subtle":"alert-subtle",leftIcon:(0,r.jsx)(t2.id1,{}),onClick:()=>o.onChange(d?"":lA),disabled:n,children:d?"Cancel clear":"Clear value"})}),(0,r.jsx)(n7,{value:d||null==o.value?"":String(o.value),disabled:n||d,placeholder:d?"(will be cleared on save)":l?"(value set — type to replace)":void 0,rows:6,className:"font-mono text-xs",onValueChange:e=>o.onChange(e)}
17)]})}let lO=[["TB",1e12],["GB",1e9],["MB",1e6],["KB",1e3],["B",1]];function lU(e){if(!Number.isFinite(e)||e<0)return"";if(0===e)return"0B";for(let[t,s]of lO)if(e>=s){let a=e/s;return`${Number.isInteger(a)?a:a.toFixed(1)}${t}`}return`${e}B`}function lF(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 lz(e){let{name:t,label:s,help:a,disabled:l}=e,{control:i}=(0,nw.xW)(),{field:o}=(0,nw.as)({name:t,control:i}),d="number"==typeof o.value?o.value:Number(o.value??0)||0,[c,u]=n.useState(()=>lU(d)),[m,p]=n.useState(null);return n.useEffect(()=>{lF(c)!==d&&(u(lU(d)),p(null))},[d]),(0,r.jsx)(F,{label:s,help:lR(a),error:m??void 0,children:(0,r.jsx)(G,{value:c,disabled:l,placeholder:'e.g. "20MB", "1GB", "500KB"',onValueChange:e=>{u(e);let t=lF(e);null==t?p("Invalid size. Use e.g. 500KB, 20MB, 1GB."):(p(null),o.onChange(t))}})})}function lV(e){let{name:t,label:s,help:a,disabled:l}=e,{control:i}=(0,nw.xW)(),{field:o}=(0,nw.as)({name:t,control:i}),[d,c]=n.useState(()=>JSON.stringify(o.value??null,null,2)),[u,m]=n.useState(null);return n.useEffect(()=>{c(JSON.stringify(o.value??null,null,2)),m(null)},[o.value]),(0,r.jsx)(F,{label:s,help:lR(a),error:u??void 0,children:(0,r.jsx)(n7,{value:d,disabled:l,rows:4,className:"font-mono text-xs",onValueChange:e=>{c(e);try{o.onChange(JSON.parse(e)),m(null)}catch{m("Invalid JSON")}}})})}let lq=e=>e.replace(/\./g,"--");function lB(e){let{name:t,label:s,help:a,secretSet:n,disabled:l}=e,{setValue:i,watch:o}=(0,nw.xW)(),d=o(t),c=d===lA;return(0,r.jsx)(F,{label:s,help:lR(c?`${a?a+" \xb7 ":""}Will be cleared on save.`:a),children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(Z,{autoComplete:"new-password",value:c?"":d??"",placeholder:c?"(will be cleared)":n?"•••••••• (unchanged)":"",disabled:l||c,onValueChange:e=>i(t,e,{shouldDirty:!0})})}),n&&!l&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:c?"alert-subtle":"gray-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":c?"Cancel clear":"Clear secret value",onClick:()=>i(t,c?"":lA,{shouldDirty:!0})}),children:c?"Cancel — keep current value":"Clear saved value"})]})})}function lK(e){let{env:t}=e;return(0,r.jsxs)(tO,{trigger:(0,r.jsx)(t2.E2M,{className:"inline text-[--muted]"}),children:["Set by environment variable: ",(0,r.jsx)("code",{children:t})]})}function lH(e){let{k:t}=e,s=(0,r.jsx)(lW,{k:t});return void 0===t.deprecated?s:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(lN,{intent:"warning-basic",title:"Deprecated",description:lR(t.deprecated)}),s]})}function lW(e){let{k:t}=e,s=lq(t.key),a="environment"===t.source,n=(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[t.label,a&&t.env&&(0,r.jsx)(lK,{env:t.env})]}),l=t.description||void 0;if(t.secret){let e=t.secretSet?`${l?l+" \xb7 ":""}A value is set. Type to replace it, or clear it.`:l;return t.ui.multiline?(0,r.jsx)(lL,{name:s,label:t.label,help:e,disabled:a,secretSet:t.secretSet}):(0,r.jsx)(lB,{name:s,label:n,help:e,secretSet:t.secretSet,disabled:a})}switch(t.ui.kind){case"boolean":return(0,r.jsx)(lx.Switch,{name:s,label:n,help:lR(l),side:"right",disabled:a});case"number":return(0,r.jsx)(lx.Number,{name:s,label:n,help:lR(l),disabled:a,min:t.ui.min,max:t.ui.max,step:t.ui.step});case"enum":return(0,r.jsx)(lx.Select,{name:s,label:n,help:lR(l),disabled:a,options:(t.ui.options??[]).map(e=>({label:e,value:e}))});case"list":return(0,r.jsx)(lE,{name:s,label:t.label,help:l,disabled:a});case"map":return(0,r.jsx)(lI,{name:s,label:t.label,help:l,disabled:a,valueKind:t.ui.mapValueKind??"string",width:t.ui.mapWidth??"equal",min:t.ui.min});case"duration":return(0,r.jsx)(l$,{name:s,label:t.label,help:l,disabled:a});case"size":return(0,r.jsx)(lz,{name:s,label:t.label,help:l,disabled:a});case"boolOrList":return(0,r.jsx)(lM,{name:s,label:t.label,help:l,disabled:a});case"json":return(0,r.jsx)(lV,{name:s,label:t.label,help:l,disabled:a});default:if(t.ui.multiline)return(0,r.jsx)(lL,{name:s,label:t.label,help:l,disabled:a});return(0,r.jsx)(lx.Text,{name:s,label:n,help:lR(l),disabled:a})}}var lG=s(51400);let lY={subTrigger:(0,h.F)(["UI-DropdownMenu__subTrigger","focus:bg-[--subtle] data-[state=open]:bg-[--subtle]"]),subContent:(0,h.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,h.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,h.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,h.F)(["UI-DropdownMenu__group"]),label:(0,h.F)(["UI-DropdownMenu__label","px-2 py-1.5 text-sm font-semibold text-[--muted]"]),separator:(0,h.F)(["UI-DropdownMenu__separator","-mx-1 my-2 h-px bg-[--border]"]),shortcut:(0,h.F)(["UI-DropdownMenu__shortcut","ml-auto text-xs tracking-widest opacity-60"])},lJ=n.createContext({}),lZ=n.forwardRef((e,t)=>{let{children:s,trigger:a,defaultOpen:n,open:l,onOpenChange:i,dir:o,allowOutsideInteraction:d,sideOffset:c=4,className:u,subContentClass:m,subTriggerClass:p,shortcutClass:h,itemClass:x,labelClass:g,separatorClass:f,groupClass:v,...y}=e;return(0,r.jsx)(lJ.Provider,{value:{subContentClass:m,subTriggerClass:p,shortcutClass:h,itemClass:x,labelClass:g,separatorClass:f,groupClass:v},children:(0,r.jsxs)(lG.bL,{defaultOpen:n,open:l,onOpenChange:i,dir:o,modal:!d,...y,children:[(0,r.jsx)(lG.l9,{asChild:!0,children:a}),(0,r.jsx)(lG.ZL,{children:(0,r.jsx)(lG.UC,{ref:t,sideOffset:c,className:b(lY.root(),u),...y,children:s})})]})})});lZ.displayName="DropdownMenu",n.forwardRef((e,t)=>{let{className:s,...a}=e,{groupClass:l}=n.useContext(lJ);return(0,r.jsx)(lG.YJ,{ref:t,className:b(lY.group(),l,s),...a})}).displayName="DropdownMenuGroup",n.forwardRef((e,t)=>{let{children:s,triggerContent:a,triggerProps:l,triggerInset:i,defaultOpen:o,open:d,onOpenChange:c,sideOffset:u=8,className:m,subTriggerClass:p,...h}=e,{subTriggerClass:x,subContentClass:g}=n.useContext(lJ);return(0,r.jsxs)(lG.Pb,{...h,children:[(0,r.jsxs)(lG.ZP,{className:b(lY.item(),lY.subTrigger(),i&&"pl-8",x,p,m),...l,children:[a,(0,r.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:b(lY.shortcut(),"w-4 h-4 ml-auto"),children:(0,r.jsx)("path",{d:"m9 18 6-6-6-6"})})]}),(0,r.jsx)(lG.ZL,{children:(0,r.jsx)(lG.G5,{ref:t,sideOffset:u,className:b(lY.subContent(),g,m),...h,children:s})})]})}).displayName="DropdownMenuSub";let lQ=n.forwardRef((e,t)=>{let{className:s,inset:a,...l}=e,{itemClass:i}=n.useContext(lJ);return(0,r.jsx)(lG.q7,{ref:t,className:b(lY.item(),a&&"pl-8",i,s),...l})});lQ.displayName="DropdownMenuItem";let lX=n.forwardRef((e,t)=>{let{className:s,inset:a,...l}=e,{labelClass:i}=n.useContext(lJ);return(0,r.jsx)(lG.JU,{ref:t,className:b(lY.label(),a&&"pl-8",i,s),...l})});lX.displayName="DropdownMenuLabel";let l0=n.forwardRef((e,t)=>{let{className:s,...a}=e,{separatorClass:l}=n.useContext(lJ);return(0,r.jsx)(lG.wv,{ref:t,className:b(lY.separator(),l,s),...a})});function l1(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 l2(e){return e.secret?e.secretSet:JSON.stringify(e.value)!==JSON.stringify(e.default)}function l3(e){return{key:e.key,label:e.label,source:e.source,requiresRestart:e.requiresRestart,preview:{from:l1(e.value,e.secret),to:l1(e.default,e.secret)}}}function l5(e){let{open:t,onOpenChange:s,scope:a,scopeLabel:l,keys:i,managed:d,invalidate:c}=e,{mutateAsync:u,isPending:m}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[rI],t=(0,o.jE)();return(0,e2.n)({mutationFn:e=>el("POST /dashboard/settings/reset",{body:{keys:e}}),onSuccess:()=>
17e.forEach(e=>t.invalidateQueries({queryKey:e}))})}(c),p=n.useMemo(()=>[...i.filter(e=>"database"===e.source&&l2(e)).map(l3),...(d??[]).filter(e=>"database"===e.source&&!e.isDefault).map(e=>({key:e.key,label:e.label,source:e.source,requiresRestart:e.requiresRestart}))],[i,d]),h=n.useMemo(()=>i.filter(e=>"environment"===e.source).length+(d??[]).filter(e=>"environment"===e.source).length,[i,d]),g=n.useMemo(()=>i.filter(e=>"database"===e.source&&!l2(e)).length+(d??[]).filter(e=>"database"===e.source&&e.isDefault).length,[i,d]),[f,b]=n.useState(new Set);n.useEffect(()=>{t&&b(new Set(p.map(e=>e.key)))},[t,p]);let v=n.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(rR).join(" › ");s.push({subsection:a,rows:r})}return s})(p),[p]),y=f.size===p.length&&p.length>0,j=f.size>0&&!y,N=e=>{b(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},k=async()=>{if(0!==f.size)try{let e=await u([...f]);x.oR.success(`Reset ${e.reset.length} setting${1===e.reset.length?"":"s"}.`);let t=e.skipped.filter(e=>"already-default"!==e.reason);t.length&&x.oR.warning(`${t.length} could not be reset (env-locked or unknown).`),e.requiresRestart&&x.oR.warning("Some changes require a restart to take effect.",{duration:8e3}),s(!1)}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to reset settings")}};return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"all"===a?"Reset all settings":`Reset settings in ${l}`,description:0===p.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),disabled:m,children:"Cancel"}),(0,r.jsx)(w,{intent:"alert-subtle",onClick:k,loading:m,disabled:m||0===f.size,children:0===f.size?"Nothing selected":`Reset ${f.size} ${1===f.size?"key":"keys"}`})]}),children:p.length>0&&(0,r.jsxs)("div",{className:"space-y-3",children:[(h>0||g>0)&&(0,r.jsx)(lN,{intent:"info",description:(0,r.jsxs)(r.Fragment,{children:[h>0&&(0,r.jsxs)(r.Fragment,{children:[h," key",1===h?"":"s"," in this scope ",1===h?"is":"are"," pinned by environment variables and won't change."," "]}),g>0&&(0,r.jsxs)(r.Fragment,{children:[g," already"," ",1===g?"holds":"hold"," the default value, so ",1===g?"it is":"they are"," ","not listed."]})]}),isClosable:!1}),(0,r.jsx)("div",{className:"flex items-center justify-between border-b border-[--border] pb-2",children:(0,r.jsx)(nB,{label:y?`All ${p.length} selected`:j?`${f.size} of ${p.length} selected`:"Select all",value:!!y||!!j&&"indeterminate",onValueChange:()=>{b(e=>e.size===p.length?new Set:new Set(p.map(e=>e.key)))}})}),(0,r.jsx)("div",{className:"max-h-[50vh] overflow-y-auto space-y-4 pr-1",children:v.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-1.5",children:e.subsection}),(0,r.jsx)("ul",{className:"space-y-1",children:e.rows.map(e=>{let t=f.has(e.key);return(0,r.jsxs)("li",{className:"flex items-start gap-3 py-1.5 px-2 rounded-md hover:bg-[--subtle] transition-colors",children:[(0,r.jsx)("div",{className:"pt-0.5",children:(0,r.jsx)(nB,{value:t,onValueChange:()=>N(e.key)})}),(0,r.jsxs)("button",{type:"button",className:"flex-1 text-left min-w-0",onClick:()=>N(e.key),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 min-w-0",children:[(0,r.jsx)("span",{className:"font-medium break-words",children:e.label}),(0,r.jsx)("code",{className:"text-xs text-[--muted] break-all min-w-0",children:e.key})]}),(0,r.jsx)("div",{className:"text-xs text-[--muted] break-all mt-0.5 min-w-0",children:e.preview?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"font-mono",children:e.preview.from}),(0,r.jsx)("span",{className:"mx-1.5",children:"→"}),(0,r.jsx)("span",{className:"font-mono",children:e.preview.to})]}):(0,r.jsx)("span",{className:"italic",children:"edited below; resetting restores the built-in defaults"})})]}),e.requiresRestart&&(0,r.jsx)(tO,{trigger:(0,r.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 l4(e){let t,{open:s,onOpenChange:a,envKeys:l}=e,{mutateAsync:i,isPending:d}=(t=(0,o.jE)(),(0,e2.n)({mutationFn:()=>el("POST /dashboard/settings/import/env"),onSuccess:()=>
17t.invalidateQueries({queryKey:rI})})),c=n.useMemo(()=>{let e=new Map;for(let t of l){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)})},[l]),u=async()=>{try{let e=await i();x.oR.success(`Imported ${e.imported.length} setting${1===e.imported.length?"":"s"} into the database.`),e.skippedAsDefault.length&&x.oR.info(`Skipped ${e.skippedAsDefault.length} that already match the default.`),e.failed.length&&x.oR.warning(`${e.failed.length} could not be imported. Check logs.`),e.imported.length&&x.oR.warning("Remove the corresponding env vars and restart for these to take effect.",{duration:1e4}),a(!1)}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to import env settings")}};return(0,r.jsx)(tJ,{open:s,onOpenChange:a,title:"Import environment variables into the database",description:0===l.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"gray-basic",onClick:()=>a(!1),disabled:d,children:"Cancel"}),(0,r.jsxs)(w,{intent:"primary-subtle",onClick:u,loading:d,disabled:d||0===l.length,children:["Import ",l.length," ",1===l.length?"key":"keys"]})]}),children:l.length>0&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(lN,{intent:"info",description:(0,r.jsxs)(r.Fragment,{children:["Environment variables always override database values. After importing, you must remove the matching env vars from your deployment ",(0,r.jsx)("em",{children:"and restart"})," for the persisted values to take effect - otherwise the env still overrides."]}),isClosable:!1}),(0,r.jsx)("div",{className:"max-h-[50vh] overflow-y-auto space-y-4 pr-1",children:c.map(e=>{let[t,s]=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-1.5",children:rR(t)}),(0,r.jsx)("ul",{className:"space-y-1",children:s.map(e=>(0,r.jsx)("li",{className:"flex items-start justify-between gap-3 py-1.5 px-2 rounded-md hover:bg-[--subtle] transition-colors",children:(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 min-w-0",children:[(0,r.jsx)("span",{className:"font-medium break-words",children:e.label}),e.env&&(0,r.jsx)("code",{className:"text-xs text-[--muted] break-all min-w-0",children:e.env})]}),(0,r.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)})})]})})}l0.displayName="DropdownMenuSeparator",n.forwardRef((e,t)=>{let{className:s,...a}=e,{shortcutClass:l}=n.useContext(lJ);return(0,r.jsx)("span",{ref:t,className:b(lY.shortcut(),l,s),...a})}).displayName="DropdownMenuShortcut";let l6={initial:{opacity:0,x:12},animate:{opacity:1,x:0},exit:{opacity:0,x:-12},transition:{duration:.18,ease:"easeOut"}};function l9(e){let{open:t,onOpenChange:s,restrict:a,invalidate:l}=e,{mutateAsync:i,isPending:d}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[rI],t=(0,o.jE)();return(0,e2.n)({mutationFn:e=>el("POST /dashboard/settings/import/json",{body:{settings:e}}),onSuccess:()=>e.forEach(e=>t.invalidateQueries({queryKey:e}))})}(l),[c,u]=n.useState("pick"),[m,p]=n.useState(null),[h,g]=n.useState(null);n.useEffect(()=>{t||(u("pick"),p(null),g(null))},[t]);let f=async e=>{let t=e[0];if(t){g(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);p(s),u("review")}catch(e){g((null==e?void 0:e.message)??"Failed to parse JSON file.")}}},b=n.useMemo(()=>
17{if(!m)return[];let e=new Map;for(let[t,s]of Object.entries(m.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)})},[m]),v=async()=>{if(m)try{let e=await i(m.settings);x.oR.success(`Imported ${e.imported.length} setting${1===e.imported.length?"":"s"}.`),e.skipped.length&&x.oR.info(`Skipped ${e.skipped.length} (unknown or env-locked keys).`),e.failed.length&&x.oR.warning(`${e.failed.length} failed validation. Check logs for details.`),e.requiresRestart&&x.oR.warning("Some changes require a restart to take effect.",{duration:8e3}),s(!1)}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to import settings")}},y=m?Object.keys(m.settings).length:0;return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"Import settings from JSON",description:"pick"===c?"Choose a settings export file to preview and import.":`Reviewing ${(null==m?void 0:m.fileName)??""}`,contentClass:"max-w-2xl",footer:"pick"===c?(0,r.jsx)(w,{intent:"gray-basic",onClick:()=>s(!1),disabled:d,children:"Cancel"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"gray-basic",leftIcon:(0,r.jsx)(t2.OLK,{}),onClick:()=>{p(null),u("pick")},disabled:d,children:"Back"}),(0,r.jsxs)(w,{intent:"primary-subtle",onClick:v,loading:d,disabled:d||0===y,children:["Import ",y," ",1===y?"key":"keys"]})]}),children:(0,r.jsxs)(tq.N,{mode:"wait",initial:!1,children:["pick"===c&&(0,r.jsxs)(tB.P.div,{...l6,className:"space-y-3",children:[(0,r.jsx)(n9,{accept:{"application/json":[".json"]},multiple:!1,maxFiles:1,onValueChange:f,dropzoneText:"Click or drag a settings JSON file here"}),h&&(0,r.jsx)(lN,{intent:"alert",description:h,isClosable:!1}),(0,r.jsx)(lN,{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"===c&&m&&(0,r.jsxs)(tB.P.div,{...l6,className:"space-y-3",children:[m.exportedAt&&(0,r.jsx)(lN,{intent:"info",description:(0,r.jsxs)("span",{children:["Exported"," ",(0,r.jsx)("span",{className:"font-medium",children:new Date(m.exportedAt).toLocaleString()}),void 0!==m.version&&` \xb7 v${m.version}`," \xb7"," ",m.totalEntries," total entr",1===m.totalEntries?"y":"ies"," in source."]}),isClosable:!1}),m.outOfScope.length>0&&(0,r.jsx)(lN,{intent:"info",title:`${m.outOfScope.length} entr${1===m.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}),m.maskedSecrets.length>0&&(0,r.jsx)(lN,{intent:"warning",title:`${m.maskedSecrets.length} masked secret${1===m.maskedSecrets.length?"":"s"} skipped`,description:(0,r.jsxs)("span",{children:["You'll need to enter these manually after the import:"," ",(0,r.jsxs)("span",{className:"font-mono text-xs",children:[m.maskedSecrets.slice(0,5).join(", "),m.maskedSecrets.length>5&&` and ${m.maskedSecrets.length-5} more`]})]}),isClosable:!1}),0===y?(0,r.jsx)(lN,{intent:"alert",description:"Nothing to import - the file contains no values that can be applied (everything was either a masked secret or empty).",isClosable:!1}):(0,r.jsx)("div",{className:"max-h-[40vh] overflow-y-auto space-y-4 pr-1",children:b.map(e=>{let[t,s]=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-1.5",children:rR(t)}),(0,r.jsx)("ul",{className:"space-y-1",children:s.map(e=>{let[t,s]=e;return(0,r.jsx)("li",{className:"flex items-start gap-3 py-1.5 px-2 rounded-md hover:bg-[--subtle] transition-colors",children:(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("code",{className:"text-xs text-[--muted] break-all block",children:t}),(0,r.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 l8=e=>"database"===e.source&&(e.secret?e.secretSet:JSON.stringify(e.value)!==JSON.stringify(e.default)),l7=e=>"database"===e.source&&!e.isDefault;function ie(e){let{allKeys:t,allManagedKeys:s,sectionKeys:a,sectionManagedKeys:l,sectionLabel:i,invalidate:o,scope:d}=e,[c,u]=n.useState(null),[m,p]=n.useState(!1),[h,g]=n.useState(!1),[f,b]=n.useState(!1),v=n.useMemo(()=>a.filter(l8).length+(l??[]).filter(l7).length,[a,l]),y=n.useMemo(()=>(t??[]).filter(l8).length+(s??[]).filter(l7).length,[t,s]),j=n.useMemo(()=>(t??[]).filter(e=>"environment"===e.source).length,[t]),w=async()=>
17{if(!d)return void window.open("/api/v1/dashboard/settings/export?download=1","_blank");b(!0);try{let e=await r$(),t={};for(let[s,a]of Object.entries(e.settings))d.includes(s)&&(t[s]=a);let s={...e,settings:t,maskedSecretKeys:e.maskedSecretKeys.filter(e=>d.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=`${d.fileStem}-${n}.json`,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(r)}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to export settings")}finally{b(!1)}},N=d?d.noun:"database";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(lZ,{align:"end",trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.voe,{}),"aria-label":"Settings actions"}),children:[(0,r.jsx)(lX,{children:"Reset"}),(0,r.jsxs)(lQ,{onSelect:()=>u("section"),disabled:0===v,children:[(0,r.jsx)(t2.zOm,{}),"Reset settings in this section…",(0,r.jsx)("span",{className:"ml-auto text-xs text-[--muted]",children:v})]}),t&&(0,r.jsxs)(lQ,{onSelect:()=>u("all"),disabled:0===y,children:[(0,r.jsx)(t2.zOm,{}),"Reset all settings…",(0,r.jsx)("span",{className:"ml-auto text-xs text-[--muted]",children:y})]}),!d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l0,{}),(0,r.jsx)(lX,{children:"Environment"}),(0,r.jsxs)(lQ,{onSelect:()=>p(!0),disabled:0===j,children:[(0,r.jsx)(t2.bh6,{}),"Import environment variables…",(0,r.jsx)("span",{className:"ml-auto text-xs text-[--muted]",children:j})]})]}),(0,r.jsx)(l0,{}),(0,r.jsx)(lX,{children:"Backup"}),(0,r.jsxs)(lQ,{onSelect:()=>g(!0),children:[(0,r.jsx)(t2.Ah9,{}),"Import ",N," settings…"]}),(0,r.jsxs)(lQ,{onSelect:w,disabled:f,children:[(0,r.jsx)(t2.tAF,{}),"Export ",N," settings"]})]}),(0,r.jsx)(l5,{open:null!==c,onOpenChange:e=>!e&&u(null),scope:c??"section",scopeLabel:"all"===c?"all settings":i,keys:"all"===c&&t?t:a,managed:"all"===c?s:l,invalidate:o}),!d&&(0,r.jsx)(l4,{open:m,onOpenChange:p,envKeys:(t??[]).filter(e=>"environment"===e.source)}),(0,r.jsx)(l9,{open:h,onOpenChange:g,restrict:null==d?void 0:d.includes,invalidate:o})]})}let it=n.createContext(null);function is(e){let{panelsRef:t,children:s}=e,a=n.useMemo(()=>({register:(e,s)=>void t.current.set(e,s),unregister:e=>void t.current.delete(e)}),[t]);return(0,r.jsx)(it.Provider,{value:a,children:s})}function ia(e,t){let s=lq(e),a=n.useContext(it),{resetField:r}=(0,nw.xW)(),{field:l}=(0,nw.as)({name:s});n.useEffect(()=>{if(a)return a.register(s,t),()=>a.unregister(s)});let i=n.useCallback(e=>r(s,{defaultValue:e}),[s,r]);return{name:s,value:l.value,setValue:l.onChange,seed:i}}async function ir(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 il(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 ii(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 io(e){let{intent:t,children:s}=e;return(0,r.jsx)("span",{className:b("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 id=[{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 ic(e){return{id:e.id,enabled:e.enabled,action:e.action}}function iu(e){var t,s,a;let r=(0,nw.xW)(),n=rE(),l=null==r||null==(t=r.watch)?void 0:t.call(r,lq(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 im(e){let{title:t,note:s,command:a}=e,n=async()=>{try{await navigator.clipboard.writeText(a),x.oR.success("Copied")}catch{x.oR.error("Could not copy to the clipboard")}};return(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:t}),(0,r.jsx)(E,{size:"sm",intent:"white-subtle",icon:(0,r.jsx)(t2.Xpf,{}),onClick:n})]}),s&&(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:s}),(0,r.jsx)("pre",{className:"text-xs bg-[--subtle] rounded-[--radius] p-3 overflow-x-auto whitespace-pre",children:a})]})}function ip(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)"`,n=`rclone mount aiostreams: ${t} \\
22  --links \\
23  --read-only \\
24  --dir-cache-time 20s \\
25  --vfs-cache-mode off \\
26  --allow-other`;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(im,{title:"1. Create the rclone remote",note:"Use an AIOSTREAMS_AUTH user that holds the webdav permission.",command:a}),(0,r.jsx)(im,{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:n}),(0,r.jsx)(im,{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 ih(e){let{host:t,port:s,mountDir:a}=e,n=`sudo mkdir -p ${a}
27sudo mount -t nfs4 -o ro,port=${s} ${t}:/ ${a}`;return(0,r.jsx)(im,{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:n})}function ix(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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(im,{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,r.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 ig={off:"Off",unavailable:"Unavailable",mounting:"Mounting",mounted:"Mounted",unmounted:"Not mounted",error:"Failed"},ib={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]"},iv=e=>e.trim().replace(/\/+$/,"");function iy(e){let{label:t,value:s}=e;return(0,r.jsxs)("div",{className:"flex items-baseline justify-between gap-4 text-sm",children:[(0,r.jsx)("span",{className:"text-[--muted]",children:t}),(0,r.jsx)("span",{className:"font-mono text-right break-all",children:s})]})}var ij=s(11482);function iw(e){let t=[];
42return e.releaseKey&&t.push(e.releaseKey),/^[0-9a-f]{40}$/.test(e.nzbHash)&&t.push(`nh1:${e.nzbHash}`),t}let iN=["dashboard","usenet"],ik=[...iN,"settings"],iS=[...iN,"live"],iC=null,i_=0;function iA(){let e=(0,o.jE)();return(0,e2.n)({mutationFn:e=>el("POST /dashboard/usenet/stats/reset",{body:{confirm:!0,...e}}),onSuccess:(t,s)=>{s.dryRun||e.invalidateQueries({queryKey:[...iN,"stats"]})}})}function iR(){return(0,e2.n)({mutationFn:e=>{let t=e.download?"download":"play",s=e.fileSel?`/${encodeURIComponent(e.fileSel)}`:"";return el(`/dashboard/usenet/library/${encodeURIComponent(e.hash)}/${t}${s}`)}})}let iT=["prefetchSegments","maxConcurrentDownloads","segmentDiskCacheBytes"],iI={"arr.instances":function(){let e,t=(0,ta.I)({queryKey:rP,queryFn:()=>el("/dashboard/arr/instances"),staleTime:1e4}),s=(e=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el("PUT /dashboard/arr/instances",{body:{instances:e}}),onSuccess:()=>e.invalidateQueries({queryKey:rI})})),a=(0,e2.n)({mutationFn:e=>el("POST /dashboard/arr/instances/test",{body:e})}),[l,i]=n.useState({}),{name:d,value:c,setValue:u,seed:m}=ia("arr.instances",{save:async e=>{let t=await s.mutateAsync(e.map(ii)),a=t.instances.length;return{message:`${a} Sonarr/Radarr instance${1===a?"":"s"}`,value:t.instances.map(il)}}});if(n.useEffect(()=>{void 0===c&&t.data&&m(t.data.instances.map(il))},[t.data,c,m]),t.isLoading||void 0===c)return(0,r.jsx)(X,{className:"p-6 flex justify-center",children:(0,r.jsx)(C,{className:"w-6 h-6"})});if(t.isError)return(0,r.jsx)(X,{className:"p-6 text-sm text-red-400",children:"Failed to load Sonarr/Radarr instances."});let p=(e,t)=>u(c.map(s=>s.id===e?{...s,...t}:s)),h=async e=>{i(t=>({...t,[e.id]:"pending"}));try{let t=await a.mutateAsync(ii(e));i(s=>({...s,[e.id]:t})),t.ok?x.oR.success(`${t.appName??"Connected"} ${t.version??""}`):x.oR.error(t.error??"Connection failed")}catch(s){let t={ok:!1,error:(null==s?void 0:s.message)??"Connection failed"};i(s=>({...s,[e.id]:t})),x.oR.error(t.error)}};return(0,r.jsxs)(X,{className:"p-4 space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-semibold",children:"Sonarr / Radarr instances"}),(0,r.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,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(t2.Ca6,{}),onClick:()=>{var e,t;return u([...c,{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===c.length&&(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No instances configured."}),c.map((e,t)=>{let s=l[e.id];return(0,r.jsxs)(X,{className:"p-4 space-y-3 bg-[--subtle]/30",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(rZ,{value:e.enabled,onValueChange:t=>p(e.id,{enabled:t}),label:"Enabled"}),s&&"pending"!==s&&(0,r.jsxs)(io,{intent:s.ok?"success":"alert",children:[s.ok?(0,r.jsx)(t2.qGT,{}):(0,r.jsx)(t2.wew,{}),s.ok?`${s.appName??"OK"} ${s.version??""}`.trim():"Failed"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(w,{size:"sm",intent:"white-subtle",leftIcon:(0,r.jsx)(t2.UWw,{}),loading:"pending"===s,onClick:()=>h(e),children:"Test"}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),onClick:()=>u(c.filter(t=>t.id!==e.id))})]})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,r.jsx)(F,{label:"Name",children:(0,r.jsx)(G,{value:e.name,placeholder:"Sonarr",onValueChange:t=>p(e.id,{name:t})})}),(0,r.jsx)(F,{label:"Application",children:(0,r.jsx)(r0,{value:e.type,options:[{value:"sonarr",label:"Sonarr"},{value:"radarr",label:"Radarr"}],onValueChange:t=>p(e.id,{type:t})})}),(0,r.jsx)(F,{label:"URL",help:"As AIOStreams reaches it, e.g. http://sonarr:8989",children:(0,r.jsx)(G,{value:e.url,placeholder:"http://sonarr:8989",onValueChange:t=>p(e.id,{url:t})})}),(0,r.jsx)(F,{label:"API key",help:e.hasApiKey?"Stored. Leave blank to keep it.":void 0,children:(0,r.jsx)(Z,{value:e.apiKey,placeholder:e.hasApiKey?"••••••••":"",onValueChange:t=>p(e.id,{apiKey:t})})}),(0,r.jsx)("div",{className:"sm:col-span-2",children:(0,r.jsx)(lE,{name:`${d}.${t}.categories`,label:"Categories",help:"Download-client categories this instance owns. Leave empty for any."})})]})]},e.id)})]})},"arr.queueCleanup.rules":function(){var e;let t,s=(0,ta.I)({queryKey:rD,queryFn:()=>el("/dashboard/arr/queue-rules"),staleTime:1e4}),a=(t=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el("PUT /dashboard/arr/queue-rules",{body:{rules:e}}),onSuccess:()=>
42t.invalidateQueries({queryKey:rI})})),l=null==(e=s.data)?void 0:e.rules,{value:i,setValue:d,seed:c}=ia("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(ic)}}});if(n.useEffect(()=>{void 0===i&&l&&c(l.map(ic))},[l,i,c]),s.isLoading||void 0===i)return(0,r.jsx)(X,{className:"p-6 flex justify-center",children:(0,r.jsx)(C,{className:"w-6 h-6"})});if(s.isError||!l)return(0,r.jsx)(X,{className:"p-6 text-sm text-red-400",children:"Failed to load the queue cleanup rules."});let u=(e,t)=>d(i.map(s=>s.id===e?{...s,...t}:s));return(0,r.jsxs)(X,{className:"p-4 space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-semibold",children:"Queue cleanup rules"}),(0,r.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,r.jsx)("div",{className:"space-y-2",children:i.map(e=>{var t;let s=l.find(t=>t.id===e.id);return s?(0,r.jsxs)("div",{className:b("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,r.jsxs)("div",{className:"flex items-start gap-3 min-w-0",children:[(0,r.jsx)(rZ,{value:e.enabled,onValueChange:t=>u(e.id,{enabled:t})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:s.label}),(0,r.jsxs)("p",{className:"text-xs text-[--muted] truncate",children:["“",s.phrase,"”"]}),s.note&&(0,r.jsx)("p",{className:"text-xs text-[--muted] mt-0.5",children:s.note})]})]}),(0,r.jsx)("div",{className:"sm:w-48 shrink-0",children:(0,r.jsx)(r0,{value:e.action,disabled:!e.enabled,options:id.map(e=>({value:e.value,label:e.label})),onValueChange:t=>u(e.id,{action:t}),help:null==(t=id.find(t=>t.value===e.action))?void 0:t.help})})]},e.id):null})})]})},"shares.fuse":function(){var e;let t,s="true"===iu("shares.fuse.enabled"),a=(e={enabled:s},(0,ta.I)({queryKey:rM,queryFn:()=>el("/dashboard/shares/fuse/status"),refetchInterval:5e3,enabled:(null==e?void 0:e.enabled)??!0})),n=(t=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el(`POST /dashboard/shares/fuse/${e}`),onSuccess:e=>t.setQueryData(rM,e)})),l=iu("shares.fuse.mountPath"),i=iu("arr.mountDir");if(!s)return null;let d=a.data,c=(null==d?void 0:d.mountPath)||l||"/mnt/aiostreams",u=(null==d?void 0:d.state)??"off",m=n.isPending||"mounting"===u,p=async e=>{try{let t=await n.mutateAsync(e);"mounted"===t.state?x.oR.success(`Mounted at ${t.mountPath}`):"unmounted"===t.state?x.oR.success("Unmounted"):t.error?x.oR.error(t.error):t.reason&&x.oR.warning(t.reason)}catch(e){x.oR.error(e.message)}};return(0,r.jsxs)(X,{className:"p-4 space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-semibold",children:"Mount status"}),(0,r.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,r.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,r.jsx)("span",{className:b("rounded-full px-2.5 py-0.5 text-xs font-medium",ib[u]),children:ig[u]}),(0,r.jsx)(E,{size:"sm",intent:"white-subtle",icon:(0,r.jsx)(t2.Zxy,{}),loading:a.isFetching,onClick:()=>a.refetch()})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(iy,{label:"Mount path",value:c}),(null==d?void 0:d.since)&&"mounted"===u&&(0,r.jsx)(iy,{label:"Since",value:new Date(d.since).toLocaleString()}),(null==d?void 0:d.stats)&&"mounted"===u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(iy,{label:"Open files",value:d.stats.openFiles}),(0,r.jsx)(iy,{label:"In-flight reads",value:d.stats.pendingRequests}),(0,r.jsx)(iy,{label:"Cached inodes",value:d.stats.inodes}),(0,r.jsx)(iy,{label:"Requests",value:`${d.stats.requests} (${d.stats.errors} failed)`})]})]}),"unavailable"===u&&(null==d?void 0:d.reason)&&(0,r.jsx)(lN,{intent:"warning",title:"This host cannot mou
42nt",description:d.reason}),"error"===u&&(null==d?void 0:d.error)&&(0,r.jsx)(lN,{intent:"alert",title:"Mount failed",description:d.error}),a.error&&(0,r.jsx)(lN,{intent:"alert",title:"Could not read the mount status",description:a.error.message}),i.trim()?iv(i)!==iv(c)?(0,r.jsx)(lN,{intent:"info",title:"Mount directory differs from the FUSE mount path",description:`Sonarr / Radarr are told ${iv(i)} while AIOStreams mounts at ${iv(c)}. That is right only if the arr container binds the mount at a different path; otherwise make them the same.`}):null:(0,r.jsx)(lN,{intent:"warning",title:"Sonarr / Radarr mount directory is empty",description:`Set it to ${c} (the path the arr sees the mount at) so the symlinks it imports resolve. Grabs work without it; imports do not.`}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"primary",loading:m&&"mount"===n.variables,disabled:m||"mounted"===u,onClick:()=>p("mount"),children:"error"===u||"unavailable"===u?"Retry mount":"Mount"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",loading:m&&"unmount"===n.variables,disabled:m||"mounted"!==u,onClick:()=>p("unmount"),children:"Unmount"})]})]})},"shares.connect":function(){let e="true"===iu("shares.fuse.enabled"),t=iu("arr.mountDir")||"/mnt/aiostreams",s=iu("shares.fuse.mountPath")||"/mnt/aiostreams",a="false"!==iu("shares.webdav.enabled"),n="true"===iu("shares.nfs.enabled"),l=iu("shares.nfs.port")||"2049",i=(iu("bootstrap.baseUrl")||("u">typeof window?window.location.origin:"")).replace(/\/$/,""),o=`${i}/webdav`,d="AIOSTREAMS_HOST";try{d=new URL(i).hostname||d}catch{}return(0,r.jsxs)(X,{className:"p-4 space-y-5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-semibold",children:"Connect"}),(0,r.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,r.jsx)(ix,{mountPath:s}):(0,r.jsxs)(r.Fragment,{children:[a&&(0,r.jsx)(ip,{mountDir:t,davUrl:o}),n&&(0,r.jsx)(ih,{host:d,port:l,mountDir:t}),!a&&!n&&(0,r.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,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"Without mounting anything"}),(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["A player that speaks WebDAV (Infuse, VLC, a file manager) can open"," ",(0,r.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."]})]})]})}},iE={usenet:function(){var e;let{setValue:t,getValues:s}=(0,nw.xW)(),a=null==(e=(0,ta.I)({queryKey:ik,queryFn:()=>el("/dashboard/usenet/settings"),staleTime:1e4,enabled:(void 0)??!0}).data)?void 0:e.profiles,r=lq("usenet.performanceProfile"),l=iT.map(e=>lq(`usenet.${e}`)),i=(0,nw.FH)({name:r}),o=(0,nw.FH)({name:l[0]}),d=(0,nw.FH)({name:l[1]}),c=(0,nw.FH)({name:l[2]}),u=n.useRef(!1);return n.useEffect(()=>{let e=a&&i&&"custom"!==i?a[i]:void 0;if(!e||iT.every((t,a)=>Number(s(l[a]))===e[t]))return;u.current=!0,iT.forEach((s,a)=>t(l[a],e[s],{shouldDirty:!0}));let r=setTimeout(()=>{u.current=!1},0);return()=>clearTimeout(r)},[i,a]),n.useEffect(()=>{if(u.current)return;let e=a&&i&&"custom"!==i?a[i]:void 0;if(!e)return;let s=[o,d,c];iT.every((t,a)=>Number(s[a])===e[t])||t(r,"custom",{shouldDirty:!0})},[o,d,c]),null}},iM=e=>e?Array.isArray(e)?e:[e]:[];function iP(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 iD(e){let t=(0,nw.FH)({name:e.map(lq)}),s=new Map(e.map((e,s)=>[e,t[s]]));return e=>s.get(e)}function i$(e){let{when:t,children:s}=e,a=iD(t.map(e=>e.key));return iP(t,a)?(0,r.jsx)(r.Fragment,{children:s}):null}function iL(e){let{when:t,children:s}=e,a=iM(t);return 0===a.length?(0,r.jsx)(r.Fragment,{children:s}):(0,r.jsx)(i$,{when:a,children:s})}function iO(e){let{own:t,fields:s,children:a}=e,n=iD([...new Set([...t,...s.flat()].map(e=>e.key))]);return iP(t,n)&&s.some(e=>iP(e,n))?(0,r.jsx)(r.Fragment,{children:a}):null}function iU(e){let{when:t,fields:s,children:a}=e,n=iM(t),l=s.map(iM);return 0===n.length&&l.some(e=>0===e.length)?(0,r.jsx)(r.Fragment,{children:a}):(0,r.jsx)(iO,{own:n,fields:l,children:a})}function iF(e){let t,{tab:s,allKeys:a,managed:l}=e,{mutateAsync:i,isPending:d}=(t=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el("PATCH /dashboard/settings",{body:e}),onSuccess:()=>
42t.invalidateQueries({queryKey:rI})})),c=n.useRef(new Map),u=n.useMemo(()=>{let e=new Set((s.cards??[]).flatMap(e=>"editor"in e?[e.editor]:[]));return((s.editors??[]).filter(t=>!e.has(t))??[]).map(e=>iI[e]).filter(e=>!!e)},[s.cards,s.editors]),m=n.useRef(null),p=n.useMemo(()=>[...s.groups.values()].flat(),[s]),{schema:h,defaults:g,byName:f}=n.useMemo(()=>{let e={},t={},a=new Map;for(let s of p){let r=lq(s.key);e[r]=nj.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=lq(a);e[s]=nj.bz(),t[s]=void 0}return{schema:nj.Ik(e),defaults:t,byName:a}},[p,s.editors]);return(0,r.jsx)(n$,{schema:h,defaultValues:g,stackClass:"space-y-4 relative",onSubmit:async e=>{var t,s,a,r,n;let l={};for(let[t,s]of Object.entries(e)){let e=f.get(t);if(!e||"environment"===e.source)continue;if(e.secret){s===lA?l[e.key]=null:""!==s&&null!=s&&(l[e.key]=s);continue}let a=(null===e.value||null===e.default)&&""===s?null:s;JSON.stringify(a)!==JSON.stringify(e.value)&&(l[e.key]=a)}let o=null==(t=m.current)?void 0:t.formState.defaultValues,d=(n=c.current,[...n].filter(t=>{let[s]=t;return void 0!==e[s]&&JSON.stringify(e[s])!==JSON.stringify(null==o?void 0:o[s])}));if(0===Object.keys(l).length&&0===d.length){x.oR.info("No changes to save."),null==(s=m.current)||s.reset(e,{keepValues:!0,keepIsValid:!0});return}try{let t=[],s={updated:[],requiresRestart:!1};for(let[a]of(Object.keys(l).length>0&&(s=await i(l),t.push(`${s.updated.length} setting${1===s.updated.length?"":"s"}`)),t.push(...await ir(d,e)),d))null==(r=m.current)||r.setValue(a,e[a],{shouldDirty:!1});x.oR.success(`Saved ${t.join(" and ")}.`),null==(a=m.current)||a.reset(e,{keepValues:!0,keepIsValid:!0}),s.requiresRestart&&x.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))x.oR.error(`${t}: ${s}`);else x.oR.error((null==t?void 0:t.message)??"Failed to save settings")}},children:e=>{m.current=e;let t=iE[s.section],n=[...s.groups.keys()],i=!s.curated&&n.includes("")?["",...n.filter(e=>""!==e)]:n,o=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"}]:[]]:i.map(e=>{var t;return{title:e,when:null==(t=s.cardVisibility)?void 0:t[e]}});return(0,r.jsxs)(is,{panelsRef:c,children:[t&&(0,r.jsx)(t,{}),(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsx)(ly,{title:s.label,description:`${s.label} configuration`,icon:s.icon}),(0,r.jsx)("div",{className:"pt-1",children:(0,r.jsx)(ie,{allKeys:a,allManagedKeys:l,sectionKeys:p,sectionManagedKeys:l.filter(e=>{var t;return null==(t=s.editors)?void 0:t.includes(e.key)}),sectionLabel:s.label})})]}),o.map(e=>{if("editor"in e){let t=iI[e.editor];return t?(0,r.jsx)(iL,{when:e.when,children:(0,r.jsx)(t,{})},`editor:${e.editor}`):null}let t=s.groups.get(e.title);return(null==t?void 0:t.length)?(0,r.jsx)(iU,{when:e.when,fields:t.map(e=>{var t;return null==(t=s.fieldVisibility)?void 0:t[e.key]}),children:(0,r.jsxs)(lv,{title:s.curated?e.title:e.title?e.title.split(".").map(rR).join(" › "):void 0,children:[s.curated&&e.note&&(0,r.jsx)("p",{className:"text-sm text-[--muted] -mt-1",children:(0,r.jsx)(l_,{children:e.note})}),t.map(e=>{var t;return(0,r.jsx)(iL,{when:null==(t=s.fieldVisibility)?void 0:t[e.key],children:(0,r.jsx)("div",{id:`setting-${e.key}`,children:(0,r.jsx)(lH,{k:e})})},e.key)})]})},e.title||"_root"):null}),u.map((e,t)=>(0,r.jsx)(e,{},t)),(0,r.jsx)("div",{className:"flex justify-end pt-2",children:(0,r.jsx)(lk,{isPending:d})}),(0,r.jsx)(lS,{isPending:d})]})}})}function iz(e){let{className:t}=e;return(0,r.jsx)("div",{className:b("p-8 flex items-center justify-center w-full",t),children:(0,r.jsx)(C,{className:"w-6 h-6"})})}function iV(e){let{title:t="Failed to load",message:s,onRetry:a,retrying:n=!1,className:l}=e;return(0,r.jsxs)(X,{className:b("p-6 flex flex-col items-center text-center gap-3",l),children:[(0,r.jsx)(t2.wew,{className:"w-8 h-8 text-red-400"}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"font-medium",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-[--muted] break-words max-w-md",children:s})]}),a&&(0,r.jsx)(w,{size:"sm",intent:"warning-subtle",leftIcon:(0,r.jsx)(t2.Zxy,{}),loading:n,onClick:a,children:"Retry"})]})}function iq(e){let{query:t,skeleton:s,errorTitle:a,children:n}=e;return t.isPending?(0,r.jsx)(r.Fragment,{children:s??(0,r.jsx)(iz,{})}):t.isError?(0,r.jsx)(iV,{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,r.jsx)(r.Fragment,{children:n(t.data)})}var iB=s(58396),iK=s(89507),iH=s(95321),iW=s(35634),iG=s(93825),iY=s(60502),iJ=s(92666),iZ=s(4097),iQ=s(65814),iX=s(21519),i0=s(88810),i1=s(77341),i2=s(43773),i3=s(77444),i5=s(2980);let i4=["var(--brand)","#22c55e","#f59e0b","#06b6d4","#a855f7","#ef4444","#ec4899","#14b8a6"],i6={stroke:"var(--muted)",fontSize:11,tickLine:!1,axisLine:!1},i9={...i6,interval:"preserveStartEnd",minTickGap:24};function i8(e){var t,s;let{active:a,payload:n,label:l,valueFormatter:i,tooltipLabelKey:o}=e;if(!a||!(null==n?void 0:n.length))return null;let d=(o?null==(s=n[0])||null==(t=s.payload)?void 0:t[o]:void 0)??l;return(0,r.jsxs)("div",{className:"rounded-lg border border-[--border] bg-[--paper] px-3 py-2 text-xs shadow-xl",children:[void 0!==d&&(0,r.jsx)("div",{className:"mb-1 font-medium text-[--foreground]",children:d}),n.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 tabular-nums",children:[(0,r.jsx)("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:e.color||e.fill}}),(0,r.jsx)("span",{className:"text-[--muted]",children:e.name}),(0,r.jsx)("span",{className:"ml-auto font-medium text-[--foreground]",children:i?i(e.value):e.value})]},t))]})}function i7(e,t){return e.color??i4[t%i4.length]}function oe(e){let{data:t,xKey:s,series:a,height:n=260,className:l,valueFormatter:i,yTickFormatter:o,tooltipLabelKey:d,hideLegend:c,hideGrid:u}=e;return(0,r.jsx)("div",{className:b("w-full",l),children:(0,r.jsx)(iB.u,{width:"100%",height:n,children:(0,r.jsxs)(iK.b,{data:t,margin:{top:8,right:8,bottom:0,left:0},children:[!u&&(0,r.jsx)(iH.d,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),(0,r.jsx)(iW.W,{dataKey:s,...i9}),(0,r.jsx)(iG.h,{...i6,width:o?60:40,tickFormatter:o}),(0,r.jsx)(iY.m,{content:(0,r.jsx)(i8,{valueFormatter:i,tooltipLabelKey:d}),cursor:{stroke:"var(--border)"}}),!c&&a.length>1&&(0,r.jsx)(iJ.s,{wrapperStyle:{fontSize:12}}),a.map((e,t)=>(0,r.jsx)(iZ.N1,{type:"monotone",dataKey:e.key,name:e.label??e.key,stroke:i7(e,t),strokeWidth:2,dot:!1,activeDot:{r:4}},e.key))]})})})}function ot(e){let{data:t,xKey:s,series:a,height:n=260,className:l,stacked:i,valueFormatter:o,yTickFormatter:d,tooltipLabelKey:c,hideLegend:u,hideGrid:m}=e;return(0,r.jsx)("div",{className:b("w-full",l),children:(0,r.jsx)(iB.u,{width:"100%",height:n,children:(0,r.jsxs)(iQ.Q,{data:t,margin:{top:8,right:8,bottom:0,left:0},children:[(0,r.jsx)("defs",{children:a.map((e,t)=>(0,r.jsxs)("linearGradient",{id:`grad-${e.key}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,r.jsx)("stop",{offset:"5%",stopColor:i7(e,t),stopOpacity:.35}),(0,r.jsx)("stop",{offset:"95%",stopColor:i7(e,t),stopOpacity:0})]},e.key))}),!m&&(0,r.jsx)(iH.d,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),(0,r.jsx)(iW.W,{dataKey:s,...i9}),(0,r.jsx)(iG.h,{...i6,width:d?60:40,tickFormatter:d}),(0,r.jsx)(iY.m,{content:(0,r.jsx)(i8,{valueFormatter:o,tooltipLabelKey:c}),cursor:{stroke:"var(--border)"}}),!u&&a.length>1&&(0,r.jsx)(iJ.s,{wrapperStyle:{fontSize:12}}),a.map((e,t)=>(0,r.jsx)(iX.Gk,{type:"monotone",dataKey:e.key,name:e.label??e.key,stackId:i?"stack":void 0,stroke:i7(e,t),strokeWidth:2,fill:`url(#grad-${e.key})`},e.key))]})})})}function os(e){let{data:t,xKey:s,series:a,height:n=260,className:l,stacked:i,valueFormatter:o,hideLegend:d,hideGrid:c}=e;return(0,r.jsx)("div",{className:b("w-full",l),children:(0,r.jsx)(iB.u,{width:"100%",height:n,children:(0,r.jsxs)(i0.E,{data:t,margin:{top:8,right:8,bottom:0,left:0},children:[!c&&(0,r.jsx)(iH.d,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),(0,r.jsx)(iW.W,{dataKey:s,...i6}),(0,r.jsx)(iG.h,{...i6,width:40}),(0,r.jsx)(iY.m,{content:(0,r.jsx)(i8,{valueFormatter:o}),cursor:{fill:"var(--subtle)"}}),!d&&a.length>1&&(0,r.jsx)(iJ.s,{wrapperStyle:{fontSize:12}}),a.map((e,t)=>(0,r.jsx)(i1.yP,{dataKey:e.key,name:e.label??e.key,stackId:i?"stack":void 0,fill:i7(e,t),radius:i?0:[4,4,0,0]},e.key))]})})})}function oa(e){let{data:t,height:s=200,className:a,centerLabel:n,centerValue:l,valueFormatter:i}=e;return(0,r.jsxs)("div",{className:b("relative w-full",a),children:[(0,r.jsx)(iB.u,{width:"100%",height:s,children:(0,r.jsxs)(i2.r,{children:[(0,r.jsx)(i3.Fq,{data:t,dataKey:"value",nameKey:"name",innerRadius:"62%",outerRadius:"90%",paddingAngle:2,stroke:"none",children:t.map((e,t)=>(0,r.jsx)(i5.f,{fill:e.color??i4[t%i4.length]},t))}),(0,r.jsx)(iY.m,{content:(0,r.jsx)(i8,{valueFormatter:i})})]})}),(l||n)&&(0,r.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center",children:[l&&(0,r.jsx)("span",{className:"text-xl font-bold tabular-nums text-[--foreground]",children:l}),n&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:n})]})]})}function or(e){let{data:t,color:s="var(--brand)",width:a=80,height:n=24,className:l}=e;if(!t.length)return null;let i=Math.min(...t),o=Math.max(...t)-i||1,d=t.map((e,s)=>{let r=s/(t.length-1||1)*a,l=n-(e-i)/o*n;return`${r.toFixed(1)},${l.toFixed(1)}`}).join(" ");
42return(0,r.jsx)("svg",{width:a,height:n,className:b("overflow-visible",l),preserveAspectRatio:"none",children:(0,r.jsx)("polyline",{points:d,fill:"none",stroke:s,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"})})}function on(e){let{label:t,value:s,hint:a,delta:n,spark:l,className:i}=e;return(0,r.jsxs)("div",{className:b("rounded-xl border border-[--border] bg-[--paper] p-4 flex flex-col gap-1",i),children:[(0,r.jsx)("span",{className:"text-xs uppercase tracking-wide text-[--muted]",children:t}),(0,r.jsxs)("div",{className:"flex items-end justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-2xl font-bold tabular-nums text-[--foreground]",children:s}),l&&(0,r.jsx)(or,{data:l})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[n&&(0,r.jsx)("span",{className:b("text-xs font-medium",n.positive?"text-emerald-500":"text-red-500"),children:n.value}),a&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:a})]})]})}function ol(e){let{value:t}=e,s=nc(t),a=t.toLocaleString();return s===a?(0,r.jsx)("span",{className:"tabular-nums",children:s}):(0,r.jsx)(tO,{trigger:(0,r.jsx)("span",{className:"tabular-nums cursor-default border-b border-dotted border-[--muted]/40",children:s}),children:a})}let oi=["24h","7d","30d","all"];function oo(e){let{value:t,onChange:s}=e;return(0,r.jsx)("div",{className:"flex gap-1",children:oi.map(e=>(0,r.jsx)("button",{onClick:()=>s(e),className:b("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 od(e){var t;let{title:s,rows:a}=e,n=a.slice(0,12),l=(null==(t=n[0])?void 0:t.count)??0;return(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-2",children:s}),0===n.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No data for this range."}):(0,r.jsx)("ul",{className:"space-y-1.5",children:n.map(e=>(0,r.jsxs)("li",{className:"text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"truncate font-medium",children:e.key}),(0,r.jsx)("span",{className:"text-[--muted]",children:(0,r.jsx)(ol,{value:e.count})})]}),(0,r.jsx)("div",{className:"h-1 rounded-full bg-[--subtle] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-brand",style:{width:l?`${e.count/l*100}%`:"0%"}})})]},e.key))})]})}function oc(e){let{uuidHash:t,range:s,onClose:a}=e,n=(0,ta.I)({queryKey:["dashboard","analytics","user-activity",t,s],queryFn:()=>el(`/dashboard/analytics/users/${t}?range=${s}`),enabled:!!t,staleTime:3e4}),l=n.data,i=l?Math.max(1,...l.resources.map(e=>e.count)):1;return(0,r.jsx)(tJ,{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:n.isLoading?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Loading…"}):n.isError?(0,r.jsx)("p",{className:"text-sm text-red-400",children:"Failed to load user activity."}):l?(0,r.jsxs)("div",{className:"space-y-5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-[--muted]",children:"Requests by resource"}),0===l.resources.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No requests in this range."}):(0,r.jsx)("ul",{className:"space-y-1.5",children:l.resources.map(e=>(0,r.jsxs)("li",{className:"text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"font-medium",children:e.resource}),(0,r.jsx)("span",{className:"text-[--muted]",children:(0,r.jsx)(ol,{value:e.count})})]}),(0,r.jsx)("div",{className:"h-1 overflow-hidden rounded-full bg-[--subtle]",children:(0,r.jsx)("div",{className:"h-full bg-brand",style:{width:`${e.count/i*100}%`}})})]},e.resource))})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-[--muted]",children:["IP addresses (",l.ips.length,")"]}),0===l.ips.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No IP data recorded for this user."}):(0,r.jsx)("div",{className:"max-h-64 overflow-y-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-xs uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"border-b border-[--border] text-left",children:[(0,r.jsx)("th",{className:"py-1.5 pr-3",children:"Anonymized IP"}),(0,r.jsx)("th",{className:"py-1.5 px-3 text-right",children:"Requests"}),(0,r.jsx)("th",{className:"py-1.5 pl-3 text-right",children:"Last seen"})]})}),(0,r.jsx)("tbody",{children:l.ips.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,r.jsx)("td",{className:"py-1.5 pr-3 font-mono text-xs",children:e.ipPrefix}),(0,r.jsx)("td",{className:"py-1.5 px-3 text-right",children:(0,r.jsx)(ol,{value:e.count})}),(0,r.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 ou=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 om(){let[e,t]=n.useState(null),[s,a]=n.useState(!1),[r,l]=n.useState(null),[i,o]=n.useState(0),d=n.useRef([]),[c,u]=n.useState([]),m=n.useCallback(e=>{var t;let s=new Map(d.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);d.current=n,u(n)},[]),p=n.useCallback(()=>{l(null),o(e=>e+1)},[]);return n.useEffect(()=>{let e=!1;el("/dashboard/system").then(s=>{e||(t(s),l(null),m([...s.history??[],ou(s)]))}).catch(t=>{e||l(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),l(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([ou(s)])}catch{}},()=>{e=!0,s.close()}},[m,i]),{metrics:e,connected:s,history:c,windowMs:3e5,error:r,retry:p}}function op(e){let{label:t,pct:s,detail:a}=e;return(0,r.jsxs)(X,{className:"p-4 flex flex-col items-center",children:[(0,r.jsx)("span",{className:"text-xs uppercase tracking-wide text-[--muted] mb-2",children:t}),(0,r.jsx)(oa,{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,r.jsx)("span",{className:"text-xs text-[--muted] mt-2",children:a})]})}let oh=e=>{let t=new Date(e);return[t.getHours(),t.getMinutes(),t.getSeconds()].map(e=>String(e).padStart(2,"0")).join(":")},ox=[{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 og(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 of(e){let{memory:t,history:s}=e,[a,l]=n.useState("process"),i="system"===a?{data:s.map(e=>({t:oh(e.ts),used:e.memory.used})),series:[{key:"used",label:"Used"}]}:{data:s.map(e=>({t:oh(e.ts),...og(e.memory)})),series:ox.map(e=>({key:e.key,label:e.label,color:e.color}))},o=og(t),d="process"===a?ox.map(e=>({label:e.label,color:e.color,value:o[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,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Memory usage"}),(0,r.jsxs)("span",{className:"text-sm",children:[(0,r.jsx)("span",{className:"text-xs text-[--muted] mr-1",children:"process"===a?"RSS":"Used"}),(0,r.jsx)("span",{className:"font-medium",children:ne("process"===a?t.rss:t.used)}),"system"===a&&(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:[" / ",ne(t.total)]})]})]}),(0,r.jsx)(ob,{value:a,onChange:l,options:[{value:"system",label:"System"},{value:"process",label:"Process"}]})]}),(0,r.jsx)(ot,{data:i.data,xKey:"t",series:i.series,height:200,stacked:"process"===a,hideLegend:!0,valueFormatter:ne,yTickFormatter:ne}),(0,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-4 text-sm",children:d.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"text-xs text-[--muted] flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"inline-block w-2 h-2 rounded-full shrink-0",style:{background:e.color}}),e.label]}),(0,r.jsx)("div",{className:"font-medium",children:ne(e.value)})]},e.label))})]})}function ob(e){let{value:t,onChange:s,options:a}=e;return(0,r.jsx)("div",{className:"inline-flex rounded-md border border-[--border] bg-[--subtle]/30 p-0.5 text-xs",children:a.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>!e.disabled&&s(e.value),disabled:e.disabled,title:e.title,className:b("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 ov=["10","25","50","100"],oy=e=>{if(!e)return"never";let t=(Date.now()-e)/1e3;return t<0?`in ${nn(-t)}`:`${nn(t)} ago`},oj=e=>null==e?"":"0s"===nn(e/1e3)?`${e}ms`:nn(e/1e3),ow={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 oN(e){let{sections:t,value:s,onChange:a}
42=e,[l,i]=n.useState(!1),o=n.useRef(null),d=t.find(e=>e.id===s)??t[0],c=d.icon;return n.useEffect(()=>{if(!l)return;let e=e=>{o.current&&!o.current.contains(e.target)&&i(!1)},t=e=>{"Escape"===e.key&&i(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[l]),(0,r.jsxs)("div",{ref:o,className:"relative sm:hidden",children:[(0,r.jsxs)("button",{type:"button","aria-haspopup":"listbox","aria-expanded":l,onClick:()=>i(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,r.jsx)(c,{className:"shrink-0 text-lg text-[--muted]"}),(0,r.jsx)("span",{className:"flex-1 text-left",children:d.label}),(0,r.jsx)(t2.nwe,{className:b("text-lg text-[--muted] transition-transform",l&&"rotate-180")})]}),(0,r.jsx)(tq.N,{children:l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tB.P.div,{className:"fixed inset-0 w-screen z-40 bg-black/30",initial:{opacity:0}
42,animate:{opacity:1},exit:{opacity:0},onClick:()=>i(!1)}),(0,r.jsx)(tB.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,n=e.icon;return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":t,onClick:()=>{a(e.id),i(!1)},className:b("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,r.jsx)(n,{className:"shrink-0 text-lg"}),(0,r.jsx)("span",{className:"flex-1 text-left",children:e.label}),t&&(0,r.jsx)(t2.mmP,{className:"text-lg text-[--muted]"})]})},e.id)})})]})})]})}let ok=["dead","defective","fake","mislabeled"],oS=["full","corroborate","observe"],oC={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"},o_={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"},oA={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 oR(e){let{className:t,children:s}=e;return(0,r.jsx)("span",{className:b("text-[10px] uppercase px-1.5 py-0.5 rounded border whitespace-nowrap",t),children:s})}function oT(e){return e?new Date(1e3*e).toLocaleString():"—"}function oI(e){return e%86400==0?`${e/86400}d`:e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function oE(){return(0,ta.I)({queryKey:["dashboard","blocklist","snapshot"],queryFn:()=>el("/dashboard/blocklist"),refetchInterval:3e4})}function oM(){let e=(0,o.jE)();return()=>e.invalidateQueries({queryKey:["dashboard","blocklist"]})}function oP(e){let{snapshot:t,invalidate:s}=e,[a,l]=n.useState(!1),[i,o]=n.useState(!1),[d,c]=n.useState(!1),[u,m]=n.useState(),[p,h]=n.useState(new Set),[g,f]=n.useState(!1),[v,y]=n.useState(null),j=t.sources,N=j.filter(e=>"local"!==e.id),k=j.length>0&&j.every(e=>p.has(e.id)),S=j.map(e=>e.id).sort().join(",");n.useEffect(()=>{h(new Set)},[S]);let C=(0,e2.n)({mutationFn:e=>el("POST /dashboard/blocklist/sources/remove",{body:{ids:e}}),onSuccess:e=>{x.oR.success(`Removed ${e.affected} source${1===e.affected?"":"s"}`),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Remove failed")}),_=(0,e2.n)({mutationFn:e=>el("POST /dashboard/blocklist/sources/clear",{body:{ids:e}}),onSuccess:e=>{x.oR.success(`Cleared ${e.affected} source${1===e.affected?"":"s"}`),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Clear failed")}),A=(0,e2.n)({mutationFn:e=>el("POST /dashboard/blocklist/sources/refresh",{body:{ids:e}}),onSuccess:e=>{x.oR.success(`Refreshed ${e.affected} source${1===e.affected?"":"s"}`),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Refresh failed")}),R=(0,e2.n)({mutationFn:e=>el("PATCH /dashboard/blocklist/sources",{body:{ids:e.ids,...e.body}}),onSuccess:()=>s(),onError:e=>x.oR.error((null==e?void 0:e.message)??"Update failed")}),T={onSuccess:()=>h(new Set)},I=tX({title:(null==v?void 0:v.title)??"",description:null==v?void 0:v.description,actionText:null==v?void 0:v.actionText,actionIntent:null==v?void 0:v.actionIntent,onConfirm:()=>null==v?void 0:v.onConfirm()}),M=e=>{y(e),I.open()},P=e=>`${e} source${1===e?"":"s"}`,D=[...p].some(e=>{var t;return(null==(t=j.find(t=>t.id===e))?void 0:t.kind)==="remote"}),$=[...p].some(e=>{var t;return(null==(t=j.find(t=>t.id===e))?void 0:t.kind)==="local"}),L=!$,O=!$,U=!$&&D;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap items-center min-h-9",children:[(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(t2.Ca6,{}),onClick:()=>l(!0),children:"Subscribe to a list"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(t2.tAF,{}),onClick:()=>o(!0),children:"Import"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(t2.Ah9,{}),onClick:()=>c(!0),children:"Export"}),(0,r.jsxs)("div",{className:"relative flex flex-1 gap-2 items-center",children:[(0,r.jsxs)("div",{className:b("flex flex-1 gap-2 items-center",0===p.size&&"invisible"),children:[(0,r.jsxs)("span",{className:"text-sm font-medium tabular-nums text-[--muted]",children:[p.size," selected"]}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.Zxy,{}),"aria-label":"Refresh selected",title:U?"Refresh selected":$?"Cannot refresh local sources":"No remote sources selected",loading:A.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:()=>A.mutate([...p],T)}),disabled:!U}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.z$h,{}
42),"aria-label":"Edit selected",title:L?"Edit selected":"Cannot edit the local source",onClick:()=>f(!0),disabled:!L}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.PLI,{}),"aria-label":"Clear entries of selected",title:"Clear entries of selected",loading:_.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:()=>_.mutate([...p],T)})}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Remove selected",title:O?"Remove selected":"Cannot remove the local source",loading:C.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:()=>C.mutate([...p],T)}),disabled:!O})]}),0===p.size&&N.length>0&&(0,r.jsx)(w,{size:"sm",intent:"alert-subtle",leftIcon:(0,r.jsx)(t2.id1,{}),title:"Remove all sources except the local one",loading:C.isPending,onClick:()=>M({title:"Remove all non-local sources",description:`Remove every source except this instance's own list (${P(N.length)}). This cannot be undone.`,actionText:"Remove all",actionIntent:"alert-subtle",onConfirm:()=>C.mutate(N.map(e=>e.id),T)}),className:"absolute right-0",children:"Remove all"})]})]}),(0,r.jsx)(X,{className:"p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3 w-10",children:j.length>0&&(0,r.jsx)(nB,{value:k,onValueChange:e=>h(!0===e?new Set(j.map(e=>e.id)):new Set),"aria-label":"Select all"})}),(0,r.jsx)("th",{className:"p-3",children:"Name"}),(0,r.jsx)("th",{className:"p-3",children:"Kind"}),(0,r.jsx)("th",{className:"p-3",children:"Trust"}),(0,r.jsx)("th",{className:"p-3",children:"Refresh"}),(0,r.jsx)("th",{className:"p-3",children:"Status"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Entries"}),(0,r.jsx)("th",{className:"p-3",children:"Enabled"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:t.sources.map(e=>{var t,s,a;return(0,r.jsxs)("tr",{className:b("border-t border-[--border]/50",p.has(e.id)?"bg-[--accent]/5":"hover:bg-[--subtle]/30"),children:[(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(nB,{value:p.has(e.id),onValueChange:()=>{var t;return t=e.id,void h(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},"aria-label":`Select ${e.name}`})}),(0,r.jsx)("td",{className:"p-3 font-medium",children:e.name}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(oR,{className:o_[e.kind],children:e.kind})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(oR,{className:oA[e.trust],children:e.trust})}),(0,r.jsx)("td",{className:"p-3 tabular-nums",children:"remote"===e.kind?oI(e.refreshSeconds):"—"}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted] max-w-[220px] truncate",title:e.status??void 0,children:e.status??"—"}),(0,r.jsxs)("td",{className:"p-3 text-right tabular-nums",children:[(0,r.jsx)("div",{children:e.count}),e.count>0&&(0,r.jsxs)("div",{className:"text-xs text-[--muted]",title:"Entries no other source lists",children:[e.uniqueCount," unique"]})]}),(0,r.jsx)("td",{className:"p-3",children:"local"===e.kind?"—":(0,r.jsx)(rZ,{value:e.enabled,onValueChange:t=>R.mutate({ids:[e.id],body:{enabled:t}})})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex justify-end gap-1",children:["remote"===e.kind&&(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.Zxy,{}),"aria-label":"Refresh now",loading:A.isPending&&(null==(t=A.variables)?void 0:t.length)===1&&A.variables[0]===e.id,onClick:()=>A.mutate([e.id])}),"local"!==e.kind&&(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.z$h,{}),"aria-label":"Edit source",onClick:()=>m(e)}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.PLI,{}),"aria-label":"Clear entries",loading:_.isPending&&(null==(s=_.variables)?void 0:s.length)===1&&_.variables[0]===e.id,onClick:()=>M({title:"Clear source entries",description:"This removes every entry this 
42source contributed but keeps the source itself.",actionText:"Clear",actionIntent:"alert-subtle",onConfirm:()=>_.mutate([e.id])})}),"local"!==e.kind&&(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Remove source",loading:C.isPending&&(null==(a=C.variables)?void 0:a.length)===1&&C.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:()=>C.mutate([e.id])})})]})})]},e.id)})})]})})}),(0,r.jsx)(o$,{open:a,onOpenChange:l,invalidate:s}),(0,r.jsx)(oO,{open:i,onOpenChange:o,invalidate:s}),(0,r.jsx)(oU,{open:d,onOpenChange:c}),u&&(0,r.jsx)(oD,{source:u,onClose:()=>m(void 0),invalidate:s}),g&&(0,r.jsx)(oF,{selectedIds:[...p],sources:j,onSave:e=>R.mutate({ids:[...p],body:e},{onSuccess:e=>{x.oR.success(`Updated ${e.affected} source${1===e.affected?"":"s"}`),h(new Set),f(!1)}}),loading:R.isPending,onClose:()=>f(!1)}),(0,r.jsx)(t0,{...I})]})}function oD(e){let{source:t,onClose:s,invalidate:a}=e,[l,i]=n.useState(t.name),[o,d]=n.useState(""),[c,u]=n.useState(t.trust),[m,p]=n.useState(Math.max(1,Math.round(t.refreshSeconds/3600))),h=(0,e2.n)({mutationFn:()=>{let e={name:l.trim()||t.name,trust:c};return"remote"===t.kind&&(e.refreshSeconds=Math.round(3600*m),o.trim()&&(e.url=o.trim())),el("PATCH /dashboard/blocklist/sources",{body:{ids:[t.id],...e}})},onSuccess:()=>{x.oR.success("Source updated"),s(),a()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Update failed")});return(0,r.jsx)(tJ,{open:!0,onOpenChange:e=>!e&&s(),title:`Edit "${t.name}"`,children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(G,{label:"Name",value:l,onValueChange:i}),"remote"===t.kind&&(0,r.jsx)(G,{label:"URL",placeholder:"(unchanged)",value:o,onValueChange:d,help:t.url?`Current: ${t.url}`:"Leave blank to keep the current URL"}),(0,r.jsx)(r0,{label:"Trust",options:oS.map(e=>({label:e,value:e})),value:c,onValueChange:e=>u(e),help:"full filters on its own; corroborate needs the quorum; observe never filters"}),"remote"===t.kind&&(0,r.jsx)(n1,{label:"Refresh (hours)",value:m,min:1,max:720,onValueChange:e=>p(e||24)}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:s,children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:h.isPending,onClick:()=>h.mutate(),children:"Save"})]})]})})}function o$(e){let{open:t,onOpenChange:s,invalidate:a}=e,[l,i]=n.useState(""),[o,d]=n.useState("full"),[c,u]=n.useState(24),m=l.split("\n").map(e=>e.trim()).filter(e=>e&&!e.startsWith("#")).length,p=(0,e2.n)({mutationFn:()=>el("POST /dashboard/blocklist/sources/remote",{body:{input:l,trust:o,refreshSeconds:Math.round(3600*c)}}),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`),x.oR.success(r.join(", ")),s(!1),i(""),a()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Subscribe failed")});return(0,r.jsx)(tJ,{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,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(n7,{label:"List URL(s)",placeholder:"https://example.com/blocklist/export",rows:5,value:l,onValueChange:i}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(r0,{label:"Trust",options:oS.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"}),(0,r.jsx)(n1,{label:"Refresh (hours)",value:c,min:1,max:720,onValueChange:e=>u(e||24)})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:p.isPending,disabled:0===m,onClick:()=>p.mutate(),children:m>1?`Subscribe (${m})`:"Subscribe"})]})]})})}let oL={"application/x-ndjson":[".ndjson"],"application/json":[".json"],"application/gzip":[".gz"],"text/plain":[".txt"]};function oO(e){let{open:t,onOpenChange:s,invalidate:a}
42=e,[l,i]=n.useState(""),[o,d]=n.useState(null),[c,u]=n.useState(!1),m=async()=>{if(o){u(!0);try{let t=await o.arrayBuffer(),r=new URLSearchParams;l.trim()&&r.set("name",l.trim());let n=await fetch(`/api/v1/dashboard/blocklist/import?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:t}),c=await n.json().catch(()=>void 0);if(!n.ok||(null==c?void 0:c.success)===!1){var e;throw Error((null==c||null==(e=c.error)?void 0:e.message)??`HTTP ${n.status}`)}x.oR.success("List imported"),s(!1),d(null),i(""),a()}catch(e){x.oR.error((null==e?void 0:e.message)??"Import failed")}finally{u(!1)}}};return(0,r.jsx)(tJ,{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,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(G,{label:"Name (optional)",placeholder:`Import ${new Date().toISOString().slice(0,10)}`,value:l,onValueChange:i}),(0,r.jsx)(n9,{accept:oL,className:"min-h-[120px] w-full",dropzoneText:"Drop a list file here, or click to choose",onValueChange:e=>d(e[0]??null),onDropRejected:e=>{let t=e.map(e=>e.file.name);x.oR.error(1===t.length?`"${t[0]}" isn't a supported list file`:"Drop a single .ndjson, .json, .gz or .txt file")}}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:c,disabled:!o,onClick:m,children:"Import"})]})]})})}function oU(e){let{open:t,onOpenChange:s}=e,[a,l]=n.useState(!1),[i,o]=n.useState("local");return(0,r.jsx)(tJ,{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,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(r0,{label:"Scope",options:[{label:"This instance's own verdicts",value:"local"},{label:"Everything (all sources, deduplicated)",value:"all"}],value:i,onValueChange:e=>o(e)}),(0,r.jsx)(rZ,{label:"Warden-compatible format",value:a,onValueChange:l,help:"For davex. Carries only dead usenet fingerprints; content-hash and torrent entries are left out."}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",leftIcon:(0,r.jsx)(t2.Ah9,{}),onClick:()=>{let e=document.createElement("a");e.href=`/api/v1/dashboard/blocklist/export?format=${a?"warden":"native"}&scope=${i}`,e.download="",document.body.appendChild(e),e.click(),e.remove(),s(!1)},children:"Download"})]})]})})}function oF(e){let{selectedIds:t,sources:s,onSave:a,loading:l,onClose:i}=e,o=s.filter(e=>t.includes(e.id)).some(e=>"remote"===e.kind),[d,c]=n.useState(""),[u,m]=n.useState(24),[p,h]=n.useState(!1),[x,g]=n.useState(""),f=()=>{let e={};return d&&(e.trust=d),o&&p&&u>0&&(e.refreshSeconds=Math.round(3600*u)),""!==x&&(e.enabled=x),e};return(0,r.jsx)(tJ,{open:!0,onOpenChange:e=>!e&&i(),title:`Edit ${t.length} source${1===t.length?"":"s"}`,description:"Set common fields for all selected sources. Blank fields are left unchanged.",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(r0,{label:"Trust",options:[{label:"Leave unchanged",value:""},...oS.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"}),o&&(0,r.jsx)(n1,{label:"Refresh (hours)",value:u,min:1,max:720,onValueChange:e=>{m(e||24),h(!0)},help:"Only applies to remote sources"}),(0,r.jsx)(r0,{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,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:i,children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:l,disabled:0===Object.keys(f()).length,onClick:()=>a(f()),children:"Save"})]})]})})}let oz={root:(0,h.F)(["UI-Pagination__root","flex gap-1 text-xs font-medium"]),item:(0,h.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,h.F)(["UI-Pagination__ellipsis","flex p-2 items-center text-[1.05rem]"])},oV=n.createContext({}),oq=n.forwardRef((e,t)=>
42{let{children:s,itemClass:a,className:n,ellipsisClass:l,...i}=e;return(0,r.jsx)(oV.Provider,{value:{itemClass:a,ellipsisClass:l},children:(0,r.jsx)("ul",{ref:t,className:b(oz.root(),n),role:"navigation",...i,children:s})})});oq.displayName="Pagination";let oB=n.forwardRef((e,t)=>{let{value:s,className:a,...l}=e,{itemClass:i}=n.useContext(oV);return(0,r.jsx)("li",{children:(0,r.jsx)("button",{className:b(oz.item(),i,a),...l,ref:t,children:s})})});oB.displayName="PaginationItem";let oK=n.forwardRef((e,t)=>{let{isChevrons:s=!1,isDisabled:a=!1,direction:l,className:i,...o}=e,{itemClass:d}=n.useContext(oV);return(0,r.jsx)("li",{children:(0,r.jsx)("button",{className:b(oz.item(),d,i),"data-disabled":a,tabIndex:a?-1:void 0,...o,ref:t,children:"previous"===l?(0,r.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("polyline",{points:"11 17 6 12 11 7"}),(0,r.jsx)("polyline",{points:"18 17 13 12 18 7"})]}):(0,r.jsx)("polyline",{points:"15 18 9 12 15 6"})}):(0,r.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("polyline",{points:"13 17 18 12 13 7"}),(0,r.jsx)("polyline",{points:"6 17 11 12 6 7"})]}):(0,r.jsx)("polyline",{points:"9 18 15 12 9 6"})})})})});oK.displayName="PaginationTrigger";let oH=n.forwardRef((e,t)=>{let{className:s,...a}=e,{ellipsisClass:l}=n.useContext(oV);return(0,r.jsx)("li",{className:b(oz.ellipsis(),l,s),children:(0,r.jsx)("span",{...a,ref:t,children:"…"})})});function oW(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 oG(e){let{snapshot:t,invalidate:s}=e,[a,l]=n.useState(""),[i,o]=n.useState(""),[d,c]=n.useState(""),[u,m]=n.useState(""),[p,h]=n.useState(1),[g,f]=n.useState(!1),[v,y]=n.useState(),j=(0,ta.I)({queryKey:["dashboard","blocklist","entries",{search:a,sourceId:i,verdict:d,kind:u,page:p}],queryFn:()=>{let e=new URLSearchParams({page:String(p)});return a.trim()&&e.set("search",a.trim()),i&&e.set("source",i),d&&e.set("verdict",d),u&&e.set("kind",u),el(`/dashboard/blocklist/entries?${e}`)},placeholderData:ij.rX}),N=(0,e2.n)({mutationFn:e=>el("POST /dashboard/blocklist/unmark",{body:{releases:[[e]]}}),onSuccess:()=>{x.oR.success("Release allowed on this instance"),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed")}),k=(0,e2.n)({mutationFn:e=>el(`DELETE /dashboard/blocklist/entries?key=${encodeURIComponent(e)}`),onSuccess:()=>{x.oR.success("Verdict removed"),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed")}),S=(0,e2.n)({mutationFn:e=>el(`DELETE /dashboard/blocklist/overrides${e?`?key=${encodeURIComponent(e)}`:""}`),onSuccess:(e,t)=>{x.oR.success(t?"Override cleared":"All overrides cleared"),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed")}),C=tX({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)}),_=j.data,A=_?Math.max(1,Math.ceil(_.total/_.pageSize)):1,R="__any__";return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap items-end",children:[(0,r.jsx)(G,{leftIcon:(0,r.jsx)(t2.iyI,{}),placeholder:"Search keys…",value:a,onValueChange:e=>{l(e),h(1)},className:"w-64"}),(0,r.jsx)(r0,{options:[{label:"All sources",value:R},...t.sources.map(e=>({label:e.name,value:e.id}))],value:i||R,onValueChange:e=>{o(e===R?"":e),h(1)}}),(0,r.jsx)(r0,{options:[{label:"All verdicts",value:R},...ok.map(e=>({label:e,value:e}))],value:d||R,onValueChange:e=>{c(e===R?"":e),h(1)}}),(0,r.jsx)(r0,{options:[{label:"All kinds",value:R},{label:"usenet",value:"usenet"},{label:"torrent",value:"torrent"}],value:u||R,onValueChange:e=>{m(e===R?"":e),h(1)}}),(0,r.jsx)("div",{className:"flex-1"}),t.counts.overrides>0&&(0,r.jsxs)(w,{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,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(t2.Ca6,{}),onClick:()=>f(!0),children:"Mark a release"})]}),(0,r.jsx)(iq,{query:j,errorTitle:"Failed to load entries",children:e=>(0,r.jsxs)(X,{className:"p-0 overflow-hidden",children:[(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"Key"}),(0,r.jsx)("th",{className:"p-3",children:"Kind"}),(0,r.jsx)("th",{className:"p-3",children:"Verdict"}),(0,r.jsx)("th",{className:"p-3",children:"Sources"}),(0,r.jsx)("th",{className:"p-3",children:"Backbones"}),(0,r.jsx)("th",{className:"p-3",children:"Last seen"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,r.jsxs)("tbody",{children:[0===e.entries.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{className:"p-6 text-center text-[--muted]",colSpan:7,children:"No entries"})}),e.entries.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsx)("td",{className:"p-3 font-mono text-xs max-w-[260px] truncate cursor-pointer",title:`${e.key} (click to copy)`,onClick:()=>void r9(e.key,{onSuccess:()=>x.oR.success("Key copied"),onError:()=>x.oR.error("Copy failed")}),children:e.key}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(oR,{className:o_[e.kind],children:e.kind})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)(oR,{className:oC[e.verdict],children:e.verdict}),e.overridden&&(0,r.jsx)(oR,{className:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",children:"allowed"})]})}),(0,r.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,r.jsx)("td",{className:b("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&&y(e),children:e.backbones.join(", ")||"everywhere"}),(0,r.jsx)("td",{className:"p-3 text-xs tabular-nums whitespace-nowrap",children:oT(e.lastAt)}
42),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)("div",{className:"flex justify-end",children:e.overridden?(0,r.jsx)(w,{size:"sm",intent:"gray-subtle",leftIcon:(0,r.jsx)(t2.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,r.jsx)(w,{size:"sm",intent:"gray-subtle",leftIcon:(0,r.jsx)(t2.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,r.jsx)(w,{size:"sm",intent:"gray-subtle",leftIcon:(0,r.jsx)(t2.id1,{}),loading:k.isPending&&k.variables===e.key,onClick:()=>k.mutate(e.key),title:"Delete this instance's verdict",children:"Remove"})})})]},e.key))]})]})}),(0,r.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,r.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,r.jsxs)(oq,{children:[(0,r.jsx)(oK,{direction:"previous",isDisabled:p<=1,onClick:()=>h(e=>Math.max(1,e-1))}),oW(p,A).map((e,t)=>"…"===e?(0,r.jsx)(oH,{},`e${t}`):(0,r.jsx)(oB,{value:e,"data-selected":e===p,onClick:()=>h(e)},e)),(0,r.jsx)(oK,{direction:"next",isDisabled:p>=A,onClick:()=>h(e=>Math.min(A,e+1))})]})]})]})}),v&&(0,r.jsx)(tJ,{open:!0,onOpenChange:e=>!e&&y(void 0),title:"Backbone scope",description:v.key,children:(0,r.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs uppercase text-[--muted] mb-1",children:"Backbones"}),(0,r.jsx)("div",{children:v.backbones.join(", ")||"everywhere"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs uppercase text-[--muted]",children:"As recorded per source"}),v.sources.map(e=>(0,r.jsxs)("div",{className:"text-xs",children:[(0,r.jsx)("span",{className:"font-medium",children:e.name})," ",(0,r.jsxs)("span",{className:"text-[--muted]",children:["(",e.verdict,", seen ",e.n,"\xd7)"]}),(0,r.jsx)("div",{className:"font-mono text-[--muted]",children:e.backbones.join(", ")||"no scope (applies everywhere)"})]},e.id))]})]})}),(0,r.jsx)(oY,{open:g,onOpenChange:f,invalidate:s}),(0,r.jsx)(t0,{...C})]})}function oY(e){let{open:t,onOpenChange:s,invalidate:a}=e,[l,i]=n.useState(""),[o,d]=n.useState("dead"),c=(0,e2.n)({mutationFn:()=>el("POST /dashboard/blocklist/mark",{body:{releases:[[l.trim()]],verdict:o}}),onSuccess:()=>{x.oR.success("Release marked"),s(!1),i(""),a()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Mark failed")});return(0,r.jsx)(tJ,{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,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(G,{label:"Release key",placeholder:"btih:… or wd1:…",value:l,onValueChange:i}),(0,r.jsx)(r0,{label:"Verdict",options:ok.map(e=>({label:e,value:e})),value:o,onValueChange:e=>d(e)}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:c.isPending,disabled:!l.trim(),onClick:()=>c.mutate(),children:"Mark"})]})]})})}oH.displayName="PaginationEllipsis";let oJ={local:"Own verdicts",all:"Every source"};function oZ(e){r9(e,{onSuccess:()=>x.oR.success("Copied to clipboard"),onError:()=>x.oR.error("Failed to copy")})}function oQ(e){let{target:t}=e;return t.error?(0,r.jsx)(L,{className:"w-96",align:"start",trigger:(0,r.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,r.jsx)(t2.wfp,{className:"h-3.5 w-3.5"})]}),children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:"Last push failed"}),(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:oT(t.lastChecked)})]}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(t2.Xpf,{}),"aria-label":"Copy the error",onClick:()=>oZ(t.error)})]}),(0,r.jsx)("p",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words text-xs text-[--muted]",children:t.error})]})}):(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:t.status??"—"})}function oX(e){let{title:t,description:s,files:a}
42=e,[l,i]=n.useState(!1),o=n.useMemo(()=>{let e;return e=e=>2*("native"!==e.format)+ +("local"!==e.scope),[...a].sort((t,s)=>e(t)-e(s))},[a]),d=o[0];if(!d)return(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"—"});let c=o.length-1;return(0,r.jsxs)("div",{className:"space-y-1",children:[d.url?(0,r.jsxs)("button",{type:"button",className:"group flex items-center gap-1.5 text-xs font-mono max-w-[260px]",title:d.url,"aria-label":`Copy the URL for ${d.label}`,onClick:()=>oZ(d.url),children:[(0,r.jsx)(t2.Xpf,{className:"h-3.5 w-3.5 shrink-0 text-[--muted] group-hover:text-[--brand]"}),(0,r.jsx)("span",{className:"truncate group-hover:text-[--brand]",children:d.label})]}):(0,r.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,r.jsx)("span",{className:"truncate",children:d.label})}),c>0&&(0,r.jsxs)("button",{type:"button",className:"ml-5 text-xs text-[--muted] hover:text-[--foreground] hover:underline underline-offset-2",onClick:()=>i(!0),children:[c," more ",1===c?"file":"files"]}),l&&(0,r.jsx)(o0,{title:t,description:s,files:o,onClose:()=>i(!1)})]})}function o0(e){let{title:t,description:s,files:a,onClose:n}=e;return(0,r.jsx)(tJ,{open:!0,onOpenChange:e=>!e&&n(),title:t,description:s,children:(0,r.jsx)("div",{className:"space-y-2 min-w-0",children:a.map(e=>{let t;return(0,r.jsxs)("div",{className:"rounded-[--radius] border border-[--border]/60 bg-[--subtle]/30 p-3 space-y-1.5",children:[(0,r.jsx)("div",{className:"text-sm font-mono break-all",children:e.label}),(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:(t=[oJ[e.scope]],"warden"===e.format&&t.push("Warden format"),e.gzip&&t.push("gzip"),e.pushedAt&&t.push(`pushed ${oT(e.pushedAt)}`),t.join(" \xb7 "))}),e.url?(0,r.jsxs)("div",{className:"flex items-start gap-1",children:[(0,r.jsx)("span",{className:"flex-1 min-w-0 break-all text-xs font-mono text-[--muted]",title:e.url,children:e.url}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(t2.Xpf,{}),"aria-label":`Copy the URL for ${e.label}`,onClick:()=>oZ(e.url)})]}):(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"The URL appears once the file has been pushed."})]},e.key)})})})}function o1(e){let{snapshot:t,invalidate:s}=e,[a,l]=n.useState(!1),[i,o]=n.useState(!1),[d,c]=n.useState(),[u,m]=n.useState(),p=(0,e2.n)({mutationFn:e=>el(`PATCH /dashboard/blocklist/targets/${e.id}`,{body:e.body}),onSuccess:s,onError:e=>x.oR.error((null==e?void 0:e.message)??"Update failed")}),h=(0,e2.n)({mutationFn:e=>el(`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)?x.oR.error(a.error):x.oR.success((null==a?void 0:a.status)??"Pushed"),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Push failed")}),g=(0,e2.n)({mutationFn:e=>el(`DELETE /dashboard/blocklist/targets/${e}`),onSuccess:()=>{x.oR.success("Target removed"),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Delete failed")}),f=tX({title:"Remove publish target",description:"This stops pushing to this destination. Files already uploaded there are not deleted.",actionText:"Remove",actionIntent:"alert-subtle",onConfirm:()=>u&&g.mutate(u.id)});return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap items-center",children:[(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(t2.Ca6,{}),onClick:()=>{c(void 0),l(!0)},children:"Add target"}),(0,r.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,r.jsx)(X,{className:"p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"Name"}),(0,r.jsx)("th",{className:"p-3",children:"Provider"}),(0,r.jsx)("th",{className:"p-3",children:"Files"}),(0,r.jsx)("th",{className:"p-3",children:"Interval"}),(0,r.jsx)("th",{className:"p-3",children:"Last push"}),(0,r.jsx)("th",{className:"p-3",children:"Status"}),(0,r.jsx)("th",{className:"p-3",children:"Enabled"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}
42),(0,r.jsxs)("tbody",{children:[(0,r.jsx)(o3,{snapshot:t,invalidate:s,onEdit:()=>o(!0)}),t.targets.map(e=>{var t;let s;return(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsxs)("td",{className:"p-3 font-medium",children:[e.name,e.configUnreadable&&(0,r.jsx)("div",{className:"text-xs text-red-400",children:"config unreadable — re-enter it"})]}),(0,r.jsxs)("td",{className:"p-3",children:[(0,r.jsx)(oR,{className:"bg-sky-500/10 text-sky-500 border-sky-500/20",children:e.providerLabel}),(0,r.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,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(oX,{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,r.jsx)("td",{className:"p-3 tabular-nums",children:oI(e.intervalSeconds)}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted] whitespace-nowrap",children:oT(e.lastPushed)}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(oQ,{target:e})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(rZ,{value:e.enabled,onValueChange:t=>p.mutate({id:e.id,body:{enabled:t}})})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.tAF,{}),"aria-label":"Push now",loading:h.isPending&&h.variables===e.id,onClick:()=>h.mutate(e.id)}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.z$h,{}),"aria-label":"Edit target",onClick:()=>{c(e),l(!0)}}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Remove target",onClick:()=>{m(e),f.open()}})]})})]},e.id)})]})]})})}),a&&(0,r.jsx)(o9,{providers:t.providers,target:d,onClose:()=>l(!1),invalidate:s}),i&&(0,r.jsx)(o5,{snapshot:t,onClose:()=>o(!1),invalidate:s}),(0,r.jsx)(t0,{...f})]})}function o2(e){return e?`Set by ${e}; change it in the environment.`:void 0}function o3(e){var t;let{snapshot:s,invalidate:a,onEdit:n}=e,{status:l}=tr(),i=(null==l||null==(t=l.settings)?void 0:t.baseUrl)||window.location.origin,{settings:o,publicExportEnv:d}=s,c=(0,e2.n)({mutationFn:e=>el("PATCH /dashboard/blocklist/settings",{body:{publicExport:e}}),onSuccess:a,onError:e=>x.oR.error((null==e?void 0:e.message)??"Update failed")});return(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 bg-[--subtle]/20",children:[(0,r.jsx)("td",{className:"p-3 font-medium",children:"This instance"}),(0,r.jsxs)("td",{className:"p-3",children:[(0,r.jsx)(oR,{className:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",children:"public export"}),(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:"served live, nothing is pushed"})]}),(0,r.jsx)("td",{className:"p-3",children:o.publicExport?(0,r.jsx)(oX,{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,i)}):(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"—"})}),(0,r.jsx)("td",{className:"p-3 tabular-nums",children:"—"}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:"—"}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:o.publicExport?"subscribers fetch it directly":"disabled"}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)("span",{title:o2(d.publicExport),children:(0,r.jsx)(rZ,{value:o.publicExport,disabled:!!d.publicExport||c.isPending,onValueChange:e=>c.mutate(e)}
42)})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)("div",{className:"flex justify-end gap-1",children:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.z$h,{}),"aria-label":"Edit the public export",onClick:n})})})]})}function o5(e){let{snapshot:t,onClose:s,invalidate:a}=e,{settings:l,publicExportEnv:i}=t,[o,d]=n.useState(l.publicExport),[c,u]=n.useState(l.publicExportScope),[m,p]=n.useState(l.publicExportPassword),h=(0,e2.n)({mutationFn:e=>el("PATCH /dashboard/blocklist/settings",{body:e}),onSuccess:()=>{x.oR.success("Public export updated"),s(),a()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Save failed")});return(0,r.jsx)(tJ,{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,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(rZ,{side:"right",label:"Serve the public export",value:o,disabled:!!i.publicExport,onValueChange:d,help:o2(i.publicExport)??"The list contains only release digests and backbone root domains."}),(0,r.jsx)(r0,{label:"Scope",options:[{label:"local (own verdicts)",value:"local"},{label:"all (every source)",value:"all"}],value:c,disabled:!!i.publicExportScope,onValueChange:e=>u(e),help:o2(i.publicExportScope)??"The most a subscriber may ask for. With local, only verdicts this instance recorded first-hand are ever served."}),(0,r.jsx)(G,{type:"password",label:"Password",autoComplete:"new-password",placeholder:"No password",value:m,disabled:!!i.publicExportPassword,onValueChange:p,help:o2(i.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"===c&&(0,r.jsx)(lN,{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,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:s,children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:h.isPending,onClick:()=>{let e={};if(i.publicExport||o===l.publicExport||(e.publicExport=o),i.publicExportScope||c===l.publicExportScope||(e.publicExportScope=c),i.publicExportPassword||m===l.publicExportPassword||(e.publicExportPassword=m),0===Object.keys(e).length)return s();h.mutate(e)},children:"Save"})]})]})})}function o4(e,t,s){let a={};for(let r of e)if("switch"===r.type){let e=s?t[r.key]:void 0;a[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 o6(e){let{field:t,value:s,editing:a,onChange:n}=e,l=a&&t.editHelp||t.help,i=a&&t.editPlaceholder||t.placeholder;return"switch"===t.type?(0,r.jsx)(rZ,{side:"right",label:t.label,value:!!s,onValueChange:n,help:l}):"select"===t.type?(0,r.jsx)(r0,{label:t.label,options:t.options??[],value:String(s),onValueChange:n,help:l}):"textarea"===t.type?(0,r.jsx)(n7,{label:t.label,rows:3,placeholder:i,value:String(s),onValueChange:n,help:l}):(0,r.jsx)(G,{type:"password"===t.type?"password":"text",label:t.label,placeholder:i,value:String(s),onValueChange:n,help:l})}function o9(e){var t;let{providers:s,target:a,onClose:l,invalidate:i}=e,o=!!a,d=(null==a?void 0:a.summary)??{},[c,u]=n.useState((null==a?void 0:a.provider)??(null==(t=s[0])?void 0:t.id)??"github-gist"),m=s.find(e=>e.id===c),[p,h]=n.useState((null==a?void 0:a.name)??""),[g,f]=n.useState(a?Math.max(1,Math.round(a.intervalSeconds/3600)):6),[b,v]=n.useState(a?a.artifacts.map(e=>({format:e.format,scope:e.scope,gzip:e.gzip})):[{format:"native",scope:"local",gzip:!!(null==m?void 0:m.capabilities.binary)}]),[y,j]=n.useState(()=>o4((null==m?void 0:m.fields)??[],d,o)),N=(0,e2.n)({mutationFn:()=>{let e={name:p.trim(),intervalSeconds:Math.round(3600*g),artifacts:b.map(e=>({format:e.format,scope:e.scope,gzip:null!=m&&!!m.capabilities.binary&&e.gzip})),config:(()=>{let e={};for(let t of(null==m?void 0:m.fields)??[]){let s=y[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 o?el(`PATCH /dashboard/blocklist/targets/${a.id}`,{body:e}):el("POST /dashboard/blocklist/targets",{body:{...e,provider:c}})},onSuccess:()=>
42{x.oR.success(o?"Target updated":"Target added"),l(),i()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Save failed")}),k=b.some(e=>"all"===e.scope);return(0,r.jsx)(tJ,{open:!0,onOpenChange:e=>!e&&l(),title:o?`Edit "${a.name}"`:"Add publish target",children:(0,r.jsxs)("div",{className:"space-y-3",children:[!o&&(0,r.jsx)(r0,{label:"Provider",options:s.map(e=>({label:e.label,value:e.id})),value:c,onValueChange:e=>{let t=s.find(t=>t.id===e);u(e),j(o4((null==t?void 0:t.fields)??[],{},!1)),v(e=>e.map(e=>({...e,gzip:!!(null==t?void 0:t.capabilities.binary)&&e.gzip})))}}),(0,r.jsx)(G,{label:"Name",value:p,onValueChange:h}),(0,r.jsx)(n1,{label:"Push interval (hours)",value:g,min:1,max:720,onValueChange:e=>f(e||6)}),((null==m?void 0:m.fields)??[]).map(e=>(0,r.jsx)(o6,{field:e,value:y[e.key]??("switch"!==e.type&&""),editing:o,onChange:t=>j(s=>({...s,[e.key]:t}))},`${c}:${e.key}`)),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-[--muted] ml-1",children:"Files to push"}),b.map((e,t)=>(0,r.jsxs)("div",{className:"rounded-[--radius] border border-[--border]/60 bg-[--subtle]/30 p-3 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.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,r.jsx)(E,{size:"xs",rounded:!0,intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Remove file",onClick:()=>v(e=>e.filter((e,s)=>s!==t))})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(r0,{label:"Format",options:[{label:"native",value:"native"},{label:"warden",value:"warden"}],value:e.format,onValueChange:e=>v(s=>s.map((s,a)=>a===t?{...s,format:e}:s))}),(0,r.jsx)(r0,{label:"Scope",options:[{label:"local (own verdicts)",value:"local"},{label:"all (every source)",value:"all"}],value:e.scope,onValueChange:e=>v(s=>s.map((s,a)=>a===t?{...s,scope:e}:s))})]}),(null==m?void 0:m.capabilities.binary)&&(0,r.jsx)(rZ,{side:"right",label:"Compress (gzip)",value:e.gzip,onValueChange:e=>v(s=>s.map((s,a)=>a===t?{...s,gzip:e}:s))})]},t)),b.length<4&&(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(t2.Ca6,{}),"aria-label":"Add file",onClick:()=>v(e=>[...e,{format:"warden",scope:"local",gzip:!!(null==m?void 0:m.capabilities.binary)}])})}),k&&(0,r.jsx)(lN,{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,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:l,children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:N.isPending,onClick:()=>{if(!p.trim())return x.oR.error("a name is required");if(new Set(b.map(e=>`${e.format}:${e.scope}`)).size!==b.length)return x.oR.error("duplicate format/scope file");for(let e of(null==m?void 0:m.fields)??[]){let t=y[e.key];if(e.required&&"switch"!==e.type&&!String(t??"").trim()&&!(o&&e.secret))return x.oR.error(`${e.label} is required`)}N.mutate()},children:o?"Save":"Add target"})]})]})})}var o8=s(64422),o7=s(38390),de=s(40883);function dt(e){let{value:t,format:s,durationSec:a=.35,ease:l="easeOut"}=e,i=(0,nk.I)(),o=(0,o8.d)(t),d=(0,o7.G)(o,s),c=n.useRef(!1);return n.useEffect(()=>{let e=o.get(),s=Math.max(Math.abs(e),Math.abs(t)),r=s>0&&Math.abs(t-e)/s>.5;if(!c.current||i||r){c.current=!0,o.set(t);return}let n=(0,de.i)(o,t,{duration:a,ease:l});return()=>n.stop()},[t,a,l,i,o]),(0,r.jsx)(tB.P.span,{children:d})}let ds=["dashboard","streams"],da=[...ds,"live"],dr=[...ds,"bans"];function dn(e){return(null==e?void 0:e.tickMs)??500}let dl=null,di=0;function dd(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=(0,o.jE)();return n.useEffect(()=>{if(e)return di++,dl||((dl=new EventSource("/api/v1/dashboard/streams/live/stream",{withCredentials:!0})).onmessage=e=>{try{t.setQueryData(da,JSON.parse(e.data))}catch{}}),()=>{--di>0||(null==dl||dl.close(),dl=null)}},[t,e]),(0,ta.I)({queryKey:da,queryFn:()=>el("/dashboard/streams/live"),staleTime:1/0,enabled:e})}function dc(e){return(0,ta.I)({queryKey:[...ds,"bandwidth",e],queryFn:()=>el(`/dashboard/streams/bandwidth?window=${e}`),staleTime:15e3,refetchInterval:3e4})}function du(){let e=(0,o.jE)();return(0,e2.n)({mutationFn:e=>el("POST /dashboard/streams/bans",{body:e}),onSuccess:()=>
42{e.invalidateQueries({queryKey:dr}),e.invalidateQueries({queryKey:da})}})}let dm="aiostreams.proxy.generated",dp=nj.Ik({url:nj.Yj(),filename:nj.bz(),requestHeaders:nj.bz(),responseHeaders:nj.bz(),type:nj.bz(),encrypt:nj.bz()});function dh(e){r9(e,{onSuccess:()=>x.oR.success("Copied to clipboard"),onError:()=>x.oR.error("Failed to copy to clipboard")})}function dx(){let[e,t]=n.useState(!1),[s,a]=n.useState(null),l=(0,e2.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}}),[i,o]=n.useState(()=>{try{return JSON.parse(localStorage.getItem(dm)||"[]")}catch{return[]}});return(0,r.jsxs)(tJ,{open:e,onOpenChange:e=>{t(e),e||a(null)},title:"Generate proxy link",trigger:(0,r.jsx)(w,{intent:"primary-subtle",size:"sm",leftIcon:(0,r.jsx)(t2.Jty,{}),children:"Generate proxy link"}),children:[(0,r.jsx)(n$,{schema:dp,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 x.oR.error("URL is required");try{let t=await l.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,...i].slice(0,20);o(s),localStorage.setItem(dm,JSON.stringify(s))}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to generate")}},children:()=>(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(lx.Text,{name:"url",label:"URL",placeholder:"https://…"}),(0,r.jsx)(lx.Text,{name:"filename",label:"Filename (optional)"}),(0,r.jsx)(lI,{name:"requestHeaders",label:"Request headers",valueKind:"string"}),(0,r.jsx)(lI,{name:"responseHeaders",label:"Response headers",valueKind:"string"}),(0,r.jsx)(lx.Select,{name:"type",label:"Type",options:[{label:"Stream",value:"stream"},{label:"NZB",value:"nzb"}]}),(0,r.jsx)(lx.Switch,{name:"encrypt",label:"Encrypt payload",side:"right"}),(0,r.jsx)(lx.Submit,{loading:l.isPending,children:"Generate"})]})}),s&&(0,r.jsxs)("div",{className:"mt-4 flex items-center gap-2 rounded-lg bg-[--subtle] p-3",children:[(0,r.jsx)("code",{className:"flex-1 break-all text-xs",children:s}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(t2.Xpf,{}),onClick:()=>dh(s),children:"Copy"})]}),i.length>0&&(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)("p",{className:"mb-1 text-xs text-[--muted]",children:"Recent (this browser)"}),(0,r.jsx)("ul",{className:"max-h-40 space-y-1 overflow-auto",children:i.map((e,t)=>(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 break-all text-[10px] text-[--muted]",children:e}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.Xpf,{}),"aria-label":"Copy link",onClick:()=>dh(e)})]},t))})]})]})}let dg={usenet:{label:"Usenet",icon:t2.hQe,className:"border-indigo-500/40 bg-indigo-500/10 text-indigo-300"},proxy:{label:"Proxy",icon:t2.IS1,className:"border-teal-500/40 bg-teal-500/10 text-teal-300"}};function df(e){let{transport:t,className:s}=e,a=dg[t]??dg.proxy,n=a.icon;return(0,r.jsxs)("span",{className:b("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,r.jsx)(n,{className:"text-xs"}),a.label]})}let db="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 dv(e){let{children:t,className:s}=e;return(0,r.jsx)("span",{className:b(db,s),children:t})}function dy(e){let{reads:t}=e;return(0,r.jsxs)(tO,{trigger:(0,r.jsxs)(dv,{className:"border-amber-500/40 bg-amber-500/10 text-amber-300",children:[(0,r.jsx)(t2.P$d,{}),t]}),children:[t," range requests open at once — a player normally holds one."]})}function dj(e){let{ip:t}=e,[s,a]=n.useState(!1),l=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(l===t)return(0,r.jsx)(dv,{className:"font-mono",children:t});let i=s?"Hide client IP":"Reveal client IP";return(0,r.jsx)("button",{type:"button",onClick:()=>a(e=>!e),"aria-label":i,"aria-pressed":s,title:i,className:b(db,"font-mono transition-colors hover:border-[--muted] hover:text-[--foreground]"),children:s?t:l})}function dw(e){let{value:t,onChange:s,options:a,className:n}=e;return(0,r.jsx)("div",{role:"tablist",className:b("inline-flex items-center gap-0.5 rounded-lg border border-[--border] bg-[--subtle]/50 p-0.5",n),children:a.map(e=>{let a=e.value===t;return(0,r.jsx)("button",{role:"tab","aria-selected":a,onClick:()=>s(e.value),className:b("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 dN(e){return e.filename||e.displayUrl||e.targetKey}function dk(e){return e.size?Math.min(1,Math.max(0,(e.start+e.currentBytes)/e.size)):0}function dS(e){return e||"unidentified"}function dC(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 d_=[{label:"15 minutes",ms:9e5},{label:"1 hour",ms:36e5},{label:"24 hours",ms:864e5},{label:"7 days",ms:6048e5},{label:"Until lifted"}];function dA(e){let t,s,{stream:a,now:n,frameMs:l,onBlock:i}=e,d=dk(a),c="streaming"===a.activity,u=(t=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el(`DELETE /dashboard/streams/sessions/${encodeURIComponent(e)}`),onSuccess:()=>t.invalidateQueries({queryKey:da})})),m=(s=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el(`POST /dashboard/streams/users/${encodeURIComponent(e)}/kill`),onSuccess:()=>s.invalidateQueries({queryKey:da})})),p=!!a.username,h=(e,t)=>e.then(()=>x.oR.success(t)).catch(e=>x.oR.error((null==e?void 0:e.message)??"Action failed")),g=tX({title:"Stop this stream",description:(0,r.jsxs)(r.Fragment,{children:["End ",(0,r.jsx)("span",{className:"break-all",children:dN(a)})," for"," ",dS(a.username),". Their player will drop, and nothing prevents it reconnecting — use a block for that."]}),actionText:"Stop",actionIntent:"alert-subtle",onConfirm:()=>void h(u.mutateAsync(a.id),"Stream stopped")}),f=tX({title:`Stop all streams for ${dS(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 h(m.mutateAsync(a.username),"Stopped all their streams")});return(0,r.jsxs)("div",{className:"space-y-1.5 rounded-lg border border-[--border] bg-[--paper] p-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1.5",children:[(0,r.jsx)(df,{transport:a.transport}),a.activeReads>1&&(0,r.jsx)(dy,{reads:a.activeReads}),(0,r.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:dN(a),children:dN(a)}),(0,r.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-[--muted]",children:c?(0,r.jsx)(dt,{value:a.bytesPerSec,format:nt,durationSec:l/1e3}):(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",title:`No bytes for ${nd(a.idleMs)}`,children:[(0,r.jsx)(t2._5G,{}),"paused"===a.activity?"paused":"idle"]})}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2._6i,{}),"aria-label":"Stop stream",disabled:u.isPending,onClick:g.open}),children:"Stop this stream"}),(0,r.jsxs)(lZ,{align:"end",trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.voe,{}),"aria-label":"More actions"}),children:[(0,r.jsx)(lX,{children:p?dS(a.username):"Unidentified stream"}),(0,r.jsxs)(lQ,{disabled:!p,onSelect:()=>i({scope:"target",username:a.username,targetKey:a.targetKey,label:dN(a)}),children:[(0,r.jsx)(t2.PLI,{}),"Block this title…"]}),(0,r.jsx)(l0,{}),(0,r.jsxs)(lQ,{disabled:!p||m.isPending,onSelect:f.open,children:[(0,r.jsx)(t2._6i,{}),"Stop all their streams"]}
42),(0,r.jsxs)(lQ,{disabled:!p,onSelect:()=>i({scope:"user",username:a.username}),children:[(0,r.jsx)(t2.Jg2,{}),"Block this user…"]})]})]}),(0,r.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-[--subtle]",children:(0,r.jsx)("div",{className:b("h-full bg-brand transition-[width] ease-linear motion-reduce:transition-none",c&&"animate-pulse"),style:{width:`${100*d}%`,transitionDuration:`${l}ms`}})}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs tabular-nums text-[--muted]",children:[(0,r.jsx)(dv,{children:dS(a.username)}),a.clientIp&&(0,r.jsx)(dj,{ip:a.clientIp}),a.size>0&&(0,r.jsx)("span",{children:(0,r.jsx)(dt,{value:100*d,format:e=>`${Math.round(e)}%`,durationSec:l/1e3,ease:"linear"})}),(0,r.jsxs)("span",{children:[(0,r.jsx)(dt,{value:a.bytesServed,format:ne,durationSec:l/1e3,ease:"linear"}),a.size>0?` of ${ne(a.size)}`:""," served"]}),(0,r.jsxs)("span",{children:[a.requests," request",1===a.requests?"":"s"]}),(0,r.jsxs)("span",{children:[nd(n-a.startedAt)," elapsed"]})]}),(0,r.jsx)(t0,{...g}),(0,r.jsx)(t0,{...f})]})}function dR(e){let{target:t,onClose:s}=e,a=du(),[l,i]=n.useState("0"),[o,d]=n.useState("");if(n.useEffect(()=>{t&&(i("0"),d(""))},[t]),!t)return null;let c="user"===t.scope,u=async()=>{try{var e;let r=await a.mutateAsync({scope:t.scope,username:t.username,targetKey:t.targetKey,reason:o.trim()||void 0,durationMs:null==(e=d_[Number(l)])?void 0:e.ms});x.oR.success(r.stopped>0?`Blocked — stopped ${r.stopped} stream${1===r.stopped?"":"s"}`:"Blocked"),s()}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to block")}};return(0,r.jsx)(tJ,{open:!0,onOpenChange:e=>!e&&s(),title:c?`Block ${t.username}`:"Block this stream",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:c?(0,r.jsxs)(r.Fragment,{children:[(0,r.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-[--foreground]",children:t.username})," ","will not be able to reopen"," ",(0,r.jsx)("span",{className:"break-all text-[--foreground]",children:t.label||"this title"}),". Their other streams keep working."]})}),(0,r.jsx)(F,{label:"Duration",children:(0,r.jsx)(r0,{value:l,onValueChange:i,options:d_.map((e,t)=>({label:e.label,value:String(t)}))})}),(0,r.jsx)(F,{label:"Reason (optional)",children:(0,r.jsx)(G,{value:o,onValueChange:d,placeholder:"Shown on the Blocks list"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",size:"sm",onClick:s,children:"Cancel"}),(0,r.jsx)(w,{intent:"alert",size:"sm",loading:a.isPending,onClick:u,children:"Block"})]})]})})}let dT={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"}},dI=[{label:"All types",value:"all"},{label:"Usenet",value:"usenet"},{label:"Proxy",value:"proxy"}],dE=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}),dM=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}),dP=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"});function dD(e){let{used:t,limit:s}=e;if(s<=0)return(0,r.jsx)("span",{className:"tabular-nums",children:ne(t)});let a=Math.min(1,t/s);return(0,r.jsxs)("div",{className:"flex min-w-[160px] items-center gap-2",children:[(0,r.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-[--subtle]",children:(0,r.jsx)("div",{className:b("h-full",a>=1?"bg-red-400":a>=.85?"bg-amber-500":"bg-brand"),style:{width:`${100*a}%`}})}),(0,r.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-[--muted]",children:[ne(t)," / ",ne(s)]})]})}let d$=[{value:"total",label:"Total"},{value:"user",label:"By user"}];function dL(){let[e,t]=n.useState(!1),[s,a]=n.useState(""),[l,i]=n.useState("0"),[o,d]=n.useState(""),c=du(),u=async()=>
42{if(!s.trim())return void x.oR.error("Username is required");try{var e;await c.mutateAsync({scope:"user",username:s.trim(),reason:o.trim()||void 0,durationMs:null==(e=d_[Number(l)])?void 0:e.ms}),x.oR.success("Blocked"),t(!1),a(""),d("")}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to block")}};return(0,r.jsx)(tJ,{open:e,onOpenChange:t,title:"Block a user",trigger:(0,r.jsx)(w,{intent:"alert-subtle",size:"sm",leftIcon:(0,r.jsx)(t2.Ca6,{}),children:"Block a user"}),children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(F,{label:"Username",help:"Must match a username in AIOSTREAMS_AUTH.",children:(0,r.jsx)(G,{value:s,onValueChange:a,placeholder:"alice"})}),(0,r.jsx)(F,{label:"Duration",children:(0,r.jsx)(r0,{value:l,onValueChange:i,options:d_.map((e,t)=>({label:e.label,value:String(t)}))})}),(0,r.jsx)(F,{label:"Reason (optional)",children:(0,r.jsx)(G,{value:o,onValueChange:d})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"alert",size:"sm",loading:c.isPending,onClick:u,children:"Block"})]})]})})}function dO(e){let[t,s]=(0,n.useState)(!1);return(0,n.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 dU(e){if(e.name)return e.name;let t=e.path??"",s=t.lastIndexOf("/");return -1===s?t:t.slice(s+1)}function dF(e){var t;let{hash:s,name:a,open:n,onOpenChange:l}=e,i=(t=n?s:null,(0,ta.I)({queryKey:[...iN,"library","files",t],enabled:!!t,queryFn:()=>el(`/dashboard/usenet/library/${encodeURIComponent(t)}/files`)})),o=iR(),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=>x.oR.error((null==e?void 0:e.message)??"No playable source"))},u=i.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}(i.data.files):{},m=Object.keys(u).sort();return(0,r.jsx)(tJ,{open:n,onOpenChange:l,title:a||"Browse NZB",description:"Files in this NZB (including stored archive contents).",contentClass:"max-w-4xl",headerClass:"pr-8",children:(0,r.jsx)("div",{className:"max-h-[72vh] overflow-y-auto space-y-4",children:i.isLoading?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Loading…"}):i.isError?(0,r.jsx)("p",{className:"text-sm text-red-400",children:"Failed to load files."}):0===m.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No files."}):m.map(e=>{var t;let a;return(0,r.jsxs)("div",{children:[e&&(0,r.jsxs)("div",{className:"flex items-start gap-1.5 text-xs text-[--muted] mb-1",children:[(0,r.jsx)(t2.gNt,{className:"shrink-0 mt-0.5"}),(0,r.jsx)("span",{className:"min-w-0 break-all",children:e})]}),(0,r.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??"")||dU(e).localeCompare(dU(t)))).map((t,a)=>{let n=!1!==t.streamable;return(0,r.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,r.jsxs)("div",{className:"flex w-full min-w-0 items-start gap-2 sm:w-auto sm:flex-1",children:[(0,r.jsx)(t2.MG2,{className:"text-[--muted] shrink-0 mt-0.5"}),(0,r.jsx)("span",{className:"min-w-0 text-sm break-all",children:dU(t)})]}),t.category&&(0,r.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:t.category}),(0,r.jsx)("span",{className:"text-xs tabular-nums text-[--muted] shrink-0 sm:w-20 sm:text-right",children:ne(t.size)}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0 ml-auto sm:ml-0",children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(t2.UIR,{}),"aria-label":"Preview",disabled:!n,className:b(!n&&"opacity-40"),onClick:()=>c(t,!1)}),children:n?"Preview":"Not individually streamable"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.Ah9,{}),"aria-label":"Download",disabled:!n,className:b(!n&&"opacity-40"),onClick:()=>c(t,!0)}),children:n?"Download":"Not individually streamable"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.o9J,{}),"aria-label":"Copy download link",disabled:!n,className:b(!n&&"opacity-40"),onClick:()=>{s&&o.mutateAsync({hash:s,fileSel:d(t),download:!0}).then(e=>r9(window.location.origin+e.url,{onSuccess:()=>x.oR.success("Download link copied"),onError:()=>x.oR.error("Failed to copy link")})).catch(e=>x.oR.error((null==e?void 0:e.message)??"No downloadable source"))}}),children:"Copy download link"})]})]},`${e}-${a}`)})})]},e||"root")})})})}function dz(e,t){r9(e,{onSuccess:()=>x.oR.success(`${t} copied`),onError:()=>x.oR.error("Copy failed")})}function dV(e){let{label:t,value:s,onCopy:a,children:n}=e;return null!=s||n?(0,r.jsxs)("div",{className:"flex items-start gap-3 py-1.5 border-b border-[--border]/40 last:border-0",children:[(0,r.jsx)("span",{className:"w-28 shrink-0 text-xs font-medium text-[--muted] pt-0.5",children:t}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 text-sm flex items-center gap-2",children:[n??(0,r.jsx)("span",{className:"break-all",children:s}),a&&(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(t2.Xpf,{}),"aria-label":`Copy ${t}`,className:"shrink-0 ml-auto",onClick:a})]})]}):null}function dq(e){let{label:t,secret:s}=e,[a,l]=n.useState(!1);return(0,r.jsxs)(dV,{label:t,children:[(0,r.jsx)("span",{className:"font-mono break-all",children:a?s:"•".repeat(Math.min(s.length,12))}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:a?(0,r.jsx)(t2.MXC,{}):(0,r.jsx)(t2.Nyy,{}),"aria-label":a?`Hide ${t}`:`Show ${t}`,className:"shrink-0 ml-auto",onClick:()=>l(e=>!e)}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(t2.Xpf,{}),"aria-label":`Copy ${t}`,className:"shrink-0",onClick:()=>dz(s,t)})]})}function dB(e){let{url:t}=e;if(t.startsWith("local-nzb://"))return null;let s=t;try{s=new URL(t).hostname}catch{}
42return(0,r.jsxs)(dV,{label:"NZB URL",children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)("span",{className:"font-mono break-all cursor-default",children:s}),className:"max-w-md break-all",children:t}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(t2.Xpf,{}),"aria-label":"Copy NZB URL",className:"shrink-0 ml-auto",onClick:()=>dz(t,"NZB URL")})]})}let dK={wd1:"Portable release fingerprint based on indexer metadata (size, poster, date)",nh1:"Exact NZB content hash"};function dH(e){let{entry:t}=e,s=iw(t);return 0===s.length?null:(0,r.jsx)(dV,{label:1===s.length?"Release key":"Release keys",children:(0,r.jsx)("div",{className:"min-w-0 flex-1 flex flex-col gap-1",children:s.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(tO,{side:"left",trigger:(0,r.jsx)("span",{className:"font-mono text-xs break-all cursor-default",children:e}),children:dK[e.split(":")[0]]??"Blocklist key"}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(t2.Xpf,{}),"aria-label":"Copy release key",className:"shrink-0 ml-auto",onClick:()=>dz(e,"Release key")})]},e))})})}function dW(e){let{entry:t}=e,s=t.arrLink;if(!s)return null;let a=s.repair;return(0,r.jsx)(dV,{label:"Arr repair",value:(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.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,r.jsxs)("span",{className:"text-[--muted]",children:[" ","\xb7 ",a.attempts," attempt",1===a.attempts?"":"s"]}):null,(null==a?void 0:a.lastError)&&(0,r.jsx)("p",{className:"text-xs text-red-400 break-words",children:a.lastError})]})})}function dG(e){let{entry:t,open:s,onOpenChange:a}=e;return t?(0,r.jsx)(tJ,{open:s,onOpenChange:a,title:"NZB details",contentClass:"max-w-lg",children:(0,r.jsxs)("div",{className:b("mt-1"),children:[(0,r.jsx)(dV,{label:"Name",value:t.name||t.nzbHash,onCopy:()=>dz(t.name||t.nzbHash,"Name")}),(0,r.jsx)(dV,{label:"Status",value:t.status}),"failed"===t.status&&t.failReason&&(0,r.jsx)(dV,{label:"Error",value:t.failReason}),(0,r.jsx)(dV,{label:"Size",value:ne(t.size)}),(0,r.jsx)(dV,{label:"Files",value:`${t.files.length} file${1===t.files.length?"":"s"}`}),(0,r.jsx)(dV,{label:"Source",value:t.source}),t.owner&&(0,r.jsx)(dV,{label:"Added by",value:t.owner}),t.postedAt&&(0,r.jsx)(dV,{label:"Posted",value:nu(new Date(1e3*t.postedAt).toISOString())}),(0,r.jsx)(dV,{label:"Added",value:nu(t.addedAt)}),(0,r.jsx)(dV,{label:"Last used",value:nu(t.lastUsedAt)}),null!=t.importMs&&(0,r.jsx)(dV,{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,r.jsx)(dq,{label:"Password",secret:t.password}),t.nzbUrl&&(0,r.jsx)(dB,{url:t.nzbUrl}),(0,r.jsx)(dV,{label:"Hash",value:(0,r.jsx)("span",{className:"font-mono text-xs break-all",children:t.nzbHash}),onCopy:()=>dz(t.nzbHash,"Hash")}),(0,r.jsx)(dW,{entry:t}),(0,r.jsx)(dH,{entry:t})]})}):null}let dY={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"},dJ=[{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"}],dZ=[{value:"activity",label:"Recent activity"},{value:"added",label:"Date added"},{value:"name",label:"Name"},{value:"size",label:"Size"}],dQ={activity:"desc",added:"desc",name:"asc",size:"desc"},dX=[15,30,50,100],d0=dX.map(e=>({value:String(e),label:`${e} / page`})),d1="usenet.library.view",d2="usenet.library.pageSize";function d3(){try{return"list"===localStorage.getItem(d1)?"list":"grid"}catch{return"grid"}}function d5(){try{let e=Number(localStorage.getItem(d2));return dX.includes(e)?e:15}catch{return 15}}function d4(e){let{value:t,onChange:s}=e,a=(e,a,n)=>(0,r.jsx)("button",{type:"button","aria-label":n,"aria-pressed":t===e,onClick:()=>s(e),className:b("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,r.jsxs)("div",{className:"flex h-10 items-center gap-0.5 rounded-md border border-[--border] p-0.5",children:[a("grid",(0,r.jsx)(t2.fiy,{}),"Grid view"),a("list",(0,r.jsx)(t2.XfR,{}),"List view")]})}function d6(e){let{status:t}=e;return(0,r.jsx)("span",{className:b("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",dY[t]),children:t})}let d9={"application/x-nzb":[".nzb"],"application/xml":[".nzb"],"text/xml":[".nzb"]}
42;function d8(){let e,t,[s,a]=n.useState(""),[l,i]=n.useState(null),d=(e=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el("POST /dashboard/usenet/library",{body:e}),onSuccess:()=>e.invalidateQueries({queryKey:[...iN,"library"]})})),c=(t=(0,o.jE)(),(0,e2.n)({mutationFn:e=>{let t=new FormData;return t.append("file",e.file,e.file.name),e.name&&t.append("name",e.name),el("POST /dashboard/usenet/library/upload",{body:t})},onSuccess:()=>t.invalidateQueries({queryKey:[...iN,"library"]})})),u=e=>{"failed"===e.status?x.oR.error(e.failReason??"Import failed"):x.oR.success("NZB queued")},m=async e=>{i({done:0,total:e.length});let t=0;await Promise.all(e.map(async s=>{try{let e=await c.mutateAsync({file:s,name:s.name});u(e)}catch(e){x.oR.error(`${s.name}: ${(null==e?void 0:e.message)??"upload failed"}`)}finally{i({done:t+=1,total:e.length})}})),i(null)},p=()=>{let e=s.trim();e&&d.mutateAsync({url:e}).then(e=>{u(e),"failed"!==e.status&&a("")}).catch(e=>x.oR.error((null==e?void 0:e.message)??"Failed to add NZB"))};return(0,r.jsxs)(X,{className:"p-4 space-y-3",children:[(0,r.jsx)(ly,{title:"Add NZB",description:"Import .nzb files or paste a URL",icon:t2.K0Y,size:"md"}),(0,r.jsx)(n9,{accept:d9,multiple:!0,className:"min-h-[120px] w-full",dropzoneText:"Drop .nzb files here, or click to choose",onValueChange:e=>{e.length&&m(e)},onDropRejected:e=>{let t=e.map(e=>e.file.name);x.oR.error(1===t.length?`"${t[0]}" isn't a .nzb file`:`${t.length} files skipped, only .nzb files are supported`)}}),l&&(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["Importing ",l.done,"/",l.total,"…"]}),(0,r.jsxs)("div",{className:"flex items-stretch",children:[(0,r.jsx)(G,{leftIcon:(0,r.jsx)(t2.Jty,{}),placeholder:"…or add by URL: https://…/file.nzb",value:s,onValueChange:a,onKeyDown:e=>"Enter"===e.key&&p(),className:"flex-1 rounded-r-none"}),(0,r.jsx)(w,{intent:"primary",leftIcon:(0,r.jsx)(t2.Ca6,{}),loading:d.isPending,onClick:p,disabled:!s.trim(),className:"rounded-l-none shrink-0",children:"Add"})]})]})}function d7(e){var t;let{entry:s,onBrowse:a,onInfo:n,onBlock:l,onUnblock:i,onRequeue:o,onRepair:d,onDelete:c}=e,u=iR(),m="available"===s.status||"degraded"===s.status,p=s.files.length>1,h=m&&!p,g=e=>{u.mutateAsync({hash:s.nzbHash,download:e}).then(e=>window.open(e.url,"_blank")).catch(e=>x.oR.error((null==e?void 0:e.message)??"No playable source"))},f=iw(s);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(t2.uwC,{}),onClick:()=>a(s),children:"Browse"}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(t2.UIR,{}),"aria-label":"Preview",disabled:!h,onClick:()=>g(!1)}),children:p?"Browse to pick a file":"Preview"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.Ah9,{}),"aria-label":"Download",disabled:!h,onClick:()=>g(!0)}),children:p?"Browse to pick a file":"Download"}),(0,r.jsxs)(lZ,{align:"end",trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.voe,{}),"aria-label":"More actions"}),children:[(0,r.jsxs)(lQ,{onSelect:()=>n(s),children:[(0,r.jsx)(t2.wfp,{}),"Details"]}),(0,r.jsxs)(lQ,{onSelect:()=>o([s.nzbHash]),disabled:!s.nzbUrl,children:[(0,r.jsx)(t2.Zxy,{}),s.nzbUrl?"Requeue import":"No source NZB to re-import"]}),(0,r.jsxs)(lQ,{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,r.jsx)(t2.w4m,{}),"Export NZB"]}),s.arrLink&&(0,r.jsxs)(lQ,{onSelect:()=>d(s),children:[(0,r.jsx)(t2.x8l,{}),(null==(t=s.arrLink.repair)?void 0:t.state)==="failed"?"Retry repair":"Replace via Sonarr/Radarr"]}),f.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l0,{}),(0,r.jsxs)(lQ,{onSelect:()=>s.blocked?i(s):l(s),children:[s.blocked?(0,r.jsx)(t2.DNZ,{}):(0,r.jsx)(t2.PLI,{}),s.blocked?"Unblock release":"Block release"]})]})]}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Delete entry",onClick:()=>c(s.nzbHash)}),children:"Delete"})]})]})}function ce(e){let{entry:t,view:s,selectMode:a,selected:n,onToggleSelect:l,onBrowse:i,onInfo:o,onBlock:d,onUnblock:c,onRequeue:u,onRepair:m,onDelete:p}=e,h=t.name||t.nzbHash,x=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:ne(t.size)}),(0,r.jsxs)("span",{children:[t.files.length," file",1===t.files.length?"":"s"]}),"sabnzbd"===t.origin&&(0,r.jsx)("span",{title:"Added through the SABnzbd API (Sonarr, Radarr, NZBHydra, …)",children:t.hiddenAt?"sab \xb7 imported":"sab"})]}),g=b("transition-[background-color,box-shadow] duration-200",a&&"cursor-pointer hover:bg-[--subtle]/30",n&&"ring-1 ring-inset ring-brand/60 bg-brand/[0.06]"),f=a?()=>l(t,!n):void 0;return"list"===s?(0,r.jsx)(X,{className:b(g,"p-3"),onClick:f,children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block font-medium text-sm break-all line-clamp-1",children:h}),(0,r.jsxs)("div",{className:"mt-0.5 flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-[--muted]",children:[x,"failed"===t.status&&t.failReason&&(0,r.jsx)("span",{className:"text-red-400",title:t.errorCode,children:t.failReason})]})]}),(0,r.jsx)(d6,{status:t.status}),!a&&(0,r.jsx)("div",{className:"shrink-0",children:(0,r.jsx)(d7,{entry:t,onBrowse:i,onInfo:o,onBlock:d,onUnblock:c,onRequeue:u,onRepair:m,onDelete:p})})]})}):(0,r.jsxs)(X,{className:b(g,"flex flex-col h-full p-3 sm:p-4"),onClick:f,children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)("span",{className:"min-w-0 flex-1 font-medium text-sm break-all line-clamp-2",children:h}),children:h}),(0,r.jsx)(d6,{status:t.status})]}),"failed"===t.status&&t.failReason&&(0,r.jsx)("p",{className:"text-xs text-red-400 mt-0.5",title:t.errorCode,children:t.failReason}),(0,r.jsx)("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-[--muted]",children:x})]}),!a&&(0,r.jsx)("div",{className:"mt-auto pt-3",children:(0,r.jsx)(d7,{entry:t,onBrowse:i,onInfo:o,onBlock:d,onUnblock:c,onRequeue:u,onRepair:m,onDelete:p})})]})}let ct=[{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 cs(e){var t,s;let a=null==(t=ct.find(t=>t.value===e))?void 0:t.hours;return void 0===a?void 0:(s=Date.now())-s%36e5-(a-1)*36e5}function ca(e){let{target:t,onClose:s}=e,[a,l]=n.useState("all"),[i,o]=n.useState(null),d=iA(),c=iA();if(n.useEffect(()=>{t&&l("all")},[t]),n.useEffect(()=>{if(!t)return;let e=!0;return o(null),d.mutateAsync({target:t.target,id:t.id,sinceMs:cs(a),dryRun:!0}).then(t=>{e&&o(t)}).catch(()=>{}),()=>{e=!1}},[null==t?void 0:t.target,null==t?void 0:t.id,a]),!t)return null;let u=async()=>{try{let e=await c.mutateAsync({target:t.target,id:t.id,sinceMs:cs(a)}),r=e.providerRows+e.indexerRows;x.oR.success(0===r?"Nothing to reset":`Reset ${nc(r)} hourly row${1===r?"":"s"}`),s()}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to reset stats")}};return(0,r.jsx)(tJ,{open:!0,onOpenChange:e=>!e&&s(),title:`Reset stats — ${t.label}`,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Deletes the recorded history for"," ",(0,r.jsx)("span",{className:"text-[--foreground]",children:t.label}),". Charts and totals are rebuilt from what is left, and this cannot be undone."]}),(0,r.jsx)(F,{label:"Range",children:(0,r.jsx)(r0,{value:a,onValueChange:l,options:ct.map(e=>({label:e.label,value:e.value}))})}),(0,r.jsx)("p",{className:"text-sm tabular-nums",children:i?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(`${ne(t.providerBytes)}, ${nc(t.providerArticles)} articles`),"providers"!==e&&t.indexerRows>0&&a.push(`${nc(t.indexerGrabs)} grabs`);let r=1===s?"row":"rows";return`Removes ${nc(s)} hourly ${r}${a.length?` (${a.join(" \xb7 ")})`:""}.`}
42(t.target,i):(0,r.jsx)("span",{className:"text-[--muted]",children:"Checking what this removes…"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:s,children:"Cancel"}),(0,r.jsx)(w,{intent:"alert",loading:c.isPending,disabled:(null==i?void 0:i.providerRows)===0&&(null==i?void 0:i.indexerRows)===0,onClick:u,children:"Reset stats"})]})]})})}let cr=["24h","7d","30d","all"];function cn(e){let{value:t,onChange:s}=e;return(0,r.jsx)("div",{className:"flex gap-1",children:cr.map(e=>(0,r.jsx)("button",{onClick:()=>s(e),className:b("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 cl={online:"bg-emerald-500",connecting:"bg-amber-500",offline:"bg-[--muted]",auth_failed:"bg-red-400",disabled:"bg-[--muted]/40"};function ci(e){let t=Date.now()-e;return t<1e3?"just now":`${no(t)} ago`}function co(e){let{p:t,health:s}=e;return(0,r.jsx)(L,{modal:!1,align:"start",className:"w-80",trigger:(0,r.jsx)("button",{type:"button","aria-label":`${t.name||t.id}: ${s.label}. Show details`,className:b("shrink-0 -my-1 p-1 rounded-full transition-opacity hover:opacity-70","bad"===s.tone?"text-red-400":"text-amber-500"),children:(0,r.jsx)(t2.wew,{className:"w-4 h-4"})}),children:(0,r.jsxs)("div",{className:"space-y-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:b("w-2 h-2 rounded-full shrink-0",s.cls)}),(0,r.jsx)("span",{className:"text-sm font-semibold",children:s.label})]}),s.hint&&(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:s.hint}),t.lastDialError&&(0,r.jsxs)("div",{className:"rounded-[--radius] bg-[--subtle] p-2 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium",children:t.lastDialError.kind}),(0,r.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:ci(t.lastDialError.at)})]}),(0,r.jsx)("p",{className:"text-xs text-[--muted] break-words",children:t.lastDialError.message})]}),(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:[t.lastDialOkAt?`Last successful connection ${ci(t.lastDialOkAt)}`:"No successful connection recorded",t.queued>0&&` \xb7 ${t.queued} queued in pool`]})]})})}function cd(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 cc(){let e=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=(0,o.jE)();return n.useEffect(()=>{if(e)return i_++,iC||((iC=new EventSource("/api/v1/dashboard/usenet/live/stream",{withCredentials:!0})).onmessage=e=>{try{t.setQueryData(iS,JSON.parse(e.data))}catch{}}),()=>{--i_>0||(null==iC||iC.close(),iC=null)}},[t,e]),(0,ta.I)({queryKey:iS,queryFn:()=>el("/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]=n.useState(!1),a=n.useRef(null),r=(null==e?void 0:e.providers.reduce((e,t)=>e+t.queued,0))??0,l=(null==e?void 0:e.globalDownloadsOnWire)??0;return n.useEffect(()=>{r>0&&0===l?(a.current??(a.current=Date.now()),s(Date.now()-a.current>6e4)):(a.current=null,s(!1))},[r,l,e]),t}(s),l=(null==s?void 0:s.providers.some(e=>e.isBackup))??!1,i=(null==e?void 0:e.tickMs)??500;return(0,r.jsxs)("div",{className:"space-y-4",children:[a&&(0,r.jsx)(lN,{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,r.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,r.jsx)(on,{label:"Active streams",value:t?String(t.activeStreams):"—",hint:s?cd(s):""}),(0,r.jsx)(on,{label:"Download speed",value:t?(0,r.jsx)(dt,{value:t.currentBytesPerSec,format:nt,durationSec:i/1e3}):"—",hint:t?`peak ${nt(t.peakBytesPerSec)}`:""}),(0,r.jsx)(on,{label:"Articles / min",value:t?(0,r.jsx)(dt,{value:t.articlesLastMinute,format:e=>nc(Math.round(e)),durationSec:i/1e3}):"—",hint:t?`${t.errorsLastMinute} errors`:""}),(0,r.jsx)(on,{label:"Cache hit rate",value:e?(0,r.jsx)(dt,{value:e.cache.hitRate,format:na,durationSec:i/1e3}):"—",hint:e?`${ne(e.cache.diskBytes)} on disk`:""})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex items-baseline justify-between mb-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Live connections"}),(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:[s?cd(s):"0 downloading \xb7 0 queued",l?" \xb7 includes backup capacity":""]})]}),s&&0!==s.providers.length?(0,r.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 ski
42p 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,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)("span",{className:b("w-2 h-2 rounded-full shrink-0",t.cls)}),children:t.label}),(0,r.jsxs)("span",{className:"text-sm font-medium w-40 truncate flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"truncate",children:e.name||e.id}),e.isBackup&&(0,r.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:"backup"}),s&&(0,r.jsx)(co,{p:e,health:t})]}),(0,r.jsxs)("div",{className:"relative flex-1 h-1.5 rounded-full bg-[--subtle] overflow-hidden",children:[(0,r.jsx)("div",{className:b("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:`${i}ms`}}),(0,r.jsx)("div",{className:b("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:`${i}ms`}})]}),(0,r.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(dt,{value:e.throughput,format:nt,durationSec:i/1e3}),"/conn"]}):"—"}),(0,r.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,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No active provider pools. Connections open on demand when streaming."})]})]})}function cu(e){let{id:t}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"font-medium text-[--muted]",title:t,children:"Removed provider"}),(0,r.jsx)("span",{className:"text-xs text-[--muted] tabular-nums",title:t,children:t.slice(0,8)})]})}function cm(e){let{providers:t,onReset:s}=e;return 0===t.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No provider activity recorded in this window yet."}):(0,r.jsx)("div",{className:"overflow-x-auto -mx-4 px-4 lg:mx-0 lg:px-0",children:(0,r.jsxs)("table",{className:"w-full text-sm min-w-[720px]",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase",children:(0,r.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,r.jsx)("th",{className:"py-2 pr-3",children:"Provider"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Share"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Data"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Avg speed"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Articles"}),(0,r.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,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Errors"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Missing"}),(0,r.jsx)("th",{className:"py-2 pl-3 w-8","aria-label":"Actions"})]})}),(0,r.jsx)("tbody",{children:t.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,r.jsx)("td",{className:"py-2 pr-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:b("w-2 h-2 rounded-full shrink-0",cl[e.live.state]),title:e.live.state}),e.removed?(0,r.jsx)(cu,{id:e.id}):(0,r.jsx)("span",{className:"font-medium",children:e.name||e.host}),e.isBackup&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"backup"}),e.removed?(0,r.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-[--radius] bg-[--subtle] text-[--muted]",children:"removed"}):!e.enabled&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"(disabled)"})]})}),(0,r.jsx)("td",{className:"py-2 px-3 text-right",children:(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("div",{className:"w-16 h-1 rounded-full bg-[--subtle] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-brand",style:{width:`${100*e.articleShare}%`}})}),(0,r.jsx)("span",{className:"tabular-nums w-10 text-right",children:na(e.articleShare)})]})}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:ne(e.bytes)}),(0,r.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?nt(e.avgBytesPerSec):"—"}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:nc(e.articles)}),(0,r.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,r.jsx)("td",{className:b("py-2 px-3 text-right tabular-nums",e.errorRate>.1&&"text-red-400"),children:na(e.errorRate)}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums text-[--muted]",children:na(e.missRate)}),(0,r.jsx)("td",{className:"py-2 pl-3 text-right",children:(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.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 cp(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 ch(e){let{indexer:t,error:s,breakdown:a}=e,n=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,r.jsx)(L,{modal:!1,align:"start",className:"w-80",trigger:(0,r.jsx)("button",{type:"button","aria-label":`${t}: ${n.label}. Show details`,className:b("shrink-0 -my-1 p-1 rounded-full transition-opacity hover:opacity-70","bad"===n.tone?"text-red-400":"text-amber-500"),children:(0,r.jsx)(t2.wew,{className:"w-4 h-4"})}),children:(0,r.jsxs)("div",{className:"space-y-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:b("w-2 h-2 rounded-full shrink-0","bad"===n.tone?"bg-red-400":"bg-amber-500")}),(0,r.jsx)("span",{className:"text-sm font-semibold",children:n.label})]}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:n.hint}),(0,r.jsxs)("div",{className:"rounded-[--radius] bg-[--subtle] p-2 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium",children:"Last grab error"}),(0,r.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:ci(s.atMs)})]}),(0,r.jsx)("p",{className:"text-xs text-[--muted] break-words",children:s.message})]}),a&&(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["Failed in this window: ",a]})]})})}function cx(e){let{indexers:t,onReset:s}=e;return 0===t.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No grabs recorded in this window yet."}):(0,r.jsx)("div",{className:"overflow-x-auto -mx-4 px-4 lg:mx-0 lg:px-0",children:(0,r.jsxs)("table",{className:"w-full text-sm min-w-[720px]",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase",children:(0,r.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,r.jsx)("th",{className:"py-2 pr-3",children:"Indexer"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Share"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Grabs"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",title:"Grabs whose import produced a streamable entry (degraded included).",children:"Success"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Failed"}),(0,r.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,r.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,r.jsx)("th",{className:"py-2 pl-3 w-8","aria-label":"Actions"})]})}),(0,r.jsx)("tbody",{children:t.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,r.jsx)("td",{className:"py-2 pr-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-medium",children:e.indexer}),e.lastError&&Date.now()-e.lastError.atMs<864e5&&(0,r.jsx)(ch,{indexer:e.indexer,error:e.lastError,breakdown:e.failed>0?cp(e):void 0})]})}),(0,r.jsx)("td",{className:"py-2 px-3 text-right",children:(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("div",{className:"w-16 h-1 rounded-full bg-[--subtle] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-brand",style:{width:`${100*e.grabShare}%`}})}),(0,r.jsx)("span",{className:"tabular-nums w-10 text-right",children:na(e.grabShare)})]})}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:nc(e.grabs)}),(0,r.jsx)("td",{className:b("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:na(e.successRate)}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",title:e.failed>0?cp(e):void 0,children:nc(e.failed)}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:null==e.avgGrabMs?"—":no(e.avgGrabMs)}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:null==e.avgImportMs?"—":no(e.avgImportMs)}),(0,r.jsx)("td",{className:"py-2 pl-3 text-right",children:(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.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 cg(e){let{label:t,onClick:s}=e;return(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.sxT,{}),onClick:s,"aria-label":t}),children:t})}function cf(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}}),n=t.providers.filter(e=>e.articles>0).slice(0,6).map(e=>({name:e.name||e.host,value:e.articles})),l=t.indexers.reduce((e,t)=>e+t.grabs,0),i=t.indexers.filter(e=>e.grabs>0).slice(0,6).map(e=>({name:e.indexer,value:e.grabs}));return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3",children:[(0,r.jsx)(on,{label:"Data downloaded",value:ne(t.totals.bytes)}),(0,r.jsx)(on,{label:"Avg download speed",value:t.totals.avgBytesPerSec?nt(t.totals.avgBytesPerSec):"—",hint:`avg while streaming \xb7 ${t.window}`}),(0,r.jsx)(on,{label:"Articles",value:nc(t.totals.articles)}),(0,r.jsx)(on,{label:"Avg latency",value:null==t.totals.avgLatencyMs?"—":`${t.totals.avgLatencyMs}ms`,hint:t.totals.avgArticleMs?`${t.totals.avgArticleMs}ms per whole article`:""}),(0,r.jsx)(on,{label:"Error rate",value:na(t.totals.articles+t.totals.errors>0?t.totals.errors/(t.totals.articles+t.totals.errors):0)})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Data downloaded"}),0===a.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No data for this window yet."}):(0,r.jsx)(ot,{data:a,xKey:"t",series:[{key:"bytes",label:"Downloaded",color:"var(--brand)"}],height:240,valueFormatter:e=>ne(Number(e)),yTickFormatter:e=>ne(Number(e))})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Provider performance"}),(0,r.jsx)(cg,{label:"Reset all provider stats",onClick:()=>s({target:"providers",label:"All providers"})})]}),n.length>0?(0,r.jsxs)("div",{className:"grid lg:grid-cols-[1fr,240px] gap-6 items-center",children:[(0,r.jsx)(cm,{providers:t.providers,onReset:s}),(0,r.jsx)("div",{className:"mx-auto w-full max-w-[240px] aspect-square",children:(0,r.jsx)(oa,{data:n,centerLabel:"articles",centerValue:nc(t.totals.articles),height:240})})]}):(0,r.jsx)(cm,{providers:t.providers,onReset:s})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Indexer performance"}),(0,r.jsx)(cg,{label:"Reset all indexer stats",onClick:()=>s({target:"indexers",label:"All indexers"})})]}),i.length>0?(0,r.jsxs)("div",{className:"grid lg:grid-cols-[1fr,240px] gap-6 items-center",children:[(0,r.jsx)(cx,{indexers:t.indexers,onReset:s}),(0,r.jsx)("div",{className:"mx-auto w-full max-w-[240px] aspect-square",children:(0,r.jsx)(oa,{data:i,centerLabel:"grabs",centerValue:nc(l),height:240})})]}):(0,r.jsx)(cx,{indexers:t.indexers,onReset:s})]})]})}function cb(e){let{intent:t,children:s}=e;return(0,r.jsx)("span",{className:b("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 cv(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 cy(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 cj(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 cw(e){let t,{providers:s}=e,[a,l]=n.useState(()=>cy(s.map(cv))),[i,d]=n.useState({}),[c,u]=n.useState({}),m=(t=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el("PUT /dashboard/usenet/providers",{body:{providers:e}}),onSuccess:()=>{t.invalidateQueries({queryKey:[...iN,"providers"]}),t.invalidateQueries({queryKey:[...iN,"stats"]})}})),p=(0,e2.n)({mutationFn:e=>el("POST /dashboard/usenet/providers/test",{body:e})}),h=(0,e2.n)({mutationFn:e=>el(`POST /dashboard/usenet/providers/${encodeURIComponent(e)}/speedtest`)}),g=n.useMemo(()=>new Set(s.map(e=>e.id)),[s]),f=n.useMemo(()=>JSON.stringify(s),[s]),b=n.useRef(f);n.useEffect(()=>{f!==b.current&&(b.current=f,l(cy(s.map(cv))),d({}),u({}))},[f,s]);let v=async e=>{d(t=>({...t,[e.id]:"pending"}));try{let t=await p.mutateAsync(cj(e));d(s=>({...s,[e.id]:t})),t.ok?x.oR.success(`${e.name||e.host}: connected in ${t.latencyMs}ms`):x.oR.error(`${e.name||e.host}: ${t.error??"failed"}`)}catch(s){let t={ok:!1,error:(null==s?void 0:s.message)??"failed"};d(s=>({...s,[e.id]:t})),x.oR.error(`${e.name||e.host}: ${t.error}`)}},y=async e=>{u(t=>({...t,[e.id]:"pending"}));try{let t=await h.mutateAsync(e.id);u(s=>({...s,[e.id]:t})),t.ok?x.oR.success(`${e.name||e.host}: ${nt(t.bytesPerSec??0)}`):x.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"};u(s=>({...s,[e.id]:t})),x.oR.error(`${e.name||e.host}: ${t.error}`)}},j=async()=>{for(let e of a)if(!e.host.trim())return void x.oR.error("Every provider needs a host.");try{await m.mutateAsync(a.map(cj)),x.oR.success("Providers saved.")}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to save providers")}},N=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,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"NNTP providers"}),(0,r.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,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(t2.Ca6,{}),onClick:()=>l(e=>{var t,s;return cy([...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,r.jsx)(X,{className:"p-6 text-center text-sm text-[--muted]",children:"No providers configured yet. Add your first NNTP account to start streaming."}),(0,r.jsx)("div",{className:"space-y-3",children:N.map(e=>(0,r.jsx)("div",{className:"space-y-px",children:e.map((t,s)=>(0,r.jsx)(cC,{draft:t,grouped:e.length>1,isGroupHead:0===s,isGroupTail:s===e.length-1,canGroupUp:t.priority>1,canUngroup:e.length>1,testResult:i[t.id],speedResult:c[t.id],canSpeedTest:g.has(t.id),onChange:e=>{let s;return s=t.id,l(t=>t.map(t=>
42t.id===s?{...t,...e}:t))},onSetPriority:e=>{let s;return s=t.id,l(t=>{let a=Math.max(1,Math.round(e)||1);return cy(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,l(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 cy(t.map(t=>t.id===e?{...t,priority:r,isBackup:n}:t))})},onUngroup:()=>{let e;return e=t.id,l(t=>{let s=t.find(t=>t.id===e);return!s||t.filter(e=>e.priority===s.priority).length<=1?t:cy(t.map(t=>t.id===e?{...t,priority:t.priority+.5}:t))})},onSetBackup:e=>{let s;return s=t.id,l(t=>{let a=t.find(e=>e.id===s);return a?cy(t.map(t=>t.priority===a.priority?{...t,isBackup:e}:t)):t})},onRemove:()=>{let e;return e=t.id,l(t=>cy(t.filter(t=>t.id!==e)))},onTest:()=>v(t),onSpeedTest:()=>y(t)},t.id))},e[0].id))}),(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(w,{intent:"primary",loading:m.isPending,onClick:j,children:"Save providers"})})]})}function cN(e){let{result:t}=e;return"pending"===t?(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"testing…"}):t?t.ok?(0,r.jsxs)(cb,{intent:"success",children:[(0,r.jsx)(t2.qGT,{})," ",t.latencyMs,"ms"]}):(0,r.jsxs)(cb,{intent:"alert",children:[(0,r.jsx)(t2.wew,{})," ",t.code??"failed"]}):null}function ck(e){let{result:t}=e;if("pending"===t)return(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"speed testing…"});if(!t)return null;if(!t.ok)return(0,r.jsxs)(cb,{intent:"warning",children:[(0,r.jsx)(t2.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,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsxs)(cb,{intent:"success",children:[(0,r.jsx)(t2.I2B,{})," ",nt(t.bytesPerSec??0)]}),s?(0,r.jsx)("span",{className:"text-[10px] text-[--muted]",title:`Fanned out across ${t.connections} connections, pipeline depth ${t.pipelineDepth??1}`,children:s}):null]})}function cS(e){let{value:t,onCommit:s}=e,a=n.useRef(t);return n.useEffect(()=>{a.current=t},[t]),(0,r.jsx)("div",{onBlur:()=>a.current!==t&&s(a.current),children:(0,r.jsx)(n1,{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 cC(e){let{draft:t,grouped:s,isGroupHead:a,isGroupTail:n,canGroupUp:l,canUngroup:i,testResult:o,speedResult:d,canSpeedTest:c,onChange:u,onSetPriority:m,onGroupUp:p,onUngroup:h,onSetBackup:x,onRemove:g,onTest:f,onSpeedTest:v}=e,y="pending"===o,j="pending"===d,w=tX({title:"Delete provider?",description:(0,r.jsxs)(r.Fragment,{children:["Are you sure you want to remove"," ",(0,r.jsx)("strong",{children:t.name||t.host||"this provider"}),"?"]}),actionText:"Delete",actionIntent:"alert-subtle",onConfirm:g});return(0,r.jsxs)(X,{className:b("p-4 transition-opacity duration-300",!t.enabled&&"opacity-60",s&&"border-l-2 border-l-[--brand]",s&&!a&&"rounded-t-none",s&&!n&&"rounded-b-none"),children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center gap-1 pt-1",children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(t2.mlL,{}),disabled:!l,onClick:p,"aria-label":"Group with provider above"}),children:"Group with the provider above"}),(0,r.jsx)(cS,{value:t.priority,onCommit:m}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(t2.nwe,{}),disabled:!i,onClick:h,"aria-label":"Split out of group"}),children:"Split out into its own priority"})]}),(0,r.jsxs)("div",{className:"flex-1 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 flex-1 min-w-[180px]",children:[(0,r.jsx)("span",{className:"font-medium text-sm",children:t.name||t.host||"New provider"}),t.isBackup&&(0,r.jsx)(cb,{intent:"warning",children:"backup"}),s&&(0,r.jsx)(cb,{intent:"success",children:"load-balanced"}),(0,r.jsx)(cN,{result:o}),(0,r.jsx)(ck,{result:d})]}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.UWw,{}),onClick:f,loading:y,disabled:!t.host||y,"aria-label":"Test provider"}),children:"Test connection"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.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,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:t.enabled?"success-subtle":"gray-subtle",icon:t.enabled?(0,r.jsx)(J.lXh,{}):(0,r.jsx)(J.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,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),onClick:w.open,"aria-label":"Remove provider"}),children:"Remove provider"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[(0,r.jsx)(F,{label:"Name",children:(0,r.jsx)(G,{value:t.name,placeholder:"Friendly name",onValueChange:e=>u({name:e})})}),(0,r.jsx)(F,{label:"Host",className:"lg:col-span-2",children:(0,r.jsx)(G,{value:t.host,placeholder:"news.example.com",onValueChange:e=>u({host:e})})}),(0,r.jsx)(F,{label:"Port",children:(0,r.jsx)(n1,{value:t.port,min:1,max:65535,hideControls:!0,onValueChange:e=>u({port:e||0})})}),(0,r.jsx)(F,{label:"Max connections",children:(0,r.jsx)(n1,{value:t.maxConnections,min:1,onValueChange:e=>u({maxConnections:e||1})})}),(0,r.jsx)(F,{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,r.jsx)(n1,{value:t.pipelineDepth,min:1,max:20,onValueChange:e=>u({pipelineDepth:Math.min(20,Math.max(1,e||1))})})}),(0,r.jsx)(F,{label:"Username",children:(0,r.jsx)(G,{value:t.username,autoComplete:"off",onValueChange:e=>u({username:e})})}),(0,r.jsx)(F,{label:"Password",className:"lg:col-span-2",children:(0,r.jsx)(Z,{value:t.password,autoComplete:"new-password",placeholder:t.hasPassword?"•••••••• (unchanged)":"",onValueChange:e=>u({password:e})})})]}),(0,r.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,r.jsx)(rZ,{value:t.tls,onValueChange:e=>u({tls:e}),label:"SSL/TLS",side:"right"}),(0,r.jsx)(rZ,{value:t.isBackup,onValueChange:x,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,r.jsx)(rZ,{value:t.tlsSkipVerify,onValueChange:e=>u({tlsSkipVerify:e}),label:"Skip TLS verify",side:"right"})]})]})]}),(0,r.jsx)(t0,{...w})]})}let c_=["dashboard","community"];function cA(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,ta.I)({queryKey:[...c_,"items",s],queryFn:()=>el(`/dashboard/community/items${s?`?${s}`:""}`),placeholderData:ij.rX,staleTime:1e4})}function cR(e){let t=(0,o.jE)();return(0,e2.n)({mutationFn:e,onSuccess:()=>{t.invalidateQueries({queryKey:c_}),t.invalidateQueries({queryKey:["community"]})}})}let cT=e=>`/dashboard/community/items/${encodeURIComponent(e)}`;function cI(){return cR(e=>el(`DELETE ${cT(e)}`))}function cE(e){let{kind:t}=e;return(0,r.jsx)(dv,{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 cM(e){let{tags:t}=e;return 0===t.length?null:(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:t.map(e=>(0,r.jsx)(dv,{children:e},e))})}function cP(e){let{kind:t,payload:s}
42=e,[a,l]=(0,n.useState)("formatter"===t);if("formatter"===t){let e=s??{};return(0,r.jsxs)("div",{className:"space-y-2 text-xs",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:"Name"}),(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words rounded border border-[--border] bg-[--subtle]/40 p-2",children:e.name})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:"Description"}),(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-words rounded border border-[--border] bg-[--subtle]/40 p-2",children:e.description})]})]})}return(0,r.jsxs)("div",{className:"text-xs",children:[(0,r.jsxs)("button",{type:"button",className:"text-[--brand] hover:underline",onClick:()=>l(e=>!e),children:[a?"Hide":"Show"," template JSON"]}),a&&(0,r.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 cD(e){var t,s;let{summary:a}=e,n=a.presets.filter(e=>e.urlOptions.some(e=>e.differsFromDefault));return(0,r.jsxs)("div",{className:"space-y-3 rounded border border-[--border] bg-[--subtle]/30 p-3 text-xs",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:"Addons"}),a.presetsInspected?0===a.presets.length?(0,r.jsx)("p",{className:"text-[--muted]",children:"No addons."}):(0,r.jsx)("ul",{className:"space-y-1",children:a.presets.map((e,t)=>(0,r.jsxs)("li",{className:"flex flex-wrap gap-x-2",children:[(0,r.jsx)("span",{className:"font-medium",children:e.name??e.type}),(0,r.jsxs)("span",{className:"text-[--muted]",children:["(",e.type,")"]}),e.urlOptions.map(e=>(0,r.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,r.jsx)("p",{className:"text-yellow-300",children:"The addon list is a template directive, so it could not be inspected. Read the JSON below."}),n.length>0&&(0,r.jsxs)("p",{className:"mt-1 text-red-200",children:[n.length," addon",1===n.length?"":"s"," point at a non-default host. Those hosts may receive the service credentials of anyone who applies this template."]})]}),a.changelogUrl&&(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:"Changelog URL"}),(0,r.jsx)("p",{className:"break-all font-mono",children:a.changelogUrl}),(0,r.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,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:["Regex patterns (",a.regexPatterns.length,")"]}),0===a.regexPatterns.length?(0,r.jsx)("p",{className:"text-[--muted]",children:"None."}):(0,r.jsx)("ul",{className:"max-h-40 space-y-0.5 overflow-auto font-mono",children:a.regexPatterns.map((e,t)=>(0,r.jsx)("li",{className:"break-all",children:e},t))})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"mb-1 uppercase tracking-wide text-[--muted]",children:["Synced URLs (",a.syncedUrls.length,")"]}),0===a.syncedUrls.length?(0,r.jsx)("p",{className:"text-[--muted]",children:"None."}):(0,r.jsx)("ul",{className:"max-h-40 space-y-0.5 overflow-auto font-mono",children:a.syncedUrls.map((e,t)=>(0,r.jsx)("li",{className:"break-all",children:e},t))})]}),(0,r.jsxs)("div",{children:[(0,r.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,r.jsxs)("div",{className:"max-h-60 space-y-2 overflow-auto",children:[a.variantScripts.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"font-medium",children:[e.name??e.id," ",(0,r.jsxs)("span",{className:"text-[--muted]",children:["(",e.id,")"]})]}),(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-all font-mono text-[--muted]",children:e.script})]},e.id)),(0,r.jsx)("p",{className:"text-[--muted]",children:"Stored as written."})]}):(0,r.jsx)("p",{className:"text-[--muted]",children:"None."})]})]})}function c$(e){let{open:t,onOpenChange:s,title:a,actionText:l,pending:i,onConfirm:o}
42=e,[d,c]=(0,n.useState)("");return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:a,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(n7,{value:d,onValueChange:c,placeholder:"The uploader sees this reason.",maxLength:500}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",size:"sm",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"alert",size:"sm",disabled:!d.trim(),loading:i,onClick:()=>{o(d.trim()),c("")},children:l})]})]})})}function cL(e){let{item:t}=e,s=cR(e=>{let{id:t,trusted:s}=e;return el(`POST ${cT(t)}/approve`,{body:{trusted:s}})}),a=cR(e=>{let{id:t,reason:s}=e;return el(`POST ${cT(t)}/reject`,{body:{reason:s}})}),l=cR(e=>el(`POST ${cT(e)}/draft/approve`)),i=cR(e=>{let{id:t,reason:s}=e;return el(`POST ${cT(t)}/draft/reject`,{body:{reason:s}})}),o=cI(),d=cR(e=>el("POST /dashboard/community/blocks",{body:e})),[c,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(null),h="approved"===t.status&&!!t.draft,g=h&&t.draft?t.draft:t,f=(e,t)=>e.then(()=>x.oR.success(t)).catch(e=>x.oR.error((null==e?void 0:e.message)??"Failed")),b=tX({title:"Delete submission",description:`Delete "${t.name}" entirely? This cannot be undone.`,actionText:"Delete",onConfirm:()=>f(o.mutateAsync(t.id),"Deleted")}),v=tX({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(d.mutateAsync({itemId:t.id,kind:"owner",reason:`blocked via ${t.name}`}),"Uploader blocked")}),y=tX({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(d.mutateAsync({itemId:t.id,kind:"ip",reason:`blocked via ${t.name}`}),"Address blocked")});return(0,r.jsxs)(X,{className:"space-y-4 p-4",children:[(0,r.jsx)(t0,{...b}),(0,r.jsx)(t0,{...v}),(0,r.jsx)(t0,{...y}),(0,r.jsx)(c$,{open:null!==m,onOpenChange:e=>!e&&p(null),title:"draft"===m?"Reject update":"Reject submission",actionText:"Reject",pending:a.isPending||i.isPending,onConfirm:e=>{f("draft"===m?i.mutateAsync({id:t.id,reason:e}):a.mutateAsync({id:t.id,reason:e}),"Rejected").finally(()=>p(null))}}),(0,r.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:(0,r.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(cE,{kind:t.kind}),(0,r.jsx)("h3",{className:"text-base font-semibold",children:g.name}),(0,r.jsxs)(dv,{children:["v",g.version]}),h&&(0,r.jsxs)(dv,{className:"border-yellow-400/30 bg-yellow-500/10 text-yellow-300",children:["update to v",t.version]}),"rejected"===t.status&&(0,r.jsx)(dv,{className:"border-red-400/30 bg-red-500/10 text-red-200",children:"previously rejected"})]}),(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["by ",g.author," \xb7 submitted"," ",dC(h&&t.draft?t.draft.submittedAt:t.createdAt),t.likes>0&&` \xb7 ${t.likes} likes`]}),g.description&&(0,r.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:g.description}),(0,r.jsx)(cM,{tags:g.tags??[]})]})}),h&&t.draft&&(0,r.jsx)(cO,{live:t,draft:t.draft}),"template"===t.kind&&g.reviewSummary?(0,r.jsx)(cD,{summary:g.reviewSummary}):null,(0,r.jsx)(cP,{kind:t.kind,payload:g.payload}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-[--border]/50 pt-3",children:["template"===t.kind&&!h&&(0,r.jsxs)("label",{className:"mr-2 flex items-center gap-2 text-xs text-[--muted]",children:[(0,r.jsx)(nB,{value:c,onValueChange:e=>u(!!e)}),"Approve as trusted (whitelists its regex patterns and synced URLs; takes a restart to undo)"]}),(0,r.jsx)(w,{size:"sm",intent:"success",leftIcon:(0,r.jsx)(t2.mmP,{}),loading:s.isPending||l.isPending,onClick:()=>f(h?l.mutateAsync(t.id):s.mutateAsync({id:t.id,trusted:"template"===t.kind?c:void 0}),h?"Update published":"Published"),children:h?"Approve update":"Approve"}),(0,r.jsx)(w,{size:"sm",intent:"alert-subtle",leftIcon:(0,r.jsx)(t2.Gsv,{}),onClick:()=>p(h?"draft":"item"),children:h?"Reject update":"Reject"}),(0,r.jsxs)("div",{className:"ml-auto flex flex-wrap gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(t2.PLI,{}),onClick:v.open,children:"Block uploader"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(t2.PLI,{}),onClick:y.open,children:"Block address"}),(0,r.jsx)(w,{size:"sm",intent:"alert-subtle",leftIcon:(0,r.jsx)(t2.id1,{}),onClick:b.open,children:"Delete"})]})]})]})}function cO(e){let{live:t,draft:s}=e,a=[],n=(e,t,s)=>{t!==s&&a.push([e,t,s])};if(n("Name",t.name,s.name),n("Description",t.description,s.description),n("Author",t.author,s.author),n("Tags",(t.tags??[]).join(", "),(s.tags??[]).join(", ")),"formatter"===t.kind){let e=t.payload??{},a=s.payload??{};n("Name template",e.name??"",a.name??""),n("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,r.jsx)("p",{className:"text-xs text-[--muted]",children:"Only the version changed; the payload and metadata are identical."}):(0,r.jsx)("div",{className:"overflow-x-auto rounded border border-[--border]/60",children:(0,r.jsxs)("table",{className:"w-full text-xs",children:[(0,r.jsx)("thead",{className:"bg-[--subtle]/40 uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-2",children:"Field"}),(0,r.jsx)("th",{className:"p-2",children:"Published"}),(0,r.jsx)("th",{className:"p-2",children:"Proposed"})]})}),(0,r.jsx)("tbody",{children:a.map(e=>{let[t,s,a]=e;return(0,r.jsxs)("tr",{className:"border-t border-[--border]/40",children:[(0,r.jsx)("td",{className:"p-2 font-medium",children:t}),(0,r.jsx)("td",{className:"max-w-[240px] whitespace-pre-wrap break-words p-2 text-[--muted]",children:s||"—"}),(0,r.jsx)("td",{className:"max-w-[240px] whitespace-pre-wrap break-words p-2",children:a||"—"})]},t)})})]})})}function cU(){var e;let t=(null==(e=(0,ta.I)({queryKey:[...c_,"remote"],queryFn:()=>el("/dashboard/community/remote"),staleTime:1e4}).data)?void 0:e.sources)??[];return(0,r.jsxs)(X,{className:"space-y-3 p-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Remote sources"}),(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["Approved items from other instances, shown read-only in the browsers."," ",(0,r.jsx)("a",{href:"/dashboard/settings?tab=community",className:"text-[--brand] hover:underline",children:"Edit the list in settings"}),"; run"," ",(0,r.jsx)("a",{href:"/dashboard/tasks",className:"text-[--brand] hover:underline",children:"Community remote refresh"})," ","from Tasks to fetch now."]})]}),0===t.length?(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"No remote sources configured."}):(0,r.jsxs)("table",{className:"w-full text-xs",children:[(0,r.jsx)("thead",{className:"text-[--muted]",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"py-1 pr-3",children:"Source"}),(0,r.jsx)("th",{className:"py-1 pr-3",children:"Items"}),(0,r.jsx)("th",{className:"py-1 pr-3",children:"Last fetched"}),(0,r.jsx)("th",{className:"py-1",children:"Status"})]})}),(0,r.jsx)("tbody",{children:t.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/40",children:[(0,r.jsx)("td",{className:"max-w-[360px] truncate py-1 pr-3 font-mono",children:e.url}),(0,r.jsx)("td",{className:"py-1 pr-3",children:e.count}),(0,r.jsx)("td",{className:"py-1 pr-3 text-[--muted]",children:e.lastFetchedAt?dC(e.lastFetchedAt):"never"}),(0,r.jsx)("td",{className:e.error?"py-1 text-red-200":"py-1 text-green-300",children:e.error??"ok"})]},e.url))})]})]})}function cF(e){let{item:t}=e,s=cI(),a=cR(e=>el(`POST ${cT(e)}/reset-likes`)),n=cR(e=>{let{id:t,trusted:s}=e;return el(`POST ${cT(t)}/trusted`,{body:{trusted:s}})}),l=(e,t)=>e.then(()=>x.oR.success(t)).catch(e=>x.oR.error((null==e?void 0:e.message)??"Failed")),i=tX({title:"Delete item",description:`Remove "${t.name}" from the community? People who installed it keep their copy.`,actionText:"Delete",onConfirm:()=>l(s.mutateAsync(t.id),"Deleted")}),o=tX({title:"Reset likes",description:`Clear all ${t.likes} likes on "${t.name}"?`,actionText:"Reset",onConfirm:()=>l(a.mutateAsync(t.id),"Likes reset")});return(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsx)(t0,{...i}),(0,r.jsx)(t0,{...o}),(0,r.jsxs)("td",{className:"p-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(cE,{kind:t.kind}),(0,r.jsx)("span",{className:"font-medium",children:t.name}),(0,r.jsxs)(dv,{children:["v",t.version]}),t.draft&&(0,r.jsx)(dv,{className:"border-yellow-400/30 bg-yellow-500/10 text-yellow-300",children:"update pending"})]}),t.description&&(0,r.jsx)("p",{className:"mt-1 max-w-[420px] truncate text-xs text-[--muted]",children:t.description})]}),(0,r.jsx)("td",{className:"p-3 text-[--muted]",children:t.author}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(cM,{tags:t.tags??[]})}),(0,r.jsx)("td",{className:"p-3",children:t.likes}),(0,r.jsx)("td",{className:"p-3",children:"template"===t.kind?(0,r.jsx)(tO,{trigger:(0,r.jsx)("span",{children:(0,r.jsx)(rZ,{value:t.trusted,onValueChange:e=>l(n.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,r.jsx)("span",{className:"text-xs text-[--muted]",children:"—"})}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:dC(t.updatedAt)}),(0,r.jsx)("td",{className:"p-3 text-right",children:(0,r.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.zOm,{}),"aria-label":"Reset likes",disabled:0===t.likes,onClick:o.open}),children:"Reset likes"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Delete",onClick:i.open}),children:"Delete"})]})})]})}var cz=s(43300);function cV(e){let{to:t,icon:s,title:a,aside:n,className:l,children:i}=e;return(0,r.jsx)(cz.N_,{to:t,className:"group block min-w-0 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[--muted]",children:(0,r.jsxs)(X,{className:b("flex h-full min-w-0 flex-col gap-3 p-4 transition-colors","group-hover:border-[--muted]/40 group-hover:bg-[--subtle]/50",l),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(s,{className:"shrink-0 text-[--muted] transition-colors group-hover:text-[--foreground]"}),(0,r.jsx)("h3",{className:"truncate text-sm font-semibold",children:a}),(0,r.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1.5 text-xs tabular-nums text-[--muted]",children:[n,(0,r.jsx)(t2.XWt,{className:"text-base transition-transform group-hover:translate-x-0.5"})]})]}),i]})})}function cq(e){let{children:t}=e;return(0,r.jsx)("p",{className:"text-xs italic text-[--muted]",children:t})}function cB(e){let{stream:t,frameMs:s}=e,a="streaming"===t.activity,n=dk(t);return(0,r.jsxs)("li",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(df,{transport:t.transport}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm",title:dN(t),children:dN(t)}),(0,r.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-[--muted]",children:a?(0,r.jsx)(dt,{value:t.bytesPerSec,format:nt,durationSec:s/1e3}):(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(t2._5G,{}),"paused"===t.activity?"paused":"idle"]})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-1 min-w-0 flex-1 overflow-hidden rounded-full bg-[--subtle]",children:(0,r.jsx)("div",{className:"h-full bg-brand transition-[width] ease-linear motion-reduce:transition-none",style:{width:`${100*n}%`,transitionDuration:`${s}ms`}})}),(0,r.jsx)(dv,{children:dS(t.username)})]})]})}function cK(){var e,t;let s=dd(),a=dn(s.data),l=null==(e=s.data)?void 0:e.summary,i=null==(t=s.data)?void 0:t.streams,o=n.useMemo(()=>[...i??[]].sort((e,t)=>
42t.bytesPerSec-e.bytesPerSec).slice(0,3),[i]),d=((null==l?void 0:l.paused)??0)+((null==l?void 0:l.idle)??0),c=((null==i?void 0:i.length)??0)-o.length;return(0,r.jsxs)(cV,{to:"/dashboard/streams/active",icon:t2.U2S,title:"Active streams",aside:l&&(0,r.jsx)(dt,{value:l.totalBytesPerSec,format:nt,durationSec:a/1e3}),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[(0,r.jsx)("span",{className:b("text-2xl font-semibold tabular-nums",(null==l?void 0:l.streaming)?void 0:"text-[--muted]"),children:(null==l?void 0:l.streaming)??"—"}),(0,r.jsx)("span",{className:"text-sm text-[--muted]",children:"streaming"}),d>0&&(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:["\xb7 ",d," paused"]}),(null==l?void 0:l.connectionLimit)?(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:["\xb7 ",l.connectionLimit," allowed at once"]}):null]}),s.isError?(0,r.jsx)(cq,{children:"Failed to load active streams."}):0===o.length?(0,r.jsx)(cq,{children:"Nothing streaming right now."}):(0,r.jsxs)("ul",{className:"space-y-2",children:[o.map(e=>(0,r.jsx)(cB,{stream:e,frameMs:a},e.id)),c>0&&(0,r.jsxs)("li",{className:"text-xs text-[--muted]",children:["+",c," more ",1===c?"stream":"streams"]})]})]})}function cH(){let e=dc("30d"),t=e.data,s=(null==t?void 0:t.periodMode)==="monthly";return(0,r.jsxs)(cV,{to:"/dashboard/streams/bandwidth",icon:t2.yWU,title:s?"Bandwidth this month":"Bandwidth",aside:t&&(s?`since ${new Date(t.periodStart).toLocaleDateString()}`:"last 30 days"),children:[(0,r.jsxs)("div",{className:"space-y-0.5",children:[(0,r.jsx)("div",{className:"text-2xl font-semibold tabular-nums",children:t?ne(t.periodTotal):"—"}),t&&t.globalLimit>0&&(0,r.jsxs)("div",{className:"text-xs text-[--muted]",children:["of ",ne(t.globalLimit)," allowed this period"]}),t&&t.total>0&&(0,r.jsxs)("div",{className:"text-xs text-[--muted]",children:[na((t.byTransport.usenet??0)/t.total)," usenet \xb7"," ",na((t.byTransport.proxy??0)/t.total)," proxy"]})]}),e.isError&&(0,r.jsx)(cq,{children:"Failed to load bandwidth."})]})}function cW(){return(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Sections"}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4",children:t8.filter(e=>"/dashboard"!==e.href).map(e=>{let t=e.icon,s=t7[e.href];return(0,r.jsxs)(X,{className:"group relative p-4 transition-colors hover:border-[--muted]/40 hover:bg-[--subtle]/50",children:[(0,r.jsxs)(cz.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,r.jsx)(t,{className:"text-[--muted] transition-colors group-hover:text-[--foreground]"}),e.label]}),s?(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:s.map(t=>{var s,a;return(0,r.jsx)(cz.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,r.jsx)("p",{className:"mt-2 text-xs text-[--muted]",children:e.desc})]},e.href)})})]})}function cG(e){let{label:t,value:s,hint:a,ratio:n}=e;return(0,r.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,r.jsx)("div",{className:"text-xs uppercase tracking-wide text-[--muted]",children:t}),(0,r.jsx)("div",{className:b("truncate text-lg font-semibold tabular-nums",null!=n&&n>=.95&&"text-red-400",null!=n&&n>=.85&&n<.95&&"text-amber-500"),children:s}),a&&(0,r.jsx)("div",{className:"truncate text-xs text-[--muted]",children:a})]})}function cY(e){let{metrics:t}=e,{cpu:s,memory:a,process:n}=t,l=a.total>0?a.used/a.total:0;return(0,r.jsx)(cV,{to:"/dashboard/system",icon:t2.EYW,title:"System",aside:`up ${nn(n.uptimeSec)}`,children:(0,r.jsxs)("div",{className:"grid gap-4 sm:grid-cols-3",children:[(0,r.jsx)(cG,{label:"CPU",value:`${Math.round(s.total)}%`,hint:`${Math.round(s.process)}% this process \xb7 ${s.cores} cores`,ratio:s.total/100}),(0,r.jsx)(cG,{label:"Memory",value:`${ne(a.used)} / ${ne(a.total)}`,hint:`${Math.round(100*l)}% used \xb7 ${ne(a.free)} free`,ratio:l}),(0,r.jsx)(cG,{label:"Process memory",value:ne(a.rss),hint:`${ne(a.heapUsed)} of ${ne(a.heapTotal)} heap`})]})})}function cJ(e){let{label:t,value:s}=e;return(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("dt",{className:"truncate text-[10px] uppercase tracking-wide text-[--muted]",children:t}),(0,r.jsx)("dd",{className:"truncate text-sm font-medium tabular-nums",children:s})]})}function cZ(e){let{data:t}=e,{live:s,pool:a,cache:n}=t,l=a.providers.length;return(0,r.jsxs)(cV,{to:"/dashboard/usenet/stats",icon:t2.hQe,title:"Usenet activity",aside:`${l} ${1===l?"provider":"providers"}`,children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-2xl font-semibold tabular-nums",children:nt(s.currentBytesPerSec)}),(0,r.jsxs)("div",{className:"text-xs text-[--muted]",children:["peak ",nt(s.peakBytesPerSec)]})]}),(0,r.jsxs)("dl",{className:"grid grid-cols-3 gap-2",children:[(0,r.jsx)(cJ,{label:"Streams",value:String(s.activeStreams)}),(0,r.jsx)(cJ,{label:"Articles/min",value:nc(s.articlesLastMinute)}),(0,r.jsx)(cJ,{label:"Cache hits",value:na(n.hitRate)})]}),a.globalDownloadMax>0&&(0,r.jsxs)("div",{className:"text-xs tabular-nums text-[--muted]",children:[a.globalDownloadsInUse," / ",a.globalDownloadMax," concurrent downloads"]}),s.errorsLastMinute>0&&(0,r.jsxs)("p",{className:"text-xs text-amber-500",children:[s.errorsLastMinute," article",1===s.errorsLastMinute?"":"s"," failed in the last minute"]})]})}function cQ(e){let{label:t,value:s,hint:a,intent:n,className:l}=e;return(0,r.jsxs)(X,{className:b("p-4",l),children:[(0,r.jsx)("div",{className:"text-xs uppercase tracking-wide text-[--muted]",children:t}),(0,r.jsx)("div",{className:b("mt-1 text-2xl font-semibold tabular-nums","ok"===n&&"text-emerald-500","warn"===n&&"text-amber-500","err"===n&&"text-red-400"),children:s}),a&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:a})]})}function cX(e){let{open:t,onSuccess:s,onOpenChange:a,initialUuid:l}=e,{setUserData:i,setUuid:d,setPassword:c,setEncryptedPassword:u,setBaseline:m}=aY(),{user:p}=t1(),{status:h}=tr(),g=(null==h?void 0:h.settings.configSessionsEnabled)!==!1,f=(0,o.jE)(),[b,v]=n.useState(l||""),[y,j]=n.useState(""),[N,k]=n.useState(!1),[C,_]=n.useState(!1),[A,R]=n.useState(""),[T,I]=n.useState(!1),[M,P]=n.useState(null),[D,$]=n.useState(null),[L,O]=n.useState(null),[U,F]=n.useState(!1),z=n.useRef(C);z.current=C;let V=n.useRef(null),{data:q,isLoading:B}=(0,ta.I)({...e6,enabled:t&&!!p}),K=(null==q?void 0:q.profiles)??[],H=K.length>0,W=n.useCallback(async function(e,t){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=await eg(e,t);if(i(()=>r.userData),m(r.userData),d(e),c(t),u(r.encryptedPassword),g)try{await ep(e,t,a)}catch{}s()},[g,i,m,d,c,u,s]),Y=async e=>{e.preventDefault(),I(!0);try{if(await W(b,y,C),N&&p)try{await e_(b,y,A.trim()||void 0),f.invalidateQueries({queryKey:e6.queryKey})}catch(e){x.oR.error(e instanceof Error?`Loaded, but not saved: ${e.message}`:"Loaded, but could not be saved as a profile")}}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to load configuration")}finally{I(!1)}},J=n.useCallback(async e=>{P(e.id);try{let t=await eT(e.id);await W(t.uuid,t.password,z.current)}catch(t){t instanceof en&&(v(e.uuid),F(!0),f.invalidateQueries({queryKey:e6.queryKey})),x.oR.error(t instanceof Error?t.message:"Failed to open configuration")}finally{P(null)}},[W,f]),Q=l?K.find(e=>e.uuid===l&&!e.needsRelink):void 0,X=n.useRef(null);n.useEffect(()=>{t&&Q&&X.current!==Q.id&&(X.current=Q.id,J(Q))},[t,Q,J]);let ee=async e=>{$(e.id);try{await eR(e.id),f.invalidateQueries({queryKey:e6.queryKey}),x.oR.success(`Deleted profile "${e.label}"`)}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to delete profile")}finally{$(null),O(null)}};n.useEffect(()=>{t||(j(""),k(!1),_(!1),R(""),F(!1),O(null),X.current=null)},[t]),n.useEffect(()=>{l?v(l):v("")},[l]);let et=!B&&(U||!!l&&!Q||!H),es=g?(0,r.jsx)(nB,{label:"Stay signed in on this device",value:C,onValueChange:e=>_(!0===e)}):null;return(0,r.jsx)(tJ,{open:t,onOpenChange:a,title:"Load Configuration",onOpenAutoFocus:l?e=>{var t;
42e.preventDefault(),null==(t=V.current)||t.focus()}:void 0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[p&&B&&(0,r.jsx)("div",{className:"flex justify-center py-2",children:(0,r.jsx)(S,{})}),H&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Your profiles",p?` (${p.username})`:""]}),(0,r.jsx)("ul",{className:"space-y-1",children:K.map(e=>(null==L?void 0:L.id)===e.id?(0,r.jsxs)("li",{className:"flex flex-wrap items-center gap-2 rounded-[--radius] border border-[--border] px-3 py-2",children:[(0,r.jsxs)("span",{className:"flex-1 min-w-0 text-sm",children:["Delete ",(0,r.jsx)("b",{children:e.label}),"? The configuration itself is kept."]}),(0,r.jsx)(w,{type:"button",intent:"alert-subtle",size:"sm",loading:D===e.id,onClick:()=>ee(e),children:"Delete"}),(0,r.jsx)(w,{type:"button",intent:"gray-subtle",size:"sm",disabled:null!==D,onClick:()=>O(null),children:"Cancel"})]},e.id):(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[(0,r.jsxs)(w,{type:"button",intent:"gray-subtle",className:"flex-1 justify-start min-w-0",loading:M===e.id,disabled:null!==M,onClick:()=>J(e),children:[(0,r.jsx)("span",{className:"truncate",children:e.label}),e.alias&&(0,r.jsxs)("span",{className:"ml-2 text-xs text-[--muted] truncate",children:["/u/",e.alias]}),e.needsRelink&&(0,r.jsx)("span",{className:"ml-2 text-xs text-[--red]",children:"needs password"})]}),(0,r.jsx)(E,{type:"button",icon:(0,r.jsx)(t2.id1,{}),intent:"alert-subtle",size:"sm",disabled:null!==M||null!==D,"aria-label":`Delete profile ${e.label}`,onClick:()=>O(e)})]},e.id))}),!et&&(0,r.jsx)(w,{type:"button",intent:"white-link",size:"sm",leftIcon:(0,r.jsx)(t2.zaF,{}),onClick:()=>F(!0),children:"Use a UUID and password"}),!et&&es]}),et&&(0,r.jsxs)("form",{onSubmit:Y,className:"space-y-4",children:[(0,r.jsx)(G,{label:"UUID",id:"uuid",name:"username",autoComplete:"username",autoCapitalize:"none",spellCheck:!1,value:b,onValueChange:e=>v(e),placeholder:"Enter your configuration UUID",required:!0,readOnly:!!l,className:l?"opacity-50":void 0}),(0,r.jsx)(Z,{ref:V,label:"Password",id:"password",name:"password",value:y,onValueChange:e=>j(e),placeholder:"Enter your configuration password",required:!0}),p&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(nB,{label:"Save as a profile",value:N,onValueChange:e=>k(!0===e)}),N&&(0,r.jsx)(G,{label:"Name",value:A,onValueChange:R,placeholder:"Optional, defaults to the start of the UUID"})]}),es,(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{type:"button",onClick:()=>{a(!1)},children:"Cancel"}),(0,r.jsx)(w,{type:"submit",loading:T,children:"Load"})]})]})]})})}let c0=n.createContext(null);function c1(){let e=n.useContext(c0);if(!e)throw Error("useConfigAuth must be used within a ConfigAuthProvider");return e}let c2=/stremio\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/.*\/configure/;function c3(e){let{children:t}=e,{uuid:s,setUserData:a,setUuid:l,setPassword:i,setEncryptedPassword:o,setBaseline:d}=aY(),{status:c}=tr(),[u,m]=n.useState(!1),[p,h]=n.useState(),[g,f]=n.useState(!1),b=(null==c?void 0:c.settings.configSessionsEnabled)!==!1,[v,y]=n.useState(()=>b&&em()),j=!!s,w=n.useCallback(e=>{aF(s),a(null),l(null),i(null),o(null),(e?ex():eh()).catch(()=>{})},[s,a,l,i,o]),N=tX({title:"Sign Out",description:"Are you sure you want to sign out?",onConfirm:()=>w(g)}),k=n.useCallback(e=>{e&&h(e),m(!0)},[]);n.useEffect(()=>{if("u"<typeof window)return;let e=window.location.pathname.match(c2);e&&k(e[1])},[k]),n.useEffect(()=>{if(!v)return;let e=!1;return ef().then(t=>{e||(a(()=>t.userData),d(t.userData),l(t.userData.uuid??null),o(t.encryptedPassword))}).catch(()=>{}).finally(()=>{e||y(!1)}),()=>{e=!0}},[v,a,d,l,o]);let S=n.useRef(N);S.current=N;let C=n.useCallback(()=>{S.current.open()},[]),_=n.useMemo(()=>({isSignedIn:j,openSignIn:k,openSignOut:C,toggleSession:()=>j?C():k()}),[j,k,C]);return(0,r.jsxs)(c0.Provider,{value:_,children:[t,(0,r.jsx)(cX,{open:u,onSuccess:()=>{m(!1),x.oR.success("Signed in successfully")},onOpenChange:e=>{e||m(!1)},initialUuid:p}),(0,r.jsx)(t0,{...N,description:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{children:"Are you sure you want to sign out?"}),b&&(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(nB,{label:"Sign out on all devices",value:g,onValueChange:e=>f(!0===e)})})]})})]})}var c5=s(62447);function c4(e){let{open:t,onOpenChange:s}=e;return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"Support AIOStreams",children:(0,r.jsxs)("div",{className:"flex flex-col gap-5 items-center text-center p-2",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-2 items-center",children:[(0,r.jsx)("span",{className:"text-3xl",children:"\uD83D\uDC96"}),(0,r.jsx)("h2",{className:"text-xl font-bold",children:"Donate to Me"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground 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,r.jsxs)("div",{className:"flex flex-col gap-3 w-full mt-2",children:[(0,r.jsx)(w,{intent:"alert-subtle",onClick:()=>window.open("https://github.com/sponsors/Viren070","_blank"),leftIcon:(0,r.jsx)(c5.Zak,{}),className:"w-full",children:"GitHub Sponsors"}),(0,r.jsx)(w,{intent:"alert-subtle",onClick:()=>window.open("https://ko-fi.com/Viren070","_blank"),leftIcon:(0,r.jsx)(c5.OnT,{}),className:"w-full",children:"Ko-fi"})]})]})})}function c6(){let e=(0,M.Z)(),{selectedMenu:t,setSelectedMenu:s}=a1(),a=tQ(!1),n=aY(),{isSignedIn:l,openSignIn:i,openSignOut:o}=c1(),{status:d,error:c,loading:u}=tr(),{mode:m,setMode:p}=sy(),{open:h}=ra();ri(l?{id:"sign-out",label:"Sign Out",icon:(0,r.jsx)(t2.eZR,{}),keywords:["logout","log out"],onSelect:o}:{id:"sign-in",label:"Sign In",icon:(0,r.jsx)(t2.XzR,{}),keywords:["login","log in"],onSelect:()=>i()},[l,i,o]),ri({id:"donate",label:"Donate",icon:(0,r.jsx)(t2.uoR,{}),keywords:["support","sponsor"],onSelect:()=>a.open()},[a]),ri({id:"toggle-mode",label:"pro"===m?"Switch to Simple mode":"Switch to Advanced mode",icon:(0,r.jsx)(t2.nMM,{}),keywords:["mode","pro","noob","beginner","advanced"],onSelect:()=>p("pro"===m?"noob":"pro")},[m,p]);let x=[{name:"About",iconType:t2.wfp,isCurrent:"about"===t,id:"about"},{name:"Services",iconType:t2.V0M,isCurrent:"services"===t,id:"services"},{name:"Addons",iconType:t2.DT2,isCurrent:"addons"===t,id:"addons"},{name:"Filters",iconType:t2.Jw7,isCurrent:"filters"===t,id:"filters"},..."pro"===m?[{name:"Sorting",iconType:t2.MFA,isCurrent:"sorting"===t,i
42d:"sorting"}]:[],{name:"Formatter",iconType:t2.fSy,isCurrent:"formatter"===t,id:"formatter"},{name:"Proxy",iconType:t2.nmg,isCurrent:"proxy"===t,id:"proxy"},{name:"Miscellaneous",iconType:t2.nMM,isCurrent:"miscellaneous"===t,id:"miscellaneous"},...(null==d?void 0:d.settings.userAnalyticsEnabled)&&l?[{name:"Stats",iconType:t2.yWU,isCurrent:"stats"===t,id:"stats"}]:[],{name:"Save & Install",iconType:t2.Ruw,isCurrent:"save-install"===t,id:"save-install"}],g=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-4 p-4 pb-0 flex flex-col items-center w-full",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.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":n.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,r.jsx)("span",{className:"text-xs text-gray-500",children:d?"nightly"===d.channel?"nightly":d.tag:""})]}),(0,r.jsx)(rV,{label:"Search settings",onOpen:h})]}),f=[{name:"Dashboard",iconType:t2.fiy,onClick(t){t.ctrlKey||t.metaKey?window.open("/dashboard","_blank"):e({to:"/dashboard"})}},{name:"Donate",iconType:t2.uoR,onClick:()=>a.open()},{name:l?"Sign Out":"Sign In",iconType:l?t2.eZR:t2.XzR,onClick:()=>l?o():i()}];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tG,{header:g,items:x,footerItems:f,onItemSelect:e=>{s(e.id)}}),(0,r.jsx)(c4,{open:a.isOpen,onOpenChange:a.toggle})]})}var c9=s(72780),c8=s(98188);let c7=e=>{let{words:t,className:s,style:a,...l}=e,[i,o]=(0,c9.l)(),d=t.split(" ");return(0,n.useEffect)(()=>{o("span",{opacity:1},{duration:2,delay:(0,c8.y)(.2)})},[t]),(0,r.jsx)("div",{className:b("font-bold",s),style:a,...l,children:(0,r.jsx)(tB.P.div,{ref:i,children:d.map((e,t)=>(0,r.jsxs)(tB.P.span,{className:"opacity-0",children:[e," "]},e+t))})})};function ue(e){let{title:t}=e;return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[--background]",children:(0,r.jsxs)("div",{className:b("flex flex-col items-center gap-6 transition-opacity duration-300 ease-out","opacity-100"),children:[(0,r.jsx)(C,{className:"w-10 h-10 m-0"}),t&&(0,r.jsx)(c7,{words:t||"Loading...",className:"text-2xl"})]})})}var ut=s(98592);let us=["id","version","description","name","logo","behaviorHints","stremioAddonsConfig"];function ua(e){let t={...e};for(let e of us)delete t[e];return t}function ur(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 un(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 ul=s(96221),ui=s(20440);function uo(e){let{diffs:t,valueFormatter:s,oldValue:a,newValue:l,annotations:i,pathFormatter:o}=e,d=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)},c=(0,n.useMemo)(()=>{if(!a&&!l)return[];try{let e=a?JSON.stringify(a,null,2):"",t=l?JSON.stringify(l,null,2):"";return un(e,t)}catch(e){return console.error("Failed to stringify JSON for diff:",e),un("","")}},[a,l]),u=(0,n.useMemo)(()=>{if(!i||0===i.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,"["),n=i.get(a),l=i.get(r);return n&&!l?-1:!n&&l?1:n&&l?(e[n.severity??"info"]??3)-(e[l.severity??"info"]??3):0})},[t,i]);return 0===t.length?(0,r.jsx)("div",{className:"text-center p-4 text-[--muted]",children:"No changes detected."}):(0,r.jsx)("div",{className:"w-full mt-4",children:(0,r.jsxs)(n_,{defaultValue:"visual",className:"w-full",children:[(0,r.jsxs)(nA,{className:"mb-4 grid w-full grid-cols-2",children:[(0,r.jsx)(nR,{value:"visual",children:"Visual"}),(0,r.jsx)(nR,{value:"json",children:"Raw JSON"})]}),(0,r.jsx)(nT,{value:"visual",className:"max-h-[60vh] overflow-y-auto pr-2 custom-scrollbar",children:(0,r.jsx)("div",{className:"space-y-3",children:u.map((e,t)=>{var s;let a,n=e.path.join(".").replace(/\.\[/g,"["),l=o?o(e.path):n,c=null==i?void 0:i.get(n);return(0,r.jsxs)("div",{className:"p-3 bg-gray-800/50 rounded-lg border border-gray-700 relative group",children:[(0,r.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)(uc,{type:e.type}),c&&(0,r.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,r.jsx)("span",{className:"font-mono text-sm text-gray-300",children:l})]})}),(null==c?void 0:c.description)&&(0,r.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,r.jsxs)("div",{className:`grid gap-4 text-sm ${"CHANGE"===e.type?"grid-cols-2":"grid-cols-1"}`,children:["ADD"!==e.type&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("div",{className:"text-xs text-[--muted] uppercase",children:"Old"}),(0,r.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:d(e.oldValue)})]}),"REMOVE"!==e.type&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("div",{className:"text-xs text-[--muted] uppercase",children:"New"}),(0,r.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:d(e.newValue)})]})]})]},`${e.path.join(".")}-${e.type}-${t}`)})})}),(0,r.jsx)(nT,{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,r.jsx)(ud,{textDiffs:c})})]})})}function ud(e){let{textDiffs:t}
42=e,[s,a]=(0,n.useState)(0),l=(0,n.useRef)(null),i=(0,n.useRef)([]),o=(0,n.useMemo)(()=>{let e=[],s=!1;return t.forEach((t,a)=>{"same"!==t.type?s||(e.push(a),s=!0):s=!1}),e},[t]),d=(0,n.useCallback)(e=>{let t=o[e];void 0!==t&&i.current[t]&&l.current&&i.current[t].scrollIntoView({behavior:"smooth",block:"center"}),a(e)},[o]);return(0,n.useEffect)(()=>{let e;return a(0),i.current=i.current.slice(0,t.length),o.length>0&&(e=setTimeout(()=>d(0),100)),()=>{e&&clearTimeout(e)}},[t,o,d]),(0,n.useEffect)(()=>{t.some(e=>e.truncated)&&x.oR.warning("Large File Detected: Diff simplified for performance.",{id:"large-file-warning"})},[t]),(0,r.jsxs)(r.Fragment,{children:[o.length>0&&(0,r.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,r.jsxs)("span",{className:"text-xs text-gray-400 font-mono px-2 select-none",children:[s+1," / ",o.length]}),(0,r.jsx)("div",{className:"h-4 w-px bg-gray-700 mx-1"}),(0,r.jsx)(w,{className:"h-7 w-7 p-0 hover:bg-gray-800 bg-transparent",onClick:()=>{d((s-1+o.length)%o.length)},title:"Previous Change","aria-label":"Previous Change",children:(0,r.jsx)(ul.A,{className:"h-4 w-4"})}),(0,r.jsx)(w,{className:"h-7 w-7 p-0 hover:bg-gray-800 bg-transparent",onClick:()=>{d((s+1)%o.length)},title:"Next Change","aria-label":"Next Change",children:(0,r.jsx)(ui.A,{className:"h-4 w-4"})})]}),(0,r.jsx)("div",{ref:l,className:"overflow-y-auto custom-scrollbar p-4 flex-1 font-mono text-xs",children:(0,r.jsxs)("div",{className:"flex flex-col",children:[t.map((e,t)=>(0,r.jsxs)("div",{ref:e=>{i.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===o[s]?"ring-1 ring-blue-500/50":""}`,children:[(0,r.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,r.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,r.jsxs)("pre",{className:"whitespace-pre-wrap break-all flex-1",children:["add"===e.type?"+":"remove"===e.type?"-":" "," ",e.content]})]},t)),0===t.length&&(0,r.jsx)("div",{className:"text-center p-4 text-[--muted]",children:"No raw JSON available for comparison."})]})})]})}function uc(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,r.jsx)("span",{className:`px-2 py-0.5 text-[10px] font-bold rounded border ${s}`,children:t})}function uu(e){let{oldConfig:t,newConfig:s}=e,a=(0,n.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]),l=(0,n.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:i,processedOld:o,processedNew:d}=(0,n.useMemo)(()=>a_(t,s),[t,s]);return(0,r.jsx)(uo,{diffs:i,valueFormatter:l,oldValue:o,newValue:d})}function um(e){return`${e.name} (${e.type})`}function up(e){if(null==e)return String(e);if(uh(e))return um(e);if(Array.isArray(e)){if(e.every(e=>"string"==typeof e))return e.join("\n");if(e.every(uh))return e.map(um).join("\n")}if("object"==typeof e)try{return JSON.stringify(e,null,2)}catch{return"[object]"}return String(e)}function uh(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.type&&"string"==typeof e.id&&"string"==typeof e.name}function ux(e,t){let s=ua(e),a=ua(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);
42if(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}(ak(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 ak({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 ak(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?um(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?um(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?um(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?um(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 ug(e){let{oldManifest:t,newManifest:s}=e,{diffs:a,annotations:l}=(0,n.useMemo)(()=>ux(t,s),[t,s]),i=(0,n.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,r.jsx)("div",{className:"text-center p-4 text-[--muted] text-sm",children:"No meaningful manifest changes detected."}):(0,r.jsx)(uo,{diffs:a,valueFormatter:up,oldValue:t,newValue:s,annotations:l,pathFormatter:i})}function uf(e){let{oldManifest:t,newManifest:s}=e,{diffs:a,annotations:l}=(0,n.useMemo)(()=>ux(t,s),[t,s]),i=(0,n.useMemo)(()=>{let e={critical:0,warning:1,info:2};return a.map(e=>{let t=e.path.join(".").replace(/\.\[/g,"["),s=l.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,l]);if(0===a.length)return null;let o=i.some(e=>"critical"===e.annotation.severity),d=!o&&i.some(e=>"warning"===e.annotation.severity);return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(lN,{intent:o?"alert":d?"warning":"info",isClosable:!1,description:o?"Reinstall required - some changes will not take effect until you reinstall.":d?"Reinstall recommended to apply all changes correctly.":"No significant changes - reinstall is not required for expected functionality."}),i.length>0&&(0,r.jsx)("div",{className:"space-y-1.5",children:i.map((e,t)=>(0,r.jsxs)("div",{className:"p-2.5 rounded-lg border border-[--border] bg-gray-800/30 space-y-1",children:[(0,r.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,r.jsx)("p",{className:"text-xs text-[--muted]",children:e.annotation.description})]},t))})]})}async function ub(e,t){try{let s=await e0({uuid:e,password:t});for(let e of s.filter(e=>!e.ok))x.oR.error(`Could not push to ${e.label}: ${e.error??""}`);return s}catch(e){return x.oR.error(e instanceof Error?e.message:"Could not push your changes"),null}}let uv=n.createContext(void 0);function uy(e){var t,s;let{children:a}=e,{userData:l,setUserData:i,uuid:d,password:c,encryptedPassword:u,setBaseline:m}=aY(),{status:p}=tr(),{setSelectedMenu:h}=a1(),g=(null==p||null==(t=p.settings)?void 0:t.baseUrl)||("u">typeof window?window.location.origin:""),[f,b]=n.useState(!1),[v,y]=n.useState(!1),[j,N]=n.useState(!1),[k,S]=n.useState(!1),[C,_]=n.useState(!1),[A,R]=n.useState(!1),[T,I]=n.useState(!1),[E,M]=n.useState(null),[P,D]=n.useState(null),[$,L]=n.useState(!1),[O,U]=n.useState(!1),F=(null==(s=l.linkedAccounts)?void 0:s.pushBehaviour)??"ask",z=l.manifestNotice??(d?"u"<typeof window?"always":"true"===localStorage.getItem(`aiostreams-manifest-all-dismissed-${d}`)?"never":"true"===localStorage.getItem(`aiostreams-manifest-insignificant-dismissed-${d}`)?"significant":"always":"always"),[V,q]=n.useState(null),B=n.useMemo(()=>{var e,t;return V?(e=V)&&"object"==typeof e?ur(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(",")}}`}
42(ua(e)),0x811c9dc5)+ur(t,0x1000193)+ur(t,0x9e3779b9)+ur(t,0x85ebca6b):"":null},[V]),[K,H]=n.useState(null),[W,G]=n.useState(null),Y=n.useRef(!1),J=d&&u?/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(d)?`${g}/stremio/${d}/${u}/manifest.json`:`${g}/stremio/u/${d}/manifest.json`:null,Z=(0,o.jE)(),Q=d?{uuid:d,password:c}:null,{data:X}=(0,ta.I)(e9(Q)),ee=X??[];n.useEffect(()=>{J?e1(J).then(q).catch(e=>{console.warn("Failed to fetch manifest:",e)}):q(null)},[d,u]);let et=n.useRef(null);et.current=V;let es=n.useCallback(async()=>{if(J&&d)try{let e=await e1(J),t=et.current,s=null!==t&&function(e,t){let{diffs:s}=ux(e,t);return s.length>0}(t,e);if(s&&"auto"===F){let t=await ub(d,c);if(Z.invalidateQueries({queryKey:e8}),null==t?void 0:t.some(e=>e.ok)){let e=t.filter(e=>e.ok).length;x.oR.success(`Pushed to ${e} linked ${1===e?"account":"accounts"}`)}q(e);return}if(D(null),s&&"never"!==z){let s=function(e,t){let{annotations:s}=ux(e,t);return Array.from(s.values()).some(e=>"critical"===e.severity||"warning"===e.severity)}(t,e);if(!s&&"significant"===z)return void q(e);I(s),H(e),S(!1),_(!1),N(!0)}else q(e)}catch{}},[J,d,c,F,z,Z]),ea=n.useCallback(async e=>{let t=((null==e?void 0:e.skipDiff)??!1)||Y.current;if(Y.current=!1,!d){h("save-install"),x.oR.info("Please create a configuration first");return}let s=!1;if(!t&&(null==l?void 0:l.showChanges)){b(!0);try{let e=(await eg(d,c)).userData,{diffs:t}=a_(e,l);if(0===t.length)x.oR.info("No changes detected"),s=!0,b(!1);else{M(e),y(!0),b(!1);return}}catch(e){console.error("Error checking for changes:",e),x.oR.warning("Error checking for changes. Proceeding with save."),b(!1)}}b(!0);try{await ev(d,l,c),m(l),s||x.oR.success("Configuration updated successfully"),G(V),await es()}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to save configuration")}finally{b(!1)}},[d,c,l,p,es,h,i,m]),er=()=>{let e=k?"never":C&&!T?"significant":void 0,t=void 0!==e||$,s={...l,...e?{manifestNotice:e}:{},...$?{linkedAccounts:{...l.linkedAccounts,pushBehaviour:"auto"}}:{}};t&&d&&(i(()=>s),ev(d,s,c).catch(()=>x.oR.warning("Could not remember that preference"))),L(!1),D(null),q(K),N(!1),R(!1),setTimeout(()=>{H(null),G(null)},300)};return(0,r.jsxs)(uv.Provider,{value:{handleSave:ea,loading:f,currentManifestFingerprint:B,currentManifestUrl:J},children:[a,(0,r.jsx)(tJ,{open:v,onOpenChange:y,title:"Confirm Changes",description:"Review the changes you are about to make to your configuration.",contentClass:"max-w-4xl",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(uu,{oldConfig:E,newConfig:l}),(0,r.jsxs)("div",{className:"flex justify-between pt-4",children:[(0,r.jsx)(w,{intent:"alert",onClick:()=>{E&&(i(e=>({...aB,...E,uuid:e.uuid,encryptedPassword:e.encryptedPassword,trusted:e.trusted,accessKey:e.accessKey,ip:e.ip,showChanges:e.showChanges})),x.oR.success("Changes reverted"),y(!1))},disabled:f,children:"Reset Changes"}),(0,r.jsxs)("div",{className:"flex gap-3",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>y(!1),disabled:f,children:"Cancel"}),(0,r.jsx)(w,{intent:"white",onClick:()=>{y(!1),ea({skipDiff:!0})},loading:f,children:"Confirm & Save"})]})]})]})}),(0,r.jsx)(tJ,{open:j,onOpenChange:e=>{e||er()},title:"Manifest Changed",description:"Your addon manifest has changed since your last install.",contentClass:"max-w-xl",children:(0,r.jsxs)("div",{className:"space-y-4",children:[W&&K&&(0,r.jsx)(uf,{oldManifest:W,newManifest:K}),W&&K&&(0,r.jsx)(w,{intent:"primary",className:"w-full text-sm",onClick:()=>R(!0),children:"See what changed →"}),null!==P&&(0,r.jsx)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white",children:P.every(e=>e.ok)?`Pushed to ${P.length} linked ${1===P.length?"account":"accounts"}`:`Pushed to ${P.filter(e=>e.ok).length} of ${P.length} linked accounts`}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:P.every(e=>e.ok)?"They are now up to date with this change":"Open the install page to see what failed"})]})}),null===P&&"ask"===F&&ee.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1 pr-3",children:[(0,r.jsxs)("div",{className:"text-sm font-medium text-white",children:["Push to your linked"," ",1===ee.length?ee[0].label:`${ee.length} accounts`]}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Send this change now so they pick it up without a reinstall"})]}),(0,r.jsx)(w,{intent:"primary",loading:O,onClick:async()=>{d&&(U(!0),D(await ub(d,c)),Z.invalidateQueries({queryKey:e8}),U(!1))},children:"Push now"})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white",children:"Push automatically when a reinstall is needed"}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Whenever a save changes your manifest, push it without asking"})]}
42),(0,r.jsx)(rZ,{id:"always-push-linked-accounts",value:$,onValueChange:L})]})]}),!T&&(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white",children:"Don't show for insignificant changes"}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Skip this notice when there are no significant manifest changes"})]}),(0,r.jsx)(rZ,{id:"dont-show-insignificant-again",value:C,onValueChange:_})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white",children:"Don't show this again"}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Skip this notice for all future manifest changes"})]}),(0,r.jsx)(rZ,{id:"dont-show-manifest-again",value:k,onValueChange:S})]}),(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(w,{intent:"white",onClick:er,children:"OK"})})]})}),(0,r.jsx)(tJ,{open:A,onOpenChange:R,title:"What Changed",description:"Detailed diff of your manifest changes.",contentClass:"max-w-4xl",children:W&&K&&(0,r.jsx)(ug,{oldManifest:W,newManifest:K})})]})}function uj(){let e=n.useContext(uv);if(void 0===e)throw Error("useSave must be used within a SaveProvider");return e}function uw(){let{setSelectedMenu:e,selectedMenu:t,previousMenu:s,nextMenu:a,firstMenu:n,lastMenu:l}=a1(),{handleSave:i,loading:o}=uj(),{isSignedIn:d,toggleSession:c}=c1();return(0,r.jsxs)("div",{className:"flex flex-1 gap-2 items-center",children:[(0,r.jsx)(w,{leftIcon:(0,r.jsx)(ut.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(n)},500),s=()=>{clearTimeout(t),window.removeEventListener("mouseup",s)};window.addEventListener("mouseup",s)}},disabled:t===n,children:"Previous"}),(0,r.jsx)(E,{icon:d?(0,r.jsx)(t2.eZR,{}):(0,r.jsx)(t2.XzR,{}),intent:"white-outline",rounded:!0,size:"md",onClick:c}),d&&(0,r.jsx)(E,{icon:(0,r.jsx)(t2.Ruw,{}),intent:"white-outline",rounded:!0,size:"md",loading:o,onClick:()=>i()}),(0,r.jsx)(w,{rightIcon:(0,r.jsx)(ut.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(l)},500),s=()=>{clearTimeout(t),window.removeEventListener("mouseup",s)};window.addEventListener("mouseup",s)}},disabled:t===l,children:"Next"})]})}let uN={root:(0,h.F)(["UI-Accordion__root"]),header:(0,h.F)(["UI-Accordion__header","flex text-lg"]),trigger:(0,h.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,h.F)(["UI-Accordion__triggerIcon","h-4 w-4 shrink-0 transition-transform duration-200"]),item:(0,h.F)(["UI-Accordion__item",""]),contentContainer:(0,h.F)(["UI-Accordion__contentContainer","overflow-hidden transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"]),content:(0,h.F)(["UI-Accordion__content","p-4"])},uk=n.createContext({}),uS=n.forwardRef((e,t)=>{let{className:s,headerClass:a,triggerClass:n,triggerIconClass:l,contentContainerClass:i,contentClass:o,itemClass:d,...c}=e;return(0,r.jsx)(uk.Provider,{value:{itemClass:d,headerClass:a,triggerClass:n,triggerIconClass:l,contentContainerClass:i,contentClass:o},children:(0,r.jsx)(tR.bL,{ref:t,className:b(uN.root(),s),...c})})});uS.displayName="Accordion";let uC=n.forwardRef((e,t)=>{let{className:s,...a}=e,{itemClass:l}=n.useContext(uk);return(0,r.jsx)(tR.q7,{ref:t,className:b(uN.item(),l,s),...a})});uC.displayName="AccordionItem";let u_=n.forwardRef((e,t)=>{let{className:s,headerClass:a,triggerIconClass:l,children:i,...o}=e,{headerClass:d,triggerClass:c,triggerIconClass:u}=n.useContext(uk);return(0,r.jsx)(tR.Y9,{className:b(uN.header(),d,a),children:(0,r.jsxs)(tR.l9,{ref:t,className:b(uN.trigger(),c,s),...o,children:[i,(0,r.jsx)("svg",{className:b(uN.triggerIcon(),u,l),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})]})})});u_.displayName="AccordionTrigger";let uA=n.forwardRef((e,t)=>
42{let{className:s,contentContainerClass:a,children:l,...i}=e,{contentContainerClass:o,contentClass:d}=n.useContext(uk);return(0,r.jsx)(tR.UC,{ref:t,className:b(uN.contentContainer(),o,a),...i,children:(0,r.jsx)("div",{className:b(uN.content(),d,s),children:l})})});uA.displayName="AccordionContent";let uR={enter:e=>({x:e>=0?40:-40,opacity:0}),center:{x:0,opacity:1},exit:e=>({x:e>=0?-40:40,opacity:0})};function uT(e){let{tabs:t,activeTab:s,onTabChange:a,defaultMobileOpen:l="",revealOnChange:i=!1}=e,o=t.findIndex(e=>e.value===s),d=o>=0?t[o].content:null,c=n.useRef(o),u=o===c.current?0:o>c.current?1:-1;n.useEffect(()=>{c.current=o},[o]);let m=n.useRef(null),p=n.useRef(!1);n.useEffect(()=>{if(!i)return;if(!p.current){p.current=!0;return}let e=m.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,i]);let[h,x]=n.useState(l||s);return n.useEffect(()=>{x(s)},[s]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"sm:hidden space-y-2",children:(0,r.jsx)(uS,{type:"single",collapsible:!0,value:h,onValueChange:e=>{x(e),e&&a(e)},children:t.map(e=>(0,r.jsxs)(uC,{value:e.value,className:"border border-[--border] rounded-[--radius-md] overflow-hidden mb-2",children:[(0,r.jsx)(u_,{children:(0,r.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[e.icon,e.label]})}),(0,r.jsx)(uA,{children:(0,r.jsx)("div",{ref:t=>{t&&(t.inert=h!==e.value)},className:"space-y-4",children:e.content})})]},e.value))})}),(0,r.jsxs)("div",{className:"hidden sm:block",children:[(0,r.jsx)(n_,{value:s,onValueChange:a,className:"w-full",children:(0,r.jsx)(nA,{className:"flex w-full border-b border-[--border] overflow-x-auto",children:t.map(e=>(0,r.jsxs)(nR,{value:e.value,className:"flex flex-1 basis-0 items-center gap-1.5",children:[e.icon,e.label]},e.value))})}),(0,r.jsx)("div",{ref:m,className:"relative mt-4 overflow-hidden",children:(0,r.jsx)(tq.N,{mode:"popLayout",initial:!1,custom:u,children:(0,r.jsx)(tB.P.div,{custom:u,variants:uR,initial:"enter",animate:"center",exit:"exit",transition:{duration:.3,ease:[.32,.72,0,1]},className:"space-y-4 p-1",children:d},s)})})]})]})}function uI(e){let{section:t}=e;return(0,r.jsx)(tO,{trigger:(0,r.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,r.jsx)(lj.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 uE={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"},uM=[sH,sW,sG,sK,sY,sJ],uP=["torbox"];function uD(e){return uM.includes(e)}function u$(e){return uP.includes(e)}let uL=[{id:"debrid",label:"Debrid"},{id:"usenet",label:"Usenet"}];function uO(e){let{serviceId:t,shortName:s,className:a}=e,n=uE[t];return n?(0,r.jsx)("img",{src:n,alt:s,className:b("w-9 h-9 rounded-lg object-contain shrink-0",a)}):(0,r.jsx)("div",{className:b("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})}var uU=s(69788),uF=s(57320),uz=s(15920),uV=s(11627);function uq(e){let{id:t,url:s,className:a,trusted:n=!0}=e,l=(()=>{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}})(),i=tX({title:"External Link Warning",description:(0,r.jsxs)(r.Fragment,{children:["This link was added by a template creator and is not verified or endorsed by AIOStreams.",(0,r.jsx)("br",{}),(0,r.jsx)("br",{}),"You are being taken to"," ",(0,r.jsx)("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] underline",onClick:e=>e.stopPropagation(),children:(0,r.jsx)("b",{children:s})}),"."]}),actionText:"Continue",onConfirm:()=>{window.open(s,"_blank","noopener,noreferrer")}}),o=n?void 0:e=>{e.preventDefault(),i.open()};return(0,r.jsxs)(r.Fragment,{children:[!n&&(0,r.jsx)(t0,{...i}),l?(0,r.jsx)(tO,{side:"top",trigger:(0,r.jsx)(uB,{id:t,url:s,className:a,onClick:o}),children:l}):(0,r.jsx)(uB,{id:t,url:s,className:a,onClick:o})]})}let uB=e=>{let{id:t,url:s,className:a,onClick:n}=e;return(0,r.jsx)("a",{href:s,target:"_blank",rel:"noopener noreferrer",onClick:n,className:b("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,r.jsx)(ut.f35,{className:"w-7 h-7"});case"discord":return(0,r.jsx)(P.fzZ,{className:"w-7 h-7"});case"github":return(0,r.jsx)(lj.BR8,{className:"w-7 h-7"});case"github-sponsors":return(0,r.jsx)(c5.Zak,{className:"w-7 h-7"});case"ko-fi":return(0,r.jsx)(c5.OnT,{className:"w-7 h-7"});case"patreon":return(0,r.jsx)(ut.hk0,{className:"w-7 h-7"});case"buymeacoffee":return(0,r.jsx)(c5.Ylh,{className:"w-7 h-7"});case"donate":return(0,r.jsx)(t2.xko,{className:"w-7 h-7"});default:return null}})()})};var uK=s(8963).Buffer;function uH(e){let{subsectionIntent:t,buttonIntent:s,name:a,description:n,onClick:l,disabled:i}=e;return"block"===t?(0,r.jsxs)("button",{type:"button",onClick:l,disabled:i,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,r.jsx)("div",{className:"font-semibold text-sm",children:a}),n&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(l_,{children:n})})]}):"pill"===t?(0,r.jsxs)("div",{children:[(0,r.jsx)(w,{type:"button",rounded:!0,intent:s??"white-subtle",size:"md",onClick:l,disabled:i,className:"w-full",children:a}),n&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-2",children:(0,r.jsx)(l_,{children:n})})]}):"inline"===t?(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"font-medium text-sm",children:a}),n&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:(0,r.jsx)(l_,{children:n})})]}),(0,r.jsx)(w,{type:"button",rounded:!0,intent:s??"white",size:"sm",onClick:l,disabled:i,className:"shrink-0",children:"Open"})]}):"link"===t?(0,r.jsxs)("button",{type:"button",onClick:l,disabled:i,className:"group text-left disabled:opacity-50 disabled:pointer-events-none",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-sm font-medium text-[--brand] group-hover:underline",children:[a,(0,r.jsx)(ut.X6T,{className:"w-3 h-3 opacity-60 transition-transform group-hover:translate-x-0.5"})]}),n&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:(0,r.jsx)(l_,{children:n})})]}):"banner"===t?(0,r.jsx)("button",{type:"button",onClick:l,disabled:i,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,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-semibold text-sm",children:a}),n&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:(0,r.jsx)(l_,{children:n})})]}),(0,r.jsx)(ut.X6T,{className:"w-3 h-3 text-[--muted] shrink-0"})]})}):(0,r.jsxs)("div",{className:"flex items-center gap-3 bg-gray-100 dark:bg-gray-800 p-4 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h4",{className:"font-medium mb-1",children:a}),n&&(0,r.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,r.jsx)(l_,{children:n})})]}),(0,r.jsx)(E,{icon:(0,r.jsx)(ut.XGb,{}),intent:"primary-outline",onClick:l,disabled:i,title:`Configure ${a}`})]})}function uW(e){let{label:t,value:s,onChange:a,options:n,required:l,disabled:i}=e,o=e=>{a("undefined"===e?void 0:e)},d=!(null==n?void 0:n.some(e=>e.value===s)),c=[...(null==n?void 0:n.map(e=>({label:e.label,value:e.value})))??[],{label:"Custom",value:"Custom"}];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(r0,{label:t,value:d?"Custom"
42:s,onValueChange:e=>{o("Custom"===e?"":e)},options:c,required:l,disabled:i}),d&&(0,r.jsx)(G,{label:"Custom",value:s??"",onValueChange:o,required:l,disabled:i})]})}let uG=e=>{let{option:t,value:s,trusted:a,onChange:l,disabled:i}=e,{id:o,name:d,description:c,type:u,required:m,options:p,constraints:h,forced:x,default:g,intent:f,subsectionIntent:b,buttonIntent:v,socials:y,oauth:j,emptyIsUndefined:N=!1}=t,k=i||null!=x,S=null!=x?x:void 0;switch(u){case"socials":return(0,r.jsx)("div",{className:"flex items-center justify-center w-full gap-6 mt-2",children:null==y?void 0:y.map(e=>(0,r.jsx)(uq,{id:e.id,url:e.url,trusted:a},e.id))});case"alert":return(0,r.jsx)(lN,{intent:f,title:d,description:(0,r.jsx)(l_,{children:c})});case"password":return(0,r.jsxs)("div",{children:[(0,r.jsx)(Z,{label:d,value:S??s??g??"",onValueChange:e=>l(N?e||void 0:e),required:m,disabled:k,autoComplete:"new-password",minLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.min:void 0,maxLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.max:void 0}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(l_,{children:c})})]});case"string":return(0,r.jsxs)("div",{children:[(0,r.jsx)(G,{label:d,value:S??s??g??"",onValueChange:e=>l(N?e||void 0:e),required:m,minLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.min:void 0,maxLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.max:void 0,disabled:k}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(l_,{children:c})})]});case"number":return(0,r.jsxs)("div",{children:[(0,r.jsx)(n1,{value:S??s??g??void 0,label:d,onValueChange:(e,t)=>
42l(isNaN(e)?void 0:e),required:m,step:(null==h?void 0:h.max)&&Math.floor((null==h?void 0:h.max)/100)>0?Math.floor((null==h?void 0:h.max)/100):1,disabled:k,clampValueOnBlur:!1,min:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.min:void 0,max:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.max:void 0}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(l_,{children:c})})]});case"boolean":return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("span",{className:"font-medium text-sm",children:d}),(0,r.jsx)(rZ,{disabled:k,value:!!(S??s??g),onValueChange:l})]}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(l_,{children:c})})]});case"select":return(0,r.jsxs)("div",{children:[(0,r.jsx)(r0,{label:d,value:S??s??g,onValueChange:l,options:(null==p?void 0:p.map(e=>({label:e.label,value:e.value})))??[],required:m,disabled:k}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(l_,{children:c})})]});case"select-with-custom":return(0,r.jsxs)("div",{children:[(0,r.jsx)(uW,{label:d,value:S??s??g,onChange:l,options:p,required:m,disabled:k}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(l_,{children:c})})]});case"multi-select":return(0,r.jsxs)("div",{children:[(0,r.jsx)(nJ,{label:d,value:S??Array.isArray(s)?s:g,onValueChange:e=>l(N&&(null==e?void 0:e.length)===0?void 0:e),options:(null==p?void 0:p.map(e=>({label:e.label,value:e.value,textValue:e.label})))??[],multiple:!0,emptyMessage:"No options",disabled:k,required:m,maxItems:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.max:void 0}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(l_,{children:c})})]});case"url":return(0,r.jsxs)("div",{children:[(0,r.jsx)(G,{label:d,value:S??s??g??"",onValueChange:e=>l(N?e||void 0:e),required:m,type:"url",disabled:k,minLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.min:void 0,maxLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.max:void 0}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(l_,{children:c})})]});case"oauth":{var C,_;let[e,t]=(0,n.useState)(!!s);if(!e)return(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:"flex flex-col gap-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-3 bg-[--subtle] p-4 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h4",{className:"font-medium mb-1",children:d}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:(0,r.jsx)(l_,{children:c})})]}),(0,r.jsx)(E,{icon:(0,r.jsx)(ut.pXu,{}),intent:"primary-outline",onClick:()=>{window.open((null==j?void 0:j.authorisationUrl)||"","_blank"),t(!0)},className:"shrink-0"})]})})});return(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:"flex flex-col gap-3",children:(0,r.jsxs)("div",{className:"bg-[--subtle] p-4 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("h4",{className:"font-medium",children:["Enter ",(null==j||null==(C=j.oauthResultField)?void 0:C.name)||"Authorization Code"]}),(0,r.jsx)(E,{icon:(0,r.jsx)(ut.QVr,{className:"w-4 h-4"}),intent:"primary-subtle",size:"sm",onClick:()=>t(!1),"aria-label":"Go back to authorization"})]}),(0,r.jsx)(Z,{value:S??s??g,onValueChange:e=>l(N?e||void 0:e),required:m,disabled:k,autoComplete:"new-password"}),(null==j||null==(_=j.oauthResultField)?void 0:_.description)&&(0,r.jsx)("div",{className:"text-sm text-[--muted] mt-2",children:(0,r.jsx)(l_,{children:j.oauthResultField.description})})]})})})}case"subsection":{let[e,a]=(0,n.useState)(!1),i=t.subOptions??[],o=S??s??g??{},u={};for(let e of i)void 0!==e.default&&(u[e.id]=e.default);let m={...u,...o},[p,h]=(0,n.useState)(m);return(0,r.jsxs)("div",{children:[(0,r.jsx)(uH,{subsectionIntent:b,buttonIntent:v,name:d,description:c,onClick:()=>{h(m),a(!0)},disabled:k}),(0,r.jsx)(tJ,{open:e,onOpenChange:e=>!e&&void(h(m),a(!1)),title:d,children:(0,r.jsxs)("div",{className:"space-y-4",children:[i.map(e=>(0,r.jsx)(uG,{option:e,value:p[e.id],onChange:t=>{var s;return s=e.id,void h(e=>({...e,[s]:t}))},disabled:k},e.id)),(0,r.jsx)(w,{type:"button",intent:"primary",className:"w-full",onClick:()=>{l(p),a(!1)},children:"Save"})]})})]})}case"custom-nntp-servers":return(0,r.jsx)(uX,{name:d,description:c,value:S??s??g,onChange:l,disabled:k});case"nab-endpoint":return(0,r.jsx)(uJ,{option:t,value:S??s??g,onChange:l,disabled:k});default:return null}},uY={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 uJ(e){var t,s,a;let{option:l,value:i,onChange:o,disabled:d}=e,c=l.subOptions??[],u=c.find(e=>"url"===e.id),m=c.find(e=>"apiKey"===e.id),p=i??{}
42,[h,g]=(0,n.useState)(!1),[f,b]=(0,n.useState)(null),v=e=>{b(null),o({...p,...e})},y=null==u||null==(s=u.options)||null==(t=s.find(e=>e.value===p.url))?void 0:t.apiKeyUrl,j=[null==m?void 0:m.description,y&&`[Find your API key](${y})`].filter(Boolean).join(" "),w=async()=>{g(!0),b(null);try{var e,t,s;let a=await fetch(`/builtins/${(null==(e=l.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=l.nab)?void 0:t.preset})}),r=await a.json();if(!r.success)throw Error(r.detail||(null==(s=r.error)?void 0:s.message)||"Could not run the test");b(r.data)}catch(e){x.oR.error(e instanceof Error?e.message:"Could not run the test")}finally{g(!1)}};return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-end gap-2",children:[(0,r.jsx)("div",{className:"flex-1 min-w-0 space-y-2",children:(null==u||null==(a=u.options)?void 0:a.length)?(0,r.jsx)(uW,{label:u.name,value:p.url,onChange:e=>v({url:e}),options:u.options,required:u.required,disabled:d}):(0,r.jsx)(G,{label:(null==u?void 0:u.name)??"URL",value:p.url??"",onValueChange:e=>v({url:e}),type:"url",required:null==u?void 0:u.required,disabled:d})}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{intent:"gray-subtle",icon:(0,r.jsx)(t2.UWw,{}),onClick:w,loading:h,disabled:d||h,"aria-label":"Test endpoint",className:"shrink-0"}),children:"Test connection"})]}),(null==u?void 0:u.description)&&(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:(0,r.jsx)(l_,{children:u.description})}),m&&(0,r.jsxs)("div",{children:[(0,r.jsx)(Z,{label:m.name,value:p.apiKey??"",onValueChange:e=>v({apiKey:e}),required:m.required,disabled:d,autoComplete:"new-password"}),j&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(l_,{children:j})})]}),f&&(0,r.jsx)(uZ,{result:f})]})}function uZ(e){var t,s,a,n,l,i;let o,d,{result:c}=e;if(!c.ok){let e=c.stage?uY[c.stage]:void 0;return(0,r.jsx)(lN,{intent:"alert-basic",title:"Test failed",description:(0,r.jsxs)("span",{children:[e?`${e} `:"",null==(n=c.error)?void 0:n.message,(null==(l=c.error)?void 0:l.code)!==void 0&&` (${c.error.code})`]})})}let u=[(o=(null==(i=c.idSearchParams)?void 0:i.movie)??[],d=(null==i?void 0:i.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,r.jsx)(lN,{intent:"success-basic",title:`Connected to ${(null==(a=c.server)?void 0:a.title)||"the indexer"}`,description:u.join(" \xb7 ")})}let uQ=e=>{if(!e)return[];try{let t=uK.from(e,"base64").toString("utf-8");return JSON.parse(t)}catch{return[]}};function uX(e){let{name:t,description:s,value:a,onChange:l,disabled:i}
42=e,[o,d]=(0,n.useState)(!1),[c,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{o&&u(uQ(a))},[o,a]);let m=uQ(a).length,p=(e,t)=>{u(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)})},h=(e,t,s)=>{u(a=>a.map((a,r)=>r===e?{...a,[t]:s}:a))};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 bg-[--subtle] p-4 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h4",{className:"font-medium mb-1",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:(0,r.jsx)(l_,{children:s})}),m>0&&(0,r.jsxs)("p",{className:"text-sm text-[--brand] mt-1",children:[m," server",1!==m?"s":""," configured"]})]}),(0,r.jsx)(E,{icon:(0,r.jsx)(ut.vwk,{}),intent:"primary-outline",onClick:()=>d(!0),disabled:i,className:"shrink-0"})]}),(0,r.jsxs)(tJ,{open:o,onOpenChange:d,title:"Configure NNTP Servers",contentClass:"max-w-4xl",children:[(0,r.jsxs)("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto pr-1",children:[0===c.length?(0,r.jsxs)("div",{className:"text-center py-8 text-[--muted]",children:[(0,r.jsx)(ut.vwk,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),(0,r.jsx)("p",{children:"No servers configured"}),(0,r.jsx)("p",{className:"text-sm",children:"Click the button below to add a server"})]}):c.map((e,t)=>(0,r.jsxs)("div",{className:"border border-[--border] rounded-lg p-4 bg-[--subtle]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("span",{className:"font-medium text-sm",children:["Server ",t+1]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(E,{icon:(0,r.jsx)(ut.Ucs,{className:"w-4 h-4"}),intent:"gray-subtle",size:"sm",onClick:()=>p(t,"up"),disabled:0===t}),(0,r.jsx)(E,{icon:(0,r.jsx)(ut.Vr3,{className:"w-4 h-4"}),intent:"gray-subtle",size:"sm",onClick:()=>p(t,"down"),disabled:t===c.length-1}),(0,r.jsx)(E,{icon:(0,r.jsx)(ut.G02,{className:"w-4 h-4"}),intent:"alert-subtle",size:"sm",onClick:()=>{u(e=>e.filter((e,s)=>s!==t))}})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,r.jsx)(G,{label:"Host",value:e.host??"",onValueChange:e=>h(t,"host",e),placeholder:"news.example.com",required:!0}),(0,r.jsx)(n1,{label:"Port",value:e.port,onValueChange:e=>h(t,"port",e),min:1,max:65535,required:!0}),(0,r.jsx)(G,{label:"Username",autoComplete:"off",value:e.username??"",onValueChange:e=>h(t,"username",e),placeholder:"username",required:!0}),(0,r.jsx)(Z,{label:"Password",autoComplete:"new-password",value:e.password??"",onValueChange:e=>h(t,"password",e),placeholder:"password",required:!0}),(0,r.jsx)(n1,{label:"Connections",value:e.connections,onValueChange:e=>h(t,"connections",e),min:1,max:500,required:!0}),(0,r.jsx)("div",{className:"flex items-end pb-1",children:(0,r.jsx)(rZ,{label:"Use SSL",value:e.ssl,onValueChange:e=>h(t,"ssl",e),side:"right"})})]})]},t)),(0,r.jsx)(w,{type:"button",intent:"primary-outline",className:"w-full",leftIcon:(0,r.jsx)(ut.OiG,{className:"w-4 h-4"}),onClick:()=>{u(e=>[...e,{username:"",password:"",host:"",port:563,ssl:!0,connections:5}])},children:"Add Server"})]}),(0,r.jsxs)("div",{className:"flex gap-2 mt-4 pt-4 border-t border-[--border]",children:[(0,r.jsx)(w,{type:"button",className:"w-full",intent:"primary-outline",onClick:()=>{d(!1)},children:"Cancel"}),(0,r.jsx)(w,{type:"button",className:"w-full",onClick:()=>{l((e=>{if(0!==e.length)return uK.from(JSON.stringify(e)).toString("base64")})(c.filter(e=>""!==e.host.trim()))),d(!1)},children:"Save"})]})]})]})}function u0(){var e,t,s,a,l;let{status:i}=tr();if(!i)return null;let{setUserData:o,userData:d}
42=aY(),[c,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(null),[h,x]=(0,n.useState)({}),[g,f]=(0,n.useState)(!1),[v,y]=(0,n.useState)(""),[j,w]=(0,n.useState)("all"),N=e=>{var t;p(e);let s=null==(t=d.services)?void 0:t.find(t=>t.id===e);x((null==s?void 0:s.credentials)||{}),u(!0)},k=()=>{u(!1),p(null),x({})};(0,n.useEffect)(()=>{let e=Object.keys(i.settings.services),t=d.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:{}}));o(t=>({...t,services:[...s,...e]}))}},[i.settings.services,d.services]);let S=(0,uV.FR)((0,uV.MS)(uV.AN),(0,uV.MS)(uV.IG,{activationConstraint:{delay:150,tolerance:8}}));(0,n.useEffect)(()=>{function e(e){g&&e.preventDefault()}function t(){f(!1)}return g?(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)}},[g]);let C=(null==(e=d.services)?void 0:e.filter(e=>{let t=i.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=i.settings.services[e.id])?void 0:t.name}))??[],_=(null==(t=d.services)?void 0:t.map(e=>e.id))||[],A=""!==v.trim()||"all"!==j,R=(d.services??[]).filter(e=>{let t=i.settings.services[e.id];if(!t)return!1;if("all"!==j){let t=u$(e.id),s=uD(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,r.jsxs)(r.Fragment,{children:[C.length>0&&(0,r.jsx)(lN,{intent:"alert",title:"Missing Credentials",description:(0,r.jsxs)(r.Fragment,{children:["The following services are missing credentials:",(0,r.jsx)("div",{className:"flex flex-col gap-1 mt-2",children:C.map(e=>(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-current mr-2"}),e]},e))})]})}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 items-start sm:items-center",children:[(0,r.jsx)(G,{className:"flex-1 w-full sm:w-auto",placeholder:"Search services...",leftIcon:(0,r.jsx)(lj.CKj,{className:"w-4 h-4 text-[--muted]"}),value:v,onValueChange:y}),(0,r.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,r.jsx)("button",{type:"button",onClick:()=>w(e),className:b("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,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Showing ",R.length," of ",(null==(s=d.services)?void 0:s.length)??0," ","services."," ",(0,r.jsx)("button",{type:"button",className:"underline hover:text-[--foreground] transition-colors",onClick:()=>{y(""),w("all")},children:"Clear filters"})," ","to reorder."]}):(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Drag to reorder by priority. Enable a service and click"," ",(0,r.jsx)("strong",{children:"Configure"})," to enter credentials."]}),A?(0,r.jsx)("ul",{className:"space-y-2",children:0===R.length?(0,r.jsx)("li",{children:(0,r.jsx)("div",{className:"flex flex-col items-center justify-center py-12",children:(0,r.jsx)("span",{className:"text-lg text-[--muted] font-semibold text-center",children:"No services match your search."})})}):R.map(e=>{let t=i.settings.services[e.id];return t?(0,r.jsx)(u2,{service:e,meta:t,onEdit:()=>N(e.id),onToggleEnabled:t=>{o(s=>({...s,services:(s.services??[]).map(s=>s.id===e.id?{...s,enabled:t}:s)}))}},e.id):null})}):(0,r.jsx)(uV.Mp,{modifiers:[uU.FN],onDragEnd:function(e){let{active:t,over:s}=e;s&&(t.id!==s.id&&o(e=>{let a=e.services??[],r=a.findIndex(e=>e.id===t.id),n=a.findIndex(e=>e.id===s.id),l=(0,uF.be)(a,r,n);return{...e,services:l}}),f(!1))},onDragStart:function(){f(!0)},sensors:S,children:(0,r.jsx)(uF.gB,{items:_,strategy:uF._G,children:(0,r.jsx)("ul",{className:"space-y-2",children:((null==(a=d.services)?void 0:a.length)??0)===0?(0,r.jsx)("li",{children:(0,r.jsx)("div",{className:"flex flex-col items-center justify-center py-12",children:(0,r.jsx)("span",{className:"text-lg text-[--muted] font-semibold text-center",children:"No services found."})})}):null==(l=d.services)?void 0:l.map(e=>{let t=i.settings.services[e.id];return t?(0,r.jsx)(u3,{service:e,meta:t,onEdit:()=>N(e.id),onToggleEnabled:t=>{o(s=>({...s,services:(s.services??[]).map(s=>s.id===e.id?{...s,enabled:t}:s)}))}},e.id):null})})})}),(0,r.jsx)(u5,{open:c,onOpenChange:u,serviceId:m,values:h,onSubmit:e=>{o(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 u1(e){let{service:t,meta:s,onEdit:a,onToggleEnabled:n,dragHandleProps:l}=e,i=s.credentials.every(e=>e.forced),o=uD(t.id),d=u$(t.id);return(0,r.jsxs)("div",{className:"px-3 py-2.5 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 items-center relative",children:[l?(0,r.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",...l.attributes,...l.listeners}):(0,r.jsx)("div",{className:"w-6 flex-shrink-0"}),(0,r.jsx)(uO,{serviceId:t.id,shortName:s.shortName}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col justify-center min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"font-semibold text-sm truncate",children:(null==s?void 0:s.name)||t.id}),d?(0,r.jsxs)(r.Fragment,{children:[(0,r.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,r.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,r.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,r.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,r.jsx)("span",{className:"text-xs text-[--muted] font-normal line-clamp-1",children:(0,r.jsx)(l_,{children:null==s?void 0:s.signUpText})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,r.jsx)(rZ,{value:!!t.enabled,onValueChange:n,disabled:i}),(0,r.jsx)(E,{intent:"gray-outline",size:"sm",onClick:a,disabled:i,icon:(0,r.jsx)(lj.VSk,{})})]})]})}function u2(e){let{service:t,meta:s,onEdit:a,onToggleEnabled:n}=e;return(0,r.jsx)("li",{children:(0,r.jsx)(u1,{service:t,meta:s,onEdit:a,onToggleEnabled:n,dragHandleProps:null})})}function u3(e){let{service:t,meta:s,onEdit:a,onToggleEnabled:n}=e,{attributes:l,listeners:i,setNodeRef:o,transform:d,transition:c,isDragging:u}=(0,uF.gl)({id:t.id}),m={transform:uz.Ks.Transform.toString(d),transition:c,opacity:u?.5:1};return(0,r.jsx)("li",{ref:o,style:m,children:(0,r.jsx)(u1,{service:t,meta:s,onEdit:a,onToggleEnabled:n,dragHandleProps:{attributes:l,listeners:i}})})}function u5(e){let{open:t,onOpenChange:s,serviceId:a,values:l,onSubmit:i,onClose:o}=e,{status:d}
42=tr(),[c,u]=(0,n.useState)({});if((0,n.useEffect)(()=>{t&&u(l)},[t,l]),!d||!a)return null;let m=d.settings.services[a],p=m.credentials||[];return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:`Configure ${m.name}`,children:(0,r.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),i(c)},children:[p.map(e=>(0,r.jsx)(uG,{option:{...e,required:!1},value:e.forced||e.default||c[e.id],onChange:t=>u(s=>({...s,[e.id]:t||void 0}))},e.id)),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{type:"button",className:"w-full",intent:"primary-outline",onClick:o,children:"Cancel"}),(0,r.jsx)(w,{type:"submit",className:"w-full",children:"Save"})]})]})})}function u4(e){let{title:t,children:s}=e,[a,l]=(0,n.useState)({x:0,y:0}),i=(0,n.useRef)(null);return(0,r.jsx)("div",{className:"pb-4",children:(0,r.jsx)("div",{ref:i,onMouseMove:e=>{if(!i.current)return;let t=i.current.getBoundingClientRect();l({x:e.clientX-t.left,y:e.clientY-t.top})},className:"contents lg:block relative group/settings-nav",children:s})})}function u6(e){let{title:t,description:s,children:a,className:l,titleClassName:i,action:o,id:d}
42=e,[c,u]=(0,n.useState)({x:0,y:0}),[m,p]=(0,n.useState)(!1),h=(0,n.useRef)(null);return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(X,{ref:h,id:d,"data-settings-card":!0,className:b("group/settings-card relative lg:bg-gray-950/70 scroll-mt-24",l),onMouseMove:e=>{if(!h.current)return;let t=h.current.getBoundingClientRect();u({x:e.clientX-t.left,y:e.clientY-t.top})},children:[t&&(0,r.jsx)(ee,{className:"p-0 pb-4",children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)(et,{className:b("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 rounded-tl-md rounded-br-md",i),children:t}),s&&(0,r.jsx)(es,{className:"px-4 mt-2",children:s})]}),o&&(0,r.jsx)("div",{className:"flex-shrink-0 px-4 pt-2",children:o})]})}),(0,r.jsx)(ea,{className:b(!t&&"pt-4","space-y-3 flex-wrap"),children:a})]})})}function u9(e){let{label:t,help:s,disabled:a,value:l,onValueChange:i,placeholder:o,min:d=0}=e,[c,u]=n.useState(()=>no(l)),[m,p]=n.useState(null);return n.useEffect(()=>{ni(c)!==l&&(u(no(l)),p(null))},[l]),(0,r.jsx)(G,{label:t,help:s,error:m??void 0,disabled:a,value:c,placeholder:o??'e.g. "1.5s", "500ms", "2s"',onValueChange:e=>{u(e);let t=ni(e);null==t||t<d?p("Invalid duration. Use e.g. 500ms, 1.5s, 2s, 1m."):(p(null),i(t))}})}function u8(){var e,t,s,a,n,l,i,o,d,c,u,m,p,h,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;let{status:B}=tr(),{userData:K,setUserData:H}=aY();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u6,{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,r.jsx)(rZ,{label:"Enable Service Wrap",side:"right",value:(null==(e=K.serviceWrap)?void 0:e.enabled)??!1,onValueChange:e=>{H(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=K.serviceWrap)?void 0:t.enabled)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rZ,{label:"Reconfigure Service",side:"right",value:(null==(s=K.serviceWrap)?void 0:s.reconfigureService)??!1,onValueChange:e=>{H(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,r.jsx)(nJ,{label:"Wrap Addons",help:"Select which addons to wrap. Leave empty to wrap all applicable addons.",options:(K.presets??[]).filter(e=>{var t;let s=null==B?void 0:B.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=K.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=K.serviceWrap)?void 0:a.presets)??[],onValueChange:e=>{H(t=>({...t,serviceWrap:{...t.serviceWrap,presets:e.length>0?e:void 0}}))}}),(0,r.jsx)(nJ,{label:"Processing Services",help:"Select which debrid services to use for processing wrapped torrents. Leave empty to use all enabled services.",options:(K.services??[]).filter(e=>e.enabled&&sX.includes(e.id)&&![sH,sW,sG,sK].includes(e.id)).map(e=>{var t,s;return{label:(null==B||null==(t=B.settings.services[e.id])?void 0:t.name)??e.id,value:e.id,textValue:(null==B||null==(s=B.settings.services[e.id])?void 0:s.name)??e.id}}),multiple:!0,emptyMessage:"No supported services found",value:(null==(n=K.serviceWrap)?void 0:n.services)??[],onValueChange:e=>{H(t=>({...t,serviceWrap:{...t.serviceWrap,services:e.length>0?e:void 0}}))}})]})]}),(0,r.jsxs)(u6,{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,r.jsx)(rZ,{label:"Enable",side:"right",value:(null==(l=K.failover)?void 0:l.enabled)??!1,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,enabled:e}}))}}),(0,r.jsx)(nJ,{label:"Failover Content Types",help:"Which kinds of result may be used as failover targets.",disabled:!(null==(i=K.failover)?void 0:i.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=K.failover)?void 0:o.contentTypes)??["usenet"],onValueChange:e=>{H(t=>({...t,failover:{...t.failover,contentTypes:e}}))}}),(0,r.jsx)(rZ,{label:"Allow Cross-Type Failover",side:"right",disabled:!(null==(d=K.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=K.failover)?void 0:c.allowCrossType)??!1,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,allowCrossType:e}}))}}),(0,r.jsx)(rZ,{label:"Include External Addon Targets",side:"right",disabled:!(null==(u=K.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=K.failover)?void 0:m.includeExternalFailover)??!1,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,includeExternalFailover:e}}))}}),(0,r.jsx)(n1,{label:"Max Failover Attempts",help:(0,r.jsxs)(r.Fragment,{children:["How many unique fallback results to try before giving up. Maximum is set by ",(0,r.jsx)("code",{children:"MAX_FAILOVER_ATTEMPTS"})," (currently"," ",(null==B||null==(h=B.settings)||null==(p=h.limits)?void 0:p.maxFailoverAttempts)??5,")."]}),min:1,max:(null==B||null==(g=B.settings)||null==(x=g.limits)?void 0:x.maxFailoverAttempts)??5,defaultValue:3,disabled:!(null==(f=K.failover)?void 0:f.enabled),value:(null==(b=K.failover)?void 0:b.maxAttempts)??3,onValueChange:e=>{var t,s;let a=(null==B||null==(s=B.settings)||null==(t=s.limits)?void 0:t.maxFailoverAttempts)??5;H(t=>({...t,failover:{...t.failover,maxAttempts:Math.min(a,Math.max(1,Number(e||3)))}}))}}),(0,r.jsx)(n1,{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==B||null==(y=B.settings)||null==(v=y.limits)?void 0:v.maxFailoverAttempts)??5,defaultValue:2,disabled:!(null==(j=K.failover)?void 0:j.enabled),value:(null==(w=K.failover)?void 0:w.sameReleaseLimit)??2,onValueChange:e=>{var t,s;let a=(null==B||null==(s=B.settings)||null==(t=s.limits)?void 0:t.maxFailoverAttempts)??5;H(t=>({...t,failover:{...t.failover,sameReleaseLimit:Math.min(a,Math.max(0,Number(e??2)))}}))}}),(0,r.jsx)(n1,{label:"Parallel Attempts",help:(0,r.jsxs)(r.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,r.jsx)("code",{children:"MAX_PARALLEL_ATTEMPTS"})," ","(currently ",(null==B||null==(k=B.settings)||null==(N=k.limits)?void 0:N.maxParallelAttempts)??2,")."]}),min:1,max:(null==B||null==(C=B.settings)||null==(S=C.limits)?void 0:S.maxParallelAttempts)??2,defaultValue:1,disabled:!(null==(_=K.failover)?void 0:_.enabled),value:(null==(A=K.failover)?void 0:A.parallel)??1,onValueChange:e=>{var t,s;let a=(null==B||null==(s=B.settings)||null==(t=s.limits)?void 0:t.maxParallelAttempts)??2;H(t=>({...t,failover:{...t.failover,parallel:Math.min(a,Math.max(1,Number(e||1)))}}))}}),((null==(R=K.failover)?void 0:R.parallel)??1)>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u9,{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==(T=K.failover)?void 0:T.enabled),value:(null==(I=K.failover)?void 0:I.staggerMs)??1e3,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,staggerMs:e}}))}}),(0,r.jsx)(u9,{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==(E=K.failover)?void 0:E.enabled),value:(null==(M=K.failover)?void 0:M.duplicateStaggerMs)??0,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,duplicateStaggerMs:e}}))}}),(0,r.jsx)(u9,{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==(P=K.failover)?void 0:P.enabled),value:(null==(D=K.failover)?void 0:D.preferredGraceMs)??2e3,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,preferredGraceMs:e}}))}}),(0,r.jsx)(u9,{label:"Max wait",help:"Overall deadline for the parallel chain before giving up and serving an error.",min:1e3,disabled:!(null==($=K.failover)?void 0:$.enabled),value:(null==(L=K.failover)?void 0:L.maxWaitMs)??3e4,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,maxWaitMs:e}}))}})]}),(0,r.jsx)(rZ,{label:"During Pre-cache",side:"right",disabled:!(null==(O=K.failover)?void 0:O.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==(U=K.failover)?void 0:U.precacheFailover)??!1,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,precacheFailover:e}}))}}),(0,r.jsx)(r0,{label:"Failover Position",disabled:!(null==(F=K.failover)?void 0:F.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==(z=K.failover)?void 0:z.position)??"last",onValueChange:e=>{H(t=>({...t,failover:{...t.failover,position:e}}))}})]}),(0,r.jsx)(u6,{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,r.jsx)(rZ,{label:"Enable",side:"right",value:K.autoRemoveDownloads??!1,onValueChange:e=>{H(t=>({...t,autoRemoveDownloads:e}))}})}),(0,r.jsx)(u6,{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,r.jsx)(rZ,{label:"Enable",side:"right",value:K.checkOwned??!0,onValueChange:e=>{H(t=>({...t,checkOwned:e}))}})}),(0,r.jsxs)(u6,{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,r.jsx)(rZ,{label:"Enable",side:"right",value:null==(V=K.cacheAndPlay)?void 0:V.enabled,onValueChange:e=>{H(t=>({...t,cacheAndPlay:{...t.cacheAndPlay,enabled:e}}))}}),(0,r.jsx)(nJ,{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==(q=K.cacheAndPlay)?void 0:q.streamTypes)??["usenet"],onValueChange:e=>{H(t=>({...t,cacheAndPlay:{...t.cacheAndPlay,streamTypes:e}}))}})]})]})}let u7="Provided by this instance (enter your own to override)";function me(){let{status:e}=tr(),{userData:t,setUserData:s}=aY(),a=null==e?void 0:e.settings.metadata,n=!!(null==a?void 0:a.tmdb.accessToken),l=!!(null==a?void 0:a.tmdb.apiKey),i=!!(null==a?void 0:a.tvdb.apiKey);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u6,{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,r.jsx)(Z,{autoComplete:"new-password",label:"TMDB Read Access Token",help:(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("p",{children:["You can get it from your"," ",(0,r.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:!n&&!l,value:t.tmdbAccessToken,placeholder:n?u7:"Enter your TMDB access token",onValueChange:e=>{s(t=>({...t,tmdbAccessToken:e}))}}),(0,r.jsx)(Z,{autoComplete:"new-password",label:"TMDB API Key",help:(0,r.jsxs)("span",{children:["You can get it from your"," ",(0,r.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:l?u7:"Enter your TMDB API Key",value:t.tmdbApiKey,onValueChange:e=>{s(t=>({...t,tmdbApiKey:e}))}})]}),(0,r.jsx)(u6,{id:"tvdbApiKey",title:"TVDB",description:"Provide your TVDB API key to also fetch metadata from TVDB.",children:(0,r.jsx)(Z,{autoComplete:"new-password",label:"TVDB API Key",value:t.tvdbApiKey,placeholder:i?u7:"Enter your TVDB API Key",help:(0,r.jsxs)("span",{children:["Sign up for a ",(0,r.jsx)("b",{children:"free"})," API Key at"," ",(0,r.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 mt(){let{userData:e,setUserData:t}=aY();return(0,r.jsxs)(u6,{title:"Poster Service",description:"Select a poster service to use for catalogs that support it.",children:[(0,r.jsx)(r0,{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,r.jsx)(Z,{autoComplete:"new-password",label:"RPDB API Key",help:(0,r.jsxs)("span",{children:["Get your API Key from"," ",(0,r.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,r.jsx)(Z,{autoComplete:"new-password",label:"TOP Posters API Key",help:(0,r.jsxs)("span",{children:["Get your API Key from"," ",(0,r.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Z,{autoComplete:"new-password",label:"AIOratings API Key",help:(0,r.jsxs)("span",{children:["Get your API Key from"," ",(0,r.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,r.jsx)(G,{label:"AIOratings Profile ID",help:(0,r.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,r.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Z,{autoComplete:"new-password",label:"OpenPosterDB API Key",help:(0,r.jsxs)("span",{children:["Get your API Key from"," ",(0,r.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,r.jsx)(G,{label:"OpenPosterDB URL",help:(0,r.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,r.jsx)(G,{label:"OpenPosterDB Custom Parameters",help:(0,r.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,r.jsx)("code",{children:"?"}),", for example"," ",(0,r.jsx)("code",{children:"ratings_limit=2&badge_size=l&position=br"}),". See the"," ",(0,r.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,r.jsx)(rZ,{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,r.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,r.jsx)(rZ,{label:"Use Poster Redirect API",side:"right",disabled:"none"===e.posterService||!e.rpdbApiKey&&!e.topPosterApiKey&&!e.aioratingsApiKey&&!e.openposterdbApiKey,help:(0,r.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 ms(){return(0,r.jsx)(r6,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(ma,{})})}function ma(){let{mode:e}=sy(),{isInherited:t,hasParent:s}=aJ(),{tab:a,setTab:n}=a9("services");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{children:"Services"}),s&&t("services")&&(0,r.jsx)(uI,{section:"services"})]}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Configure your debrid, metadata, and poster services."})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(uw,{})})]}),(0,r.jsx)(uT,{tabs:[{value:"services",label:"Services",icon:(0,r.jsx)(lj.LIi,{className:"w-4 h-4 shrink-0"}),content:(0,r.jsx)(u0,{})},{value:"builtin",label:"Built-in",icon:(0,r.jsx)(lj.VSk,{className:"w-4 h-4 shrink-0"}),content:"pro"===e?(0,r.jsx)(u8,{}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,r.jsx)(lj.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,r.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Built-in addon settings are only available in Advanced mode."})]})},{value:"metadata",label:"Metadata",icon:(0,r.jsx)(lj.Hbo,{className:"w-4 h-4 shrink-0"}),content:(0,r.jsx)(me,{})},{value:"posters",label:"Posters",icon:(0,r.jsx)(lj.fZZ,{className:"w-4 h-4 shrink-0"}),content:(0,r.jsx)(mt,{})}],activeTab:a,onTabChange:n,defaultMobileOpen:"services"})]})}var mr=s(56738),mn=s(70254),ml=s(10820),mi=s(55008),mo=s(26286);function md(e){var t,s,a;let{preset:l,onAdd:i}
43=e,[o,d]=(0,n.useState)(!1);return(0,r.jsxs)(r.Fragment,{children:[(0,r.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:[l.BUILTIN&&(0,r.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:()=>d(!0),title:"Click to learn more about built-in addons",children:"Built-in"}),(0,r.jsxs)("div",{className:"z-[1] relative flex flex-col flex-1 gap-3",children:[(0,r.jsxs)("div",{className:"flex gap-3 pr-16",children:["custom"===l.ID?(0,r.jsx)("div",{className:"relative rounded-md size-12 bg-gray-950 overflow-hidden flex items-center justify-center",children:(0,r.jsx)(mo.A,{className:"w-6 h-6 text-[--brand]"})}):l.LOGO?(0,r.jsx)("div",{className:"relative rounded-md size-12 bg-gray-900 overflow-hidden",children:(0,r.jsx)("img",{src:l.LOGO,alt:l.NAME,className:"w-full h-full object-cover"})}):(0,r.jsx)("div",{className:"relative rounded-md size-12 bg-gray-950 overflow-hidden flex items-center justify-center",children:(0,r.jsx)("p",{className:"text-2xl font-bold",children:l.NAME[0].toUpperCase()})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-semibold line-clamp-1",children:l.NAME}),(0,r.jsx)("p",{className:"text-xs line-clamp-1 tracking-wide opacity-30",children:l.ID})]})]}),l.DESCRIPTION&&(0,r.jsx)(L,{trigger:(0,r.jsx)("p",{className:"text-sm text-[--muted] line-clamp-2 cursor-pointer",children:(0,r.jsx)(l_,{children:l.DESCRIPTION})}),children:(0,r.jsx)("p",{className:"text-sm",children:(0,r.jsx)(l_,{children:l.DESCRIPTION})})}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[null==(t=l.SUPPORTED_SERVICES)?void 0:t.map(e=>{let t=s5[e];return(0,r.jsx)(tO,{side:"top",trigger:(0,r.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=l.SUPPORTED_RESOURCES)?void 0:s.map(e=>(0,r.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=l.SUPPORTED_STREAM_TYPES)?void 0:a.map(e=>(0,r.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,r.jsx)("div",{className:"flex-1"}),l.DISABLED?(0,r.jsx)("div",{className:"mt-auto",children:(0,r.jsx)(lN,{intent:"alert",className:"w-full overflow-x-auto whitespace-nowrap",description:(0,r.jsx)(l_,{children:l.DISABLED.reason})})}):(0,r.jsx)("div",{className:"mt-auto",children:(0,r.jsx)(w,{size:"md",className:"w-full",intent:"primary-subtle",onClick:i,children:"Configure"})})]})]}),(0,r.jsx)(tJ,{open:o,onOpenChange:d,title:"What are Built-in Addons?",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.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,r.jsxs)("div",{className:"bg-[--subtle] rounded-lg p-3 space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"Why does this matter?"}),(0,r.jsxs)("ul",{className:"text-sm text-[--muted] space-y-1.5 list-disc list-inside",children:[(0,r.jsx)("li",{children:"Not affected by rate limits from other addon servers"}),(0,r.jsx)("li",{children:"Faster response times since there's no network delay"}),(0,r.jsx)("li",{children:"Exclusive to AIOStreams and can't be installed directly to Stremio"})]})]}),(0,r.jsx)("p",{className:"text-xs text-[--muted] italic",children:"Think of it like having the addon server built into AIOStreams itself!"})]})})]})}function mc(e){let{open:t,onOpenChange:s,mode:a,presetMetadata:l,initialValues:i={},onSubmit:o}=e,{mode:d}
43=sy(),[c,u]=(0,n.useState)(i);(0,n.useEffect)(()=>{t?u(i):setTimeout(()=>{u(i)},150)},[t,i]);let m=(null==l?void 0:l.OPTIONS)||[];"noob"===d&&(m=m.filter(e=>(null==e?void 0:e.showInSimpleMode)!==!1&&(null==e?void 0:e.advanced)!==!0));let p=m.every(e=>{var t;if(!e.required)return!0;let s=null==(t=c.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});return(0,r.jsx)(tJ,{open:t,description:(0,r.jsx)(l_,{children:null==l?void 0:l.DESCRIPTION}),onOpenChange:s,title:"add"===a?`Install ${null==l?void 0:l.NAME}`:`Edit ${null==l?void 0:l.NAME}`,children:(0,r.jsxs)("form",{className:"space-y-4",onSubmit:function(e){for(let s of(e.preventDefault(),m))if(s.constraints){var t;let e=null==(t=c.options)?void 0:t[s.id];if("string"==typeof e){if(s.constraints.min&&e.length<s.constraints.min)return x.oR.error(`${s.name} must be at least ${s.constraints.min} characters`),!1;if(s.constraints.max&&e.length>s.constraints.max)return x.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 x.oR.error(`${s.name} must be at least ${s.constraints.min}`),!1;if(s.constraints.max&&e>s.constraints.max)return x.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 x.oR.error(`${s.name} must be at most ${s.constraints.max} items`),!1;if(s.constraints.min&&e.length<s.constraints.min)return x.oR.error(`${s.name} must be at least ${s.constraints.min} items`),!1}}p?o(c):x.oR.error("Please fill in all required fields")},children:[m.map(e=>{var t;return(0,r.jsx)("div",{className:"mb-2",children:(0,r.jsx)(uG,{option:e,value:null==(t=c.options)?void 0:t[e.id],onChange:t=>u(s=>({...s,options:{...s.options,[e.id]:t}})),disabled:!1})},e.id)}),(0,r.jsx)(w,{className:"w-full mt-2",type:"submit",disabled:!p,children:"add"===a?"Install":"Update"})]})})}var mu=s(5524);let mm="flex items-center justify-end gap-2 md:contents",mp="shrink-0 mr-auto md:mr-0",mh="flex gap-1 justify-end md:order-last";function mx(e,t){let s=(0,n.useRef)(e);s.current=e;let a=(0,n.useRef)([]),r=(0,n.useRef)(0);for(;a.current.length<e.length;)a.current.push(`row-${r.current++}`);a.current.length=e.length;let[l,i]=(0,n.useState)(!1),o=(0,uV.FR)((0,uV.MS)(uV.AN),(0,uV.MS)(uV.IG,{activationConstraint:{delay:150,tolerance:8}}));(0,n.useEffect)(()=>{if(!l)return;let e=e=>e.preventDefault();return document.body.addEventListener("touchmove",e,{passive:!1}),()=>document.body.removeEventListener("touchmove",e)},[l]);let d=(0,n.useCallback)((e,r)=>{a.current=(0,uF.be)(a.current,e,r),t((0,uF.be)(s.current,e,r))},[t]),c=(0,n.useCallback)(e=>{a.current=a.current.filter((t,s)=>s!==e),t(s.current.filter((t,s)=>s!==e))},[t]),u=(0,n.useCallback)(e=>{i(!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&&d(r,n)},[d]);return{count:e.length,keyAt:e=>a.current[e],sortableIds:[...a.current],move:d,removeAt:c,dndProps:{sensors:o,modifiers:[uU.FN],onDragStart:()=>i(!0),onDragEnd:u}}}function mg(e){let{rows:t,children:s}=e;return(0,r.jsx)(uV.Mp,{...t.dndProps,children:(0,r.jsx)(uF.gB,{items:t.sortableIds,strategy:uF._G,children:(0,r.jsx)("div",{className:"space-y-2",children:s})})})}function mf(e){let{id:t,children:s}=e,{attributes:a,listeners:n,setNodeRef:l,transform:i,transition:o,isDragging:d}=(0,uF.gl)({id:t}),c={transform:uz.Ks.Transform.toString(i),transition:o,opacity:d?.5:1};return(0,r.jsx)("div",{ref:l,style:c,children:(0,r.jsxs)("div",{className:"px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 relative",children:[(0,r.jsx)("div",{className:"rounded-full w-6 h-auto bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move shrink-0",...a,...n}),(0,r.jsx)("div",{className:"flex-1 min-w-0 flex flex-col md:flex-row gap-2 md:items-center",children:s})]})})}function mb(e){let{rows:t,index:s}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(mu.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,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(mu.$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,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(mu.H8h,{}),intent:"alert-subtle","aria-label":"Remove",onClick:()=>t.removeAt(s)})]})}let mv="true";function my(){var e;let{userData:t,setUserData:s}=aY(),a=(null==(e=t.groups)?void 0:e.groupings)??[],l=(0,n.useCallback)(e=>{let t=[...e];t.length>0&&!t[0].condition&&(t[0]={...t[0],condition:mv}),s(e=>({...e,groups:{...e.groups,groupings:t}}))},[s]),i=mx(a,l),o=(e,t)=>{l(a.map((s,a)=>a===e?{...s,...t}:s))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.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,r.jsx)(mg,{rows:i,children:a.map((e,s)=>{let n,l=i.keyAt(s);return(0,r.jsxs)(mf,{id:l,children:[(0,r.jsx)("div",{className:mh,children:(0,r.jsx)(mb,{rows:i,index:s})}),(0,r.jsx)("div",{className:"md:flex-[2] min-w-0",children:(0,r.jsx)(nJ,{multiple:!0,maxDisplayedItems:3,value:e.addons,options:(n=new Set(a.flatMap((e,t)=>t!==s?e.addons:[])),t.presets.filter(e=>!n.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=>{o(s,{addons:e})}})}),(0,r.jsx)("div",{className:"md:flex-[3] min-w-0",children:(0,r.jsx)(G,{value:0===s?mv:e.condition,disabled:0===s,"aria-label":"Condition",placeholder:"count(totalStreams) < 4",onValueChange:e=>{o(s,{condition:e})}})})]},l)})}),(0,r.jsx)("div",{className:"mt-2 flex gap-2 items-center",children:(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(mu.OiG,{}),"aria-label":"Add group",onClick:()=>l([...a,{addons:[],condition:0===a.length?mv:""}])}),children:"Add group"})})]})}function mj(){var e,t,s,a,l,i;let{userData:o,setUserData:d}
43=aY(),[c,u]=(0,n.useState)(()=>{var e,t;return(null==(e=o.dynamicAddonFetching)?void 0:e.enabled)?"dynamic":(null==(t=o.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,r.jsxs)(u6,{title:"Addon Fetching Strategy",id:"fetchStrategy",description:"Choose how streams are fetched from your addons",children:[(0,r.jsx)(r0,{label:"Strategy",value:c,onValueChange:e=>{u(e),d(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,r.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](https://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."}[c]}),"groups"===c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(r0,{label:"Group Behaviour",value:(null==(e=o.groups)?void 0:e.behaviour)??"parallel",onValueChange:e=>{d(t=>({...t,groups:{...t.groups,behaviour:e}}))},options:[{label:"Parallel",value:"parallel"},{label:"Sequential",value:"sequential"}],help:(null==(t=o.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=o.groups)?void 0:s.behaviour)!=="sequential"&&(0,r.jsx)(r0,{label:"When a Condition Fails",value:(null==(a=o.groups)?void 0:a.onConditionFailure)??"stop",onValueChange:e=>{d(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==(l=o.groups)?void 0:l.onConditionFailure)??"stop"]}),(0,r.jsx)(my,{})]}),"dynamic"===c&&(0,r.jsx)(G,{label:"Exit Condition",placeholder:m[Math.floor(Math.random()*m.length)],value:(null==(i=o.dynamicAddonFetching)?void 0:i.condition)??"",onValueChange:e=>{d(t=>({...t,dynamicAddonFetching:{...t.dynamicAddonFetching,condition:e}}))},help:(0,r.jsxs)("p",{children:["Write the condition using"," ",(0,r.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,r.jsxs)("ul",{className:"list-disc list-inside space-y-1 ml-2 mt-2",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"totalStreams"}),": The total number of streams"]}
43),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"totalTimeTaken"}),": The total time taken to fetch the streams"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"queryType"}),": The type of query e.g. 'movie', 'series', or 'anime'"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"queriedAddons"}),": The addons that have been queried. Tip: use the ",(0,r.jsx)("code",{children:"in"})," operator to check if a specific addon has been queried."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"allAddons"}),": All addons that were intended to be used for that query."]})]})]})})]})}var mw=s(97737),mN=s(92814);function mk(e){let{catalog:t,onToggleEnabled:s,capitalise:a}=e,{attributes:l,listeners:i,setNodeRef:o,transform:d,transition:c,isDragging:u}=(0,uF.gl)({id:`${t.id}-${t.type}`}),{setUserData:m}=aY(),p=t.id.startsWith("aiostreams.merged."),h={transform:uz.Ks.Transform.toString(d),transition:c,opacity:u?.5:1},g=()=>{m(e=>{if(!e.catalogModifications)return e;let s=e.catalogModifications.findIndex(e=>e.id===t.id&&e.type===t.type);if(s<=0)return e;let a=[...e.catalogModifications],[r]=a.splice(s,1);return a.unshift(r),{...e,catalogModifications:a}})},f=()=>{m(e=>{if(!e.catalogModifications)return e;let s=e.catalogModifications.findIndex(e=>e.id===t.id&&e.type===t.type);if(s===e.catalogModifications.length-1)return e;let a=[...e.catalogModifications],[r]=a.splice(s,1);return a.push(r),{...e,catalogModifications:a}})},b=t.shuffle?"shuffle":t.reverse?"reverse":"default",v=["default","shuffle","reverse"],[y,j]=(0,n.useState)(!1),[N,k]=(0,n.useState)(t.name||""),[S,C]=(0,n.useState)(t.overrideType||t.type||""),_="text-xl h-8 w-8 lg:text-2xl lg:h-10 lg:w-10";return(0,r.jsxs)("li",{ref:o,style:h,children:[(0,r.jsxs)("div",{className:"relative px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute top-2 bottom-2 left-2 w-5 bg-[var(--muted)] md:bg-[var(--subtle)] md:hover:bg-[var(--subtle-highlight)] cursor-move flex-shrink-0 rounded-full",...l,...i}),(0,r.jsxs)("div",{className:"pl-8 pr-3 py-3",children:[(0,r.jsxs)("div",{className:"mb-4 md:mb-6 md:pr-40",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsxs)("h3",{className:"text-sm md:text-base font-medium line-clamp-1 truncate text-ellipsis",children:[t.name??t.id," -"," ",a(t.overrideType??t.type)]}),!p&&(0,r.jsx)(E,{className:"rounded-full h-5 w-5 md:h-6 md:w-6 flex-shrink-0",icon:(0,r.jsx)(t2.u6n,{}),intent:"primary-subtle",onClick:()=>j(!0)})]}),(0,r.jsx)("p",{className:"text-xs md:text-sm text-[var(--muted-foreground)] mb-2 md:mb-0",children:p?"Merged Catalog":t.addonName}),(0,r.jsxs)("div",{className:"flex md:hidden items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(E,{rounded:!0,className:_,icon:(0,r.jsx)(J.TaX,{}),intent:"primary-subtle",onClick:g,title:"Move to top"}),(0,r.jsx)(E,{rounded:!0,className:_,icon:(0,r.jsx)(J.KVh,{}),intent:"primary-subtle",onClick:f,title:"Move to bottom"})]}),(0,r.jsx)(rZ,{value:t.enabled??!0,onValueChange:s,moreHelp:"Enable or disable this catalog from being used"})]}),(0,r.jsxs)("div",{className:"hidden md:flex items-center justify-end gap-2 absolute top-4 right-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(E,{rounded:!0,icon:(0,r.jsx)(J.TaX,{}),intent:"primary-subtle",onClick:g,title:"Move to top"}),(0,r.jsx)(E,{rounded:!0,icon:(0,r.jsx)(J.KVh,{}),intent:"primary-subtle",onClick:f,title:"Move to bottom"})]}),(0,r.jsx)(rZ,{value:t.enabled??!0,onValueChange:s,moreHelp:"Enable or disable this catalog from being used"})]})]})," ",(0,r.jsx)(uS,{type:"single",collapsible:!0,children:(0,r.jsxs)(uC,{value:"settings",children:[(0,r.jsx)(u_,{children:(0,r.jsxs)("div",{className:"flex items-center justify-center md:justify-between w-full",children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-[var(--muted-foreground)] uppercase tracking-wide hidden md:block",children:"Settings"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mr-2",children:[p&&(0,r.jsx)(tO,{trigger:(0,r.jsx)("div",{className:"flex items-center justify-center h-10 w-10 rounded-full bg-[var(--brand-subtle)]",children:(0,r.jsx)(J.dPp,{className:"text-xl text-[var(--brand)]"})}),children:"Merged Catalog"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{className:"text-2xl h-10 w-10",icon:t.shuffle?(0,r.jsx)(ut.xAZ,{}):t.reverse?(0,r.jsx)(ut.oWm,{}):(0,r.jsx)(ut.j6T,{}),intent:"primary-subtle",rounded:!0,onClick:e=>{e.stopPropagation(),m(e=>{var s,a;if(!(null==(s=e.catalogModifications)?void 0:s.find(e=>e.id===t.id&&e.type===t.type)))return e;let r=v[(v.indexOf(b)+1)%v.length];return{...e,catalogModifications:null==(a=e.catalogModifications)?void 0:a.map(e=>e.id===t.id&&e.type===t.type?{...e,shuffle:"shuffle"===r,reverse:"reverse"===r}:e)}})}}),children:b.charAt(0).toUpperCase()+b.slice(1)}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{className:"text-2xl h-10 w-10",icon:t.usePosterService?(0,r.jsx)(mN.PYM,{}):(0,r.jsx)(mN.h4A,{}),intent:"primary-subtle",rounded:!0,onClick:e=>{e.stopPropagation(),m(e=>{var s;return{...e,catalogModifications:null==(s=e.catalogModifications)?void 0:s.map(e=>e.id===t.id&&e.type===t.type?{...e,usePosterService:!e.usePosterService}:e)}})}}),children:"Poster Services"}),t.hideable&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{className:"text-2xl h-10 w-10",icon:t.onlyOnDiscover?(0,r.jsx)(mw.o$K,{}):(0,r.jsx)(mw.tTb,{}),disabled:t.onlyOnSearch,intent:"primary-subtle",rounded:!0,onClick:e=>{e.stopPropagation(),m(e=>{var s;return{...e,catalogModifications:null==(s=e.catalogModifications)?void 0:s.map(e=>e.id===t.id&&e.type===t.type?{...e,onlyOnDiscover:!e.onlyOnDiscover}:e)}})}}),children:"Discover Only"}),t.searchable&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{className:"text-2xl h-10 w-10",icon:t.onlyOnSearch?(0,r.jsx)(ml.TOn,{}):t.disableSearch?(0,r.jsx)(mw.QDx,{}):(0,r.jsx)(mw.PuI,{}),intent:"primary-subtle",rounded:!0,onClick:e=>{e.stopPropagation(),m(e=>{var s;return{...e,catalogModifications:null==(s=e.catalogModifications)?void 0:s.map(e=>e.id!==t.id||e.type!==t.type?e:e.onlyOnSearch||e.disableSearch?e.onlyOnSearch?{...e,onlyOnSearch:!1,disableSearch:!0}:{...e,disableSearch:!1}:{...e,onlyOnSearch:!0,onlyOnDiscover:!1})}})}}),children:t.onlyOnSearch?"Search Only":t.disableSearch?"Search Disabled":"Searchable"})]})]})}),(0,r.jsx)(uA,{children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(rZ,{label:"Shuffle",help:"Randomize the order of catalog items on each request",side:"right",value:t.shuffle??!1,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,shuffle:e,reverse:!e&&s.reverse}:s)}})}}),(0,r.jsx)(rZ,{label:"Reverse Order",help:"Reverse the order of catalog items",side:"right",value:t.reverse??!1,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,reverse:e,shuffle:!e&&s.shuffle}:s)}})}}),(0,r.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center gap-2 -mx-2 px-2 hover:bg-[var(--subtle-highlight)] rounded-md",children:[(0,r.jsxs)("div",{className:"flex-1 py-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Persist Shuffle For"}),(0,r.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,r.jsx)("div",{className:"w-full md:w-32 py-2",children:(0,r.jsx)(n1,{value:t.persistShuffleFor??0,min:0,step:1,max:24,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,persistShuffleFor:e}:s)}})}})})]}),(0,r.jsx)(rZ,{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=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,usePosterService:e}:s)}})}}),t.hideable&&(0,r.jsx)(rZ,{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=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,onlyOnDiscover:e,onlyOnSearch:!e&&s.onlyOnSearch}:s)}})}}),t.searchable&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rZ,{label:"Search Only",help:"Only show this catalog when searching",side:"right",value:t.onlyOnSearch??!1,disabled:t.disableSearch,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,onlyOnSearch:e,onlyOnDiscover:!e&&s.onlyOnDiscover}:s)}})}}),(0,r.jsx)(rZ,{label:"Disable Search",help:"Disable the search for this catalog",side:"right",value:t.disableSearch??!1,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,disableSearch:e,onlyOnSearch:!e&&s.onlyOnSearch}:s)}})}})]})]})})})]})})]})]}),(0,r.jsx)(tJ,{open:y,onOpenChange:j,title:"Edit Catalog Name",children:(0,r.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),S?(m(e=>{var s;return{...e,catalogModifications:null==(s=e.catalogModifications)?void 0:s.map(e=>e.id===t.id&&e.type===t.type?{...e,name:N,overrideType:S}:e)}}),j(!1)):x.oR.error("Type cannot be empty")},children:[(0,r.jsx)(G,{label:"Name",placeholder:"Enter catalog name",value:N,onValueChange:k}),(0,r.jsx)(G,{label:"Type",placeholder:"Enter catalog type",value:S,onValueChange:C}),(0,r.jsx)(w,{className:"w-full",type:"submit",children:"Save Changes"})]})})]})}function mS(e){var t,s,a;let{loading:l,fetchCatalogsData:i}=e,{userData:o,setUserData:d}=aY(),c=(0,n.useRef)((null==(t=o.mergedCatalogs)?void 0:t.length)??0);(0,n.useEffect)(()=>{var e;let t=(null==(e=o.mergedCatalogs)?void 0:e.length)??0;t!==c.current&&(c.current=t,i(!0))},[null==(s=o.mergedCatalogs)?void 0:s.length,i]);let u=e=>e?e.charAt(0).toUpperCase()+e.slice(1):"",m=(0,n.useMemo)(()=>{let e=new Set;for(let t of(o.mergedCatalogs||[]).filter(e=>!1!==e.enabled))for(let s of t.catalogIds){let t=new URLSearchParams(s),a=t.get("id"),r=t.get("type");a&&r&&e.add(`${a}-${r}`)}return e},[o.mergedCatalogs]),p=(0,uV.FR)((0,uV.MS)(uV.AN),(0,uV.MS)(uV.IG,{activationConstraint:{delay:150,tolerance:8}}
43)),[h,x]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{function e(e){h&&e.preventDefault()}function t(){x(!1)}return h?(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)}},[h]),(0,r.jsxs)(u6,{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,r.jsx)(E,{size:"sm",intent:"warning-subtle",icon:(0,r.jsx)(ml.joZ,{}),rounded:!0,onClick:()=>{i()},loading:l}),children:[!(null==(a=o.catalogModifications)?void 0:a.length)&&(0,r.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 :/"}),o.catalogModifications&&o.catalogModifications.length>0&&(0,r.jsx)(uV.Mp,{modifiers:[uU.FN],onDragEnd:e=>{let{active:t,over:s}=e;s&&(t.id!==s.id&&d(e=>{var a,r;let n=null==(a=e.catalogModifications)?void 0:a.findIndex(e=>`${e.id}-${e.type}`===t.id),l=null==(r=e.catalogModifications)?void 0:r.findIndex(e=>`${e.id}-${e.type}`===s.id);return void 0!==n&&void 0!==l&&e.catalogModifications?{...e,catalogModifications:(0,uF.be)(e.catalogModifications,n,l)}:e}),x(!1))},onDragStart:()=>{x(!0)},sensors:p,children:(0,r.jsx)(uF.gB,{items:(o.catalogModifications||[]).map(e=>`${e.id}-${e.type}`),strategy:uF._G,children:(0,r.jsx)("ul",{className:"space-y-2",children:(o.catalogModifications||[]).filter(e=>!m.has(`${e.id}-${e.type}`)).map(e=>(0,r.jsx)(mk,{catalog:e,onToggleEnabled:t=>{d(s=>{var a,r;let n={catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===e.id&&s.type===e.type?{...s,enabled:t}:s)};return e.id.startsWith("aiostreams.merged.")&&(n.mergedCatalogs=null==(r=s.mergedCatalogs)?void 0:r.map(s=>s.id===e.id?{...s,enabled:t}:s)),{...s,...n}})},capitalise:u},`${e.id}-${e.type}`))})})})]})}function mC(){var e,t;let s,{userData:a,setUserData:l}=aY(),{status:i}=tr(),o=(null==i||null==(t=i.settings)||null==(e=t.limits)?void 0:e.maxMergedCatalogSources)??10,[d,c]=(0,n.useState)(!1),[u,m]=(0,n.useState)(null),[p,h]=(0,n.useState)(""),[g,f]=(0,n.useState)("movie"),[b,v]=(0,n.useState)([]),[y,j]=(0,n.useState)(["id"]),[N,k]=(0,n.useState)("sequential"),[S,C]=(0,n.useState)(""),[_,A]=(0,n.useState)(new Set),[R,I]=(0,n.useState)(null),M=tX({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:()=>{R&&(l(e=>{var t,s;return{...e,mergedCatalogs:null==(t=e.mergedCatalogs)?void 0:t.filter(e=>e.id!==R),catalogModifications:null==(s=e.catalogModifications)?void 0:s.filter(e=>e.id!==R)}}),I(null),x.oR.success("Merged catalog deleted"))}}),P=a.mergedCatalogs||[],D=e=>e?e.charAt(0).toUpperCase()+e.slice(1):"",$=(a.catalogModifications||[]).filter(e=>!e.id.startsWith("aiostreams.merged.")).map(e=>({value:`id=${encodeURIComponent(e.id)}&type=${encodeURIComponent(e.type)}`,name:e.name||e.id,catalogType:e.type,addonName:e.addonName||"Unknown Addon",isDisabled:!1===e.enabled})),L=Object.entries($.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(S.toLowerCase())||e.addonName.toLowerCase().includes(S.toLowerCase())||e.catalogType.toLowerCase().includes(S.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},{});return(0,r.jsxs)(u6,{title:"Merged Catalogs",id:"mergedCatalogs",description:"Combine multiple catalogs into a single merged catalog. Useful for creating custom collections from different sources.",action:(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(mu.OiG,{}),rounded:!0,onClick:()=>{m(null),h(""),f("movie"),v([]),j(["id"]),k("sequential"),C(""),A(new Set),c(!0)}}),children:[0===P.length&&(0,r.jsx)("p",{className:"text-[--muted] text-base text-center my-8",children:"No merged catalogs yet. Click the + button to create one."}),P.length>0&&(0,r.jsx)("ul",{className:"space-y-2",children:P.map(e=>(0,r.jsx)("li",{children:(0,r.jsxs)("div",{className:"relative px-4 py-3 bg-[var(--background)] rounded-[--radius-md] border overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-[var(--subtle)] flex-shrink-0",children:(0,r.jsx)(J.dPp,{className:"text-xl"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm md:text-base font-medium truncate",children:e.name}),(0,r.jsxs)("p",{className:"text-xs text-[var(--muted-foreground)]",children:[D(e.type)," • ",e.catalogIds.length," catalogs"]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(E,{className:"h-8 w-8",icon:(0,r.jsx)(t2.u6n,{}),intent:"primary-subtle",rounded:!0,onClick:()=>{m(e),h(e.name),f(e.type),v(e.catalogIds),j(e.deduplicationMethods??["
43id"]),k(e.mergeMethod??"sequential"),C(""),A(new Set),c(!0)}}),(0,r.jsx)(E,{className:"h-8 w-8",icon:(0,r.jsx)(t2.id1,{}),intent:"alert-subtle",rounded:!0,onClick:()=>{var t;return t=e.id,void(l(e=>({...e,mergedCatalogs:(e.mergedCatalogs||[]).filter(e=>e.id!==t),catalogModifications:(e.catalogModifications||[]).filter(e=>e.id!==t)})),x.oR.success("Merged catalog deleted"))}})]})]}),(0,r.jsx)(uS,{type:"single",collapsible:!0,className:"mt-2",children:(0,r.jsxs)(uC,{value:"settings",children:[(0,r.jsx)(u_,{children:(0,r.jsx)("div",{className:"flex items-center justify-center md:justify-between w-full",children:(0,r.jsxs)("h4",{className:"text-xs font-medium text-[var(--muted-foreground)] uppercase tracking-wide hidden md:block",children:["Included Catalogs (",e.catalogIds.length,")"]})})}),(0,r.jsx)(uA,{children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.catalogIds.map(t=>{let s=$.find(e=>e.value===t),a=!s,n=e.catalogIds.filter(e=>$.find(t=>t.value===e)).length,i=!a&&1===n,o=1===e.catalogIds.length;return(0,r.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,r.jsx)("span",{className:"font-medium text-[var(--foreground)]",children:s?s.name:"Unavailable Catalog"}),(null==s?void 0:s.isDisabled)&&(0,r.jsx)("span",{className:"text-[10px] px-1 py-0.5 rounded text-[--red]",children:"Disabled"}),s&&(0,r.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:D(s.catalogType)}),(0,r.jsx)(T,{type:"button",className:"ml-0.5",size:"sm",onClick:s=>{if(s.stopPropagation(),i)return void x.oR.error("Cannot remove the last available catalog. Add another catalog first or delete the merged catalog.");if(o&&a){I(e.id),M.open();return}l(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:i?"Cannot remove last available catalog":"Remove catalog"})]},t)})})})})]})})]})},e.id))}),(0,r.jsx)(tJ,{open:d,onOpenChange:c,title:u?"Edit Merged Catalog":"Create Merged Catalog",children:(0,r.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),(()=>{if(!p.trim())return x.oR.error("Name is required");if(!g.trim())return x.oR.error("Type is required");if(b.length<2)return x.oR.error("Select at least 2 catalogs to merge");if(b.length>o)return x.oR.error(`Maximum ${o} source catalogs allowed per merged catalog`);if(u)l(e=>({...e,catalogModifications:(e.catalogModifications||[]).map(e=>e.id===u.id&&e.type===u.type?{...e,name:p.trim(),type:g.trim()}:e),mergedCatalogs:(e.mergedCatalogs||[]).map(e=>e.id===u.id?{...e,name:p.trim(),type:g.trim(),catalogIds:b,deduplicationMethods:y.length>0?y:void 0,mergeMethod:N??"sequential"}:e)})),x.oR.success("Merged catalog updated");else{let e=`aiostreams.merged.${Date.now()}`;l(t=>({...t,mergedCatalogs:[...t.mergedCatalogs||[],{id:e,name:p.trim(),type:g.trim(),catalogIds:b,enabled:!0,deduplicationMethods:y.length>0?y:void 0,mergeMethod:N??"sequential"}]})),x.oR.success("Merged catalog created")}c(!1)})()},children:[(0,r.jsx)(G,{label:"Name",placeholder:"e.g., My Combined Movies",value:p,onValueChange:h}),(0,r.jsx)(G,{label:"Type",placeholder:"e.g., movie, series, anime",help:"The content type for this merged catalog (e.g., movie, series, anime, tv)",value:g,onValueChange:f}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Catalogs to Merge"}),(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:[b.length," selected"]})]}),(0,r.jsx)(G,{placeholder:"Search catalogs...",value:S,onValueChange:C}),(0,r.jsx)("div",{className:"border rounded-[--radius-md] h-64 overflow-y-auto",children:0===Object.keys(L).length?(0,r.jsx)("p",{className:"text-sm text-[--muted] text-center py-8",children:S?"No catalogs match your search":"No catalogs available"}):Object.entries(L).map(e=>{let[t,s]=e,a=_.has(t);return(0,r.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,r.jsxs)("div",{onClick:()=>{A(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,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.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,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),(0,r.jsx)("span",{className:"text-xs font-semibold text-[var(--muted-foreground)] uppercase tracking-wide",children:t})]}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsxs)("span",{className:"text-xs text-[var(--muted-foreground)]",children:[s.length," catalog",1!==s.length?"s":""]})})]}),a&&s.map(e=>{let t=b.includes(e.value);return(0,r.jsxs)("div",{onClick:()=>{var t;return t=e.value,void v(e=>e.includes(t)?e.filter(e=>e!==t):e.length>=o?(x.oR.error(`Maximum ${o} 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,r.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)]"}
43`,children:t&&(0,r.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)("span",{className:`text-sm font-medium truncate block ${e.isDisabled?"text-[var(--muted-foreground)]":""}`,children:e.name})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.isDisabled&&(0,r.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,r.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:D(e.catalogType)})]})]},e.value)})]},t)})}),b.length>0&&(0,r.jsxs)(r.Fragment,{children:[0===(s=b.filter(e=>!$.find(t=>t.value===e))).length?null:(0,r.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,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("p",{className:"text-sm text-orange-700 dark:text-orange-300",children:[s.length," unavailable catalog",1!==s.length?"s":""," found"]}),(0,r.jsx)(w,{type:"button",size:"sm",intent:"warning",onClick:()=>v(e=>e.filter(e=>$.find(t=>t.value===e))),children:"Remove All"})]})}),(0,r.jsxs)("div",{className:"text-xs text-[--muted]",children:["Selected (",b.length,"/",o,"):"," ",b.filter(e=>$.find(t=>t.value===e)).slice(0,3).map(e=>{let t=$.find(t=>t.value===e);return(null==t?void 0:t.name)||e}).join(", "),b.filter(e=>$.find(t=>t.value===e)).length>3&&` +${b.filter(e=>$.find(t=>t.value===e)).length-3} more`]})]})]}),(0,r.jsx)(nJ,{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:y,onValueChange:e=>j(e),placeholder:"None - Keep all items",emptyMessage:"No deduplication methods available"}),(0,r.jsx)(r0,{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:N??"sequential",onValueChange:e=>k(e)}),("imdbRating"===N||"releaseDateDesc"===N||"releaseDateAsc"===N)&&(0,r.jsx)(lN,{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,r.jsx)(w,{className:"w-full",type:"submit",children:u?"Save Changes":"Create Merged Catalog"})]})}),(0,r.jsx)(t0,{...M})]})}function m_(e){let{item:t}=e,{attributes:s,listeners:a,setNodeRef:n,transform:l,transition:i,isDragging:o}=(0,uF.gl)({id:t.instanceId}),d={transform:uz.Ks.Transform.toString(l),transition:i,opacity:o?.6:1,zIndex:10*!!o};return(0,r.jsxs)("li",{ref:n,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,r.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,r.jsx)("svg",{className:"w-4 h-4 text-[--muted]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{d:"M4 8h16M4 16h16",strokeLinecap:"round"})})}),(0,r.jsx)("div",{className:"relative flex-shrink-0 h-6 w-6",children:t.logo?(0,r.jsx)("img",{src:t.logo,alt:t.name,className:"absolute inset-0 w-full h-full object-contain rounded"}):"custom"===t.type?(0,r.jsx)(mo.A,{className:"w-full h-full text-[--brand]"}):(0,r.jsx)(mn.Yoo,{className:"w-full h-full text-[--brand]"})}),(0,r.jsx)("span",{className:"text-sm font-medium truncate flex-1",children:t.name}),!t.enabled&&(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[--subtle] text-[--muted] border border-[--border]",children:"Disabled"})]})}function mA(e){let{open:t,onOpenChange:s,presets:a,presetMetadataMap:l,manifestCache:i,onSave:o}
43=e,[d,c]=(0,n.useState)([]),[u,m]=(0,n.useState)(!1);(0,n.useEffect)(()=>{t&&c([...a])},[t,a]);let p=(0,uV.FR)((0,uV.MS)(uV.AN),(0,uV.MS)(uV.IG,{activationConstraint:{delay:150,tolerance:8}}));(0,n.useEffect)(()=>{function e(e){u&&e.preventDefault()}function t(){m(!1)}return u?(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)}},[u]);let h=d.map(e=>{var t;let s=l.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),r=a?i.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==r?void 0:r.logo)||e.logo||(null==s?void 0:s.LOGO),enabled:e.enabled??!0}});return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"Reorder Addon Priority",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.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,r.jsx)("b",{children:"when sorting by the addon criterion"}),"."]}),(0,r.jsx)(uV.Mp,{modifiers:[uU.FN],onDragEnd:function(e){let{active:t,over:s}=e;s&&(t.id!==s.id&&c(e=>{let a=e.findIndex(e=>e.instanceId===t.id),r=e.findIndex(e=>e.instanceId===s.id);return(0,uF.be)(e,a,r)}),m(!1))},onDragStart:()=>m(!0),sensors:p,children:(0,r.jsx)(uF.gB,{items:h.map(e=>e.instanceId),strategy:uF._G,children:(0,r.jsx)("ul",{className:"space-y-1.5 max-h-[60vh] overflow-y-auto pr-1",children:h.map(e=>(0,r.jsx)(m_,{item:e},e.instanceId))})})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{className:"flex-1",intent:"primary-subtle",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{className:"flex-1",onClick:()=>{o(d),s(!1)},children:"Save Order"})]})]})})}let mR=new Map,mT=[{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"}],mI={streams:mT[0],subtitles:mT[1],meta_catalogs:mT[2],misc:mT[3]},mE={streams:"Streams",subtitles:"Subtitles",meta_catalogs:"Metadata & Catalogs",misc:"Miscellaneous"};function mM(e,t){var s;let a;return e.category||(s=e.type,(null==(a=t.get(s))?void 0:a.CATEGORY)||"streams")}function mP(e,t){if(mI[e])return mI[e];let s=null==t?void 0:t[e];if(s){let e=mT.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 mT[Math.abs(a)%mT.length]}function mD(e){let{onEdit:t}=e,{userData:s,setUserData:a}=aY(),{status:l}=tr(),{mode:i}
43=sy(),[o,d]=(0,n.useState)(new Set),[c,u]=(0,n.useState)("all"),[m,p]=(0,n.useState)(""),h=tQ(!1),g=tQ(!1),f=tQ(!1),[b,v]=(0,n.useState)("pick"),[y,j]=(0,n.useState)(new Set),[N,k]=(0,n.useState)({}),[S,C]=(0,n.useState)(""),[_,A]=(0,n.useState)("blue"),R=(0,n.useMemo)(()=>{var e;let t=new Map;if(null==l||null==(e=l.settings)?void 0:e.presets)for(let e of l.settings.presets)t.set(e.ID,e);return t},[l]),T=(0,n.useMemo)(()=>{let e=new Map;for(let t of s.presets){let s=mM(t,R);e.set(s,(e.get(s)||0)+1)}return e},[s.presets,R]),I=(0,n.useMemo)(()=>{let e=["streams","subtitles","meta_catalogs","misc"];return[...e.filter(e=>T.has(e)),...[...T.keys()].filter(t=>!e.includes(t)).sort((e,t)=>s.presets.findIndex(t=>mM(t,R)===e)-s.presets.findIndex(e=>mM(e,R)===t))]},[T,s.presets,R]),M=(0,n.useMemo)(()=>{let e=s.presets;if("all"!==c&&(e=e.filter(e=>mM(e,R)===c)),m.trim()){let t=m.toLowerCase();e=e.filter(e=>{var s;return((null==(s=e.options)?void 0:s.name)||"").toLowerCase().includes(t)})}return e},[s.presets,R,c,m]),P=(0,n.useMemo)(()=>{let e={};for(let t of M){let s=mM(t,R);e[s]||(e[s]=[]),e[s].push(t)}return e},[M,R]),D=M.length>0&&M.every(e=>o.has(e.instanceId)),$=o.size>0,L=(0,n.useMemo)(()=>{let e=s.presets.filter(e=>o.has(e.instanceId)),t=e.filter(e=>e.enabled).length;return e.filter(e=>!e.enabled).length>t},[s.presets,o]),O=e=>{d(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};(0,n.useEffect)(()=>{d(new Set)},[c,m]);let U=(0,n.useMemo)(()=>{if(0===o.size)return[];let e=s.presets.filter(e=>o.has(e.instanceId)),t=new Map;for(let s of e){let e=R.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)},[o,s.presets,R]),F=tX({title:"Delete Selected Addons",description:`Are you sure you want to delete ${o.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=>!o.has(e.instanceId)),aq(t)}),d(new Set)}}),z=e=>{a(t=>({...t,presets:t.presets.map(t=>o.has(t.instanceId)?{...t,category:e}:t)})),x.oR.info(e?`Categorised ${o.size} addon(s) as "${e}"`:`Reset category for ${o.size} addon(s)`),f.close()},V=e=>mE[e]||e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u6,{title:"My Addons",description:"Manage your installed addons. Reorder, batch edit, or categorise by type.",action:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(E,{rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(J.CBv,{className:"w-5 h-5"}),onClick:()=>h.open(),disabled:s.presets.length<2,title:"Reorder Priority"}),(0,r.jsx)(E,{rounded:!0,intent:D?"primary":"primary-subtle",icon:(0,r.jsx)(J.hpl,{className:"w-5 h-5"}),onClick:()=>{D?d(new Set):d(new Set(M.map(e=>e.instanceId)))},disabled:0===M.length,title:D?"Deselect All":"Select All"})]}),children:[s.presets.length>0&&(0,r.jsxs)("div",{className:"space-y-3 mb-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-1 min-w-[140px]",children:(0,r.jsx)(G,{value:m,onChange:e=>p(e.target.value),placeholder:"Search addons...",leftIcon:(0,r.jsx)(mr.A,{className:"w-4 h-4"})})}),$&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 animate-in fade-in duration-150",children:[(0,r.jsxs)("span",{className:"text-xs font-semibold text-[--brand] whitespace-nowrap",children:[o.size," selected"]}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"primary-subtle",icon:L?(0,r.jsx)(J.lXh,{className:"w-3.5 h-3.5"}):(0,r.jsx)(J.czG,{className:"w-3.5 h-3.5"}),onClick:()=>{a(e=>({...e,presets:e.presets.map(e=>o.has(e.instanceId)?{...e,enabled:L}:e)}))},title:L?"Enable selected":"Disable selected"}),"pro"===i&&U.length>0&&(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(J.H6t,{className:"w-3.5 h-3.5"}),onClick:()=>{v("pick"),j(new Set),k({}),g.open()},title:"Edit common fields"}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(J.kIN,{className:"w-3.5 h-3.5"}),onClick:()=>f.open(),title:"Set category"}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"alert-subtle",icon:(0,r.jsx)(J.Mst,{className:"w-3.5 h-3.5"}),onClick:()=>F.open(),title:"Delete selected"})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,r.jsxs)("button",{onClick:()=>u("all"),className:`px-2.5 py-1 text-xs font-medium rounded-full border transition-colors ${"all"===c?"bg-[--brand]/20 text-[--brand] border-[--brand]/50":"bg-transparent text-[--muted] border-[--border] hover:bg-[--subtle]"}`,children:["All (",s.presets.length,")"]}),I.map(e=>{let t=T.get(e)||0,a=mP(e,s.addonCategoryColors);return(0,r.jsxs)("button",{onClick:()=>u(c===e?"all":e),className:`px-2.5 py-1 text-xs font-medium rounded-full border transition-colors ${c===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,r.jsx)("div",{className:"flex flex-col items-center justify-center py-12",children:(0,r.jsxs)("span",{className:"text-lg text-muted-foreground font-semibold text-center",children:["Looks like you don't have any addons...",(0,r.jsx)("br",{}),"Add some from the marketplace!"]})}):0===M.length?(0,r.jsx)("div",{className:"flex flex-col items-center justify-center py-8",children:(0,r.jsx)("span",{className:"text-sm text-[--muted]",children:"No addons match your search."})}):"all"!==c||m.trim()?(0,r.jsx)("ul",{className:"space-y-1.5",children:M.map(e=>(0,r.jsx)(m$,{preset:e,presetMetadata:R.get(e.type),isSelected:o.has(e.instanceId),onToggleSelect:()=>O(e.instanceId),onEdit:()=>t(e,R.get(e.type)),onRemove:()=>{a(t=>{let s=structuredClone(t);return s.presets=s.presets.filter(t=>t.instanceId!==e.instanceId),aq(s)})},onToggleEnabled:t=>{a(s=>({...s,presets:s.presets.map(s=>s.instanceId===e.instanceId?{...s,enabled:t}:s)}))}},e.instanceId))}):(0,r.jsx)("div",{className:"space-y-4",children:I.map(e=>{let n=P[e];
43if(!n||0===n.length)return null;let l=mP(e,s.addonCategoryColors);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{className:"flex items-center gap-2 mb-2 group cursor-pointer",onClick:()=>{let e=n.map(e=>e.instanceId),t=e.every(e=>o.has(e));d(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,r.jsx)("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${l.swatch}`}),(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wider text-[--muted] group-hover:text-[--foreground] transition-colors",children:V(e)})]}),(0,r.jsx)("ul",{className:"space-y-1.5",children:n.map(e=>(0,r.jsx)(m$,{preset:e,presetMetadata:R.get(e.type),isSelected:o.has(e.instanceId),onToggleSelect:()=>O(e.instanceId),onEdit:()=>t(e,R.get(e.type)),onRemove:()=>{a(t=>{let s=structuredClone(t);return s.presets=s.presets.filter(t=>t.instanceId!==e.instanceId),aq(s)})},onToggleEnabled:t=>{a(s=>({...s,presets:s.presets.map(s=>s.instanceId===e.instanceId?{...s,enabled:t}:s)}))}},e.instanceId))})]},e)})})]}),(0,r.jsx)(mA,{open:h.isOpen,onOpenChange:h.toggle,presets:s.presets,presetMetadataMap:R,manifestCache:mR,onSave:e=>{a(t=>({...t,presets:e}))}}),(0,r.jsx)(tJ,{open:g.isOpen,onOpenChange:g.toggle,title:"pick"===b?"Choose Fields to Edit":"Edit Selected Fields",children:"pick"===b?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Select which fields to update across ",o.size," selected addon(s). Only fields common to all selected addons are shown."]}),(0,r.jsx)("div",{className:"space-y-1.5 max-h-[50vh] overflow-y-auto",children:U.map(e=>(0,r.jsxs)("button",{onClick:()=>{j(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 ${y.has(e.id)?"border-[--brand]/50 bg-[--brand]/10":"border-[--border] hover:bg-[--subtle]"}`,children:[(0,r.jsx)("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center flex-shrink-0 transition-colors ${y.has(e.id)?"bg-brand-600 border-brand-600":"border-gray-500"}`,children:y.has(e.id)&&(0,r.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:e.name}),e.description&&(0,r.jsx)("p",{className:"text-xs text-[--muted] line-clamp-1",children:e.description})]})]},e.id))}),(0,r.jsxs)(w,{className:"w-full",disabled:0===y.size,onClick:()=>{let e={};for(let t of y){let s=U.find(e=>e.id===t);s&&(e[t]=s.default??void 0)}k(e),v("edit")},children:["Continue (",y.size," field",1!==y.size?"s":"",")"]})]}):(0,r.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),a(e=>({...e,presets:e.presets.map(e=>{if(!o.has(e.instanceId))return e;let t=R.get(e.type),s=new Set(((null==t?void 0:t.OPTIONS)||[]).map(e=>e.id)),a={...e.options};for(let e of y)s.has(e)&&(a[e]=N[e]);return{...e,options:a}})})),g.close()},children:[[...y].map(e=>{let t=U.find(t=>t.id===e);return t?(0,r.jsx)("div",{children:(0,r.jsx)(uG,{option:t,value:N[e],onChange:t=>k(s=>({...s,[e]:t})),disabled:!1})},e):null}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(E,{rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(J.wwB,{className:"w-4 h-4"}),onClick:()=>v("pick"),title:"Back",type:"button"}),(0,r.jsxs)(w,{className:"flex-1",type:"submit",children:["Apply to ",o.size," addon(s)"]})]})]})}),(0,r.jsx)(tJ,{open:f.isOpen,onOpenChange:f.toggle,title:"Set Category",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Choose a category for the ",o.size," selected addon(s), or create a new one."]}),(0,r.jsxs)("div",{className:"space-y-1.5 max-h-[40vh] overflow-y-auto",children:[(0,r.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"}),I.map(e=>{let t=mP(e,s.addonCategoryColors);return(0,r.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,r.jsx)("span",{className:`inline-block w-3 h-3 rounded-full ${t.swatch}`}),(0,r.jsx)("span",{className:"text-sm",children:V(e)}),(0,r.jsx)("span",{className:"text-xs text-[--muted] ml-auto",children:T.get(e)||0})]},e)})]}),(0,r.jsxs)("div",{className:"pt-2 border-t border-[--border] space-y-3",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-[--muted] uppercase tracking-wide",children:"New Category"}),(0,r.jsx)(G,{value:S,onValueChange:C,placeholder:"e.g. Usenet, HTTP, Anime..."}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:mT.map(e=>(0,r.jsx)("button",{onClick:()=>A(e.key),className:`w-6 h-6 rounded-full ${e.swatch} transition-all ${_===e.key?"ring-2 ring-offset-2 ring-offset-[--background] ring-white/60 scale-110":"hover:scale-110"}`,title:e.key},e.key))}),(0,r.jsx)(w,{className:"w-full",size:"md",disabled:!S.trim(),onClick:()=>{var e;e=S.trim(),a(t=>({...t,presets:t.presets.map(t=>o.has(t.instanceId)?{...t,category:e}:t),addonCategoryColors:{...t.addonCategoryColors||{},[e]:_}})),x.oR.info(`Categorised ${o.size} addon(s) as "${e}"`),f.close(),C(""),C("")},children:"Create & Apply"})]})]})}),(0,r.jsx)(t0,{...F})]})}function m$(e){var t,s,a,l,i,o;let{preset:d,presetMetadata:c,isSelected:u,onToggleSelect:m,onEdit:p,onRemove:h,onToggleEnabled:g}=e,{setUserData:f}
43=aY(),[b,v]=(0,n.useState)(!1),[y,j]=(0,n.useState)(d.logo||(null==c?void 0:c.LOGO)),[N,k]=(0,n.useState)(1),S=tQ(!1),[C,_]=(0,n.useState)(""),[A,R]=(0,n.useState)(!1),T=tX({title:"Delete Addon",description:`Are you sure you want to delete "${(null==(t=d.options)?void 0:t.name)||"this addon"}"?`,actionText:"Delete",actionIntent:"alert",onConfirm:h}),I=e=>e.replace(/^stremio:\/\//,"https://").replace(/\/$/,""),M=()=>{if((null==c?void 0:c.ID)==="custom"||(null==c?void 0:c.ID)==="aiostreams")return d.options.manifestUrl;let e=d.options.url;if(e)try{if(new URL(e).pathname.endsWith("/manifest.json"))return e}catch{}};(0,n.useEffect)(()=>{S.isOpen&&k(1)},[S.isOpen]),(0,n.useEffect)(()=>{let e=!0,t=M();if(t){let a=I(t),r=mR.get(a);if(r){var s;v((null==(s=r.behaviorHints)?void 0:s.configurable)===!0),j(r.logo);return}fetch(a).then(e=>e.json()).then(t=>{if(mR.set(a,t),e){var s;v((null==t||null==(s=t.behaviorHints)?void 0:s.configurable)===!0),j(null==t?void 0:t.logo)}}).catch(()=>{e&&v(!1)})}return()=>{e=!1}},[null==c?void 0:c.ID,d.options.manifestUrl,d.options.url]);let P=async e=>{e.preventDefault();let t=I(C);if(!C)return void x.oR.error("Please enter a new manifest URL");if(!/^(https?|stremio):\/\/.+\/manifest\.json$/.test(t))return void x.oR.error("Please enter a valid manifest URL");try{R(!0);let e=await fetch(t);if(!e.ok)throw Error(`${e.status} ${e.statusText}`);await e.json()}catch(e){x.oR.error(`Failed to fetch or parse manifest: ${e.message}`),R(!1);return}f(e=>{let s=e.presets.find(e=>e.instanceId===d.instanceId);if(!s)return e;let a=(null==c?void 0:c.ID)==="custom"||(null==c?void 0:c.ID)==="aiostreams"?{...s.options,manifestUrl:t}:{...s.options,url:t};return{...e,presets:e.presets.map(e=>e.instanceId===d.instanceId?{...e,options:a}:e)}}),_(""),S.close(),x.oR.success("Manifest URL updated successfully"),R(!1)};return(0,r.jsxs)("li",{children:[(0,r.jsxs)("div",{className:`px-2.5 py-2 rounded-[--radius-md] border flex gap-2 sm:gap-3 items-center transition-colors ${u?"border-brand-500/50 bg-brand-500/10":"bg-[var(--background)] border-[--border]"}`,children:[(0,r.jsx)("button",{onClick:m,className:"flex items-center justify-center flex-shrink-0",children:(0,r.jsx)("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${u?"bg-brand-600 border-brand-600":"border-gray-500 hover:border-gray-400"}`,children:u&&(0,r.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})}),(0,r.jsx)("div",{className:"relative flex-shrink-0 h-8 w-8 hidden sm:block",children:y?(0,r.jsx)("img",{src:y,alt:(null==c?void 0:c.NAME)||"",className:"absolute inset-0 w-full h-full object-contain rounded-md"}):(null==c?void 0:c.ID)==="custom"?(0,r.jsx)(mo.A,{className:"w-full h-full object-contain text-[--brand]"}):(null==(a=d.options.name)||null==(s=a.trim())?void 0:s[0])?(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center rounded-md bg-gray-950",children:(0,r.jsx)("p",{className:"text-lg font-bold",children:(null==(o=d.options.name)||null==(i=o.trim())||null==(l=i[0])?void 0:l.toUpperCase())||"?"})}):(0,r.jsx)(mn.Yoo,{className:"w-full h-full object-contain text-[--brand]"})}),(0,r.jsx)("p",{className:"text-base line-clamp-1 truncate block flex-1 min-w-0",children:d.options.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[(0,r.jsx)(rZ,{value:d.enabled??!1,onValueChange:g}),b&&(0,r.jsx)(E,{className:"rounded-full h-8 w-8 md:h-10 md:w-10",icon:(0,r.jsx)(J.xPd,{}),intent:"primary-subtle",onClick:()=>S.open()}),(0,r.jsx)(E,{className:"rounded-full h-8 w-8 md:h-10 md:w-10",icon:(0,r.jsx)(t2.u6n,{}),intent:"primary-subtle",onClick:p}),(0,r.jsx)(E,{className:"rounded-full h-8 w-8 md:h-10 md:w-10",icon:(0,r.jsx)(t2.id1,{}),intent:"alert-subtle",onClick:()=>T.open()})]})]}),(0,r.jsxs)(tJ,{open:S.isOpen,onOpenChange:S.toggle,title:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"mr-1.5",children:"Reconfigure"}),(0,r.jsx)("span",{className:"font-semibold truncate overflow-hidden text-ellipsis",children:d.options.name})]}),titleClass:"truncate max-w-sm",children:[1===N&&(0,r.jsxs)("div",{className:"text-center space-y-4",children:[(0,r.jsx)("div",{className:"mx-auto bg-[--subtle] rounded-full h-12 w-12 flex items-center justify-center",children:(0,r.jsx)(J.TdP,{className:"h-6 w-6 text-[--brand]"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Reconfigure in a new tab"}),(0,r.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,r.jsx)(w,{className:"w-full",onClick:()=>{let e;window.open((e=M())?I(e).replace(/\/manifest\.json$/,"/configure"):"","_blank"),k(2)},children:(0,r.jsx)("span",{className:"truncate",children:"Take me to configuration"})})]}),2===N&&(0,r.jsxs)("div",{className:"space-y-4 max-w-md",children:[(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"mx-auto bg-[--subtle] rounded-full h-12 w-12 flex items-center justify-center",children:(0,r.jsx)(J.GzK,{className:"h-6 w-6 text-[--brand]"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Awaiting New URL"}),(0,r.jsx)("p",{className:"text-sm text-[var(--muted-foreground)]",children:"After adjusting your settings, copy the manifest URL and paste it below."})]}),(0,r.jsxs)("form",{onSubmit:P,className:"space-y-4 pt-2",children:[(0,r.jsx)(G,{type:"url",label:"New Manifest URL",placeholder:"Paste your new URL here",value:C,onValueChange:_,required:!0,autoFocus:!0}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{intent:"primary-subtle",onClick:()=>k(1),children:"Back"}),(0,r.jsxs)(w,{loading:A,type:"submit",className:"max-w-sm w-full text-ellipsis whitespace-nowrap overflow-hidden text-left",children:["Update ",d.options.name]})]})]})]})]}),(0,r.jsx)(t0,{...T})]})}function mL(){return(0,r.jsx)(r6,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(mO,{})})}function mO(){let{status:e}=tr(),{mode:t}=sy(),{userData:s,setUserData:a}=aY(),{isInherited:l,hasParent:i}
43=aJ(),[o,d]=(0,n.useState)("installed"),{tab:c,setTab:u}=a9("addons"),{mutate:m,isPending:p}=(0,e2.n)({mutationFn:e=>eP(e),onSuccess:(e,t)=>{a(s=>{let a=s.catalogModifications||[],r=new Set(a.map(e=>`${e.id}-${e.type}`)),n=a.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?{...t,addonName:s.addonName,type:s.type,hideable:s.hideable,searchable:s.searchable}:t});e.forEach(e=>{r.has(`${e.id}-${e.type}`)||n.push({id:e.id,name:e.name,type:e.type,enabled:!0,shuffle:!1,usePosterService:!!(t.rpdbApiKey||t.topPosterApiKey||t.aioratingsApiKey),hideable:e.hideable,searchable:e.searchable,addonName:e.addonName})});let l=new Set(e.map(e=>`${e.id}-${e.type}`)),i=new Set((s.mergedCatalogs||[]).map(e=>e.id)),o=n.filter(e=>e.id.startsWith("aiostreams.merged.")&&i.has(e.id)||l.has(`${e.id}-${e.type}`));return{...s,catalogModifications:o}})},onError:e=>{console.error("Error fetching catalogs:",e),e instanceof en?x.oR.error(e.message):x.oR.error("Failed to fetch catalogs")}}),h=(0,n.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];m(s,{onSuccess:e?void 0:()=>x.oR.success("Catalogs fetched successfully")})},[m,s]);(0,n.useEffect)(()=>{m(s)},[]);let[g,f]=(0,n.useState)(""),[b,v]=(0,n.useState)("all"),[y,j]=(0,n.useState)("all"),[w,N]=(0,n.useState)("all"),[k,S]=(0,n.useState)(!1),[C,_]=(0,n.use
43State)("add"),[A,R]=(0,n.useState)(null),[T,I]=(0,n.useState)({}),[E,M]=(0,n.useState)(null),P=(0,n.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"!==b&&(s=s.filter(e=>(e.CATEGORY||"streams")===b)),"all"!==y&&(s=s.filter(e=>e.SUPPORTED_SERVICES&&e.SUPPORTED_SERVICES.includes(y))),"all"!==w&&(s=s.filter(e=>e.SUPPORTED_STREAM_TYPES&&e.SUPPORTED_STREAM_TYPES.includes(w))),g&&(s=s.filter(e=>e.NAME.toLowerCase().includes(g.toLowerCase())||e.DESCRIPTION.toLowerCase().includes(g.toLowerCase()))),s},[e,g,b,y,w]);function D(e){R(e),I({options:Object.fromEntries((e.OPTIONS||[]).map(e=>[e.id,e.forced??e.default??void 0]))}),_("add"),M(null),S(!0)}let $=Object.values(s5).map(e=>({label:e.name,value:e.id})),L={p2p:"P2P",http:"HTTP",usenet:"Usenet",debrid:"Debrid",live:"Live"},O=(am||[]).filter(e=>!["error","statistic","external","youtube","stremio-usenet","archive"].includes(e)).map(e=>({label:L[e],value:e})),U=P.filter(e=>"streams"===e.CATEGORY||!e.CATEGORY),F=P.filter(e=>"subtitles"===e.CATEGORY),z=P.filter(e=>"meta_catalogs"===e.CATEGORY),V=P.filter(e=>"misc"===e.CATEGORY),q="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,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)(nE,{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"===o,onClick:()=>d("installed"),iconType:J.Oz0},{name:"Marketplace",isCurrent:"marketplace"===o,onClick:()=>d("marketplace"),iconType:J.LG1}]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(uw,{})})]}),(0,r.jsxs)(tq.N,{mode:"wait",children:["installed"===o&&(0,r.jsx)(r6,{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,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{children:"Installed"}),i&&l("presets")&&(0,r.jsx)(uI,{section:"presets"})]}),(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:"Manage your installed addons and catalog settings."})]}),(0,r.jsx)(uT,{activeTab:c,onTabChange:e=>u(e),defaultMobileOpen:"addons",tabs:[{value:"addons",label:"Addons",icon:(0,r.jsx)(mn.Yoo,{className:"w-4 h-4"}),content:(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(mD,{onEdit:function(e,t){R(t),I({options:{...e.options}}),_("edit"),M(e.instanceId),S(!0)}}),s.presets.length>0&&"pro"===t&&(0,r.jsx)(mj,{})]})},{value:"catalogs",label:"Catalogs",icon:(0,r.jsx)(ml.S$x,{className:"w-4 h-4"}),content:(0,r.jsx)("div",{className:"space-y-6",children:0===s.presets.length?(0,r.jsx)(X,{className:"p-8 text-center",children:(0,r.jsx)("p",{className:"text-[--muted]",children:"Install some addons first to configure catalogs."})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mS,{loading:p,fetchCatalogsData:h}),(0,r.jsx)(mC,{})]})})}]})]})},"installed"),"marketplace"===o&&(0,r.jsx)(r6,{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,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Marketplace"}),(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:"Browse and install addons from the marketplace."})]}),(0,r.jsx)(nE,{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"===b,onClick:()=>v("all")},{name:"Streams",isCurrent:"streams"===b,onClick:()=>v("streams")},{name:"Subtitles",isCurrent:"subtitles"===b,onClick:()=>v("subtitles")},{name:"Metadata & Catalogs",isCurrent:"meta_catalogs"===b,onClick:()=>v("meta_catalogs")}
43,{name:"Miscellaneous",isCurrent:"misc"===b,onClick:()=>v("misc")}]}),(0,r.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-1 lg:flex-none",children:[(0,r.jsx)(r0,{value:y,onValueChange:j,options:[{label:"All Services",value:"all"},...$],fieldClass:"lg:w-[200px]"}),(0,r.jsx)(r0,{value:w,onValueChange:N,options:[{label:"All Types",value:"all"},...O],fieldClass:"lg:w-[200px]"})]}),(0,r.jsx)(G,{value:g,onChange:e=>f(e.target.value),placeholder:"Search addons...",className:"flex-1",leftIcon:(0,r.jsx)(mr.A,{className:"w-4 h-4"})})]}),0===P.length&&(0,r.jsx)(X,{className:"p-8 text-center",children:(0,r.jsx)("p",{className:"text-[--muted]",children:"No addons found matching your criteria."})}),!!(null==U?void 0:U.length)&&(0,r.jsxs)(X,{className:"p-4 space-y-6",children:[(0,r.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,r.jsx)(mi.j$e,{})," Streams"]}),(0,r.jsx)("div",{className:q,children:U.map(e=>(0,r.jsx)(md,{preset:e,onAdd:()=>D(e)},e.ID))})]}),!!(null==F?void 0:F.length)&&(0,r.jsxs)(X,{className:"p-4 space-y-6",children:[(0,r.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,r.jsx)(ml.zZ_,{})," Subtitles"]}),(0,r.jsx)("div",{className:q,children:F.map(e=>(0,r.jsx)(md,{preset:e,onAdd:()=>D(e)},e.ID))})]}),!!(null==z?void 0:z.length)&&(0,r.jsxs)(X,{className:"p-4 space-y-6",children:[(0,r.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,r.jsx)(ml.S$x,{})," Metadata & Catalogs"]}),(0,r.jsx)("div",{className:q,children:z.map(e=>(0,r.jsx)(md,{preset:e,onAdd:()=>D(e)},e.ID))})]}),!!(null==V?void 0:V.length)&&(0,r.jsxs)(X,{className:"p-4 space-y-6",children:[(0,r.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,r.jsx)(J.xPd,{})," Miscellaneous"]}),(0,r.jsx)("div",{className:q,children:V.map(e=>(0,r.jsx)(md,{preset:e,onAdd:()=>D(e)},e.ID))})]})]})},"marketplace")]}),(0,r.jsx)(mc,{open:k,onOpenChange:S,mode:C,presetMetadata:A,initialValues:T,onSubmit:function(e){if("add"===C&&A){let t={type:A.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=mU(t);if(s.presets.some(e=>mU(e)===r)){x.oR.error("You already have an addon with the same options added."),S(!1);return}a(e=>({...e,presets:[...e.presets,t]})),x.oR.info("Addon installed successfully!"),S(!1)}else"edit"===C&&E&&(a(t=>({...t,presets:t.presets.map(t=>t.instanceId===E?{...t,options:e.options}:t)})),x.oR.info("Addon updated successfully!"),S(!1))}})]})}function mU(e){return JSON.stringify({type:e.type,enabled:e.enabled,options:e.options})}function mF(e){return e.split(".").map(e=>Number(e)||0)}function mz(e){let[t=1,s=0,a=0]=mF(e);return`${t}.${s}.${a+1}`}let mV={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 mq(e,t){if(!t)return e;let s=e.metadata.version,a=s&&function(e,t){let s=mF(e),a=mF(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:mz(t.version);return{...e,metadata:{...e.metadata,version:a}}}async function mB(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=mq(t,r);return{item:r?await eK(e,r.id,{template:n}):await eB(e,n),updated:!!r}}function mK(e,t){return e.draft?"Update submitted for review":"pending"===e.status?"Submitted for review":t?"Update published":"Shared with the community"}function mH(){return new Promise((e,t)=>{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()))}
43catch(e){t(Error("That file is not valid JSON"))}},s.oncancel=()=>e(null),s.click()})}function mW(e){return!!e&&"object"==typeof e&&"object"==typeof e.metadata&&"object"==typeof e.config}let mG=["ip","uuid","accessKey","tmdbAccessToken","tmdbApiKey","tvdbApiKey","rpdbApiKey","topPosterApiKey","aioratingsApiKey","aioratingsProfileId","openposterdbApiKey","openposterdbUrl","openposterdbParameters"];function mY(e){var t;return(null==(t=e.tags)?void 0:t.length)?e.tags:e.category?[e.category.toLowerCase()]:[]}function mJ(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,mJ(r,l,s)]]:[[a,r]]}))}function mZ(e,t,s){let a=structuredClone(e);for(let e of mG)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:mJ(e.options,t(e.type),s)}:e)),a}var mQ=s(70811),mX=s(51915),m0=s(95107),m1=s(87209);function m2(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 m3=["debrid","p2p","usenet","anime","minimal","4k"];function m5(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.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:mJ((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 m4(e){let{open:t,onOpenChange:s,userData:a,filterCredentials:l}=e,{status:i}
43=tr(),[o,d]=(0,n.useState)(""),[c,u]=(0,n.useState)(""),[m,p]=(0,n.useState)(""),[h,g]=(0,n.useState)("");(0,n.useEffect)(()=>{t&&(d(""),u(""),p(""),g(""))},[t]);let f=(0,n.useMemo)(()=>m2(h),[h]);return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"Export as Template",description:"Configure your template metadata and settings",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(lN,{intent:"info",description:(0,r.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,r.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,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Want more control?"})," Edit the exported JSON manually to add advanced features like:"]}),(0,r.jsxs)("ul",{className:"list-disc list-inside ml-2 space-y-1",children:[(0,r.jsx)("li",{children:"Conditional inputs and fields based on user selections"}),(0,r.jsx)("li",{children:"Template placeholders for dynamic values"}),(0,r.jsx)("li",{children:"Service filtering and smart service selection"}),(0,r.jsx)("li",{children:"Custom validation and input grouping"})]}),(0,r.jsxs)("p",{children:["See the"," ",(0,r.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,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(G,{label:"Template Name",placeholder:"e.g. My AIOStreams setup",value:o,onValueChange:d,required:!0}),(0,r.jsx)(n7,{label:"Description",placeholder:"Describe what makes this template useful...",value:c,onValueChange:u,required:!0,rows:3}),(0,r.jsx)(G,{label:"Author",placeholder:"Your name or username",value:m,onValueChange:p,required:!0}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(G,{label:"Tags",placeholder:"Comma separated, up to 5",value:h,onValueChange:g,required:!0}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:m3.map(e=>(0,r.jsx)(w,{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,r.jsxs)("div",{className:"flex flex-wrap justify-end gap-2 pt-2 border-t border-gray-700",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:()=>{if(o.trim()?c.trim()?m.trim()?0!==f.length||(x.oR.error("Please add at least one tag"),!1):(x.oR.error("Please enter an author name"),!1):(x.oR.error("Please enter a description"),!1):(x.oR.error("Please enter a template name"),!1))try{let e=m5({userData:a,filterCredentials:l,presets:(null==i?void 0:i.settings.presets)??[],meta:{name:o,description:c,author:m,tags:f}}),t=JSON.stringify(e,null,2),r=new Blob([t],{type:"application/json"}),n=URL.createObjectURL(r),d=document.createElement("a");d.href=n,d.download=`${e.metadata.id}-template.json`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(n),x.oR.success("Template exported successfully"),s(!1)}catch(e){x.oR.error("Failed to export template")}},children:"Export Template"})]})]})})}let m6={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 m9(e,t){return(0,r.jsx)("span",{className:b("text-xs px-2 py-0.5 rounded border whitespace-nowrap",e),children:t})}function m8(e){let{open:t,onOpenChange:s,credentials:a,userData:l,filterCredentials:i,onChanged:d}=e,c=(0,o.jE)(),{status:u}=tr(),m=(0,ta.I)({...ts(a),enabled:t}),p=(0,n.useMemo)(()=>(m.data??[]).filter(e=>"template"===e.kind),[m.data]),h=()=>{c.invalidateQueries({queryKey:te}),c.invalidateQueries({queryKey:tt}),d()},g=(0,e2.n)({mutationFn:e=>eK(a,e.id,{template:m5({userData:l,filterCredentials:i,presets:(null==u?void 0:u.settings.presets)??[],meta:{name:e.name,description:e.description,author:e.author,tags:e.tags??[],version:mz(e.version)}})}),onSuccess:e=>{x.oR.success(e.draft?"Update submitted for review":"Update published"),h()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to update")}),f=(0,e2.n)({mutationFn:async e=>{let t=await mH();if(null===t)return null;if(!mW(t))throw Error("That file is not a template (needs metadata and config)");return eK(a,e.id,{template:mq(t,e)})},onSuccess:e=>{e&&(x.oR.success(mK(e,!0)),h())},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to update")}),b=(0,e2.n)({mutationFn:async()=>{let e=await mH();if(null===e)return null;if(!mW(e))throw Error("That file is not a template (needs metadata and config)");return mB(a,e,m.data)},onSuccess:e=>{e&&(x.oR.success(mK(e.item,e.updated)),h())},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to share")}),v=(0,e2.n)({mutationFn:e=>eH(a,e),onSuccess:()=>{x.oR.success("Update withdrawn"),h()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to withdraw")}),y=(0,e2.n)({mutationFn:e=>eW(a,e),onSuccess:()=>{x.oR.success("Removed from the community"),h()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to delete")}),j=(0,n.useRef)(()=>{}),N=tX({...mV,onConfirm:()=>j.current()}),k=e=>{j.current=e,N.open()};return(0,r.jsxs)(tJ,{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,r.jsx)(t0,{...N}),(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(mQ.A,{className:"w-4 h-4"}),disabled:b.isPending,onClick:()=>k(()=>b.mutate()),children:"Share a template JSON"})}),m.isPending?(0,r.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"Loading..."}):0===p.length?(0,r.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,r.jsx)("div",{className:"space-y-2 max-h-[60vh] overflow-y-auto pr-1",children:p.map(e=>(0,r.jsx)(m7,{item:e,onUpdate:()=>k(()=>g.mutate(e)),onUpdateFromFile:()=>k(()=>f.mutate(e)),onWithdraw:()=>v.mutate(e.id),onDelete:()=>y.mutate(e.id),busy:g.isPending||f.isPending||b.isPending||v.isPending||y.isPending},e.id))})]})}function m7(e){let{item:t,onUpdate:s,onUpdateFromFile:a,onWithdraw:n,onDelete:l,busy:i}=e,o=tX({title:"Remove shared template",description:`Remove "${t.name}" from the community? People who applied it keep their configuration.`,actionText:"Remove",actionIntent:"alert-subtle",onConfirm:l}),d=t.draftRejectionReason??t.rejectionReason;return(0,r.jsxs)("div",{className:"rounded-lg border border-gray-800 bg-gray-900/60 p-3 space-y-2",children:[(0,r.jsx)(t0,{...o}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"font-medium text-sm",children:t.name}),m9("bg-gray-800 text-gray-400 border-gray-700",`v${t.version}`),m9(m6[t.status],t.status),t.draft&&m9(m6.pending,`v${t.draft.version} pending review`),t.likes>0&&m9("bg-pink-500/10 text-pink-300 border-pink-500/30",`${t.likes} likes`)]}),d&&(0,r.jsxs)("p",{className:"text-xs text-red-200",children:[t.draftRejectionReason?"Update rejected: ":"Rejected: ",d]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(mX.A,{className:"w-3.5 h-3.5"}),disabled:i,onClick:s,children:"Update with current config"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(mQ.A,{className:"w-3.5 h-3.5"}),disabled:i,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,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[t.draft&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,r.jsx)(m0.A,{className:"h-3.5 w-3.5"}),disabled:i,onClick:n}),children:"Withdraw pending update"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"alert-subtle",icon:(0,r.jsx)(m1.A,{className:"h-3.5 w-3.5"}),disabled:i,onClick:o.open}),children:"Remove from community"})]})]})]})}var pe=s(46358);let pt=["string","password","custom-nntp-servers"],ps=nj.Ik({metadata:nj.Ik({id:nj.Yj().min(1).max(100).optional().transform(e=>e??crypto.randomUUID()),name:nj.Yj().min(1).max(100),description:nj.Yj().min(1).max(1e3),author:nj.Yj().min(1).max(20),source:nj.k5(["builtin","custom","external","community"]).optional().default("builtin"),version:nj.Np("semver",/^[0-9]+\.[0-9]+\.[0-9]+$/).optional().default("1.0.0"),category:nj.Yj().min(1).max(20),tags:nj.YO(nj.Yj().min(1).max(20)).max(5).optional(),services:nj.YO(nj.k5(sQ)).optional(),serviceRequired:nj.zM().optional(),setToSaveInstallMenu:nj.zM().optional().default(!0),sourceUrl:nj.OZ().optional(),inputs:nj.YO(nj.bz()).optional(),changelog:nj.YO(nj.Ik({date:nj.Yj(),version:nj.Yj(),content:nj.Yj()})).optional(),changelogUrl:nj.OZ().optional()}),config:nj.bz()}),pa={welcome:"Get started",browse:"Choose a setup",selectService:"Services",templateInputs:"Options",inputs:"Credentials",review:"Review"},pr=new Map,pn=()=>{try{let e=localStorage.getItem("aiostreams-custom-templates");if(e)return nj.YO(ps).parse(JSON.parse(e)).map(e=>({...e,metadata:{...e.metadata,source:"external"}}))}catch(e){console.error("Error loading templates from localStorage:",e)}return[]},pl=e=>{try{localStorage.setItem("aiostreams-custom-templates",JSON.stringify(e))}catch(e){console.error("Error saving templates to localStorage:",e),x.oR.error("Failed to save templates to local storage")}},pi=(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},po=Symbol("aiostreams.remove");function pd(e,t){let s=t.split("."),a=e;for(let e of s){if(null==a)return;a=a[e]}return a}function pc(e,t,s){let a=e.trim(),r=a.split(/ or (?=!?(?:inputs|services)\b)/);if(r.length>1)return r.some(e=>pc(e.trim(),t,s));let n=a.split(/ xor (?=!?(?:inputs|services)\b)/);if(n.length>1)return n.filter(e=>pc(e.trim(),t,s)).length%2==1;let l=a.split(/ and (?=!?(?:inputs|services)\b)/);if(l.length>1)return l.every(e=>pc(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=pd(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=pd(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),p=o.slice(u+1),h=!1;if("inputs"===m){let e=pd(t,p);h=null!=e&&""!==e&&!1!==e&&!(Array.isArray(e)&&0===e.length)}else"services"===m&&(h=s.includes(p));return i?!h:h}function pu(e){return Array.isArray(e)?e:null!==e&&"object"==typeof e&&Array.isArray(e.__value)?e.__value:[]}let pm=new Set(["string","password","number","boolean","select","select-with-custom","multi-select","url","alert","socials","oauth","subsection","custom-nntp-servers","nab-endpoint"]),pp=new Set(["website","github","discord","ko-fi","patreon","buymeacoffee","github-sponsors","donate"]),ph=new Set(["alert","info","success","warning","info-basic","success-basic","warning-basic","alert-basic"]),px=new Set(["alert","socials","subsection","custom-nntp-servers","nab-endpoint"]);function pg(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=ps.safeParse(e);if(!m.success)return u.push((console.log(JSON.stringify(s=m.error,null,2)),pe.S1(s))),{isValid:!1,warnings:c,errors:u};let p=pu(e.config.presets);if(p.length>0&&t){let s=[];p.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)||{});pu(e.config.services).forEach(e=>{s.includes(e.id)||c.push(`Service "${e.id}" not available on this instance`)});let u=[...pu(e.config.excludedRegexPatterns),...pu(e.config.includedRegexPatterns),...pu(e.config.requiredRegexPatterns),...pu(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 h=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(".")),h.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(".")),h.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(".")),h.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||!pm.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(pp.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&&!ph.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||px.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||px.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 pf(e){let[t,s]=(0,n.useState)([]),[a,r]=(0,n.useState)({}),[l,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)({}),{userData:c}=aY(),u=(0,n.useMemo)(()=>{let e=null==c?void 0:c.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>=pi(e.metadata.version,a.version)||a.ignored||a.dismissedVersion&&pi(a.dismissedVersion,e.metadata.version)>=0)continue;let r=(e.metadata.changelog??[]).filter(e=>pi(e.version,a.version)>0);s.push({template:e,appliedVersion:a.version,newChangelog:r})}return s},[t,null==c?void 0:c.appliedTemplates]),m=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=pr.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],pr.set(u.metadata.sourceUrl,e)}let p=e.find(e=>{var t;return((null==(t=e.metadata)?void 0:t.id)||e.id)===u.metadata.id});if(!p){console.warn(`Template "${u.metadata.name}" not found at source URL`),t.push(u);continue}let h={metadata:{...p.metadata,id:u.metadata.id,source:"external",sourceUrl:u.metadata.sourceUrl,setToSaveInstallMenu:(null==(a=p.metadata)?void 0:a.setToSaveInstallMenu)??!0,version:(null==(r=p.metadata)?void 0:r.version)||"1.0.0",name:(null==(n=p.metadata)?void 0:n.name)||u.metadata.name,description:(null==(l=p.metadata)?void 0:l.description)||u.metadata.description,author:(null==(i=p.metadata)?void 0:i.author)||u.metadata.author,category:(null==(o=p.metadata)?void 0:o.category)||u.metadata.category,services:null==(d=p.metadata)?void 0:d.services,serviceRequired:null==(c=p.metadata)?void 0:c.serviceRequired},config:p.config||p},x=h.metadata.version||"1.0.0",g=u.metadata.version||"1.0.0";pi(x,g)>0?(s.push({old:u,new:h}),t.push(h),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(", ");x.oR.success(`Updated ${s.length} template${1!==s.length?"s":""}: ${e}`)}return t},p=async()=>{i(!0);let t=[];try{var a;let n=pr.get("api_templates");n?t=n:(t=await e$(),pr.set("api_templates",t));let l=pn(),i=await m(l);JSON.stringify(i)!==JSON.stringify(l)&&(pl(i),l=i),l=l.filter(e=>{let s=t.find(t=>t.metadata.id===e.metadata.id);return!s||1===pi(e.metadata.version,s.metadata.version)});let o=[];if((null==e||null==(a=e.settings.community)?void 0:a.templates)!=="off")try{let e=await ez("template");r(Object.fromEntries(e.map(e=>[e.id,e]))),o=e.map(e=>e.payload)}catch(e){console.warn("Failed to load community templates:",e)}let c=[...l,...t,...o].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]=pg(s,e)}),d(t)}}catch(e){console.error("Error fetching templates:",e),x.oR.error("Failed to load templates")}finally{i(!1)}};return{templates:t,setTemplates:s,loadingTemplates:l,templateValidations:o,setTemplateValidations:d,loadTemplates:p,appliedTemplateUpdates:u,communityItems:a,setCommunityItems:r}}let pb=e=>{if("string"!=typeof e)return{isPlaceholder:!1,required:!1};for(let{pattern:t,required:s}of[{pattern:/<required_template_placeholder>/gi,required:!0},{pattern:/<optional_template_placeholder>/gi,required:!1},{pattern:/<template_placeholder>/gi,required:!0}])if(t.test(e))return{isPlaceholder:!0,required:s};return{isPlaceholder:!1,required:!1}},pv=(e,t,s)=>{var a,r,n,l,i,o,d,c,u,m,p,h;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;if(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),(null==(r=e.config)?void 0:r.proxy)&&e.config.proxy.id){let t=s3[e.config.proxy.id];["url","publicUrl","credentials","publicIp"].forEach(a=>{var r,n;let l=pb(null==(r=e.config.proxy)?void 0:r[a]);if(l.isPlaceholder){let e={url:`${t.name} URL`,publicUrl:`${t.name} Public URL`,credentials:`${t.name} Credentials`,publicIp:`${t.name} Public IP`},r={url:`The URL of your ${t.name} instance`,publicUrl:`The public URL of your ${t.name} instance (if different from URL)`,credentials:t.credentialDescription,publicIp:`Public IP address of your ${t.name} instance`};x.push({key:`proxy_${a}`,path:`proxy.${a}`,label:e[a]||a,description:r[a],type:"credentials"===a?"password":"string",required:l.required,value:(null==s||null==(n=s.proxy)?void 0:n[a])||""})}})}let j={tmdbApiKey:!!(null==t||null==(i=t.settings)||null==(l=i.metadata)||null==(n=l.tmdb)?void 0:n.apiKey),tmdbAccessToken:!!(null==t||null==(c=t.settings)||null==(d=c.metadata)||null==(o=d.tmdb)?void 0:o.accessToken),tvdbApiKey:!!(null==t||null==(p=t.settings)||null==(m
43=p.metadata)||null==(u=m.tvdb)?void 0:u.apiKey)};return["tmdbApiKey","tmdbAccessToken","tvdbApiKey","rpdbApiKey","topPosterApiKey","aioratingsApiKey","aioratingsProfileId","openposterdbApiKey","openposterdbUrl","openposterdbParameters"].forEach(t=>{var a;let r=pb(null==(a=e.config)?void 0:a[t]);if(r.isPlaceholder){let e=null==s4?void 0:s4[t],a=!0===j[t],n=a?[null==e?void 0:e.description,"This instance provides a default. Leave blank to use it, or enter your own to override."].filter(Boolean).join(" "):null==e?void 0:e.description,l="aioratingsProfileId"===t||"openposterdbUrl"===t||"openposterdbParameters"===t?"string":"password";x.push({key:`toplevel_${t}`,path:t,label:(null==e?void 0:e.name)||t,description:n,type:l,required:r.required&&!a,value:(null==s?void 0:s[t])||""})}}),pu(null==(h=e.config)?void 0:h.presets).forEach((e,a)=>{var r,n,l;let i=null==t||null==(n=t.settings)||null==(r=n.presets)?void 0:r.find(t=>t.ID===e.type);i&&(null==(l=i.OPTIONS)||l.forEach(t=>{if("string"===t.type||"password"===t.type){var r,n,l,i,o,d,c,u;let m=null==(r=e.options)?void 0:r[t.id],p=pb(m);if(p.isPlaceholder||t.required&&!m)if("debridioApiKey"===t.id){let e=x.find(e=>"debridioApiKey"===e.key);e?Array.isArray(e.path)?e.path.push(`presets.${a}.options.${t.id}`):e.path=[e.path,`presets.${a}.options.${t.id}`]:x.push({key:"debridioApiKey",path:`presets.${a}.options.${t.id}`,label:"Debridio API Key",description:t.description,type:"password",required:!0,value:(null==s||null==(i=s.presets)||null==(l=i[a])||null==(n=l.options)?void 0:n[t.id])||""})}else x.push({key:`preset_${e.instanceId}_${t.id}`,path:`presets.${a}.options.${t.id}`,label:`${(null==(o=e.options)?void 0:o.name)||e.type} - ${t.name||t.id}`,description:t.description,type:"password"===t.type?"password":"string",required:p.required||t.required||!1,value:(null==s||null==(u=s.presets)||null==(c=u[a])||null==(d=c.options)?void 0:d[t.id])||""})}}))}),{template:e,services:f,skipServiceSelection:b,showServiceSelection:v,allowSkipService:y,inputs:x}},py=(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=>pt.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},pj=(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&&(x.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)))},pw=(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},pN=(e,t,s,a)=>t.reduce((t,r)=>{if("noob"===e&&(!0===r.advanced||!1===r.showInSimpleMode)||r.__if&&"string"==typeof r.__if&&!pc(r.__if,s,a))return t;let n={...r};return r.subOptions&&(n.subOptions=pN(e,r.subOptions,s,a)),t.push(n),t},[]),pk=(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]=pk(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 pS=s(24252);function pC(e){let{steps:t,current:s,title:a,description:n,children:l,footer:i}=e,o=t.indexOf(s),d=-1!==o&&t.length>1;return(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col md:flex-row md:gap-8 min-w-0",children:[d&&(0,r.jsx)(p_,{steps:t,index:o}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 min-h-0 flex flex-col",children:[(0,r.jsxs)("div",{className:"mb-4 shrink-0 pr-10 md:pr-8",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold text-white",children:a}),n&&(0,r.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:n})]}),(0,r.jsx)(tB.P.div,{initial:{opacity:0,y:6}
43,animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},className:"flex-1 min-h-0 flex flex-col gap-3",children:l},s),i&&(0,r.jsx)("div",{className:"shrink-0 flex items-center justify-between gap-3 pt-4 mt-4 border-t border-gray-700/60",children:i})]})]})}function p_(e){let{steps:t,index:s}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("nav",{className:"hidden md:flex w-44 shrink-0 flex-col","aria-label":"Setup progress",children:t.map((e,a)=>{let n=a<s,l=a===s;return(0,r.jsxs)("div",{className:"flex items-stretch gap-3",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)("span",{className:b("w-6 h-6 rounded-full border flex items-center justify-center text-[11px] leading-none font-semibold shrink-0 transition-colors",l&&"border-brand-500 bg-brand-500 text-white",n&&"border-brand-500/50 bg-brand-500/20 text-[--brand]",!l&&!n&&"border-gray-700 text-gray-500"),children:n?(0,r.jsx)(pS.A,{className:"w-3.5 h-3.5"}):a+1}),a<t.length-1&&(0,r.jsx)("span",{className:b("w-px flex-1 min-h-5 my-1",n?"bg-brand-500/60":"bg-gray-700/70")})]}),(0,r.jsx)("span",{className:b("text-sm pb-5 -mt-0.5 leading-6 transition-colors",l?"text-white font-medium":"text-gray-500"),children:pa[e]})]},e)})}),(0,r.jsxs)("div",{className:"md:hidden mb-4 pr-10",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-1.5",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-white",children:pa[t[s]]}),(0,r.jsxs)("span",{className:"text-xs text-gray-500",children:["Step ",s+1," of ",t.length]})]}),(0,r.jsx)("div",{className:"h-1 rounded-full bg-gray-700/70 overflow-hidden",children:(0,r.jsx)(tB.P.div,{className:"h-full bg-brand-500",initial:!1,animate:{width:`${(s+1)/t.length*100}%`},transition:{duration:.25,ease:"easeOut"}})})]})]})}function pA(e){let{onBack:t,backLabel:s="Back",onSkip:a,skipLabel:n="Skip",primary:l}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{children:t&&(0,r.jsx)(w,{intent:"gray-subtle",size:"sm",onClick:t,children:s})}),(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[a&&(0,r.jsx)("button",{type:"button",onClick:a,className:"text-sm text-gray-500 hover:text-gray-300 transition-colors",children:n}),l]})]})}var pR=s(10044),pT=s(33999),pI=s(68786);function pE(e){let{icon:t,title:s,description:a,meta:n,recommended:l,onClick:i}=e;return(0,r.jsxs)("button",{type:"button",onClick:i,className:b("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",l?"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,r.jsx)("span",{className:b("shrink-0 w-10 h-10 rounded-lg flex items-center justify-center transition-colors",l?"bg-brand-500/20 text-[--brand]":"bg-gray-700/50 text-gray-400 group-hover:text-gray-300"),children:t}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"font-semibold text-white",children:s}),l&&(0,r.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,r.jsx)("span",{className:"block text-sm text-[--muted] mt-1",children:a}),n&&(0,r.jsx)("span",{className:"block text-xs text-gray-500 mt-1.5",children:n})]})]})}function pM(e){let{onUseTemplate:t,onStartFresh:s,onSignIn:a,recommendedTemplateName:n,templateCount:l,hasExistingConfig:i}=e;return(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)(pE,{recommended:!0,icon:(0,r.jsx)(pR.A,{className:"w-5 h-5"}),title:"Use a ready-made setup",description:i?"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:n?`Starting with ${n} \xb7 ${l} available`:l>0?`${l} available`:void 0,onClick:t}),(0,r.jsx)(pE,{icon:(0,r.jsx)(pT.A,{className:"w-5 h-5"}),title:i?"Keep configuring":"Set it up myself",description:i?"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,r.jsx)(pE,{icon:(0,r.jsx)(pI.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 pP=s(77809),pD=s(24558),p$=s(30713),pL=s(1497),pO=s(46408),pU=s(36995),pF=s(57556),pz=s(85421);function pV(e){return!!e&&"object"==typeof e&&"string"==typeof e.type&&("options"in e||"instanceId"in e)}function pq(e){var t;let s=null==(t=e.options)?void 0:t.name;return"string"!=typeof s||s.includes("{{")?e.type:s}function pB(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)pV(r)?s.add(pq(r)):e(r,s,a+1);return}if(pV(t))return void s.add(pq(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=s5[e])?void 0:t.name)||e}),servicesChosenDuringSetup:void 0===r,skipsServiceSelection:Array.isArray(r)&&0===r.length,addonsVary:!!s&&!Array.isArray(s)}}function pK(e){let{open:t,template:s,data:a,onProceed:n,proceedLabel:l,onClose:i}=e;return a&&s?(0,r.jsx)(tJ,{open:t,onOpenChange:e=>{e||i()},title:a.errors.length>0?`Template Errors - ${s.metadata.name}`:`Template Warnings - ${s.metadata.name}`,contentClass:"max-w-2xl",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-4 overflow-y-auto max-h-[60vh] pr-1",children:[a.errors.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,r.jsx)(pP.A,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),(0,r.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,r.jsx)("ul",{className:"space-y-1.5",children:a.errors.map((e,t)=>(0,r.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,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,r.jsx)(pP.A,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),(0,r.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,r.jsx)("ul",{className:"space-y-1.5",children:a.warnings.map((e,t)=>(0,r.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,r.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-gray-700",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:i,children:a.errors.length>0?"Close":"Cancel"}),0===a.errors.length&&null!==n&&(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:()=>{i(),n()},children:l})]})]})}):null}function pH(e){let{className:t,children:s,glowSize:a="500px",glowOpacity:l=.07,transitionDuration:i="0.5s"}=e,o=(0,n.useRef)(null),d=(0,n.useRef)(null),c=(0,n.useRef)(null);return(0,r.jsxs)("div",{ref:o,onMouseMove:e=>{if(!o.current)return;let t=o.current.getBoundingClientRect(),s=e.clientX-t.left,r=e.clientY-t.top;d.current&&(d.current.style.background=`radial-gradient(${a} circle at ${s}px ${r}px, rgba(139, 92, 246, ${l}), transparent 65%)`),c.current&&(c.current.style.background=`radial-gradient(70% 100% at ${s}px 0px, rgba(139, 92, 246, ${Math.min(1,7*l)}), transparent)`)},onMouseEnter:()=>{d.current&&(d.current.style.opacity="1"),c.current&&(c.current.style.opacity="1")},onMouseLeave:()=>{d.current&&(d.current.style.opacity="0"),c.current&&(c.current.style.opacity="0")},className:b("relative overflow-hidden rounded-xl border border-gray-700/50 bg-gray-800/40",t),children:[(0,r.jsx)("div",{ref:d,className:"pointer-events-none absolute inset-0 rounded-xl",style:{opacity:0,transition:`opacity ${i} ease`}}),(0,r.jsx)("div",{ref:c,className:"pointer-events-none absolute top-0 inset-x-0 h-px rounded-t-xl",style:{opacity:0,transition:`opacity ${i} ease`}}),s]})}var pW=s(50496);let pG={root:(0,h.F)(["UI-Skeleton__root","animate-pulse rounded-[--radius-md] bg-[--subtle] w-full h-12"])},pY=n.forwardRef((e,t)=>
43{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(pG.root(),s),...a})});pY.displayName="Skeleton";let pJ=new Map;async function pZ(e){let t=pJ.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 pJ.set(e,a),a}function pQ(e){let{entry:t}=e;return(0,r.jsxs)("div",{className:"space-y-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsxs)("span",{className:"text-sm font-bold text-[--brand]",children:["v",t.version]}),(0,r.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,r.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,r.jsx)(pW.oz,{children:t.content})})]})}function pX(){return(0,r.jsxs)("div",{className:"space-y-3 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(pY,{className:"h-4 w-16"}),(0,r.jsx)(pY,{className:"h-4 w-24 rounded-full"})]}),(0,r.jsx)(pY,{className:"h-3 w-full"}),(0,r.jsx)(pY,{className:"h-3 w-5/6"}),(0,r.jsx)(pY,{className:"h-3 w-4/6"})]})}function p0(e){let{entries:t}=e;return(0,r.jsx)("div",{className:"divide-y divide-gray-700/50",children:t.map(e=>(0,r.jsx)("div",{className:"py-4 first:pt-1 last:pb-1",children:(0,r.jsx)(pQ,{entry:e})},e.version))})}function p1(e){let{open:t,onOpenChange:s,templateName:a,changelog:l=[],changelogUrl:i}
43=e,[o,d]=(0,n.useState)(null),[c,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(null);(0,n.useEffect)(()=>{t&&i&&null===o&&(u(!0),p(null),pZ(i).then(d).catch(e=>{console.error("Failed to load changelog:",e),p("Failed to load changelog. Please try again later."),d([])}).finally(()=>u(!1)))},[t,i]);let h=i?o??[]:l;return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:`Changelog — ${a}`,contentClass:"max-w-2xl",children:c?(0,r.jsx)(pX,{}):m?(0,r.jsx)("p",{className:"text-sm text-red-300 italic py-2",children:m}):0===h.length?(0,r.jsx)("p",{className:"text-sm text-gray-500 italic py-2",children:"No changelog available."}):(0,r.jsx)("div",{className:"max-h-[60vh] overflow-y-auto pr-4 -mr-2",children:(0,r.jsx)(p0,{entries:h})})})}function p2(e){let{update:t}=e,[s,a]=(0,n.useState)(null),[l,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(null),c=t.template.metadata.changelogUrl;return((0,n.useEffect)(()=>{c&&(i(!0),pZ(c).then(e=>{a(e.filter(e=>pi(e.version,t.appliedVersion)>0))}).catch(e=>{console.error("Failed to load template changelog:",e),d("Failed to load changelog."),a([])}).finally(()=>i(!1)))},[c,t.appliedVersion]),l)?(0,r.jsx)(pX,{}):o?(0,r.jsx)("p",{className:"text-xs text-red-300 italic",children:o}):s&&0!==s.length?(0,r.jsx)("div",{className:"divide-y divide-gray-700/50",children:s.map(e=>(0,r.jsx)("div",{className:"py-3 first:pt-1 last:pb-1",children:(0,r.jsx)(pQ,{entry:e})},e.version))}):(0,r.jsx)("p",{className:"text-xs text-gray-500 italic",children:"No changelog provided for this update."})}function p3(e){let{template:t,community:s}=e,a=t.metadata.source,n="builtin"===a?"Built-in":"custom"===a?"From this instance":"external"===a?"Imported":(null==s?void 0:s.federated)?`From ${s.origin}`:"Community";return(0,r.jsx)("span",{className:b("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:n})}function p5(e){let{template:t,validation:s,onOpenDetail:a,community:n,onLike:l,likeDisabledReason:i}=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:p,addonsVary:h}=pB(t);return(0,r.jsxs)(pH,{glowSize:"350px",glowOpacity:.08,transitionDuration:"0.3s",className:b("flex flex-col bg-gray-900/60 border-gray-800 rounded-lg p-4","hover:border-gray-600 transition-colors duration-200"),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>a(t),className:"flex-1 flex flex-col text-left focus-visible:outline-none",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2 mb-1.5",children:[(0,r.jsx)("h3",{className:"flex-1 min-w-0 text-base font-semibold text-white truncate",children:t.metadata.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(d||o)&&(0,r.jsx)(pP.A,{className:b("w-3.5 h-3.5",d?"text-red-300":"text-yellow-400")}),(0,r.jsx)(p3,{template:t,community:n})]})]}),(0,r.jsx)("div",{className:"text-sm text-gray-400 line-clamp-3 mb-3",children:(0,r.jsx)(l_,{children:t.metadata.description})}),(0,r.jsxs)("div",{className:"mt-auto flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500",children:[(0,r.jsxs)("span",{className:"truncate max-w-[10rem]",children:["by ",t.metadata.author]}),c.length>0&&(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)(pD.A,{className:"w-3.5 h-3.5"}),h?"up to ":"",c.length," addon",1===c.length?"":"s"]}),u.length>0?(0,r.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)(p$.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsxs)("span",{className:"truncate",children:["Needs ",u.slice(0,2).join(", "),u.length>2?` +${u.length-2}`:""]})]}):m?(0,r.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)(p$.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:"You pick the services"})]}):p?(0,r.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)(pL.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:"No service to pick"})]}):null]})]}),n&&(0,r.jsx)("div",{className:"mt-3 pt-2.5 border-t border-gray-800/80 flex",children:(0,r.jsx)(tO,{trigger:(0,r.jsx)("span",{children:(0,r.jsxs)("button",{type:"button",disabled:!l||n.federated,onClick:e=>{e.stopPropagation(),null==l||l(n.id)},className:b("flex items-center gap-1 rounded-md border px-2 py-1 text-xs transition-colors",!l||n.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,r.jsx)(pO.A,{className:"w-3.5 h-3.5"}),n.likes]})}
43),children:n.federated?"Likes only work for templates published on this instance":i??"Like this template"})})]})}function p4(e){var t;let{template:s,validation:a,isLoading:l,onLoadTemplate:i,onDeleteRequest:o,onShare:d,shareDisabledReason:c,community:u,onClose:m}=e,[p,h]=(0,n.useState)(!1),[x,g]=(0,n.useState)(!1),{addons:f,services:v,servicesChosenDuringSetup:y,skipsServiceSelection:j,addonsVary:N}=pB(s),k=((null==(t=s.metadata.changelog)?void 0:t.length)??0)>0||!!s.metadata.changelogUrl,S=((null==a?void 0:a.warnings.length)??0)>0,C=((null==a?void 0:a.errors.length)??0)>0;return(0,r.jsxs)("div",{className:"flex flex-col gap-5 h-full min-h-0",children:[(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1 flex flex-col gap-5",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(p3,{template:s,community:u}),(0,r.jsxs)("span",{className:"text-xs text-gray-500",children:["v",s.metadata.version||"1.0.0"," \xb7 by"," ",s.metadata.author]})]}),(C||S)&&(0,r.jsxs)("button",{type:"button",onClick:()=>h(!0),className:b("flex items-center gap-2 text-left text-xs rounded-lg border px-3 py-2 transition-colors",C?"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,r.jsx)(pP.A,{className:"w-4 h-4 shrink-0"}),C?`${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`]}),(v.length>0||f.length>0||y||j)&&(0,r.jsxs)("div",{className:"rounded-lg border border-gray-700/70 bg-gray-800/40 p-4 space-y-3",children:[(0,r.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500",children:"What this sets up"}),v.length>0?(0,r.jsxs)("div",{className:"flex items-start gap-2.5 text-sm",children:[(0,r.jsx)(p$.A,{className:"w-4 h-4 text-gray-500 mt-0.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("div",{className:"text-gray-300",children:!0===s.metadata.serviceRequired?"You will need an account for":"Optionally works with"}),(0,r.jsx)("div",{className:"text-gray-400 mt-0.5",children:v.join(", ")})]})]}):y?(0,r.jsxs)("div",{className:"flex items-start gap-2.5 text-sm",children:[(0,r.jsx)(p$.A,{className:"w-4 h-4 text-gray-500 mt-0.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("div",{className:"text-gray-300",children:!0===s.metadata.serviceRequired?"Needs a debrid or usenet service":"Works with or without a service"}),(0,r.jsx)("div",{className:"text-gray-400 mt-0.5",children:"You choose which ones during setup."})]})]}):j?(0,r.jsxs)("div",{className:"flex items-start gap-2.5 text-sm",children:[(0,r.jsx)(pL.A,{className:"w-4 h-4 text-gray-500 mt-0.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("div",{className:"text-gray-300",children:"No service to pick"}),(0,r.jsx)("div",{className:"text-gray-400 mt-0.5",children:"This setup does not ask you to choose a service."})]})]}):null,f.length>0&&(0,r.jsxs)("div",{className:"flex items-start gap-2.5 text-sm",children:[(0,r.jsx)(pD.A,{className:"w-4 h-4 text-gray-500 mt-0.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"text-gray-300",children:[N?"Up to ":"",f.length," addon",1===f.length?"":"s",N&&(0,r.jsxs)("span",{className:"text-gray-500",children:[" ","— the exact set depends on your answers"]})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:f.map((e,t)=>(0,r.jsx)("span",{className:"text-xs bg-gray-700/50 text-gray-300 px-2 py-0.5 rounded",children:e},`${e}-${t}`))})]})]})]}),(0,r.jsx)(l_,{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,r.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:mY(s.metadata).map(e=>(0,r.jsx)("span",{className:"text-xs bg-gray-800/60 text-gray-400 px-2 py-1 rounded",children:e},e))})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-3 border-t border-gray-700/60",children:[k&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{icon:(0,r.jsx)(pU.A,{className:"w-4 h-4"}),intent:"gray-outline",onClick:()=>g(!0)}),children:"View changelog"}),"external"===s.metadata.source&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{icon:(0,r.jsx)(m1.A,{className:"w-4 h-4"}),intent:"alert-outline",onClick:()=>{m(),o(s)}}),children:"Delete this imported template"}),(d||c)&&(0,r.jsx)(tO,{trigger:(0,r.jsx)("span",{children:(0,r.jsx)(E,{icon:(0,r.jsx)(pF.A,{className:"w-4 h-4"}),intent:"gray-outline",disabled:!d,onClick:()=>null==d?void 0:d(s)})}),children:d?"Share this JSON with the community (updates your existing submission of the same name)":c})]}),(0,r.jsx)(w,{intent:"primary",leftIcon:(0,r.jsx)(pS.A,{className:"w-4 h-4"}),onClick:()=>i(s),loading:l,className:"flex-1",children:"Use this setup"})]}),p&&a&&(0,r.jsx)(pK,{open:p,template:s,data:a,onProceed:null,proceedLabel:"",onClose:()=>h(!1)}),(0,r.jsx)(p1,{open:x,onOpenChange:e=>!e&&g(!1),templateName:s.metadata.name,changelog:s.metadata.changelog,changelogUrl:s.metadata.changelogUrl})]})}let p6={all:"All",builtin:"Built-in",custom:"This instance",external:"Imported",community:"Community"},p9={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 p8(e){let{active:t,onClick:s,children:a,count:n}=e;return(0,r.jsxs)("button",{type:"button",onClick:s,className:b("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!==n&&(0,r.jsx)("span",{className:"ml-1.5 text-[10px] leading-none text-gray-500",children:n})]})}function p7(e){let{searchQuery:t,onSearchChange:s,selectedCategory:a,onCategoryChange:l,selectedSource:i,onSourceChange:o,categories:d,sources:c,filteredTemplates:u,allTemplates:m,loadingTemplates:p,templateValidations:h,isLoading:x,onLoadTemplate:g,onImportOpen:f,onDeleteRequest:b,totalTemplateCount:v,initialExpandedTemplate:y,onInitialExpandedConsumed:j,communityItems:w,onLike:N,likeDisabledReason:k,onMineOpen:S,onShare:C,shareDisabledReason:_}
43=e,[A,R]=(0,n.useState)(null),T=dO("(min-width: 640px)");(0,n.useEffect)(()=>{y&&(R(y),null==j||j())},[null==y?void 0:y.metadata.id]);let I=(0,n.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=c.filter(e=>"all"===e||(I[e]??0)>0);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-2.5 min-w-0",children:[(0,r.jsx)(G,{placeholder:"Search setups...",value:t,onValueChange:s,leftIcon:(0,r.jsx)(mr.A,{className:"w-4 h-4"})}),(0,r.jsx)("div",{className:"flex gap-1.5 overflow-x-auto min-w-0 pb-1",children:M.map(e=>(0,r.jsx)(tO,{trigger:(0,r.jsx)(p8,{active:i===e,onClick:()=>o(e),count:I[e]??0,children:p6[e]??e}),children:p9[e]??e},e))}),d.length>1&&(0,r.jsx)("div",{className:"flex gap-1.5 overflow-x-auto min-w-0 pb-1",children:d.map(e=>(0,r.jsx)(p8,{active:a===e,onClick:()=>l(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,r.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:p?(0,r.jsx)("div",{className:"col-span-full text-center py-8 text-gray-400 text-sm",children:"Loading setups..."}):0===u.length?(0,r.jsx)("div",{className:"col-span-full text-center py-8 text-gray-400 text-sm",children:"No setups match your search."}):u.map(e=>(0,r.jsx)(p5,{template:e,validation:h[e.metadata.id],onOpenDetail:R,community:null==w?void 0:w[e.metadata.id],onLike:N,likeDisabledReason:k},e.metadata.id))}),(0,r.jsxs)("div",{className:"flex justify-between items-center gap-3 pt-3 border-t border-gray-700/60",children:[(0,r.jsx)("span",{className:"text-xs text-gray-500",children:u.length===v?`${v} setup${1===v?"":"s"}`:`${u.length} of ${v}`}),(0,r.jsxs)("div",{className:"flex gap-2",children:[S&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{intent:"gray-outline",size:"sm",icon:(0,r.jsx)(pz.A,{className:"w-4 h-4"}),onClick:S}),children:"My shared templates"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{intent:"gray-outline",size:"sm",icon:(0,r.jsx)(t2.bh6,{}),onClick:f}),children:"Import a template"})]})]}),(0,r.jsx)(tj,{open:null!==A,onOpenChange:e=>{e||R(null)},side:T?"right":"bottom",size:T?"lg":"full",title:(null==A?void 0:A.metadata.name)??"",contentClass:"flex flex-col",children:A&&(0,r.jsx)(p4,{template:A,validation:h[A.metadata.id],isLoading:x,onLoadTemplate:e=>{R(null),g(e)},onDeleteRequest:b,onShare:C,shareDisabledReason:_,community:null==w?void 0:w[A.metadata.id],onClose:()=>R(null)})})]})}function he(e){let{processedTemplate:t,selectedServices:s,onServicesChange:a,status:n,configuredServices:l}=e,i=t.services.filter(e=>{var t,s;return!!(null==n||null==(s=n.settings)||null==(t=s.services)?void 0:t[e])}),o=uL.map(e=>({...e,services:i.filter(t=>{var s;let a;return s=e.id,"both"==(a=u$(t)?"both":uD(t)?"usenet":"debrid")||a===s})})).filter(e=>e.services.length>0),d=o.length>1;return(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1 space-y-4",children:o.map(e=>(0,r.jsxs)("div",{className:"space-y-2",children:[d&&(0,r.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500",children:e.label}),e.services.map(e=>{let t=n.settings.services[e],i=s.includes(e),o=l.includes(e);return(0,r.jsxs)("button",{type:"button",role:"checkbox","aria-checked":i,onClick:()=>a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:b("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",i?"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,r.jsx)("span",{className:b("w-5 h-5 rounded border flex items-center justify-center shrink-0 transition-colors",i?"bg-brand-500 border-brand-500 text-white":"border-gray-600"),children:i&&(0,r.jsx)(pS.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)(uO,{serviceId:e,shortName:t.shortName,className:"w-8 h-8"}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"font-medium text-white text-sm",children:t.name}),o&&(0,r.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,r.jsx)(l_,{className:"block text-xs text-[--muted] mt-0.5 line-clamp-1",stopPropagation:!0,children:t.signUpText})]})]},e)})]},e.id))})}function ht(e){let{options:t,values:s,onValuesChange:a,trusted:l,selectedServices:i}=e,[o,d]=n.useState(!1),c=pN("noob",t,s,i),u=pN("pro",t,s,i),m=new Set(c.map(e=>e.id)),p=u.filter(e=>!m.has(e.id)),h=e=>(0,r.jsx)(uG,{option:e,value:s[e.id]??e.default,trusted:l,onChange:t=>a(s=>({...s,[e.id]:t}))},e.id),x=0===c.length&&p.length>0;return(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-2 space-y-3",children:0===u.length?(0,r.jsx)("p",{className:"text-sm text-[--muted] py-6 text-center",children:"This setup has no options to configure."}):(0,r.jsxs)(r.Fragment,{children:[c.map(h),p.length>0&&(0,r.jsxs)("div",{className:"pt-1",children:[!x&&(0,r.jsxs)("button",{type:"button",onClick:()=>d(e=>!e),className:"flex items-center gap-1.5 text-sm text-gray-400 hover:text-white transition-colors",children:[(0,r.jsx)(ui.A,{className:b("w-4 h-4 transition-transform",o&&"rotate-180")}
43),o?"Hide":"Show"," ",p.length," ","advanced option",1===p.length?"":"s"]}),(o||x)&&(0,r.jsx)("div",{className:"space-y-3 mt-3",children:p.map(h)})]})]})})}function hs(e){let{processedTemplate:t,inputValues:s,onInputValuesChange:a,status:l}=e,i=n.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)=>{let[s]=e,[a]=t;return null===s?1:null===a?-1:0})},[t.inputs]);return 0===t.inputs.length?(0,r.jsx)("p",{className:"text-sm text-[--muted] py-6 text-center",children:"Nothing to enter for this setup."}):(0,r.jsx)("form",{className:"flex-1 min-h-0 overflow-y-auto pr-2 space-y-5",children:i.map(e=>{var t,n;let[i,o]=e,d=i?null==l||null==(n=l.settings)||null==(t=n.services)?void 0:t[i]:void 0;return(0,r.jsxs)("div",{className:"space-y-3",children:[i&&d&&(0,r.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,r.jsx)(uO,{serviceId:i,shortName:d.shortName,className:"w-6 h-6 rounded mt-0.5"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("span",{className:"block text-sm font-medium text-white",children:d.name}),d.signUpText&&(0,r.jsx)(l_,{className:"block text-xs text-[--muted] mt-0.5 break-words",stopPropagation:!0,children:d.signUpText})]})]}),(0,r.jsx)("div",{className:i&&d?"space-y-3 pl-0 sm:pl-8":"space-y-3",children:o.map(e=>{var t;let n;return(0,r.jsx)(ha,{type:e.type,value:s[e.key]||"",onValueChange:t=>a(s=>({...s,[e.key]:t})),label:i&&d?-1===(n=(t=e.label).indexOf(" - "))?t:t.slice(n+3):e.label,description:e.description,required:e.required},e.key)})})]},i??"__template")})})}function ha(e){let{type:t,value:s,onValueChange:a,label:n,description:l,required:i,placeholder:o}=e;return(0,r.jsxs)("div",{children:["string"===t?(0,r.jsx)(G,{value:s,onValueChange:a,label:n,required:i,placeholder:o}):"password"===t?(0,r.jsx)(Z,{value:s,onValueChange:a,label:n,required:i,placeholder:o}):"custom-nntp-servers"===t?(0,r.jsx)(uX,{name:n,description:l,value:s||void 0,onChange:e=>a(e||"")}):null,l&&"custom-nntp-servers"!==t&&(0,r.jsx)(l_,{className:"text-xs text-[--muted] mt-1",children:l})]})}var hr=s(42690);function hn(e){let{icon:t,title:s,count:a,children:n}=e;return(0,r.jsxs)("div",{className:"rounded-lg border border-gray-700/70 bg-gray-800/40 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)("span",{className:"text-gray-500",children:t}),(0,r.jsx)("span",{className:"text-sm font-medium text-white",children:s}),(0,r.jsx)("span",{className:"text-xs text-gray-500",children:a})]}),n]})}function hl(e){let{processedTemplate:t,selectedServices:s,inputValues:a,status:l,currentUserData:i,previewUserData:o}=e,[d,c]=n.useState(!1),{metadata:u}=t.template,m=d?o():null,{addons:p}=pB(t.template),h=t.inputs.filter(e=>{var t;return null==(t=a[e.key])?void 0:t.trim()});return(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1 space-y-3",children:[(0,r.jsx)("div",{className:"rounded-lg border border-brand-500/50 bg-brand-500/[0.08] p-4",children:(0,r.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"font-semibold text-white",children:u.name}),(0,r.jsxs)("span",{className:"text-xs text-gray-400",children:["v",u.version||"1.0.0"," \xb7 by ",u.author]})]})}),p.length>0&&(0,r.jsx)(hn,{icon:(0,r.jsx)(pD.A,{className:"w-4 h-4"}),title:"Addons",count:p.length,children:(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:p.map((e,t)=>(0,r.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,r.jsx)(hn,{icon:(0,r.jsx)(p$.A,{className:"w-4 h-4"}),title:"Services",count:s.length,children:(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>{var t,s;let a=null==l||null==(s=l.settings)||null==(t=s.services)?void 0:t[e];return(0,r.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,r.jsx)(uO,{serviceId:e,shortName:(null==a?void 0:a.shortName)??e,className:"w-5 h-5 rounded"}),(null==a?void 0:a.name)??e]},e)})})}
43),t.inputs.length>0&&(0,r.jsx)(hn,{icon:(0,r.jsx)(pI.A,{className:"w-4 h-4"}),title:"Credentials",count:h.length,children:(0,r.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,r.jsxs)("div",{className:"flex items-center justify-between gap-3 text-xs",children:[(0,r.jsx)("span",{className:"text-gray-400 truncate",children:e.label}),(0,r.jsx)("span",{className:s?"text-gray-500 font-mono shrink-0":"text-gray-600 italic shrink-0",children:s?"••••••••":"not set"})]},e.key)})})}),(0,r.jsx)(lN,{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."}),i&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>c(!0),className:"flex items-center gap-1.5 text-sm text-gray-400 hover:text-white transition-colors",children:[(0,r.jsx)(hr.A,{className:"w-4 h-4"}),"See exactly what changes"]}),(0,r.jsx)(tJ,{open:d,onOpenChange:c,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,r.jsxs)("div",{className:"space-y-4",children:[m?(0,r.jsx)(uu,{oldConfig:i,newConfig:m}):(0,r.jsx)(lN,{intent:"alert",description:"Could not work out the changes for this setup."}),(0,r.jsx)("div",{className:"flex justify-end pt-2",children:(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>c(!1),children:"Close"})})]})})]})]})}function hi(e){let{showImportModal:t,onImportModalChange:s,importUrl:a,onImportUrlChange:n,isImporting:l,onImportFromUrl:i,onImportFromFile:o,showImportConfirmModal:d,onImportConfirmModalChange:c,pendingImportTemplates:u,selectedPendingTemplateIndex:m,onSelectedIndexChange:p,showDeepLinkWarning:h,onConfirmImport:x,onCancelImport:g,status:f}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"Import Template",description:"Import a template from a URL or local file",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(G,{placeholder:"Enter template URL...",value:a,onValueChange:n,className:"flex-1"}),(0,r.jsx)(w,{intent:"primary",onClick:i,loading:l,disabled:!a.trim(),children:"Go"})]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,r.jsx)("div",{className:"w-full border-t border-gray-700"})}),(0,r.jsx)("div",{className:"relative flex justify-center text-xs uppercase",children:(0,r.jsx)("span",{className:"bg-gray-900 px-2 text-gray-400",children:"or"})})]}),(0,r.jsx)(w,{intent:"primary",className:"w-full",leftIcon:(0,r.jsx)(t2.bh6,{className:"w-4 h-4"}),onClick:o,children:"Import from File"})]})}),(0,r.jsx)(tJ,{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,r.jsxs)("div",{className:"space-y-4",children:[h&&(0,r.jsx)(lN,{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,r.jsxs)("div",{className:"bg-gray-800/50 border border-gray-700 rounded-lg p-4 space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Name"}),(0,r.jsxs)("div",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[u[0].metadata.name,(0,r.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,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Description"}),(0,r.jsx)(l_,{className:"text-sm text-gray-300",children:u[0].metadata.description})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Author"}),(0,r.jsx)("div",{className:"text-sm text-gray-300",children:u[0].metadata.author})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Category"}),(0,r.jsx)("div",{className:"text-sm text-gray-300",children:u[0].metadata.category})]})]}),u[0].metadata.services&&u[0].metadata.services.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Services"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:u[0].metadata.services.map(e=>{var t;return(0,r.jsx)("span",{className:"text-xs bg-green-600/30 text-green-300 px-2 py-0.5 rounded",children:(null==(t=s5[e])?void 0:t.name)||e},e)})})]})]}):(0,r.jsxs)("div",{className:"bg-gray-800/50 border border-gray-700 rounded-lg p-4",children:[(0,r.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,r.jsx)("div",{className:"space-y-1 max-h-[300px] overflow-y-auto",children:u.map((e,t)=>(0,r.jsxs)("div",{onClick:()=>p(t===m?null:t),className:b("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,r.jsx)("div",{className:b("w-3 h-3 rounded-full border-2 flex-shrink-0 transition-colors",m===t?"bg-white border-white":"border-gray-500")}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white truncate",children:e.metadata.name}),(0,r.jsxs)("div",{className:"text-xs text-gray-400 truncate",children:[e.metadata.category," • v",e.metadata.version||"1.0.0"]})]})]},t))})]}),(0,r.jsx)(lN,{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,r.jsxs)("div",{className:"flex justify-between gap-2 pt-2 border-t border-gray-700",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:g,children:"Cancel"}),(0,r.jsx)("div",{className:"flex gap-2",children:1===u.length?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>x(!1),children:"OK"}),(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:()=>x(!0),children:"Use This Template Now"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>x(!1),children:"Import All"}),null!==m&&(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:()=>x(!0,m),children:"Use Selected"})]})})]})]})})]})}function ho(e){var t,s,a;let{open:l,onOpenChange:i,openImportModal:o=!1,deepLinkUrl:d,deepLinkTemplateId:c,initialExpandedTemplateId:u,startAtWelcome:m=!1,onStartFresh:p,onSignIn:h}=e,{setUserData:g,userData:f,uuid:b,password:v}=aY(),{status:y}=tr(),{setSelectedMenu:j}
43=a1(),[N,k]=(0,n.useState)(""),[S,C]=(0,n.useState)("all"),[_,A]=(0,n.useState)("all"),[R,T]=(0,n.useState)(!1),[I,E]=(0,n.useState)(null),M=n.useRef(null),P=n.useRef(!1),D=function(){let[e,t]=(0,n.useState)(!1),[s,a]=(0,n.useState)(null),[r,l]=(0,n.useState)(null),[i,o]=(0,n.useState)(null),[d,c]=(0,n.useState)("Proceed");return{show:e,template:s,data:r,onProceed:i,proceedLabel:d,open:e=>{let{template:s,data:r,onProceed:n,proceedLabel:i}=e;a(s),l(r),o(()=>n),c(i),t(!0)},close:()=>{t(!1),a(null),l(null),o(null),c("Proceed")},setOnProceed:o}}(),$=pf(y),L=function(e){let{status:t,userData:s,setUserData:a,validationModal:r,templateValidations:l,setSelectedMenu:i,onOpenChange:o,initialStep:d="browse"}=e,[c,u]=(0,n.useState)(d),[m,p]=(0,n.useState)(["browse","review"]),h=(0,n.useRef)(d);h.current=d;let[g,f]=(0,n.useState)(null),[b,v]=(0,n.useState)([]),[y,j]=(0,n.useState)({}),[w,N]=(0,n.useState)(null),[k,S]=(0,n.useState)([]),[C,_]=(0,n.useState)({}),[A,R]=(0,n.useState)([]),[T,I]=(0,n.useState)(!1),E=()=>{let e={step:c,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=py(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)},D=e=>p(t=>t.filter(t=>t!==e)),$=e=>{let{config:t,inputs:s,resolvedValues:a,selectedSvcs:r}=e,n=aV(JSON.parse(JSON.stringify(t)));if(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 pw(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:l,setToSaveInstallMenu:d,templateId:c,templateVersion:m,templateSourceUrl:p}=e;I(!0);try{let e=$({config:t,inputs:s,resolvedValues:r,selectedSvcs:n});a(t=>({...t,...e})),c&&m&&a(e=>({...e,appliedTemplates:[...(e.appliedTemplates??[]).filter(e=>e.id!==c),{id:c,version:m,...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});x.oR.success(`Template "${l}" loaded successfully`),g.length>0&&setTimeout(()=>{x.oR.info(`Note: ${g.join(", ")} require additional setup. Please configure them in the Addons section.`,{duration:8e3})},1e3),f(null),u(h.current),v([]),j({}),R([]),d&&i("save-install"),o(!1)}catch(e){console.error("Error loading template:",e),x.oR.error("Failed to load template")}finally{I(!1)}},O=e=>{pj(e.config,t);let a=pv(e,t,s);if(f(a),P(e,a),a.skipServiceSelection){if(1===a.services.length){let e=py(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({}),D("inputs"),u("review");return}j(a.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),u("inputs")}else if(a.showServiceSelection)v(M(a.services)),u("selectService");else{if(0===a.inputs.length){v([]),j({}),D("inputs"),u("review");return}j(a.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),u("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,pk(a,(e=>{try{let t=localStorage.getItem("aiostreams-template-inputs");if(t)return JSON.parse(t)[e]??{}}catch{}return{}})(e.metadata.id))),l=pv(e,t,s);if(P(e,l),l.showServiceSelection){f(l),N(e),S(a),_(n),v(M(l.services)),u("selectService");return}f(null),N(e),S(a),_(n),u("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:c,plannedSteps:m,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=l[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 x.oR.error("Please select at least one service");E();let e=[...py(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 u("templateInputs");if(j(e.reduce((e,t)=>
43({...e,[t.key]:t.value}),{})),0===e.length){D("inputs"),u("review");return}u("inputs")},handleServiceSelectionSkip:()=>{if(g){if(!g.allowSkipService)return void x.oR.error("Service selection cannot be skipped for this template");if(E(),v([]),null!==w)return void u("templateInputs");if(j(g.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),0===g.inputs.length){D("inputs"),u("review");return}u("inputs")}},handleTemplateInputsNext:()=>{if(!w)return;let e=pN("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 x.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)||pc(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.")?pd(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 pc(t.__if,s,a)?e(t.__value,s,a):po;if(!0===t.__remove)return po;let r={};for(let[n,l]of Object.entries(t)){let t=e(l,s,a);t!==po&&(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=pd(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=pd(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);pj(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=pv(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){D("inputs"),u("review");return}u("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?x.oR.error(`Please fill in all required fields: ${e.map(e=>e.label).join(", ")}`):(E(),u("review"))},previewUserData:()=>{if(!g)return null;try{return{...s,...$({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(),u(e)},resetTo:e=>{f(null),N(null),S([]),_({}),v([]),j({}),R([]),p(["browse","review"]),u(e)},pushHistory:E,handleBack:()=>{if(0===A.length)return;let e=A[A.length-1];R(A.slice(0,-1)),u(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([]),_({}),u(h.current),v([]),j({}),R([]),p(["browse","review"]),o(!1)}}}({status:y,userData:f,setUserData:g,validationModal:D,templateValidations:$.templateValidations,setSelectedMenu:j,onOpenChange:i,initialStep:m?"welcome":"browse"}),O=function(e){let{status:t,templates:s,setTemplates:a,setTemplateValidations:r,validationModal:l,handleLoadTemplate:i,executeLoadTemplate:o}=e,[d,c]=(0,n.useState)(!1),[u,m]=(0,n.useState)(""),[p,h]=(0,n.useState)(!1),[g,f]=(0,n.useState)(!1),[b,v]=(0,n.useState)([]),[y,j]=(0,n.useState)(null),[w,N]=(0,n.useState)(!1),[k,S]=(0,n.useState)(null),C=tX({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)),pl(pn().filter(t=>t.metadata.id!==e)),x.oR.success("Template deleted successfully"))}}),_=(e,a,n)=>{try{let N=Array.isArray(e)?e:[e],k=[],S=[];if(n){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}(n);S.push(...e)}for(let e of N){var i,o,d,u,p,h,g,b,y,j,w;if(!e.config)return void x.oR.error("Invalid template: missing config field");let n=(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===n);if(f&&("builtin"===f.metadata.source||"custom"===f.metadata.source)&&1!==pi(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:n,name:(null==(o=e.metadata)?void 0:o.name)||"Imported Template",description:(null==(d=e.metadata)?void 0:d.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==(h=e.metadata)?void 0:h.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=pg(v,t);if(e.errors.length>0){c(!1),m(""),l.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 x.oR.info("There were no templates to import as existing templates are newer or the same version.");
43if(S.length>0){c(!1),m(""),l.open({template:k[0],data:{isValid:!0,errors:[],warnings:S},proceedLabel:"Import Anyway",onProceed:()=>{v(k),f(!0)}});return}c(!1),m(""),v(k),f(!0)}catch(e){x.oR.error("Invalid template format: "+e.message)}},A=async()=>{if(!u.trim())return void x.oR.error("Please enter a URL");h(!0);try{let e=await fetch(u);if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=await e.text(),s=JSON.parse(t);_(s,u,t)}catch(e){x.oR.error("Failed to import template: "+e.message)}finally{h(!1)}};return{showImportModal:d,setShowImportModal:c,importUrl:u,setImportUrl:m,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){x.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=pn(),r=new Set(b.map(e=>e.metadata.id));pl([...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?x.oR.success(`Successfully imported ${b.length} template${1!==b.length?"s":""} (${n} overwritten)`):x.oR.success(`Successfully imported ${b.length} template${1!==b.length?"s":""}`),e&&(1===b.length||void 0!==t)?(f(!1),o(b[t??0])):f(!1),v([]),j(null),N(!1)},handleCancelImport:()=>{f(!1),v([]),j(null),N(!1)},confirmDeleteTemplate:C}}({status:y,templates:$.templates,setTemplates:$.setTemplates,setTemplateValidations:$.setTemplateValidations,validationModal:D,handleLoadTemplate:L.handleLoadTemplate,executeLoadTemplate:L.executeLoadTemplate});(0,n.useEffect)(()=>{l&&!P.current&&(L.resetTo(m?"welcome":"browse"),E(u??null)),P.current=l},[l,m]),(0,n.useEffect)(()=>{if(l)try{$.loadTemplates(),o&&O.setShowImportModal(!0)}catch(t){let e="Failed to load templates";t instanceof en?e+=`: ${t.message}`:console.error("Error loading templates:",t),x.oR.error(e)}},[l]),(0,n.useEffect)(()=>{l&&d&&M.current!==d&&(M.current=d,O.setShowDeepLinkWarning(!0),(async()=>{try{let e=await fetch(d);if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=await e.json();O.processImportedTemplate(t,d)}catch(e){x.oR.error("Failed to load template from link: "+e.message)}})())},[l,d]),(0,n.useEffect)(()=>{if(c&&O.pendingImportTemplates.length>0){let e=O.pendingImportTemplates.findIndex(e=>e.metadata.id===c);-1!==e&&O.setSelectedPendingTemplateIndex(e)}},[O.pendingImportTemplates,c]);let U=(0,n.useMemo)(()=>["all",...Array.from(new Set($.templates.flatMap(e=>mY(e.metadata))))],[$.templates]),F=["all","builtin","custom","external","community"],z=b?{uuid:b,password:v}:null,V=(null==y||null==(t=y.settings.community)?void 0:t.templates)!=="off",q=(0,ta.I)({...ts(z),enabled:l&&!!z&&V}),B=(0,e2.n)({mutationFn:e=>mB(z,e,q.data),onSuccess:e=>{let{item:t,updated:s}=e;x.oR.success(mK(t,s)),q.refetch(),$.loadTemplates()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to share")}),K=n.useRef(null),H=tX({...mV,onConfirm:()=>{K.current&&B.mutate(K.current)}}),W=(0,e2.n)({mutationFn:e=>eG(z,e),onSuccess:(e,t)=>{$.setCommunityItems(s=>s[t]?{...s,[t]:{...s[t],likes:e.likes}}:s)},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to like")}),G=(0,n.useMemo)(()=>{var e;let t=new Map;return((null==y||null==(e=y.settings)?void 0:e.featuredTemplateIds)??[]).forEach((e,s)=>t.set(e,s)),t},[null==y||null==(s=y.settings)?void 0:s.featuredTemplateIds]),Y=(0,n.useMemo)(()=>$.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||mY(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)),[$.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,n.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,n.useMemo)(()=>{var e;for(let t of(null==y||null==(e=y.settings)?void 0:e.featuredTemplateIds)??[]){let e=$.templates.find(e=>e.metadata.id===t);if(e)return e}return $.templates[0]},[null==y||null==(a=y.settings)?void 0:a.featuredTemplateIds,$.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,r.jsx)(pM,{recommendedTemplateName:null==Q?void 0:Q.metadata.name,templateCount:$.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==h||h()}}),footer:null};case"browse":return{title:"Choose a setup",description:"Open one to see what it installs and what you will need.",body:(0,r.jsx)(p7,{searchQuery:N,onSearchChange:k,selectedCategory:S,onCategoryChange:C,selectedSource:_,onSourceChange:A,categories:U,sources:F,filteredTemplates:Y,allTemplates:$.templates,loadingTemplates:$.loadingTemplates,templateValidations:$.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:$.templates.length,communityItems:$.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?$.templates.find(e=>e.metadata.id===I)??void 0:void 0,onInitialExpandedConsumed:()=>E(null)}),footer:ee?(0,r.jsx)(pA,{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,r.jsx)(he,{processedTemplate:e,selectedServices:L.selectedServices,onServicesChange:L.setSelectedServices,status:y,configuredServices:Z}),footer:(0,r.jsx)(pA,{onBack:ee?L.handleBack:void 0,onSkip:t?L.handleServiceSelectionSkip:void 0,skipLabel:"I don't use any of these",primary:(0,r.jsx)(w,{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,r.jsx)(ht,{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,r.jsx)(pA,{onBack:ee?L.handleBack:void 0,primary:(0,r.jsx)(w,{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,r.jsx)(hs,{processedTemplate:e,inputValues:L.inputValues,onInputValuesChange:L.setInputValues,status:y}),footer:(0,r.jsx)(pA,{onBack:ee?L.handleBack:void 0,primary:(0,r.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[(0,r.jsx)(w,{intent:"primary",onClick:L.handleCredentialsNext,disabled:t.length>0,children:"Continue"}),t.length>0&&(0,r.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,r.jsx)(hl,{processedTemplate:e,selectedServices:L.selectedServices,inputValues:L.inputValues,status:y,currentUserData:J?f:null,previewUserData:L.previewUserData}),footer:(0,r.jsx)(pA,{onBack:ee?L.handleBack:void 0,primary:(0,r.jsx)(w,{intent:"primary",onClick:L.confirmLoadTemplate,loading:L.isLoading,children:"Apply setup"})})}}default:return null}})();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tJ,{open:l&&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,r.jsx)(pC,{steps:"welcome"===X||"browse"===X?[]:L.plannedSteps,current:X,title:et.title,de
43scription:et.description,footer:et.footer,children:et.body})}),(0,r.jsx)(hi,{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:y}),(0,r.jsx)(pK,{open:D.show,template:D.template,data:D.data,onProceed:D.onProceed,proceedLabel:D.proceedLabel,onClose:D.close}),(0,r.jsx)(t0,{...O.confirmDeleteTemplate}),(0,r.jsx)(t0,{...H}),z&&(0,r.jsx)(m8,{open:R,onOpenChange:T,credentials:z,userData:f,filterCredentials:e=>mZ(e,e=>{var t;return null==y||null==(t=y.settings.presets.find(t=>t.ID===e))?void 0:t.OPTIONS}),onChanged:()=>void $.loadTemplates()})]})}let hd="https://docs.aiostreams.viren070.me",hc=`${hd}/changelog`;function hu(e){let[t,s]=e.replace(/^v/,"").split(".");return`${t}.${s}`}function hm(e,t){let s=hu(t);return e.find(e=>e.version&&hu(e.version)===s)}function hp(e){return e.url.startsWith("http")?e.url:`${hd}${e.url}`}async function hh(){let e=await fetch(`${hd}/api/changelog.json`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return Array.isArray(t)?t:[]}async function hx(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 hg="aiostreams-last-seen-version",hf=["aiostreams-first-time","aiostreams-mode","aiostreams-template-inputs","aiostreams-custom-templates"],hb=/stremio\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/.*\/configure/;function hv(e){try{localStorage.setItem(hg,e)}catch{}}var hy=s(13243),hj=s(60767),hw=s(24720);function hN(e){let{addonName:t,addonDescription:s,logo:a,version:n,channel:l,commit:i,onCustomize:o,onDonate:d,isSignedIn:c,onToggleSession:u}=e;return(0,r.jsxs)("div",{className:"flex items-start gap-4 sm:gap-5 w-full",children:[(0,r.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,r.jsxs)("div",{className:"min-w-0 flex-1 pt-0.5",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-end gap-x-3 gap-y-1 min-w-0",children:[(0,r.jsx)("h1",{className:"text-2xl sm:text-3xl font-bold tracking-tight text-gray-100 truncate min-w-0",children:t}),(0,r.jsxs)("span",{className:"text-lg sm:text-xl font-semibold text-gray-400 pb-0.5",children:[n,("nightly"===l||"dev"===l)&&i&&(0,r.jsxs)(r.Fragment,{children:[" ",(0,r.jsxs)("a",{href:`https://github.com/Viren070/AIOStreams/commit/${i}`,target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:["(",i,")"]})]})]}),(0,r.jsx)(E,{icon:(0,r.jsx)(hy.A,{className:"w-3.5 h-3.5"}),intent:"gray-subtle",onClick:o,className:"rounded-full shrink-0 self-center",size:"sm"})]}),(0,r.jsx)("p",{className:"text-sm sm:text-base text-[--muted] mt-1.5 max-w-3xl",children:s})]}),(0,r.jsxs)("div",{className:"hidden lg:flex items-center gap-2 shrink-0",children:[(0,r.jsx)(w,{intent:"gray-outline",size:"sm",rounded:!0,leftIcon:(0,r.jsx)(pO.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,r.jsx)(w,{intent:"gray-outline",size:"sm",rounded:!0,leftIcon:c?(0,r.jsx)(hj.A,{className:"w-4 h-4"}):(0,r.jsx)(hw.A,{className:"w-4 h-4"}),onClick:u,className:"shrink-0",children:c?"Sign Out":"Sign In"})]})]})}var hk=s(19688),hS=s(72898);function hC(e){let{isSignedIn:t,hasConfig:s,onStartSetup:a,onContinue:n,onBrowseSetups:l,onInstall:i,onSignIn:o}=e;return(0,r.jsxs)(pH,{className:"p-5 sm:p-6 flex flex-col gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-white",children:s?"Your configuration":"Get started"}),(0,r.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,r.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,r.jsx)("div",{className:"flex flex-col sm:flex-row gap-2",children:s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"primary",rounded:!0,leftIcon:(0,r.jsx)(hk.A,{className:"w-4 h-4"}),className:"w-full sm:flex-1 h-11",onClick:n,children:"Continue setup"}),(0,r.jsx)(w,{intent:"gray-outline",rounded:!0,leftIcon:(0,r.jsx)(hS.A,{className:"w-4 h-4"}),className:"w-full sm:flex-1 h-11",onClick:i,children:"Save & install"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"primary",rounded:!0,leftIcon:(0,r.jsx)(hk.A,{className:"w-4 h-4"}),className:"w-full sm:flex-1 h-11",onClick:a,children:"Start setup"}),(0,r.jsx)(w,{intent:"gray-outline",rounded:!0,leftIcon:(0,r.jsx)(pR.A,{className:"w-4 h-4"}),className:"w-full sm:flex-1 h-11",onClick:l,children:"Browse setups"})]})}),(s||!t)&&(0,r.jsxs)("div",{className:"space-y-1 text-xs text-gray-500",children:[s&&(0,r.jsxs)("p",{children:[(0,r.jsx)("button",{type:"button",onClick:l,className:"text-[--brand] hover:underline",children:"Browse ready-made setups"})," ","to apply a new one, or re-apply one you already use."]}),!t&&(0,r.jsxs)("p",{children:["Already have a configuration?"," ",(0,r.jsx)("button",{type:"button",onClick:o,className:"text-[--brand] hover:underline",children:"Sign in"})," ","to load it."]})]})]})}function h_(e){let{template:t,onOpen:s}=e,{addons:a,services:n,servicesChosenDuringSetup:l,skipsServiceSelection:i,addonsVary:o}=pB(t);return(0,r.jsx)(pH,{className:"bg-gray-900/60 border-gray-800 hover:border-gray-600 transition-colors duration-200 rounded-lg",children:(0,r.jsxs)("button",{type:"button",onClick:s,className:"text-left w-full h-full p-4 flex flex-col focus-visible:outline-none",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2 mb-1.5",children:[(0,r.jsx)("h4",{className:"flex-1 min-w-0 text-base font-semibold text-white truncate",children:t.metadata.name}),(0,r.jsx)(p3,{template:t})]}),(0,r.jsx)("div",{className:"text-sm text-gray-400 line-clamp-3 mb-3",children:(0,r.jsx)(l_,{children:t.metadata.description})}),(0,r.jsxs)("div",{className:"mt-auto flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500",children:[(0,r.jsxs)("span",{className:"truncate max-w-[10rem]",children:["by ",t.metadata.author]}),a.length>0&&(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)(pD.A,{className:"w-3.5 h-3.5"}),o?"up to ":"",a.length," addon",1===a.length?"":"s"]}),n.length>0?(0,r.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)(p$.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsxs)("span",{className:"truncate",children:["Needs ",n.slice(0,2).join(", "),n.length>
432?` +${n.length-2}`:""]})]}):l?(0,r.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)(p$.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:"You pick the services"})]}):i?(0,r.jsxs)("span",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)(pL.A,{className:"w-3.5 h-3.5 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:"No service to pick"})]}):null]})]})})}function hA(e){let{templates:t,totalCount:s,loading:a,onOpen:n,onBrowseAll:l}=e;return a?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsx)(pY,{className:"h-5 w-36"}),(0,r.jsx)(pY,{className:"h-4 w-24"})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[0,1].map(e=>(0,r.jsx)(pY,{className:"h-32 w-full rounded-lg"},e))})]}):0===t.length?null:(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsx)("h3",{className:"text-base font-semibold text-white",children:"Featured setups"}),(0,r.jsxs)("button",{type:"button",onClick:l,className:"text-sm text-[--brand] hover:underline transition-colors",children:["Browse all ",s," →"]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:t.map(e=>(0,r.jsx)(h_,{template:e,onOpen:()=>n(e)},e.metadata.id))})]})}var hR=s(55784),hT=s(65238);function hI(e){let{href:t,onClick:s,icon:a,label:n,hint:l,emphasis:i}=e,o=b("group flex items-center gap-3 rounded-lg px-3 py-2.5 transition-colors text-left w-full",i?"bg-red-500/[0.07] hover:bg-red-400/15":"hover:bg-gray-800/70"),d=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:b("shrink-0 transition-colors",i?"text-red-300":"text-gray-500 group-hover:text-gray-300"),children:a}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block text-sm font-medium text-gray-200",children:n}),(0,r.jsx)("span",{className:"block text-xs text-gray-500 truncate",children:l})]}),(0,r.jsx)(mu.X6T,{className:"w-3 h-3 text-gray-600 group-hover:text-gray-400 transition-colors shrink-0"})]});return t?(0,r.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:o,children:d}):(0,r.jsx)("button",{type:"button",onClick:s,className:o,children:d})}function hE(e){let{discordUrl:t,githubUrl:s,onDonate:a}=e;return(0,r.jsxs)(pH,{className:"p-5",children:[(0,r.jsx)("h3",{className:"text-base font-semibold text-white mb-3",children:"Help & resources"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1",children:[(0,r.jsx)(hI,{href:hd,icon:(0,r.jsx)(hR.A,{className:"w-4 h-4"}),label:"Documentation",hint:"Every option, explained"}),(0,r.jsx)(hI,{href:`${hd}/configuration/setup`,icon:(0,r.jsx)(hT.A,{className:"w-4 h-4"}),label:"Setup guide",hint:"Walkthrough for a first install"}),(0,r.jsx)(hI,{href:hc,icon:(0,r.jsx)(pU.A,{className:"w-4 h-4"}),label:"Changelog",hint:"What each release added"}),(0,r.jsx)(hI,{href:t,icon:(0,r.jsx)(P.fzZ,{className:"w-4 h-4"}),label:"Discord",hint:"Ask for help"}),(0,r.jsx)(hI,{href:s,icon:(0,r.jsx)(lj.BR8,{className:"w-4 h-4"}),label:"GitHub",hint:"Source and issues"}),(0,r.jsx)(hI,{onClick:a,icon:(0,r.jsx)(pO.A,{className:"w-4 h-4"}),label:"Donate",hint:"Support development",emphasis:!0})]})]})}let hM={sm:"h-9 text-xs",md:"h-11 text-sm",lg:"h-12 text-base"};function hP(e){let{value:t,onChange:s,size:a="md",className:n}=e;return(0,r.jsxs)("div",{role:"radiogroup",className:b("relative flex rounded-full bg-gray-800/60 border border-gray-800",hM[a],n),children:[(0,r.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,r.jsx)("button",{type:"button",role:"radio","aria-checked":"noob"===t,onClick:()=>s("noob"),className:b("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,r.jsx)("button",{type:"button",role:"radio","aria-checked":"pro"===t,onClick:()=>s("pro"),className:b("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 hD(){let{mode:e,setMode:t}=sy();return(0,r.jsxs)(pH,{className:"p-5 flex flex-col sm:flex-row sm:items-center gap-4",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h3",{className:"text-base font-semibold text-white",children:"Interface"}),(0,r.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,r.jsx)(hP,{value:e,onChange:t,className:"w-full sm:w-48 sm:h-10 shrink-0"})]})}var h$=s(49638),hL=s(18579),hO=s(10930);function hU(e){var t;let{release:s,isNewer:a}=e,n=null==(t=s.body)?void 0:t.replace(s.tag_name,"").trim();return(0,r.jsxs)(uC,{value:s.tag_name,className:b("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,r.jsx)(u_,{className:"px-3.5 py-2.5 gap-3 hover:bg-gray-700/20",triggerIconClass:"text-gray-500",children:(0,r.jsxs)("span",{className:"flex items-center gap-3 min-w-0 flex-1",children:[(0,r.jsx)("span",{className:b("text-sm font-semibold",a?"text-[--brand]":"text-gray-200"),children:s.tag_name}),a&&(0,r.jsx)("span",{className:"text-[10px] leading-none font-medium px-1.5 py-1 rounded bg-brand-500/20 text-[--brand]",children:"Newer"}),(0,r.jsx)("span",{className:"ml-auto text-xs text-gray-500 shrink-0",children:new Date(s.published_at).toLocaleDateString()})]})}),(0,r.jsxs)(uA,{className:"px-3.5 pb-3.5 pt-0.5 space-y-3",children:[(0,r.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,r.jsx)(pW.oz,{children:n||"No changelog provided."})}),(0,r.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,r.jsx)(hO.A,{className:"w-3 h-3"})]})]})]})}function hF(e){let{open:t,onOpenChange:s,channel:a,releases:l}=e,i=dO("(min-width: 640px)"),{loadMore:o,hasMore:d,loadingMore:c,loading:u,error:m}=l,p=n.useRef(null),h=n.useRef(o);h.current=o;let x=n.useCallback(e=>{var t;if(null==(t=p.current)||t.disconnect(),!e){p.current=null;return}p.current=new IntersectionObserver(e=>{var t;(null==(t=e[0])?void 0:t.isIntersecting)&&h.current()},{rootMargin:"300px"}),p.current.observe(e)},[]);n.useEffect(()=>()=>{var e;return null==(e=p.current)?void 0:e.disconnect()},[]);let g=new Set(l.newer.map(e=>e.tag_name));return(0,r.jsxs)(tj,{open:t,onOpenChange:s,side:i?"right":"bottom",size:i?"lg":"full",title:"All releases",description:"nightly"===a?"Every nightly build, newest first.":"Every release, newest first.",contentClass:"flex flex-col",children:[(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1",children:[m&&(0,r.jsx)(lN,{intent:"alert",title:"Error",description:m,className:"mb-2"}),u?(0,r.jsx)("div",{className:"space-y-2",children:[0,1,2,3,4].map(e=>(0,r.jsx)(pY,{className:"h-11 w-full rounded-lg"},e))}):(0,r.jsx)(uS,{type:"multiple",defaultValue:g.size?l.newer.map(e=>e.tag_name).slice(0,5):l.releases[0]?[l.releases[0].tag_name]:[],className:"space-y-2",children:l.releases.map((e,t)=>(0,r.jsx)(tB.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,r.jsx)(hU,{release:e,isNewer:g.has(e.tag_name)})},e.id||e.tag_name))}),(0,r.jsx)("div",{ref:x,className:"h-px"}),c&&(0,r.jsx)("div",{className:"space-y-2 pt-2",children:[0,1,2].map(e=>(0,r.jsx)(pY,{className:"h-11 w-full rounded-lg"},e))}),!u&&d&&!c&&(0,r.jsx)("div",{className:"flex justify-center py-4",children:(0,r.jsx)("button",{type:"button",onClick:o,className:"text-xs text-gray-500 hover:text-white transition-colors",children:"Load older releases"})}),!u&&!d&&l.releases.length>0&&(0,r.jsx)("p",{className:"text-center text-xs text-gray-600 py-4",children:"That's everything."})]}),(0,r.jsx)("div",{className:"pt-3 mt-3 border-t border-gray-700/60",children:(0,r.jsxs)("a",{href:hc,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,r.jsx)(hO.A,{className:"w-3.5 h-3.5"})]})})]})}function hz(e){let{version:t,channel:s,releases:a,docsEntries:l,docsLoading:i}=e,[o,d]=n.useState(!1);if("dev"===s)return(0,r.jsx)(pH,{className:"p-4",children:(0,r.jsxs)("p",{className:"text-sm text-gray-400",children:["This is a dev/PR build (",(0,r.jsx)("span",{className:"font-mono text-gray-300",children:t}),"). Update checks are not available."]})});let c=a.newer[0],u=!a.loading&&!a.error&&0===a.newer.length,m=hm(l,(null==c?void 0:c.tag_name)??t);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(pH,{className:"p-5",children:a.loading?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(pY,{className:"h-5 w-52"}),(0,r.jsx)(pY,{className:"h-4 w-full max-w-md"})]}):a.error?(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,r.jsxs)("p",{className:"text-sm text-gray-400",children:["Could not check for updates — ",a.error]}),(0,r.jsx)(hV,{onOpenReleases:()=>d(!0)})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[c?(0,r.jsx)(h$.A,{className:"w-5 h-5 text-[--brand] shrink-0 mt-0.5"}):(0,r.jsx)(hL.A,{className:"w-5 h-5 text-gray-500 shrink-0 mt-0.5"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:c?(0,r.jsxs)(r.Fragment,{children:[c.tag_name," is available",a.newer.length>1&&(0,r.jsxs)("span",{className:"text-gray-500 font-normal",children:[" ","\xb7 ",a.newer.length," releases behind"]})]}):u?`You're on the latest ${"nightly"===s?"nightly":"release"}`:`Running ${t}`}),c&&(0,r.jsxs)("p",{className:"text-xs text-gray-500 mt-0.5",children:["You're on ",t]}),i?(0,r.jsx)(pY,{className:"h-4 w-64 mt-2"}):m?(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("p",{className:"text-sm text-gray-300",children:m.title}),m.description&&(0,r.jsx)("p",{className:"text-sm text-[--muted] mt-0.5",children:m.description})]}):null]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[m&&(0,r.jsxs)(w,{intent:"primary",size:"sm",rightIcon:(0,r.jsx)(hO.A,{className:"w-3.5 h-3.5"}),onClick:()=>window.open(hp(m),"_blank","noopener,noreferrer"),children:["What's new in ",m.version??m.title]}),(0,r.jsx)(hV,{onOpenReleases:()=>d(!0)})]})]})}),(0,r.jsx)(hF,{open:o,onOpenChange:d,channel:s,releases:a})]})}function hV(e){let{onOpenReleases:t}=e;return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[(0,r.jsxs)("a",{href:hc,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,r.jsx)(pU.A,{className:"w-3.5 h-3.5"}),"Changelog"]}),(0,r.jsx)("button",{type:"button",onClick:t,className:"text-sm text-gray-400 hover:text-white transition-colors",children:"All releases"})]})}var hq=s(5901);function hB(e){let{version:t,channel:s,docsEntries:a}
43=e,[l,i]=n.useState(null);n.useEffect(()=>{if("stable"!==s||!t||"unknown"===t.toLowerCase())return;let e=function(){try{return localStorage.getItem(hg)}catch{return null}}();if(!e)return void(!function(){try{if(em()||"u">typeof window&&hb.test(window.location.pathname))return!0;return hf.some(e=>null!==localStorage.getItem(e))}catch{return!1}}()?hv(t):i(t));if(e===t)return;let a=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,t);"major"===a||"minor"===a?i(t):hv(t)},[t,s]);let o=()=>{hv(t),i(null)},d=hm(a,t);return(0,r.jsx)(tJ,{open:null!==l,onOpenChange:e=>{e||o()},contentClass:"max-w-lg",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("span",{className:"w-10 h-10 rounded-lg bg-brand-500/20 text-[--brand] flex items-center justify-center shrink-0",children:(0,r.jsx)(hq.A,{className:"w-5 h-5"})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("h2",{className:"text-lg font-semibold text-white",children:["AIOStreams was updated to ",t]}),d?(0,r.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:d.title}):(0,r.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==d?void 0:d.description)&&(0,r.jsx)("p",{className:"text-sm text-gray-300 border-l-2 border-gray-700 pl-3",children:d.description}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 pt-1",children:[(0,r.jsx)("button",{type:"button",onClick:o,className:"text-sm text-gray-500 hover:text-gray-300 transition-colors",children:"Dismiss"}),(0,r.jsx)(w,{intent:"primary",rightIcon:(0,r.jsx)(hO.A,{className:"w-3.5 h-3.5"}),onClick:()=>{window.open(d?hp(d):hc,"_blank","noopener,noreferrer"),o()},children:"See what changed"})]})]})})}function hK(e){let{open:t,onOpenChange:s,currentName:a,currentLogo:l,currentDescription:i}=e,{setUserData:o}=aY(),[d,c]=(0,n.useState)(a),[u,m]=(0,n.useState)(l),[p,h]=(0,n.useState)(i);return(0,n.useEffect)(()=>{c(a),m(l),h(i)},[a,l,i]),(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"Customize Addon",children:(0,r.jsx)("form",{onSubmit:e=>{(e.preventDefault(),d.trim())?(o(e=>({...e,addonName:d.trim(),addonLogo:null==u?void 0:u.trim(),addonDescription:(null==p?void 0:p.trim())||void 0})),x.oR.success("Customization saved"),s(!1)):x.oR.error("Name cannot be empty")},children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(G,{label:"Addon Name",value:d,onValueChange:c,placeholder:"Enter addon name"}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"This name is shown wherever the addon is installed"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(G,{label:"Logo URL",value:u,onValueChange:e=>{m(e.trim()||void 0)},placeholder:"Enter logo URL",type:"url"}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"Enter a valid URL for your addon's logo image. Leave blank for default logo."})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(n7,{label:"Addon Description",value:p,onValueChange:h,placeholder:"Enter addon description",rows:3}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"This description is shown wherever the addon is installed"})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-2",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{type:"submit",intent:"primary",children:"Save Changes"})]})]})})})}function hH(e){let{open:t,onOpenChange:s,updates:a,onApply:n,onDismiss:l,onForget:i,onDismissAll:o}=e;return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"Template Updates Available",contentClass:"max-w-2xl",children:(0,r.jsxs)("div",{className:"space-y-4 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Templates you've applied have new versions available."}),(0,r.jsx)("div",{className:"space-y-3 max-h-[52vh] overflow-y-auto overflow-x-hidden pr-4 -mr-2",children:a.map(e=>(0,r.jsxs)("div",{className:"rounded-lg border border-gray-700 bg-gray-800/50 p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsx)("span",{className:"font-semibold text-white",children:e.template.metadata.name}),(0,r.jsxs)("span",{className:"text-xs text-gray-400 whitespace-nowrap flex-shrink-0",children:["v",e.appliedVersion," ",(0,r.jsx)("span",{className:"text-gray-600",children:"→"})," ",(0,r.jsxs)("span",{className:"text-green-400",children:["v",e.template.metadata.version]})]})]}),e.newChangelog.length>0?(0,r.jsx)("div",{className:"space-y-3",children:e.newChangelog.map(e=>(0,r.jsx)(pQ,{entry:e},e.version))}):e.template.metadata.changelogUrl?(0,r.jsx)(p2,{update:e}):(0,r.jsx)("p",{className:"text-xs text-gray-500 italic",children:"No changelog provided for this update."}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,r.jsx)(w,{intent:"primary",className:"flex-1",onClick:()=>n(e),children:"Apply Update"}),(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>l(e.template.metadata.id,e.template.metadata.version),children:"Skip this version"})]}),(0,r.jsx)("button",{className:"text-xs text-gray-600 hover:text-gray-400 transition-colors underline-offset-2 hover:underline",onClick:()=>i(e.template.metadata.id),children:"Ignore all future updates for this template"})]},e.template.metadata.id))}),(0,r.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-gray-700",children:[(0,r.jsx)("button",{className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",onClick:o,children:"Dismiss all"}),(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),children:"Maybe later"})]})]})})}function hW(){return(0,r.jsx)(r6,{className:"space-y-5 p-4 sm:p-8",children:(0,r.jsx)(hG,{})})}function hG(){var e,t,s;let{status:a}=tr(),{nextMenu:l,setSelectedMenu:i}=a1(),{userData:o,setUserData:d,uuid:c,password:u}=aY(),{isFirstTime:m,setIsFirstTime:p}=sy(),h=pf(a),x=tQ(!1),g=tQ(!1),f=tQ(!1),b=tQ(!1),[v,y]=n.useState(!1),[j,w]=n.useState(null),[N,k]=n.useState([]),[S,C]=n.useState(),[_,A]=n.useState(),[R,T]=n.useState([]),[I,E]=n.useState(!0),M=n.useRef(!1),{isSignedIn:P,openSignIn:D,toggleSession:$}=c1(),L=o.addonName||(null==a||null==(e=a.settings)?void 0:e.addonName)||"AIOStreams",O=o.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.",U=(null==a?void 0:a.tag)||"Unknown",F=(null==a?void 0:a.channel)??(U.startsWith("v")?"stable":"nightly"),z=null==a||null==(t=a.settings)?void 0:t.customHtml,V=function(e,t,s){let[a,r]=n.useState([]),[l,i]=n.useState(!1),[o,d]=n.useState(!1),[c,u]=n.useState(null),[m,p]=n.useState(1),[h,x]=n.useState(!0),g=n.useRef(!1),f=n.useCallback(async(e,s)=>{let a=[],r=e,n=!0;for(let e=0;e<s;e++){let e=await hx(r);if(a.push(...e.releases.filter(e=>{var s;return s=e.tag_name,"stable"===t?s.startsWith("v")&&!s.includes("nightly"):s.endsWith("-nightly")})),r+=1,!(n=e.hasNextPage)||a.length>=20)break}return a.sort((e,t)=>
43new Date(t.published_at).getTime()-new Date(e.published_at).getTime()),{collected:a,page:r,more:n}},[t]);n.useEffect(()=>{s&&"dev"!==t&&!g.current&&(g.current=!0,i(!0),u(null),f(1,1).then(e=>{let{collected:t,page:s,more:a}=e;r(t),p(s),x(a)}).catch(e=>u(e.message)).finally(()=>i(!1)))},[s,t,f]);let b=n.useCallback(()=>{o||l||!h||(d(!0),f(m,4).then(e=>{let{collected:t,page:s,more:a}=e;r(e=>{let s=new Set(e.map(e=>e.tag_name));return[...e,...t.filter(e=>!s.has(e.tag_name))]}),p(s),x(a)}).catch(e=>u(e.message)).finally(()=>d(!1)))},[f,h,l,o,m]),v=n.useMemo(()=>e&&"unknown"!==e.toLowerCase()?a.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):[],[a,e,t]);return{releases:a,newer:v,loading:l,loadingMore:o,error:c,hasMore:h,loadMore:b}}(U,F,!0),q=(o.presets??[]).length>0||(o.services??[]).some(e=>e.enabled),B=n.useMemo(()=>{var e;let t=((null==a||null==(e=a.settings)?void 0:e.featuredTemplateIds)??[]).slice(0,2).map(e=>h.templates.find(t=>t.metadata.id===e)).filter(e=>void 0!==e);return t.length>0?t:h.templates.slice(0,2)},[null==a||null==(s=a.settings)?void 0:s.featuredTemplateIds,h.templates]);n.useEffect(()=>{h.loadTemplates()},[]),n.useEffect(()=>{hh().then(T).catch(()=>T([])).finally(()=>E(!1))},[]),n.useEffect(()=>{m&&!c&&(y(!0),f.open(),p(!1))},[]),n.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()))},[]),n.useEffect(()=>{M.current=!1},[c]),n.useEffect(()=>{!c||M.current||0!==h.appliedTemplateUpdates.length&&(M.current=!0,k(h.appliedTemplateUpdates),b.open())},[h.appliedTemplateUpdates,c,u]);let K=e=>{k(t=>{let s=t.filter(t=>t.template.metadata.id!==e);return 0===s.length&&b.close(),s})},H=e=>{y((null==e?void 0:e.welcome)??!1),w((null==e?void 0:e.template)??null),f.open()};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col gap-5 w-full",children:[(0,r.jsx)(hN,{addonName:L,addonDescription:O,logo:o.addonLogo||"/logo.png",version:U,channel:F,commit:null==a?void 0:a.commit,onCustomize:g.open,onDonate:x.open,isSignedIn:P,onToggleSession:$}),z&&(0,r.jsx)(u6,{children:(0,r.jsx)("div",{className:"[&_a]:text-[--brand] [&_a:hover]:underline",dangerouslySetInnerHTML:{__html:z}})}),(0,r.jsx)(hC,{isSignedIn:P,hasConfig:q,onStartSetup:()=>H({welcome:!0}),onContinue:()=>l(),onBrowseSetups:()=>H(),onInstall:()=>i("save-install"),onSignIn:()=>D()}),(0,r.jsx)(hA,{templates:B,totalCount:h.templates.length,loading:h.loadingTemplates,onOpen:e=>H({template:e}),onBrowseAll:()=>H()}),(0,r.jsx)(hz,{version:U,channel:F,releases:V,docsEntries:R,docsLoading:I}),(0,r.jsx)(hD,{}),(0,r.jsx)(hE,{discordUrl:"https://discord.viren070.me",githubUrl:"https://github.com/Viren070/AIOStreams",onDonate:x.open}),(0,r.jsxs)("div",{className:"flex flex-col items-center gap-0.5 text-xs text-gray-500 pt-2",children:[(0,r.jsxs)("span",{children:["\xa9 ",new Date().getFullYear()," AIOStreams. Developed by Viren070."]}),(0,r.jsxs)("span",{children:["This beautiful UI would not be possible without"," ",(0,r.jsx)("a",{href:"https://seanime.rahim.app/",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"Seanime"})]})]})]}),(0,r.jsx)(c4,{open:x.isOpen,onOpenChange:x.toggle}),(0,r.jsx)(hK,{open:g.isOpen,onOpenChange:g.toggle,currentName:L,currentLogo:o.addonLogo,currentDescription:o.addonDescription}),(0,r.jsx)(ho,{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:()=>l(),onSignIn:()=>D()}),(0,r.jsx)(hH,{open:b.isOpen,onOpenChange:b.toggle,updates:N,onApply:e=>{b.close(),H({template:e.template})},onDismiss:(e,t)=>{d(s=>({...s,appliedTemplates:(s.appliedTemplates??[]).map(s=>s.id===e?{...s,dismissedVersion:t}:s)})),K(e)},onForget:e=>{d(t=>({...t,appliedTemplates:(t.appliedTemplates??[]).filter(t=>t.id!==e)})),K(e)},onDismissAll:()=>{d(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,r.jsx)(hB,{version:U,channel:F,docsEntries:R})]})}var hY=s(74298),hJ=s(39733),hZ=s(70858);let hQ={root:(0,h.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,h.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,h.F)(["UI-Slider__range","absolute h-full bg-brand","data-[disabled=true]:opacity-50"]),thumb:(0,h.F)(["UI-Slider__thumb","block h-4 w-4 roun
43ded-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,h.F)(["UI-Slider__mark","absolute top-6 -translate-x-1/2 text-xs text-gray-500"]),markIndicator:(0,h.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,h.F)(["UI-Slider__label","relative font-normal","data-[disabled=true]:text-gray-300 cursor-pointer user-select-none select-none"])},hX=n.forwardRef((e,t)=>{let[{value:s,className:a,onValueChange:l,defaultValue:i,trackClass:o,rangeClass:d,thumbClass:c,markClass:u,markIndicatorClass:m,labelClass:p,showMarks:h,marks:x,size:g,...f},{label:v,moreHelp:y,...j}]=U(e,n.useId()),w=n.useRef(!0),[N,k]=n.useState(s??i??[0]),S=n.useCallback(e=>{k(e),null==l||l(e)},[l]);n.useEffect(()=>{i&&w.current||k(s??[0]),w.current=!1},[s]);let C=n.useMemo(()=>{if(!h||x)return[];let e=f.step||1,t=f.min||0;return Array.from({length:Math.floor(((f.max||100)-t)/e)+1},(s,a)=>({value:t+a*e,label:(t+a*e).toString()}))},[h,x,f.step,f.min,f.max]),_=x||C;return(0,r.jsx)(F,{...j,id:j.id,children:(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[v&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("label",{className:b(hQ.label(),p),htmlFor:j.id,"data-disabled":j.disabled,children:v}),y&&(0,r.jsx)(L,{className:"text-sm",trigger:(0,r.jsx)(P.ExT,{className:"transition-opacity opacity-45 hover:opacity-90"}),children:y})]}),(0,r.jsxs)(hZ.bL,{ref:rG([t]),className:b(hQ.root({size:g}),a),value:N,onValueChange:S,disabled:j.disabled||j.readonly,"data-disabled":j.disabled,"data-readonly":j.readonly,"data-error":!!j.error,...f,children:[(0,r.jsx)(hZ.CC,{className:b(hQ.track(),o),children:(0,r.jsx)(hZ.Q6,{className:b(hQ.range(),d)})}),_.map(e=>{let{value:t,label:s}=e;return(0,r.jsxs)(n.Fragment,{children:[(0,r.jsx)("div",{className:b(hQ.markIndicator(),m),style:{left:`${(t-(f.min||0))/((f.max||100)-(f.min||0))*100}%`}}),(0,r.jsx)("div",{className:b(hQ.mark(),u),style:{left:`${(t-(f.min||0))/((f.max||100)-(f.min||0))*100}%`},children:s})]},t)}),N.map((e,t)=>(0,r.jsx)(hZ.zi,{className:b(hQ.thumb({size:g}),c)},t))]})]})})});function h0(e){let{filterName:t,preferredOptions:s,requiredOptions:a,excludedOptions:l,includedOptions:i,onPreferredChange:o,onRequiredChange:d,onExcludedChange:c,onIncludedChange:u,options:m}=e,[p,h]=(0,n.useState)(a),[x,g]=(0,n.useState)(l),[f,b]=(0,n.useState)(s),[v,y]=(0,n.useState)(i),[j,w]=(0,n.useState)(!1),{mode:N}=sy(),k=e=>e.filter(e=>m.some(t=>t.value===e));(0,n.useEffect)(()=>{h(k(a)),g(k(l)),b(k(s)),y(k(i))},[a,l,s,i]);let S=(0,uV.FR)((0,uV.MS)(uV.AN),(0,uV.MS)(uV.IG,{activationConstraint:{delay:150,tolerance:8}}));return(0,n.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,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(u6,{title:`${t} Selection`,description:`Configure required, excluded, and preferred ${t.toLowerCase()}`,children:(0,r.jsxs)("div",{className:"space-y-4",children:["pro"===N&&(0,r.jsx)(nJ,{label:`Required ${t}`,help:`Any stream that is not one of the required ${t.toLowerCase()} will be excluded.`,value:p,onValueChange:e=>{h(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 required ${t.toLowerCase()}...`}),(0,r.jsx)("div",{children:(0,r.jsx)(nJ,{label:`Excluded ${t}`,value:x,help:`Any stream that is one of the excluded ${t.toLowerCase()} will be excluded.`,onValueChange:e=>{g(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 excluded ${t.toLowerCase()}...`})}),"pro"===N&&(0,r.jsx)("div",{children:(0,r.jsx)(nJ,{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),u(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,r.jsx)("div",{children:(0,r.jsx)(nJ,{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),o(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,r.jsx)(u6,{title:"Preference Order",description:`Drag to reorder your preferred ${t.toLowerCase()}`,children:(0,r.jsx)(uV.Mp,{modifiers:[uU.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,uF.be)(f,e,a);b(r),o(r)}w(!1)}},onDragStart:function(e){w(!0)},sensors:S,children:(0,r.jsx)(uF.gB,{items:f,strategy:uF._G,children:(0,r.jsx)("div",{className:"space-y-2",children:f.map(e=>{var t;return(0,r.jsx)(h1,{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),o(t)}},e)})})})})})]})}function h1(e){let{id:t,name:s,onDelete:a}=e,{attributes:n,listeners:l,setNodeRef:i,transform:o,transition:d,isDragging:c}=(0,uF.gl)({id:t}),u={transform:uz.Ks.Transform.toString(o),transition:d,opacity:c?.5:1};return(0,r.jsx)("div",{ref:i,style:u,children:(0,r.jsxs)("div",{className:"px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 relative",children:[(0,r.jsx)("div",{className:"rounded-full w-6 h-auto bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move",...n,...l}),(0,r.jsx)("div",{className:"flex-1 flex flex-col justify-center min-w-0",children:(0,r.jsx)("span",{className:"font-mono text-base truncate",children:s})}),(0,r.jsx)("div",{className:"flex-shrink-0 ml-auto",children:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(mu.H8h,{}),intent:"alert-subtle",onClick:e=>{e.preventDefault(),e.stopPropagation(),a()}})})]})})}function h2(e){let{open:t,onOpenChange:s,onImport:a}=e,[l,i]=(0,n.useState)(!1),o=(0,n.useRef)(null),d=tQ(!1),[c,u]=(0,n.use
43State)(""),m=async()=>{if(!c)return void x.oR.error("Please enter a URL");i(!0);try{let e=await fetch(c);if(!e.ok)throw Error("Failed to fetch URL");let t=await e.json();a(t),d.close(),s(!1)}catch(e){console.error("Error importing from URL:",e),x.oR.error("Failed to import from URL")}finally{i(!1)}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"Import",children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)("input",{type:"file",ref:o,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),x.oR.error("Failed to parse JSON file")}},n.readAsText(r),o.current&&(o.current.value="")},accept:".json",className:"hidden"}),(0,r.jsx)(w,{intent:"primary",onClick:()=>{var e;return null==(e=o.current)?void 0:e.click()},className:"w-full",children:"Import from File"}),(0,r.jsx)(w,{intent:"primary",onClick:d.open,className:"w-full",children:"Import from URL"})]})})}),(0,r.jsx)(tJ,{open:d.isOpen,onOpenChange:d.close,title:"Import from URL",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(G,{label:"URL",value:c,onValueChange:u,placeholder:"Enter URL to JSON file"}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:d.close,children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",onClick:m,loading:l,children:"Import"})]})]})})]})}function h3(e,t){return e.length===t.length&&e.every((e,s)=>e===t[s])}function h5(e){let{renderType:t,syncMode:s,syncedValues:a,isLoading:l,fetchError:i}=e,{userData:o,setUserData:d}=aY(),{isOpen:c,open:u,close:m}=tQ(!1),[p,h]=(0,n.useState)(null),[g,f]=(0,n.useState)(null),v="sel"===s,y=v?"selOverrides":"regexOverrides",j=v?"Expression":"Pattern";return l?(0,r.jsxs)("div",{className:"px-3 pb-2 text-xs text-[--muted] animate-pulse",children:["Loading ",j.toLowerCase(),"s..."]}):i&&0===a.length?(0,r.jsx)("div",{className:"px-3 pb-3",children:(0,r.jsxs)("div",{className:"rounded border border-red-400/30 bg-red-500/5 p-2 text-xs text-red-300",children:[(0,r.jsx)("span",{className:"font-medium",children:"Error: "}),i]})}):0===a.length?null:(0,r.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[i&&(0,r.jsxs)("div",{className:"rounded border border-yellow-400/30 bg-yellow-500/5 p-2 text-xs text-yellow-400",children:[(0,r.jsx)("span",{className:"font-medium",children:"Warning: "}),i]}),a.map((e,s)=>{let a=e.pattern??e.expression??"",n=o[y]||[],l=v?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,i=t=>v?t.expression===a||!!t.exprNames&&!!l&&h3(t.exprNames,l):t.pattern===a||e.name&&t.originalName===e.name,c=n.find(i),m=c?c.disabled:!1===e.enabled,p=v?(null==l?void 0:l.join(", "))??"":(null==c?void 0:c.name)??e.name??"",g=v?!!c&&!c.disabled&&void 0!==c.score:!!c&&!c.disabled,w=(null==c?void 0:c.score)!==void 0?c.score:e.score??0,N=t=>{d(s=>{let r=[...s[y]||[]];if(t){let t=r.findIndex(i);if(t>=0){let a=r[t],n=void 0!==a.score&&a.score!==e.score;return!v&&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,[y]:r}}if(!1===e.enabled){let t=v?{expression:a,exprNames:l,disabled:!1}:{pattern:a,originalName:e.name,disabled:!1};return r.push(t),{...s,[y]:r}}return s}let n=r.findIndex(i),o=n>=0?r[n]:null,d=v?{expression:a,score:null==o?void 0:o.score,exprNames:l,disabled:!0}:{pattern:a,name:null==o?void 0:o.name,score:null==o?void 0:o.score,originalName:e.name,disabled:!0};return n>=0?r[n]=d:r.push(d),{...s,[y]:r}}),x.oR.success(t?`${j} enabled`:`${j} disabled`)},k=()=>{d(e=>({...e,[y]:(e[y]||[]).filter(e=>!i(e))})),x.oR.info("Override removed")};return(0,r.jsxs)("div",{className:b("p-2 rounded border",m?"opacity-50 border-gray-700/50 bg-gray-900/30":"border-gray-700 bg-gray-900/60",g&&!m&&"border-primary/40"),children:["simple"===t&&(0,r.jsxs)("div",{className:"relative flex gap-2 items-start pl-[calc(24px+0.5rem)]",children:[(0,r.jsx)("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 min-w-[24px] flex justify-center",children:(0,r.jsx)(nB,{value:!m,size:"lg",onValueChange:e=>N(!0===e)})}),(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(G,{value:a,label:`${j} (Synced)`,disabled:!0,size:"sm"})})]}),"nameable"===t&&(0,r.jsxs)("div",{className:"relative flex gap-2 items-start pl-[calc(24px+0.5rem)]",children:[(0,r.jsx)("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 min-w-[24px] flex justify-center",children:(0,r.jsx)(nB,{value:!m,size:"lg",onValueChange:e=>N(!0===e)})}),(0,r.jsx)("div",{className:"flex-none w-1/3",children:(0,r.jsx)(G,{value:p,label:!v&&g?"Name (Overridden)":"Name (Synced)",disabled:!0,size:"sm",className:b(m&&"line-through text-gray-500")})}),(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(G,{value:a,label:`${j} (Synced)`,disabled:!0,size:"sm",className:b(m&&"line-through text-gray-500")})}),(0,r.jsxs)("div",{className:"pb-0.5 flex gap-1 flex-shrink-0 self-end",children:[g&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(mu.EEI,{className:"text-xs"}),intent:"alert-subtle",onClick:k,className:"h-[38px] w-[38px] border border-red-400/20 hover:border-red-400/50 transition-colors shadow-sm"}),children:"Reset Override"}),!v&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(mu.uO9,{className:"text-xs"}),intent:g?"primary":"primary-subtle",onClick:()=>{h({pattern:a,name:(null==c?void 0:c.name)??e.name??"",originalName:e.name}),u()},className:"h-[38px] w-[38px] border border-primary/20 hover:border-primary/50 transition-colors shadow-sm"}),children:"Override"})]})]}),"ranked"===t&&(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 min-w-[24px] flex justify-center",children:(0,r.jsx)(nB,{value:!m,size:"lg",onValueChange:e=>N(!0===e)})}),(0,r.jsxs)("div",{className:"flex gap-2 items-start pl-[calc(24px+0.5rem)]",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(G,{value:a,label:`${j} (Synced)`,disabled:!0,size:"sm",className:b(m&&"line-through text-gray-500")})}),(0,r.jsxs)("div",{className:"pb-0.5 flex gap-1 flex-shrink-0 self-end",children:[g&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",icon:(0,r.jsx)(mu.EEI,{className:"text-xs"}),intent:"alert-subtle",onClick:k}),children:"Reset Override"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(mu.uO9,{className:"text-xs"}),intent:g?"primary":"primary-subtle",onClick:()=>{v?f({expression:a,score:w,exprNames:l}):h({pattern:a,name:(null==c?void 0:c.name)??e.name??"",score:w,originalName:e.name}),u()}}),children:"Override"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 pl-[calc(24px+0.5rem)] mt-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(G,{value:p,label:`Name${l&&l.length>
431?"s":""} (Synced)`,disabled:!0,size:"sm",className:b(m&&"line-through text-gray-500")})}),(0,r.jsx)("div",{className:"w-24",children:(0,r.jsx)(n1,{value:w,label:g?"Score (Ovr)":"Score",disabled:!0,size:"sm"})})]})]})]},s)}),(0,r.jsx)(tJ,{open:c&&null!==p,onOpenChange:e=>{e||(h(null),m())},title:"Override",children:(0,r.jsxs)("div",{className:"space-y-4 py-2",children:[(0,r.jsxs)("p",{className:"text-xs text-[--muted] break-all",children:[j,":"," ",(0,r.jsx)("code",{className:"text-[--primary]",children:null==p?void 0:p.pattern})]}),("nameable"===t||"ranked"===t)&&(0,r.jsx)(G,{label:"Custom Name",value:(null==p?void 0:p.name)||"",onValueChange:e=>h(t=>t?{...t,name:e}:null)}),"ranked"===t&&(0,r.jsx)(n1,{label:"Custom Score",value:(null==p?void 0:p.score)||0,min:-1e6,max:1e6,step:50,onValueChange:e=>h(t=>t?{...t,score:e}:null)}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:()=>{h(null),m()},children:"Cancel"}),(0,r.jsx)(w,{onClick:()=>{p&&(d(e=>{let t=[...e[y]||[]],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,[y]:t}}),h(null),m(),x.oR.success("Override saved"))},children:"Save Override"})]})]})}),(0,r.jsx)(tJ,{open:c&&null!==g,onOpenChange:e=>{e||(f(null),m())},title:"Score Override",children:(0,r.jsxs)("div",{className:"space-y-4 py-2",children:[(0,r.jsxs)("p",{className:"text-xs text-[--muted] break-all",children:["Expression:"," ",(0,r.jsx)("code",{className:"text-[--primary]",children:null==g?void 0:g.expression})]}),(0,r.jsx)(n1,{label:"Custom Score",value:(null==g?void 0:g.score)||0,min:-1e6,max:1e6,step:50,onValueChange:e=>f(t=>t?{...t,score:e}:null)}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:()=>{f(null),m()},children:"Cancel"}),(0,r.jsx)(w,{onClick:()=>{g&&(d(e=>{let t=[...e[y]||[]],s=t.findIndex(e=>e.expression===g.expression||!!e.exprNames&&!!g.exprNames&&h3(e.exprNames,g.exprNames)),a=s>=0?t[s]:void 0,r={expression:g.expression,score:g.score||0,exprNames:g.exprNames,disabled:g.disabled??(null==a?void 0:a.disabled)};return s>=0?t[s]=r:t.push(r),{...e,[y]:t}}),f(null),m(),x.oR.success("Score override saved"))},children:"Save Override"})]})]})})]})}function h4(e){var t;let{syncConfig:s,renderType:a="simple"}=e,{status:l}=tr(),{userData:i,password:o}=aY(),[d,c]=(0,n.useState)(""),[u,m]=(0,n.useState)({}),p=(null==s?void 0:s.syncMode)??"regex",h="sel"===p?"expressions":"patterns";if((0,n.useEffect)(()=>{if(!s)return;let{urls:e}=s;if(0===e.length)return;let t=new AbortController,a=i.uuid?{uuid:i.uuid,password:o}:void 0;for(let s of(m(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?eM([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}}):eE([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||m(e=>({...e,[s]:{values:a,isLoading:!1,error:r}}))}).catch(e=>{t.signal.aborted||m(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(","),i.uuid,o,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,r,n,i;let o=(null==l||null==(s=l.settings)||null==(t=s.regexAccess)?void 0:t.urls)||[];if(!e)return!1;try{new URL(e)}catch{return x.oR.error("Invalid URL format"),!1}if(g.includes(e))return x.oR.error("URL is already added"),!1;if("sel"===p){let t=(null==l||null==(r=l.settings)||null==(a=r.selSyncAccess)?void 0:a.level)??"all";return!!("all"===t||"trusted"===t&&b)||!!((null==l||null==(i=l.settings)||null==(n=i.selSyncAccess)?void 0:n.trustedUrls)||[]).includes(e)||(x.oR.error("This URL is not in the allowed list. Contact the instance owner to whitelist it."),!1)}return!!((null==l?void 0:l.settings.regexAccess.level)==="all"||(null==l?void 0:l.settings.regexAccess.level)==="trusted"&&b)||!!o.includes(e)||(x.oR.error("URL is not in the allowed list"),!1)})(d)&&(v([...g,d]),c(""))};return(0,r.jsxs)("div",{className:"mt-4 border-t border-gray-800 pt-4 space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("h5",{className:"text-sm font-medium",children:["Synced URLs",g.length>0&&(0,r.jsxs)("span",{className:"ml-1.5 text-xs text-[--muted] font-normal",children:["(",g.length,")"]})]}),(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["Automatically fetch and sync ",h," from URLs"]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[g.length>0&&(0,r.jsx)("div",{className:"rounded-md border border-[--brand]/20 bg-[--brand]/5 divi
43de-y divide-[--brand]/10",children:g.map(e=>{var t,n;let l=u[e];return(0,r.jsx)("div",{"data-synced-url":e,children:(0,r.jsx)(tE,{type:"single",collapsible:!0,children:(0,r.jsxs)(tM,{value:"items",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 p-2 px-3 text-sm",children:[(0,r.jsx)(tP,{children:(0,r.jsx)("button",{type:"button",className:"group flex items-center",children:(0,r.jsx)(mu.Vr3,{className:"text-[10px] text-[--muted] transition-transform duration-200 group-data-[state=open]:rotate-180"})})}),(0,r.jsx)("span",{className:"flex-1 break-all font-mono text-xs text-[--muted]",children:e}),s.onInsertPlaceholder&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(mu.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==(n=s.hasPlaceholder)?void 0:n.call(s,e))?"Remove from inline":"Place inline"}),(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(mu.H8h,{}),intent:"alert-subtle",onClick:()=>v(g.filter(t=>t!==e))})]}),(0,r.jsx)(tD,{children:(0,r.jsx)(h5,{renderType:a,syncMode:p,syncedValues:(null==l?void 0:l.values)??[],isLoading:(null==l?void 0:l.isLoading)??!0,fetchError:(null==l?void 0:l.error)??null})})]})})},e)})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(G,{value:d,placeholder:`https://example.com/${h}.json`,onValueChange:c,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),y())}})}),(0,r.jsx)(E,{onClick:y,disabled:!d,icon:(0,r.jsx)(mu.OiG,{}),rounded:!0,intent:"primary-subtle"})]})]})]})}hX.displayName="Slider";let h6="md:flex-1 md:min-w-[100px]";function h9(e){return e.charAt(0).toLowerCase()+e.slice(1).replace(/\s+/g,"")}function h8(e){let{rows:t,index:s,url:a,iconPosition:l}=e,i=(0,n.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]),o=(0,r.jsx)(tO,{trigger:(0,r.jsx)("button",{type:"button","aria-label":"Jump to synced URL",onClick:i,className:"h-6 w-6 flex items-center justify-center cursor-pointer hover:opacity-80 transition-opacity shrink-0",children:(0,r.jsx)(mu.AnD,{className:"text-[--brand] text-base"})}),children:"Jump to synced URL"});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:mm,children:["inside"!==l&&(0,r.jsx)("div",{className:mp,children:o}),(0,r.jsx)("div",{className:mh,children:(0,r.jsx)(mb,{rows:t,index:s})})]}),(0,r.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"===l&&o,(0,r.jsx)("span",{className:"text-sm text-[--muted] font-mono truncate min-w-0 flex-1",children:a})]})]})}function h7(e,t,s,a,n){return t.map((t,l)=>{let i=e.keyAt(l),o=(null==n?void 0:n.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,r.jsx)(mf,{id:i,children:o?(0,r.jsx)(h8,{rows:e,index:l,url:o,iconPosition:null==n?void 0:n.iconPosition}):a(t,l)},i)})}function xe(e,t,s){let a=tQ(!1);return{modal:a,handleImport:(0,n.useCallback)(e=>{t(e)||x.oR.error("Invalid import format")},[t]),handleExport:(0,n.useCallback)(()=>{var t,a;let r,n,l,i,o,d,c,u,m,p;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),(p=document.createElement("a")).href=m,p.download=a,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(m)},[e,s])}}function xt(e){let{onAdd:t,onImportClick:s,onExport:a,children:n}=e;return(0,r.jsxs)("div",{className:"mt-2 flex gap-2 items-center",children:[(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(mu.OiG,{}),onClick:t}),n,(0,r.jsxs)("div",{className:"ml-auto flex gap-2",children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(mu.P
43iR,{}),onClick:s}),children:"Import"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(mu.Mbn,{}),onClick:a}),children:"Export"})]})]})}function xs(e){let{fieldName:t,itemName:s,label:a,help:l,values:i,onValuesChange:o,placeholder:d,syncConfig:c,disabled:u}=e,m=(0,n.useRef)(i);m.current=i;let p=mx(i,o),{modal:h,handleImport:x,handleExport:g}=xe((0,n.useCallback)(()=>({values:m.current}),[]),(0,n.useCallback)(e=>!!Array.isArray(e.values)&&(o(e.values),!0),[o]),a),f=(0,n.useCallback)((e,t)=>{let s=m.current;o([...s.slice(0,t),e,...s.slice(t+1)])},[o]);return(0,r.jsxs)(u6,{id:t??h9(a),title:a,description:l,children:[(0,r.jsx)(mg,{rows:p,children:h7(p,i,e=>e,(e,t)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:mh,children:(0,r.jsx)(mb,{rows:p,index:t})}),(0,r.jsx)("div",{className:"md:flex-1",children:(0,r.jsx)(G,{value:e,"aria-label":s,placeholder:d??s,onValueChange:e=>f(e,t)})})]}),{syncEnabled:!!c,iconPosition:"inside"})}),(0,r.jsx)(xt,{onAdd:()=>o([...i,""]),onImportClick:h.open,onExport:g}),(0,r.jsx)(h2,{open:h.isOpen,onOpenChange:h.toggle,onImport:x}),c&&(0,r.jsx)(h4,{syncConfig:c,renderType:"simple"})]},a)}function xa(e){let{title:t,fieldName:s,description:a,values:l,onValuesChange:i,onExpressionChange:o,onEnabledChange:d,placeholder:c,syncConfig:u}=e,m=(0,n.useRef)(l);m.current=l;let p=mx(l,i),{modal:h,handleImport:x,handleExport:g}=xe((0,n.useCallback)(()=>m.current.map(e=>({expression:e.expression,enabled:e.enabled})),[]),(0,n.useCallback)(e=>Array.isArray(e)&&e.every(e=>"string"==typeof e.expression)?(i(e.map(e=>({expression:e.expression,enabled:e.enabled??!0}))),!0):!!Array.isArray(null==e?void 0:e.values)&&(i(e.values.map(e=>({expression:e,enabled:!0}))),!0),[i]),t);return(0,r.jsxs)(u6,{id:s??h9(t),title:t,description:a,children:[(0,r.jsx)(mg,{rows:p,children:h7(p,l,e=>e.expression,(e,t)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:mm,children:[(0,r.jsx)("div",{className:mp,children:(0,r.jsx)(nB,{value:e.enabled??!0,defaultValue:!0,size:"lg","aria-label":"Enabled",onValueChange:e=>{d&&d(!0===e,t)}})}),(0,r.jsx)("div",{className:mh,children:(0,r.jsx)(mb,{rows:p,index:t})})]}),(0,r.jsx)("div",{className:"md:flex-1",children:(0,r.jsx)(G,{value:e.expression,"aria-label":"Expression",placeholder:c,disabled:!1===e.enabled,onValueChange:e=>o(e,t)})})]}),{syncEnabled:!!u})}),(0,r.jsx)(xt,{onAdd:()=>i([...l,{expression:"",enabled:!0}]),onImportClick:h.open,onExport:g}),(0,r.jsx)(h2,{open:h.isOpen,onOpenChange:h.toggle,onImport:x}),u&&(0,r.jsx)(h4,{syncConfig:u,renderType:"nameable"})]})}function xr(e){let{title:t,description:s,keyName:a,keyId:l,keyPlaceholder:i,valueId:o,valueName:d,valuePlaceholder:c,values:u,onValuesChange:m,onValueChange:p,onKeyChange:h,disabled:x,syncConfig:g}=e,f=(0,n.useRef)(u);f.current=u;let b=mx(u,m),{modal:v,handleImport:y,handleExport:j}=xe((0,n.useCallback)(()=>f.current.map(e=>({[l]:e.name,[o]:e.value})),[l,o]),(0,n.useCallback)(e=>!!(Array.isArray(e)&&e.every(e=>"string"==typeof e[l]&&"string"==typeof e[o]))&&(m(e.map(e=>({name:e[l],value:e[o]}))),!0),[m,l,o]),t);return(0,r.jsxs)(u6,{title:t,description:s,children:[(0,r.jsx)(mg,{rows:b,children:h7(b,u,e=>e.value,(e,t)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:mh,children:(0,r.jsx)(mb,{rows:b,index:t})}),(0,r.jsx)("div",{className:"md:flex-1",children:(0,r.jsx)(G,{value:e.name,"aria-label":a,placeholder:i,onValueChange:e=>h(e,t)})}),(0,r.jsx)("div",{className:"md:flex-1",children:(0,r.jsx)(G,{value:e.value,"aria-label":d,placeholder:c,onValueChange:e=>p(e,t)})})]}),{syncEnabled:!!g,iconPosition:"inside"})}),(0,r.jsx)(xt,{onAdd:()=>m([...u,{name:"",value:""}]),onImportClick:v.open,onExport:j}),(0,r.jsx)(h2,{open:v.isOpen,onOpenChange:v.toggle,onImport:y}),g&&(0,r.jsx)(h4,{syncConfig:g,renderType:"nameable"})]})}function xn(e){let{title:t,fieldName:s,description:a,values:l,onValuesChange:i,onExpressionChange:o,onScoreChange:d,onEnabledChange:c,syncConfig:u}=e,m=(0,n.useRef)(l);m.current=l;let p=mx(l,i),{modal:h,handleImport:x,handleExport:g}=xe((0,n.useCallback)(()=>m.current.map(e=>({expression:e.expression,score:e.score,enabled:e.enabled})),[]),(0,n.useCallback)(e=>!!(Array.isArray(e)&&e.every(e=>"string"==typeof e.expression&&"number"==typeof e.score))&&(i(e.map(e=>({expression:e.expression,score:e.score,enabled:e.enabled??!0}))),!0),[i]),t);return(0,r.jsxs)(u6,{id:s??h9(t),title:t,description:a,children:[(0,r.jsx)(mg,{rows:p,children:h7(p,l,e=>e.expression,(e,t)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:mm,children:[(0,r.jsx)("div",{className:mp,children:(0,r.jsx)(nB,{value:e.enabled??!0,defaultValue:!0,size:"lg","aria-label":"Enabled",onValueChange:e=>{c&&c(!0===e,t)}})}),(0,r.jsx)("div",{className:mh,children:(0,r.jsx)(mb,{rows:p,index:t})})]}),(0,r.jsx)("div",{className:"md:flex-[3]",children:(0,r.jsx)(G,{value:e.expression,"aria-label":"Expression",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",disabled:!1===e.enabled,onValueChange:e=>o(e,t)})}),(0,r.jsx)("div",{className:h6,children:(0,r.jsx)(n1,{value:e.score||0,defaultValue:0,"aria-label":"Score",disabled:!1===e.enabled,onValueChange:e=>d(e||0,t),min:-1e6,max:1e6,step:50})})]}),{syncEnabled:!!u})}),(0,r.jsx)(xt,{onAdd:()=>i([...l,{expression:"",score:0,enabled:!0}]),onImportClick:h.open,onExport:g}),(0,r.jsx)(h2,{open:h.isOpen,onOpenChange:h.toggle,onImport:x}),u&&(0,r.jsx)(h4,{syncConfig:u,renderType:"ranked"})]})}function xl(e){let{title:t,description:s,values:a,onValuesChange:l,onPatternChange:i,onNameChange:o,onScoreChange:d,syncConfig:c}=e,u=(0,n.useRef)(a);u.current=a;let m=mx(a,l),{modal:p,handleImport:h,handleExport:x}=xe((0,n.useCallback)(()=>u.current.map(e=>({pattern:e.pattern,name:e.name,score:e.score})),[]),(0,n.useCallback)(e=>!!(Array.isArray(e)&&e.every(e=>"string"==typeof e.pattern&&"number"==typeof e.score))&&(l(e.map(e=>({pattern:e.pattern,name:e.name,score:e.score}))),!0),[l]),t);return(0,r.jsxs)(u6,{title:t,description:s,children:[(0,r.jsx)(mg,{rows:m,children:h7(m,a,e=>e.pattern,(e,t)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:mh,children:(0,r.jsx)(mb,{rows:m,index:t})}),(0,r.jsx)("div",{className:"md:flex-[3]",children:(0,r.jsx)(G,{value:e.pattern,"aria-label":"Pattern",placeholder:"Regex Pattern",onValueChange:e=>i(e,t)})}),(0,r.jsx)("div",{className:"md:flex-[2]",children:(0,r.jsx)(G,{value:e.name||"","aria-label":"Name",placeholder:"Name (Optional)",onValueChange:e=>o(e,t)})}),(0,r.jsx)("div",{className:h6,children:(0,r.jsx)(n1,{value:e.score,"aria-label":"Score",onValueChange:e=>d(e??0,t),min:-1e6,max:1e6,step:50})})]}),{syncEnabled:!!c,iconPosition:"inside"})}),(0,r.jsx)(xt,{onAdd:()=>l([...a,{pattern:"",name:"",score:0}]),onImportClick:p.open,onExport:x}),(0,r.jsx)(h2,{open:p.isOpen,onOpenChange:p.toggle,onImport:h}),c&&(0,r.jsx)(h4,{syncConfig:c,renderType:"ranked"})]})}let xi=[{key:"movies",heading:"Movies"},{key:"series",heading:"Series"},{key:"anime",heading:"Anime Series"}];
43function xo(e){let{label:t,help:s,moviesValue:a,seriesValue:n,animeValue:l,onMoviesChange:i,onSeriesChange:o,onAnimeChange:d,min:c,max:u,formatValue:m,kind:p}=e,h={movies:a,series:n,anime:l},x={movies:i,series:o,anime:d};return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("h4",{className:"text-base font-medium",children:t}),xi.map(e=>{let{key:t,heading:a}=e,n=h[t],l=x[t];return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h5",{className:"text-sm font-medium text-[--muted]",children:a}),(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(hX,{min:c,max:u,defaultValue:[c,u],step:u/1e3,value:n,onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&l([e[0],e[1]]),minStepsBetweenThumbs:1,label:`${a} ${p} Range`,help:s}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:m(n[0])}),(0,r.jsx)("span",{children:m(n[1])})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(n1,{label:"Min",step:u/1e3,value:n[0],min:c,max:n[1],onValueChange:e=>void 0!==e&&l([e,n[1]])}),(0,r.jsx)(n1,{label:"Max",step:u/1e3,value:n[1],min:n[0],max:u,onValueChange:e=>void 0!==e&&l([n[0],e])})]})]})]},t)})]})}function xd(e){let{min:t=0,max:s=1e11,...a}=e;return(0,r.jsx)(xo,{min:t,max:s,formatValue:ne,kind:"Size",...a})}function xc(e){let{min:t=0,max:s=25e7,...a}=e;return(0,r.jsx)(xo,{min:t,max:s,formatValue:ns,kind:"Bitrate",...a})}let xu=["2160p","1440p","1080p","720p","576p","480p","360p","240p","144p","Unknown"],xm=["BluRay REMUX","BluRay","WEB-DL","WEBRip","HDRip","HC HD-Rip","DVD REMUX","DVDRip","HDTV","CAM","TS","TC","SCR","Unknown"],xp=[],xh=[],xx=[],xg=[],xf=b("w-full grid grid-cols-1 lg:grid lg:grid-cols-[300px,1fr] gap-4"),xb=b("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"),xv=b("w-full flex flex-wrap lg:flex-nowrap h-fit xl:h-10","lg:block p-2 lg:p-0"),xy=b("contents lg:block border-0 bg-transparent lg:border lg:bg-[--paper] overflow-clip p-1"),xj=b("space-y-4 animate-in fade-in-0 slide-in-from-right-2 duration-300");function xw(e){if(e<24)return`${e}h`;let t=Math.floor(e/24);return`${t}d`}function xN(e){let{heading:t}=e;return(0,r.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4 mb-4",children:[(0,r.jsx)("h3",{children:t}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(uw,{})})]})}let xk={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"},xS="aggressive";function xC(e){return`<SYNCED: ${e}>`}let x_={syncedPreferredRegexUrls:"preferredRegexPatterns",syncedExcludedRegexUrls:"excludedRegexPatterns",syncedIncludedRegexUrls:"includedRegexPatterns",syncedRequiredRegexUrls:"requiredRegexPatterns",syncedRankedRegexUrls:"rankedRegexPatterns",syncedPreferredStreamExpressionUrls:"preferredStreamExpressions",syncedExcludedStreamExpressionUrls:"excludedStreamExpressions",syncedIncludedStreamExpressionUrls:"includedStreamExpressions",syncedRequiredStreamExpressionUrls:"requiredStreamExpressions",syncedRankedStreamExpressionUrls:"rankedStreamExpressions"};function xA(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 xR(){return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(r6,{className:"p-4 sm:p-8 space-y-4",children:(0,r.jsx)(xT,{})})})}function xT(){var e,t,s,a,l,i,o,d,c,u,m,p,h,g,f,b,v,y,j,N,k,S,C,_,A,R,T,I,M,D,$,O,U,F,z,V,q,B,K,H,W,G,Y,J,Z,Q,ee,et,es,ea,er,en,el,ei,eo,ed,ec,eu,em,ep,eh,ex,eg,ef,eb,ev,ey,ej,ew,eN,ek,eS,eC,e_,eA,eR,eT,eI,eE,eM,eP,eD,e$,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,tn,tl,ti,to,td,tc,tu,tm,tp,th,tx,tg,tf,tb,tv,ty,tj,tw,tN,tk,tS,tC,t_,tA,tR,tT,tI,tE,tM,tP,tD,t$,tL,tO,tU,tF,tz,tV,tq,tB,tK,tH;let{tab:tW,setTab:tG}=a9("filters"),{status:tY}=tr(),{mode:tZ}=sy(),{userData:tX,setUserData:t0}=aY(),{isInherited:t1,hasParent:t3}=aJ(),t5=tQ(!1),t4=tQ(!1),t6=tQ(!1),t9=e=>{let t=x_[e];return{syncConfig:{urls:tX[e]||[],trusted:tX.trusted,syncMode:e.includes("StreamExpression")?"sel":"regex",onUrlsChange:t=>{t0(s=>({...s,[e]:t}))},onInsertPlaceholder:t?e=>{let s=function(e,t){let s=xC(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);t0(e=>({...e,[t]:[...e[t]||[],s]}))}:void 0,onRemovePlaceholder:t?e=>{let s=xC(e);t0(e=>{let a=e[t];if(!Array.isArray(a))return e;let r=a.filter(e=>xA(t,e)!==s);return r.length===a.length?e:{...e,[t]:r}})}:void 0,hasPlaceholder:t?e=>{let s=xC(e),a=tX[t];return!!Array.isArray(a)&&a.some(e=>xA(t,e)===s)}:void 0}}};return(0,n.useEffect)(()=>{tX.preferredResolutions||t0(e=>({...e,preferredResolutions:xu})),tX.preferredQualities||t0(e=>({...e,preferredQualities:xm})),tX.preferredEncodes||t0(e=>({...e,preferredEncodes:xp})),tX.preferredStreamTypes||t0(e=>({...e,preferredStreamTypes:xh})),tX.preferredVisualTags||t0(e=>({...e,preferredVisualTags:xx})),tX.preferredAudioTags||t0(e=>({...e,preferredAudioTags:xg}))},[]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n_,{value:tW,onValueChange:e=>{tG(e)},variant:"pill",className:xf,triggerClass:xb,listClass:xv,contentClass:xj,children:[(0,r.jsx)(nA,{className:"flex-wrap max-w-full lg:space-y-2",children:(0,r.jsxs)(u4,{children:[(0,r.jsx)("div",{className:"w-full my-2",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 justify-center",children:[(0,r.jsx)("h4",{children:"Filters"}),t3&&t1("filters")&&(0,r.jsx)(uI,{section:"filters"})]})}),(0,r.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,r.jsxs)(X,{className:xy,children:[(0,r.jsxs)(nR,{value:"cache",children:[(0,r.jsx)(mu.lHQ,{className:"text-lg mr-3"}),"Cache"]}
43),"pro"===tZ&&(0,r.jsxs)(nR,{value:"stream-type",children:[(0,r.jsx)(ml.iDz,{className:"text-lg mr-3"}),"Stream Type"]}),(0,r.jsxs)(nR,{value:"seeders",children:[(0,r.jsx)(ml.LTk,{className:"text-lg mr-3"}),"Seeders"]}),(0,r.jsxs)(nR,{value:"age",children:[(0,r.jsx)(mu.w_X,{className:"text-lg mr-3"}),"Age"]})]}),(0,r.jsxs)(X,{className:xy,children:[(0,r.jsxs)(nR,{value:"resolution",children:[(0,r.jsx)(t2._U5,{className:"text-lg mr-3"}),"Resolution"]}),"pro"===tZ&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(nR,{value:"quality",children:[(0,r.jsx)(ml.KBW,{className:"text-lg mr-3"}),"Quality"]}),(0,r.jsxs)(nR,{value:"encode",children:[(0,r.jsx)(mu.UUG,{className:"text-lg mr-3"}),"Encode"]}),(0,r.jsxs)(nR,{value:"visual-tag",children:[(0,r.jsx)(ml.Xc1,{className:"text-lg mr-3"}),"Visual Tag"]}),(0,r.jsxs)(nR,{value:"audio-tag",children:[(0,r.jsx)(hY.YkV,{className:"text-lg mr-3"}),"Audio Tag"]}),(0,r.jsxs)(nR,{value:"audio-channel",children:[(0,r.jsx)(ml.pCc,{className:"text-lg mr-3"}),"Audio Channel"]})]})]}),(0,r.jsxs)(X,{className:xy,children:[(0,r.jsxs)(nR,{value:"language",children:[(0,r.jsx)(mu.gqt,{className:"text-lg mr-3"}),"Language"]}),(0,r.jsxs)(nR,{value:"subtitle",children:[(0,r.jsx)(ml.zZ_,{className:"text-lg mr-3"}),"Subtitle"]})]}),(0,r.jsxs)(X,{className:xy,children:[(0,r.jsxs)(nR,{value:"size",children:[(0,r.jsx)(hJ.mKD,{className:"text-lg mr-3"}),"Size"]}),(0,r.jsxs)(nR,{value:"bitrate",children:[(0,r.jsx)(mu.$BV,{className:"text-lg mr-3"}),"Bitrate"]})]}),"pro"===tZ&&(0,r.jsx)(X,{className:xy,children:(0,r.jsxs)(nR,{value:"matching",children:[(0,r.jsx)(mu.VsL,{className:"text-lg mr-3"}),"Matching"]})}),"pro"===tZ&&(0,r.jsxs)(X,{className:xy,children:[(0,r.jsxs)(nR,{value:"keyword",children:[(0,r.jsx)(ml.Gfv,{className:"text-lg mr-3"}),"Keyword"]}),(0,r.jsxs)(nR,{value:"release-group",children:[(0,r.jsx)(ut.Com,{className:"text-lg mr-3"}),"Release Group"]}),(0,r.jsxs)(nR,{value:"stream-expression",children:[(0,r.jsx)(mw.awR,{className:"text-lg mr-3"}),"Stream Expression"]}),((null==tY?void 0:tY.settings.regexAccess.level)!=="none"||((null==tY||null==(e=tY.settings.regexAccess.patterns)?void 0:e.length)??0)>0||((null==tY||null==(t=tY.settings.regexAccess.urls)?void 0:t.length)??0)>0)&&(0,r.jsxs)(nR,{value:"regex",children:[(0,r.jsx)(hY.zvj,{className:"text-lg mr-3"}),"Regex"]})]}),(0,r.jsxs)(X,{className:xy,children:[(0,r.jsxs)(nR,{value:"limit",children:[(0,r.jsx)(hJ.GJ9,{className:"text-lg mr-3"}),"Result Limits"]}),(0,r.jsxs)(nR,{value:"deduplicator",children:[(0,r.jsx)(ml.xbI,{className:"text-lg mr-3"}),"Deduplicator"]})]}),(0,r.jsx)(X,{className:xy,children:(0,r.jsxs)(nR,{value:"miscellaneous",children:[(0,r.jsx)(ml.y2g,{className:"text-lg mr-3"}),"Miscellaneous"]})})]})]})}),(0,r.jsxs)("div",{className:"space-y-0 relative",children:[(0,r.jsx)(nT,{id:"filter-tab-cache",value:"cache",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Cache"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(u6,{id:"excludeUncached",title:"Uncached",description:"Control the exclusion of uncached results",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(rZ,{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:tX.excludeUncached??!1,onValueChange:e=>{t0(t=>({...t,excludeUncached:e}))}}),"pro"===tZ&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(nJ,{help:"Addons selected here will have their uncached results excluded",label:"Exclude Uncached From Addons",value:tX.excludeUncachedFromAddons??[],onValueChange:e=>{t0(t=>({...t,excludeUncachedFromAddons:e}))},options:tX.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===tX.excludeUncached}),(0,r.jsx)(nJ,{help:"Services selected here will have their uncached results excluded",label:"Exclude Uncached From Services",value:tX.excludeUncachedFromServices??[],onValueChange:e=>{t0(t=>({...t,excludeUncachedFromServices:e}))},options:Object.values((null==tY?void 0:tY.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===tX.excludeUncached}),(0,r.jsx)(nJ,{help:"Stream types selected here will have their uncached results excluded",label:"Exclude Uncached From Stream Types",value:tX.excludeUncachedFromStreamTypes??[],onValueChange:e=>{t0(t=>({...t,excludeUncachedFromStreamTypes:e}))},options:am.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===tX.excludeUncached}),(0,r.jsx)(r0,{label:"Apply mode",disabled:!0===tX.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:tX.excludeUncachedMode??"or",onValueChange:e=>{t0(t=>({...t,excludeUncachedMode:e}))},options:[{label:"OR",value:"or"},{label:"AND",value:"and"}]})]})]})}),(0,r.jsx)(u6,{id:"excludeCached",title:"Cached",description:"Control the exclusion of cached results",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(rZ,{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:tX.excludeCached??!1,onValueChange:e=>{t0(t=>({...t,excludeCached:e}))}}),"pro"===tZ&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(nJ,{help:"Addons selected here will have their cached results excluded",label:"Exclude Cached From Addons",value:tX.excludeCachedFromAddons??[],onValueChange:e=>{t0(t=>({...t,excludeCachedFromAddons:e}))},options:tX.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===tX.excludeCached}),(0,r.jsx)(nJ,{help:"Services selected here will have their cached results excluded",label:"Exclude Cached From Services",value:tX.excludeCachedFromServices??[],onValueChange:e=>{t0(t=>({...t,excludeCachedFromServices:e}))},options:Object.values((null==tY?void 0:tY.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===tX.excludeCached}),(0,r.jsx)(nJ,{help:"Stream types selected here will have their cached results excluded",label:"Exclude Cached From Stream Types",value:tX.excludeCachedFromStreamTypes??[],onValueChange:e=>{t0(t=>({...t,excludeCachedFromStreamTypes:e}))},options:am.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===tX.excludeCached}),(0,r.jsx)(r0,{label:"Apply mode",disabled:!0===tX.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:tX.excludeCachedMode??"or",onValueChange:e=>{t0(t=>({...t,excludeCachedMode:e}))},options:[{label:"OR",value:"or"},{label:"AND",value:"and"}]})]})]})})]})]})}),(0,r.jsx)(nT,{id:"filter-tab-resolution",value:"resolution",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Resolution"}),(0,r.jsx)(h0,{filterName:"Resolutions",preferredOptions:tX.preferredResolutions||xu,requiredOptions:tX.requiredResolutions||[],excludedOptions:tX.excludedResolutions||[],includedOptions:tX.includedResolutions||[],onPreferredChange:e=>t0(t=>({...t,preferredResolutions:e})),onRequiredChange:e=>t0(t=>({...t,requiredResolutions:e})),onExcludedChange:e=>t0(t=>({...t,excludedResolutions:e})),onIncludedChange:e=>t0(t=>({...t,includedResolutions:e})),options:ar.map(e=>({name:e,value:e}))})]})}
43),(0,r.jsx)(nT,{id:"filter-tab-quality",value:"quality",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Quality"}),(0,r.jsx)(h0,{filterName:"Qualities",preferredOptions:tX.preferredQualities||xm,requiredOptions:tX.requiredQualities||[],excludedOptions:tX.excludedQualities||[],includedOptions:tX.includedQualities||[],onPreferredChange:e=>t0(t=>({...t,preferredQualities:e})),onRequiredChange:e=>t0(t=>({...t,requiredQualities:e})),onExcludedChange:e=>t0(t=>({...t,excludedQualities:e})),onIncludedChange:e=>t0(t=>({...t,includedQualities:e})),options:an.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(nT,{id:"filter-tab-encode",value:"encode",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Encode"}),(0,r.jsx)(h0,{filterName:"Encodes",preferredOptions:tX.preferredEncodes||xp,requiredOptions:tX.requiredEncodes||[],excludedOptions:tX.excludedEncodes||[],includedOptions:tX.includedEncodes||[],onPreferredChange:e=>t0(t=>({...t,preferredEncodes:e})),onRequiredChange:e=>t0(t=>({...t,requiredEncodes:e})),onExcludedChange:e=>t0(t=>({...t,excludedEncodes:e})),onIncludedChange:e=>t0(t=>({...t,includedEncodes:e})),options:ad.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(nT,{id:"filter-tab-stream-type",value:"stream-type",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Stream Type"}),(0,r.jsx)(h0,{filterName:"Stream Types",preferredOptions:tX.preferredStreamTypes||xh,requiredOptions:tX.requiredStreamTypes||[],excludedOptions:tX.excludedStreamTypes||[],includedOptions:tX.includedStreamTypes||[],onPreferredChange:e=>t0(t=>({...t,preferredStreamTypes:e})),onRequiredChange:e=>t0(t=>({...t,requiredStreamTypes:e})),onExcludedChange:e=>t0(t=>({...t,excludedStreamTypes:e})),onIncludedChange:e=>t0(t=>({...t,includedStreamTypes:e})),options:am.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(nT,{id:"filter-tab-visual-tag",value:"visual-tag",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Visual Tag"}),(0,r.jsx)(h0,{filterName:"Visual Tags",preferredOptions:tX.preferredVisualTags||xx,requiredOptions:tX.requiredVisualTags||[],excludedOptions:tX.excludedVisualTags||[],includedOptions:tX.includedVisualTags||[],onPreferredChange:e=>t0(t=>({...t,preferredVisualTags:e})),onRequiredChange:e=>t0(t=>({...t,requiredVisualTags:e})),onExcludedChange:e=>t0(t=>({...t,excludedVisualTags:e})),onIncludedChange:e=>t0(t=>({...t,includedVisualTags:e})),options:al.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(nT,{id:"filter-tab-audio-tag",value:"audio-tag",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Audio Tag"}),(0,r.jsx)(h0,{filterName:"Audio Tags",preferredOptions:tX.preferredAudioTags||[],requiredOptions:tX.requiredAudioTags||[],excludedOptions:tX.excludedAudioTags||[],includedOptions:tX.includedAudioTags||[],onPreferredChange:e=>t0(t=>({...t,preferredAudioTags:e})),onRequiredChange:e=>t0(t=>({...t,requiredAudioTags:e})),onExcludedChange:e=>t0(t=>({...t,excludedAudioTags:e})),onIncludedChange:e=>t0(t=>({...t,includedAudioTags:e})),options:ai.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(nT,{id:"filter-tab-audio-channel",value:"audio-channel",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Audio Channel"}),(0,r.jsx)(h0,{filterName:"Audio Channels",preferredOptions:tX.preferredAudioChannels||[],requiredOptions:tX.requiredAudioChannels||[],excludedOptions:tX.excludedAudioChannels||[],includedOptions:tX.includedAudioChannels||[],onPreferredChange:e=>t0(t=>({...t,preferredAudioChannels:e})),onRequiredChange:e=>t0(t=>({...t,requiredAudioChannels:e})),onExcludedChange:e=>t0(t=>({...t,excludedAudioChannels:e})),onIncludedChange:e=>t0(t=>({...t,includedAudioChannels:e})),options:ao.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(nT,{id:"filter-tab-language",value:"language",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Language"}),(0,r.jsx)(h0,{filterName:"Languages",preferredOptions:tX.preferredLanguages||[],requiredOptions:tX.requiredLanguages||[],excludedOptions:tX.excludedLanguages||[],includedOptions:tX.includedLanguages||[],onPreferredChange:e=>t0(t=>({...t,preferredLanguages:e})),onRequiredChange:e=>t0(t=>({...t,requiredLanguages:e})),onExcludedChange:e=>t0(t=>({...t,excludedLanguages:e})),onIncludedChange:e=>t0(t=>({...t,includedLanguages:e})),options:ay.map(e=>({name:e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),value:e}))})]})}),(0,r.jsx)(nT,{id:"filter-tab-subtitle",value:"subtitle",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Subtitle"}),(0,r.jsx)(lN,{intent:"warning",title:"Difference between Language and Subtitle filters",description:(0,r.jsxs)("div",{className:"text-sm",children:["Languages and subtitles behave differently depending on what information is available for a stream.",(0,r.jsx)("br",{}),(0,r.jsx)("br",{}),(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:["When accurate media info is available",(0,r.jsx)(L,{className:"text-sm ",trigger:(0,r.jsx)(P.ExT,{className:"transition-opacity opacity-45 hover:opacity-90 inline-block cursor-pointer"}),children:(0,r.jsxs)("div",{className:"max-w-sm",children:[(0,r.jsx)("div",{className:"font-medium",children:"Accurate media info is available for:"}),(0,r.jsxs)("ul",{className:"list-disc list-inside mt-2 space-y-1 text-xs",children:[(0,r.jsx)("li",{children:"Certain results from built-in or service-wrapped addons"}),(0,r.jsx)("li",{children:"Certain results from StremThru Torz/Store and Meteor"}),(0,r.jsx)("li",{children:"Torznab/Newznab results from indexers that provide separate audio/subtitle metadata"}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"nekoBT"})," results (all results have accurate audio/subtitle info)"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Torrentio"})," anime results (subtitles field may be populated)"]})]})]})})]}),", ",(0,r.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"languages"})," ","contains audio track languages and"," ",(0,r.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"subtitles"})," ","contains embedded subtitle languages.",(0,r.jsx)("br",{}),(0,r.jsx)("br",{}),"In all other cases,"," ",(0,r.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"subtitles"}
43)," ","is empty and"," ",(0,r.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,r.jsx)(h0,{filterName:"Subtitles",preferredOptions:tX.preferredSubtitles||[],requiredOptions:tX.requiredSubtitles||[],excludedOptions:tX.excludedSubtitles||[],includedOptions:tX.includedSubtitles||[],onPreferredChange:e=>t0(t=>({...t,preferredSubtitles:e})),onRequiredChange:e=>t0(t=>({...t,requiredSubtitles:e})),onExcludedChange:e=>t0(t=>({...t,excludedSubtitles:e})),onIncludedChange:e=>t0(t=>({...t,includedSubtitles:e})),options:ay.map(e=>({name:e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),value:e}))})]})}),(0,r.jsx)(nT,{id:"filter-tab-seeders",value:"seeders",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Seeders"}),(0,r.jsx)(u6,{title:"Seeder Filters",description:"Configure required, excluded, and included seeder ranges",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(hX,{min:0,max:1e3,defaultValue:[0,1e3],value:tX.requiredSeederRange||[0,1e3],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t0(t=>({...t,requiredSeederRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Required Seeder Range",help:"Streams with seeders outside this range will be excluded"}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:(null==(s=tX.requiredSeederRange)?void 0:s[0])||0}),(0,r.jsx)("span",{children:(null==(a=tX.requiredSeederRange)?void 0:a[1])||1e3})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(n1,{label:"Min",value:(null==(l=tX.requiredSeederRange)?void 0:l[0])||0,min:0,max:(null==(i=tX.requiredSeederRange)?void 0:i[1])||1e3,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,requiredSeederRange:[e,(null==(s=t.requiredSeederRange)?void 0:s[1])||1e3]}})}),(0,r.jsx)(n1,{label:"Max",value:(null==(o=tX.requiredSeederRange)?void 0:o[1])||1e3,min:(null==(d=tX.requiredSeederRange)?void 0:d[0])||0,max:1e3,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,requiredSeederRange:[(null==(s=t.requiredSeederRange)?void 0:s[0])||0,e]}})})]})]}),"pro"===tZ&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(hX,{min:0,max:1e3,defaultValue:[0,1e3],value:tX.excludeSeederRange||[0,1e3],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t0(t=>({...t,excludeSeederRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Excluded Seeder Range",help:"Streams with seeders in this range will be excluded"}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:(null==(c=tX.excludeSeederRange)?void 0:c[0])||0}),(0,r.jsx)("span",{children:(null==(u=tX.excludeSeederRange)?void 0:u[1])||1e3})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(n1,{label:"Min",value:(null==(m=tX.excludeSeederRange)?void 0:m[0])||0,min:0,max:(null==(p=tX.excludeSeederRange)?void 0:p[1])||1e3,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,excludeSeederRange:[e,(null==(s=t.excludeSeederRange)?void 0:s[1])||1e3]}})}),(0,r.jsx)(n1,{label:"Max",value:(null==(h=tX.excludeSeederRange)?void 0:h[1])||1e3,min:(null==(g=tX.excludeSeederRange)?void 0:g[0])||0,max:1e3,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,excludeSeederRange:[(null==(s=t.excludeSeederRange)?void 0:s[0])||0,e]}})})]})]})}),"pro"===tZ&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(hX,{min:0,max:1e3,defaultValue:[0,1e3],value:tX.includeSeederRange||[0,1e3],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t0(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,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:(null==(f=tX.includeSeederRange)?void 0:f[0])||0}),(0,r.jsx)("span",{children:(null==(b=tX.includeSeederRange)?void 0:b[1])||1e3})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(n1,{label:"Min",value:(null==(v=tX.includeSeederRange)?void 0:v[0])||0,min:0,max:(null==(y=tX.includeSeederRange)?void 0:y[1])||1e3,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,includeSeederRange:[e,(null==(s=t.includeSeederRange)?void 0:s[1])||1e3]}})}),(0,r.jsx)(n1,{label:"Max",value:(null==(j=tX.includeSeederRange)?void 0:j[1])||1e3,min:(null==(N=tX.includeSeederRange)?void 0:N[0])||0,max:1e3,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,includeSeederRange:[(null==(s=t.includeSeederRange)?void 0:s[0])||0,e]}})})]})]})})]}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)(nJ,{label:"Stream Types",emptyMessage:"There aren't any stream types to choose from...",options:["p2p","cached","uncached"].map(e=>({label:e,value:e})),value:tX.seederRangeTypes||[],onValueChange:e=>{t0(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,r.jsx)(nT,{id:"filter-tab-age",value:"age",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Age"}),(0,r.jsx)(u6,{title:"Age Filters",description:"Configure required, excluded, and included age ranges (in hours since upload)",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(hX,{min:0,max:155520,step:24,defaultValue:[0,155520],value:tX.requiredAgeRange||[0,155520],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t0(t=>({...t,requiredAgeRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Required Age Range",help:"Streams with age outside this range will be excluded"}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:xw((null==(k=tX.requiredAgeRange)?void 0:k[0])||0)}),(0,r.jsx)("span",{children:xw((null==(S=tX.requiredAgeRange)?void 0:S[1])||155520)})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(n1,{label:"Min",step:24,value:(null==(C=tX.requiredAgeRange)?void 0:C[0])||0,min:0,max:(null==(_=tX.requiredAgeRange)?void 0:_[1])||155520,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,requiredAgeRange:[e,(null==(s=t.requiredAgeRange)?void 0:s[1])||155520]}})}),(0,r.jsx)(n1,{label:"Max",step:24,value:(null==(A=tX.requiredAgeRange)?void 0:A[1])||155520,min:(null==(R=tX.requiredAgeRange)?void 0:R[0])||0,max:155520,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,requiredAgeRange:[(null==(s=t.requiredAgeRange)?void 0:s[0])||0,e]}})})]})]}),"pro"===tZ&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(hX,{min:0,max:155520,step:24,defaultValue:[0,155520],value:tX.excludeAgeRange||[0,155520],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t0(t=>({...t,excludeAgeRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Excluded Age Range",help:"Streams with age in this range will be excluded"}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:xw((null==(T=tX.excludeAgeRange)?void 0:T[0])||0)}),(0,r.jsx)("span",{children:xw((null==(I=tX.excludeAgeRange)?void 0:I[1])||155520)})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(n1,{label:"Min",step:24,value:(null==(M=tX.excludeAgeRange)?void 0:M[0])||0,min:0,max:(null==(D=tX.excludeAgeRange)?void 0:D[1])||155520,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,excludeAgeRange:[e,(null==(s=t.excludeAgeRange)?void 0:s[1])||155520]}})}),(0,r.jsx)(n1,{label:"Max",step:24,value:(null==($=tX.excludeAgeRange)?void 0:$[1])||155520,min:(null==(O=tX.excludeAgeRange)?void 0:O[0])||0,max:155520,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,excludeAgeRange:[(null==(s=t.excludeAgeRange)?void 0:s[0])||0,e]}})})]})]}),(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(hX,{min:0,max:155520,step:24,defaultValue:[0,155520],value:tX.includeAgeRange||[0,155520],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t0(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,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:xw((null==(U=tX.includeAgeRange)?void 0:U[0])||0)}),(0,r.jsx)("span",{children:xw((null==(F=tX.includeAgeRange)?void 0:F[1])||155520)})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(n1,{label:"Min",step:24,value:(null==(z=tX.includeAgeRange)?void 0:z[0])||0,min:0,max:(null==(V=tX.includeAgeRange)?void 0:V[1])||155520,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,includeAgeRange:[e,(null==(s=t.includeAgeRange)?void 0:s[1])||155520]}})}),(0,r.jsx)(n1,{label:"Max",step:24,value:(null==(q=tX.includeAgeRange)?void 0:q[1])||155520,min:(null==(B=tX.includeAgeRange)?void 0:B[0])||0,max:155520,onValueChange:e=>void 0!==e&&t0(t=>{var s;return{...t,includeAgeRange:[(null==(s=t.includeAgeRange)?void 0:s[0])||0,e]}})})]})]})]})]}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)(nJ,{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:tX.ageRangeTypes||["usenet"],onValueChange:e=>{t0(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,r.jsx)(nT,{id:"filter-tab-matching",value:"matching",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Matching"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(u6,{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,r.jsx)(rZ,{label:"Enabled",side:"right",value:(null==(K=tX.titleMatching)?void 0:K.enabled)??!1,onValueChange:e=>{t0(t=>({...t,titleMatching:{...t.titleMatching||{},enabled:e}}))}}),(0,r.jsx)(r0,{disabled:!(null==(H=tX.titleMatching)?void 0:H.enabled),label:"Matching Mode",options:["exact","contains"].map(e=>({label:e,value:e})),defaultValue:"exact",value:null==(W=tX.titleMatching)?void 0:W.mode,help:(null==(G=tX.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=>{t0(t=>({...t,titleMatching:{...t.titleMatching,mode:e}}))}}),(0,r.jsx)(r0,{disabled:!(null==(Y=tX.titleMatching)?void 0:Y.enabled),label:"Ambiguous Results",options:[{label:"keep",value:"keep"},{label:"discard",value:"discard"}],defaultValue:"keep",value:null==(J=tX.titleMatching)?void 0:J.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=>{t0(t=>({...t,titleMatching:{...t.titleMatching,ambiguousResults:e}}))}}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(hX,{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==(Z=tX.titleMatching)?void 0:Z.enabled),value:[(null==(Q=tX.titleMatching)?void 0:Q.similarityThreshold)??.85],min:0,max:1,step:.
4301,defaultValue:[.85],onValueChange:e=>{t0(t=>({...t,titleMatching:{...t.titleMatching,similarityThreshold:e[0]}}))}})}),(0,r.jsx)("div",{className:"w-24",children:(0,r.jsx)(n1,{label:"Value",step:.01,value:(null==(ee=tX.titleMatching)?void 0:ee.similarityThreshold)??.85,min:0,max:1,disabled:!(null==(et=tX.titleMatching)?void 0:et.enabled),onValueChange:e=>{void 0!==e&&t0(t=>({...t,titleMatching:{...t.titleMatching,similarityThreshold:e}}))}})})]}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(es=tX.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:af.map(e=>({label:e,value:e,textValue:e})),value:null==(ea=tX.titleMatching)?void 0:ea.requestTypes,onValueChange:e=>{t0(t=>({...t,titleMatching:{...t.titleMatching,requestTypes:e}}))}}),(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(er=tX.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:tX.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(en=tX.titleMatching)?void 0:en.addons)||[],onValueChange:e=>{t0(t=>({...t,titleMatching:{...t.titleMatching,addons:e}}))}})]})})]}),(0,r.jsxs)(u6,{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,r.jsx)(rZ,{label:"Enable",side:"right",value:(null==(el=tX.yearMatching)?void 0:el.enabled)??!1,onValueChange:e=>{t0(t=>({...t,yearMatching:{...t.yearMatching,enabled:e}}))}}),(0,r.jsx)(rZ,{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=tX.yearMatching)?void 0:ei.enabled),value:(null==(eo=tX.yearMatching)?void 0:eo.strict)??!0,onValueChange:e=>{t0(t=>({...t,yearMatching:{...t.yearMatching,strict:e}}))}}),(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(ed=tX.yearMatching)?void 0:ed.enabled)||(null==(ec=tX.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:af.map(e=>({label:e,value:e,textValue:e})),value:(null==(eu=tX.yearMatching)?void 0:eu.strictTypes)??["movie"],onValueChange:e=>{t0(t=>({...t,yearMatching:{...t.yearMatching,strictTypes:e}}))}}),(0,r.jsx)(rZ,{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=tX.yearMatching)?void 0:em.enabled),value:(null==(ep=tX.yearMatching)?void 0:ep.useInitialAirDate)??!1,onValueChange:e=>{t0(t=>({...t,yearMatching:{...t.yearMatching,useInitialAirDate:e}}))}}),(0,r.jsx)(n1,{label:"Year Tolerance",disabled:!(null==(eh=tX.yearMatching)?void 0:eh.enabled),value:(null==(ex=tX.yearMatching)?void 0:ex.tolerance)??1,onValueChange:e=>{t0(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,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(eg=tX.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:af.map(e=>({label:e,value:e,textValue:e})),value:null==(ef=tX.yearMatching)?void 0:ef.requestTypes,onValueChange:e=>{t0(t=>({...t,yearMatching:{...t.yearMatching,requestTypes:e}}))}}),(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(eb=tX.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:tX.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(ev=tX.yearMatching)?void 0:ev.addons)||[],onValueChange:e=>{t0(t=>({...t,yearMatching:{...t.yearMatching,addons:e}}))}})]})})]}),(0,r.jsxs)(u6,{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,r.jsx)(rZ,{label:"Enabled",side:"right",value:(null==(ey=tX.seasonEpisodeMatching)?void 0:ey.enabled)??!1,onValueChange:e=>{t0(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching||{},enabled:e}}))}}
43),(0,r.jsx)(rZ,{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=tX.seasonEpisodeMatching)?void 0:ej.enabled),value:(null==(ew=tX.seasonEpisodeMatching)?void 0:ew.strict)??!1,onValueChange:e=>{t0(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching,strict:e}}))}}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(eN=tX.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:af.map(e=>({label:e,value:e,textValue:e})),value:null==(ek=tX.seasonEpisodeMatching)?void 0:ek.requestTypes,onValueChange:e=>{t0(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching,requestTypes:e}}))}}),(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(eS=tX.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:tX.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(eC=tX.seasonEpisodeMatching)?void 0:eC.addons)||[],onValueChange:e=>{t0(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching,addons:e}}))}})]})})]}),(0,r.jsxs)(u6,{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,r.jsx)(rZ,{label:"Enabled",side:"right",value:(null==(e_=tX.episodeTitleMatching)?void 0:e_.enabled)??!1,onValueChange:e=>{t0(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching||{},enabled:e}}))}}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(hX,{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=tX.episodeTitleMatching)?void 0:eA.enabled),value:[(null==(eR=tX.episodeTitleMatching)?void 0:eR.similarityThreshold)??.8],min:0,max:1,step:.01,defaultValue:[.8],onValueChange:e=>{t0(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,similarityThreshold:e[0]}}))}})}),(0,r.jsx)("div",{className:"w-24",children:(0,r.jsx)(n1,{label:"Value",step:.01,value:(null==(eT=tX.episodeTitleMatching)?void 0:eT.similarityThreshold)??.8,min:0,max:1,disabled:!(null==(eI=tX.episodeTitleMatching)?void 0:eI.enabled),onValueChange:e=>{void 0!==e&&t0(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,similarityThreshold:e}}))}})})]}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(eE=tX.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:af.map(e=>({label:e,value:e,textValue:e})),value:null==(eM=tX.episodeTitleMatching)?void 0:eM.requestTypes,onValueChange:e=>{t0(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,requestTypes:e}}))}}),(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(eP=tX.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:tX.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(eD=tX.episodeTitleMatching)?void 0:eD.addons)||[],onValueChange:e=>{t0(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,addons:e}}))}})]})})]}),(0,r.jsxs)(u6,{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,r.jsx)(rZ,{label:"Enabled",side:"right",value:(null==(e$=tX.languageInference)?void 0:e$.enabled)??!0,onValueChange:e=>{t0(t=>({...t,languageInference:{...t.languageInference||{},enabled:e}}))}}),(0,r.jsx)(nJ,{multiple:!0,disabled:(null==(eL=tX.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=tX.languageInference)?void 0:eO.sources)||[],onValueChange:e=>{t0(t=>({...t,languageInference:{...t.languageInference,sources:e}}))}})]})]})]})}),(0,r.jsx)(nT,{id:"filter-tab-stream-expression",value:"stream-expression",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Stream Expression"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.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,r.jsx)("div",{className:"mb-4 space-y-4",children:(null==tY?void 0:tY.settings.selSyncAccess.level)==="trusted"&&(tX.trusted?(0,r.jsx)(lN,{intent:"success",title:"Trusted User",description:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{children:"You are a trusted user. You can sync expressions from any URL."}),(null==tY?void 0:tY.settings.selSyncAccess.trustedUrls)&&tY.settings.selSyncAccess.trustedUrls.length>0&&(0,r.jsx)("div",{className:"flex flex-row flex-wrap gap-2",children:(0,r.jsx)(w,{intent:"primary-outline",size:"sm",onClick:t6.open,children:"View Whitelisted Sync URLs"})})]})}):(0,r.jsx)(lN,{intent:"info",title:"Trusted Users Only",description:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.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,r.jsx)("code",{className:"font-mono",children:"TRUSTED_UUIDS"})," ","environment variable."]}),(null==tY?void 0:tY.settings.selSyncAccess.trustedUrls)&&tY.settings.selSyncAccess.trustedUrls.length>0&&(0,r.jsx)("div",{className:"flex flex-row flex-wrap gap-2",children:(0,r.jsx)(w,{intent:"primary-outline",size:"sm",onClick:t6.open,children:"View Whitelisted Sync URLs"})})]})}))}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(u6,{title:"Help",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["This filter uses AIOStreams'"," ",(0,r.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,r.jsx)("code",{children:"streams"})," constant containing all available streams"]}),(0,r.jsxs)("div",{className:"text-sm text-[--muted]",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:"How it works:"}),(0,r.jsxs)("ul",{className:"list-disc list-inside space-y-1 ml-2",children:[(0,r.jsx)("li",{children:"Your expression should return an array of streams"}),(0,r.jsxs)("li",{children:["Use functions like ",(0,r.jsx)("code",{children:"addon()"}),","," ",(0,r.jsx)("code",{children:"type()"}),", ",(0,r.jsx)("code",{children:"quality()"})," to filter streams"]}),(0,r.jsx)("li",{children:"Combine multiple attributes together using nested functions"}),(0,r.jsxs)("li",{children:["Apply conditional logic using ternary operators"," ",(0,r.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,r.jsxs)("p",{className:"text-sm text-[--muted]",children:[(0,r.jsx)("strong",{children:"Example:"})," ",(0,r.jsx)("code",{children:"addon(type(streams, 'debrid'), 'TorBox')"})," ","excludes all TorBox debrid streams."]}),(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["For detailed syntax and available functions, see the"," ",(0,r.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,r.jsx)(xa,{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:tX.requiredStreamExpressions||[],onValuesChange:e=>{t0(t=>({...t,requiredStreamExpressions:e}))},onExpressionChange:(e,t)=>
43{t0(s=>({...s,requiredStreamExpressions:[...(s.requiredStreamExpressions||[]).slice(0,t),{...(s.requiredStreamExpressions||[])[t],expression:e},...(s.requiredStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t0(s=>({...s,requiredStreamExpressions:[...(s.requiredStreamExpressions||[]).slice(0,t),{...(s.requiredStreamExpressions||[])[t],enabled:e},...(s.requiredStreamExpressions||[]).slice(t+1)]}))},...t9("syncedRequiredStreamExpressionUrls")}),(0,r.jsx)(xa,{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:tX.excludedStreamExpressions||[],onValuesChange:e=>{t0(t=>({...t,excludedStreamExpressions:e}))},onExpressionChange:(e,t)=>{t0(s=>({...s,excludedStreamExpressions:[...(s.excludedStreamExpressions||[]).slice(0,t),{...(s.excludedStreamExpressions||[])[t],expression:e},...(s.excludedStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>
43{t0(s=>({...s,excludedStreamExpressions:[...(s.excludedStreamExpressions||[]).slice(0,t),{...(s.excludedStreamExpressions||[])[t],enabled:e},...(s.excludedStreamExpressions||[]).slice(t+1)]}))},...t9("syncedExcludedStreamExpressionUrls")}),(0,r.jsx)(xa,{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:tX.includedStreamExpressions||[],onValuesChange:e=>{t0(t=>({...t,includedStreamExpressions:e}))},onExpressionChange:(e,t)=>{t0(s=>({...s,includedStreamExpressions:[...(s.includedStreamExpressions||[]).slice(0,t),{...(s.includedStreamExpressions||[])[t],expression:e},...(s.includedStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t0(s=>({...s,includedStreamExpressions:[...(s.includedStreamExpressions||[]).slice(0,t),{...(s.includedStreamExpressions||[])[t],enabled:e},...(s.includedStreamExpressions||[]).slice(t+1)]}))},...t9("syncedIncludedStreamExpressionUrls")}),(0,r.jsx)(xa,{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:tX.preferredStreamExpressions||[],onValuesChange:e=>{t0(t=>({...t,preferredStreamExpressions:e}))},onExpressionChange:(e,t)=>
43{t0(s=>({...s,preferredStreamExpressions:[...(s.preferredStreamExpressions||[]).slice(0,t),{...(s.preferredStreamExpressions||[])[t],expression:e},...(s.preferredStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t0(s=>({...s,preferredStreamExpressions:[...(s.preferredStreamExpressions||[]).slice(0,t),{...(s.preferredStreamExpressions||[])[t],enabled:e},...(s.preferredStreamExpressions||[]).slice(t+1)]}))},...t9("syncedPreferredStreamExpressionUrls")}),(0,r.jsx)(xn,{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:tX.rankedStreamExpressions||[],onValuesChange:e=>{t0(t=>({...t,rankedStreamExpressions:e}))},onExpressionChange:(e,t)=>{t0(s=>({...s,rankedStreamExpressions:[...(s.rankedStreamExpressions||[]).slice(0,t),{...(s.rankedStreamExpressions||[])[t],expression:e},...(s.rankedStreamExpressions||[]).slice(t+1)]}))},onScoreChange:(e,t)=>
43{t0(s=>({...s,rankedStreamExpressions:[...(s.rankedStreamExpressions||[]).slice(0,t),{...(s.rankedStreamExpressions||[])[t],score:e},...(s.rankedStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t0(s=>({...s,rankedStreamExpressions:[...(s.rankedStreamExpressions||[]).slice(0,t),{...(s.rankedStreamExpressions||[])[t],enabled:e},...(s.rankedStreamExpressions||[]).slice(t+1)]}))},...t9("syncedRankedStreamExpressionUrls")})]})]})}),(0,r.jsx)(nT,{id:"filter-tab-keyword",value:"keyword",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Keyword"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.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,r.jsxs)("div",{className:"space-y-4",children:["pro"===tZ&&(0,r.jsx)(xs,{label:"Required Keywords",help:"Streams that do not contain any of these keywords will be excluded",itemName:"Keyword",values:tX.requiredKeywords||[],onValuesChange:e=>{t0(t=>({...t,requiredKeywords:e}))}}),(0,r.jsx)(xs,{label:"Excluded Keywords",help:"Streams that contain any of these keywords will be excluded",itemName:"Keyword",values:tX.excludedKeywords||[],onValuesChange:e=>{t0(t=>({...t,excludedKeywords:e}))}}),"pro"===tZ&&(0,r.jsx)(xs,{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:tX.includedKeywords||[],onValuesChange:e=>{t0(t=>({...t,includedKeywords:e}))}}),(0,r.jsx)(xs,{label:"Preferred Keywords",help:"Streams that contain any of these keywords will be preferred",itemName:"Keyword",values:tX.preferredKeywords||[],onValuesChange:e=>{t0(t=>({...t,preferredKeywords:e}))}})]})]})}),(0,r.jsx)(nT,{id:"filter-tab-release-group",value:"release-group",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Release Group"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.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,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(xs,{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:tX.requiredReleaseGroups||[],onValuesChange:e=>{t0(t=>({...t,requiredReleaseGroups:e}))}}),(0,r.jsx)(xs,{label:"Excluded Release Groups",help:"Streams from these release groups will be excluded",itemName:"Release Group",values:tX.excludedReleaseGroups||[],onValuesChange:e=>{t0(t=>({...t,excludedReleaseGroups:e}))}}),(0,r.jsx)(xs,{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:tX.includedReleaseGroups||[],onValuesChange:e=>{t0(t=>({...t,includedReleaseGroups:e}))}}),(0,r.jsx)(xs,{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:tX.preferredReleaseGroups||[],onValuesChange:e=>{t0(t=>({...t,preferredReleaseGroups:e}))}})]})]})}),(0,r.jsx)(nT,{id:"filter-tab-regex",value:"regex",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Regex"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.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,r.jsxs)("div",{className:"mb-4 space-y-4",children:[(null==tY?void 0:tY.settings.regexAccess.level)==="trusted"&&(tX.trusted?(0,r.jsx)(lN,{intent:"success",title:"Trusted User",description:(0,r.jsx)("p",{children:"You are a trusted user. You have full access to regex filters."})}):(0,r.jsx)(lN,{intent:"info",title:"Trusted Users Only",description:(0,r.jsx)(r.Fragment,{children:(0,r.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,r.jsx)("code",{className:"font-mono",children:"TRUSTED_UUIDS"})," ","environment variable."]})})})),((null==tY||null==(eU=tY.settings.regexAccess.patterns)?void 0:eU.length)||(null==tY||null==(eF=tY.settings.regexAccess.urls)?void 0:eF.length))&&(0,r.jsx)(lN,{intent:"info",title:"Allowed Regex Patterns",description:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"max-w-full overflow-hidden",children:[(0,r.jsx)("p",{className:"break-words",children:"This instance has allowed a specific set of regexes to be used by all users."}),(null==tY?void 0:tY.settings.regexAccess.description)&&(0,r.jsx)("div",{className:"mt-2 break-words overflow-hidden",children:(0,r.jsx)(l_,{children:(null==tY?void 0:tY.settings.regexAccess.description)||""})})]}),(0,r.jsxs)("div",{className:"flex flex-row flex-wrap gap-2",children:[(null==tY?void 0:tY.settings.regexAccess.urls)&&tY.settings.regexAccess.urls.length>0&&(0,r.jsx)(w,{intent:"primary-outline",size:"sm",onClick:t4.open,children:"View Allowed Import URLs"}),(0,r.jsx)(w,{intent:"primary-outline",size:"sm",onClick:t5.open,children:"View Allowed Patterns"})]})]})})]}),(0,r.jsxs)("div",{className:"space-y-4",children:["pro"===tZ&&(0,r.jsx)(xs,{fieldName:"requiredRegexPatterns",label:"Required Regex",help:"Streams that do not match any of these regular expressions will be excluded",itemName:"Regex",values:tX.requiredRegexPatterns||[],onValuesChange:e=>{t0(t=>({...t,requiredRegexPatterns:e}))},...t9("syncedRequiredRegexUrls")}),(0,r.jsx)(xs,{label:"Excluded Regex",fieldName:"excludedRegexPatterns",help:"Streams that match any of these regular expressions will be excluded",itemName:"Regex",values:tX.excludedRegexPatterns||[],onValuesChange:e=>{t0(t=>({...t,excludedRegexPatterns:e}))},...t9("syncedExcludedRegexUrls")}),"pro"===tZ&&(0,r.jsx)(xs,{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:tX.includedRegexPatterns||[],onValuesChange:e=>{t0(t=>({...t,includedRegexPatterns:e}))},...t9("syncedIncludedRegexUrls")}),(0,r.jsx)(xr,{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:(tX.preferredRegexPatterns||[]).map(e=>({name:e.name,value:e.pattern}
43)),onValuesChange:e=>{t0(t=>({...t,preferredRegexPatterns:e.map(e=>({name:e.name,pattern:e.value}))}))},onValueChange:(e,t)=>{t0(s=>({...s,preferredRegexPatterns:[...(s.preferredRegexPatterns||[]).slice(0,t),{...(s.preferredRegexPatterns||[])[t],pattern:e},...(s.preferredRegexPatterns||[]).slice(t+1)]}))},onKeyChange:(e,t)=>{t0(s=>({...s,preferredRegexPatterns:[...(s.preferredRegexPatterns||[]).slice(0,t),{...(s.preferredRegexPatterns||[])[t],name:e},...(s.preferredRegexPatterns||[]).slice(t+1)]}))}}),(0,r.jsx)(xl,{title:"Ranked Regex Patterns",description:"Add regex patterns with scores. Matches on filename only. Accumulates scores.",values:tX.rankedRegexPatterns||[],onValuesChange:e=>{t0(t=>({...t,rankedRegexPatterns:e}))},onPatternChange:(e,t)=>{t0(s=>({...s,rankedRegexPatterns:[...(s.rankedRegexPatterns||[]).slice(0,t),{...(s.rankedRegexPatterns||[])[t],pattern:e},...(s.rankedRegexPatterns||[]).slice(t+1)]}))},onNameChange:(e,t)=>{t0(s=>({...s,rankedRegexPatterns:[...(s.rankedRegexPatterns||[]).slice(0,t),{...(s.rankedRegexPatterns||[])[t],name:e},...(s.rankedRegexPatterns||[]).slice(t+1)]}))},onScoreChange:(e,t)=>
43{t0(s=>({...s,rankedRegexPatterns:[...(s.rankedRegexPatterns||[]).slice(0,t),{...(s.rankedRegexPatterns||[])[t],score:e},...(s.rankedRegexPatterns||[]).slice(t+1)]}))},...t9("syncedRankedRegexUrls")})]})]})}),(0,r.jsx)(nT,{id:"filter-tab-bitrate",value:"bitrate",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Bitrate"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.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,r.jsx)(lN,{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,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"rounded-[--radius-md] border bg-[--background] p-4",children:(0,r.jsx)(rZ,{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=tX.bitrate)?void 0:ez.useMetadataRuntime)??!0,onValueChange:e=>{t0(t=>({...t,bitrate:{...t.bitrate,useMetadataRuntime:e}}))}})}),(0,r.jsx)(u6,{title:"Global",description:"Apply bitrate filters for movies, series, and anime series",children:(0,r.jsx)(xc,{label:"Global Bitrate Limits",help:"Set the minimum and maximum bitrate limits for all results",moviesValue:((null==(eq=tX.bitrate)||null==(eV=eq.global)?void 0:eV.movies)||[0,25e7]).map(e=>Math.min(e,25e7)),seriesValue:((null==(eK=tX.bitrate)||null==(eB=eK.global)?void 0:eB.series)||[0,25e7]).map(e=>Math.min(e,25e7)),animeValue:((null==(eW=tX.bitrate)||null==(eH=eW.global)?void 0:eH.anime)||[0,25e7]).map(e=>Math.min(e,25e7)),onMoviesChange:e=>{t0(t=>{var s;return{...t,bitrate:{...t.bitrate,global:{...null==(s=t.bitrate)?void 0:s.global,movies:e}}}})},onSeriesChange:e=>{t0(t=>{var s;return{...t,bitrate:{...t.bitrate,global:{...null==(s=t.bitrate)?void 0:s.global,series:e}}}})},onAnimeChange:e=>{t0(t=>{var s;return{...t,bitrate:{...t.bitrate,global:{...null==(s=t.bitrate)?void 0:s.global,anime:e}}}})}})}),"pro"===tZ&&(0,r.jsx)(u6,{title:"Resolution-Specific",description:"Set bitrate limits for specific resolutions",children:(0,r.jsx)("div",{className:"space-y-8",children:ar.map(e=>{var t,s,a,n,l,i,o,d,c;return(0,r.jsx)(xc,{label:e,help:`Set the minimum and maximum bitrate for ${e} results`,moviesValue:((null==(a=tX.bitrate)||null==(s=a.resolution)||null==(t=s[e])?void 0:t.movies)||[0,25e7]).map(e=>Math.min(e,25e7)),seriesValue:((null==(i=tX.bitrate)||null==(l=i.resolution)||null==(n=l[e])?void 0:n.series)||[0,25e7]).map(e=>Math.min(e,25e7)),animeValue:((null==(c=tX.bitrate)||null==(d=c.resolution)||null==(o=d[e])?void 0:o.anime)||[0,25e7]).map(e=>Math.min(e,25e7)),onMoviesChange:t=>{t0(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=>{t0(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=>{t0(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,r.jsx)(nT,{id:"filter-tab-size",value:"size",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Size"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.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,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(u6,{title:"Global",description:"Apply size filters for movies, series, and anime series",children:(0,r.jsx)(xd,{label:"Global Size Limits",help:"Set the minimum and maximum size limits for all results",moviesValue:(null==(eY=tX.size)||null==(eG=eY.global)?void 0:eG.movies)||[0,1e11],seriesValue:(null==(eZ=tX.size)||null==(eJ=eZ.global)?void 0:eJ.series)||[0,1e11],animeValue:(null==(eX=tX.size)||null==(eQ=eX.global)?void 0:eQ.anime)||[0,1e11],onMoviesChange:e=>{t0(t=>{var s;return{...t,size:{...t.size,global:{...null==(s=t.size)?void 0:s.global,movies:e}}}})},onSeriesChange:e=>{t0(t=>{var s;return{...t,size:{...t.size,global:{...null==(s=t.size)?void 0:s.global,series:e}}}})},onAnimeChange:e=>{t0(t=>{var s;return{...t,size:{...t.size,global:{...null==(s=t.size)?void 0:s.global,anime:e}}}})}})}),"pro"===tZ&&(0,r.jsx)(u6,{title:"Resolution-Specific",description:"Set size limits for specific resolutions",children:(0,r.jsx)("div",{className:"space-y-8",children:ar.map(e=>{var t,s,a,n,l,i,o,d,c;return(0,r.jsx)(xd,{label:e,help:`Set the minimum and maximum size for ${e} results`,moviesValue:(null==(a=tX.size)||null==(s=a.resolution)||null==(t=s[e])?void 0:t.movies)||[0,1e11],seriesValue:(null==(i=tX.size)||null==(l=i.resolution)||null==(n=l[e])?void 0:n.series)||[0,1e11],animeValue:(null==(c=tX.size)||null==(d=c.resolution)||null==(o=d[e])?void 0:o.anime)||[0,1e11],onMoviesChange:t=>{t0(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=>{t0(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=>{t0(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,r.jsx)(nT,{id:"filter-tab-limit",value:"limit",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Result Limits"}),(0,r.jsx)(u6,{description:"Apply limits to specific kinds of results",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(r0,{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=tX.resultLimits)?void 0:e0.mode)??"independent",onValueChange:e=>{t0(t=>({...t,resultLimits:{...t.resultLimits,mode:e}}))},options:[{label:"Independent",value:"independent"},{label:"Conjunctive",value:"conjunctive"}]}),(0,r.jsx)(n1,{help:"Global limit for all results",label:"Global Limit",value:(null==(e1=tX.resultLimits)?void 0:e1.global)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t0(t=>({...t,resultLimits:{...t.resultLimits,global:e||void 0}}))}}),"pro"===tZ&&(0,r.jsx)(n1,{help:"Limit for results by service",label:"Service Limit",value:(null==(e2=tX.resultLimits)?void 0:e2.service)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t0(t=>({...t,resultLimits:{...t.resultLimits,service:e||void 0}}))}}),"pro"===tZ&&(0,r.jsx)(n1,{help:"Limit for results by addon",label:"Addon Limit",value:(null==(e3=tX.resultLimits)?void 0:e3.addon)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t0(t=>({...t,resultLimits:{...t.resultLimits,addon:e||void 0}}))}}),(0,r.jsx)(n1,{help:"Limit for results by resolution",label:"Resolution Limit",value:(null==(e5=tX.resultLimits)?void 0:e5.resolution)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t0(t=>({...t,resultLimits:{...t.resultLimits,resolution:e||void 0}}))}}),"pro"===tZ&&(0,r.jsx)(n1,{help:"Limit for results by quality",label:"Quality Limit",value:(null==(e4=tX.resultLimits)?void 0:e4.quality)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t0(t=>({...t,resultLimits:{...t.resultLimits,quality:e||void 0}}))}}),"pro"===tZ&&(0,r.jsx)(n1,{help:"Limit for results by indexer",label:"Indexer Limit",value:(null==(e6=tX.resultLimits)?void 0:e6.indexer)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t0(t=>({...t,resultLimits:{...t.resultLimits,indexer:e||void 0}}))}}),"pro"===tZ&&(0,r.jsx)(n1,{help:"Limit for results by release group",label:"Release Group Limit",value:(null==(e9=tX.resultLimits)?void 0:e9.releaseGroup)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t0(t=>({...t,resultLimits:{...t.resultLimits,releaseGroup:e||void 0}}))}})]})})]})}),(0,r.jsx)(nT,{id:"filter-tab-deduplicator",value:"deduplicator",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Deduplicator"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Enable and customise the removal of duplicate results."})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(u6,{children:(0,r.jsx)(rZ,{label:"Enable",side:"right",value:(null==(e8=tX.deduplicator)?void 0:e8.enabled)??!1,onValueChange:e=>{t0(t=>({...t,deduplicator:{...t.deduplicator,enabled:e}}))}})}),"pro"===tZ&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u6,{title:"Group Handling",description:(0,r.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,r.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium",children:"Single Result"}),(0,r.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,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium",children:"Per Service"}),(0,r.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,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium",children:"Per Addon"}),(0,r.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,r.jsx)(r0,{disabled:!(null==(e7=tX.deduplicator)?void 0:e7.enabled),label:"Cached Results",value:(null==(te=tX.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=>{t0(t=>({...t,deduplicator:{...t.deduplicator,cached:e}}))}}),(0,r.jsx)(r0,{disabled:!(null==(tt=tX.deduplicator)?void 0:tt.enabled),label:"Uncached Results",value:(null==(ts=tX.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=>{t0(t=>({...t,deduplicator:{...t.deduplicator,uncached:e}}))}}),(0,r.jsx)(r0,{disabled:!(null==(ta=tX.deduplicator)?void 0:ta.enabled),label:"P2P Results",value:(null==(tn=tX.deduplicator)?void 0:tn.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=>{t0(t=>({...t,deduplicator:{...t.deduplicator,p2p:e}}))}})]}),(0,r.jsxs)(u6,{title:"Other",children:[(0,r.jsx)(nJ,{disabled:!(null==(tl=tX.deduplicator)?void 0:tl.enabled),label:"Detection Methods",multiple:!0,help:"Select the methods used to detect duplicates",value:(null==(ti=tX.deduplicator)?void 0:ti.keys)??["filename","
43infoHash"],emptyMessage:"No detection methods available",onValueChange:e=>{t0(t=>({...t,deduplicator:{...t.deduplicator,keys:e}}))},options:s6.map(e=>({label:e,value:e}))}),((null==(to=tX.deduplicator)?void 0:to.keys)??["filename","infoHash"]).includes("smartDetect")&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(nJ,{disabled:!(null==(td=tX.deduplicator)?void 0:td.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==(tc=tX.deduplicator)?void 0:tc.smartDetectAttributes)??s7,emptyMessage:"No attributes available",onValueChange:e=>{t0(t=>({...t,deduplicator:{...t.deduplicator,smartDetectAttributes:e}}))},options:s8.map(e=>({label:e,value:e}))}),["size","bitrate"].some(e=>{var t;return((null==(t=tX.deduplicator)?void 0:t.smartDetectAttributes)??s7).includes(e)})&&(0,r.jsx)(n1,{disabled:!(null==(tu=tX.deduplicator)?void 0:tu.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==(tm=tX.deduplicator)?void 0:tm.smartDetectRounding)??10,onValueChange:e=>{void 0!==e&&t0(t=>({...t,deduplicator:{...t.deduplicator,smartDetectRounding:e}}))}})]}),(0,r.jsx)(nJ,{help:"Addons selected here will always have their results kept during deduplication.",label:"Addon Exclusions",value:(null==(tp=tX.deduplicator)?void 0:tp.excludeAddons)??[],onValueChange:e=>{t0(t=>({...t,deduplicator:{...t.deduplicator,excludeAddons:e}}))},options:tX.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=tX.deduplicator)?void 0:th.enabled)===!1}),(0,r.jsx)(r0,{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                      ${xk[(null==(tx=tX.deduplicator)?void 0:tx.multiGroupBehaviour)||xS]}
45                      `,value:(null==(tg=tX.deduplicator)?void 0:tg.multiGroupBehaviour)??xS,onValueChange:e=>{t0(t=>({...t,deduplicator:{...t.deduplicator,multiGroupBehaviour:e}}))},disabled:!(null==(tf=tX.deduplicator)?void 0:tf.enabled),options:[{label:"Conservative",value:"conservative"},{label:"Aggressive",value:"aggressive"},{label:"Keep All",value:"keep_all"}]}),(0,r.jsx)(r0,{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==(tb=tX.deduplicator)?void 0:tb.libraryBehaviour)??"ignore",onValueChange:e=>{t0(t=>({...t,deduplicator:{...t.deduplicator,libraryBehaviour:e}}))},disabled:!(null==(tv=tX.deduplicator)?void 0:tv.enabled),options:[{label:"Ignore",value:"ignore"},{label:"Prefer",value:"prefer"},{label:"Exclusive",value:"exclusive"}]}),s9.map(e=>{var t,s;let a=((null==(t=tX.deduplicator)?void 0:t.tiebreakers)??[{type:"torrent_seeders",position:"before_addon"},{type:"usenet_age",position:"before_addon"}]).find(t=>t.type===e),n=(null==a?void 0:a.position)??"disabled";return(0,r.jsx)(r0,{disabled:!(null==(s=tX.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:n??"before_addon",onValueChange:t=>{t0(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,r.jsxs)(u6,{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,r.jsx)(rZ,{label:"Enable Merging",side:"right",disabled:!(null==(ty=tX.deduplicator)?void 0:ty.enabled),value:(null==(tw=tX.deduplicator)||null==(tj=tw.merge)?void 0:tj.enabled)??!1,onValueChange:e=>{t0(t=>{var s;return{...t,deduplicator:{...t.deduplicator,merge:{...null==(s=t.deduplicator)?void 0:s.merge,enabled:e}}}})}}),(0,r.jsx)(rZ,{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=tX.deduplicator)?void 0:tN.enabled)||!(null==(tS=tX.deduplicator)||null==(tk=tS.merge)?void 0:tk.enabled),value:(null==(t_=tX.deduplicator)||null==(tC=t_.merge)?void 0:tC.failoverVariants)??!1,onValueChange:e=>{t0(t=>{var s;return{...t,deduplicator:{...t.deduplicator,merge:{...null==(s=t.deduplicator)?void 0:s.merge,failoverVariants:e}}}})}}),(0,r.jsx)(nJ,{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=tX.deduplicator)?void 0:tA.enabled)||!(null==(tT=tX.deduplicator)||null==(tR=tT.merge)?void 0:tR.enabled),value:(null==(tE=tX.deduplicator)||null==(tI=tE.merge)?void 0:tI.fields)??[],emptyMessage:"No fields available",onValueChange:e=>{t0(t=>{var s;return{...t,deduplicator:{...t.deduplicator,merge:{...null==(s=t.deduplicator)?void 0:s.merge,fields:e}}}})},options:sk.map(e=>({label:e,value:e}))})]})]})]})]})}),(0,r.jsx)(nT,{id:"filter-tab-miscellaneous",value:"miscellaneous",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xN,{heading:"Miscellaneous"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Additional miscellaneous filters."})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(u6,{id:"digitalReleaseFilter",title:"Digital Release Filter",description:"This will filter out all results for movies that are determined to not have a digital release.",children:[(0,r.jsx)(rZ,{label:"Enabled",side:"right",value:(null==(tM=tX.digitalReleaseFilter)?void 0:tM.enabled)??!1,onValueChange:e=>{t0(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter||{},enabled:e}}))}}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(hX,{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=tX.digitalReleaseFilter)?void 0:tP.enabled),value:[(null==(tD=tX.digitalReleaseFilter)?void 0:tD.tolerance)??0],min:0,max:365,step:1,defaultValue:[0],onValueChange:e=>{t0(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,tolerance:e[0]}}))}})}),(0,r.jsx)("div",{className:"w-24",children:(0,r.jsx)(n1,{label:"Value",step:1,value:(null==(t$=tX.digitalReleaseFilter)?void 0:t$.tolerance)??0,min:0,max:365,disabled:!(null==(tL=tX.digitalReleaseFilter)?void 0:tL.enabled),onValueChange:e=>{void 0!==e&&t0(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,tolerance:e}}))}})})]}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Tolerance in days"}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(tO=tX.digitalReleaseFilter)?void 0:tO.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:af.map(e=>({label:e,value:e,textValue:e})),value:null==(tU=tX.digitalReleaseFilter)?void 0:tU.requestTypes,onValueChange:e=>{t0(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,requestTypes:e}}))}}),(0,r.jsx)(nJ,{multiple:!0,disabled:!(null==(tF=tX.digitalReleaseFilter)?void 0:tF.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:tX.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(tz=tX.digitalReleaseFilter)?void 0:tz.addons)||[],onValueChange:e=>{t0(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,addons:e}}))}})]})}),(0,r.jsx)(rZ,{label:"Show Info Stream When Filtered",side:"right",defaultValue:!0,disabled:!(null==(tV=tX.digitalReleaseFilter)?void 0:tV.enabled),value:(null==(tq=tX.digitalReleaseFilter)?void 0:tq.showInfoOnFilter)??!0,moreHelp:"When the digital release filter triggers, show an info stream.",onValueChange:e=>{t0(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,showInfoOnFilter:e}}))}})]}),(0,r.jsx)(u6,{id:"enableSeadex",title:"SeaDex Integration",description:"Fetch SeaDex data (releases.moe) for anime to identify best quality releases.",children:(0,r.jsx)(rZ,{label:"Enable",side:"right",value:tX.enableSeadex??!0,defaultValue:!0,onValueChange:e=>{t0(t=>({...t,enableSeadex:e}))}})}),"pro"===tZ&&tX.excludeSeasonPacks&&(0,r.jsx)(u6,{id:"excludeSeasonPacks",title:"Exclude Season Packs",de
45scription:"Whether to filter out results that contain entire seasons.",children:(0,r.jsx)(rZ,{label:"Enable",side:"right",value:tX.excludeSeasonPacks,onValueChange:e=>{t0(t=>({...t,excludeSeasonPacks:e}))}})})]})]})})]})]}),(0,r.jsx)(tJ,{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,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)("div",{className:"border rounded-md bg-gray-900 border-gray-800 p-4 max-h-96 overflow-auto",children:(0,r.jsxs)("div",{className:"space-y-2",children:[null==tY||null==(tB=tY.settings.regexAccess.patterns)?void 0:tB.map((e,t)=>(0,r.jsx)("div",{className:"font-mono text-sm bg-gray-800 rounded px-3 py-2 break-all whitespace-pre-wrap",children:e},t)),(!(null==tY?void 0:tY.settings.regexAccess.patterns)||0===tY.settings.regexAccess.patterns.length)&&(0,r.jsx)("div",{className:"text-muted-foreground text-sm text-center",children:"No allowed regex patterns configured"})]})})})}),(0,r.jsx)(tJ,{open:t6.isOpen,onOpenChange:t6.close,title:"Whitelisted Sync URLs",description:"These are URLs that are whitelisted for syncing stream expressions.",children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)("div",{className:"border rounded-md bg-gray-900 border-gray-800 p-4 max-h-96 overflow-auto",children:(0,r.jsxs)("div",{className:"space-y-2",children:[null==tY||null==(tK=tY.settings.selSyncAccess.trustedUrls)?void 0:tK.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 font-mono text-sm bg-gray-800 rounded px-3 py-2",children:[(0,r.jsx)("div",{className:"flex-1 break-all whitespace-pre-wrap",children:e}),(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(mu.zU_,{}),onClick:()=>r9(e,{onSuccess:()=>x.oR.success("URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})})]},t)),(!(null==tY?void 0:tY.settings.selSyncAccess.trustedUrls)||0===tY.settings.selSyncAccess.trustedUrls.length)&&(0,r.jsx)("div",{className:"text-muted-foreground text-sm text-center",children:"No whitelisted sync URLs configured"})]})})})}),(0,r.jsx)(tJ,{open:t4.isOpen,onOpenChange:t4.close,title:"Allowed Regex Pattern URLs",description:"These are URLs that you can import regex patterns from.",children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)("div",{className:"border rounded-md bg-gray-900 border-gray-800 p-4 max-h-96 overflow-auto",children:(0,r.jsxs)("div",{className:"space-y-2",children:[null==tY||null==(tH=tY.settings.regexAccess.urls)?void 0:tH.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 font-mono text-sm bg-gray-800 rounded px-3 py-2",children:[(0,r.jsx)("div",{className:"flex-1 break-all whitespace-pre-wrap",children:e}),(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(mu.zU_,{}),onClick:()=>r9(e,{onSuccess:()=>x.oR.success("URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})})]},t)),(!(null==tY?void 0:tY.settings.regexAccess.urls)||0===tY.settings.regexAccess.urls.length)&&(0,r.jsx)("div",{className:"text-muted-foreground text-sm text-center",children:"No allowed regex pattern URLs configured"})]})})})})]})}var xI=s(39114),xE=s(90571),xM=s(17328),xP=s(71972),xD=s(15498),x$=s(70339),xL=s(9413);let xO={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 xU(e,t){var s;return(null==(s=e.sortCriteria)?void 0:s[t])??[]}function xF(e){let{id:t,name:s,description:a,direction:n,onDirectionChange:l}=e,{attributes:i,listeners:o,setNodeRef:d,transform:c,transition:u,isDragging:m}=(0,uF.gl)({id:t}),p={transform:uz.Ks.Transform.toString(c),transition:u,opacity:m?.5:1};return(0,r.jsx)("div",{ref:d,style:p,children:(0,r.jsxs)("div",{className:"px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 relative",children:[(0,r.jsx)("div",{className:"rounded-full w-6 h-auto bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move",...i,...o}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col justify-center min-w-0",children:[(0,r.jsx)("span",{className:"font-mono text-base truncate",children:s}),(0,r.jsx)("span",{className:"text-[--muted] text-sm truncate",children:a})]}),(0,r.jsx)(E,{size:"sm",rounded:!0,icon:"asc"===n?(0,r.jsx)(xI.A,{}):(0,r.jsx)(xE.A,{}),intent:"primary-subtle",onClick:l})]})})}function xz(e){let{sortKey:t,inheritedFrom:s}=e,{userData:a,setUserData:l}
45=aY(),[i,o]=(0,n.useState)(!1),d=xU(a,t),c=(0,uV.FR)((0,uV.MS)(uV.AN),(0,uV.MS)(uV.IG,{activationConstraint:{delay:150,tolerance:8}}));function u(e){l(s=>({...s,sortCriteria:{...s.sortCriteria||{},[t]:e}}))}return(0,n.useEffect)(()=>{function e(e){i&&e.preventDefault()}return i?document.body.addEventListener("touchmove",e,{passive:!1}):document.body.removeEventListener("touchmove",e),()=>document.body.removeEventListener("touchmove",e)},[i]),(0,r.jsxs)("div",{className:"space-y-2",children:[0===d.length&&s&&(0,r.jsxs)("p",{className:"text-xs text-[--muted] italic",children:["Empty — using"," ",(0,r.jsx)("span",{className:"not-italic text-[--foreground]",children:s})," ","as fallback. Add criteria below to override."]}),0===d.length&&!s&&(0,r.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No criteria defined yet."}),(0,r.jsx)(nJ,{multiple:!0,value:d.map(e=>e.key),emptyMessage:"No sort criteria available",onValueChange:e=>{u(e.map(e=>d.find(t=>t.key===e)??{key:e,direction:au[e].defaultDirection}))},options:ac.map(e=>({label:au[e].name,textValue:au[e].name,value:e}))}),d.length>0&&(0,r.jsx)(uV.Mp,{modifiers:[uU.FN],onDragEnd:function(e){let{active:t,over:s}=e;
45if(s&&t.id!==s.id){let e=d.findIndex(e=>`${e.key}-${e.direction}`===t.id),a=d.findIndex(e=>`${e.key}-${e.direction}`===s.id);u((0,uF.be)(d,e,a))}o(!1)},onDragStart:()=>o(!0),sensors:c,children:(0,r.jsx)(uF.gB,{items:d.map(e=>`${e.key}-${e.direction}`),strategy:uF._G,children:(0,r.jsx)("div",{className:"space-y-2",children:d.map(e=>(0,r.jsx)(xF,{id:`${e.key}-${e.direction}`,name:au[e.key].name,description:"asc"===e.direction?`${au[e.key].description}, ${au[e.key].ascendingDescription}`:`${au[e.key].description}, ${au[e.key].descendingDescription}`,direction:e.direction,onDirectionChange:()=>{let t="asc"===e.direction?"desc":"asc";u(d.map(s=>s.key===e.key?{...s,direction:t}:s))}},`${e.key}-${e.direction}`))})})})]})}function xV(e){let{items:t}=e;if(0===t.length)return null;let s=t.slice(0,3);return(0,r.jsxs)("span",{className:"flex flex-wrap items-center gap-1",children:[s.map(e=>(0,r.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-[--subtle] text-[--muted] border border-[--border]",children:au[e.key].name},e.key)),t.length>3&&(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:["+",t.length-3]})]})}function xq(e){let{sortKey:t}=e;return(0,r.jsx)("span",{className:b("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:xO[t]})}function xB(){let{userData:e}=aY(),t=[{type:"movie",label:"Movies",icon:(0,r.jsx)(xM.A,{className:"w-3.5 h-3.5"})},{type:"series",label:"Series",icon:(0,r.jsx)(xP.A,{className:"w-3.5 h-3.5"})},{type:"anime",label:"Anime",icon:(0,r.jsx)(xD.A,{className:"w-3.5 h-3.5"})}];return(0,r.jsx)(u6,{title:"Active Sort Configuration",description:"The sort orders that will actually be applied for each content type.",children:(0,r.jsx)("div",{className:"divide-y divide-[--border]",children:t.map(t=>{let{type:s,label:a,icon:n}=t,l=function(e,t){var s,a,r,n,l,i,o,d,c,u,m,p,h,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==(p=v.uncached)?void 0:p.length)&&(w="uncached")):((null==(h=v.anime)?void 0:h.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=xU(e,y),k=N.length>0&&"cached"===N[0].key&&null!==j&&null!==w,S=j?xU(e,j):[],C=w?xU(e,w):[];return{primaryKey:y,primary:N,cachedKey:j,uncachedKey:w,cachedItems:S,uncachedItems:C,splitActive:k}}(e,s);return(0,r.jsxs)("div",{className:"py-3 first:pt-0 last:pb-0 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,r.jsx)("span",{className:"text-[--muted]",children:n}),a,l.splitActive&&(0,r.jsxs)("span",{className:"flex items-center gap-0.5 text-xs font-normal text-green-400",children:[(0,r.jsx)(hL.A,{className:"w-3 h-3"}),"split"]})]}),l.splitActive?(0,r.jsx)("div",{className:"ml-5 space-y-1.5",children:[{dot:"bg-green-400",label:"Cached",key:l.cachedKey,items:l.cachedItems},{dot:"bg-yellow-400",label:"Uncached",key:l.uncachedKey,items:l.uncachedItems}].map(e=>{let{dot:t,label:s,key:a,items:n}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,r.jsx)("span",{className:b("w-1.5 h-1.5 rounded-full shrink-0",t)}),(0,r.jsx)(xq,{sortKey:a}),n.length>0&&(0,r.jsx)("span",{className:"text-[--muted] text-xs shrink-0",children:"→"}),(0,r.jsx)(xV,{items:n}),0===n.length&&(0,r.jsx)("span",{className:"text-xs text-[--muted] italic",children:"no criteria defined"})]},s)})}):(0,r.jsxs)("div",{className:"ml-5 flex items-center gap-1.5 flex-wrap",children:[(0,r.jsx)(xq,{sortKey:l.primaryKey}),l.primary.length>0&&(0,r.jsx)("span",{className:"text-[--muted] text-xs shrink-0",children:"→"}),(0,r.jsx)(xV,{items:l.primary}),0===l.primary.length&&(0,r.jsx)("span",{className:"text-xs text-[--muted] italic",children:"no criteria defined"})]}),!l.splitActive&&(l.cachedKey||l.uncachedKey)&&(0,r.jsxs)("div",{className:"ml-5 flex items-start gap-1.5 text-xs text-yellow-400/80",children:[(0,r.jsx)(x$.A,{className:"w-3.5 h-3.5 shrink-0 mt-px"}),(0,r.jsxs)("span",{children:["Cached sorts are defined but inactive — make"," ",(0,r.jsx)("span",{className:"text-yellow-400",children:"Cached"})," the first primary criterion to enable split mode"]})]})]},s)})})})}let xK={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 xH(e){let{type:t}=e,{userData:s}=aY(),a=xK[t],n=s.sortCriteria;function l(){var e;if("global"!==t)return((null==n||null==(e=n.cached)?void 0:e.length)??0)>0?"Global Cached":void 0}function i(){var e;if("global"!==t)return((null==n||null==(e=n.uncached)?void 0:e.length)??0)>0?"Global Uncached":void 0}return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(u6,{title:a.primaryLabel,description:a.primaryDescription,children:(0,r.jsx)(xz,{sortKey:a.primaryKey,inheritedFrom:a.primaryInherit})}),(0,r.jsx)(u6,{title:"Split by Cache",description:(0,r.jsxs)(r.Fragment,{children:["When ",(0,r.jsx)("strong",{children:'"Cached"'})," is the"," ",(0,r.jsx)("strong",{children:"first criterion"})," above and both sorts below are defined, cached and uncached streams are sorted independently then merged."]}),children:(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-2 h-2 rounded-full bg-green-400 shrink-0"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Cached Streams"}),0===xU(s,a.cachedKey).length&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:l()?`— using ${l()} as fallback`:"— undefined, split requires this"})]}),(0,r.jsx)(xz,{sortKey:a.cachedKey,inheritedFrom:l()})]}),(0,r.jsx)("div",{className:"border-t border-[--border]"}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-2 h-2 rounded-full bg-yellow-400 shrink-0"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Uncached Streams"}),0===xU(s,a.uncachedKey).length&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:i()?`— using ${i()} as fallback`:"— undefined, split requires this"})]}),(0,r.jsx)(xz,{sortKey:a.uncachedKey,inheritedFrom:i()})]})]})})]})}function xW(){return(0,r.jsx)(r6,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(xG,{})})}function xG(){var e,t,s,a,l,i,o,d,c;let{userData:u,setUserData:m}=aY(),{isInherited:p,hasParent:h}
45=aJ(),[x,g]=(0,n.useState)("global");(0,n.useEffect)(()=>{u.sortCriteria||m(e=>({...e,sortCriteria:{global:[],movies:[],series:[],anime:[],cached:[],uncached:[],cachedMovies:[],uncachedMovies:[],cachedSeries:[],uncachedSeries:[],cachedAnime:[],uncachedAnime:[]}}))},[]);let f=u.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==(l=f.cachedSeries)?void 0:l.length)??0)>0||((null==f||null==(i=f.uncachedSeries)?void 0:i.length)??0)>0,y=((null==f||null==(o=f.anime)?void 0:o.length)??0)>0||((null==f||null==(d=f.cachedAnime)?void 0:d.length)??0)>0||((null==f||null==(c=f.uncachedAnime)?void 0:c.length)??0)>0;function j(e,t){return(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[e,t&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-blue-300 inline-block"})]})}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{children:"Sorting"}),h&&p("sorting")&&(0,r.jsx)(uI,{section:"sorting"})]}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Configure how your streams are sorted and organised."})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(uw,{})})]}),(0,r.jsx)(xB,{}),(0,r.jsx)(uT,{tabs:[{value:"global",label:"Global",icon:(0,r.jsx)(xL.A,{className:"w-4 h-4"}),content:(0,r.jsx)(xH,{type:"global"})},{value:"movies",label:j("Movies",b),icon:(0,r.jsx)(xM.A,{className:"w-4 h-4"}),content:(0,r.jsx)(xH,{type:"movies"})},{value:"series",label:j("Series",v),icon:(0,r.jsx)(xP.A,{className:"w-4 h-4"}),content:(0,r.jsx)(xH,{type:"series"})},{value:"anime",label:j("Anime",y),icon:(0,r.jsx)(xD.A,{className:"w-4 h-4"}),content:(0,r.jsx)(xH,{type:"anime"})}],activeTab:x,onTabChange:g})]})}function xY(){var e,t,s,a,n,l,i;let{userData:o,setUserData:d}=aY(),{status:c}=tr(),u=null==c||null==(t=c.settings)||null==(e=t.limits)?void 0:e.maxBackgroundPings;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u6,{title:"Pre-cache Next Episode",id:"precacheNextEpisode",description:(0,r.jsxs)(r.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,r.jsxs)(r.Fragment,{children:["Up to ",(0,r.jsx)("strong",{children:u})," stream",1===u?"":"s"," can be pinged per operation (",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")."]})]}),children:[(0,r.jsx)(rZ,{label:"Enable",side:"right",value:o.precacheNextEpisode,onValueChange:e=>{d(t=>({...t,precacheNextEpisode:e}))}}),(0,r.jsx)(rZ,{label:"First stream only",help:(0,r.jsxs)(r.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,r.jsxs)(r.Fragment,{children:[" ","(up to ",(0,r.jsx)("strong",{children:u}),","," ",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}):(0,r.jsxs)(r.Fragment,{children:[" ","(capped by ",(0,r.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,r.jsx)(G,{label:"Precache Selector",help:(0,r.jsxs)(r.Fragment,{children:[(0,r.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,r.jsxs)("p",{className:"mt-2",children:[(0,r.jsx)("strong",{children:"Recommended pattern:"})," ",(0,r.jsx)("code",{children:"condition ? streamsToSelectFrom : []"})]}),(0,r.jsxs)("ul",{className:"mt-2 space-y-1 list-disc list-inside",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"condition"})," - When precaching should activate"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"streamsToSelectFrom"})," - Which streams AIOStreams should choose from"]})]}),(0,r.jsx)("p",{className:"mt-2",children:(0,r.jsx)("strong",{children:"Examples:"})}),(0,r.jsxs)("ul",{className:"mt-2 space-y-1 list-disc list-inside",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Default behavior"})," (precache only when all streams are uncached):",(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"count(cached(streams)) == 0 ? uncached(streams) : []"})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Always precache first uncached stream
45:"}),(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"true ? uncached(streams) : []"})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Only for anime series:"}),(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"queryType == 'anime.series' ? uncached(streams) : []"})]})]}),(0,r.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,r.jsxs)(u6,{title:"Preload Streams",id:"preloadStreams",description:(0,r.jsxs)(r.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,r.jsxs)(r.Fragment,{children:["Up to ",(0,r.jsx)("strong",{children:u})," stream",1===u?"":"s"," can be pinged per operation (",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")."]})]}),children:[(0,r.jsx)(rZ,{label:"Enable",side:"right",value:null==(s=o.preloadStreams)?void 0:s.enabled,onValueChange:e=>{d(t=>({...t,preloadStreams:{...t.preloadStreams,enabled:e}}))}}),(0,r.jsx)(rZ,{label:"First stream only",help:(0,r.jsxs)(r.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,r.jsxs)(r.Fragment,{children:[" ","(up to ",(0,r.jsx)("strong",{children:u}),","," ",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}):(0,r.jsxs)(r.Fragment,{children:[" ","(capped by ",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}),"."]}),side:"right",disabled:!(null==(a=o.preloadStreams)?void 0:a.enabled),value:(null==(n=o.preloadStreams)?void 0:n.singleStream)??!0,defaultValue:!0,onValueChange:e=>{d(t=>({...t,preloadStreams:{...t.preloadStreams,singleStream:e}}))}}),(0,r.jsx)(G,{label:"Preload Selector",help:(0,r.jsxs)(r.Fragment,{children:[(0,r.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,r.jsx)("p",{className:"mt-2",children:(0,r.jsx)("strong",{children:"Examples:"})}),(0,r.jsxs)("ul",{className:"mt-2 space-y-1 list-disc list-inside",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Top 5 streams (default):"}),(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"slice(streams, 0, 5)"})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Top 5 usenet streams only:"}),(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"slice(type(streams, 'usenet'), 0, 5)"})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Top 3 cached streams:"}),(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"slice(cached(streams), 0, 3)"})]})]}),(0,r.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==(l=o.preloadStreams)?void 0:l.enabled),value:(null==(i=o.preloadStreams)?void 0:i.selector)??"",onValueChange:e=>{d(t=>({...t,preloadStreams:{...t.preloadStreams,selector:e||void 0}}))}})]})]})}function xJ(){var e,t,s,a,n,l,i,o,d,c,u,m;let{userData:p,setUserData:h}=aY();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u6,{title:"Auto Play",id:"autoPlay",description:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{children:"Configure how AIOStreams suggests the next stream for Stremio's auto-play feature."}),(0,r.jsx)(lN,{intent:"info-basic",children:(0,r.jsxs)("p",{className:"text-sm",children:["AIOStreams does not (and cannot) directly control auto-play. It uses the"," ",(0,r.jsx)("code",{children:(0,r.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,r.jsx)(rZ,{label:"Enable",side:"right",value:(null==(e=p.autoPlay)?void 0:e.enabled)??!0,onValueChange:e=>{h(t=>({...t,autoPlay:{...t.autoPlay,enabled:e}}))}}),(0,r.jsx)(r0,{label:"Auto Play Method",disabled:(null==(t=p.autoPlay)?void 0:t.enabled)===!1,options:as.map(e=>({label:aa[e].name,value:e})),value:(null==(s=p.autoPlay)?void 0:s.method)||"matchingFile",onValueChange:e=>{h(t=>({...t,autoPlay:{...t.autoPlay,method:e}}))},help:aa[(null==(a=p.autoPlay)?void 0:a.method)||"matchingFile"].description}),((null==(n=p.autoPlay)?void 0:n.method)??"matchingFile")==="matchingFile"&&(0,r.jsx)(nJ,{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:ae.map(e=>({label:e,value:e})),multiple:!0,disabled:(null==(l=p.autoPlay)?void 0:l.enabled)===!1,emptyMessage:"No attributes found",value:null==(i=p.autoPlay)?void 0:i.attributes,defaultValue:at,onValueChange:e=>{h(t=>({...t,autoPlay:{...t.autoPlay,attributes:e}}))}})]}),(0,r.jsxs)(u6,{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,r.jsx)(rZ,{label:"Enable",side:"right",value:null==(o=p.areYouStillThere)?void 0:o.enabled,onValueChange:e=>{h(t=>({...t,areYouStillThere:{...t.areYouStillThere,enabled:e}}))}}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,r.jsx)(n1,{label:"Episodes before check",min:1,defaultValue:3,disabled:!(null==(d=p.areYouStillThere)?void 0:d.enabled),value:(null==(c=p.areYouStillThere)?void 0:c.episodesBeforeCheck)??3,onValueChange:e=>{h(t=>({...t,areYouStillThere:{...t.areYouStillThere,episodesBeforeCheck:Math.max(1,Number(e||3))}}))}}),(0,r.jsx)(n1,{label:"Cooldown (minutes)",min:1,defaultValue:60,disabled:!(null==(u=p.areYouStillThere)?void 0:u.enabled),value:(null==(m=p.areYouStillThere)?void 0:m.cooldownMinutes)??60,onValueChange:e=>{h(t=>({...t,areYouStillThere:{...t.areYouStillThere,cooldownMinutes:Math.max(1,Number(e||60))}}))}})]})]})]})}function xZ(){var e,t,s,a,n;let{userData:l,setUserData:i}=aY();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u6,{title:"Statistic Streams",id:"statistics",description:"AIOStreams will return the statistics of stream fetches and response times for each addon if enabled.",children:[(0,r.jsx)(rZ,{label:"Enable",side:"right",value:null==(e=l.statistics)?void 0:e.enabled,onValueChange:e=>{i(t=>({...t,statistics:{...t.statistics,enabled:e}}))}}),(0,r.jsx)(r0,{label:"Statistics Position",help:"Whether to show the statistic streams at the top or bottom of the stream list.",disabled:!(null==(t=l.statistics)?void 0:t.enabled),options:[{label:"Top",value:"top"},{label:"Bottom",value:"bottom"}],value:(null==(s=l.statistics)?void 0:s.position)||"bottom",onValueChange:e=>{i(t=>({...t,statistics:{...t.statistics,position:e}}))}}
45),(0,r.jsx)(nJ,{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=l.statistics)?void 0:a.statsToShow,onValueChange:e=>{i(t=>({...t,statistics:{...t.statistics,statsToShow:e}}))}}),(0,r.jsx)(rZ,{label:"Show Filter Stats on No Streams",side:"right",defaultValue:!0,value:(null==(n=l.statistics)?void 0:n.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=>{i(t=>({...t,statistics:{...t.statistics,showFilterStatsOnNoStreams:e}}))}})]}),(0,r.jsx)(u6,{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,r.jsx)(rZ,{label:"Enable",side:"right",value:l.externalDownloads,onValueChange:e=>{i(t=>({...t,externalDownloads:e}))}})}),(0,r.jsxs)(u6,{id:"hideErrors",title:"Hide Errors",children:[(0,r.jsx)(rZ,{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:l.hideErrors,onValueChange:e=>{i(t=>({...t,hideErrors:e}))}}),(0,r.jsx)(nJ,{disabled:l.hideErrors,label:"Hide Errors for specific resources",options:av.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:l.hideErrorsForResources,onValueChange:e=>{i(t=>({...t,hideErrorsForResources:e}))}})]})]})}let xQ=[{value:"inherit",label:"Inherit from parent"},{value:"override",label:"Override with mine"}],xX=[{value:"inherit",label:"Inherit from parent"},{value:"extend",label:"Extend parent (add mine)"},{value:"override",label:"Override with mine"}],x0={presets:"Addons",services:"Services",filters:"Filters",sorting:"Sorting & Deduplication",formatter:"Formatter",proxy:"Proxy",metadata:"Metadata & Poster APIs",misc:"Miscellaneous Settings",branding:"Branding"},x1={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."},x2={filters:"Filters",sorting:"Sorting",formatter:"Formatter",proxy:"Proxy",metadata:"Metadata",misc:"Misc",branding:"Branding"},x3=["filters","sorting","formatter","proxy","metadata","misc","branding"],x5=Object.entries(sj).filter(e=>{let[,t]=e;return!t.ignoreForParentConfig}).map(e=>{let[t]=e;return t}).sort((e,t)=>{var s,a;return((null==(s=sj[e])?void 0:s.label)??e).localeCompare((null==(a=sj[t])?void 0:a.label)??t)}),x4=Object.fromEntries(x3.map(e=>[e,x5.filter(t=>{var s;return(null==(s=sj[t])?void 0:s.group)===e})]));function x6(e,t){var s;let a=null==(s=sj[e])?void 0:s.group;return a?(null==t?void 0:t[a])??"inherit":"inherit"}function x9(e){let{field:t,meta:s,activeOverride:a,groupStrategy:n,trimmedSearch:l,onChange:i}=e,o=[{value:"default",label:`Default: ${"inherit"===n?"Inherit (group)":"override"===n?"Override (group)":"Extend (group)"}`},..."list"===s.type?xX:xQ];return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2 rounded-[--radius] hover:bg-[--subtle] group",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col sm:flex-row sm:items-center sm:gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:s.label}),l&&(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:["(",x2[s.group],")"]})]}),(0,r.jsx)("div",{className:"w-48 shrink-0",children:(0,r.jsx)(r0,{size:"sm",options:o,value:a??"default",onValueChange:e=>i(t,e)})})]})}function x8(e){var t;let{open:s,onOpenChange:a,strategies:l,fieldOverrides:i,onChange:o}
45=e,[d,c]=(0,n.useState)("filters"),[u,m]=(0,n.useState)(""),p=u.trim().toLowerCase(),h=(0,n.useMemo)(()=>p?x5.filter(e=>{var t;return((null==(t=sj[e])?void 0:t.label)??e).toLowerCase().includes(p)}):x4[d]??[],[p,d]),x=(0,n.useMemo)(()=>Object.fromEntries(x3.map(e=>[e,x5.filter(t=>{var s;return(null==(s=sj[t])?void 0:s.group)===e&&i[t]}).length])),[i]),g=Object.keys(i).filter(e=>sj[e]).length;return(0,r.jsx)(tJ,{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,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(G,{placeholder:"Search fields…",value:u,onValueChange:m}),!p&&(0,r.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:x3.map(e=>{let t=x[e],s=d===e;return(0,r.jsxs)("button",{onClick:()=>c(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:[x2[e],t>0&&(0,r.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)})}),!p&&(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("p",{className:"text-sm font-semibold text-[--text-color]",children:[x2[d],(0,r.jsxs)("span",{className:"ml-2 text-xs font-normal text-[--muted]",children:[(null==(t=x4[d])?void 0:t.length)??0," fields"]})]}),x[d]>0&&(0,r.jsxs)("button",{onClick:()=>{let e;return e=new Set(x5.filter(e=>{var t;return(null==(t=sj[e])?void 0:t.group)===d}).map(e=>e)),void o(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[d]," override",1!==x[d]?"s":""]})]}),p&&(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:[h.length," field",1!==h.length?"s":""," ","matching “",u.trim(),"”"]}),(0,r.jsx)("div",{className:"space-y-1 max-h-[50vh] overflow-y-auto pr-0.5",children:0===h.length?(0,r.jsx)("p",{className:"text-sm text-[--muted] py-4 text-center",children:"No fields found."}):h.map(e=>{let t=sj[e],s=i[e],a=x6(e,l);return(0,r.jsx)(x9,{field:e,meta:t,activeOverride:s,groupStrategy:a,trimmedSearch:!!p,onChange:(e,t)=>
45{o(s=>{let a={...s};return t&&"default"!==t?a[e]=t:delete a[e],a})}},e)})}),g>0&&(0,r.jsxs)("p",{className:"text-xs text-[--muted] border-t pt-3",children:[g," field override",1!==g?"s":""," ","active across all sections."]})]})})}function x7(){let{userData:e,setUserData:t,uuid:s}=aY(),[a,l]=(0,n.useState)(""),[i,o]=(0,n.useState)(""),[d,c]=(0,n.useState)(!1),[u,m]=(0,n.useState)(!1),p=e.parentConfig;async function h(e){if(null==e||e.preventDefault(),a.trim()&&i){if(c(!0),a===s){x.oR.error("You cannot link to your own config"),c(!1);return}try{let e=await eN(a.trim(),i);t(t=>({...t,parentConfig:{uuid:e.uuid,password:i,mergeStrategies:{presets:"inherit",services:"inherit",filters:"inherit",sorting:"inherit",formatter:"inherit",proxy:"inherit",metadata:"inherit",misc:"inherit",branding:"inherit"}}})),l(""),o(""),x.oR.success("Parent config linked. Save your config to apply.")}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to link parent config")}finally{c(!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,v=(null==b?void 0:b.fieldOverrides)??{},y=Object.keys(v).filter(e=>sj[e]).length;return(0,r.jsx)("div",{className:"space-y-4",children:p?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u6,{title:"Parent Config",id:"parentConfig",description:"Settings from the parent config are merged into this config at runtime.",action:(0,r.jsx)(w,{intent:"alert-subtle",size:"sm",leftIcon:(0,r.jsx)(hJ.KOA,{}),onClick:function(){t(e=>{let t={...e};return delete t.parentConfig,t}),x.oR.success("Parent config removed. Save your config to apply.")},children:"Unlink"}),children:(0,r.jsxs)("div",{className:"flex items-center gap-2 p-2 rounded-[--radius] bg-[--subtle] border text-sm",children:[(0,r.jsx)(hJ.j2W,{className:"shrink-0 text-[--muted]"}),(0,r.jsx)("span",{className:"font-mono text-xs truncate text-[--muted]",children:p.uuid})]})}),(0,r.jsx)(u6,{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,r.jsxs)("div",{className:"space-y-4",children:[["presets","services"].map(e=>(0,r.jsx)("div",{className:"space-y-1",children:(0,r.jsx)(r0,{label:x0[e],help:x1[e],options:xX,value:(null==b?void 0:b[e])??"inherit",onValueChange:t=>g(e,t)})},e)),["filters","sorting","formatter","proxy","metadata","misc","branding"].map(e=>(0,r.jsx)("div",{className:"space-y-1",children:(0,r.jsx)(r0,{label:x0[e],help:x1[e],options:xQ,value:(null==b?void 0:b[e])??"inherit",onValueChange:t=>g(e,t)})},e))]})}),(0,r.jsx)(u6,{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,r.jsx)(E,{size:"sm",intent:"white",rounded:!0,icon:(0,r.jsx)(lj.VSk,{}),onClick:()=>m(!0),title:"Configure Field Overrides"}),children:y>0?(0,r.jsx)("div",{className:"space-y-1 mt-2",children:Object.keys(v).filter(e=>sj[e]).map(e=>{let t=sj[e],s=v[e],a=x6(e,b);return(0,r.jsx)(x9,{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,r.jsx)("p",{className:"text-sm text-[--muted] pt-2",children:"No field overrides configured. All fields use their section strategy."})}),(0,r.jsx)(x8,{open:u,onOpenChange:m,strategies:b,fieldOverrides:v,onChange:f})]}):(0,r.jsx)(u6,{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,r.jsxs)("form",{onSubmit:h,className:"space-y-3",children:[(0,r.jsx)(G,{label:"Parent UUID",placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",autoComplete:"off",value:a,onValueChange:l}),(0,r.jsx)(Z,{label:"Parent Password",autoComplete:"off",value:i,onValueChange:o}),(0,r.jsx)(w,{type:"submit",size:"sm",intent:"white",rounded:!0,loading:d,disabled:!a.trim()||!i,leftIcon:(0,r.jsx)(hJ.j2W,{}),children:"Link Parent"})]})})})}let ge={maxScriptLength:4e3,maxInstructions:100,maxValueDepth:10,maxPathSegments:12,maxPathMatches:200},gt=new Set(["accessKey","parentConfig","variants","healthChecks"]),gs=new Set(["__proto__","prototype","constructor"]),ga=new Set(["true","false","null"]),gr=new Set(["set","merge","unset","clear","add","prepe
45nd","remove","enable","disable","use"]),gn=/^[a-z0-9][a-z0-9_-]{0,31}$/;function gl(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 gi extends Error{constructor(e,t){super(e),(0,er._)(this,"diagnostic",void 0),this.diagnostic=t}}class go{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 gi(e,{index:s,source:a,line:this.line,message:e,category:t.category??"syntax",suggestion:t.suggestion})}constructor(e){(0,er._)(this,"src",void 0),(0,er._)(this,"pos",void 0),(0,er._)(this,"line",void 0),this.src=e,this.pos=0,this.line=1}}function gd(e){return/[A-Za-z_]/.test(e)}function gc(e){return/[A-Za-z0-9_]/.test(e)}function gu(e){return e>="0"&&e<="9"}function gm(e){gd(e.peek())||e.fail("expected a name");let t=e.pos,s="";for(;!e.eof&&gc(e.peek());)s+=e.advance();return gs.has(s)&&e.fail(`"${s}" is not an allowed name`,{index:t,source:s}),s}function gp(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"),gs.has(s)&&e.fail(`"${s}" is not an allowed name`,{index:t,source:s}),s}let gh=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function gx(e){if(!gd(e.peek()))return;let t="",s=0;for(;gc(e.peek(s));)t+=e.peek(s++);return t}function gg(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 gf(e){let t=e.pos,s="";for("-"===e.peek()&&(s+=e.advance());gu(e.peek());)s+=e.advance();if("."===e.peek())for(s+=e.advance();gu(e.peek());)s+=e.advance();if("e"===e.peek()||"E"===e.peek())for(s+=e.advance(),("+"===e.peek()||"-"===e.peek())&&(s+=e.advance());gu(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 gb(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 gg(e);if("-"===a||gu(a))return gf(e);if("["===a){e.advance();let a=[];if(e.skipTrivia(),"]"===e.peek())return e.advance(),a;for(;;){if(a.push(gb(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()?gg(e):gm(e);if(gs.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]=gb(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=gx(e);if(r&&ga.has(r))return e.advance(r.length),"true"===r||"false"!==r&&null;e.fail("expected a value (string, number, boolean, null, array or object)")}
45function gv(e,t){let s=e.pos,a=gm(e);gt.has(a)&&e.fail(`"${a}" cannot be changed by a variant`,{index:s,source:a,category:"denied-field"}),Object.prototype.hasOwnProperty.call(sj,a)||e.fail(`"${a}" is not a known configuration field`,{index:s,source:a,category:"unknown-field",suggestion:gl(a,Object.keys(sj).filter(e=>!gt.has(e)))});let r=[];for(;!e.eof;){if("."===e.peek())e.advance(),r.push({kind:"key",name:gm(e)});else if("["===e.peek()){if(e.advance(),e.skipTrivia(),"*"===e.peek()&&"]"===e.peek(1))e.advance(),r.push({kind:"all"});else if(gu(e.peek())||"-"===e.peek()&&gu(e.peek(1))){let t=e.pos,s=gf(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(gd(e.peek()))for(a=gm(e);"."===e.peek();)e.advance(),a+=`.${gm(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 gb(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):gh.test(a)?gf(e):gp(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 gy(e){return'"'===e.peek()||"'"===e.peek()?gg(e):gp(e)}function gj(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ge,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 go(e);for(;n.skipTrivia(),!n.eof;){let l=n.pos,i=n.line;try{let o=function(e,t){let s=e.pos,a=e.line,r=gm(e);switch(!gr.has(r)&&e.fail(`unknown instruction "${r}"`,{index:s,source:r,category:"unknown-verb",suggestion:gl(r,[...gr])}),e.skipTrivia(),r){case"set":case"merge":{let n=gv(e,t);e.skipTrivia(),"="!==e.peek()&&e.fail(`expected "=" after the path in ${r}`),e.advance();let l=gb(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:gv(e,t),index:s,line:a};case"add":case"prepend":case"remove":{let n=gv(e,t),l=function(e,t){let s=[];if(e.skipTrivia(),!function(e){let t=e.peek();if('"'===t||"'"===t||"["===t||"{"===t||"-"===t||gu(t))return!0;let s=gx(e);return void 0!==s&&ga.has(s)}(e))return s;for(s.push(gb(e,t));;){if(e.skipTrivia(),","!==e.peek())return s;e.advance(),s.push(gb(e,t))}}(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}}default:{let t=e.pos,r=gm(e);if(e.skipTrivia(),"formatter"===r)return{op:"useFormatter",name:gy(e),index:s,line:a};if("variant"===r){let t=e.pos,r=gy(e);return gn.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:gl(r,["formatter","variant"])})}}}(n,t);if(s.push(o),"useVariant"===o.op&&a.push(o.id),s.length>t.maxInstructions){r.push({index:l,source:e.slice(l,n.pos),line:i,message:`script exceeds the maximum of ${t.maxInstructions} instructions`,category:"limit",severity:"error"});break}}catch(t){t instanceof gi?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 gw(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function gN(e){if(Array.isArray(e))return e.map(gN);if(gw(e)){let t={};for(let[s,a]of Object.entries(e))gs.has(s)||(t[s]=gN(a));return t}return e}function gk(e,t){if(e===t)return!0;
45if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,s)=>gk(e,t[s]));if(gw(e)&&gw(t)){let s=Object.keys(e),a=Object.keys(t);return s.length===a.length&&s.every(s=>Object.prototype.hasOwnProperty.call(t,s)&&gk(e[s],t[s]))}return!1}function gS(e,t,s){"string"==typeof t&&gs.has(t)||(e[t]=s)}function gC(e,t){let s=e<0?t+e:e;return s>=0&&s<t?s:void 0}function g_(e,t){let s;if(t.key&&!gw(e))return!1;let a=e;for(let e of t.key?t.key.split("."):[]){if(!gw(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()):gk(a,t.value)||r&&String(a)===String(t.value),"!="===t.operator||"!*="===t.operator?!s:s}function gA(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 gw(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 gR(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 gT=s(22147),gI=s(2749);let gE=gI.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) 30%, 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 gM=s(3708);let gP={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 gD(e){let t=new gM.vB;for(let s of function(e){let t=[],s=0,a=!0,r=!1,n=!1,l=(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++;l("comment",t,s),a=!1;continue}if('"'===t||"'"===t){let i=s;for(s++;s<e.length&&e[s]!==t;)"\\"===e[s]&&s++,s++;s<e.length&&s++,l("string",i,s),a=!1,r=!1,n=!1;continue}if(gu(t)||"-"===t&&gu(e[s+1]??"")){let t=s;for(s++;s<e.length&&/[0-9.eE+-]/.test(e[s]);)s++;l("number",t,s),a=!1,r=!1,n=!1;continue}if(gd(t)){let t=s;for(;s<e.length&&gc(e[s]);)s++;let i=e.slice(t,s);ga.has(i)?l("keyword",t,s):a&&gr.has(i)?(l("verb",t,s),r=!0):r&&!n?(l("formatter"===i||"variant"===i?"verb":"root",t,s),r="formatter"===i||"variant"===i):l("property",t,s),a=!1,n=!1;continue}if("="===t||"!"===t||"*"===t){let t=s;for(;s<e.length&&/[=!*]/.test(e[s]);)s++;
45l("operator",t,s),a=!1;continue}n="."===t,l("punct",s,s+1),s++,a=!1}return t}(e.state.doc.toString()))t.add(s.start,s.end,gI.NZ.mark({class:gP[s.kind]}));return t.finish()}let g$=gI.Z9.fromClass(class{update(e){e.docChanged&&(this.decorations=gD(e.view))}constructor(e){(0,er._)(this,"decorations",void 0),this.decorations=gD(e)}},{decorations:e=>e.decorations}),gL=gI.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 gO=s(80704),gU=s(15115);let gF=[{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:"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"}],gz=/^\s*(set|merge|unset|clear|add|prepend|remove|enable|disable)\s+\w*$/,gV=Object.entries(sj).filter(e=>{let[t]=e;return!gt.has(t)}).map(e=>{let[t,s]=e;return{label:t,type:"list"===s.type?"property":"variable",detail:s.label}});function gq(e){let{value:t,onValueChange:s,limits:a,userData:l,currentVariantId:i,placeholder:o,disabled:d,className:c,initialHeight:u="14rem"}=e,m=(0,n.useMemo)(()=>[g$,gL,(0,gO.bu)(e=>{let t=e.state.doc.toString(),s=t.length;return gj(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,gU.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:gF,validFor:/^\w*$/}:gz.test(r)?{from:m.from,options:gV,validFor:/^\w*$/}:null:null}]})}({userData:l,currentVariantId:i}),gT.Lz.lineWrapping,(0,gI.qf)(o??"")],[a,l,i,o]);return(0,r.jsx)("div",{style:{height:u,minHeight:"8rem"},className:b("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",d&&"opacity-60 pointer-events-none",c),children:(0,r.jsx)(gT.Ay,{className:"h-full",value:t,onChange:s,editable:!d,theme:gE,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 gB=["stream","manifest.json","catalog","meta","subtitles","addon_catalog"];function gK(e){let{variants:t,healthChecks:s}=e,{uuid:a,password:l}=aY(),[i,o]=(0,n.useState)(""),[d,c]=(0,n.useState)("stream"),[u,m]=(0,n.useState)("movie"),[p,h]=(0,n.useState)("tt0111161"),[g,f]=(0,n.useState)(""),[b,v]=(0,n.useState)(null),[y,j]=(0,n.useState)([]),[N,k]=(0,n.useState)(!1),S=!!a;(0,n.useEffect)(()=>{o(navigator.userAgent)},[]),(0,n.useEffect)(()=>{a&&ey(a,l).then(j).catch(()=>j([]))},[a,l]);let C=async()=>{if(a){k(!0);try{let e={};for(let[t,s]of new URLSearchParams(g))e[t]=s;v(await ej(a,l,{variants:t,healthChecks:s,userAgent:i,resource:d,type:u||void 0,id:p||void 0,query:e}))}catch(e){v(null),x.oR.error((null==e?void 0:e.message)??"Could not evaluate the conditions")}finally{k(!1)}}};return(0,r.jsxs)(u6,{title:"Test conditions",description:"Describe a request and see which variants would activate for it.",children:[!S&&(0,r.jsx)(lN,{intent:"info-basic",title:"Save this configuration first",description:"Conditions are evaluated on the server, against the configuration you have saved."}),y.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"Recently seen clients"}),(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["The last ",y.length," user agent",1===y.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,r.jsx)("div",{className:"flex flex-col gap-1",children:y.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>o(e.userAgent),className:"text-left text-xs px-2 py-1.5 rounded bg-[--subtle] hover:bg-[--subtle-highlight] break-all",children:[(0,r.jsx)("span",{className:"font-mono",children:e.userAgent}),(0,r.jsxs)("span",{className:"text-[--muted]",children:[" ","\xb7 ",e.requests," request",1===e.requests?"":"s"," \xb7 last ",new Date(e.lastSeen).toLocaleString()]})]},e.userAgent))})]}),(0,r.jsx)(G,{label:"User agent",value:i,onValueChange:o}),(0,r.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,r.jsx)(r0,{label:"Resource",value:d,onValueChange:c,options:gB.map(e=>({label:e,value:e}))}),(0,r.jsx)(G,{label:"Type",value:u,onValueChange:m}),(0,r.jsx)(G,{label:"Id",value:p,onValueChange:h}),(0,r.jsx)(G,{label:"Query",help:"As it would appear in the URL, e.g. profile=tv&hd=1",value:g,onValueChange:f})]}),(0,r.jsx)("div",{children:(0,r.jsx)(w,{size:"sm",intent:"white",rounded:!0,leftIcon:(0,r.jsx)(lj.aze,{}),onClick:C,disabled:!S||N,children:N?"Evaluating...":"Evaluate"})}),b&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[0===b.variants.length&&(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No variant has an activation condition."}),b.variants.map(e=>(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm px-2 py-1.5 rounded bg-[--subtle]",children:[e.matched?(0,r.jsx)(lj.YrT,{className:"mt-0.5 shrink-0 text-[--green]"}):(0,r.jsx)(lj.yGN,{className:"mt-0.5 shrink-0 text-[--muted]"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("span",{className:"font-medium",children:e.id}),(0,r.jsxs)("span",{className:"text-[--muted] font-mono text-xs break-all",children:[" ",e.when]}),e.error&&(0,r.jsx)("p",{className:"text-xs text-[--red]",children:e.error})]})]},e.id))]}),Object.keys(b.health).length>0&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"Health checks"}),Object.entries(b.health).map(e=>{let[t,s]=e;return(0,r.jsxs)("div",{className:"flex items-start gap-2 text-sm px-2 py-1.5 rounded bg-[--subtle]",children:[s.ok?(0,r.jsx)(lj.YrT,{className:"mt-0.5 shrink-0 text-[--green]"}):(0,r.jsx)(lj.yGN,{className:"mt-0.5 shrink-0 text-[--red]"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("span",{className:"font-medium",children:t}),(0,r.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 gH=/^[a-z0-9][a-z0-9_-]{0,31}$/;function gW(){let{userData:e,setUserData:t}=aY(),{status:s}
45=tr(),[a,l]=(0,n.useState)(null),i=null==s?void 0:s.settings.variants,o=(0,n.useMemo)(()=>({maxScriptLength:(null==i?void 0:i.maxScriptLength)??4e3,maxInstructions:(null==i?void 0:i.maxInstructions)??100,maxValueDepth:(null==i?void 0:i.maxValueDepth)??10,maxPathSegments:(null==i?void 0:i.maxPathSegments)??12,maxPathMatches:(null==i?void 0:i.maxPathMatches)??200}),[i]),d=e.variants??[],c=(null==i?void 0:i.max)??10,u=e=>t(t=>({...t,variants:e}));return(null==i?void 0:i.access)==="none"?(0,r.jsx)(lN,{intent:"info-basic",title:"Variants are disabled",description:"This instance has turned off config variants."}):(null==i?void 0:i.access)!=="trusted"||e.trusted?(0,r.jsxs)("div",{className:"space-y-4",id:"variants",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.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,r.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,r.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/config-expressions",target:"_blank",rel:"noreferrer",className:"underline",children:"Language reference"})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsx)(w,{size:"sm",intent:"white",rounded:!0,leftIcon:(0,r.jsx)(lj.GGD,{}),onClick:()=>{d.length>=c?x.oR.error(`This instance allows at most ${c} variants.`):u([...d,{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}}(d),script:""}])},disabled:d.length>=c,children:"Add variant"}),(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:[d.length," of ",c," used"]})]})]}),d.map((t,s)=>(0,r.jsx)(gG,{variant:t,variants:d,userData:e,limits:o,onChange:e=>u(d.map((t,a)=>a===s?{...t,...e}:t)),onDelete:()=>u(d.filter((e,t)=>t!==s)),onPreview:()=>l(t.id)},s)),0===d.length&&(0,r.jsx)(lN,{intent:"info-basic",title:"No variants yet",description:"Add one to serve a second, adjusted version of this configuration from the same UUID."}),d.length>0&&(0,r.jsx)(gK,{variants:d,healthChecks:e.healthChecks}),(0,r.jsx)(gY,{variantId:a,variants:d,userData:e,limits:o,onClose:()=>l(null)})]}):(0,r.jsx)(lN,{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 gG(e){let{variant:t,variants:s,userData:a,limits:l,onChange:i,onDelete:o,onPreview:d}=e,c=(0,n.useMemo)(()=>gj(t.script,l).diagnostics,[t.script,l]).filter(e=>"error"===e.severity),u=gH.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,r.jsxs)(u6,{title:t.name||t.id,action:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(rZ,{label:"Enabled",side:"right",value:!1!==t.enabled,onValueChange:e=>i({enabled:e})}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(lj.Vap,{}),onClick:d}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(lj.IXo,{}),onClick:o})]}),children:[(0,r.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,r.jsx)(G,{label:"Id",help:"Used in the install URL as ?v=<id>. Changing it breaks existing installs.",value:t.id,error:u,onValueChange:e=>i({id:e.toLowerCase()})}),(0,r.jsx)(G,{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=>i({name:e||void 0})})]}),(0,r.jsx)(G,{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=>i({when:e||void 0})}),(0,r.jsx)(gq,{value:t.script,onValueChange:e=>i({script:e}),limits:l,userData:a,currentVariantId:t.id,placeholder:"# Example: set formatter.id = 'prism' to switch to the built-in Prism formatter."}),(0,r.jsxs)("div",{className:"flex items-center justify-between text-xs text-[--muted]",children:[(0,r.jsxs)("span",{children:[t.script.length," / ",l.maxScriptLength," characters"]}),(0,r.jsx)("span",{className:c.length?"text-[--red]":void 0,children:c.length?`${c.length} error${1===c.length?"":"s"}`:"No errors"})]})]})}function gY(e){let{variantId:t,variants:s,userData:a,limits:l,onClose:i}
45=e,[o,d]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=s.find(e=>e.id===t);e&&d(e)},[t,s]);let c=(0,n.useMemo)(()=>{if(!o)return null;let{program:e,diagnostics:t}=gj(o.script,l),r=t.filter(e=>"error"===e.severity);if(r.length)return{errors:r,notes:[],patched:null};let n=new Map(s.map(e=>[e.id,gj(e.script,l).program])),i=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,n,l,i){let o=a.maxDepth??5,d=a.limits??ge;for(let x of s.statements){var c,u,m,p,h;if("useVariant"===x.op){if(i>=o){r.push(gR(x,`variant nesting exceeds the maximum depth of ${o}`,"limit"));continue}if(l.has(x.id)){r.push(gR(x,`variant "${x.id}" is already being applied`,"unknown-variant"));continue}let s=null==(c=a.resolveVariant)?void 0:c.call(a,x.id);if(!s){r.push(gR(x,`unknown variant "${x.id}"`,"unknown-variant"));continue}l.add(x.id),e(t,s,a,r,n,l,i+1),l.delete(x.id);continue}if("useFormatter"===x.op){let e=null==t||null==(p=t.formatter)||null==(m=p.definitions)||null==(u=m.saved)?void 0:u[x.name];if(!e){r.push(gR(x,`no saved formatter named "${x.name}"`,"unknown-formatter"));continue}t.formatter={...t.formatter,id:"custom",selectedSaved:void 0,definitions:{...null==(h=t.formatter)?void 0:h.definitions,custom:{
45name:e.name,description:e.description}}},n.add("formatter");continue}let s="set"===x.op||"merge"===x.op||"add"===x.op||"prepend"===x.op||"enable"===x.op||"disable"===x.op,g=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=function(e,t,s){let a=[];for(let r of e)switch(t.kind){case"key":if(!gw(r))break;void 0===r[t.name]&&void 0!==s&&gS(r,t.name,s),void 0!==r[t.name]&&a.push(r[t.name]);break;case"index":{if(!Array.isArray(r))break;let e=gC(t.index,r.length);void 0!==e&&a.push(r[e]);break}case"all":Array.isArray(r)&&a.push(...r);break;case"filter":Array.isArray(r)&&a.push(...r.filter(e=>g_(e,t)))}return a}(n,a[e],t)).length)return[]}let l=[];for(let e of n)switch(r.kind){case"key":gw(e)&&l.push({container:e,key:r.name});break;case"index":{if(!Array.isArray(e))break;let t=gC(r.index,e.length);void 0!==t&&l.push({container:e,key:t});break}case"all":Array.isArray(e)&&e.forEach((t,s)=>l.push({container:e,key:s}));break;case"filter":Array.isArray(e)&&e.forEach((t,s)=>
45{g_(t,r)&&l.push({container:e,key:s})})}return l}(t,"enable"===x.op||"disable"===x.op?{...x.path,segments:[...x.path.segments,{kind:"key",name:"enabled"}]}:x.path,s);if(0===g.length){r.push(gR(x,`"${x.path.raw}" matched nothing, instruction skipped`,"no-match"));continue}if(g.length>d.maxPathMatches){r.push(gR(x,`"${x.path.raw}" matched ${g.length} places, over the limit of ${d.maxPathMatches}`,"limit"));continue}switch(x.op){case"set":for(let e of g)gS(e.container,e.key,gN(x.value));break;case"enable":case"disable":for(let e of g)gS(e.container,e.key,"enable"===x.op);break;case"merge":for(let e of g)gS(e.container,e.key,function e(t,s){if(!gw(s))return gN(s);let a=gw(t)?{...t}:{};for(let[t,r]of Object.entries(s))gs.has(t)||(null===r?delete a[t]:a[t]=e(a[t],r));return a}(e.container[e.key],x.value));break;case"unset":gA(g);break;case"clear":for(let e of g){let t=e.container[e.key];Array.isArray(t)?gS(e.container,e.key,[]):gw(t)?gS(e.container,e.key,{}):r.push(gR(x,`"${x.path.raw}" is not a list or object, clear skipped`,"no-match"))}break;case"add":case"prepend":for(let e of g){let t=e.container[e.key];if(void 0===t&&(t=[],gS(e.container,e.key,t)),!Array.isArray(t)){r.push(gR(x,`"${x.path.raw}" is not a list, ${x.op} skipped`,"no-match"));continue}let s=x.values.filter(e=>!t.some(t=>gk(t,e))).map(gN);"add"===x.op?t.push(...s):t.unshift(...s)}break;case"remove":if(0===x.values.length){gA(g);break}for(let e of g){let t=e.container[e.key];if(!Array.isArray(t)){r.push(gR(x,`"${x.path.raw}" is not a list, remove skipped`,"no-match"));continue}gS(e.container,e.key,t.filter(e=>!x.values.some(t=>gk(e,t))))}}n.add(x.path.root)}}(e,t,s,a,r,new Set(s.activeVariants??[]),0),{notes:a,touchedRoots:r}}(a,t,s)}}(a,e,{resolveVariant:e=>n.get(e),limits:l});return{errors:[],notes:i.notes,patched:i.userData}},[o,s,a,l]);return(0,r.jsx)(tJ,{open:null!==t,onOpenChange:e=>!e&&i(),title:`Preview: ${(null==o?void 0:o.name)||(null==o?void 0:o.id)||""}`,contentClass:"max-w-4xl",children:(null==c?void 0:c.errors.length)?(0,r.jsx)(lN,{intent:"alert",title:"This script does not parse",description:c.errors.map(e=>`Line ${e.line}: ${e.message}`).join("\n")}):(0,r.jsxs)("div",{className:"space-y-3",children:[(null==c?void 0:c.notes.length)?(0,r.jsx)(lN,{intent:"warning",title:"Some instructions matched nothing",description:c.notes.map(e=>`Line ${e.line}: ${e.message}`).join("\n")}):null,(0,r.jsx)(uu,{oldConfig:a,newConfig:(null==c?void 0:c.patched)??null})]})})}let gJ=/^[a-z0-9][a-z0-9_-]{0,31}$/;function gZ(){let{userData:e,setUserData:t}=aY(),{status:s}=tr(),a=null==s?void 0:s.settings.healthChecks,l=e.healthChecks??[],i=(null==a?void 0:a.max)??5,[o,d]=(0,n.useState)(null),[c,u]=(0,n.use
45State)(null),m=e=>t(t=>({...t,healthChecks:e}));return(null==a?void 0:a.access)==="none"?(0,r.jsx)(lN,{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,r.jsxs)("div",{className:"space-y-4",id:"healthChecks",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.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,r.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,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsx)(w,{size:"sm",intent:"white",rounded:!0,leftIcon:(0,r.jsx)(lj.GGD,{}),onClick:()=>{l.length>=i?x.oR.error(`This instance allows at most ${i} health checks.`):(u((e=>{let t="check";for(let s=2;e.some(e=>e.id===t);s++)t=`check-${s}`;return{id:t,url:""}})(l)),d(l.length))},disabled:l.length>=i,children:"Add health check"}),(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:[l.length," of ",i," used"]})]})]}),l.map((e,t)=>(0,r.jsx)(gQ,{check:e,onEdit:()=>{u({...l[t]}),d(t)},onDelete:()=>m(l.filter((e,s)=>s!==t))},t)),0===l.length&&(0,r.jsx)(lN,{intent:"info-basic",title:"No health checks yet",description:"Add one to let a condition react to whether a service is reachable."}),(0,r.jsx)(gX,{draft:c,limits:a,onChange:u,onClose:()=>{d(null),u(null)},onSave:()=>{if(!c)return;if(!gJ.test(c.id))return void x.oR.error('Use 1-32 characters: lowercase letters, digits, "-" or "_".');if(l.some((e,t)=>e.id===c.id&&t!==o))return void x.oR.error("Another health check already uses this id.");if(!c.url.trim())return void x.oR.error("A health check needs a URL.");let e=[...l];null!==o&&o<l.length?e[o]=c:e.push(c),m(e),d(null),u(null)}})]}):(0,r.jsx)(lN,{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 gQ(e){let{check:t,onEdit:s,onDelete:a}=e;return(0,r.jsx)(u6,{title:t.name||t.id,description:t.url,action:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(lj.WXf,{}),onClick:s}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(lj.IXo,{}),onClick:a})]}),children:(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["Referenced as"," ",(0,r.jsxs)("span",{className:"font-mono",children:["health('",t.id,"')"]})]})})}function gX(e){var t,s,a,l;let{draft:i,limits:o,onChange:d,onClose:c,onSave:u}=e,{uuid:m,password:p}=aY(),[h,g]=(0,n.useState)(null),[f,b]=(0,n.useState)(!1);if(!i)return null;let v=e=>d({...i,...e}),y=e=>d({...i,expect:{...i.expect,...e}}),j=async()=>{if(!m)return void x.oR.error("Save this configuration before testing a health check.");b(!0);try{g(await ew(m,p,i))}catch(e){g(null),x.oR.error((null==e?void 0:e.message)??"Could not run the health check")}finally{b(!1)}};return(0,r.jsx)(tJ,{open:!0,onOpenChange:c,title:"Health check",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,r.jsx)(G,{label:"Id",help:"Used as health('id') in conditions.",value:i.id,onValueChange:e=>v({id:e.toLowerCase()})}),(0,r.jsx)(G,{label:"Name",help:"A label for this list.",value:i.name??"",onValueChange:e=>v({name:e||void 0})})]}),(0,r.jsx)(G,{label:"URL",placeholder:"https://status.example.com/api/health",value:i.url,onValueChange:e=>v({url:e})}),(0,r.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,r.jsx)(r0,{label:"Method",value:i.method??"GET",onValueChange:e=>v({method:e}),options:[{label:"GET",value:"GET"},{label:"HEAD",value:"HEAD"}]}),(0,r.jsx)(G,{label:"Expected status",help:"A code (200), a class (2xx) or a range (200-299).",placeholder:"2xx",value:(null==(t=i.expect)?void 0:t.status)??"",onValueChange:e=>y({status:e||void 0})})]}),(0,r.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,r.jsx)(G,{label:"JSON path",help:"Optional. A dotted path into a JSON body, e.g. data.status.",value:(null==(s=i.expect)?void 0:s.jsonPath)??"",onValueChange:e=>y({jsonPath:e||void 0})}),(0,r.jsx)(G,{label:"Expected value",help:"Optional. Compared to the value at that path. Leave empty to require any truthy value.",value:(null==(a=i.expect)?void 0:a.jsonValue)===void 0?"":String(i.expect.jsonValue),onValueChange:e=>{if(!e)return y({jsonValue:void 0});if("true"===e||"false"===e)return y({jsonValue:"true"===e});let t=Number(e);y({jsonValue:""===e.trim()||Number.isNaN(t)?e:t})}})]}),(0,r.jsx)(G,{label:"Body contains",help:"Optional. Text the response body must contain, ignoring case.",placeholder:"operational",value:(null==(l=i.expect)?void 0:l.bodyContains)??"",onValueChange:e=>y({bodyContains:e||void 0})}),(0,r.jsxs)("div",{className:"grid gap-3 md:grid-cols-3",children:[(0,r.jsx)(n1,{label:"Interval (seconds)",help:`How long a result is reused. Minimum ${(null==o?void 0:o.minTtl)??60}.`,value:i.ttl??300,onValueChange:e=>v({ttl:e||void 0})}),(0,r.jsx)(n1,{label:"Timeout (ms)",help:`Maximum ${(null==o?void 0:o.maxTimeout)??1e4}.`,value:i.timeout??3e3,onValueChange:e=>v({timeout:e||void 0})}),(0,r.jsx)(r0,{label:"If the check fails",help:"When the request times out or cannot be made at all.",value:i.onError??"unhealthy",onValueChange:e=>v({onError:e}),options:[{label:"Treat as down",value:"unhealthy"},{label:"Treat as up",value:"healthy"}]})]}),h&&(0,r.jsx)(lN,{intent:h.ok?"success-basic":"warning-basic",title:h.ok?"Healthy":"Not healthy",description:[h.status?`HTTP ${h.status}`:null,h.error,`${h.latencyMs}
45 ms`].filter(Boolean).join(" \xb7 ")}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"white-subtle",leftIcon:(0,r.jsx)(lj.z1n,{}),onClick:j,disabled:f||!i.url.trim(),children:f?"Testing...":"Test now"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",onClick:c,children:"Cancel"}),(0,r.jsx)(w,{size:"sm",intent:"primary",onClick:u,children:"Save"})]})]})]})})}function g0(){return(0,r.jsx)(r6,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(g1,{})})}function g1(){let{mode:e}=sy(),{tab:t,setTab:s}=a9("miscellaneous");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Miscellaneous"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Additional settings and configurations."})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(uw,{})})]}),(0,r.jsx)(uT,{tabs:[{value:"background",label:"Background",icon:(0,r.jsx)(mu.uoG,{className:"w-4 h-4"}),content:(0,r.jsx)(xY,{})},{value:"playback",label:"Playback",icon:(0,r.jsx)(mu.gSK,{className:"w-4 h-4"}),content:"pro"===e?(0,r.jsx)(xJ,{}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,r.jsx)(lj.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,r.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Playback settings are only available in Advanced mode."})]})},{value:"display",label:"Display",icon:(0,r.jsx)(mu.Ny1,{className:"w-4 h-4"}),content:"pro"===e?(0,r.jsx)(xZ,{}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,r.jsx)(lj.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,r.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Display settings are only available in Advanced mode."})]})},{value:"parent",label:"Parent Config",icon:(0,r.jsx)(lj.ayE,{className:"w-4 h-4"}),content:(0,r.jsx)(x7,{})},{value:"variants",label:"Variants",icon:(0,r.jsx)(lj.s_k,{className:"w-4 h-4"}),content:"pro"===e?(0,r.jsx)(gW,{}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,r.jsx)(lj.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,r.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Variants are only available in Advanced mode."})]})},{value:"health-checks",label:"Health Checks",icon:(0,r.jsx)(lj.z1n,{className:"w-4 h-4"}),content:"pro"===e?(0,r.jsx)(gZ,{}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,r.jsx)(lj.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,r.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Health checks are only available in Advanced mode."})]})}],activeTab:t,onTabChange:s})]})}var g2=s(30028),g3=s(41131),g5=s(41896),g4=s(69799);let g6=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;function g9(e){return e.split(",").map(e=>decodeURIComponent(e).trim()).filter(Boolean)}function g8(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?g9(a):[]}function g7(){let{user:e}=t1(),{uuid:t,password:s}=aY(),a=(0,o.jE)(),{data:l}=(0,ta.I)({...e6,enabled:!!e}),i=(null==l?void 0:l.profiles.find(e=>e.uuid===t))??null,[d,c]=n.useState(""),[u,m]=n.useState(""),[p,h]=n.useState(!1);if(n.useEffect(()=>{c((null==i?void 0:i.label)??""),m((null==i?void 0:i.alias)??"")},[null==i?void 0:i.id,null==i?void 0:i.label,null==i?void 0:i.alias]),!e||!t||!s)return null;let g=async(e,t)=>{h(!0);try{await e(),await a.invalidateQueries({queryKey:e6.queryKey}),x.oR.success(t)}catch(e){x.oR.error(e instanceof Error?e.message:"Something went wrong")}finally{h(!1)}};return(0,r.jsx)(u6,{title:"Profile",description:i?`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:i?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end gap-2",children:[(0,r.jsx)(G,{label:"Name",value:d,onValueChange:c,className:"flex-1"}),(0,r.jsx)(w,{intent:"gray-subtle",rounded:!0,loading:p,disabled:!d.trim()||d.trim()===i.label,onClick:()=>g(()=>eA(i.id,{label:d.trim()}),"Renamed"),children:"Rename"})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end gap-2",children:[(0,r.jsx)(G,{label:"Share alias",value:u,onValueChange:m,placeholder:"Optional, e.g. living-room",className:"flex-1"}),(0,r.jsx)(w,{intent:"gray-subtle",rounded:!0,loading:p,disabled:u.trim().toLowerCase()===(i.alias??""),onClick:()=>g(()=>eA(i.id,{alias:u.trim()?u.trim():null}),u.trim()?"Alias set":"Alias removed"),children:u.trim()?"Set alias":"Clear alias"})]}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:i.alias?"Your manifest URL above uses 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 above. It replaces the UUID and password in the link, so it grants the same access."})]}),(0,r.jsx)(w,{intent:"alert-subtle",rounded:!0,size:"sm",loading:p,onClick:()=>g(()=>eR(i.id),"Profile deleted. The configuration itself is untouched."),children:"Delete profile"})]}):(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end gap-2",children:[(0,r.jsx)(G,{label:"Name",value:d,onValueChange:c,placeholder:"Optional",className:"flex-1"}),(0,r.jsx)(w,{intent:"white",rounded:!0,loading:p,onClick:()=>g(()=>e_(t,s,d.trim()||void 0),"Saved to your profile"),children:"Save as profile"})]})})}let fe=e=>b("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 ft(e){let{variants:t,value:s,onChange:a,className:n}=e;return(0,r.jsxs)("div",{className:b("flex flex-wrap gap-1.5",n),children:[(0,r.jsx)("button",{type:"button",onClick:()=>a([]),className:fe(0===s.length),children:"Base config"}),t.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>{let t;return t=e.id,a(s.includes(t)?s.filter(e=>e!==t):[...s,t])},className:fe(s.includes(e.id)),title:e.when?"Also applies on its own when its condition matches":void 0,children:[e.name||e.
45id,e.when?(0,r.jsx)("span",{className:"ml-1 opacity-60",children:"auto"}):null]},e.id))]})}function fs(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??(g6.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 fa(e){let{variants:t,value:s,onChange:a,baseUrl:n,uuid:l,encryptedPassword:i,alias:o}=e,d=t.filter(e=>!1!==e.enabled);if(0===d.length)return null;let c=s.length>0?s:[[]],u=fs(c,{baseUrl:n,uuid:l,encryptedPassword:i,alias:o});return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"What to push"}),(0,r.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,r.jsx)("div",{className:"space-y-2",children:c.map((e,t)=>(0,r.jsx)("div",{className:"rounded-lg border border-gray-700 bg-gray-800/40 p-2.5",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(ft,{className:"flex-1",variants:d,value:e,onChange:e=>a(c.map((s,a)=>a===t?e:s))}),c.length>1&&(0,r.jsx)(E,{intent:"gray-basic",size:"sm","aria-label":"Remove",icon:(0,r.jsx)(J.SXS,{}),onClick:()=>a(c.filter((e,s)=>s!==t))})]})},t))}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>a([...c,[]]),className:"flex items-center gap-1 text-xs text-gray-400 hover:text-[--brand]",children:[(0,r.jsx)(J._rf,{className:"h-3 w-3"})," Add another addon"]}),(0,r.jsxs)("span",{className:"text-xs text-gray-500",children:[u.length," addon",1===u.length?"":"s"]})]})]})}function fr(e){var t;return{mode:(null==(t=e.authMethods[0])?void 0:t.id)??"",values:{}}}function fn(e,t){let s=e.authMethods.find(e=>e.id===t.mode);return[...e.commonFields??[],...(null==s?void 0:s.fields)??[]]}function fl(e,t){let s={mode:t.mode};for(let a of fn(e,t))s[a.key]=(t.values[a.key]??"").trim();return s}function fi(e,t){return fn(e,t).every(e=>e.optional||(t.values[e.key]??"").trim())}function fo(e){let{platform:t,value:s,onChange:a}=e,n=t.authMethods.find(e=>e.id===s.mode),l=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,r.jsx)(Z,{...t}):(0,r.jsx)(G,{...t,type:"email"===e.type?"email":"text"})};return(0,r.jsxs)(r.Fragment,{children:[(t.commonFields??[]).map(l),t.authMethods.length>1&&(0,r.jsx)(r0,{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==n?void 0:n.fields)??[]).map(l),(null==n?void 0:n.note)&&(0,r.jsx)("p",{className:"text-xs text-gray-500",children:n.note})]})}function fd(e,t){return e instanceof Error&&e.message?e.message:t}function fc(e){var t;let{manifestUrl:s}=e,{uuid:a,password:l,encryptedPassword:i,userData:d}=aY(),{currentManifestFingerprint:c,currentManifestUrl:u}=uj(),{status:m}=tr(),p={baseUrl:(null==m||null==(t=m.settings)?void 0:t.baseUrl)||("u">typeof window?window.location.origin:""),uuid:a??"",encryptedPassword:i??void 0},h=d.variants??[],g=a?{uuid:a,password:l}:null,f=(0,o.jE)(),{data:b,isPending:v}=(0,ta.I)(e9(g)),{data:y=[]}=(0,ta.I)(e7(g)),j=e=>y.find(t=>t.id===e)??null,[N,k]=n.useState(null),[C,_]=n.useState(null),A=tQ(!1),R=()=>f.invalidateQueries({queryKey:e8});if(!g)return null;let T=async e=>{k(e.id);try{await eX(g,e.id),x.oR.success(`Pushed to ${e.label}`)}catch(t){x.oR.error(fd(t,`Could not push to ${e.label}`))}finally{k(null),R()}},I=((null==b?void 0:b.length)??0)>0;return(0,r.jsxs)("div",{id:"linked-accounts",children:[(0,r.jsxs)("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-px bg-gray-700 flex-1"}),"Linked accounts",(0,r.jsx)("div",{className:"h-px bg-gray-700 flex-1"})]}),v?(0,r.jsx)("div",{className:"flex justify-center py-4",children:(0,r.jsx)(S,{})}):I?(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(b??[]).map(e=>{var t;let s;return(0,r.jsx)(fu,{account:e,platform:j(e.platform),stale:(s=(null==(t=e.config)?void 0:t.manifestUrls)??[],!!u&&!!c&&!!e.lastPushedManifestHash&&1===s.length&&s[0]===u&&e.lastPushedManifestHash!==c),busy:N===e.id,onPush:()=>T(e),onManage:()=>_(e)},e.id)}),(0,r.jsxs)("button",{type:"button",onClick:A.open,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 hover:border-brand-400 hover:text-brand-400",children:[(0,r.jsx)(J.sDI,{className:"h-4 w-4"})," Link another account"]})]}):(0,r.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,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,r.jsx)(J.sDI,{className:"h-4 w-4 shrink-0 text-gray-500"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"text-sm text-gray-300",children:"Keep AIOStreams up to date automatically"}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:["Optional. Link ",`to one of the supported platforms (e.g. ${y.slice(0,3).map(e=>e.name).join(", ")})`," and AIOStreams can push config changes for you, instead of you reinstalling by hand."]})]})]}),(0,r.jsx)(w,{intent:"gray-outline",className:"w-full sm:w-auto",onClick:A.open,children:"Link an account"})]}),(0,r.jsx)(fm,{variants:h,urlParts:p,open:A.isOpen,onOpenChange:e=>e?A.open():A.close(),credentials:g,manifestUrl:s,onLinked:()=>{A.close(),R()}}
45),(0,r.jsx)(fp,{variants:h,urlParts:p,account:C,platform:C?j(C.platform):null,credentials:g,onClose:()=>_(null),onChanged:()=>{_(null),R()}})]})}function fu(e){let{account:t,platform:s,stale:a,busy:n,onPush:l,onManage:i}=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,r.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,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,r.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,r.jsx)("img",{src:s.logo,alt:s.name,className:"h-full w-full object-contain"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"truncate text-sm font-medium text-white",children:t.label}),(0,r.jsx)("span",{title:m,className:`h-1.5 w-1.5 shrink-0 rounded-full ${u}`})]}),(0,r.jsx)("p",{className:"truncate text-xs text-gray-500",children:m})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 lg:shrink-0",children:[(0,r.jsx)(w,{intent:"primary-subtle",size:"sm",className:"flex-1 lg:flex-none",loading:n,onClick:l,leftIcon:(0,r.jsx)(J.JbZ,{className:"h-3.5 w-3.5"}),children:"Push"}),(0,r.jsx)(E,{intent:"gray-basic",size:"sm","aria-label":`Manage ${t.label}`,icon:(0,r.jsx)(J.xPd,{}),onClick:i})]})]})}function fm(e){let{variants:t,urlParts:s,open:a,onOpenChange:l,credentials:i,manifestUrl:o,onLinked:d}=e,{data:c=[]}=(0,ta.I)(e7(i)),[u,m]=n.useState(null),p=c.find(e=>e.id===u)??c[0]??null,[h,g]=n.useState(null),[f,b]=n.useState([[]]),[v,y]=n.useState(!1),[j,N]=n.useState({state:"idle"});n.useEffect(()=>{g(p?fr(p):null),N({state:"idle"})},[null==p?void 0:p.id]);let k=(null==p?void 0:p.probeOn)?((null==h?void 0:h.values[p.probeO
45n])??"").trim().replace(/\/+$/,""):"";n.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 eY(i,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:fd(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||!h)return;let e=t.length?fs(f,s):[o];y(!0);try{let t=await eJ(i,{platform:p.id,input:fl(p,h),manifestUrls:e});x.oR.success(`Linked ${t.label}`),d()}catch(e){x.oR.error(fd(e,"Could not link that account"))}finally{y(!1)}},C=!!p&&!!h&&fi(p,h)&&(!p.probeOn||"ok"===j.state);return(0,r.jsx)(tJ,{open:a,onOpenChange:l,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,r.jsxs)("div",{className:"min-w-0 space-y-4",children:[c.length>1&&(0,r.jsx)(r0,{label:"Platform",value:(null==p?void 0:p.id)??"",onValueChange:m,options:c.map(e=>({value:e.id,label:e.name}))}),p&&h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-xs text-gray-400",children:p.description}),(0,r.jsx)(fo,{platform:p,value:h,onChange:g}),"checking"===j.state&&(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Checking…"}),"bad"===j.state&&(0,r.jsx)(lN,{intent:"warning",description:j.message}),"ok"===j.state&&(0,r.jsx)("p",{className:"text-xs text-emerald-400",children:j.message})]}),t.length>0?(0,r.jsx)(fa,{variants:t,value:f,onChange:b,...s}):(0,r.jsxs)("div",{className:"min-w-0 rounded-lg bg-gray-900/40 p-3",children:[(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Will keep this URL up to date"}),(0,r.jsx)("p",{className:"break-all font-mono text-xs text-gray-400",children:o})]}),(0,r.jsx)(w,{className:"w-full",intent:"primary",disabled:!C,loading:v,onClick:S,children:"Link account"})]})})}function fp(e){var t;let{variants:s,urlParts:a,account:l,platform:i,credentials:o,onClose:d,onChanged:c}=e,[u,m]=n.useState(""),[p,h]=n.useState(!0),[g,f]=n.useState([[]]),[b,v]=n.useState(!1),y=tX({title:"Unlink account",description:(null==l||null==(t=l.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(l)try{await eQ(o,l.id),x.oR.success("Account unlinked"),c()}catch(e){x.oR.error(fd(e,"Could not unlink that account"))}}});n.useEffect(()=>{var e;if(!l)return;m(l.label),h(l.autoPush);let t=(null==(e=l.config)?void 0:e.manifestUrls)??[];f(t.length?t.map(g8):[[]])},[l]);let j=async()=>{if(l){v(!0);try{await eZ(o,l.id,{label:u,autoPush:p,...s.length?{manifestUrls:fs(g,a)}:{}}),x.oR.success("Saved"),c()}catch(e){x.oR.error(fd(e,"Could not save those changes"))}finally{v(!1)}}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tJ,{open:null!==l,onOpenChange:e=>{e||d()},title:(null==i?void 0:i.name)??(null==l?void 0:l.label)??"",description:(null==l?void 0:l.identity)??void 0,contentClass:"max-w-md",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(G,{label:"Name",value:u,onValueChange:m}),(0,r.jsx)(fa,{variants:s,value:g,onChange:f,...a}),(0,r.jsxs)("div",{className:"flex items-center justify-between rounded-lg bg-gray-800/50 p-3",children:[(0,r.jsxs)("div",{className:"flex-1 pr-3",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white",children:"Include in automatic pushes"}),(0,r.jsx)("div",{className:"mt-1 text-xs text-gray-400",children:"Only applies when you have turned automatic pushing on."})]}),(0,r.jsx)(rZ,{id:"linked-account-auto-push",value:p,onValueChange:h})]}),(0,r.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,r.jsx)(w,{intent:"alert-subtle",onClick:y.open,children:"Unlink"}),(0,r.jsx)(w,{intent:"primary",loading:b,onClick:j,children:"Save"})]})]})}),(0,r.jsx)(t0,{...y})]})}let fh="aiostreams:linked-accounts:offer-dismissed";function fx(e){let{open:t,onOpenChange:s,credentials:a,manifestUrl:l}=e,i=(0,o.jE)(),{data:d=[]}=(0,ta.I)(e7(a)),c=d.filter(e=>"client"===e.kind),[u,m]=n.useState(null),p=c.find(e=>e.id===u)??c[0]??null,[h,g]=n.useState(null),[f,b]=n.useState(!1),[v,y]=n.useState(null);n.useEffect(()=>{g(p?fr(p):null)},[null==p?void 0:p.id]);let j=e=>{e&&localStorage.setItem(fh,"true"),s(!1)},N=async()=>
45{if(p&&h){b(!0);try{let e=await eJ(a,{platform:p.id,input:fl(p,h),manifestUrls:[l]});await eX(a,e.id),await i.invalidateQueries({queryKey:e8}),y(e.identity??p.name),x.oR.success(`AIOStreams installed to ${e.identity??p.name}`)}catch(e){x.oR.error(e instanceof Error?e.message:`Could not link your ${p.name} account`)}finally{b(!1)}}};return p?(0,r.jsx)(tJ,{open:t,onOpenChange:e=>{e||j(!1)},title:v?"All set":`Install to ${p.name}?`,description:v?void 0:p.description,contentClass:"max-w-lg",children:v?(0,r.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,r.jsx)(lN,{intent:"success",title:`AIOStreams is installed to ${v}.`,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,r.jsx)(w,{intent:"primary",className:"w-full",onClick:()=>j(!1),children:"Done"})]}):(0,r.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-gray-700 bg-gray-800/40 p-3",children:[p.logo&&(0,r.jsx)("img",{src:p.logo,alt:p.name,className:"h-8 w-8 shrink-0 object-contain"}),(0,r.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."})]}),c.length>1&&(0,r.jsx)(r0,{label:"Install to",value:p.id,onValueChange:m,options:c.map(e=>({value:e.id,label:e.name}))}),h&&(0,r.jsx)(fo,{platform:p,value:h,onChange:g}),(0,r.jsx)(lN,{intent:"info-basic",description:(0,r.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,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)(w,{intent:"primary",className:"w-full",disabled:!h||!fi(p,h),loading:f,onClick:N,leftIcon:(0,r.jsx)(J.JbZ,{className:"h-4 w-4"}),children:["Install to ",p.name]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("button",{type:"button",onClick:()=>j(!1),className:"text-xs text-gray-400 hover:text-white",children:"Not now"}),(0,r.jsx)("button",{type:"button",onClick:()=>j(!0),className:"text-xs text-gray-500 hover:text-white",children:"Don't show this again"})]})]})]})}):null}function fg(e){let{onClick:t,icon:s,title:a,description:n}=e;return(0,r.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,r.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,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-bold text-white",children:a}),(0,r.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-gray-400",children:n})]})]})}function ff(e){let{logoSrc:t,icon:s,name:a,description:n,onClick:l,unofficial:i,beta:o,author:d,disabled:c,disabledReason:u}=e;return(0,r.jsxs)("button",{onClick:l,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,r.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,r.jsx)("img",{src:t,alt:a,className:"h-full w-full object-contain"}):s}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-white",children:a}),o&&(0,r.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"}),i&&(0,r.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,r.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:n}),d&&(0,r.jsxs)("p",{className:"text-[11px] text-gray-500 mt-0.5",children:["Integration author: ",d]}),u&&(0,r.jsx)("p",{className:"text-[11px] text-amber-300 mt-1",children:u})]})]})}function fb(e){let{onSubmit:t,passwordRequirements:s,newPassword:a,confirmNewPassword:n,onNewPasswordChange:l,onConfirmNewPasswordChange:i,createLoading:o}=e;return(0,r.jsx)(u6,{title:"Create Configuration",description:"Set up your personalised addon configuration",children:(0,r.jsxs)("form",{onSubmit:t,className:"space-y-4",children:[(0,r.jsxs)("div",{children:[s.length>0&&(null==a?void 0:a.length)>0&&(0,r.jsx)(lN,{intent:"alert",title:"Password Requirements",description:(0,r.jsx)("ul",{className:"list-disc list-inside",children:s.map(e=>(0,r.jsx)("li",{children:e},e))})}),(0,r.jsx)(Z,{label:"Password",id:"password",name:"new-password",value:a,onValueChange:l,placeholder:"Enter a password to protect your configuration",required:!0,autoComplete:"new-password"}),(0,r.jsx)("div",{className:"pt-2",children:(0,r.jsx)(Z,{label:"Confirm Password",id:"confirm-password",name:"confirm-new-password",value:n,onValueChange:i,placeholder:"Re-enter your password",required:!0,autoComplete:"new-password"})}),(0,r.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,r.jsx)(w,{intent:"white",type:"submit",loading:o,rounded:!0,children:"Create"})]})})}function fv(e){let{open:t,onOpenChange:s,showChanges:a,onShowChangesChange:n,manifestNotice:l,onManifestNoticeChange:i,pushBehaviour:o,onPushBehaviourChange:d,hasLinkedAccounts:c}=e;return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"Save preferences",description:"These apply wherever you open this configuration. Remember to save.",contentClass:"max-w-lg",children:(0,r.jsxs)("div",{className:"min-w-0 space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1 pr-3",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white",children:"Show changes before saving"}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Review a diff of what you changed before it is 
45written"})]}),(0,r.jsx)(rZ,{id:"show-changes",value:a,onValueChange:n})]}),(0,r.jsx)(r0,{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:l,onValueChange:e=>i(e),options:[{value:"always",label:"On every change"},{value:"significant",label:"Only significant changes"},{value:"never",label:"Never"}]}),c&&(0,r.jsx)(r0,{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 fy(e){let{uuid:t,onCopyUuid:s,onSave:a,saveLoading:n,onOpenPreferences:l}=e;return(0,r.jsxs)(u6,{title:"Save Configuration",description:"Save your configuration to your account by clicking Save below.",children:[(0,r.jsx)("div",{className:"flex items-start gap-1",children:(0,r.jsx)(lN,{intent:"info",isClosable:!1,description:(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-md text-[--primary]",children:["Your UUID: ",(0,r.jsx)("span",{className:"font-bold",children:t})]}),(0,r.jsx)(t2.Xpf,{className:"min-h-5 min-w-5 cursor-pointer",onClick:s})]}),(0,r.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,r.jsx)("form",{onSubmit:a,children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 mt-4",children:[(0,r.jsx)(w,{type:"submit",intent:"white",loading:n,rounded:!0,children:"Save"}),(0,r.jsx)(w,{type:"button",intent:"gray-outline",size:"sm",rounded:!0,leftIcon:(0,r.jsx)(g2.A,{className:"h-4 w-4"}),onClick:l,children:"Preferences"})]})})]})}let fj=[{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 fw(){return(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2 pt-1.5 ml-1",children:fj.map(e=>(0,r.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,r.jsx)("img",{src:e.logoSrc,alt:e.name,className:`h-full w-full object-contain ${e.imgClassName??""}`})},e.name))})}function fN(e){let{variants:t,selected:s,onChange:a,location:n,onLocationChange:l}=e;return(0,r.jsxs)("div",{className:"w-full rounded-xl border border-gray-700 bg-gray-800/30 p-5 shadow-inner",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Variant"}),(0,r.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,r.jsx)(ft,{className:"mt-4",variants:t,value:s,onChange:a}),s.length>0&&(0,r.jsx)("div",{className:"mt-5 pt-4 border-t border-gray-700/50 max-w-md",children:(0,r.jsx)(r0,{label:"Selector location",help:"path"===n?"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:n,onValueChange:e=>l(e),options:[{value:"path",label:"Path segment (/v/)"},{value:"query",label:"Query parameter (?v=)"}]})})]})}function fk(e){let{encodedManifest:t,manifestUrl:s,usingAlias:a,variantSelector:n,onCopyManifestUrl:l,onOpenChillio:i,onOpenSeanime:o,onOpenJellyfin:d,onOpenAniyomi:c,onOpenNabIndexer:u,onOpenSearchApi:m,disableSeanimeCard:p,seanimeDisabledReason:h,disableNabIndexerCard:x,nabIndexerDisabledReason:g,disableSearchApiCard:f,searchApiDisabledReason:b}=e;return(0,r.jsx)(u6,{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,r.jsxs)("div",{className:"flex flex-col gap-6",children:[n,(0,r.jsx)("div",{className:"w-full rounded-xl border border-gray-700 bg-gray-800/30 p-5 shadow-inner",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-8 lg:items-center",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.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,r.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,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Stremio"}),(0,r.jsx)("p",{className:"text-sm text-gray-400",children:"Install to Stremio or other Stremio addon compatible clients using the Manifest URL."})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,r.jsx)(w,{onClick:()=>window.open(s.replace(/^https?:\/\//,"stremio://")),intent:"primary",className:"w-full shadow-md",children:"Install to Stremio"}),(0,r.jsx)(w,{onClick:()=>window.open(`https://web.stremio.com/#/addons?addon=${t}`),intent:"gray-outline",className:"w-full",children:"Install to Stremio Web"})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5 lg:border-l lg:border-gray-700/50 lg:pl-8",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-gray-400 ml-1",children:a?"Manifest URL (alias)":"Direct Manifest URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{type:"text",readOnly:!0,value:s,className:"flex-1 font-mono text-sm bg-black/20",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:l,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy install link",children:(0,r.jsx)(g3.A,{className:"h-4 w-4"})})]}),(0,r.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,r.jsx)(fw,{})]})]})}),(0,r.jsx)(fc,{manifestUrl:s}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-px bg-gray-700 flex-1"}),"Other apps",(0,r.jsx)("div",{className:"h-px bg-gray-700 flex-1"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,r.jsx)(ff,{logoSrc:"https://seanime.app/seanime-logo.png",name:"Seanime",description:"Anime-focused client",onClick:o,disabled:p,disabledReason:h}),(0,r.jsx)(ff,{logoSrc:"https://raw.githubusercontent.com/jellyfin/jellyfin-ux/refs/heads/master/logos/PNG-4x/jellyfin-icon--color-on-dark.png",name:"Jellyfin",description:"Via Gelato plugin",unofficial:!0,author:"lostb1t",onClick:d}),(0,r.jsx)(ff,{logoSrc:"https://link.chillio.app/app-icon.png",name:"Chillio",description:"Via ChillLink protocol",onClick:i}),(0,r.jsx)(ff,{logoSrc:"https://aniyomi.org/img/logo-128px.png",name:"Aniyomi / Animiru",description:"Extension-based integration",unofficial:!0,author:"worldInColors",onClick:c})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-px bg-gray-700 flex-1"}),"Programmatic / API access",(0,r.jsx)("div",{className:"h-px bg-gray-700 flex-1"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,r.jsx)(ff,{icon:(0,r.jsx)(g5.A,{className:"h-5 w-5"}),name:"Newznab / Torznab",description:"Indexer for Prowlarr, NZBHydra & *Arr apps",onClick:u,disabled:x,disabledReason:g}),(0,r.jsx)(ff,{icon:(0,r.jsx)(g4.A,{className:"h-5 w-5"}),name:"Search API",description:"JSON stream search endpoint",onClick:m,disabled:f,disabledReason:b})]})]})]})})}function fS(e){let{onExportOpen:t,onImportOpen:s,onImport:a,importFileRef:n}=e;return(0,r.jsx)(u6,{title:"Backups",description:"Export your settings or restore from a backup file",children:(0,r.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,r.jsx)(w,{onClick:t,leftIcon:(0,r.jsx)(mX.A,{}),intent:"gray",children:"Export"}),(0,r.jsx)("input",{type:"file",accept:".json",className:"hidden",id:"import-file",onChange:a,ref:n}),(0,r.jsx)(w,{onClick:s,leftIcon:(0,r.jsx)(hS.A,{}),intent:"gray",children:"Import"})]})})}function fC(e){let{hasUser:t,onChangePasswordOpen:s,onDeleteUserOpen:a,onResetOpen:n}=e;return(0,r.jsx)(u6,{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,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"alert",rounded:!0,onClick:s,children:"Change Password"}),(0,r.jsx)(w,{intent:"alert",rounded:!0,onClick:a,children:"Delete User"})]}),(0,r.jsx)(w,{intent:"alert",rounded:!0,onClick:n,children:"Reset Configuration"})]})})}let f_="{catalog.name} - {catalog.type}",fA="aiostreams:install:variant-location",fR="aiostreams:seanime:stremio-custom-source:manifest-url",fT="aiostreams:seanime:stremio-custom-source:name-template",fI="aiostreams:seanime:stremio-custom-source:catalog-selections",fE={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()},fM=e=>`${e.type}::${e.id}`,fP=e=>{if("u"<typeof window)return null;try{return window.localStorage.getItem(e)}catch{return null}},fD=(e,t)=>{if("u">typeof window)try{window.localStorage.setItem(e,t)}catch{}},f$=e=>{if("u">typeof window)try{window.localStorage.removeItem(e)}catch{}};function fL(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=fE[t];return s?s(e):e},l)})}function fO(e){let{open:t,onOpenChange:s,baseUrl:a,initialManifestUrl:l}=e,[i,o]=n.useState("url"),[d,c]=n.useState(l),[u,m]=n.useState(null),[p,h]=n.useState([]),[g,f]=n.useState(!1),[b,v]=n.useState(null),[y,j]=n.useState(""),[N,k]=n.useState(f_);n.useEffect(()=>{if(!t){o("url"),m(null),h([]),v(null),j("");return}let e=fP(fT),s=fP(fR);s===l&&f$(fR),c(s&&s!==l?s:l),k(e||f_)},[t,l]),n.useEffect(()=>{t&&fD(fT,N)},[N,t]),n.useEffect(()=>{if(!t)return;let e=d.trim();e&&e!==l?fD(fR,e):f$(fR)},[d,l,t]),n.useEffect(()=>{t&&0!==p.length&&fD(fI,JSON.stringify(p.reduce((e,t)=>(e[fM(t)]={selected:t.selected,displayName:t.displayName},e),{})))},[p,t]);let S=async()=>{let e=d.trim();if(e){f(!0),v(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 v("This manifest has no catalogs.");m(s);let a=(()=>{let e=fP(fI);if(!e)return{};try{let t=JSON.parse(e);return"object"==typeof t&&null!==t?t:{}}catch{return{}}})();h(s.catalogs.map(e=>{var t,r;let n=null==(t=e.extra)?void 0:t.find(e=>"search"===e.name),l=a[fM(e)],i=fL(N,{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}})),o("catalogs")}catch(e){v(e instanceof Error?e.message:"Failed to fetch manifest. Check the URL and try again.")}finally{f(!1)}}},C=e=>{var t;let s=(null==u||null==(t=u.logo)?void 0:t.startsWith("http"))?u.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:d.trim(),addonLogo:s})))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${a}/seanime/extensions/${r}/stremio-custom-source.json`},_=p.filter(e=>e.selected).length,A=p.length>0&&p.every(e=>e.selected),R={url:"Enter a Stremio addon manifest URL to browse its catalogs.",catalogs:u?`${p.length} catalog${1!==p.length?"s":""} from ${u.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."},T={initial:{opacity:0,x:12},animate:{opacity:1,x:0},exit:{opacity:0,x:-12},transition:{duration:.18,ease:"easeOut"}};return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:"Stremio Custom Source",description:R[i],contentClass:"max-w-2xl",children:(0,r.jsxs)(tq.N,{mode:"wait",initial:!1,children:["url"===i&&(0,r.jsxs)(tB.P.div,{...T,className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(G,{value:d,onValueChange:c,placeholder:"https://…/manifest.json",className:"flex-1 font-mono text-sm",onKeyDown:e=>{"Enter"===e.key&&S()}}),(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:S,loading:g,className:"shrink-0",children:"Continue"})]}),b&&(0,r.jsx)(lN,{intent:"alert",description:b,isClosable:!1})]},"url"),"catalogs"===i&&(0,r.jsxs)(tB.P.div,{...T,className:"space-y-4",children:[u&&(0,r.jsxs)("div",{className:"flex items-center gap-3 pb-3 border-b border-gray-700/50",children:[u.logo&&(0,r.jsx)("img",{src:u.logo,alt:u.name,className:"h-8 w-8 rounded object-contain bg-gray-900 p-1"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-100 truncate",children:u.name}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:[_," of ",p.length," selected"]})]}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:A?"primary":"primary-subtle",icon:A?(0,r.jsx)(J.Pqg,{className:"w-4 h-4"}):(0,r.jsx)(J.hpl,{className:"w-4 h-4"}),onClick:()=>{h(e=>e.map(e=>({...e,selected:!A})))},title:A?"Deselect all":"Select all"})]}),(0,r.jsx)("div",{className:"flex flex-col gap-1 max-h-80 overflow-y-auto -mx-1 px-1",children:p.map((e,t)=>(0,r.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,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(nB,{id:`cat-${t}`,size:"sm",value:e.selected,onValueChange:e=>h(s=>s.map((s,a)=>a===t?{...s,selected:!0===e}:s))})}
45),(0,r.jsxs)("div",{className:"flex-shrink-0 w-36 cursor-pointer",onClick:()=>h(e=>e.map((e,s)=>s===t?{...e,selected:!e.selected}:e)),children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-100 truncate",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 text-[11px] text-gray-500",children:[(0,r.jsx)("span",{className:"capitalize",children:e.type}),e.hasSearch&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-gray-700",children:"\xb7"}),(0,r.jsxs)("span",{className:`flex items-center gap-0.5 ${e.searchRequired?"text-amber-400/80":"text-gray-500"}`,children:[(0,r.jsx)(mr.A,{className:"h-2.5 w-2.5"}),e.searchRequired?"search only":"searchable"]})]})]})]}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)(G,{value:e.displayName,onValueChange:e=>h(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,r.jsx)(tq.N,{initial:!1,children:_>0&&(0,r.jsx)(tB.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,r.jsxs)("div",{className:"rounded-lg border border-gray-700/60 bg-gray-800/30 p-3 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{value:N,onValueChange:k,placeholder:f_,className:"flex-1 font-mono text-xs",leftIcon:(0,r.jsx)(J.Uth,{className:"w-3.5 h-3.5"})}),(0,r.jsxs)(w,{intent:"primary-subtle",size:"sm",onClick:()=>{u&&(h(e=>e.map(e=>e.selected?{...e,displayName:fL(N,{addonName:u.name,catalogName:e.name,catalogType:e.type})}:e)),x.oR.success(`Renamed ${_} catalog${1!==_?"s":""}`))},className:"shrink-0",children:["Apply to ",_]})]}),(0,r.jsxs)("p",{className:"text-[11px] text-gray-500",children:["Variables:"," ",(0,r.jsx)("code",{className:"text-gray-400",children:"{addon.name}"}),","," ",(0,r.jsx)("code",{className:"text-gray-400",children:"{catalog.name}"}),","," ",(0,r.jsx)("code",{className:"text-gray-400",children:"{catalog.type}"})," \xb7 ","Modifiers:"," ",(0,r.jsx)("code",{className:"text-gray-400",children:"{catalog.type::title}"})]})]})},"rename-bar")}),b&&(0,r.jsx)(lN,{intent:"alert",description:b,isClosable:!1}),(0,r.jsxs)("div",{className:"flex justify-between pt-2",children:[(0,r.jsx)(w,{intent:"gray-outline",rounded:!0,onClick:()=>{o("url"),v(null)},children:"Back"}),(0,r.jsxs)(w,{intent:"white",rounded:!0,onClick:()=>{let e=p.filter(e=>e.selected);e.length?(v(null),j(JSON.stringify({urls:e.map(C)})),o("import")):v("Select at least one catalog.")},disabled:0===_,children:["Continue with ",_," catalog",1!==_?"s":""]})]})]},"catalogs"),"import"===i&&(0,r.jsxs)(tB.P.div,{...T,className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-gray-400 ml-1",children:"URL list JSON"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{type:"text",readOnly:!0,value:y,className:"flex-1 font-mono text-sm bg-black/20",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:()=>r9(y,{onSuccess:()=>x.oR.success("Copied to clipboard"),onError:()=>x.oR.error("Failed to copy")}),intent:"primary",className:"shrink-0 px-3","aria-label":"Copy URL list",children:(0,r.jsx)(g3.A,{className:"h-4 w-4"})})]})]}),(0,r.jsx)("div",{className:"flex justify-between pt-2",children:(0,r.jsx)(w,{intent:"gray-outline",rounded:!0,onClick:()=>{o("catalogs"),v(null)},children:"Back"})})]},"import")]})})}function fU(){return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(r6,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(fF,{})})})}function fF(){var e,t,s,a,l,i;let{userData:o,setUserData:d,uuid:c,setUuid:u,password:m,setPassword:p,encryptedPassword:h,setEncryptedPassword:g}=aY(),{data:f}=(0,ta.I)(e9(c?{uuid:c,password:m}:null)),b=tQ(!1),[v,y]=n.useState(""),[j,N]=n.useState(""),[k,S]=n.useState(!1),[C,_]=n.useState(null),[A,R]=n.useState([]),{status:T}=tr(),{user:I}=t1(),{data:E}=(0,ta.I)({...e6,enabled:!!I}),M=(null==E||null==(e=E.profiles.find(e=>e.uuid===c))?void 0:e.alias)??null,P=(null==T||null==(t=T.settings)?void 0:t.baseUrl)||window.location.origin,D=!!T,$=(null==T||null==(s=T.settings)?void 0:s.searchApiDisabled)??!1,L=(null==T||null==(a=T.settings)?void 0:a.nabApiDisabled)??!1,O=(null==T||null==(l=T.settings)?void 0:l.seanimeExtensionVersion)??null,U=D&&!$&&!O,F=$||U,z=$?"Requires Search API (disabled on this instance)":U?"Unavailable on this instance. Please ask your instance hoster.":void 0,V=n.useRef(null),q=tQ(!1),[B,K]=n.useState(""),{setSelectedMenu:H,firstMenu:W}=a1(),Y=tQ(!1),J=tQ(!1),Q=tQ(!1),X=tQ(!1),[ee,et]=n.useState(!0),es=n.useMemo(()=>"u"<typeof window?null:function(e,t){let s=/\/v\/([^/]+)\/configure\/?$/.exec(e);if(s){let e=g9(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=g9(a);if(e.length)return{ids:e,location:"query"}}return null}(window.location.pathname,window.location.search),[]),[ea,er]=n.useState((null==es?void 0:es.ids)??[]),[en,el]=n.useState(()=>es?es.location:"query"===fP(fA)?"query":"path");n.useEffect(()=>{fD(fA,en)},[en]);let ei=tQ(!1),eo=tQ(!1),ed=tQ(!1),ec=tQ(!1),eu=tQ(!1),em=tQ(!1),ep=tQ(!1),{handleSave:eh,loading:ex}=uj(),eg=tX({title:"Confirm Reset",description:`Are you sure you want to reset your configuration? This will clear all your settings${c?" but keep your user account":""}. This action cannot be undone.`,actionText:"Reset",actionIntent:"alert",onConfirm:()=>{d(null),H(W),x.oR.success("Configuration reset successfully")}}),ef=tX({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:()=>{S(!0),eG()}});n.useEffect(()=>{let e=[];c?R([]):(v.length<6&&e.push("Password must be at least 6 characters long"),j.length>0&&v!==j&&e.push("Passwords do not match"),R(e))},[v,j,c,m]);let ev=async e=>{if(null==e||e.preventDefault(),A.length>0)return void x.oR.error("Password requirements not met");S(!0);try{let e=await eb(o,v);x.oR.success("Configuration created successfully, your UUID and password are below"),u(e.uuid),g(e.encryptedPassword),p(v),"u"<typeof window||"true"===localStorage.getItem(fh)||_({uuid:e.uuid,password:v})}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to create configuration")}finally{S(!1)}},ey=e=>mZ(e,e=>{var t;return null==T||null==(t=T.settings.presets.find(t=>t.ID===e))?void 0:t.OPTIONS}),ej=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i,ew=c?ej.test(c)?M??null:c:null,eN=(o.variants??[]).filter(e=>!1!==e.enabled),eC=ea.filter(e=>eN.some(t=>
45t.id===e)),e_=eC.map(encodeURIComponent).join(","),eA=eC.length&&"path"===en?`/v/${e_}`:"",eR=eC.length&&"query"===en?`?v=${e_}`:"",eT=c?ew?`${P}/stremio/u/${ew}${eA}/manifest.json${eR}`:`${P}/stremio/${c}/${h}${eA}/manifest.json${eR}`:"",eI=c?`${P}/chilllink/${c}/${h}${eA}${eR}`:"",eE=encodeURIComponent(eT),eM=!!c&&!!h&&ej.test(c),eP=eM?`${P}/seanime/${c}/${h}${eA}/extensions/aiostreams-plugin.json${eR}`:`${P}/seanime/extensions/aiostreams-plugin.json`,eD=eM?`${P}/seanime/${c}/${h}${eA}/extensions/aiostreams-torrent-provider.json${eR}`:`${P}/seanime/extensions/aiostreams-torrent-provider.json`,e$=async()=>{await r9(eT,{onSuccess:()=>x.oR.success("Manifest URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy manifest URL")})},eL=async()=>{await r9(eI,{onSuccess:()=>x.oR.success("ChillLink URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy ChillLink URL")})},eO=async()=>{await r9(eP,{onSuccess:()=>x.oR.success("Plugin URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})},eU=async()=>{await r9(eD,{onSuccess:()=>x.oR.success("Torrent provider URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})},eF=`${P}/api/v1/newznab/api`,ez=`${P}/api/v1/torznab/api`,eV=c&&h?btoa(`${c}:${h}`):"",eq=`${P}/api/v1/search`,eB=async()=>{await r9(eF,{onSuccess:()=>x.oR.success("Newznab URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})},eK=async()=>{await r9(ez,{onSuccess:()=>x.oR.success("Torznab URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})},eH=async()=>{await r9(eV,{onSuccess:()=>x.oR.success("API key copied to clipboard"),onError:()=>x.oR.error("Failed to copy API key")})},eW=async()=>{await r9(eq,{onSuccess:()=>x.oR.success("Search API URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})},eG=async()=>{try{if(!c)return void x.oR.error("No UUID found");await ek(c,B),x.oR.success("Configuration deleted successfully"),u(null),g(null),p(null),d(null),H(W),q.close()}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to delete configuration")}finally{S(!1)}},eY=tQ(!1),[eJ,eZ]=n.useState(!1),[eQ,eX]=n.useState({currentPassword:"",newPassword:"",confirmNewPassword:""}),e0=async e=>{if(e.preventDefault(),!c)return void x.oR.error("No UUID found");if(eQ.newPassword.length<6)return void x.oR.error("New password must be at least 6 characters long");if(eQ.newPassword!==eQ.confirmNewPassword)return void x.oR.error("New passwords do not match");if(eQ.newPassword===eQ.currentPassword)return void x.oR.error("New password cannot be the same as current password");eZ(!0);
45try{let e=await eS(c,eQ.currentPassword,eQ.newPassword);x.oR.success("Password changed successfully. Please reinstall AIOStreams."),p(eQ.newPassword),g(e.encryptedPassword),eY.close(),eX({currentPassword:"",newPassword:"",confirmNewPassword:""})}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to change password")}finally{eZ(!1)}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Install Addon"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Configure and install your personalized addon"})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(uw,{})})]}),(0,r.jsxs)("div",{className:"space-y-4 mt-6",children:[c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(fy,{uuid:c,onCopyUuid:()=>r9(c,{onSuccess:()=>x.oR.success("UUID copied to clipboard"),onError:()=>x.oR.error("Failed to copy UUID")}),onSave:e=>{e.preventDefault(),eh()},saveLoading:ex,onOpenPreferences:b.open}),(0,r.jsx)(fk,{encodedManifest:eE,manifestUrl:eT,usingAlias:!!ew,variantSelector:eN.length>0?(0,r.jsx)(fN,{variants:eN,selected:eC,onChange:er,location:en,onLocationChange:el}):void 0,onCopyManifestUrl:e$,onOpenChillio:ei.open,onOpenSeanime:eo.open,onOpenJellyfin:ec.open,onOpenAniyomi:eu.open,onOpenNabIndexer:em.open,onOpenSearchApi:ep.open,disableSeanimeCard:F,seanimeDisabledReason:z,disableNabIndexerCard:L,nabIndexerDisabledReason:L?"Newznab/Torznab API (disabled on this instance)":void 0,disableSearchApiCard:$,searchApiDisabledReason:$?"Search API (disabled on this instance)":void 0}),(0,r.jsx)(g7,{})]}):(0,r.jsx)(fb,{onSubmit:ev,passwordRequirements:A,newPassword:v,confirmNewPassword:j,onNewPasswordChange:y,onConfirmNewPasswordChange:N,createLoading:k}),(0,r.jsx)(fS,{onExportOpen:Q.open,onImportOpen:X.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 x.oR.error("The imported file is a template, please use the template import option instead.");delete s.uuid,delete s.trusted,d(e=>({...e,...aV(s)})),x.oR.success("Configuration imported successfully")}catch(e){x.oR.error("Failed to import configuration: Invalid JSON file")}},a.readAsText(s)},importFileRef:V}),(0,r.jsx)(fC,{hasUser:!!c,onChangePasswordOpen:eY.open,onDeleteUserOpen:q.open,onResetOpen:eg.open}),(0,r.jsx)(tJ,{open:eY.isOpen,onOpenChange:e=>{!eJ&&(eY.toggle(),e||eX({currentPassword:"",newPassword:"",confirmNewPassword:""}))},title:"Change Password",description:(0,r.jsx)(lN,{intent:"warning",description:"Changing your password will invalidate ALL existing installations. You will need to re-install AIOStreams after this change."}),children:(0,r.jsxs)("form",{onSubmit:e0,className:"space-y-4",children:[(0,r.jsx)("input",{type:"text",name:"username",autoComplete:"username",value:c??"",readOnly:!0,"aria-hidden":"true",tabIndex:-1,className:"sr-only"}),(0,r.jsx)(Z,{id:"change-current-password",label:"Current Password",name:"current-password",autoComplete:"current-password",value:eQ.currentPassword,required:!0,placeholder:"Enter your current password",onValueChange:e=>eX(t=>({...t,currentPassword:e}))}),(0,r.jsx)(Z,{id:"change-new-password",label:"New Password",name:"new-password",autoComplete:"new-password",value:eQ.newPassword,required:!0,placeholder:"Enter your new password",onValueChange:e=>eX(t=>({...t,newPassword:e}))}),(0,r.jsx)(Z,{id:"change-confirm-new-password",label:"Confirm New Password",name:"confirm-new-password",autoComplete:"new-password",value:eQ.confirmNewPassword,required:!0,placeholder:"Re-enter your new password",onValueChange:e=>eX(t=>({...t,confirmNewPassword:e}))}),(0,r.jsxs)("div",{className:"pt-2 flex justify-end gap-3",children:[(0,r.jsx)(w,{type:"button",intent:"gray-outline",onClick:()=>{eJ||eY.close()},disabled:eJ,children:"Cancel"}),(0,r.jsx)(w,{type:"submit",intent:"alert",loading:eJ,children:"Change Password"})]})]})}),(0,r.jsx)(tJ,{open:q.isOpen,onOpenChange:q.toggle,title:"Delete Configuration",description:(0,r.jsx)(lN,{intent:"warning",description:"Please enter your password to confirm deleti
45on of your user and all associated data. This action cannot be undone."}),children:(0,r.jsx)("form",{onSubmit:e=>{(e.preventDefault(),B)?ef.open():x.oR.error("Please enter your password")},children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(Z,{label:"Password",id:"delete-confirm-password",name:"password",value:B,required:!0,placeholder:"Enter your password to confirm deletion",onValueChange:e=>K(e)}),(0,r.jsx)("div",{className:"pt-2",children:(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 w-full",children:[(0,r.jsx)(w,{type:"button",intent:"gray-outline",onClick:q.close,className:"w-full",children:"Cancel"}),(0,r.jsx)(w,{type:"submit",intent:"alert",loading:k,className:"w-full",children:"Delete"})]})})]})})}),(0,r.jsx)(tJ,{open:ei.isOpen,onOpenChange:ei.toggle,title:"Install in Chillio",description:"Add your AIOStreams addon via the ChillLink protocol",children:(0,r.jsx)("div",{className:"flex flex-col gap-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{type:"text",readOnly:!0,value:eI,className:"flex-1",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eL,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy ChillLink URL",children:(0,r.jsx)(g3.A,{className:"h-4 w-4"})})]})})}),(0,r.jsx)(tJ,{open:eo.isOpen,onOpenChange:eo.toggle,title:"Install in Seanime",description:"Stream AIOStreams content directly within Seanime",children:(0,r.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,r.jsxs)("span",{className:"text-gray-400",children:["Seanime integration is in"," ",(0,r.jsx)("span",{className:"font-medium text-amber-300",children:"beta"})]}),(0,r.jsxs)("span",{className:"text-gray-400",children:["Extension ver
45sion:"," ",(0,r.jsx)("span",{className:"font-medium text-gray-200",children:O?`v${O}`:"Unavailable"})]})]}),(0,r.jsxs)("p",{className:"text-xs text-gray-400",children:["In Seanime, go to"," ",(0,r.jsx)("span",{className:"text-gray-200",children:"Extensions → Add Extensions → Install from URL"}),". Install one of the two extensions below."]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-sm font-medium text-white",children:["AIOStreams Plugin"," ",(0,r.jsx)("span",{className:"text-xs text-gray-500 font-normal",children:"— recommended for most"})]}),(0,r.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,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{type:"text",readOnly:!0,value:eP,className:"flex-1",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eO,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy plugin URL",children:(0,r.jsx)(g3.A,{className:"h-4 w-4"})})]}),!eM&&(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"After installing, open the extension settings and enter your Manifest URL."})]}),(0,r.jsx)("div",{className:"border-t border-gray-700/60"}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"AIOStreams Torrent Provider"}),(0,r.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,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{type:"text",readOnly:!0,value:eD,className:"flex-1",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eU,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy torrent provider URL",children:(0,r.jsx)(g3.A,{className:"h-4 w-4"})})]}),!eM&&(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"After installing, open the extension settings and enter your Manifest URL."})]}),(0,r.jsx)("div",{className:"border-t border-gray-700/60"}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"Stremio Custom Source"}),(0,r.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,r.jsx)(w,{intent:"white",rounded:!0,className:"w-full",onClick:ed.open,children:"Configure"})]})]})}),(0,r.jsx)(fO,{open:ed.isOpen,onOpenChange:ed.toggle,baseUrl:P,initialManifestUrl:eT}),(0,r.jsx)(tJ,{open:em.isOpen,onOpenChange:em.toggle,title:"Newznab / Torznab Indexer",description:"Use AIOStreams as a newznab/torznab indexer in Prowlarr, Sonarr or Radarr",children:(0,r.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,r.jsxs)("p",{className:"text-xs text-gray-400",children:["Add a ",(0,r.jsx)("span",{className:"text-gray-200",children:"Generic Newznab"})," ","(usenet) or ",(0,r.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,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"Newznab URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{type:"text",readOnly:!0,value:eF,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eB,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy Newznab URL",children:(0,r.jsx)(g3.A,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"Torznab URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{type:"text",readOnly:!0,value:ez,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eK,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy Torznab URL",children:(0,r.jsx)(g3.A,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"API Key"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{type:"text",readOnly:!0,value:eV,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eH,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy API key",children:(0,r.jsx)(g3.A,{className:"h-4 w-4"})})]}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Paste this into the indexer's API Key field."})]})]})}),(0,r.jsx)(tJ,{open:ep.isOpen,onOpenChange:ep.toggle,title:"Search API",description:"Query your stream pipeline as JSON",children:(0,r.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,r.jsxs)("p",{className:"text-xs text-gray-400",children:[(0,r.jsxs)("span",{className:"font-mono text-gray-200",children:["GET ",eq]})," ","with query params ",(0,r.jsx)("span",{className:"text-gray-200",children:"type"})," and"," ",(0,r.jsx)("span",{className:"text-gray-200",children:"id"}),", authenticated with an"," ",(0,r.jsx)("span",{className:"text-gray-200",children:"Authorization: Basic base64(uuid:password)"})," ","header."]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"Endpoint"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{type:"text",readOnly:!0,value:eq,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eW,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy Search API URL",children:(0,r.jsx)(g3.A,{className:"h-4 w-4"})})]})]})]})}),(0,r.jsx)(tJ,{open:ec.isOpen,onOpenChange:ec.toggle,title:"AIOStreams for Jellyfin",description:"Install the Gelato plugin to bring AIOStreams to Jellyfin",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-gray-300",children:"Gelato is an unofficial Jellyfin plugin that brings Stremio addons into Jellyfin."}),(0,r.jsx)(w,{intent:"primary",className:"w-full",leftIcon:(0,r.jsx)(lj.HaR,{}),onClick:()=>window.open("https://github.com/lostb1t/Gelato","_blank"),children:"Open Gelato on GitHub"})]})}),(0,r.jsx)(tJ,{open:eu.isOpen,onOpenChange:eu.toggle,title:"AIOStreams for Aniyomi / Animiru",description:"Install the extension to use AIOStreams in Aniyomi and Animiru",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-gray-300",children:"This unofficial extension brings AIOStreams support to Aniyomi and forks (e.g. Animiru)."}),(0,r.jsx)(w,{intent:"primary",className:"w-full",leftIcon:(0,r.jsx)(lj.HaR,{}),onClick:()=>window.open("https://github.com/worldInColors/aiostreams-extension","_blank"),children:"Open extension on GitHub"})]})}),(0,r.jsx)(fv,{open:b.isOpen,onOpenChange:e=>e?b.open():b.close(),showChanges:(null==o?void 0:o.showChanges)??!1,onShowChangesChange:e=>d(t=>({...t,showChanges:e})),manifestNotice:(null==o?void 0:o.manifestNotice)??"always",onManifestNoticeChange:e=>d(t=>({...t,manifestNotice:e})),pushBehaviour:(null==o||null==(i=o.linkedAccounts)?void 0:i.pushBehaviour)??"ask",onPushBehaviourChange:e=>d(t=>({...t,linkedAccounts:{...t.linkedAccounts,pushBehaviour:e}})),hasLinkedAccounts:((null==f?void 0:f.length)??0)>0}
45),C&&(0,r.jsx)(fx,{open:!0,onOpenChange:e=>{e||_(null)},credentials:C,manifestUrl:eT}),(0,r.jsx)(t0,{...ef}),(0,r.jsx)(t0,{...eg}),(0,r.jsx)(tJ,{open:Q.isOpen,onOpenChange:Q.toggle,title:"Export Configuration",description:"Choose how to export your configuration",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsx)(fg,{onClick:()=>{try{let e=ee?ey(o):structuredClone(o),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),x.oR.success("Configuration exported successfully"),Q.close()}catch(e){x.oR.error("Failed to export configuration")}},icon:(0,r.jsx)(mX.A,{className:"h-8 w-8"}),title:"Export Config",description:"Download as JSON file for backup or sharing"}),(0,r.jsx)(fg,{onClick:()=>{Q.close(),Y.open()},icon:(0,r.jsx)(mo.A,{className:"h-8 w-8"}),title:"Export as Template",description:"Create reusable template with custom metadata"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 mt-6 p-3 bg-gray-800/50 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white",children:"Exclude Credentials"}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Remove sensitive API keys and passwords from the export"})]}),(0,r.jsx)(rZ,{value:ee,onValueChange:et})]}),(0,r.jsx)(lN,{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,r.jsx)(tJ,{open:X.isOpen,onOpenChange:X.toggle,title:"Import Configuration",description:"Choose what type of configuration to import",children:(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsx)(fg,{onClick:()=>{var e;X.close(),null==(e=V.current)||e.click()},icon:(0,r.jsx)(hS.A,{className:"h-8 w-8"}),title:"Import Config",description:"Restore from a backup JSON file"}),(0,r.jsx)(fg,{onClick:()=>{X.close(),J.open()},icon:(0,r.jsx)(mo.A,{className:"h-8 w-8"}),title:"Import Template",description:"Load a pre-configured template"})]})}),(0,r.jsx)(m4,{open:Y.isOpen,onOpenChange:Y.toggle,userData:o,filterCredentials:ey}),(0,r.jsx)(ho,{open:J.isOpen,onOpenChange:J.toggle,openImportModal:!0})]})]})}var fz=s(3046);let fV={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"||""]}`}},fq={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","releaseGroup","regexMatched","rankedRegexMatched","regexScore","nRegexScore","encode","audioChannels","edition","editions","remastered","regraded","repack","proper","uncensored","unrated","upscaled","hasChapters","network","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"],service:["id","shortName","name","cached"],addon:["name","presetId","manifestUrl"],debug:["json","jsonf"]},fB=new Map(Object.entries(fq).flatMap(e=>{let[t,s]=e;return s.map(e=>[`${t}.${e}`.toLowerCase(),[t,e]])}));function fK(e,t){return fB.get(`${e}.${t}`.toLowerCase())}let fH=(()=>{let e=new Map;for(let[t,s]of Object.entries(fq))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 fW(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 fG(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 fY(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 fJ(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 fZ(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 fQ=["H","M","S"];function fX(e){return e<0?0:e<1e3?60*e*1e3:e}let f0=["January","February","March","April","May","June","July","August","September","October","November","December"],f1=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function f2(e){return e.split("").map(e=>f3[e.toUpperCase()]||e).join("")}let f3={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:"ᴢ"},f5=[{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",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",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 f4(e){return e.internal_english_name?e.internal_english_name:e.english_name.split(/;|\(/)[0].trim()}let f6={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"},f9=new Map(ay.map(e=>[e.toLowerCase(),e])),f8=new Map;for(let e of f5)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=f8.get(s);a&&(a.flag_priority||!e.flag_priority)||f8.set(s,e)}let f7={"latin america":"419",latam:"419",la:"419"},be=/^(.*\S)\s*\(([^()]+)\)$/;function bt(e){if(!e)return;let t=f4(e);return ay.includes(t)?t:void 0}function bs(e){let t,s=ba(f6[t=e.toLowerCase().trim()]??t).toLowerCase().split("-"),a=f5.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 ba(e){switch(e.toLowerCase()){case"zh-tw":case"zh-hans":return"zh";case"es-419":return"es-MX";default:return e}}function br(e){if("string"!=typeof e)return;let t=e.trim();if(!(t.length>64))for(;t;){var s,a;let e=f9.get(t.toLowerCase());if(e)return e;let r=bt(f8.get(t.toLowerCase()));if(r)return r;let n=bt(bs(t));if(n)return n;let l=be.exec(t);if(!l)break;let i=l[1].trim(),o=l[2].trim(),d=(null==(s=f8.get(i.toLowerCase()))?void 0:s.iso_639_1)??(null==(a=bs(i))?void 0:a.iso_639_1),c=f7[o.toLowerCase()]??(/^[a-z]{2}$/i.test(o)?o:void 0);if(d&&c){let e=bt(bs(`${d}-${c}`));if(e)return e}t=i}}let bn=new Set(["Latino","Portuguese (Brazil)"].map(e=>e.toLowerCase()));function bl(e){let t=bi.get(e);if(void 0!==t||bi.has(e))return t;let s=function(e){var t,s,a;let r=f5.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 bn.has(f4(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 bi.size>=bo&&bi.clear(),bi.set(e,s),s}let bi=new Map,bo=1e3,bd={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 bc(e){return bd[e.toLowerCase()]}let bu=/[\u0011\u0012]/g;function bm(e){return e.includes("\x11")||e.includes("\x12")}function bp(e){return bm(e)?e.replace(bu,""):e}function bh(e){return e.replaceAll("{tools.newLine}","\x11").replaceAll("{tools.removeLine}","\x12")}var bx=s(8963).Buffer;let bg=e=>{let t=br(e)??e;return bl(t)||t.toUpperCase()},bf=e=>bc(br(e)??e)??"",bb=(e,t)=>[...new Set(e.map(e=>
90t(String(e))).filter(Boolean))],bv={upper:e=>e.toUpperCase(),lower:e=>e.toLowerCase(),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=>bx.from(e,"utf8").toString("base64"),string:e=>e,smallcaps:e=>f2(e),subscript:e=>bN(e,by,bj),superscript:e=>bN(e,by,bw),languagecode:bg,languageemoji:bf},by="0123456789+-=()",bj="₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎",bw="⁰\xb9\xb2\xb3⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾";function bN(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("")}let bk=(e,t)=>e.length>0?String(e[t]):"",bS=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}),bC=e=>t=>{let s=Math.floor(t/20),a=+(t%20>=10);return"★".repeat(s)+"⯪".repeat(a)+(e?"☆".repeat(5-s-a):"")},b_={join:e=>e.join(", "),length:e=>e.length.toString(),first:e=>bk(e,0),last:e=>bk(e,e.length-1),random:e=>bk(e,Math.floor(Math.random()*e.length)),sort:bS(!0),rsort:bS(!1),lsort:e=>[...e].sort(),reverse:e=>[...e].reverse(),languagecode:e=>bb(e,bg),languageemoji:e=>bb(e,bf),string:e=>e.toString()},bA={comma:e=>e.toLocaleString(),hex:e=>e.toString(16),octal:e=>e.toString(8),binary:e=>e.toString(2),bytes:e=>fG(e,1e3),sbytes:e=>fY(e,1e3),sbytes10:e=>fY(e,1e3),sbytes2:e=>fY(e,1024),rbytes:e=>fG(e,1e3,!0),bytes10:e=>fG(e,1e3),rbytes10:e=>fG(e,1e3,!0),bytes2:e=>fG(e,1024),rbytes2:e=>fG(e,1024,!0),bitrate:e=>fJ(e),rbitrate:e=>fJ(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(fX(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:bC(!1),pstar:bC(!0)},bR={string:e=>String(e)},bT={istrue:e=>!0===e,isfalse:e=>!1===e,exists:e=>null!=e&&("string"==typeof e?/\S/.test(e):!Array.isArray(e)||e.length>0)},bI={$:(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},bE=Object.keys(bv),bM=Object.keys(bA),bP=Object.keys(b_),bD=Object.keys(bR),b$=Object.keys(bT),bL=[...bE,...bD,...bM,...bP,...b$],bO=Object.keys(bI).sort((e,t)=>t.length-e.length);function bU(e){let t,s=[],a=/"([^"]*)"|'([^']*)'/g;for(;null!==(t=a.exec(e));)s.push(t[1]??t[2]??"");return s}function bF(e){let t=e[0];return e.length>=2&&("'"===t||'"'===t)&&e.endsWith(t)?e.slice(1,-1):void 0}function bz(e,t,s){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 bV={and:(e,t)=>e&&t,or:(e,t)=>e||t,xor:(e,t)=>(e||t)&&!(e&&t),neq:(e,t)=>e!==t,equal:(e,t)=>e===t,left:e=>e,right:(e,t)=>t},bq=Object.keys(bV),bB=()=>bq,bK=[...bL].map(e=>e.toLowerCase()).sort((e,t)=>t.length-e.length),bH=[["replace","replaceArgs"],["remove","loose"],["join","quoted"],["truncate","digits"],["slice","digitsOrPair"],["time","quoted"],["date","quoted"],["default","quoted"],["in","loose"],["translate","quotedPair"]],bW=/^\s*[A-Za-z_][A-Za-z0-9_]*\s*\.\s*[A-Za-z_][A-Za-z0-9_]*/,bG=new Set(["unknown-field","unknown-modifier","modifier-arguments"]);class bY{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,er._)(this,"input",void 0),(0,er._)(this,"pos",void 0),this.input=e,this.pos=t}}function bJ(e){return void 0!==e&&/[A-Za-z0-9_]/.test(e)}function bZ(e){for(;!e.atEnd;){let t=e.peek();if("}"===t||"["===t||"]"===t||":"===t&&":"===e.peek(1))break;e.pos+=1}}function bQ(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 bX(e){let t=e.pos;for(;void 0!==e.peek()&&/\d/.test(e.peek());)e.pos+=1;return e.pos>t}function b0(e){for(;void 0!==e.peek()&&/\s/.test(e.peek());)e.pos+=1}function b1(e,t){if(!e.eat("("))return!1;switch(t){case"quoted":if(!bQ(e))return!1;break;case"quotedPair":if(!bQ(e)||(b0(e),!e.eat(","))||(b0(e),!bQ(e)))return!1;break;case"replaceArgs":if("{"===e.peek()){for(;!e.atEnd&&"}"!==e.peek();)e.pos+=1;if(!e.eat("}"))return!1}else if(!bQ(e))return!1;if(b0(e),!e.eat(",")||(b0(e),!bQ(e)))return!1;break;case"digits":if(!bX(e))return!1;break;case"digitsOrPair":if(b0(e),!bX(e))return!1;if(b0(e),e.eat(",")){if(b0(e),!bX(e))return!1;b0(e)}break;case"loose":return function(e){let t=-1;for(;!e.atEnd;){let s=e.peek();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 b2(e){let t=e.pos;for(let[s,a]of bH)if(e.startsWith(`${s}(`)){if(e.pos+=s.length,b1(e,a))return e.slice(t);e.pos=t;break}for(let s of bO)if(e.startsWith(s))return e.pos+=s.length,bZ(e),e.slice(t);for(let s of bK)if(e.startsWith(s)&&!bJ(e.peek(s.length)))return e.pos+=s.length,e.slice(t);e.pos=t}function b3(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(;bJ(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(;bJ(e.peek());)e.pos+=1;let r=e.slice(a);if(!r){e.pos=t;return}let n=fK(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,bB().some(t=>e.startsWith(`${t}::`))){e.pos=t;break}let a=b2(e);if(void 0===a){e.pos=t;break}s.push(a)}return{...t,modifiers:s}}function b5(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 b4(e){let t=e.pos,s=()=>{e.pos=t};if(!e.eat("{"))return s();b0(e);let a=[],r=[],n=b3(e);if(!n)return s();for(a.push(n);e.startsWith("::");){let t=e.pos;e.pos+=2;let n=bB().find(t=>e.startsWith(`${t}::`));if(!n){e.pos=t;break}e.pos+=n.length+2;let l=b3(e);if(!l)return s();r.push(n.toLowerCase()),a.push(l)}let l="["===e.peek()?b5(e):void 0;return(b0(e),e.eat("}"))?{kind:"expression",source:e.slice(t),operands:a,comparators:r,start:t,end:e.pos,...l?{check:l}:{}}:s()}function b6(e){let t=new bY(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=b6(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)??b4(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}=b8(e,t),r=e.slice(t,a?s+1:s),n=a?r.slice(1,-1):r.slice(1);if(!bW.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=bH.find(e=>{let[s]=e;return s===t});return l("modifier-arguments",s?`modifier \`${e}
90\` has invalid arguments; expected \`${t}${b9[s[1]]}\``:`modifier \`${e}\` takes no arguments`)},o=new bY(r);o.eat("{"),b0(o);let d=()=>{let e=o.pos;for(;bJ(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(;bJ(o.peek());)o.pos+=1;let a=o.slice(s);if(!a||fK(t,a))return;let r=function(e,t){let s=fH.get(t.toLowerCase());if(s)return[...s];let a=Object.keys(fq),r=a.find(t=>t.toLowerCase()===e.toLowerCase());return r?fW(t,fq[r]).map(e=>`${r}.${e}`):fW(e,a).map(e=>fK(e,t)).filter(e=>void 0!==e).map(e=>{let[t,s]=e;return`${t}.${s}`})}(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,bB().some(e=>o.startsWith(`${e}::`))){o.pos=e;break}let t=o.pos;if(b2(o)){if("("===o.peek())return i(o.slice(t));continue}if(bO.some(e=>o.startsWith(e))){o.pos=e;break}let s=o.pos;for(;bJ(o.peek());)o.pos+=1;let a=o.slice(s);if(!a)break;if(b7().includes(a.toLowerCase()))return i(a);let r=fW(a.toLowerCase(),b7())[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=bB().find(e=>o.startsWith(`${e}::`));if(!a){o.pos=s;break}o.pos+=a.length+2}if("["===o.peek()){let e;if(b5(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||bG.has(t.category))&&a.push(t)}if(n=Math.max(n,b8(e,i).end),!d.includes("{")&&bW.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 b9={quoted:"('text')",quotedPair:"('from', 'to')",replaceArgs:"('find', 'replaceWith')",digits:"(3)",digitsOrPair:"(0, 3)",loose:"('a', 'b')"};function b8(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 b7(){return[...new Set([...bK,...bH.map(e=>{let[t]=e;return t})])]}let ve=e=>e;function vt(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 vs(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),vt(r,s,l,e.pos,"literal",a)}else{let t=e.pos;for(;bJ(e.peek());)e.pos+=1;if(vt(r,s,t,e.pos,"section",a),"."===e.peek()){vt(r,s,e.pos,e.pos+1,"dot",a),e.pos+=1;let t=e.pos;for(;bJ(e.peek());)e.pos+=1;vt(r,s,t,e.pos,"property",a)}}for(;e.pos<t&&e.startsWith("::");){let t=e.pos;if(e.pos+=2,bB().some(t=>e.startsWith(`${t}::`))){e.pos=t;break}vt(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 bH){if(!e.startsWith(`${n}(`))continue;let i=r+n.length;e.pos=i;let o=e.pos;if(b1(e,l)){vt(a,t,r,i,"modifier",s),vt(a,t,o,e.pos,"call-args",s);return}e.pos=r;break}for(let n of bO){if(!e.startsWith(n))continue;let l=r+n.length;vt(a,t,r,l,"prefix-op",s),e.pos=l;let i=e.pos;bZ(e),vt(a,t,i,e.pos,"call-args",s);return}for(let n of bK)if(e.startsWith(n)&&!bJ(e.peek(n.length))){vt(a,t,r,r+n.length,"modifier",s),e.pos=r+n.length;return}}(e,s,a,r),e.pos<=n)break}}let va=8e3;function vr(e,t){if(va<=0)return"";let s=e(t);return va-=s.length,s}function vn(e){return{node:e,modifiers:e.modifiers.map(e=>{let t;return{source:e,apply:function(e){let t=Object.prototype.hasOwnProperty.call(bT,e),s=bO.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(!bT.exists(l))return!1;if(t)return bT[e](l);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,bI[s])(m?c:(r?i:void 0)??o,m?u:d)}catch{return!1}}}(t=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=bh(s);return(t,s,r)=>{if("string"!=typeof t)return;let n=r.resolveVariable(e,s);return n?bz(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=>"string"==typeof e?e:void 0;let o=n.startsWith("{")&&n.endsWith("}")?n.slice(1,-1):void 0,d=bh(l);return(e,t,s)=>{if("string"!=typeof e)return;if(!o)return bz(e,n,d);let a=s.resolveVariable(o,t);return a?bz(e,a,d):e}}case"remove":{let e=bU(r);if(0===e.length)return()=>void 0;let t=e.filter(Boolean);return s=>{if("string"==typeof s){let e=s;for(let s of t)e=e.replaceAll(s,"");return e}if(Array.isArray(s))return s.filter(t=>!e.includes(t))}}case"join":{let e=bF(r);if(void 0===e)return;let t=bh(e);return e=>Array.isArray(e)?e.join(t):void 0}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=bF(r);if(void 0===e)return;return t=>bT.exists(t)?t:e}case"translate":{let[e,t]=bU(r);if(void 0===e||void 0===t)return;return s=>"string"==typeof s?bN(s,e,t):void 0}case"in":{let e=bU(r).map(e=>e.toLowerCase());if(0===e.length)return;let t=new Set(e);return e=>null!=e&&(Array.isArray(e)?e.some(e=>"string"==typeof e&&t.has(e.toLowerCase())):t.has(String(e).toLowerCase()))}case"time":{let e=bF(r);if(void 0===e)return;return t=>{var s;let a,r,n,l;return"number"==typeof t?(s=fX(t),a=new Set,fZ(e,e=>{let t=e.startsWith("-")?e.slice(1):e;if(fQ.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},fZ(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=bF(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:f0[r],b:f0[r].slice(0,3),A:f1[l.getUTCDay()],a:f1[l.getUTCDay()].slice(0,3)};return fZ(t,e=>void 0!==i[e]?{text:i[e]}:void 0)}(t,e):void 0}default:return}}(e,t)??(e=>{if("string"==typeof e){let s=bv[t];return s?s(e):void 0}if(Array.isArray(e)){let s=b_[t];return s?s(e):void 0}if("number"==typeof e){let s=bA[t];return s?s(e):void 0}if("boolean"==typeof e){let s=bR[t];return s?s(e):void 0}})}})}}function vl(e,t,s){if(void 0!==e.node.literal){let a={resolveVariable:e=>s.resolveVariable(e,t)},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={resolveVariable:e=>s.resolveVariable(e,t)},l=r;"string"==typeof r?l=bp(r):Array.isArray(r)&&r.some(e=>"string"==typeof e&&bm(e))&&(l=r.map(e=>"string"==typeof e?bp(e):e));let i=vo(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{result:l,present:i}}function vi(e,t,s,a){if(1===t.length)return vl(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=vl(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=vl(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&&vo(t[e.node.property])}}function vo(e){return null!=e&&("string"==typeof e?/\S/.test(e):!Array.isArray(e)||e.length>0)}function vd(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(s>5){var a;return null==(a=t.onDepthExceeded)||a.call(t,5),()=>e}let r=e;for(let[e,s]of Object.entries(t.debugMacros??{}))r=r.replace(`{debug.${e}}`,s);let{nodes:n}=b6(r),l=n.map(e=>
90(function e(t,s,a){if("raw"===t.kind){let e=t.text.replace(/\\n/g,"\n");return()=>e}if("tool"===t.kind){let e="newLine"===t.tool?"\x11":"\x12";return()=>e}if("group"===t.kind){var r,n,l;let i;return r=t,n=s,l=a,i=r.nodes.map(t=>({node:t,render:e(t,n,l),operands:"expression"!==t.kind||t.check?void 0:t.operands.map(vn)})),e=>{let t="";for(let{node:s,render:a,operands:r}of i){if(r){let t=vi(s,r,e,n);if(void 0===t.error&&!1===t.present)return""}t+=vr(a,e)}return t}}let i=t.operands.map(vn);if(!t.check)return e=>{let a=vi(t,i,e,s);return a.error??String(a.result??"")};let o=vd(t.check.trueTemplate,s,a+1),d=vd(t.check.falseTemplate,s,a+1),c=void 0===t.check.absentTemplate?void 0:vd(t.check.absentTemplate,s,a+1);return e=>{let a=vi(t,i,e,s);return void 0!==a.error?a.error:vo(a.result)?!0!==a.result&&!1!==a.result?`{cannot_coerce_boolean_for_check_from(${a.result})}`:a.result?o(e):d(e):c?c(e):""}})(e,t,s)),i=1===l.length?l[0]:e=>{let t="";for(let s of l)t+=vr(s,e);return t};return s>0?i:e=>(va=8e3,i(e))}function vc(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 e of r.operands)void 0===e.literal&&e.section&&s.add(`${e.section}.${e.property}`);if(r.check&&!(a>=5))for(let t of[r.check.trueTemplate,r.check.falseTemplate,r.check.absentTemplate])t&&e(b6(t).nodes,s,a+1)}}}(b6(e).nodes,t,0),t}let vu={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"},vm=new Set(["brace","bracket","group-brace"]);function vp(e){var t;let s,a=new gM.vB;for(let r of(s=[],function e(t,s,a,r,n,l){let i=s,o=s,d=e=>vt(l,r,o,e,"text",n);for(;i<a;){if("{"!==t[i]){i+=1;continue}let s=i,c=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}}(t,s,a);if(void 0!==c){d(s),vt(l,r,s,c,"tool",n),o=i=c;continue}if(t.startsWith("{?",s)){let c=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}}(t,s,a);if(void 0!==c){d(s),vt(l,r,s,s+2,"group-brace",n),e(t,s+2,c.bodyEnd,r,n+1,l),vt(l,r,c.bodyEnd,c.end,"group-brace",n),o=i=c.end;continue}}let u=new bY(t,s);if(b4(u)&&u.pos<=a){d(s),function(t,s,a,r,n,l){let i=new bY(t,s+1);for(vt(l,r,s,s+1,"brace",n),b0(i),vs(i,a,r,n,l);i.pos<a&&i.startsWith("::");){let e=i.pos;i.pos+=2;let t=bB().find(e=>i.startsWith(`${e}::`));if(!t){i.pos=e;break}let s=e+2;vt(l,r,e,s,"separator",n),vt(l,r,s,s+t.length,"comparator",n),vt(l,r,s+t.length,s+t.length+2,"separator",n),i.pos=s+t.length+2,vs(i,a,r,n,l)}i.pos<a&&"["===i.peek()&&function(t,s,a,r,n){vt(n,a,t.pos,t.pos+1,"bracket",r),t.pos+=1;for(let l=0;l<3&&(function(t,s,a,r,n){if('"'!==t.peek())return;vt(n,a,t.pos,t.pos+1,"quote",r),t.pos+=1;let l="",i=[],o=0;for(;t.pos<s;){let e=t.peek();if("\\"===e&&'"'===t.peek(1)){i.push(t.pos),l+='"',t.pos+=2;continue}if("{"===e)o+=1;else if("}"===e)o=Math.max(0,o-1);else if('"'===e&&0===o)break;i.push(t.pos),l+=e,t.pos+=1}let d=t.pos;e(l,0,l.length,e=>a(e>=0&&e<i.length?i[e]:d),r+1,n),'"'===t.peek()&&(vt(n,a,d,d+1,"quote",r),t.pos+=1)}(t,s,a,r,n),t.startsWith("||"));l++)vt(n,a,t.pos,t.pos+2,"pipe",r),t.pos+=2;"]"===t.peek()&&(vt(n,a,t.pos,t.pos+1,"bracket",r),t.pos+=1)}(i,a,r,n,l),"}"===t[a-1]&&vt(l,r,a-1,a,"brace",n)}(t,s,u.pos,r,n,l),o=i=u.pos;continue}d(s);let m=b8(t,s),p=Math.min(m.terminated?m.end+1:m.end,a);p>s?(vt(l,r,s,p,"invalid",n),i=p):i=s+1,o=i}d(a)}(t=e.state.doc.toString(),0,t.length,ve,0,s),s.sort((e,t)=>e.start-t.start),s)){let e=vm.has(r.kind)?`cmf-d${r.depth%5}`:vu[r.kind];e&&a.add(r.start,r.end,gI.NZ.mark({class:e}))}return a.finish()}let vh=gI.Z9.fromClass(class{update(e){e.docChanged&&(this.decorations=vp(e.view))}constructor(e){(0,er._)(this,"decorations",void 0),this.decorations=vp(e)}},{decorations:e=>e.decorations}),vx=new Set(["unterminated","unterminated-group","unparseable"]),vg=(0,gO.bu)(e=>{let t=e.state.doc.toString(),s=t.length;return(function(e){let{nodes:t,diagnostics:s}=b6(e),a=[...s,...function e(t,s,a){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;
90if(r>5)return[];let n=[];for(let l of t){if("group"===l.kind){n.push(...e(l.nodes,s,a,r+1));continue}if("expression"===l.kind&&l.check)for(let[t,i]of[[l.check.trueTemplate,l.check.trueStart],[l.check.falseTemplate,l.check.falseStart],[l.check.absentTemplate,l.check.absentStart]]){if(void 0===t||void 0===i)continue;let l=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(i)),o=b6(t);n.push(...o.diagnostics.map(e=>({...e,index:l(e.index),message:`inside conditional branch: ${e.message}`}))),n.push(...e(o.nodes,s,l,r+1))}}return n}(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:vx.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}),vf=Object.keys(fq),vb=vf.map(e=>({label:e,type:"namespace",apply:`${e}.`})),vv=[...bH.map(e=>{let[t,s]=e;return{label:t,type:"function",detail:b9[s],apply:`${t}${b9[s]}`}}),...b$.map(e=>({label:e,type:"keyword",detail:"conditional"})),...[...new Set([...bE,...bM,...bP,...bD])].map(e=>({label:e,type:"method"})),...bq.map(e=>({label:e,type:"operator",detail:"comparator",apply:`${e}::`}))],vy=/^[A-Za-z]*$/,vj=(0,gU.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:vv,validFor:vy};let n=/([A-Za-z]+)\.([A-Za-z]*)$/.exec(a);if(n){var l;let t,s=(l=n[1],(t=vf.find(e=>e.toLowerCase()===l.toLowerCase()))?fq[t].map(e=>({label:e,type:"property"})):[]);if(s.length)return{from:e.pos-n[2].length,options:s,validFor:vy}}let i=/\{\s*([A-Za-z]*)$/.exec(a);return i?{from:e.pos-i[1].length,options:vb,validFor:vy}:null}],icons:!1});function vw(e){let{value:t,onValueChange:s,placeholder:a,disabled:l,className:i,initialHeight:o="11rem",minHeight:d="6rem",onFocusView:c,onViewReady:u}=e,m=(0,n.useRef)(null),p=(0,n.useRef)(c);p.current=c;let h=(0,n.useMemo)(()=>[vh,vg,vj,gT.Lz.lineWrapping,(0,gI.qf)(a??""),gT.Lz.domEventHandlers({focus:(e,t)=>{var s;return null==(s=p.current)||s.call(p,t),!1}})],[a]);return(0,r.jsx)("div",{style:{height:o,minHeight:d},className:b("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",l&&"opacity-60 pointer-events-none",i),children:(0,r.jsx)(gT.Ay,{ref:m,className:"h-full",value:t,onChange:s,onCreateEditor:e=>null==u?void 0:u(e),editable:!l,theme:gE,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:h})})}function vN(e){let{onInsert:t}=e,s=tQ(!1);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"white",size:"sm",onClick:s.open,children:"Snippets"}),(0,r.jsx)(tJ,{open:s.isOpen,onOpenChange:s.close,title:"Formatter Snippets",children:(0,r.jsx)("div",{className:"space-y-4",children:aj.map((e,a)=>(0,r.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,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-semibold text-base mb-1",children:e.name}),(0,r.jsx)("div",{className:"text-sm text-muted-foreground mb-1 break-words",children:e.description}),(0,r.jsx)("div",{className:"font-mono text-xs bg-gray-800 rounded px-2 py-1 inline-block break-all",children:e.value})]}),(0,r.jsxs)("div",{className:"flex gap-2 sm:ml-4 flex-shrink-0",children:[t&&(0,r.jsx)(w,{size:"sm",intent:"primary",onClick:()=>{t(e.value)?(x.oR.success("Snippet inserted"),s.close()):x.oR.message("Click into a template first")},title:"Insert at cursor",children:(0,r.jsx)(mo.A,{className:"w-5 h-5"})}),(0,r.jsx)(w,{size:"sm",intent:"primary-outline",onClick:async()=>{await r9(e.value,{onSuccess:()=>x.oR.success("Snippet copied to clipboard"),onError:()=>x.oR.error("Failed to copy snippet to clipboard")})},title:"Copy snippet",children:(0,r.jsx)(g3.A,{className:"w-5 h-5"})})]})]},a))})})]})}var vk=s(41460),vS=s(46290),vC=s(55560);function v_(e){var t,s;let a=e.formatter.id,r=e.formatter.definitions;if(a===sE){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=fV[a];return{name:(null==l?void 0:l.name)??"",description:(null==l?void 0:l.description)??""}}function vA(e){var t,s;let a=e.formatter.selectedSaved;if(e.formatter.id===sE&&a&&(null==(s=e.formatter.definitions)||null==(t=s.saved)?void 0:t[a]))return a}function vR(e){let{name:t,description:s,compact:a=!1,className:n}=e;return(0,r.jsxs)("div",{className:b("bg-gray-900 rounded-md border border-gray-800",a?"p-3":"p-4",n),children:[(0,r.jsx)("div",{className:b("font-bold mb-1 overflow-x-auto",a?"text-sm":"text-xl"),style:{whiteSpace:"pre"},children:t}),(0,r.jsx)("div",{className:b("text-muted-foreground overflow-x-auto",a?"text-xs":"text-base"),style:{whiteSpace:"pre"},children:s})]})}function vT(e){let{title:t,description:s,badge:a,preview:n,active:l=!1,actions:i,tags:o,header:d}=e;return(0,r.jsxs)(pH,{glowSize:"350px",glowOpacity:.08,transitionDuration:"0.3s",className:b("flex flex-col gap-3 bg-gray-900 border-gray-800 hover:border-gray-600 transition-colors duration-200 rounded-lg p-4",l&&"border-[--brand] ring-1 ring-[--brand]/40"),children:[d??(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[(0,r.jsx)("h3",{className:"flex-1 min-w-[8rem] text-base font-semibold text-white truncate",children:t}),(l||a)&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[l&&(0,r.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,r.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,r.jsx)("div",{className:"flex flex-wrap gap-1",children:o.map(e=>(0,r.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==n?void 0:n.error)?(0,r.jsx)("div",{className:"rounded-md border border-red-600/60 bg-red-700/30 p-3 text-xs text-red-300 break-words",children:n.error}):(0,r.jsx)(vR,{compact:!0,name:(null==n?void 0:n.name)??" ",description:(null==n?void 0:n.description)??" ",className:b(!n&&"animate-pulse")}),i&&(0,r.jsx)("div",{className:"flex items-center gap-2 flex-wrap mt-auto",children:i})]})}var vI=s(21123),vE=s(2020);function vM(e){let{saved:t,previews:s,activeName:a,onSelect:l,onSaveCurrent:i,onRename:o,onDelete:d}=e,c=(0,n.useMemo)(()=>Object.keys(t).sort((e,t)=>
90e.localeCompare(t)),[t]);return 0===c.length?(0,r.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,r.jsx)("span",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-gray-800/60 text-[--muted]",children:(0,r.jsx)(vS.A,{className:"h-5 w-5"})}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"No saved formatters yet"}),(0,r.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,r.jsx)(vP,{existing:c,onSave:i,intent:"primary"})]}):(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.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,r.jsx)(vP,{existing:c,onSave:i})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[560px] overflow-y-auto pr-2",children:c.map(e=>(0,r.jsx)(vD,{name:e,existingNames:c,preview:s[`saved:${e}`],active:a===e,onSelect:l,onRename:o,onDelete:d},e))})]})}function vP(e){let{existing:t,onSave:s,intent:a="primary-subtle"}=e,[l,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(""),c=o.trim(),u=c.length>0&&t.includes(c),m=()=>{i(!1),d("")},p=()=>{c&&(s(c),m())};return(0,r.jsx)(L,{open:l,onOpenChange:e=>e?i(!0):m(),align:"end",className:"w-80",onOpenAutoFocus:()=>{},trigger:(0,r.jsx)(w,{size:"sm",intent:a,leftIcon:(0,r.jsx)(vI.A,{className:"w-4 h-4"}),children:"Save current formatter"}),children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-0.5",children:[(0,r.jsx)("p",{className:"text-sm font-semibold",children:"Save current formatter"}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"Keeps a named copy of the templates in the editor and switches to it."})]}),(0,r.jsx)(G,{value:o,onValueChange:d,placeholder:"Name",className:"text-sm",onKeyDown:e=>{"Enter"===e.key&&p()}}),u&&(0,r.jsxs)("p",{className:"text-xs text-yellow-400 break-all",children:["Replaces the existing “",c,"”."]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"gray-outline",onClick:m,children:"Cancel"}),(0,r.jsx)(w,{size:"sm",intent:"primary",disabled:!c,onClick:p,children:"Save"})]})]})})}function vD(e){let{name:t,existingNames:s,preview:a,active:l,onSelect:i,onRename:o,onDelete:d}
90=e,[c,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(t);(0,n.useEffect)(()=>{p(t)},[t]);let h=tX({title:"Delete formatter",description:(0,r.jsxs)("span",{className:"break-all",children:["Are you sure you want to delete “",t,"”?"]}),actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>d(t)}),x=()=>{let e=m.trim();if(e&&e!==t){if(s.includes(e))return;o(t,e)}else p(t);u(!1)},g=()=>{p(t),u(!1)},f=c&&m.trim()!==t&&s.includes(m.trim());return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t0,{...h}),(0,r.jsx)(vT,{title:t,preview:a,active:l,header:c?(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(G,{value:m,onValueChange:p,autoFocus:!0,className:"flex-1 min-w-0 text-sm",onKeyDown:e=>{"Enter"===e.key&&x(),"Escape"===e.key&&g()}}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(pS.A,{className:"h-3.5 w-3.5"}),disabled:f,onClick:x}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,r.jsx)(vE.A,{className:"h-3.5 w-3.5"}),onClick:g})]}),f&&(0,r.jsx)("p",{className:"text-xs text-red-300",children:"A saved formatter with this name already exists."})]}):void 0,badge:(0,r.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{size:"sm",intent:l?"gray-outline":"primary-subtle",disabled:l,onClick:()=>i(t),children:l?"In use":"Use"}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,r.jsx)(hy.A,{className:"h-3.5 w-3.5"}),onClick:()=>u(!0)}),children:"Rename"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"alert-subtle",icon:(0,r.jsx)(m1.A,{className:"h-3.5 w-3.5"}),onClick:h.open}),children:"Delete"})]})]})})]})}function v$(e){let{open:t,onOpenChange:s,credentials:a,definition:l,existing:i,moderated:d}=e,c=(0,o.jE)(),[u,m]=(0,n.useState)(""),[p,h]=(0,n.useState)(""),[g,f]=(0,n.useState)(""),[b,v]=(0,n.useState)("");(0,n.useEffect)(()=>{var e;t&&(m((null==i?void 0:i.name)??""),h((null==i?void 0:i.description)??""),f((null==i?void 0:i.author)??""),v((null==i||null==(e=i.tags)?void 0:e.join(", "))??""))},[t,i]);let y=m2(b),j=(0,e2.n)({mutationFn:()=>i?eK(a,i.id,{name:u.trim(),description:p.trim(),author:g.trim(),tags:y,payload:l}):eq(a,{name:u.trim(),description:p.trim(),author:g.trim(),tags:y,payload:l}),onSuccess:e=>{c.invalidateQueries({queryKey:te}),c.invalidateQueries({queryKey:tt}),e.draft?x.oR.success("Update submitted for review"):"pending"===e.status?x.oR.success("Submitted for review"):x.oR.success(i?"Update published":"Published"),s(!1)},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to share")}),N=u.trim().length>0&&g.trim().length>0,k=i?mz(i.version):"1.0.0";return(0,r.jsx)(tJ,{open:t,onOpenChange:s,title:i?"Update shared formatter":"Share formatter",description:i?`Publishes the formatter currently in the editor as v${k} of "${i.name}".`:"Publishes the formatter currently in the editor for everyone on this instance.",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(F,{label:"Name",children:(0,r.jsx)(G,{value:u,onValueChange:m,placeholder:"A short, recognisable name",maxLength:100})}),(0,r.jsx)(F,{label:"Description",help:"What makes it different, what it shows.",children:(0,r.jsx)(n7,{value:p,onValueChange:h,placeholder:"Optional",maxLength:1e3})}),(0,r.jsx)(F,{label:"Author",help:"Shown on the card. Up to 20 characters.",children:(0,r.jsx)(G,{value:g,onValueChange:f,placeholder:"Your name or handle",maxLength:20})}),(0,r.jsxs)(F,{label:"Tags",help:"Comma separated, up to 5. Used to filter the community list.",children:[(0,r.jsx)(G,{value:b,onValueChange:v,placeholder:"minimal, emoji, anime"}),y.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1 mt-2",children:y.map(e=>(0,r.jsx)("span",{className:"text-xs bg-gray-800 text-gray-300 px-2 py-0.5 rounded border border-gray-700",children:e},e))})]}),d&&(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["This instance reviews submissions before they appear to others.",i&&" The current version stays published meanwhile."]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",size:"sm",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",size:"sm",disabled:!N,loading:j.isPending,onClick:()=>j.mutate(),children:i?`Publish v${k}`:"Share"})]})]})})}
90class vL{async compileTemplatesAsync(){this.precompiledNameFunction=await this.getCompiledTemplate(this.config.name),this.precompiledDescriptionFunction=await this.getCompiledTemplate(this.config.description)}async getCompiledTemplate(e){let t=vL.compiledTemplates.get(e);if(t)return t;let s=await this.compileTemplate(e);return vL.compiledTemplates.size>=vL.MAX_CACHED_TEMPLATES&&vL.compiledTemplates.clear(),vL.compiledTemplates.set(e,s),s}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,p,h,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,ep,eh,ex,eg;let ef=(e,t)=>e.toString().padStart(t,"0"),eb=(null==(s=e.parsedFile)||null==(t=s.seasons)?void 0:t.length)?1===e.parsedFile.seasons.length?`S${ef(e.parsedFile.seasons[0],2)}`:`S${ef(e.parsedFile.seasons[0],2)}-${ef(e.parsedFile.seasons[e.parsedFile.seasons.length-1],2)}
90`:void 0,ev=(null==(r=e.parsedFile)||null==(a=r.episodes)?void 0:a.length)?1===e.parsedFile.episodes.length?`E${ef(e.parsedFile.episodes[0],2)}`:`E${ef(e.parsedFile.episodes[0],2)}-${ef(e.parsedFile.episodes[e.parsedFile.episodes.length-1],2)}`:void 0,ey=[eb,ev].filter(e=>void 0!==e),ej=(null==(l=e.parsedFile)||null==(n=l.folderSeasons)?void 0:n.length)?1===e.parsedFile.folderSeasons.length?`S${ef(e.parsedFile.folderSeasons[0],2)}`:`S${ef(e.parsedFile.folderSeasons[0],2)}-${ef(e.parsedFile.folderSeasons[e.parsedFile.folderSeasons.length-1],2)}`:void 0,ew=(null==(o=e.parsedFile)||null==(i=o.folderEpisodes)?void 0:i.length)?1===e.parsedFile.folderEpisodes.length?`E${ef(e.parsedFile.folderEpisodes[0],2)}`:`E${ef(e.parsedFile.folderEpisodes[0],2)}-${ef(e.parsedFile.folderEpisodes[e.parsedFile.folderEpisodes.length-1],2)}`:void 0,eN=e=>{let t=e.charAt(0).toUpperCase()+e.slice(1);return[...this.userData[`preferred${t}`]||[],...this.userData[`required${t}`]||[],...this.userData[`included${t}`]||[]]},ek=(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,eS=[...new Set(eN("languages").map(e=>"Original"===e&&this.formatterContext.originalLanguage?this.formatterContext.originalLanguage:e))],eC=[...new Set(eN("subtitles").map(e=>"Original"===e&&this.formatterContext.originalLanguage?this.formatterContext.originalLanguage:e))],e_=(e,t)=>{let s=ek(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,bc),l=r(a,bc),i=r(s,e=>bl(e)||e.toUpperCase()),o=r(a,e=>bl(e)||e.toUpperCase()),d=r(s,bl,f2),c=r(a,bl,f2),u=r(s,bc,e=>e.replace("\uD83C\uDDEC\uD83C\uDDE7","\uD83C\uDDFA\uD83C\uDDF8\uD83E\uDD85")),m=r(a,bc,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}},eA=e=>{let t,s=!1;return()=>(s||(t=e(),s=!0),t)},eR=eA(()=>{var t;return e_(null==(t=e.parsedFile)?void 0:t.languages,eS)}),eT=eA(()=>{var t;return e_(null==(t=e.parsedFile)?void 0:t.subtitles,(null==eC?void 0:eC.length)?eC:eS)}),eI=ek(null==(d=e.parsedFile)?void 0:d.audioChannels,eN("audioChannels")),eE=ek(null==(c=e.parsedFile)?void 0:c.audioTags,eN("audioTags")),eM=ek(null==(u=e.parsedFile)?void 0:u.visualTags,eN("visualTags")),eP=e.age?function(e){if(e<24)return`${e}h`;let t=Math.floor(e/24);return`${t}d`}(e.age):null,eD={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==(p=e.parsedFile)?void 0:p.resolution)||null,subbed:(null==(h=e.parsedFile)?void 0:h.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 eR().sortedValues},get uLanguages(){return eR().userValues},get subtitles(){return eT().sortedValues},get uSubtitles(){return eT().userValues},get languageEmojis(){return eR().emojis},get uLanguageEmojis(){return eR().userEmojis},get subtitleEmojis(){return eT().emojis},get uSubtitleEmojis(){return eT().userEmojis},get languageCodes(){return eR().codes},get uLanguageCodes(){return eR().userCodes},get subtitleCodes(){return eT().codes},get uSubtitleCodes(){return eT().userCodes},get smallLanguageCodes(){return eR().smallCodes},get uSmallLanguageCodes(){return eR().userSmallCodes},get smallSubtitleCodes(){return eT().smallCodes},get uSmallSubtitleCodes(){return eT().userSmallCodes},get wedontknowwhatakilometeris(){return eR().usEmojis},get uWedontknowwhatakilometeris(){return eR().userUsEmojis},visualTags:eM,audioTags:eE,releaseGroup:(null==(v=e.parsedFile)?void 0:v.releaseGroup)||null,regexMatched:(null==(y=e.regexMatched)?void 0:y.name)||(null==(j=e.rankedRegexesMatched)?void 0:j[0])||null,rankedRegexMatched:(null==(w=e.rankedRegexesMatched)?void 0:w.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==(N=e.parsedFile)?void 0:N.encode)||null,audioChannels:eI||null,indexer:e.indexer||null,seeders:(null==(k=e.torrent)?void 0:k.seeders)??null,private:(null==(S=e.torrent)?void 0:S.private)??!1,freeleech:(null==(C=e.torrent)?void 0:C.freeleech)??null,year:(null==(_=e.parsedFile)?void 0:_.year)||null,type:e.type||null,title:(null==(A=e.parsedFile)?void 0:A.title)||null,country:(null==(R=e.parsedFile)?void 0:R.country)||null,episodeTitle:(null==(T=e.parsedFile)?void 0:T.episodeTitle)||null,date:(null==(I=e.parsedFile)?void 0:I.date)||null,season:(null==(M=e.parsedFile)||null==(E=M.seasons)?void 0:E[0])||null,formattedSeasons:eb||null,seasons:(null==(P=e.parsedFile)?void 0:P.seasons)||null,folderSeasons:(null==(D=e.parsedFile)?void 0:D.folderSeasons)||null,formattedFolderSeasons:ej||null,episode:(null==(L=e.parsedFile)||null==($=L.episodes
90)?void 0:$[0])||null,formattedEpisodes:ev||null,episodes:(null==(O=e.parsedFile)?void 0:O.episodes)||null,formattedFolderEpisodes:ew||null,folderEpisodes:(null==(U=e.parsedFile)?void 0:U.folderEpisodes)||null,seasonEpisode:ey||null,seasonPack:(null==(F=e.parsedFile)?void 0:F.seasonPack)??!1,duration:e.duration||null,bitrate:e.bitrate??null,infoHash:(null==(z=e.torrent)?void 0:z.infoHash)||null,age:eP,ageHours:e.age||null,message:e.message||null,proxied:e.proxied??!1,edition:(null==(q=e.parsedFile)||null==(V=q.editions)?void 0:V[0])||null,editions:(null==(B=e.parsedFile)?void 0:B.editions)||null,regraded:(null==(K=e.parsedFile)?void 0:K.regraded)??!1,remastered:null,repack:(null==(H=e.parsedFile)?void 0:H.repack)??!1,proper:(null==(W=e.parsedFile)?void 0:W.proper)??!1,uncensored:(null==(G=e.parsedFile)?void 0:G.uncensored)??!1,unrated:(null==(Y=e.parsedFile)?void 0:Y.unrated)??!1,upscaled:(null==(J=e.parsedFile)?void 0:J.upscaled)??!1,hasChapters:(null==(Z=e.parsedFile)?void 0:Z.hasChapters)??!1,network:(null==(Q=e.parsedFile)?void 0:Q.network)||null,container:(null==(X=e.parsedFile)?void 0:X.container)||null,extension:(null==(ee=e.parsedFile)?void 0:ee.extension)||null,seadex:(null==(et=e.seadex)?void 0:et.isSeadex)??!1,seadexBest:(null==(es=e.seadex)?void 0:es.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==(ea=e.streamExpressionMatched)?void 0:ea.name)||null,rseMatched:(null==(er=e.rankedStreamExpressionsMatched)?void 0:er.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==(en=this.formatterContext.episodeTitles)?void 0:en[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==(el=e.addon)?void 0:el.name)||null,presetId:(null==(eo=e.addon)||null==(ei=eo.preset)?void 0:ei.type)||null,manifestUrl:(null==(ed=e.addon)?void 0:ed.manifestUrl)||null},service:{id:(null==(ec=e.service)?void 0:ec.id)||null,shortName:(null==(eu=e.service)?void 0:eu.id)&&(null==(em=Object.values(s5).find(t=>{var s;return t.id===(null==(s=e.service)?void 0:s.id)}))?void 0:em.shortName)||null,name:(null==(ep=e.service)?void 0:ep.id)&&(null==(eh=Object.values(s5).find(t=>{var s;return t.id===(null==(s=e.service)?void 0:s.id)}))?void 0:eh.name)||null,cached:(null==(ex=e.service)?void 0:ex.cached)!==void 0?null==(eg=e.service)?void 0:eg.cached:null}};return eD.debug={get json(){return JSON.stringify({...eD,debug:void 0})},get jsonf(){return JSON.stringify({...eD,debug:void 0},(e,t)=>t,2)}},eD}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){return vd(e,{resolveVariable:(e,t)=>
90{var s;let[a,r]=e.split("."),n=null==t||null==(s=t[a])?void 0:s[r];return null==n?void 0:String(n)},comparators:bV,onDepthExceeded:e=>{var t,s;return null==(t=(s=this.formatterContext).onWarning)?void 0:t.call(s,`Template nesting depth exceeded (max ${e}). Returning literal text.`)}})}constructor(e,t){(0,er._)(this,"config",void 0),(0,er._)(this,"userData",void 0),(0,er._)(this,"formatterContext",void 0),(0,er._)(this,"precompiledNameFunction",null),(0,er._)(this,"precompiledDescriptionFunction",null),(0,er._)(this,"_compilationPromise",void 0),this.config=e,this.userData=t.userData,this.formatterContext=t,this._compilationPromise=this.compileTemplatesAsync()}}(0,er._)(vL,"compiledTemplates",new Map),(0,er._)(vL,"MAX_CACHED_TEMPLATES",200);class vO extends vL{static fromConfig(e,t){return new vO(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 vU=e=>RegExp(`(?<![^\\s\\[(_\\-.,])(${e})(?=[\\s\\)\\]_.\\-,]|$)`,"i"),vF=e=>vU(`${e}(?![ .\\-_]?sub(title)?s?)`),vz={resolutions:{"2160p":vU("(bd|hd|m)?(4k|2160(p|i)?)|u(ltra)?[ .\\-_]?hd|3840\\s?x\\s?(\\d{4})"),"1440p":vU("(bd|hd|m)?(1440(p|i)?)|2k|w?q(uad)?[ .\\-_]?hd|2560\\s?x(\\d{4})"),"1080p":vU("(bd|hd|m)?(1080(p|i)?)|f(ull)?[ .\\-_]?hd|1920\\s?x\\s?(\\d{3,4})"),"720p":vU("(bd|hd|m)?((720|800)(p|i)?)|hd|1280\\s?x\\s?(\\d{3,4})"),"576p":vU("(bd|hd|m)?((576|534)(p|i)?)"),"480p":vU("(bd|hd|m)?(480(p|i)?)|sd"),"360p":vU("(bd|hd|m)?(360(p|i)?)"),"240p":vU("(bd|hd|m)?(240(p|i)?)"),"144p":vU("(bd|hd|m)?(144(p|i)?)")},qualities:{"BluRay REMUX":vU("(?<!dvd.*)(bd|br|b|uhd)?remux(?!.*dvd)"),BluRay:vU("(?<!remux.*)((bd|blu[ .\\-_]?ray)([ .\\-_]?rip)?|br[ .\\-_]?rip)(?!.*remux)"),"WEB-DL":vU("web[ .\\-_]?(dl)?(?![ .\\-_]?(rip|DLRip|cam))"),WEBRip:vU("web[ .\\-_]?rip"),HDRip:vU("hd[ .\\-_]?rip|web[ .\\-_]?dl[ .\\-_]?rip"),"HC HD-Rip":vU("hc|hd[ .\\-_]?rip"),"DVD REMUX":vU("(hd[ .\\-_]?)?dvd.*remux|remux.*(hd[ .\\-_]?)?dvd"),DVDRip:vU("dvd[ .\\-_]?(rip|mux|r|full|5|9)?"),HDTV:vU("(hd|pd)tv|tv[ .\\-_]?rip|hdtv[ .\\-_]?rip|dsr(ip)?|sat[ .\\-_]?rip"),CAM:vU("cam|hdcam|cam[ .\\-_]?rip"),TS:vU("telesync|ts|hd[ .\\-_]?ts|pdvd|predvd(rip)?"),TC:vU("telecine|tc|hd[ .\\-_]?tc"),SCR:vU("((dvd|bd|web|hd)?[ .\\-_]?)?(scr(eener)?)")},visualTags:{"10bit":vU("10[ .\\-_]?bit|hi10p?"),"HDR10+":vU("hdr[ .\\-_]?10[ .\\-_]?(p(lus)?|[+])"),HDR10:vU("hdr[ .\\-_]?10(?![ .\\-_]?(?:\\+|p(?:lus)?|bit|hi))"),HDR:vU("hdr(?![ .\\-_]?(?:10(?![ .\\-_]?(?:bit|hi))|\\+|p(?:lus)?))"),HLG:vU("hlg"),DV:vU("do?(lby)?[ .\\-_]?vi?(sion)?(?:[ .\\-_]?atmos)?|dv"),"3D":vU("(bd)?(3|three)[ .\\-_]?(d(imension)?(al)?)"),IMAX:vU("imax"),AI:vU("ai|ai(enhanced?|re[ .\\-_]?graded?)"),Upscaled:vU("(ai)?(uprez|ups(uhd|cal(ed?|ing)(uhd)?))(ai)?"),SDR:vU("sdr"),"H-OU":vU("h?(alf)?[ .\\-_]?(ou|over[ .\\-_]?under)"),"H-SBS":vU("h?(alf)?[ .\\-_]?(sbs|side[ .\\-_]?by[ .\\-_]?side)")},audioTags:{Atmos:vU("atmos|ddpa\\d?"),"DD+":vU("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)(?:[ .\\-_]?(2[ .\\-_]?0|5[ .\\-_]?1|7[ .\\-_]?1))?)|e[ .\\-_]?ac[ .\\-_]?3"),DD:vU("(d(olby)?[ .\\-_]?d(igital)?(?:[ .\\-_]?(5[ .\\-_]?1|7[ .\\-_]?1|2[ .\\-_]?0?))?)|(?<!e[ .\\-_]?)ac[ .\\-_]?3"),"DTS:X":vU("dts[ .\\-:_]?x"),"DTS-HD MA":vU("dts[ .\\-_]?hd[ .\\-_]?ma"),"DTS-HD":vU("dts[ .\\-_]?hd(?![ .\\-_]?ma)"),"DTS-ES":vU("dts[ .\\-_]?es"),DTS:vU("dts(?![ .\\-:_]?(x(?=[\\s\\)\\]_.\\-,]|$)|hd[ .\\-_]?(ma)?|es))"),TrueHD:vU("true[ .\\-_]?hd"),PCM:vU("l?pcm"),OPUS:vU("opus"),AAC:vU("q?aac(?:[ .\\-_]?2)?"),FLAC:vU("flac(?:[ .\\-_]?(lossless|2\\.0|x[2-4]))?")},audioChannels:{"2.0":vU("(d(olby)?[ .\\-_]?d(igital)?)?2[ .\\-_]?0(ch)?"),"5.1":vU("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)?)?5[ .\\-_]?1(ch)?"),"6.1":vU("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)?)?6[ .\\-_]?1(ch)?"),"7.1":vU("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)?)?7[ .\\-_]?1(ch)?")},encodes:{HEVC:vU("hevc[ .\\-_]?(10)?|[xh][ .\\-_]?265"),AVC:vU("avc|[xh][ .\\-_]?264"),AV1:vU("av1"),"VC-1":vU("vc[ .\\-_]?1"),XviD:vU("xvid"),DivX:vU("divx|dvix"),"MPEG-4":vU("mpeg[ .\\-_]?4")},languages:{Multi:vF("multi"),"Dual Audio":vF("dual[ .\\-_]?(audio|lang(uage)?|flac|ac3|aac2?)"),Dubbed:vF("dub(s|bed|bing)?"),English:vF("english|eng"),Japanese:vF("japanese|jap|jpn"),Chinese:vF("chinese|chi"),Russian:vF("russian|rus"),Arabic:vF("arabic|ara"),Portuguese:vF("portuguese"),"Portuguese (Brazil)":vF("portuguese[ .\\-_]?brazil|pt[ .\\-_]?br"),Spanish:vF("spanish|spa|esp"),French:vF("french|fra|fr|vf|vff|vfi|vf2|vfq|truefrench"),German:vF("deu(tsch)?(land)?|ger(man)?"),Italian:vF("italian|ita"),Korean:vF("korean|kor"),Hindi:vF("hindi|hin"),Bengali:vF("bengali|ben(?![ .\\-_]?the[ .\\-_]?men)"),Punjabi:vF("punjabi|pan"),Marathi:vF("marathi|mar"),Gujarati:vF("gujarati|guj"),Tamil:vF("tamil|tam"),Telugu:vF("telugu|tel"),Kannada:vF("kannada|kan"),Malayalam:vF("malayalam|mal"),Thai:vF("thai|tha"),Vietnamese:vF("vietnamese|vie"),Indonesian:vF("indonesian|ind"),Turkish:vF("turkish|tur"),Hebrew:vF("hebrew|heb"),Persian:vF("persian|per"),Ukrainian:vF("ukrainian|ukr"),Greek:vF("greek|ell"),Lithuanian:vF("lithuanian|lit"),Latvian:vF("latvian|lav"),Estonian:vF("estonian|est"),Polish:vF("polish|pol"),Czech:vF("czech|cze"),Slovak:vF("slovak|slo"),Hungarian:vF("hungarian|hun"),Romanian:vF("romanian|rum"),Bulgarian:vF("bulgarian|bul"),Serbian:vF("serbian|srp"),Croatian:vF("croatian|hrv"),Slovenian:vF("slovenian|slv"),Dutch:vF("dutch|dut"),Danish:vF("danish|dan"),Finnish:vF("finnish|fin"),Swedish:vF("swedish|swe"),Norwegian:vF("norwegian|nor"),Malay:vF("malay"),Latino:vF("latino|lat")},releaseGroup:/-[. ]?(?!\d+$|S\d+|\d+x|ep?\d+|[^[]+]$)([^\-. []+[^\-. [)\]\d][^\-. [)\]]*)(?:\[[\w.-]+])?(?=\)|[.-]+\w{2,4}$|$)/i};var vV=s(49401);let vq=new Map;function vB(e,t){var s;return null==(s=Object.entries(t).find(t=>{let[s,a]=t;return a.test(e)}))?void 0:s[0]}function vK(e,t){return Object.entries(t).filter(t=>{let[s,a]=t;return a.test(e)}).map(e=>{let[t]=e;return t})}let vH=class{static parse(e){var t,s,a,r;let n=function(e){let t=vq.get(e);if(void 0!==t)return vq.delete(e),vq.set(e,t),t;let s=(0,vV.OI)(e);if(vq.size>=1e4){let e=vq.keys().next().value;void 0!==e&&vq.delete(e)}return vq.set(e,s),s}(e),l=n.title;if(l&&l.length>
904){let t=RegExp(l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/ /g,"[._ ]"),"i");e=(e=e.replace(t,"").trim()).replace(/\s+/g,".").replace(/^\.+|\.+$/g,"")}let i=function(e){if(!e)return;let t=e.toLowerCase();if("4k"===t)return"2160p";if(ar.includes(t))return t;let s=t.match(/^(\d+)p$/);if(s){let e=parseInt(s[1],10);return ar.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]}}(n.resolution)||vB(e,vz.resolutions),o=vB(e,vz.qualities),d=vB(e,vz.encodes),c=vK(e,vz.audioChannels),u=vK(e,vz.visualTags),m=vK(e,vz.audioTags),p=e;(null==(t=n.group)?void 0:t.toLowerCase())==="ind"&&(p=p.replace(/ind/i,""));let h=[...new Set([...vK(p,vz.languages),...(n.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=f5.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=f4(a);return ay.includes(r)?r:void 0}(ba(e))}}).filter(e=>!!e)])],x=(null==(s=e.match(vz.releaseGroup))?void 0:s[1])??n.group,g=n.year?n.year.toString():void 0;return{resolution:i,quality:o,languages:h,subtitles:[],encode:d,audioChannels:c,audioTags:m,visualTags:u,releaseGroup:x,title:l,year:g,country:n.country,episodeTitle:n.episodeTitle,subbed:n.subbed??!1,dubbed:n.dubbed??!1,editions:n.editions,regraded:n.regraded??!1,repack:n.repack??!1,proper:n.proper??!1,uncensored:n.uncensored??!1,unrated:n.unrated??!1,upscaled:n.upscaled??!1,network:n.network,container:n.container,extension:n.extension,seasons:n.seasons,volumes:n.volumes,episodes:n.episodes,date:n.date,seasonPack:!!((null==(a=n.seasons)?void 0:a.length)&&!(null==(r=n.episodes)?void 0:r.length))}}};function vW(e,t){return Array.from(new Set([...e??[],...t??[]]))}let vG={type:ap,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},vY={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:vG,regexMatched:"",regexScore:25,maxRegexScore:50,rankedRegexMatched:"",seMatched:"",seScore:150,maxSeScore:100,rseMatched:"",seadex:!1,seadexBest:!1},vJ=["stream.filename","stream.folderName"],vZ=["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"],vQ=["stream.regexMatched","stream.regexScore","stream.nRegexScore","stream.rankedRegexMatched","stream.seMatched","stream.seScore","stream.nSeScore","stream.rseMatched","stream.seadex","stream.seadexBest"],vX={source:vJ,stream:vZ,scoring:vQ,metadata:[],parsed:[]},v0=[{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:ah,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:ah,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:ah,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}}],v1="aiostreams:formatter-preview";function v2(){try{var e,t;let s=localStorage.getItem(v1);if(!s)return vY;let a=JSON.parse(s);if((null==a?void 0:a.version)!==2)return vY;return{...vY,...a.input,metadata:{...vG,...null==(e=a.input)?void 0:e.metadata},parsedFileOverrides:(null==(t=a.input)?void 0:t.parsedFileOverrides)??{}}}catch{return vY}}function v3(e){try{return new URL(e),!0}catch{return!1}}function v5(e){return e.split(",").map(e=>e.trim()).filter(Boolean)}function v4(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:vW(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),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:vW(null==t?void 0:t.visualTags,null==e?void 0:e.visualTags),audioTags:vW(null==t?void 0:t.audioTags,null==e?void 0:e.audioTags),audioChannels:vW(null==t?void 0:t.audioChannels,null==e?void 0:e.audioChannels),languages:vW(null==t?void 0:t.languages,null==e?void 0:e.languages),subtitles:vW(null==t?void 0:t.subtitles,null==e?void 0:e.subtitles),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?vH.parse(e.filename):void 0,e.folderName?vH.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 v6(e){return e.size&&e.duration?Math.floor(8*e.size/(e.duration/1e3)):void 0}function v9(e){return void 0===e||""===e?null:e}function v8(e){let t=v5(e);return t.length?t:null}async function v7(e,t,s){let a,r,n,l,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:v2(),o=Object.fromEntries(Object.entries({type:r=v9((a=i.metadata).type),queryType:r?a.isAnime?`anime.${r}`:r:null,isAnime:a.isAnime,title:v9(a.title),titles:v8(a.titles),year:v9(a.year),yearEnd:v9(a.yearEnd),season:v9(a.season),episode:v9(a.episode),episodeTitles:v8(a.episodeTitles),genres:v8(a.genres),runtime:v9(a.runtime),episodeRuntime:v9(a.episodeRuntime),absoluteEpisode:v9(a.absoluteEpisode),relativeAbsoluteEpisode:v9(a.relativeAbsoluteEpisode),originalLanguage:v9(a.originalLanguage),country:v9(a.country),latestSeason:v9(a.latestSeason),daysSinceRelease:v9(a.daysSinceRelease),daysSinceFirstAired:v9(a.daysSinceFirstAired),daysSinceLastAired:v9(a.daysSinceLastAired),hasNextEpisode:a.hasNextEpisode,daysUntilNextEpisode:v9(a.daysUntilNextEpisode),anilistId:v9(a.anilistId),malId:v9(a.malId),hasSeaDex:a.hasSeaDex,maxRegexScore:v9(i.maxRegexScore),maxSeScore:v9(i.maxSeScore)}).map(e=>{let[t,s]=e;return[t,s??void 0]}));return vO.fromConfig(e,{...o,userData:t,addonName:s}).format((n=v4(i),l=i.bitrate??v6(i),{id:"preview",type:i.type,addon:{name:i.addonName,preset:{type:i.presetId,id:i.presetId,options:{}},enabled:!0,manifestUrl:v3(i.manifestUrl)?i.manifestUrl:vY.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},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:v5(i.rseMatched),regexScore:i.regexScore,rankedRegexesMatched:v5(i.rankedRegexMatched)}))}function ye(e,t){let{userData:s}=aY(),{status:a}
90=tr(),r=null==a?void 0:a.settings.addonName,[l,i]=(0,n.useState)({}),o=(0,n.useMemo)(()=>v2(),[t]);return(0,n.useEffect)(()=>{if(!t)return;if(0===Object.keys(e).length)return void i(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 v7(a,s,r,o)]}catch(e){return[t,{error:e instanceof Error?e.message:String(e)}]}}));a||i(Object.fromEntries(t))})(),()=>{a=!0}},[e,t,s,r,o]),l}let yt=[],ys=[],ya={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 yr(e,t){return(0,r.jsx)("span",{className:b("text-xs px-2 py-0.5 rounded border whitespace-nowrap",e),children:t})}function yn(e){var t;let s,{enabled:a,onInstall:l}=e,i=(0,o.jE)(),{userData:d,uuid:c,password:u}=aY(),{status:m}=tr(),p=(null==m||null==(t=m.settings.community)?void 0:t.formatters)??"off",h=c?{uuid:c,password:u}:null,[g,f]=(0,n.useState)(!1),[v,y]=(0,n.useState)(""),[j,N]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),C=(0,ta.I)({...(s="formatter",(0,e3.j)({queryKey:[...te,s],queryFn:()=>ez(s),staleTime:6e4,retry:!1})),enabled:a&&"off"!==p}),_=(0,ta.I)({...ts(h),enabled:a&&g&&!!h}),A=C.data??yt,R=(0,n.useMemo)(()=>(_.data??ys).filter(e=>"formatter"===e.kind),[_.data]),T=(0,n.useMemo)(()=>{let e=new Map;
90for(let t of A)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})},[A]),I=(0,n.useMemo)(()=>{let e=v.trim().toLowerCase();return A.filter(t=>(!j||!!(t.tags??[]).includes(j))&&(!e||[t.name,t.description,t.author,...t.tags??[]].join(" ").toLowerCase().includes(e)))},[A,v,j]),E=ye((0,n.useMemo)(()=>{let e={};for(let t of[...A,...R])e[`community:${t.id}`]=t.payload;return e},[A,R]),a),M=()=>{i.invalidateQueries({queryKey:te}),i.invalidateQueries({queryKey:tt})},P=(0,e2.n)({mutationFn:e=>eG(h,e),onSuccess:M,onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to like")}),D=(0,e2.n)({mutationFn:e=>eH(h,e),onSuccess:()=>{x.oR.success("Update withdrawn"),M()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to withdraw")}),$=(0,e2.n)({mutationFn:e=>eW(h,e),onSuccess:()=>{x.oR.success("Removed from the community"),M()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed to delete")});if("off"===p)return(0,r.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"Community formatters are turned off on this instance."});let L="Create or load your configuration (UUID and password) first; sharing and likes are tied to it",O=(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(pF.A,{className:"w-4 h-4"}),disabled:!h,onClick:()=>S({}),children:"Share current formatter"});return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-[--muted] flex-1 min-w-[12rem]",children:"approval"===p?"Submissions are reviewed by an admin before they appear here.":"Anyone with a saved configuration can share a formatter here."}),h&&(0,r.jsx)(w,{size:"sm",intent:g?"primary":"gray-outline",onClick:()=>f(e=>!e),children:"Mine"}),h?O:(0,r.jsx)(tO,{trigger:(0,r.jsx)("span",{children:O}),children:L})]}),!g&&A.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(G,{value:v,onValueChange:y,placeholder:"Search by name, author or tag",leftIcon:(0,r.jsx)(mr.A,{className:"w-4 h-4"}),className:"text-sm"}),T.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:T.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>N(j===e?null:e),className:b("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,r.jsx)(yi,{items:R,loading:_.isPending,previews:E,onUpdate:e=>S({existing:e}),onWithdraw:e=>D.mutate(e.id),onDelete:e=>$.mutate(e.id)}):C.isPending?(0,r.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"Loading..."}):0===A.length?(0,r.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"Nothing shared yet. Be the first."}):0===I.length?(0,r.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"No formatters match this filter."}):(0,r.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[560px] overflow-y-auto pr-2",children:I.map(e=>(0,r.jsx)(vT,{title:e.name,description:e.description||`by ${e.author}`,preview:E[`community:${e.id}`],badge:(0,r.jsxs)(r.Fragment,{children:[e.federated&&yr("bg-gray-500/20 text-gray-300 border-gray-500/30",`From ${e.origin}`),yr("bg-gray-800 text-gray-400 border-gray-700",`v${e.version}`)]}),tags:e.tags,actions:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",onClick:()=>l(e.name,e.payload),children:"Install"}),(0,r.jsxs)("span",{className:"text-xs text-[--muted] truncate",children:["by ",e.author]}),(0,r.jsx)("div",{className:"ml-auto",children:(0,r.jsx)(yl,{item:e,disabledReason:e.federated?"Likes only work for items published on this instance":h?void 0:L,pending:P.isPending,onClick:()=>P.mutate(e.id)})})]})},e.id))}),h&&k&&(0,r.jsx)(v$,{open:!0,onOpenChange:e=>!e&&S(null),credentials:h,definition:v_(d),existing:k.existing,moderated:"approval"===p})]})}function yl(e){let{item:t,disabledReason:s,pending:a,onClick:n}=e,l=(0,r.jsxs)("button",{type:"button",disabled:!!s||a,onClick:n,className:b("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,r.jsx)(pO.A,{className:"w-3.5 h-3.5"}),t.likes]});return s?(0,r.jsx)(tO,{trigger:(0,r.jsx)("span",{children:l}),children:s}):l}function yi(e){let{items:t,loading:s,previews:a,onUpdate:n,onWithdraw:l,onDelete:i}=e;return s?(0,r.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"Loading..."}):0===t.length?(0,r.jsx)("p",{className:"text-sm text-gray-500 text-center py-8",children:"You have not shared a formatter yet."}):(0,r.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,r.jsx)(yo,{item:e,preview:a[`community:${e.id}`],onUpdate:()=>n(e),onWithdraw:()=>l(e),onDelete:()=>i(e)},e.id))})}function yo(e){let{item:t,preview:s,onUpdate:a,onWithdraw:n,onDelete:l}=e,i=tX({title:"Remove shared formatter",description:`Remove "${t.name}" from the community? People who installed it keep their copy.`,actionText:"Remove",actionIntent:"alert-subtle",onConfirm:l}),o=t.draftRejectionReason??t.rejectionReason;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t0,{...i}),(0,r.jsx)(vT,{title:t.name,description:(0,r.jsxs)(r.Fragment,{children:["v",t.version,t.likes>0&&` \xb7 ${t.likes} likes`,o&&(0,r.jsxs)("span",{className:"block text-red-200 mt-0.5",children:[t.draftRejectionReason?"Update rejected: ":"Rejected: ",o]})]}),preview:s,tags:t.tags,badge:(0,r.jsxs)(r.Fragment,{children:[yr(ya[t.status],t.status),t.draft&&yr(ya.pending,`v${t.draft.version} pending review`)]}),actions:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(mX.A,{className:"w-3.5 h-3.5"}),onClick:a,children:"Update with current"}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[t.draft&&(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,r.jsx)(m0.A,{className:"h-3.5 w-3.5"}),onClick:n}),children:"Withdraw pending update"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"alert-subtle",icon:(0,r.jsx)(m1.A,{className:"h-3.5 w-3.5"}),onClick:i.open}),children:"Remove from community"})]})]})})]})}let yd=[sS,sT,sI,sC,s_,sA,sR,sE].filter(e=>e!==sE);function yc(e){let{open:t,onOpenChange:s,onSelectBuiltin:a,onSelectSaved:l,onSelectCustom:i,onSaveCurrent:o,onRename:d,onDelete:c,onInstall:u}=e,{userData:m}
90=aY(),[p,h]=(0,n.useState)("builtin"),x=m.formatter.id,g=m.formatter.definitions,f=null==g?void 0:g.overrides,b=null==g?void 0:g.saved,v=null==g?void 0:g.custom,y=vA(m),j=x===sE&&!y,N=ye((0,n.useMemo)(()=>{let e={};for(let t of yd){let s=(null==f?void 0:f[t])??fV[t];s&&(e[t]=s)}for(let[t,s]of Object.entries(b??{}))e[`saved:${t}`]=s;return v&&(e.custom=v),e},[f,b,v]),t),k=(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[560px] overflow-y-auto pr-2",children:[yd.map(e=>{let t=sM[e],s=x===e,n=!!(null==f?void 0:f[e]);return(0,r.jsx)(vT,{title:t.name,description:t.description,preview:N[e],active:s,badge:n?(0,r.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,r.jsx)(w,{size:"sm",intent:s?"gray-outline":"primary-subtle",disabled:s,onClick:()=>a(e),children:s?"In use":"Use"})},e)}),(0,r.jsx)(vT,{title:sM[sE].name,description:sM[sE].description,preview:v?N.custom:{name:"Start from the active formatter",description:""},active:j,actions:(0,r.jsx)(w,{size:"sm",intent:j?"gray-outline":"primary-subtle",disabled:j,onClick:i,children:j?"In use":"Use"})})]}),S=[{value:"builtin",label:"Built-in",icon:(0,r.jsx)(vk.A,{className:"w-4 h-4"}),content:k},{value:"saved",label:`Saved (${Object.keys(b??{}).length})`,icon:(0,r.jsx)(vS.A,{className:"w-4 h-4"}),content:(0,r.jsx)(vM,{saved:b??{},previews:N,activeName:y,onSelect:l,onSaveCurrent:o,onRename:d,onDelete:c})},{value:"community",label:"Community",icon:(0,r.jsx)(vC.A,{className:"w-4 h-4"}),content:(0,r.jsx)(yn,{enabled:t&&"community"===p,onInstall:u})}];return(0,r.jsx)(tJ,{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,r.jsx)(uT,{tabs:S,activeTab:p,onTabChange:h})})}var yu=s(34670),ym=s(87903);let yp={builtin:{label:"Built-in",icon:vk.A,badge:"bg-green-500/20 text-green-400 border-green-500/30"},customised:{label:"Customised",icon:vk.A,badge:"bg-yellow-400/20 text-yellow-400 border-yellow-400/30"},saved:{label:"Saved",icon:vS.A,badge:"bg-sky-500/20 text-sky-300 border-sky-500/30"},custom:{label:"Custom",icon:yu.A,badge:"bg-purple-500/20 text-purple-300 border-purple-500/30"}};function yh(e){let{name:t,kind:s,detail:a,onOpen:n}=e,{label:l,icon:i,badge:o}=yp[s];return(0,r.jsxs)("button",{type:"button",onClick:n,"aria-haspopup":"dialog",className:b("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,r.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,r.jsx)(i,{className:"h-5 w-5"})}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[(0,r.jsx)("span",{className:"truncate text-sm font-semibold text-[--foreground]",children:t}),(0,r.jsx)("span",{className:b("shrink-0 rounded-full border px-2 py-0.5 text-xs font-medium",o),children:l})]}),a&&(0,r.jsx)("span",{className:"mt-0.5 block text-xs text-[--muted] line-clamp-2",children:a})]}),(0,r.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,r.jsx)("span",{className:"hidden sm:inline",children:"Change"}),(0,r.jsx)(ym.A,{className:"h-4 w-4"})]})]})}var yx=s(8170),yg=s(80757),yf=s(25611),yb=s(57216);function yv(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 yy={expression:(0,r.jsx)(yx.A,{className:"w-3.5 h-3.5 text-[--sky]"}),group:(0,r.jsx)(vk.A,{className:"w-3.5 h-3.5 text-[--violet]"}),branch:(0,r.jsx)(yg.A,{className:"w-3.5 h-3.5 text-[--amber]"}),tool:(0,r.jsx)(yf.A,{className:"w-3.5 h-3.5 text-[--teal]"})};function yj(e){let{item:t,depth:s,onJump:a}
90=e,[l,i]=(0,n.useState)(s<2),o=t.children.length>0;return(0,r.jsxs)("div",{children:[(0,r.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:[o?(0,r.jsx)("button",{type:"button",onClick:()=>i(e=>!e),className:"shrink-0 text-[--muted] hover:text-[--foreground]",children:l?(0,r.jsx)(ui.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(yb.A,{className:"w-3.5 h-3.5"})}):(0,r.jsx)("span",{className:"w-3.5 shrink-0"}),yy[t.kind],(0,r.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})]}),o&&l&&(0,r.jsx)("div",{children:t.children.map((e,t)=>(0,r.jsx)(yj,{item:e,depth:s+1,onJump:a},t))})]})}function yw(e){let{template:t,getView:s}=e,[a,l]=(0,n.useState)(!1),i=(0,n.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}: "${yv(a,28)}"`,from:n,to:n+a.length,kind:"branch",children:e(b6(a).nodes,n)});a.push({label:yv(r.source),from:t,to:n,kind:"expression",children:s})}}return a})(b6(t).nodes,0),[t]),o=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===i.length?null:(0,r.jsxs)("div",{className:"mt-1.5",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>l(e=>!e),className:"flex items-center gap-1 text-xs text-[--muted] hover:text-[--foreground]",children:[a?(0,r.jsx)(ui.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(yb.A,{className:"w-3.5 h-3.5"}),"Structure (",i.length,")"]}),a&&(0,r.jsx)("div",{className:"mt-1 max-h-56 overflow-y-auto rounded-md border border-[--border] bg-[--subtle] p-1",children:i.map((e,t)=>(0,r.jsx)(yj,{item:e,depth:0,onJump:o},t))})]})}let yN="aiostreams:formatter-simple-editor";function yk(){try{return"1"===localStorage.getItem(yN)}catch{return!1}}function yS(e,t,s){var a,r;let n=e.formatter.id;if(n===sE){let a=vA(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=fV[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 yC(){var e,t,s;let{userData:a,setUserData:l}=aY(),i=tQ(!1),o=tQ(!1),d=(0,n.useRef)(null),c=(0,n.useRef)(null),u=(0,n.useRef)(null),[m,p]=(0,n.useState)(yk);function h(e,t,s,a){return m?(0,r.jsx)(n7,{value:e,onValueChange:t,placeholder:s}):(0,r.jsx)(vw,{value:e,onValueChange:t,placeholder:s,onViewReady:e=>a.current=e,onFocusView:e=>u.current=e})}(0,n.useEffect)(()=>{try{localStorage.setItem(yN,m?"1":"0")}catch{}},[m]);let g=a.formatter.id,f=a.formatter.definitions,{name:b,description:v}=v_(a),y=g===sE,j=!y&&!!(null==f||null==(e=f.overrides)?void 0:e[g]),N=vA(a),k=y||!!fV[g],S=N?{name:N,kind:"saved",detail:"Saved in your config. Edits below update it in place."}:y?{name:"Custom",kind:"custom",detail:"Your own templates, edited below."}:{name:(null==(t=sM[g])?void 0:t.name)??g,kind:j?"customised":"builtin",detail:null==(s=sM[g])?void 0:s.description};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(u6,{title:"Formatter Selection",id:"formatter",description:"Pick a built-in, saved or community formatter, then tune its templates below",children:[(0,r.jsx)(yh,{...S,onOpen:o.open}),k&&(0,r.jsxs)("div",{className:"space-y-4 mt-4",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{className:"text-sm text-gray-400",children:["Type ",(0,r.jsx)("span",{className:"font-mono",children:"{debug.jsonf}"})," to see all available variables. See the"," ",(0,r.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,r.jsx)(tO,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",className:"shrink-0",icon:m?(0,r.jsx)(g4.A,{className:"w-4 h-4"}):(0,r.jsx)(fz.A,{className:"w-4 h-4"}),onClick:()=>p(e=>!e)}),children:m?"Switch to the rich editor":"Switch to a plain textarea"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-sm font-medium mb-2 block",children:"Name Template"}),h(b,e=>l(t=>yS(t,e,v_(t).description)),"Enter a template for the stream name",d),!m&&(0,r.jsx)(yw,{template:b,getView:()=>d.current})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-sm font-medium mb-2 block",children:"Description Template"}),h(v,e=>l(t=>yS(t,v_(t).name,e)),"Enter a template for the stream description",c),!m&&(0,r.jsx)(yw,{template:v,getView:()=>c.current})]}),(0,r.jsxs)("div",{className:"flex gap-2 items-center flex-wrap",children:[(0,r.jsx)(vN,{onInsert:m?void 0:function(e){let t=u.current;return!!t&&(t.dispatch(t.state.replaceSelection(e)),t.focus(),!0)}}),j&&(0,r.jsx)(w,{intent:"white",size:"sm",onClick:function(){l(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,r.jsxs)("div",{className:"ml-auto flex gap-2",children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(mu.PiR,{}),onClick:i.open}),children:"Import"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(mu.Mbn,{}),onClick:function(){let e=new Blob([JSON.stringify({name:b,description:v},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),x.oR.success("Formatter exported successfully")}}),children:"Export"})]})]})]})]}),(0,r.jsx)(h2,{open:i.isOpen,onOpenChange:i.toggle,onImport:function(e){"string"==typeof e.name&&"string"==typeof e.description?(l(t=>yS(t,e.name,e.description)),x.oR.success("Formatter imported successfully")):x.oR.error("Invalid formatter format")}}),(0,r.jsx)(yc,{open:o.isOpen,onOpenChange:o.toggle,onSelectBuiltin:function(e){l(t=>({...t,formatter:{...t.formatter,id:e,selectedSaved:void 0}})),o.close()},onSelectSaved:function(e){l(t=>{var s,a;return(null==(a=t.formatter.definitions)||null==(s=a.saved)?void 0:s[e])?{...t,formatter:{...t.formatter,id:sE,selectedSaved:e}}:t}),o.close()},onSelectCustom:function(){l(e=>{var t;let s=(null==(t=e.formatter.definitions)?void 0:t.custom)??v_(e);return{...e,formatter:{...e.formatter,id:sE,selectedSaved:void 0,definitions:{...e.formatter.definitions,custom:s}}}}),o.close()},onSaveCurrent:function(e){let t=e.trim();t?(l(e=>{var s;let{name:a,description:r}=v_(e);return{...e,formatter:{...e.formatter,id:sE,selectedSaved:t,definitions:{...e.formatter.definitions,saved:{...(null==(s=e.formatter.definitions)?void 0:s.saved)??{},[t]:{name:a,description:r}}}}}}),x.oR.success(`Saved and switched to "${t}"`)):x.oR.error("Please enter a name")},onRename:function(e,t){var s;let a=t.trim();if(!a)return void x.oR.error("Name cannot be empty");if(a!==e){if(null==f||null==(s=f.saved)?void 0:s[a])return void x.oR.error("A saved formatter with this name already exists");l(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)}}}}),x.oR.success("Saved formatter renamed")}},onDelete:function(e){l(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=vA(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}}}}),x.oR.success("Saved formatter deleted")},onInstall:function(e,t){let s=e.trim()||"Community formatter";l(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:sE,selectedSaved:s,definitions:{...a.formatter.definitions,saved:{...n,[s]:{...t}}}}}}),o.close(),x.oR.success(`Installed as "${s}"`)}})]})}var y_=s(77090),yA=s(47198),yR=s(38498),yT=s(1142),yI=s(58749),yE=s(85227);class yM{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,er._)(this,"queue",[]),(0,er._)(this,"processing",!1),(0,er._)(this,"delay",void 0),this.delay=e}}let yP=(0,n.createContext)({used:new Set,onlyUsed:!1});function yD(e){let{used:t,onlyUsed:s,children:a}=e,l=(0,n.useMemo)(()=>({used:t,onlyUsed:s}),[t,s]);return(0,r.jsx)(yP.Provider,{value:l,children:a})}function y$(e){return"string"==typeof e?[e]:e}function yL(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{used:s,onlyUsed:a}=(0,n.useContext)(yP),r=y$(e).some(e=>s.has(e));return{isUsed:r,visible:t||r||!a}}function yO(e){let{label:t,field:s,isUsed:a}=e,n=y$(s);return(0,r.jsxs)("span",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"truncate",children:t}),a&&(0,r.jsx)("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-[--brand]",title:`Used by your template (${n.join(", ")})`})]})}
90function yU(e){let{cols:t=3,children:s}=e;return(0,r.jsx)("div",{className:b("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 yF(e){let{children:t}=e;return(0,r.jsx)("div",{className:"flex flex-wrap justify-center gap-x-6 gap-y-3 pt-1",children:t})}function yz(e){let{fields:t,children:s}=e,[a,l]=(0,n.useState)(""),i=function(e){let{used:t,onlyUsed:s}=(0,n.useContext)(yP);return s?e.filter(e=>y$(e).some(e=>t.has(e))).length:e.length}(t);return 0===i?null:(0,r.jsx)(uS,{type:"single",collapsible:!0,value:a,onValueChange:l,className:"pt-1",children:(0,r.jsxs)(uC,{value:"advanced",className:"border border-[--border] rounded-[--radius-md] overflow-hidden",children:[(0,r.jsxs)(u_,{className:"py-2 text-sm text-[--muted-highlight]",children:["Advanced (",i,")"]}),(0,r.jsx)(uA,{className:"space-y-4",children:s})]})})}function yV(e){let{children:t}=e;return(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:t})}function yq(e){let{field:t,label:s,help:a,disabled:n,always:l,value:i,onChange:o,placeholder:d,error:c}=e,{visible:u,isUsed:m}=yL(t,l);return u?(0,r.jsx)(G,{label:(0,r.jsx)(yO,{label:s,field:t,isUsed:m}),moreHelp:a,error:c,disabled:n,value:i,placeholder:d,onValueChange:e=>o(e??""),className:"w-full"}):null}function yB(e){let{field:t,label:s,help:a,disabled:n,value:l,onChange:i,min:o,max:d,step:c,placeholder:u}=e,{visible:m,isUsed:p}=yL(t);return m?(0,r.jsx)(n1,{label:(0,r.jsx)(yO,{label:s,field:t,isUsed:p}),moreHelp:a,disabled:n,allowEmpty:!0,value:l??"",placeholder:u,min:o,max:d,step:c,onValueChange:(e,t)=>
90i(""===t||Number.isNaN(e)?void 0:e),className:"w-full"}):null}function yK(e){let{field:t,label:s,help:a,disabled:n,value:l,onChange:i,options:o}=e,{visible:d,isUsed:c}=yL(t);return d?(0,r.jsx)(r0,{label:(0,r.jsx)(yO,{label:s,field:t,isUsed:c}),moreHelp:a,disabled:n,value:l,options:o,onValueChange:i,className:"w-full"}):null}function yH(e){let{field:t,label:s,help:a,disabled:n,value:l,onChange:i}=e,{visible:o,isUsed:d}=yL(t);return o?(0,r.jsx)(rZ,{label:(0,r.jsx)(yO,{label:s,field:t,isUsed:d}),moreHelp:a,disabled:n,value:l,onValueChange:i}):null}function yW(e){let{field:t,label:s,help:a,disabled:n,value:l,onChange:i,placeholder:o}=e;return(0,r.jsx)(yq,{field:t,label:s,help:a??"Comma separated",disabled:n,value:l,onChange:i,placeholder:o})}function yG(e){let{input:t,patch:s}=e;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(yq,{field:"stream.filename",label:"Filename",always:!0,value:t.filename,onChange:e=>s({filename:e})}),(0,r.jsx)(yq,{field:"stream.folderName",label:"Folder name",always:!0,value:t.folderName,onChange:e=>s({folderName:e})}),(0,r.jsx)(yV,{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 yY="__none__",yJ="__auto__",yZ=[{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:ar},{key:"quality",label:"Quality",field:"stream.quality",kind:"enum",options:an},{key:"encode",label:"Encode",field:"stream.encode",kind:"enum",options:ad},{key:"releaseGroup",label:"Release group",field:"stream.releaseGroup",kind:"text"},{key:"visualTags",label:"Visual tags",field:"stream.visualTags",kind:"enumList",options:al},{key:"audioTags",label:"Audio tags",field:"stream.audioTags",kind:"enumList",options:ai},{key:"audioChannels",label:"Audio channels",field:"stream.audioChannels",kind:"enumList",options:ao},{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:ay},{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:ay,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"}],yQ=[{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:"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 yX(e){return null==e||""===e||Array.isArray(e)&&0===e.length}function y0(e,t){return!!(yX(e)&&yX(t))||(Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,s)=>e===t[s]):e===t)}function y1(e){return null==e?"":Array.isArray(e)?e.join(", "):String(e)}function y2(e){let t,{row:s,parsed:a,overrides:n,setOverride:l}=e,{visible:i,isUsed:o}=yL(s.field);if(!i)return null;let d=s.key in n,c=d?n[s.key]:null==a?void 0:a[s.key],u=(0,r.jsx)(yO,{label:s.label,field:s.field,isUsed:o});switch(s.kind){case"enum":t=(0,r.jsx)(r0,{label:u,moreHelp:s.help,value:null==c?yY:String(c),options:[{label:"Not detected",value:yY},...(s.options??[]).map(e=>({label:e,value:e}))],onValueChange:e=>l(s.key,e===yY?"":e),className:"w-full"});break;case"enumList":t=(0,r.jsx)(nJ,{label:u,moreHelp:s.help,multiple:!0,value:Array.isArray(c)?c.map(String):[],onValueChange:e=>l(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,r.jsx)(r0,{label:u,moreHelp:s.help,value:d?String(c??!1):yJ,options:[{label:`Auto (${(null==a?void 0:a[s.key])?"yes":"no"})`,value:yJ},{label:"Yes",value:"true"},{label:"No",value:"false"}],onValueChange:e=>l(s.key,e===yJ?void 0:"true"===e,!1),className:"w-full"});break;case"numberList":t=(0,r.jsx)(G,{label:u,moreHelp:s.help??"Comma separated",value:y1(c),placeholder:"Not detected",onValueChange:e=>l(s.key,v5(e??"").map(Number).filter(e=>!Number.isNaN(e))),className:"w-full"});break;case"textList":t=(0,r.jsx)(G,{label:u,moreHelp:s.help??"Comma separated",value:y1(c),placeholder:"Not detected",onValueChange:e=>l(s.key,v5(e??"")),className:"w-full"});break;default:t=(0,r.jsx)(G,{label:u,moreHelp:s.help,value:y1(c),placeholder:"Not detected",onValueChange:e=>l(s.key,e??""),className:"w-full"})}return(0,r.jsxs)("div",{className:"flex items-end gap-1.5",children:[(0,r.jsx)("div",{className:"min-w-0 flex-1",children:t}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,r.jsx)(yE.A,{className:"w-3.5 h-3.5"}),"aria-label":`Reset ${s.label}`,className:d?void 0:"invisible",onClick:()=>l(s.key,void 0)})]})}
90function y3(e){let{input:t,patch:s,parsed:a,effective:l}=e,[i,o]=(0,n.useState)(!1),d=t.parsedFileOverrides,c=Object.keys(d).length,u=function(e,t){let r,n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],l={...d};void 0===t||n&&y0(t,null==a?void 0:a[e])?delete l[e]:l[e]=t,(r=Object.keys(l)).length===Object.keys(d).length&&r.every(e=>y0(l[e],d[e]))||s({parsedFileOverrides:l})};return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:c>0?`${c} override${1===c?"":"s"} applied on top of the parser`:"Straight from the parser. Editing any value overrides it."}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(w,{size:"sm",intent:"gray-subtle",onClick:()=>o(e=>!e),children:[i?"Hide":"Show"," raw JSON"]}),(0,r.jsx)(w,{size:"sm",intent:"alert-subtle",disabled:0===c,onClick:()=>s({parsedFileOverrides:{}}),children:"Clear overrides"})]})]}),i&&(0,r.jsx)("pre",{className:"max-h-72 overflow-auto rounded-md border border-[--border] bg-[--subtle] p-3 text-xs",children:JSON.stringify(l??null,null,2)}),(0,r.jsx)(yU,{cols:3,children:yZ.map(e=>(0,r.jsx)(y2,{row:e,parsed:a,overrides:d,setOverride:u},e.key))}),(0,r.jsx)(yz,{fields:yQ.map(e=>e.field),children:(0,r.jsx)(yU,{cols:3,children:yQ.map(e=>(0,r.jsx)(y2,{row:e,parsed:a,overrides:d,setOverride:u},e.key))})}),(0,r.jsx)(yV,{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 y5=["service.id","service.name","service.shortName"],y4=["stream.infoHash","stream.bitrate","addon.presetId","addon.manifestUrl"];function y6(e){let{input:t,patch:s}=e,a="none"===t.serviceId,n=v6(t);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(yU,{cols:3,children:[(0,r.jsx)(yK,{field:"stream.type",label:"Stream type",value:t.type,onChange:e=>s({type:e}),options:am.map(e=>({label:e.charAt(0).toUpperCase()+e.slice(1),value:e}))}),(0,r.jsx)(yK,{field:y5,label:"Service",value:t.serviceId,onChange:e=>s({serviceId:e}),options:[{label:"None",value:"none"},...Object.values(s5).map(e=>({label:e.name,value:e.id}))]}),(0,r.jsx)(yq,{field:"addon.name",label:"Addon name",value:t.addonName,onChange:e=>s({addonName:e})}),(0,r.jsx)(yq,{field:"stream.indexer",label:"Indexer",value:t.indexer,onChange:e=>s({indexer:e})}),(0,r.jsx)(yB,{field:"stream.seeders",label:"Seeders",value:t.seeders,onChange:e=>s({seeders:e}),min:0}),(0,r.jsx)(yq,{field:["stream.age","stream.ageHours"],label:"Age",help:"e.g. 30m, 12h, 10d, 2y",value:t.age,onChange:e=>s({age:e})}),(0,r.jsx)(yB,{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,r.jsx)(yB,{field:"stream.size",label:"Size (bytes)",help:t.size?ne(t.size):void 0,value:t.size,onChange:e=>s({size:e}),min:0,step:1e9}),(0,r.jsx)(yB,{field:"stream.folderSize",label:"Folder size (bytes)",help:t.folderSize?ne(t.folderSize):void 0,value:t.folderSize,onChange:e=>s({folderSize:e}),min:0,step:1e9})]}),(0,r.jsx)(yq,{field:"stream.message",label:"Message",value:t.message,onChange:e=>s({message:e}),placeholder:"This is a message"}),(0,r.jsxs)(yF,{children:[(0,r.jsx)(yH,{field:"service.cached",label:"Cached",disabled:a,help:a?"Needs a service":void 0,value:t.cached,onChange:e=>s({cached:e})}),(0,r.jsx)(yH,{field:"stream.library",label:"Library",value:t.library,onChange:e=>s({library:e})}),(0,r.jsx)(yH,{field:"stream.private",label:"Private",value:t.private,onChange:e=>s({private:e})}),(0,r.jsx)(yH,{field:"stream.freeleech",label:"Freeleech",value:t.freeleech,onChange:e=>s({freeleech:e})}),(0,r.jsx)(yH,{field:"stream.proxied",label:"Proxied",value:t.proxied,onChange:e=>s({proxied:e})}),(0,r.jsx)(yH,{field:"stream.preloading",label:"Preloading",value:t.preloading,onChange:e=>s({preloading:e})})]}),(0,r.jsx)(yz,{fields:y4,children:(0,r.jsxs)(yU,{cols:2,children:[(0,r.jsx)(yq,{field:"stream.infoHash",label:"Info hash",help:"Only sent for p2p streams",value:t.infoHash,onChange:e=>s({infoHash:e})}),(0,r.jsx)(yB,{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:n?`Auto: ${ns(n)}`:"Auto"}),(0,r.jsx)(yq,{field:"addon.presetId",label:"Preset ID",value:t.presetId,onChange:e=>s({presetId:e})}),(0,r.jsx)(yq,{field:"addon.manifestUrl",label:"Manifest URL",value:t.manifestUrl,onChange:e=>s({manifestUrl:e}),error:v3(t.manifestUrl)?void 0:"Must be a valid URL"})]})})]})}let y9=["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"];
90function y8(e){let{input:t,patch:s}=e,a=t.metadata,n=e=>s({metadata:{...a,...e}}),l=a.type?a.isAnime?`anime.${a.type}`:a.type:"";return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(yU,{cols:3,children:[(0,r.jsx)(yK,{field:"metadata.type",label:"Type",value:a.type,onChange:e=>n({type:e}),options:af.map(e=>({label:ab[e],value:e}))}),(0,r.jsx)(yq,{field:"metadata.queryType",label:"Query type",help:"Derived from type and anime",disabled:!0,value:l,onChange:()=>void 0}),(0,r.jsx)(yq,{field:"metadata.title",label:"Title",value:a.title,onChange:e=>n({title:e})}),(0,r.jsx)(yB,{field:"metadata.year",label:"Year",value:a.year,onChange:e=>n({year:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.season",label:"Season",value:a.season,onChange:e=>n({season:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.episode",label:"Episode",value:a.episode,onChange:e=>n({episode:e}),min:0}),(0,r.jsx)(yW,{field:["metadata.episodeTitle","metadata.episodeTitles"],label:"Episode titles",help:"Comma separated; the first is metadata.episodeTitle",value:a.episodeTitles,onChange:e=>n({episodeTitles:e})}),(0,r.jsx)(yW,{field:"metadata.genres",label:"Genres",value:a.genres,onChange:e=>n({genres:e})}),(0,r.jsx)(yB,{field:"metadata.runtime",label:"Runtime (minutes)",value:a.runtime,onChange:e=>n({runtime:e}),min:0})]}),(0,r.jsx)(yF,{children:(0,r.jsx)(yH,{field:"metadata.isAnime",label:"Anime",value:a.isAnime,onChange:e=>n({isAnime:e})})}),(0,r.jsxs)(yz,{fields:y9,children:[(0,r.jsxs)(yU,{cols:3,children:[(0,r.jsx)(yW,{field:"metadata.titles",label:"Titles",value:a.titles,onChange:e=>n({titles:e})}),(0,r.jsx)(yB,{field:"metadata.yearEnd",label:"End year",value:a.yearEnd,onChange:e=>n({yearEnd:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.episodeRuntime",label:"Episode runtime (minutes)",value:a.episodeRuntime,onChange:e=>n({episodeRuntime:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.absoluteEpisode",label:"Absolute episode",value:a.absoluteEpisode,onChange:e=>n({absoluteEpisode:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.relativeAbsoluteEpisode",label:"Relative absolute episode",value:a.relativeAbsoluteEpisode,onChange:e=>n({relativeAbsoluteEpisode:e}),min:0}),(0,r.jsx)(yq,{field:"metadata.originalLanguage",label:"Original language",help:"Also resolves the 'Original' entry in your language preferences",value:a.originalLanguage,onChange:e=>n({originalLanguage:e})}),(0,r.jsx)(yq,{field:"metadata.country",label:"Country",value:a.country,onChange:e=>n({country:e})}),(0,r.jsx)(yB,{field:"metadata.latestSeason",label:"Latest season",value:a.latestSeason,onChange:e=>n({latestSeason:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.daysSinceRelease",label:"Days since release",value:a.daysSinceRelease,onChange:e=>n({daysSinceRelease:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.daysSinceFirstAired",label:"Days since first aired",value:a.daysSinceFirstAired,onChange:e=>n({daysSinceFirstAired:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.daysSinceLastAired",label:"Days since last aired",value:a.daysSinceLastAired,onChange:e=>n({daysSinceLastAired:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.daysUntilNextEpisode",label:"Days until next episode",value:a.daysUntilNextEpisode,onChange:e=>n({daysUntilNextEpisode:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.anilistId",label:"AniList ID",value:a.anilistId,onChange:e=>n({anilistId:e}),min:0}),(0,r.jsx)(yB,{field:"metadata.malId",label:"MyAnimeList ID",value:a.malId,onChange:e=>n({malId:e}),min:0})]}),(0,r.jsxs)(yF,{children:[(0,r.jsx)(yH,{field:"metadata.hasNextEpisode",label:"Has next episode",value:a.hasNextEpisode,onChange:e=>n({hasNextEpisode:e})}),(0,r.jsx)(yH,{field:"metadata.hasSeaDex",label:"Has SeaDex entry",value:a.hasSeaDex,onChange:e=>n({hasSeaDex:e})})]})]})]})}let y7=["stream.rankedRegexMatched","stream.rseMatched"];function je(e){let{input:t,patch:s}=e;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(yU,{cols:3,children:[(0,r.jsx)(yq,{field:"stream.regexMatched",label:"Regex matched",value:t.regexMatched,onChange:e=>s({regexMatched:e}),placeholder:"e.g. 2160p"}),(0,r.jsx)(yB,{field:"stream.regexScore",label:"Regex score",value:t.regexScore,onChange:e=>s({regexScore:e}),min:-1e6,max:1e6,step:5}),(0,r.jsx)(yB,{field:"stream.nRegexScore",label:"Highest regex score",help:"Normalises stream.nRegexScore",value:t.maxRegexScore,onChange:e=>s({maxRegexScore:e}),min:1,step:10}
90),(0,r.jsx)(yq,{field:"stream.seMatched",label:"Stream expression matched",value:t.seMatched,onChange:e=>s({seMatched:e}),placeholder:"e.g. high-quality"}),(0,r.jsx)(yB,{field:"stream.seScore",label:"Stream expression score",value:t.seScore,onChange:e=>s({seScore:e}),min:-1e6,max:1e6,step:10}),(0,r.jsx)(yB,{field:"stream.nSeScore",label:"Highest expression score",help:"Normalises stream.nSeScore",value:t.maxSeScore,onChange:e=>s({maxSeScore:e}),min:1,step:25})]}),(0,r.jsxs)(yF,{children:[(0,r.jsx)(yH,{field:"stream.seadex",label:"SeaDex",value:t.seadex,onChange:e=>s({seadex:e})}),(0,r.jsx)(yH,{field:"stream.seadexBest",label:"SeaDex best",disabled:!t.seadex,value:t.seadex&&t.seadexBest,onChange:e=>s({seadexBest:e})})]}),(0,r.jsx)(yz,{fields:y7,children:(0,r.jsxs)(yU,{cols:2,children:[(0,r.jsx)(yW,{field:"stream.rankedRegexMatched",label:"Ranked regexes matched",value:t.rankedRegexMatched,onChange:e=>s({rankedRegexMatched:e}),placeholder:"2160p, HDR10+, REMUX"}),(0,r.jsx)(yW,{field:"stream.rseMatched",label:"Ranked expressions matched",value:t.rseMatched,onChange:e=>s({rseMatched:e}),placeholder:"high-quality, best-match"})]})})]})}function jt(){let{userData:e}=aY(),{status:t}=tr(),s=null==t?void 0:t.settings.addonName,a=(0,n.useRef)(new yM(200)),[l,i]=(0,n.useState)(v2),[o,d]=(0,n.useState)("source"),[c,u]=(0,n.use
90State)(!1),[m,p]=(0,n.useState)(null),h=(0,n.useCallback)(e=>{i(t=>({...t,...e}))},[]);(0,n.useEffect)(()=>{try{localStorage.setItem(v1,JSON.stringify({version:2,input:l}))}catch{}},[l]);let g=v_(e),f=(0,n.useMemo)(()=>new Set([...vc(g.name),...vc(g.description)]),[g.name,g.description]),b=(0,n.useMemo)(()=>v4({...l,parsedFileOverrides:{}}),[l]),v=(0,n.useMemo)(()=>v4(l),[l]),y=(0,n.useCallback)(async()=>{try{let t=await v7(g,e,s,l);p(t)}catch(e){console.error("Error formatting stream:",e),x.oR.error(`Failed to format stream: ${e}`)}},[l,e,g.name,g.description,s]);(0,n.useEffect)(()=>{a.current.enqueue(y)},[y]);let j=[{value:"source",label:"Source",icon:(0,r.jsx)(y_.A,{className:"w-4 h-4"}),content:(0,r.jsx)(yG,{input:l,patch:h})},{value:"stream",label:"Stream",icon:(0,r.jsx)(yA.A,{className:"w-4 h-4"}),content:(0,r.jsx)(y6,{input:l,patch:h})},{value:"parsed",label:"Parsed File",icon:(0,r.jsx)(yx.A,{className:"w-4 h-4"}),content:(0,r.jsx)(y3,{input:l,patch:h,parsed:b,effective:v})},{value:"scoring",label:"Scoring",icon:(0,r.jsx)(yR.A,{className:"w-4 h-4"}),content:(0,r.jsx)(je,{input:l,patch:h})},{value:"metadata",label:"Metadata",icon:(0,r.jsx)(yT.A,{className:"w-4 h-4"}),content:(0,r.jsx)(y8,{input:l,patch:h})}],w=c?j.filter(e=>(function(e,t){if("metadata"===e)return[...t].some(e=>e.startsWith("metadata."));if("parsed"===e){let e=new Set([...vJ,...vZ,...vQ]);return[...t].some(t=>t.startsWith("stream.")&&!e.has(t))}return(vX[e]??[]).some(e=>t.has(e))})(e.value,f)):j;(0,n.useEffect)(()=>{w.length&&!w.some(e=>e.value===o)&&d(w[0].value)},[w,o]);let N=JSON.stringify(l)===JSON.stringify(vY);return(0,r.jsx)(u6,{title:"Preview",description:"See how your streams would be formatted based on controllable variables",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(vR,{name:null==m?void 0:m.name,description:null==m?void 0:m.description}),(0,r.jsx)(js,{scenario:l.scenario,onScenario:e=>{let t;return i((t=v0.find(t=>t.id===e))?{...vY,...t.input,metadata:{...vG,...t.input.metadata},scenario:e}:{...vY,scenario:e})},onlyUsed:c,onOnlyUsed:u,usedCount:f.size,onReset:()=>i(vY),resetDisabled:N}),(0,r.jsx)(yD,{used:f,onlyUsed:c,children:w.length?(0,r.jsx)(uT,{tabs:w,activeTab:o,onTabChange:d,revealOnChange:!0}):(0,r.jsx)("p",{className:"text-center text-sm text-[--muted] py-6",children:"This formatter reads no controllable fields."})})]})})}function js(e){let{scenario:t,onScenario:s,onlyUsed:a,onOnlyUsed:n,usedCount:l,onReset:i,resetDisabled:o}=e;return(0,r.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,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"shrink-0 text-xs font-medium uppercase tracking-wide text-[--muted]",children:"Scenario"}),(0,r.jsx)(r0,{className:"w-full sm:w-56",value:t,options:v0.map(e=>({label:e.label,value:e.id})),onValueChange:s})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:justify-end",children:[(0,r.jsx)(tO,{trigger:(0,r.jsxs)("button",{type:"button",onClick:()=>n(!a),className:b("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,r.jsx)(yI.A,{className:"w-4 h-4"}),"Used only",(0,r.jsx)("span",{className:"rounded-full bg-gray-800 px-2 py-0.5 text-xs leading-none",children:l})]}),children:"Show only the fields this formatter reads"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{intent:"gray-subtle",icon:(0,r.jsx)(yE.A,{className:"w-4 h-4"}),"aria-label":"Reset preview inputs",disabled:o,onClick:i}),children:"Reset all preview inputs"})]})]})}function ja(){return(0,r.jsx)(r6,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(jr,{})})}function jr(){let{isInherited:e,hasParent:t}=aJ();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{children:"Formatter"}),t&&e("formatter")&&(0,r.jsx)(uI,{section:"formatter"})]}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Format your streams to your liking."})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(uw,{})})]}),(0,r.jsx)(yC,{}),(0,r.jsx)(jt,{})]})}function jn(){return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(r6,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(jl,{})})})}function jl(){var e,t,s,a,n,l,i,o,d,c,u,m,p,h,x,g,f,b,v,y;let{status:j}=tr(),{userData:w,setUserData:N}=aY(),{mode:k}=sy(),{isInherited:S,hasParent:C}=aJ(),_=Object.entries(s3).map(e=>{let[t,s]=e;return{label:s.name,value:t}}),A=[...Object.values(s5).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,D=(null==T?void 0:T.publicIp)!==null,$=(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)?s3[w.proxy.id]:void 0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{children:"Proxy"}),C&&S("proxy")&&(0,r.jsx)(uI,{section:"proxy"})]}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Configure a proxy for your streams to bypass IP restrictions or improve c
90ompatibility"})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(uw,{})})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(u6,{children:(0,r.jsx)(rZ,{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,r.jsxs)(u6,{children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(r0,{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,r.jsx)("p",{className:"text-[--muted] text-sm",children:(0,r.jsx)(l_,{children:U.description})})]}),(null==(n=w.proxy)?void 0:n.id)!=="builtin"&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(Z,{label:"URL",autoComplete:"new-password",value:(null==(l=w.proxy)?void 0:l.url)??"",onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,url:e}}))},placeholder:"Enter proxy URL",disabled:E||!(null==(i=w.proxy)?void 0:i.enabled)}),(0,r.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,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(Z,{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,r.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,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(Z,{label:"Credentials",autoComplete:"new-password",value:(null==(p=w.proxy)?void 0:p.credentials)??"",onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,credentials:e}}))},placeholder:"Enter proxy credentials",disabled:$||!(null==(h=w.proxy)?void 0:h.enabled)}),U&&(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:(0,r.jsx)(l_,{children:U.credentialDescription})})]}),"pro"===k&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(G,{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:D||!(null==(g=w.proxy)?void 0:g.enabled)}),(0,r.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,r.jsxs)(u6,{title:"Proxy Controls",description:"Optionally, specify services and addons that should be proxied. These options are applied conjunctively.",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(nJ,{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,r.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,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(nJ,{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,r.jsx)("p",{className:"text-[--muted] text-sm",children:"Only streams from these addons will be proxied"})]})]})]})]})}function ji(){return(0,r.jsx)(r6,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(jo,{})})}function jo(){let{status:e}=tr(),t=aY(),[s,a]=n.useState("7d"),l=!!(t.uuid&&t.password),i=(null==e?void 0:e.settings.userAnalyticsEnabled)===!0,o=(0,ta.I)({queryKey:["user-analytics",t.uuid,s],queryFn:()=>eL(t.uuid,t.password,s),enabled:l&&i,refetchOnWindowFocus:!1,staleTime:3e4});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex items-center w-full",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Stats"}),(0,r.jsxs)("p",{className:"text-[--muted]",children:["Per-user breakdown of how your addons performed across recent stream requests. Data window is up to"," ",(0,r.jsx)("strong",{children:"24h"===s?"24 hours":"7 days"}),"; older events are pruned automatically."]})]})}),!l&&(0,r.jsx)(lN,{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."}),l&&!i&&(0,r.jsx)(lN,{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."}),l&&i&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(n_,{value:s,onValueChange:e=>a(e??"7d"),children:[(0,r.jsxs)(nA,{children:[(0,r.jsx)(nR,{value:"24h",children:"Last 24h"}),(0,r.jsx)(nR,{value:"7d",children:"Last 7 days"})]}
90),(0,r.jsxs)(nT,{value:s,className:"space-y-4 mt-4",children:[o.isLoading&&(0,r.jsx)(jd,{}),o.error&&(0,r.jsx)(lN,{intent:"alert",title:"Failed to load analytics",description:o.error.message}),o.data&&(0,r.jsx)(jc,{data:o.data})]})]})})]})}function jd(){return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Array.from({length:4}).map((e,t)=>(0,r.jsx)(pY,{className:"h-24 rounded-md"},t))}),(0,r.jsx)(pY,{className:"h-64 rounded-md"})]})}function jc(e){let{data:t}=e,{status:s}=tr(),a=aY(),l=n.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]),i=n.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,r.jsx)(lN,{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 o=[],d=[];for(let e of t.perAddon)i.has(e.presetType)?o.push(e):d.push(e);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(ju,{data:t}),(0,r.jsx)(u6,{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,r.jsx)(jm,{rows:o,presetNameByType:l})}),d.length>0&&(0,r.jsx)(u6,{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,r.jsx)(jm,{rows:d,presetNameByType:l,muted:!0})}),t.perService.length>0&&(0,r.jsx)(u6,{title:"Per-service breakdown",description:"Surviving streams attributed to each debrid/cdn service across all merged contributions.",children:(0,r.jsx)(jp,{rows:t.perService})}),t.latencyLeaderboard.length>0&&(0,r.jsx)(u6,{title:"Slowest addons",description:"Average response time across the window. Only includes addons with at least 3 successful requests.",children:(0,r.jsx)("ul",{className:"text-sm divide-y divide-[--border]",children:t.latencyLeaderboard.map((e,t)=>{var s;return(0,r.jsxs)("li",{className:"flex justify-between py-2",children:[(0,r.jsx)("span",{children:(null==(s=e.addonName)?void 0:s.trim())||l.get(e.presetType)||e.presetType}),(0,r.jsxs)("span",{className:"font-mono text-[--muted]",children:[(e.avgLatencyMs/1e3).toFixed(2),"s"]})]},`${e.presetType}-${e.instanceHash}-${t}`)})})})]})}function ju(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,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:s.map(e=>(0,r.jsx)(X,{children:(0,r.jsxs)(ea,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-xs text-[--muted] uppercase tracking-wide",children:e.label}),(0,r.jsx)("div",{className:b("text-2xl font-semibold mt-1",e.alert&&"text-red-300",e.muted&&"text-[--muted]"),children:e.value})]})},e.label))})}function jm(e){let{rows:t,presetNameByType:s,muted:a}=e;return 0===t.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No data in this window."}):(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:b("w-full text-sm border-collapse",a&&"text-[--muted]"),children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,r.jsx)(jh,{children:"Addon"}),(0,r.jsx)(jh,{align:"right",children:"Requests"}),(0,r.jsx)(jh,{align:"right",children:"Avg final"}),(0,r.jsx)(jh,{align:"right",children:"Final share"}),(0,r.jsx)(jh,{align:"right",children:"Cut-off"}),(0,r.jsx)(jh,{align:"right",children:"Errors"}),(0,r.jsx)(jh,{align:"right",children:"Avg latency"}),(0,r.jsx)(jh,{children:"Notes"})]})}),(0,r.jsx)("tbody",{children:t.map(e=>{var t;let a=s.get(e.presetType)??e.presetType,n=(null==(t=e.addonName)?void 0:t.trim())||a,l=!!e.addonName&&e.addonName.trim()!==a,i=[];return e.redundant&&i.push("Redundant"),e.slow&&i.push("Slow"),e.errorRate>25&&i.push("Unstable"),(0,r.jsxs)("tr",{className:"border-b border-[--border] last:border-0 hover:bg-[--subtle]/30",children:[(0,r.jsxs)(jx,{children:[(0,r.jsx)("div",{className:"font-medium",children:n}),(0,r.jsxs)("div",{className:"text-xs text-[--muted]",children:[l&&(0,r.jsx)("span",{className:"mr-2",children:a}),(0,r.jsxs)("span",{className:"font-mono",children:[e.instanceHash.slice(0,10),"…"]})]})]}),(0,r.jsx)(jx,{align:"right",children:e.requests}),(0,r.jsx)(jx,{align:"right",children:e.avgFinalContribution.toFixed(1)}),(0,r.jsxs)(jx,{align:"right",children:[e.finalShare.toFixed(1),"%"]}),(0,r.jsx)(jx,{align:"right",children:(0,r.jsxs)("span",{className:b(e.cutOffRate>30&&"text-amber-400"),children:[e.cutOffRate.toFixed(0),"%"]})}),(0,r.jsx)(jx,{align:"right",children:(0,r.jsxs)("span",{className:b(e.errorRate>10&&"text-red-300"),children:[e.errorRate.toFixed(0),"%"]})}),(0,r.jsx)(jx,{align:"right",children:null==e.avgLatencyMs?"—":`${(e.avgLatencyMs/1e3).toFixed(2)}s`}),(0,r.jsx)(jx,{children:i.length>0?(0,r.jsx)("span",{className:"text-xs",children:i.join(" \xb7 ")}):(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"OK"})})]},`${e.presetType}-${e.instanceHash}`)})})]})})}function jp(e){let{rows:t}=e;return(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm border-collapse",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,r.jsx)(jh,{children:"Service"}),(0,r.jsx)(jh,{align:"right",children:"Streams"}),(0,r.jsx)(jh,{align:"right",children:"Cached"}),(0,r.jsx)(jh,{align:"right",children:"Cached share"}),(0,r.jsx)(jh,{children:"Contributing addons"})]})}),(0,r.jsx)("tbody",{children:t.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border] last:border-0 hover:bg-[--subtle]/30",children:[(0,r.jsx)(jx,{children:(0,r.jsx)("span",{className:"font-medium",children:e.serviceId})}),(0,r.jsx)(jx,{align:"right",children:e.finalCount}),(0,r.jsx)(jx,{align:"right",children:e.cachedCount}),(0,r.jsxs)(jx,{align:"right",children:[e.cachedShare.toFixed(0),"%"]}),(0,r.jsx)(jx,{children:(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:e.contributingAddons.join(", ")})})]},e.serviceId))})]})})}function jh(e){let{children:t,align:s}=e;return(0,r.jsx)("th",{className:b("py-2 px-3 text-xs font-semibold text-[--muted] uppercase tracking-wide","right"===s&&"text-right"),children:t})}function jx(e){let{children:t,align:s}=e;return(0,r.jsx)("td",{className:b("py-2 px-3","right"===s&&"text-right"),children:t})}function jg(){let{selectedMenu:e}=a1();switch(e){case"about":return(0,r.jsx)(hW,{});case"services":return(0,r.jsx)(ms,{});case"addons":return(0,r.jsx)(mL,{});case"filters":return(0,r.jsx)(xR,{});case"sorting":return(0,r.jsx)(xW,{});case"formatter":return(0,r.jsx)(ja,{});case"proxy":return(0,r.jsx)(jn,{});case"miscellaneous":return(0,r.jsx)(g0,{});case"stats":return(0,r.jsx)(ji,{});case"save-install":return(0,r.jsx)(fU,{});default:return(0,r.jsxs)("div",{className:"p-8",children:[(0,r.jsx)("h2",{className:"text-2xl font-bold mb-4",children:e}),(0,r.jsx)("p",{className:"text-gray-400",children:"This section is under construction."})]})}}function jf(e){let{selectedMenu:t}=a1(),{open:s}=ra(),{isSignedIn:a,toggleSession:n}=c1(),l=tQ(!1);return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{"data-top-navbar":!0,className:b("w-full h-[5rem] relative overflow-hidden flex items-center","lg:hidden"),children:[(0,r.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,r.jsxs)("div",{"data-top-navbar-content":!0,className:"flex items-center w-full gap-3",children:[(0,r.jsx)(t_,{}),(0,r.jsx)(rq,{label:"Search settings",onOpen:s}),"about"===t?(0,r.jsxs)("div",{className:"flex items-center gap-2 lg:hidden ml-auto",children:[(0,r.jsx)(E,{icon:(0,r.jsx)(t2.uoR,{}),intent:"alert-outline",rounded:!0,size:"md",onClick:l.open}),(0,r.jsx)(E,{icon:a?(0,r.jsx)(t2.eZR,{}):(0,r.jsx)(t2.XzR,{}),intent:"white-outline",rounded:!0,size:"md",onClick:n})]}):(0,r.jsx)("div",{className:"flex items-center gap-2 lg:hidden",children:(0,r.jsx)(uw,{})})]})}),(0,r.jsx)(c4,{open:l.isOpen,onOpenChange:l.toggle}),(0,r.jsx)(t3,{})]})})}function jb(){var e,t;
90let{pendingDraft:s,restoreDraft:a,discardDraft:n,disableDrafts:l,uuid:i}=aY(),{status:o}=tr();if(!s)return null;let d=null==(e=s.addonName)?void 0:e.trim(),c=d&&d!==((null==o||null==(t=o.settings)?void 0:t.addonName)||"AIOStreams")?d:null;return(0,r.jsx)("div",{className:"px-4 pt-4 sm:px-8",children:(0,r.jsxs)("div",{className:"rounded-lg border border-[--border] bg-gray-900/60 p-4 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("p",{className:"text-sm font-medium text-white",children:["Unsaved changes from ",function(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`}(s.savedAt)]}),(0,r.jsxs)("p",{className:"text-xs text-[--muted] mt-0.5",children:[c?`From "${c}". `:"","These were never saved to your configuration.",null===i&&" You are not signed in."]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 shrink-0",children:[(0,r.jsx)(w,{intent:"primary",size:"sm",rounded:!0,onClick:a,children:"Restore"}),(0,r.jsx)(w,{intent:"gray-outline",size:"sm",rounded:!0,onClick:n,children:"Discard"}),(0,r.jsx)(w,{intent:"gray-link",size:"sm",onClick:l,className:"text-xs",children:"Don't keep drafts on this browser"})]})]})})}function jv(e){let{error:t}=e,s=(0,o.jE)();return(0,r.jsx)(A,{showSpinner:!1,children:(0,r.jsx)(N,{title:"Something went wrong!",reset:()=>s.refetchQueries({queryKey:e4.queryKey}),children:(0,r.jsx)("p",{children:t})})})}function jy(){let{status:e,loading:t,error:s}=tr();return t?(0,r.jsx)(ue,{title:"Launching. . ."}):s||!e?(0,r.jsx)(jv,{error:s}):(0,r.jsx)(c3,{children:(0,r.jsx)(a0,{children:(0,r.jsx)(a6,{children:(0,r.jsx)(rn,{children:(0,r.jsxs)(rs,{children:[(0,r.jsx)(uy,{children:(0,r.jsx)(tA,{children:(0,r.jsxs)(tx,{withSidebar:!0,sidebarSize:"slim",children:[(0,r.jsx)(tg,{children:(0,r.jsx)(c6,{})}),(0,r.jsx)(tx,{children:(0,r.jsx)(tf,{children:(0,r.jsxs)("div",{"data-main-layout-container":!0,className:"h-auto",children:[(0,r.jsx)(jf,{}),(0,r.jsx)(jb,{}),(0,r.jsx)("div",{"data-main-layout-content":!0,children:(0,r.jsx)(jg,{})})]})})})]})})}),(0,r.jsx)(rv,{})]})})})})})}function jj(){return(0,r.jsx)(aG,{children:(0,r.jsx)(sv,{children:(0,r.jsx)(jy,{})})})}function jw(){return(0,r.jsx)(jj,{})}let jN=new(s(74747)).E({defaultOptions:{queries:{staleTime:3e4,retry:!1}}}),jk=(0,d.un)({getParentRoute:()=>R,path:"/",component:function(){let e=(0,M.Z)();return(0,r.jsxs)("main",{className:"min-h-screen flex flex-col items-center justify-center gap-8 px-6 text-center",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,r.jsx)("img",{src:"/logo.png",alt:"AIOStreams",className:"max-h-[90px] object-contain"}),(0,r.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"AIOStreams"}),(0,r.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,r.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[(0,r.jsx)(w,{intent:"primary",onClick:()=>{e({to:"/stremio/configure"})},children:"Configure"}),(0,r.jsx)(w,{intent:"primary-outline",onClick:()=>e({to:"/dashboard"}),children:"Dashboard"}),(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>window.open("https://docs.aiostreams.viren070.me","_blank"),children:"Documentation"})]})]})}}),jS=(0,d.un)({getParentRoute:()=>R,path:"/login",beforeLoad:async()=>{let e=await jN.ensureQueryData(e5).catch(()=>null);if(e){let t=tn(new URLSearchParams(window.location.search).get("next"));if(!e.isAdmin&&t.startsWith("/dashboard"))return;throw(0,c.V2)({href:t})}},component:function(){let e=(0,o.jE)(),{status:t}=tr(),[s,a]=n.useState(""),[l,i]=n.useState(""),d=new URLSearchParams(window.location.search),c=n.useRef(d.get("error")).current,u=null==t?void 0:t.settings.oidc,m=(null==u?void 0:u.localLoginEnabled)!==!1,p=`/api/v1/auth/oidc/start?next=${encodeURIComponent(tn(d.get("next")))}`;n.useEffect(()=>{let e=c?tl[c]:void 0;if(e){x.oR.error(e.title,{description:e.description}),d.delete("error");let t=d.toString();window.history.replaceState(null,"",t?`?${t}`:window.location.pathname)}},[]),n.useEffect(()=>{(null==u?void 0:u.enabled)&&u.autoRedirect&&(d.has("local")||c||window.location.assign(p))},[null==u?void 0:u.enabled,null==u?void 0:u.autoRedirect]);let{mutate:h,isPending:g}=(0,e2.n)({mutationFn:e=>{let{username:t,password:s}=e;return ei(t,s)},onSuccess:t=>{e.setQueryData(e5.queryKey,t);let s=new URLSearchParams(window.location.search);window.location.href=tn(s.get("next"))},onError:e=>{e instanceof en&&e.is("UNAUTHORIZED")?x.oR.error("Invalid username or password"):e instanceof en&&e.is("RATE_LIMIT_EXCEEDED")?x.oR.error("Too many attempts. Please try again later."):x.oR.error(e instanceof Error?e.message:"Failed to log in")}});return(0,r.jsx)("main",{className:"min-h-screen flex items-center justify-center px-6",children:(0,r.jsxs)(X,{className:"w-full max-w-sm p-6",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2 mb-6",children:[(0,r.jsx)("img",{src:"/logo.png",alt:"AIOStreams",className:"max-h-[60px] object-contain"}),(0,r.jsx)("h1",{className:"text-xl font-semibold",children:"Sign in"}),(0,r.jsx)("p",{className:"text-sm text-[--muted] text-center",children:"Log in to access this AIOStreams instance."}),m&&(0,r.jsxs)("p",{className:"text-xs text-[--muted] text-center",children:["Use a username and password from your instance's"," ",(0,r.jsx)("code",{className:"text-[--foreground]",children:"AIOSTREAMS_AUTH"})," ","environment variable"]})]}),(null==u?void 0:u.enabled)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4 mb-4",children:[(0,r.jsx)(w,{intent:"primary-outline",className:"w-full",onClick:()=>window.location.assign(p),children:u.buttonLabel}),m&&(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"h-px flex-1 bg-[--border]"}),(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"or"}),(0,r.jsx)("span",{className:"h-px flex-1 bg-[--border]"})]})]}),m&&(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault(),s&&l&&h({username:s,password:l})},className:"flex flex-col gap-4",children:[(0,r.jsx)(G,{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,r.jsx)(Z,{label:"Password",id:"password",name:"password",value:l,required:!0,placeholder:"Enter your password",onValueChange:i}),(0,r.jsx)(w,{type:"submit",intent:"primary",loading:g,disabled:g,className:"w-full",children:"Sign in"})]})]})})}}),jC=(0,d.un)({getParentRoute:()=>R,path:"/oauth/callback/gdrive",component:function(){let{mutate:e,isPending:t,data:s,error:a}=(0,e2.n)({mutationFn:e=>eD(e)});(0,n.useEffect)(()=>{let t=new URLSearchParams(window.location.search),s=t.get("error"),a=t.get("code");!s&&a&&e(a)},[]);let l=async()=>{(null==s?void 0:s.refreshToken)&&await r9(s.refreshToken,{onSuccess:()=>x.oR.success("Copied!"),onError:()=>x.oR.error("Failed to copy")})},i=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,r.jsx)(A,{showSpinner:!0,children:(0,r.jsx)(c7,{words:"Processing OAuth callback...",className:"text-2xl"})}):i?(0,r.jsx)(A,{showSpinner:!1,children:(0,r.jsx)(N,{title:"OAuth Error",showRefreshButton:!0,children:(0,r.jsx)("p",{children:i})})}):(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen p-4",children:(0,r.jsxs)(X,{className:"w-full max-w-lg p-6",children:[(0,r.jsx)("h1",{className:"text-2xl font-bold mb-4",children:"Google Drive Authorisation"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"text-[--muted] space-y-2",children:[(0,r.jsx)("p",{children:"Authorisation successful! Please follow these steps:"}),(0,r.jsxs)("ol",{className:"list-decimal list-inside space-y-1",children:[(0,r.jsx)("li",{children:"Copy the refresh token below"}),(0,r.jsx)("li",{children:"Return to the previous tab"}),(0,r.jsx)("li",{children:"Paste the refresh token into the Refresh Token field"})]})]}),(null==s?void 0:s.refreshToken)&&(0,r.jsx)("div",{className:"relative",children:(0,r.jsxs)("div",{className:"p-4 pr-12 bg-[--subtle] rounded-md relative",children:[(0,r.jsx)("p",{className:"text-sm font-mono break-all",children:s.refreshToken}),(0,r.jsx)(E,{icon:(0,r.jsx)(t2.Xpf,{}),intent:"primary-subtle",className:"absolute top-1/2 -translate-y-1/2 right-2",onClick:l,"aria-label":"Copy authorization code"})]})})]})]})})}}),j_=(0,d.un)({getParentRoute:()=>R,path:"/splashscreen",component:function(){return(0,r.jsxs)(A,{showSpinner:!1,children:[(0,r.jsx)("img",{src:"/logo_2.png",alt:"Launching...",width:180,height:180,className:"animate-pulse"}),"Launching..."]})}});async function jA(e){var t;let{location:s}=e,a=await jN.ensureQueryData(e4).catch(()=>null);if((null==a||null==(t=a.settings)?void 0:t.protected)&&!await jN.ensureQueryData(e5).catch(()=>null))throw(0,c.V2)({to:"/login",search:{next:s.href}})}let jR=(0,d.un)({getParentRoute:()=>R,path:"/stremio/configure",beforeLoad:jA,component:jw}),jT=(0,d.un)({getParentRoute:()=>R,path:"/stremio/$uuid/$encryptedPassword/configure",beforeLoad:jA,component:jw}),jI=(0,d.un)({getParentRoute:()=>R,path:"/stremio/$uuid/$encryptedPassword/v/$variantSelector/configure",beforeLoad:jA,component:jw}),jE=(0,d.un)({getParentRoute:()=>R,path:"/dashboard",beforeLoad:async e=>{let{location:t}=e,s=await jN.ensureQueryData(e5).catch(()=>null);if(!s)throw(0,c.V2)({to:"/login",search:{next:t.href}});if(!s.isAdmin)throw(0,c.V2)({to:"/login",search:{next:t.href,error:"forbidden"}})},component:function(){let{signOut:e}=t1(),{pathname:t}=(0,ti.z)(),s=(0,M.Z)(),a=tX({title:"Sign Out",description:"Are you sure you want to sign out?",onConfirm:async()=>{await e(),window.location.href="/login"}}),n=t8.map(e=>{let a=t7[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})}}),l=[{name:"Configure",iconType:t2.Wyp,onClick:()=>s({to:"/stremio/configure"})},{name:"Sign Out",iconType:t2.eZR,onClick:()=>a.open()}];return(0,r.jsxs)(ss,{children:[(0,r.jsxs)(tA,{children:[(0,r.jsxs)(tx,{withSidebar:!0,sidebarSize:"slim",children:[(0,r.jsx)(tg,{children:(0,r.jsx)(tG,{header:(0,r.jsx)(rB,{}),items:n,footerItems:l})}),(0,r.jsx)(tx,{children:(0,r.jsxs)(tf,{children:[(0,r.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,r.jsx)(t_,{}),(0,r.jsx)(rK,{}),(0,r.jsx)(t3,{})]}),(0,r.jsx)(m.s,{})]})})]}),(0,r.jsx)(t0,{...a})]}),(0,r.jsx)(rO,{})]})}}),jM=(0,d.un)({getParentRoute:()=>jE,path:"/",component:function(){var e,t,s,a,l;let i=(0,ta.I)({queryKey:["dashboard","overview"],queryFn:()=>el("/dashboard/analytics/overview"),staleTime:3e4}),o=(0,ta.I)({queryKey:["dashboard","tasks"],queryFn:()=>el("/dashboard/tasks"),refetchInterval:1e4}),d=(0,ta.I)({queryKey:["dashboard","overview","logs"],queryFn:()=>el("/dashboard/logs?order=desc&limit=10&level=error,warn"),refetchInterval:15e3}),{metrics:c}=om(),u=(null==(e=cA({pending:!0,limit:1}).data)?void 0:e.total)??0,m=(0,ta.I)({queryKey:[...iN,"live","glance"],queryFn:()=>el("/dashboard/usenet/live"),staleTime:5e3,refetchInterval:1e4}).data,p=((null==m?void 0:m.pool.providers.length)??0)>0,h=n.useMemo(()=>{var e;let t=(null==(e=o.data)?void 0:e.tasks)??[];return 0===t.length?null:Math.round(t.filter(e=>"error"===e.lastStatus).length/t.length*100)},[o.data]),x=n.useMemo(()=>{var e;let t=((null==(e=o.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)},[o.data]);return(0,r.jsxs)(r6,{className:"space-y-6 p-4 sm:p-8",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Dashboard"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Live overview of this AIOStreams instance."})]}),(0,r.jsxs)("div",{className:b("grid grid-cols-2 gap-3",u>0?"lg:grid-cols-5":"lg:grid-cols-4"),children:[(0,r.jsx)(cQ,{label:"Users",value:(null==(t=i.data)?void 0:t.totalUsers)??"—",hint:i.data?`+${i.data.newUsers.d1} today \xb7 +${i.data.newUsers.d7} this week`:void 0}),(0,r.jsx)(cQ,{label:"Active 24h",value:(null==(s=i.data)?void 0:s.activeUsers.d1)??"—",hint:i.data?`${i.data.activeUsers.d7} this week`:void 0}),(0,r.jsx)(cQ,{label:"Requests 24h",value:(null==(a=i.data)?void 0:a.requests24h)??"—"}),(0,r.jsx)(cQ,{label:"Task failures",value:null==h?"—":`${h}%`,intent:null==h?void 0:h>0?"err":"ok",hint:o.data?`${o.data.tasks.length} tasks tracked`:void 0}),u>0&&(0,r.jsx)(cz.N_,{to:"/dashboard/community/pending",className:"group col-span-2 block rounded-xl lg:col-span-1",children:(0,r.jsx)(cQ,{label:"Review queue",value:u,intent:"warn",hint:"Community submissions waiting",className:"h-full transition-colors group-hover:border-[--muted]/40 group-hover:bg-[--subtle]/50"})})]}),c&&(0,r.jsx)(cY,{metrics:c}),(0,r.jsxs)("div",{className:b("grid grid-cols-1 gap-3 sm:grid-cols-2",p&&"xl:grid-cols-3"),children:[(0,r.jsx)(cK,{}),(0,r.jsx)(cH,{}),p&&m&&(0,r.jsx)(cZ,{data:m})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,r.jsx)(cV,{to:"/dashboard/tasks",icon:t2.grf,title:"Recent task runs",children:o.isError?(0,r.jsx)(cq,{children:"Failed to load tasks."}):0===x.length?(0,r.jsx)(cq,{children:"No task runs yet."}):(0,r.jsx)("ul",{className:"space-y-1.5 text-sm",children:x.map(e=>(0,r.jsxs)("li",{className:"flex items-center gap-2 justify-between",children:[(0,r.jsx)("span",{className:"truncate",children:e.label}),(0,r.jsxs)("span",{className:"flex items-center gap-2 text-xs text-[--muted]",children:[(0,r.jsx)("span",{className:b("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,r.jsx)("span",{children:(e=>{if(!e)return"never";let t=(Date.now()-e)/1e3;return t<0?`in ${nn(-t)}`:`${nn(t)} ago`})(e.lastRunAt)}),null!=e.lastDurationMs&&(0,r.jsxs)("span",{children:["\xb7 ",e.lastDurationMs,"ms"]})]})]},e.id))})}),(0,r.jsx)(cV,{to:"/dashboard/logs",icon:t2.m4U,title:"Recent warnings & errors",children:d.isError?(0,r.jsx)(cq,{children:"Failed to load recent logs."}):(null==(l=d.data)?void 0:l.logs.length)?(0,r.jsx)("ul",{className:"space-y-1 text-xs",children:d.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,r.jsxs)("li",{className:"truncate",title:e.line,children:[(0,r.jsx)("span",{className:b("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,r.jsxs)("span",{className:"text-[--muted-highlight] font-mono",children:["[",t.module,"]"," "]}),(0,r.jsx)("span",{className:"text-[--foreground]",children:t.msg})]},e.seq)})}):(0,r.jsx)(cq,{children:"No recent warnings."})})]}),(0,r.jsx)(cW,{})]})}}),jP=(0,d.un)({getParentRoute:()=>jE,path:"analytics",component:function(){let[e,t]=n.useState("7d"),[s,a]=n.useState(null),l=(0,ta.I)({queryKey:["dashboard","analytics","overview"],queryFn:()=>el("/dashboard/analytics/overview"),staleTime:3e4}),i=(0,ta.I)({queryKey:["dashboard","analytics","users",e],queryFn:()=>el(`/dashboard/analytics/users?range=${e}`),staleTime:3e4}),o=(0,ta.I)({queryKey:["dashboard","analytics","requests",e],queryFn:()=>el(`/dashboard/analytics/requests?range=${e}`),staleTime:3e4}),d=(0,ta.I)({queryKey:["dashboard","analytics","addons",e],queryFn:()=>el(`/dashboard/analytics/addons?range=${e}`),staleTime:3e4}),c=(0,ta.I)({queryKey:["dashboard","analytics","features",e],queryFn:()=>el(`/dashboard/analytics/features?range=${e}`),staleTime:3e4}),u=l.data;return(0,r.jsxs)(r6,{className:"p-4 sm:p-8 space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Analytics"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Usage, requests and addon health. Only anonymized IP prefixes (first 3 octets) are stored."})]}
90),(0,r.jsx)(oo,{value:e,onChange:t})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,r.jsx)(on,{label:"Configured users",value:u?(0,r.jsx)(ol,{value:u.totalUsers}):"—",hint:u?`+${nc(u.newUsers.d7)} this week`:""}),(0,r.jsx)(on,{label:"New users (24h)",value:u?(0,r.jsx)(ol,{value:u.newUsers.d1}):"—",hint:u?`${nc(u.newUsers.d30)} in 30d`:""}),(0,r.jsx)(on,{label:"Active users (24h)",value:u?(0,r.jsx)(ol,{value:u.activeUsers.d1}):"—",hint:u?`${nc(u.activeUsers.d7)} in 7d`:""}),(0,r.jsx)(on,{label:"Requests (24h)",value:u?(0,r.jsx)(ol,{value:u.requests24h}):"—"})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"User growth"}),(0,r.jsx)(iq,{query:i,errorTitle:"Failed to load user analytics",children:e=>(0,r.jsx)(ot,{data:e.growth,xKey:"day",series:[{key:"total",label:"Total",color:"var(--brand)"},{key:"new",label:"New"}],height:260})})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Requests by resource"}),(0,r.jsx)(iq,{query:o,errorTitle:"Failed to load request analytics",children:e=>(0,r.jsx)(os,{data:e.series,xKey:"day",stacked:!0,series:e.resources.map(e=>({key:e})),height:260})})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold",children:["Addon usage & errors"," ",(0,r.jsx)("span",{className:"text-[--muted] font-normal",children:"(marketplace defaults only)"})]}),d.data&&(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:[d.data.customEndpoints," custom endpoint",1===d.data.customEndpoints?"":"s"," excluded"]})]}),(0,r.jsx)(iq,{query:d,errorTitle:"Failed to load addon analytics",children:e=>e.addons.length?(0,r.jsxs)("div",{className:"grid lg:grid-cols-[1fr,240px] gap-6 items-center",children:[(0,r.jsx)("div",{className:"overflow-x-auto -mx-4 px-4 lg:mx-0 lg:px-0",children:(0,r.jsxs)("table",{className:"w-full text-sm min-w-[560px]",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase",children:(0,r.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,r.jsx)("th",{className:"py-2 pr-3",children:"Addon"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Requests"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Share"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Errors"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Err %"}),(0,r.jsx)("th",{className:"py-2 pl-3 text-right",children:"Avg ms"})]})}),(0,r.jsx)("tbody",{children:e.addons.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,r.jsx)("td",{className:"py-2 pr-3 font-medium",children:e.presetId}),(0,r.jsx)("td",{className:"py-2 px-3 text-right",children:(0,r.jsx)(ol,{value:e.requests})}),(0,r.jsxs)("td",{className:"py-2 px-3 text-right tabular-nums",children:[e.share,"%"]}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:e.errors}),(0,r.jsxs)("td",{className:b("py-2 px-3 text-right tabular-nums",e.errorRate>10&&"text-red-400"),children:[e.errorRate,"%"]}),(0,r.jsx)("td",{className:"py-2 pl-3 text-right tabular-nums",children:e.avgLatencyMs??"—"})]},e.presetId))})]})}),(0,r.jsx)("div",{className:"mx-auto w-full max-w-[240px] aspect-square",children:(0,r.jsx)(oa,{data:e.addons.slice(0,6).map(e=>({name:e.presetId,value:e.requests})),centerLabel:"requests",centerValue:nc(e.total),height:240})})]}):(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No addon data for this range."})})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Feature usage"}),(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"distinct users per day, summed"})]}),(0,r.jsx)(iq,{query:c,errorTitle:"Failed to load feature analytics",children:e=>(0,r.jsxs)("div",{className:"grid lg:grid-cols-3 gap-6",children:[(0,r.jsx)(od,{title:"Services",rows:e.service}),(0,r.jsx)(od,{title:"Formatters",rows:e.formatter}),(0,r.jsx)(od,{title:"Presets",rows:e.preset})]})})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Most active users (hashed)"}),(0,r.jsx)(iq,{query:i,errorTitle:"Failed to load top users",children:e=>e.topUsers.length?(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsx)("table",{className:"w-full text-sm",children:(0,r.jsx)("tbody",{children:e.topUsers.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,r.jsx)("td",{className:"py-1.5 font-mono text-xs text-[--muted] break-all",children:e.uuidHash.slice(0,16)}),(0,r.jsx)("td",{className:"py-1.5 pl-3 text-right whitespace-nowrap",children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsx)(ol,{value:e.requests}),(0,r.jsx)(tO,{trigger:(0,r.jsx)("button",{onClick:()=>a(e.uuidHash),"aria-label":"View user activity",className:"text-[--muted] transition-colors hover:text-brand",children:(0,r.jsx)(lj.S8s,{className:"size-4"})}),children:"View activity"})]})})]},e.uuidHash))})})}):(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No data for this range."})})]}),(0,r.jsx)(oc,{uuidHash:s,range:e,onClose:()=>a(null)})]})}}),jD=(0,d.un)({getParentRoute:()=>jE,path:"logs",component:function(){let e=(0,n.useMemo)(nf,[]),[t,s]=(0,n.use
90State)(e.autoscroll),[a,l]=(0,n.useState)(e.wrap),[i,o]=(0,n.useState)(e.levels),[d,c]=(0,n.useState)(void 0),[u,m]=(0,n.useState)(""),[p,h]=(0,n.useState)(!1),g=r5(u,250),[f,v]=(0,n.useState)(new Set),y=tX({title:"Clear logs",description:"This permanently removes all retained logs. This cannot be undone.",actionText:"Clear",actionIntent:"alert-subtle",onConfirm:async()=>{try{await el("POST /dashboard/logs/clear",{body:{confirm:!0}}),T(),x.oR.success("Logs cleared")}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to clear logs")}}}),j=(0,n.useMemo)(()=>{if(!p||!u)return null;try{return new RegExp(u),null}catch(e){return e instanceof Error?e.message:"Invalid regex"}},[p,u]);(0,n.useEffect)(()=>{localStorage.setItem(ng,JSON.stringify({autoscroll:t,wrap:a,levels:i}))},[t,a,i]);let k=(0,n.useMemo)(()=>({q:g,regex:p&&!j,levels:i,module:d}),[g,p,j,i,d]),{rows:S,loading:_,connected:A,error:R,clear:T,retry:I}=function(e){let[t,s]=(0,n.useState)([]),[a,r]=(0,n.useState)(!0),[l,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(null),[c,u]=(0,n.use
90State)(0),m=(0,n.useRef)(0),p=r2(e),h=(0,n.useCallback)(()=>u(e=>e+1),[]);return(0,n.useEffect)(()=>{let e=!1,t=null;return r(!0),d(null),s([]),m.current=0,(async()=>{try{let t=p?`&${p}`:"",a=await el(`/dashboard/logs?order=asc&limit=2000${t}`);if(e)return;let r=a.logs.map(e=>r1(e.seq,e.line));s(r),m.current=r.length?r[r.length-1].seq:a.nextSeq}catch(t){e||d(t instanceof Error?t.message:"Failed to load logs")}finally{e||r(!1)}if(e)return;let a=`since=${m.current}${p?`&${p}`:""}`;(t=new EventSource(`/api/v1/dashboard/logs/stream?${a}`,{withCredentials:!0})).onopen=()=>!e&&i(!0),t.onerror=()=>!e&&i(!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=r1(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(),i(!1)}},[p,c]),{rows:t,loading:a,connected:l,error:o,clear:(0,n.useCallback)(()=>s([]),[]),retry:h}}(k),[M,P]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=setTimeout(()=>P(!0),400);return()=>clearTimeout(e)},[]);let D=(0,n.useMemo)(()=>{let e=new Set;return S.forEach(t=>t.module&&e.add(t.module)),[{value:nx,label:"All modules"},...[...e].sort().map(e=>({value:e,label:e}))]},[S]),$=(0,n.useRef)(null),O=(0,n.useRef)(!0),[U,F]=(0,n.useState)(!0),z=(0,n.useRef)(0),V=(0,rH.T)({count:S.length,getScrollElement:()=>$.current,estimateSize:()=>30,overscan:20}),q=(0,n.useCallback)(()=>{let e=()=>{let e=$.current;e&&S.length&&(V.scrollToIndex(S.length-1,{align:"end"}),e.scrollTop=e.scrollHeight,z.current=e.scrollTop)};e(),requestAnimationFrame(()=>{e(),requestAnimationFrame(e)})},[S.length,V]);(0,n.useEffect)(()=>{M&&!_&&!R&&t&&O.current&&q()},[S.length,M,_,R,t,q]);let B=(0,n.useCallback)(()=>{let e=$.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))},[]),K=()=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rZ,{label:"Auto-scroll",labelClass:"whitespace-nowrap",side:"right",value:t,onValueChange:e=>{s(e),e&&(O.current=!0,F(!0),q())}}),(0,r.jsx)(rZ,{label:"Wrap",side:"right",value:a,onValueChange:l})]}),H=V.getVirtualItems();return(0,r.jsx)(r6,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsxs)("div",{className:"flex flex-col h-[calc(100vh-6rem)]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Logs"}),(0,r.jsxs)("p",{className:"text-[--muted]",children:["Live tail of recent logs."," ",(0,r.jsx)("span",{className:b("inline-block w-2 h-2 rounded-full align-middle",A?"bg-emerald-500":"bg-[--muted]")})," ",(0,r.jsxs)("span",{className:"text-xs",children:[A?"streaming":"disconnected"," \xb7 ",S.length," shown"]})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,r.jsx)(E,{size:"sm",intent:"gray-outline",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Clear logs",onClick:()=>y.open()}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(t2.Ah9,{}),onClick:()=>window.open(r3(k,"log"),"_blank"),children:".log"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(t2.Ah9,{}),onClick:()=>window.open(r3(k,"json"),"_blank"),children:".json"})]})]}),(0,r.jsxs)(X,{className:"p-3 mb-3 flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-3 items-center",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-[240px] flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(G,{leftIcon:(0,r.jsx)(t2.iyI,{}),placeholder:p?"Regex pattern…":"Search all retained logs…",value:u,onValueChange:m,className:b("flex-1",j&&"border-red-400 focus-within:border-red-400")}),(0,r.jsx)("button",{type:"button",title:"Toggle regex search",onClick:()=>h(e=>!e),className:b("shrink-0 h-9 px-2 rounded-md border text-xs font-mono transition-colors",p&&!j?"border-brand bg-brand/10 text-brand":p&&j?"border-red-400 bg-red-500/10 text-red-400":"border-[--border] text-[--muted] hover:text-[--foreground] hover:border-[--foreground]"),children:".*"})]}),j&&(0,r.jsx)("p",{className:"text-xs text-red-400 pl-1",children:j})]}),(0,r.jsxs)("div",{className:"flex flex-1 md:flex-none items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-1 md:min-w-[180px]",children:(0,r.jsx)(r0,{options:D,value:d??nx,onValueChange:e=>c(e===nx?void 0:e)})}),(0,r.jsx)("div",{className:"lg:hidden shrink-0",children:(0,r.jsx)(L,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-outline",icon:(0,r.jsx)(t2.voe,{}),"aria-label":"Log view options"}),children:(0,r.jsx)("div",{className:"flex flex-col gap-4 p-1 min-w-[180px]",children:K()})})})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[nm.map(e=>(0,r.jsx)("button",{onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:b("px-2 py-0.5 rounded text-xs uppercase font-semibold border transition-colors",i.includes(e)?"border-brand bg-brand/10":"border-[--border] text-[--muted] hover:text-[--foreground]",i.includes(e)&&np[e]),children:e},e)),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("div",{className:"hidden lg:flex items-center gap-5",children:K()})]})]}),(0,r.jsxs)(X,{className:"flex-1 relative overflow-hidden p-0",children:[(!M||_)&&(0,r.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 z-10",children:[(0,r.jsx)(C,{className:"w-8 h-8"}),(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:"Loading logs…"})]}),R&&M&&!_&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:(0,r.jsx)(N,{title:"Failed to load logs",reset:I,children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:R})})}),M&&!_&&!R&&0===S.length&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center text-[--muted] text-sm",children:"No logs match the current filters."}),(0,r.jsx)("div",{ref:$,onScroll:B,className:"h-full overflow-auto",children:M&&!_&&!R&&(0,r.jsx)("div",{style:{height:V.getTotalSize(),position:"relative"},children:H.map(e=>{let t=S[e.index];return(0,r.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,r.jsx)(nv,{row:t,wrap:a,expanded:f.has(t.seq),onToggle:()=>{let e;return e=t.seq,v(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})}})},t.seq)})})}),t&&!U&&(0,r.jsx)(w,{size:"sm",intent:"primary",className:"absolute bottom-4 right-4 shadow-lg",leftIcon:(0,r.jsx)(t2.oVj,{}),onClick:()=>{O.current=!0,F(!0),q()},children:"Jump to latest"})]}),(0,r.jsx)(t0,{...y})]})})}}),j$=(0,d.un)({getParentRoute:()=>jE,path:"system",component:function(){let{metrics:e,connected:t,history:s,windowMs:a,error:l,retry:i}=om(),[o,d]=n.useState("system"),[c,u]=n.useState("average"),[m,p]=n.useState(!1),h=tX({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),el("POST /dashboard/system/stop",{body:{confirm:"STOP"}}).then(()=>{x.oR.success("Process stopping — it stays down until something starts it again.")}).catch(e=>{x.oR.error((null==e?void 0:e.message)??"Failed to stop")}).finally(()=>p(!1))}});if(!e)return l?(0,r.jsx)(r6,{className:"p-4 sm:p-8",children:(0,r.jsx)(iV,{title:"Failed to load system metrics",message:l,onRetry:i})}):(0,r.jsx)(r6,{className:"p-4 sm:p-8",children:(0,r.jsx)(iz,{})});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:oh(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:oh(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,o,c),v="process"===o?e.cpu.process??0:e.cpu.total;return(0,r.jsxs)(r6,{className:"p-4 sm:p-8 space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"System"}),(0,r.jsxs)("p",{className:"text-[--muted]",children:[(0,r.jsx)("span",{className:`inline-block w-2 h-2 rounded-full align-middle ${t?"bg-emerald-500":"bg-[--muted]"}`})," ",(0,r.jsx)("span",{className:"text-xs",children:t?"live":"reconnecting"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{intent:"alert-outline",size:"sm",disabled:!e.lifecycleEnabled||m,loading:m,leftIcon:(0,r.jsx)(t2.ES$,{}),onClick:h.open,children:"STOP"}),(0,r.jsx)(t0,{...h})]})]}),!e.lifecycleEnabled&&(0,r.jsx)(lN,{intent:"info",description:"Stop is disabled. Set SYSTEM_LIFECYCLE_ENABLED=true to enable process lifecycle c
90ontrols."}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,r.jsx)(op,{label:"CPU",pct:e.cpu.total,detail:`${e.cpu.cores} cores${e.cpu.loadavg?` \xb7 load ${e.cpu.loadavg[0].toFixed(2)}`:""}`}),(0,r.jsx)(op,{label:"Memory",pct:g,detail:`${ne(e.memory.used)} / ${ne(e.memory.total)}`}),(0,r.jsx)(op,{label:"Disk (data)",pct:f,detail:e.disk?`${ne(e.disk.used)} / ${ne(e.disk.total)}`:"unavailable"})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex items-start sm:items-center justify-between flex-col sm:flex-row gap-2 mb-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"CPU utilisation"}),(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["Last ",Math.round(a/6e4)," minutes \xb7 live \xb7 now"," ",(0,r.jsxs)("span",{className:"text-[--foreground] tabular-nums",children:[v,"%"]})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(ob,{value:o,onChange:e=>{d(e),"process"===e&&"per-core"===c&&u("average")},options:[{value:"system",label:"System"},{value:"process",label:"Process"}]}),(0,r.jsx)(ob,{value:c,onChange:u,options:[{value:"average",label:"Average"},{value:"per-core",label:"Per-core",disabled:"process"===o,title:"process"===o?"Process CPU is reported as a single aggregate — per-core is only available for system scope.":void 0}]})]})]}),(0,r.jsx)(oe,{data:b.data,xKey:"t",series:b.series,height:220,hideLegend:"per-core"!==c||"process"===o,valueFormatter:e=>`${e}%`})]}),(0,r.jsx)(of,{memory:e.memory,history:s}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Process"}),(0,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[["Uptime",nn(e.process.uptimeSec)],["Node",e.process.nodeVersion],["PID",String(e.process.pid)],["Platform",e.process.platform]].map(e=>{let[t,s]=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:t}),(0,r.jsx)("div",{className:"font-medium break-all",children:s})]},t)})})]})]})}}),jL=e=>"string"==typeof e&&e?e:void 0,jO=(0,d.un)({getParentRoute:()=>jE,path:"settings",validateSearch:e=>({tab:jL(e.tab),field:jL(e.field)}),component:function(){var e,t;let s,{data:a,isLoading:l,error:i,refetch:o}=rE(),d=n.useMemo(()=>a?function(e){let t=new Map;for(let s of e){let e=rS(s.key);(t.get(e)??t.set(e,[]).get(e)).push(s)}let s=[];for(let[e,a]of t){let t=rN[e]??{label:rR(e),icon:r_,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)=>rC(e,t.key)-rC(e,s.key)):a,n=new Map;for(let t of r){let s=function(e,t){var s;let a=null==(s=rN[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]),c=n.useMemo(()=>{let e=new Set(d.flatMap(e=>e.editors??[]));return((null==a?void 0:a.managed)??[]).filter(t=>e.has(t.key))},[a,d]),u=(0,ny.S)({from:"/dashboard/settings"}),m=(0,M.Z)({from:"/dashboard/settings"}),[p,h]=n.useState("");n.useEffect(()=>{var e;if(!d.length)return;let t=u.tab?rN[e=u.tab]?e:rk.get(e)??e:void 0;t&&d.some(e=>e.section===t)?h(t):p||h(d[0].section)},[d,u.tab]);let x=n.useCallback(()=>{m({to:".",search:e=>({...e,field:void 0}),replace:!0,resetScroll:!1})},[m]);if(e=u.field,t=!!p&&d.length>0,s=(0,n.useRef)(null),(0,n.useEffect)(()=>{if(!e){s.current=null;return}t&&s.current!==e&&(s.current=e,x(),re([`setting-${e}`]))},[e,t,x]),l)return(0,r.jsx)(r6,{className:"p-8 flex items-center justify-center",children:(0,r.jsx)(C,{className:"w-8 h-8"})});if(i||!a)return(0,r.jsx)(r6,{className:"p-8",children:(0,r.jsx)(N,{title:"Failed to load settings",reset:()=>o(),children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:String(i)})})});let g=new Map;for(let e of d)(g.get(e.group)??g.set(e.group,[]).get(e.group)).push(e);return(0,r.jsx)(r6,{className:"p-4 sm:p-8 space-y-4 relative",children:(0,r.jsxs)(n_,{value:p,onValueChange:e=>{h(e),m({to:".",search:t=>({...t,tab:e}),replace:!0,resetScroll:!1})},variant:"pill",className:b("w-full grid grid-cols-1 lg:grid lg:grid-cols-[280px,1fr] gap-4"),triggerClass:b("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:b("w-full flex flex-wrap lg:flex-nowrap h-fit","lg:block p-2 lg:p-0"),children:[(0,r.jsx)(nA,{className:"flex-wrap max-w-full lg:space-y-2 lg:sticky lg:top-4",children:(0,r.jsx)(lb,{children:(0,r.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:[...g.entries()].map(e=>{let[t,s]=e;return(0,r.jsxs)(X,{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,r.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,r.jsxs)(nR,{value:e.section,className:"group",children:[(0,r.jsx)(e.icon,{className:"text-xl mr-3 transition-transform duration-200 group-hover:translate-x-0.5"}),e.label]},e.section))]},t)})})})}),(0,r.jsx)("div",{children:d.map(e=>(0,r.jsx)(nT,{value:e.section,className:"space-y-4 animate-in fade-in-0 slide-in-from-bottom-2 duration-300",children:p===e.section&&(0,r.jsx)(iF,{tab:e,allKeys:a.keys,managed:c})},e.section))})]})})}}),jU=(0,d.un)({getParentRoute:()=>jE,path:"streams",component:function(){var e,t;let s=(0,M.Z)(),{pathname:a}=(0,ti.z)(),n=dd(),l=null==(e=n.data)?void 0:e.summary,i=dn(n.data),o=(null==(t=t6.find(e=>a===`/dashboard/streams/${e.id}`))?void 0:t.id)??"active";return(0,r.jsxs)(r6,{className:"space-y-6 p-4 sm:p-8",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Streams"}),(0,r.jsx)("p",{className:"text-[--muted]",children:l?(0,r.jsxs)(r.Fragment,{children:[l.streaming," streaming \xb7 ",l.paused+l.idle," ","paused \xb7"," ",(0,r.jsx)(dt,{value:l.totalBytesPerSec,format:nt,durationSec:i/1e3})]}):"Everything being served through the proxy and the usenet engine"})]}),(0,r.jsx)(dx,{})]}),(0,r.jsx)(oN,{sections:t6,value:o,onChange:e=>s({to:`/dashboard/streams/${e}`})}),(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)(tB.P.div,{initial:{opacity:0,y:6}
90,animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,r.jsx)(m.s,{})},a)})]})}}),jF=(0,d.un)({getParentRoute:()=>jU,path:"/",beforeLoad:()=>{throw(0,c.V2)({to:"/dashboard/streams/active"})}}),jz=(0,d.un)({getParentRoute:()=>jU,path:"active",component:function(){var e,t;let s=dd(),a=dn(s.data),l=(null==(e=s.data)?void 0:e.streams)??[],i=null==(t=s.data)?void 0:t.summary,[o,d]=n.useState(null),[c,u]=n.useState(()=>Date.now());return n.useEffect(()=>{let e=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:[(0,r.jsx)(on,{label:"Streaming",value:String((null==i?void 0:i.streaming)??0),hint:(null==i?void 0:i.connectionLimit)?`Pushing bytes right now \xb7 ${i.connectionLimit} concurrent streams allowed`:"Pushing bytes right now"}),(0,r.jsx)(on,{label:"Paused",value:String(((null==i?void 0:i.paused)??0)+((null==i?void 0:i.idle)??0)),hint:"Connected or waiting, but nothing moving"}),(0,r.jsx)(on,{label:"Combined speed",className:"col-span-2 lg:col-span-1",value:(0,r.jsx)(dt,{value:(null==i?void 0:i.totalBytesPerSec)??0,format:nt,durationSec:a/1e3})})]}),(0,r.jsx)(iq,{query:s,errorTitle:"Failed to load active streams",children:()=>0===l.length?(0,r.jsx)(X,{className:"p-8",children:(0,r.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,r.jsx)("div",{className:"space-y-2",children:l.map(e=>(0,r.jsx)(dA,{stream:e,now:c,frameMs:a,onBlock:d},e.id))})}),(0,r.jsx)(dR,{target:o,onClose:()=>d(null)})]})}}),jV=(0,d.un)({getParentRoute:()=>jU,path:"history",component:function(){var e,t;let s,[a,l]=n.useState("all"),[i,d]=n.useState(""),[c,u]=n.useState(1),[m,p]=n.useState(new Set);n.useEffect(()=>{u(1),p(new Set)},[a,i]);let h=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,ta.I)({queryKey:[...ds,"history",t,s,a,r,l],queryFn:()=>el(`/dashboard/streams/history?${i.toString()}`),placeholderData:ij.rX,staleTime:1e4})}({limit:50,offset:(c-1)*50,transport:"all"===a?"":a,search:i}),g=(s=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el("DELETE /dashboard/streams/history",{body:e?{ids:e}:void 0}),onSuccess:()=>s.invalidateQueries({queryKey:[...ds,"history"]})})),f=(null==(e=h.data)?void 0:e.entries)??[],v=(null==(t=h.data)?void 0:t.total)??0,y=Math.max(1,Math.ceil(v/50)),j=f.length>0&&f.every(e=>m.has(e.id)),N=()=>{p(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})},k=(e,t)=>g.mutateAsync(e).then(e=>{x.oR.success(`${t} (${e.deleted})`),p(new Set),u(1)}).catch(e=>x.oR.error((null==e?void 0:e.message)??"Failed to delete")),S=tX({title:"Clear stream history",description:`Delete all ${v} finished stream${1===v?"":"s"}. Bandwidth totals are stored separately and are not affected.`,actionText:"Clear all",actionIntent:"alert-subtle",onConfirm:()=>void k(void 0,"History cleared")}),C=tX({title:"Delete selected streams",description:`Delete ${m.size} stream${1===m.size?"":"s"} from the history. Bandwidth totals are not affected.`,actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>void k([...m],"Deleted")}),_=m.size>0;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,r.jsx)(G,{leftIcon:(0,r.jsx)(t2.iyI,{}),placeholder:"Search title or URL…",value:i,onValueChange:d,fieldClass:"sm:flex-1 sm:min-w-0"}),(0,r.jsx)(r0,{value:a,options:dI,onValueChange:e=>l(e),fieldClass:"sm:w-40 sm:shrink-0"}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:shrink-0",children:[(0,r.jsx)("span",{className:"text-xs tabular-nums text-[--muted]",children:_?`${m.size} selected`:`${v.toLocaleString()} ${1===v?"entry":"entries"}`}),(0,r.jsx)(w,{size:"sm",intent:"alert-subtle",leftIcon:(0,r.jsx)(t2.id1,{}),loading:g.isPending,disabled:0===v&&!_,onClick:()=>_?C.open():S.open(),children:_?"Delete selected":"Clear all"})]})]}),(0,r.jsx)(iq,{query:h,errorTitle:"Failed to load stream history",children:()=>0===f.length?(0,r.jsx)(X,{className:"p-8",children:(0,r.jsxs)("p",{className:"text-center text-sm text-[--muted]",children:["No finished streams",i||"all"!==a?" match this filter":" yet","."]})}):(0,r.jsxs)(X,{className:"overflow-hidden p-0",children:[(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"w-10 p-3",children:(0,r.jsx)(nB,{value:j,onValueChange:N,"aria-label":"Select all on this page"})}),(0,r.jsx)("th",{className:"p-3",children:"Stream"}),(0,r.jsx)("th",{className:"p-3",children:"User"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Served"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Reqs"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Duration"}),(0,r.jsx)("th",{className:"p-3",children:"Ended"})]})}),(0,r.jsx)("tbody",{children:f.map(e=>{let t=e.endReason?dT[e.endReason]:void 0,s=m.has(e.id);return(0,r.jsxs)("tr",{className:b("border-t border-[--border]/50 hover:bg-[--subtle]/30",s&&"bg-brand/[0.06]"),children:[(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(nB,{value:s,onValueChange:()=>{var t;return t=e.id,void p(e=>{let s=new Set(e);return s.delete(t)||s.add(t),s})},"aria-label":"Select stream"})}),(0,r.jsx)("td",{className:"max-w-[420px] p-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(df,{transport:e.transport}),(0,r.jsx)("span",{className:"truncate",title:e.filename||e.displayUrl||e.targetKey,children:e.filename||e.displayUrl||e.targetKey})]})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{children:dS(e.username)}),e.clientIp&&(0,r.jsx)(dj,{ip:e.clientIp})]})}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:ne(e.bytesServed)}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:e.requests}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums text-[--muted]",children:nd((e.endedAt??e.lastSeenAt)-e.startedAt)}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.endedAt&&(0,r.jsx)("span",{className:"whitespace-nowrap",children:dC(e.endedAt)}),(null==t?void 0:t.className)&&(0,r.jsx)(dv,{className:t.className,children:t.label})]})})]},e.id)})})]})}),(0,r.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,r.jsxs)("span",{className:"tabular-nums",children:["Showing ",(c-1)*50+1,"–",Math.min(50*c,v)," of ",v]}),y>1&&(0,r.jsxs)(oq,{children:[(0,r.jsx)(oK,{direction:"previous",isDisabled:c<=1,onClick:()=>u(e=>Math.max(1,e-1))}),oW(c,y).map((e,t)=>"…"===e?(0,r.jsx)(oH,{},`e${t}`):(0,r.jsx)(oB,{value:e,"data-selected":e===c,onClick:()=>u(e)},e)),(0,r.jsx)(oK,{direction:"next",isDisabled:c>=y,onClick:()=>u(e=>Math.min(y,e+1))})]})]})]})}),(0,r.jsx)(t0,{...S}),(0,r.jsx)(t0,{...C})]})}}),jq=(0,d.un)({getParentRoute:()=>jU,path:"bandwidth",component:function(){let[e,t]=n.useState("30d"),[s,a]=n.useState("total"),l=dc(e),i=l.data,o=(null==i?void 0:i.periodMode)==="monthly",d=n.useMemo(()=>{let e;if(!i)return{rows:[],userSeries:[]};let t=i.seriesByUser.map((e,t)=>({key:`u${t}`,label:e.aggregated?"Others":dS(e.username),color:e.aggregated?"var(--muted)":i4[t%i4.length]})),s=i.seriesByUser.map(e=>new Map(e.series.map(e=>[e.bucketMs,e.bytes])));return{rows:(e=new Map(i.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})(i).map(t=>{var s;let a;return{ms:t,t:(s=i.bucketMs,a=new Date(t),s<864e5?`${String(a.getHours()).padStart(2,"0")}:00`:dE.format(a)),at:i.bucketMs<864e5?dP.format(new Date(t)):dM.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}},[i]),c=o&&i?`since ${new Date(i.periodStart).toLocaleDateString()}`:"rolling 30 days",u=((null==i?void 0:i.globalLimit)??0)>0&&"30d"!==e;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"Bytes served through AIOStreams. Unproxied links are not counted."}
90),(0,r.jsx)(dw,{value:e,onChange:t,options:[{value:"24h",label:"24h"},{value:"7d",label:"7d"},{value:"30d",label:o?"This month":"30d"}]})]}),(0,r.jsx)(iq,{query:l,errorTitle:"Failed to load bandwidth",children:e=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:b("grid grid-cols-2 gap-3",u?"lg:grid-cols-4":"lg:grid-cols-3"),children:[(0,r.jsx)(on,{label:"Total",value:ne(e.total)}),(0,r.jsx)(on,{label:"Usenet",value:ne(e.byTransport.usenet??0),hint:e.total>0?na((e.byTransport.usenet??0)/e.total):void 0}),(0,r.jsx)(on,{label:"Proxy",value:ne(e.byTransport.proxy??0),hint:e.total>0?na((e.byTransport.proxy??0)/e.total):void 0}),u&&(0,r.jsx)(on,{label:"This period",value:ne(e.periodTotal),hint:e.globalLimit>0?`of ${ne(e.globalLimit)} \xb7 ${c}`:c})]}),e.globalLimit>0&&(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Shared bandwidth pool"}),(0,r.jsx)(dD,{used:e.periodTotal,limit:e.globalLimit})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Served over time"}),d.userSeries.length>0&&(0,r.jsx)(dw,{value:s,onChange:a,options:d$})]}),0===e.total?(0,r.jsx)("p",{className:"py-8 text-center text-sm text-[--muted]",children:"Nothing served in this window."}):"user"===s&&d.userSeries.length>0?(0,r.jsx)(oe,{data:d.rows,xKey:"t",series:d.userSeries,height:240,tooltipLabelKey:"at",valueFormatter:e=>ne(Number(e)),yTickFormatter:e=>ne(Number(e))}):(0,r.jsx)(ot,{data:d.rows,xKey:"t",series:[{key:"bytes",label:"Served",color:"var(--brand)"}],height:240,tooltipLabelKey:"at",valueFormatter:e=>ne(Number(e)),yTickFormatter:e=>ne(Number(e))})]}),(0,r.jsxs)(X,{className:"overflow-hidden p-0",children:[(0,r.jsx)("h3",{className:"p-4 pb-3 text-sm font-semibold",children:"By user"}),0===e.byUser.length?(0,r.jsx)("p",{className:"p-8 pt-0 text-center text-sm text-[--muted]",children:"No usage recorded in this window."}):(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"User"}),(0,r.jsx)("th",{className:"p-3",children:"Usage this window"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Streams"})]})}),(0,r.jsx)("tbody",{children:e.byUser.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50",children:[(0,r.jsx)("td",{className:"p-3 font-medium",children:dS(e.username)}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(dD,{used:e.bytes,limit:e.limit})}),(0,r.jsx)("td",{className:"p-3 text-right text-xs tabular-nums text-[--muted]",children:e.connectionLimit>0?(0,r.jsx)(tO,{trigger:(0,r.jsxs)("span",{children:["max ",e.connectionLimit]}),children:"Concurrent stream limit"}):"unlimited"})]},e.username||"(unidentified)"))})]})})]})]})})]})}}),jB=(0,d.un)({getParentRoute:()=>jU,path:"bans",component:function(){var e;let t,s=(0,ta.I)({queryKey:dr,queryFn:()=>el("/dashboard/streams/bans"),staleTime:1e4}),a=(t=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el(`DELETE /dashboard/streams/bans/${encodeURIComponent(e)}`),onSuccess:()=>t.invalidateQueries({queryKey:dr})})),n=(null==(e=s.data)?void 0:e.bans)??[];return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.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,r.jsx)(dL,{})]}),(0,r.jsx)(iq,{query:s,errorTitle:"Failed to load blocks",children:()=>0===n.length?(0,r.jsx)(X,{className:"p-8",children:(0,r.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"No blocks in force."})}):(0,r.jsx)(X,{className:"overflow-hidden p-0",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"User"}),(0,r.jsx)("th",{className:"p-3",children:"Scope"}),(0,r.jsx)("th",{className:"p-3",children:"Reason"}),(0,r.jsx)("th",{className:"p-3",children:"Added"}),(0,r.jsx)("th",{className:"p-3",children:"Expires"}),(0,r.jsx)("th",{className:"p-3"})]})}),(0,r.jsx)("tbody",{children:n.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsx)("td",{className:"p-3 font-medium",children:e.username}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(dv,{children:"user"===e.scope?"All streams":"One title"})}),(0,r.jsx)("td",{className:"max-w-[280px] truncate p-3 text-[--muted]",children:e.reason||"—"}),(0,r.jsxs)("td",{className:"p-3 text-xs text-[--muted]",children:[dC(e.createdAt),e.createdBy?` by ${e.createdBy}`:""]}),(0,r.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,r.jsx)("td",{className:"p-3 text-right",children:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Lift block",disabled:a.isPending,onClick:()=>a.mutateAsync(e.id).then(()=>x.oR.success("Block lifted")).catch(e=>x.oR.error((null==e?void 0:e.message)??"Failed to lift"))})})]},e.id))})]})})})})]})}}),jK=(0,d.un)({getParentRoute:()=>jE,path:"community",component:function(){var e;let t=(0,M.Z)(),{pathname:s}=(0,ti.z)(),a=(null==(e=t9.find(e=>s===`/dashboard/community/${e.id}`))?void 0:e.id)??"pending";return(0,r.jsxs)(r6,{className:"space-y-6 p-4 sm:p-8",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Community"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Formatters and templates shared by users of this instance."})]}),(0,r.jsx)(oN,{sections:t9,value:a,onChange:e=>t({to:`/dashboard/community/${e}`})}),(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)(tB.P.div,{initial:{opacity:0,y:6}
90,animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,r.jsx)(m.s,{})},s)})]})}}),jH=(0,d.un)({getParentRoute:()=>jK,path:"/",beforeLoad:()=>{throw(0,c.V2)({to:"/dashboard/community/pending"})}}),jW=(0,d.un)({getParentRoute:()=>jK,path:"pending",component:function(){let e=cA({pending:!0,limit:200});return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.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,r.jsx)(iq,{query:e,errorTitle:"Failed to load the review queue",children:e=>0===e.entries.length?(0,r.jsx)(X,{className:"p-8",children:(0,r.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"Nothing waiting for review."})}):(0,r.jsx)("div",{className:"space-y-4",children:e.entries.map(e=>(0,r.jsx)(cL,{item:e},e.id))})})]})}}),jG=(0,d.un)({getParentRoute:()=>jK,path:"published",component:function(){let[e,t]=(0,n.useState)("all"),[s,a]=(0,n.useState)(""),[l,i]=(0,n.useState)(0),o=cA({status:"approved",kind:"all"===e?void 0:e,search:s.trim()||void 0,limit:50,offset:l});return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(cU,{}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(G,{value:s,onValueChange:e=>{a(e),i(0)},placeholder:"Search name, description, author",leftIcon:(0,r.jsx)(t2.iyI,{}),className:"w-full sm:w-72"}),(0,r.jsx)(dw,{value:e,onChange:e=>{t(e),i(0)},options:[{value:"all",label:"All"},{value:"formatter",label:"Formatters"},{value:"template",label:"Templates"}]})]}),(0,r.jsx)(iq,{query:o,errorTitle:"Failed to load published items",children:e=>0===e.entries.length?(0,r.jsx)(X,{className:"p-8",children:(0,r.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"Nothing published yet."})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(X,{className:"overflow-hidden p-0",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"Item"}),(0,r.jsx)("th",{className:"p-3",children:"Author"}),(0,r.jsx)("th",{className:"p-3",children:"Tags"}),(0,r.jsx)("th",{className:"p-3",children:"Likes"}),(0,r.jsx)("th",{className:"p-3",children:"Trusted"}),(0,r.jsx)("th",{className:"p-3",children:"Updated"}),(0,r.jsx)("th",{className:"p-3"})]})}),(0,r.jsx)("tbody",{children:e.entries.map(e=>(0,r.jsx)(cF,{item:e},e.id))})]})})}),e.total>50&&(0,r.jsxs)("div",{className:"flex items-center justify-between text-xs text-[--muted]",children:[(0,r.jsxs)("span",{children:[l+1,"–",Math.min(l+50,e.total)," of"," ",e.total]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"gray-outline",disabled:0===l,onClick:()=>i(Math.max(0,l-50)),children:"Previous"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",disabled:l+50>=e.total,onClick:()=>i(l+50),children:"Next"})]})]})]})})]})}}),jY=(0,d.un)({getParentRoute:()=>jK,path:"blocks",component:function(){let e=(0,ta.I)({queryKey:[...c_,"blocks"],queryFn:()=>el("/dashboard/community/blocks"),staleTime:1e4}),t=cR(e=>el(`DELETE /dashboard/community/blocks/${encodeURIComponent(e)}`));return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.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,r.jsx)(iq,{query:e,errorTitle:"Failed to load blocks",children:e=>0===e.blocks.length?(0,r.jsx)(X,{className:"p-8",children:(0,r.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"No blocks in force."})}):(0,r.jsx)(X,{className:"overflow-hidden p-0",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"Kind"}),(0,r.jsx)("th",{className:"p-3",children:"Hash"}),(0,r.jsx)("th",{className:"p-3",children:"Reason"}),(0,r.jsx)("th",{className:"p-3",children:"Added"}),(0,r.jsx)("th",{className:"p-3"})]})}),(0,r.jsx)("tbody",{children:e.blocks.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(dv,{children:"owner"===e.kind?"Configuration":"Address"})}),(0,r.jsxs)("td",{className:"p-3 font-mono text-xs text-[--muted]",children:[e.hash.slice(0,12),"…"]}),(0,r.jsx)("td",{className:"max-w-[320px] truncate p-3 text-[--muted]",children:e.reason||"—"}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:dC(e.createdAt)}),(0,r.jsx)("td",{className:"p-3 text-right",children:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Lift block",disabled:t.isPending,onClick:()=>t.mutateAsync(e.hash).then(()=>x.oR.success("Block lifted")).catch(e=>x.oR.error((null==e?void 0:e.message)??"Failed to lift"))})})]},e.hash))})]})})})})]})}}),jJ=(0,d.un)({getParentRoute:()=>jE,path:"users",component:function(){let e=(0,o.jE)(),[t,s]=n.useState(1),[a,l]=n.useState(25),[i,d]=n.useState(""),[c,u]=n.useState("created_at"),[m,p]=n.useState("desc"),h=r5(i,300),[g,f]=n.useState(null),[b,v]=n.useState(new Set),[y,j]=n.useState(""),[N,k]=n.useState(!1),[S,C]=n.useState(1);n.useEffect(()=>C(t),[t]);let _=(0,ta.I)({queryKey:["dashboard","users",t,a,h,c,m],queryFn:()=>el(`/dashboard/users?page=${t}&limit=${a}&q=${encodeURIComponent(h)}&sort=${c}&dir=${m}`),staleTime:1e4}),A=(0,e2.n)({mutationFn:e=>el(`DELETE /dashboard/users/${e}`),onSuccess:()=>
90{x.oR.success("User config deleted."),e.invalidateQueries({queryKey:["dashboard","users"]})},onError:e=>x.oR.error((null==e?void 0:e.message)??"Delete failed")}),R=(0,e2.n)({mutationFn:e=>el("DELETE /dashboard/users",{body:e}),onSuccess:t=>{x.oR.success(`Deleted ${t.deleted} user config${1===t.deleted?"":"s"}.`),v(new Set),e.invalidateQueries({queryKey:["dashboard","users"]})},onError:e=>x.oR.error((null==e?void 0:e.message)??"Batch delete failed")}),[T,I]=n.useState(null),M=tX({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)}}),P=tX({title:`Delete ${b.size} selected`,description:`This permanently deletes ${b.size} user configurations. This cannot be undone.`,actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>R.mutate({uuids:[...b]})}),D=async e=>{try{f(await el(`/dashboard/users/${e}`))}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to load user")}},$=_.data,L=(null==$?void 0:$.items)??[],O=L.length>0&&L.every(e=>b.has(e.uuid)),U=L.some(e=>b.has(e.uuid))&&!O,F=e=>{v(t=>{let s=new Set(t);if(!0===e)for(let e of L)s.add(e.uuid);else for(let e of L)s.delete(e.uuid);return s})};return(0,r.jsxs)(r6,{className:"p-4 sm:p-8 space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Users"}),(0,r.jsx)("p",{className:"text-[--muted]",children:$?`${$.total} configured users`:"Browse user configs"})]}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 sm:items-center",children:[(0,r.jsx)(G,{leftIcon:(0,r.jsx)(t2.iyI,{}),placeholder:"Search by UUID…",value:i,onValueChange:e=>{d(e),s(1)},className:"flex-1"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"Per page"}),(0,r.jsx)(r0,{value:String(a),options:ov.map(e=>({label:e,value:e})),onValueChange:e=>{l(Number(e)||25),s(1)},className:"w-24"})]})]}),b.size>0&&(0,r.jsxs)(X,{className:"p-3 flex flex-wrap items-center gap-3 border-brand/30 bg-brand/5",children:[(0,r.jsxs)("span",{className:"text-sm",children:[b.size," selected"]}),(0,r.jsx)(w,{size:"sm",intent:"gray-subtle",onClick:()=>v(new Set),children:"Clear"}),(0,r.jsx)(w,{size:"sm",intent:"alert-subtle",leftIcon:(0,r.jsx)(t2.id1,{}),loading:R.isPending,onClick:()=>P.open(),children:"Delete selected"}),h&&(0,r.jsx)(w,{size:"sm",intent:"alert-outline",onClick:()=>{j(""),k(!0)},children:"Delete all matching filter"})]}),(0,r.jsx)(iq,{query:_,errorTitle:"Failed to load users",children:()=>(0,r.jsx)(X,{className:"p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3 w-10",children:(0,r.jsx)(nB,{value:!!O||!!U&&"indeterminate",onValueChange:F,"aria-label":"Select all on page"})}),(0,r.jsx)("th",{className:"p-3",children:"UUID"}),[["created_at","Created"],["accessed_at","Last accessed"]].map(e=>{let[t,s]=e;return(0,r.jsxs)("th",{className:"p-3 cursor-pointer select-none",onClick:()=>{c===t?p(e=>"asc"===e?"desc":"asc"):(u(t),p("desc"))},children:[s,c===t?"asc"===m?" ▲":" ▼":""]},t)}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Req 24h"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,r.jsxs)("tbody",{children:[L.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(nB,{value:b.has(e.uuid),onValueChange:t=>{var s;return s=e.uuid,void v(e=>{let a=new Set(e);return!0===t?a.add(s):a.delete(s),a})},"aria-label":`Select ${e.uuid}`})}),(0,r.jsxs)("td",{className:"p-3 font-mono text-xs cursor-pointer",title:e.uuid,onClick:()=>void r9(e.uuid,{onSuccess:()=>x.oR.success("UUID copied"),onError:()=>x.oR.error("Copy failed")}),children:[e.uuid.slice(0,8),"…",e.uuid.slice(-4)]}),(0,r.jsx)("td",{className:"p-3",children:nu(e.createdAt)}),(0,r.jsx)("td",{className:"p-3",children:nu(e.accessedAt)}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:e.requests24h}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(t2.wfp,{}),"aria-label":"Details",onClick:()=>D(e.uuid)}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Delete",onClick:()=>{I(e.uuid),M.open()}})]})})]},e.uuid)),$&&0===L.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:6,className:"p-8 text-center text-[--muted]",children:"No users found."})})]})]})})})}),$&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:["Showing ",($.page-1)*$.limit+ +(L.length>0),"–",Math.min($.page*$.limit,$.total)," of ",$.total]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"gray-outline",disabled:t<=1,onClick:()=>s(1),children:"\xab"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",disabled:t<=1,onClick:()=>s(e=>Math.max(1,e-1)),children:"Prev"}),(0,r.jsxs)("div",{className:"flex items-center gap-1 text-xs text-[--muted]",children:["Page",(0,r.jsx)(n1,{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,r.jsx)(w,{size:"sm",intent:"gray-outline",disabled:t>=$.pages,onClick:()=>s(e=>Math.min($.pages||1,e+1)),children:"Next"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",disabled:t>=$.pages,onClick:()=>s($.pages||1),children:"\xbb"})]})]}),(0,r.jsx)(tJ,{open:!!g,onOpenChange:e=>!e&&f(null),title:"User detail",children:g&&(0,r.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"UUID"}),(0,r.jsx)("div",{className:"font-mono break-all",children:g.uuid})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"Created"}),nu(g.createdAt)]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"Updated"}),nu(g.updatedAt)]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"Last accessed"}),nu(g.accessedAt)]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"Requests 24h"}),g.requests24h]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted] mb-1",children:"Recent error stages"}),g.recentErrorStages.length?(0,r.jsx)("ul",{className:"space-y-1",children:g.recentErrorStages.map(e=>(0,r.jsxs)("li",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:e.stage}),(0,r.jsx)("span",{className:"tabular-nums text-[--muted]",children:e.count})]},e.stage))}):(0,r.jsx)("span",{className:"text-[--muted]",children:"None"})]})]})}),(0,r.jsx)(t0,{...M}),(0,r.jsx)(t0,{...P}),(0,r.jsx)(tJ,{open:N,onOpenChange:k,title:"Delete all users matching filter",footer:(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",size:"sm",onClick:()=>k(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"alert-subtle",size:"sm",disabled:"DELETE"!==y||R.isPending,loading:R.isPending,onClick:()=>{R.mutate({allMatching:!0,q:h}),k(!1)},children:"Delete"})]}),children:(0,r.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,r.jsxs)("p",{children:["This permanently deletes ",(0,r.jsx)("strong",{children:"every"})," user configuration matching your current search (",(0,r.jsx)("code",{className:"font-mono",children:h||"<empty>"}),"). This cannot be undone."]}),(0,r.jsxs)("p",{className:"text-[--muted]",children:["Type ",(0,r.jsx)("code",{className:"font-mono",children:"DELETE"})," to confirm."]}),(0,r.jsx)(G,{value:y,onValueChange:j,placeholder:"DELETE"})]})})]})}}),jZ=(0,d.un)({getParentRoute:()=>jE,path:"tasks",component:function(){let e=(0,o.jE)(),t=(0,ta.I)({queryKey:["dashboard","tasks"],queryFn:()=>el("/dashboard/tasks"),refetchInterval:5e3}),s=(0,e2.n)({mutationFn:e=>{let{id:t,confirm:s}=e;return el(`POST /dashboard/tasks/${t}/run`,{body:{confirm:s}})},onSuccess:t=>{x.oR.success((null==t?void 0:t.message)||"Task finished"),e.invali
90dateQueries({queryKey:["dashboard","tasks"]})},onError:e=>x.oR.error((null==e?void 0:e.message)??"Task failed")}),[a,l]=n.useState(null),i=tX({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,r.jsxs)(r6,{className:"p-4 sm:p-8 space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Tasks"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Background & scheduled work. Run manual tasks on demand."})]}),(0,r.jsx)(iq,{query:t,errorTitle:"Failed to load tasks",children:e=>(0,r.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,n]=e;return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h3",{className:"text-xs uppercase tracking-wider text-[--muted] font-semibold",children:t}),(0,r.jsx)("div",{className:"grid gap-2",children:n.map(e=>{var t;return(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"font-medium",children:e.label}),e.destructive&&(0,r.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,r.jsx)("span",{className:b("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,r.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,r.jsx)("p",{className:"text-xs text-[--muted] mt-0.5",children:e.description})]}),(0,r.jsxs)("div",{className:"text-xs text-[--muted] grid grid-cols-2 gap-x-6 gap-y-0.5 sm:min-w-[220px]",children:[(0,r.jsx)("span",{children:"Schedule"}),(0,r.jsx)("span",{className:"text-[--foreground]",children:(t=e.intervalMs)?`every ${nn(t/1e3)}`:"manual"}),(0,r.jsx)("span",{children:"Last run"}),(0,r.jsxs)("span",{className:b("error"===e.lastStatus&&"text-red-400","ok"===e.lastStatus&&"text-emerald-500"),children:[oy(e.lastRunAt),null!=e.lastDurationMs&&` \xb7 ${oj(e.lastDurationMs)}`]}),"scheduled"===e.kind&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:"Next run"}),(0,r.jsx)("span",{className:"text-[--foreground]",children:oy(e.nextRunAt)})]})]}),(0,r.jsx)(w,{size:"sm",intent:e.destructive?"alert-outline":"gray-outline",leftIcon:e.running?void 0:(0,r.jsx)(t2.UIR,{}),loading:e.running||s.isPending&&a===e.id,disabled:e.running,className:"w-full sm:w-auto",onClick:()=>{l(e.id),e.destructive?i.open():s.mutate({id:e.id})},children:"Run now"})]}),e.runs.length>1&&(0,r.jsxs)("details",{className:"mt-3 group",children:[(0,r.jsxs)("summary",{className:"cursor-pointer text-xs text-[--muted] flex items-center gap-1 list-none [&::-webkit-details-marker]:hidden",children:[(0,r.jsx)(t2.nwe,{className:"transition-transform group-open:rotate-180"}),e.runs.length," replicas"]}),(0,r.jsx)("div",{className:"mt-2 grid gap-1",children:e.runs.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)("span",{className:"font-mono text-[--muted]",children:e.instanceId.slice(0,8)}),e.self&&(0,r.jsx)("span",{className:"text-[10px] text-[--muted]",children:"this one"}),(0,r.jsxs)("span",{className:b("ml-auto","error"===e.lastStatus&&"text-red-400","ok"===e.lastStatus&&"text-emerald-500"),children:[oy(e.lastRunAt),null!=e.lastDurationMs&&` \xb7 ${oj(e.lastDurationMs)}`]})]},e.instanceId))})]}),"error"===e.lastStatus&&e.lastError&&(0,r.jsxs)("details",{className:"mt-3 group",children:[(0,r.jsxs)("summary",{className:"cursor-pointer text-xs text-red-400 flex items-center gap-1 list-none [&::-webkit-details-marker]:hidden",children:[(0,r.jsx)(t2.nwe,{className:"transition-transform group-open:rotate-180"}),"Last error"]}),(0,r.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,r.jsx)(t0,{...i})]})}}),jQ=(0,d.un)({getParentRoute:()=>jE,path:"cache",component:function(){let e=(0,o.jE)(),t=(0,ta.I)({queryKey:["dashboard","cache"],queryFn:()=>el("/dashboard/cache"),refetchInterval:1e4}),s=t.data,[a,l]=n.useState({}),[i,d]=n.useState(null),c=async e=>{d(e);try{let t=await el("POST /dashboard/cache/scan",{body:{prefix:e}});l(s=>({...s,[e]:t}))}catch(e){x.oR.error((null==e?void 0:e.message)??"Scan failed")}finally{d(null)}},u=(0,e2.n)({mutationFn:e=>el("POST /dashboard/cache/clear",{body:{confirm:!0,prefix:e}}),onSuccess:()=>
90{x.oR.success("Cache cleared"),e.invalidateQueries({queryKey:["dashboard","cache"]})},onError:e=>x.oR.error((null==e?void 0:e.message)??"Clear failed")}),m=(0,e2.n)({mutationFn:()=>el("POST /dashboard/tasks/clear-expired-cache/run",{body:{}}),onSuccess:t=>{x.oR.success((null==t?void 0:t.message)||"Expired keys cleared"),e.invalidateQueries({queryKey:["dashboard","cache"]})},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed")}),[p,h]=n.useState(),g=tX({title:"Clear cache",description:"This permanently removes cached entries. This cannot be undone.",actionText:"Clear",actionIntent:"alert-subtle",onConfirm:()=>u.mutate(p)}),f=null==s?void 0:s.totals;return(0,r.jsxs)(r6,{className:"p-4 sm:p-8 space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Cache"}),(0,r.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,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(t2.Zxy,{}),loading:m.isPending,onClick:()=>m.mutate(),children:"Clear expired"}),(0,r.jsx)(w,{size:"sm",intent:"alert-outline",leftIcon:(0,r.jsx)(t2.id1,{}),onClick:()=>{h(void 0),g.open()},children:"Clear all"})]})]}),(0,r.jsx)(iq,{query:t,errorTitle:"Failed to load cache",children:e=>(0,r.jsx)(X,{className:"p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"Prefix"}),(0,r.jsx)("th",{className:"p-3",children:"Backend"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Items"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Max"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Est. size"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Expired"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:e.instances.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsx)("td",{className:"p-3 font-mono text-xs",children:e.name}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)("span",{className:b("text-[10px] uppercase px-1.5 py-0.5 rounded border",ow[e.backend]),children:e.backend})}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:null!=e.items?e.items:a[e.name]?(0,r.jsxs)(r.Fragment,{children:[a[e.name].capped?"≥":"",a[e.name].count]}):"—"}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:"disk"===e.backend?ne(e.maxSize):e.maxSize??"—"}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:ne(e.estBytes)}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:e.expired??"—"}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex justify-end gap-1",children:["redis"===e.backend&&null==e.items&&(0,r.jsx)(w,{size:"sm",intent:"gray-subtle",leftIcon:(0,r.jsx)(t2.LUJ,{}),loading:i===e.name,onClick:()=>c(e.name),title:"May be slow on large Redis instances",children:"Scan"}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Clear prefix",onClick:()=>{h(e.name),g.open()}})]})})]},e.name))})]})})})}),(0,r.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,r.jsx)(t0,{...g})]})}}),jX=(0,d.un)({getParentRoute:()=>jE,path:"blocklist",component:function(){var e;let t=(0,M.Z)(),{pathname:s}=(0,ti.z)(),a=oE().data,n=(null==(e=t4.find(e=>s===`/dashboard/blocklist/${e.id}`))?void 0:e.id)??"sources";return(0,r.jsxs)(r6,{className:"p-4 sm:p-8 space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Release Blocklists"}),(0,r.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,r.jsx)(oN,{sections:t4,value:n,onChange:e=>t({to:`/dashboard/blocklist/${e}`})}),(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)(tB.P.div,{initial:{opacity:0,y:6}
90,animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,r.jsx)(m.s,{})},s)})]})}}),j0=(0,d.un)({getParentRoute:()=>jX,path:"/",beforeLoad:()=>{throw(0,c.V2)({to:"/dashboard/blocklist/sources"})}}),j1=(0,d.un)({getParentRoute:()=>jX,path:"sources",component:function(){let e=oE(),t=oM();return(0,r.jsx)(iq,{query:e,errorTitle:"Failed to load the blocklist",children:e=>(0,r.jsx)(oP,{snapshot:e,invalidate:t})})}}),j2=(0,d.un)({getParentRoute:()=>jX,path:"entries",component:function(){let e=oE(),t=oM();return(0,r.jsx)(iq,{query:e,errorTitle:"Failed to load the blocklist",children:e=>(0,r.jsx)(oG,{snapshot:e,invalidate:t})})}}),j3=(0,d.un)({getParentRoute:()=>jX,path:"publishing",component:function(){let e=oE(),t=oM();return(0,r.jsx)(iq,{query:e,errorTitle:"Failed to load the blocklist",children:e=>(0,r.jsx)(o1,{snapshot:e,invalidate:t})})}}),j5=(0,d.un)({getParentRoute:()=>jE,path:"usenet",component:function(){var e;let t=(0,M.Z)(),{pathname:s}=(0,ti.z)(),a=(null==(e=t5.find(e=>s===`/dashboard/usenet/${e.id}`))?void 0:e.id)??"library";return(0,r.jsxs)(r6,{className:"p-4 sm:p-8 space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Usenet"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"The built-in usenet engine — your library, live activity, provider performance and settings."})]}),(0,r.jsx)(oN,{sections:t5,value:a,onChange:e=>t({to:`/dashboard/usenet/${e}`})}),(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)(tB.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,r.jsx)(m.s,{})},s)})]})}}),j4=(0,d.un)({getParentRoute:()=>j5,path:"/",beforeLoad:()=>{throw(0,c.V2)({to:"/dashboard/usenet/library"})}}),j6=(0,d.un)({getParentRoute:()=>j5,path:"library",component:function(){var e,t,s,a;let l,i,d,c,u,m,p;l=(0,o.jE)(),n.useEffect(()=>{let e=new EventSource("/api/v1/dashboard/usenet/library/stream",{withCredentials:!0});return e.onmessage=()=>{l.invalidateQueries({queryKey:[...iN,"library"]})},()=>e.close()},[l]);let[h,g]=n.useState("all"),[f,v]=n.useState(""),y=r5(f,300),[j,w]=n.useState(null),[N,k]=n.useState(null),[S,C]=n.useState(!1),[_,A]=n.useState(new Map),[R,T]=n.useState(d3),I=dO("(min-width: 640px)")?R:"grid",[M,P]=n.useState("activity"),[D,$]=n.useState("desc"),[L,O]=n.useState(1),[U,F]=n.useState(d5);n.useEffect(()=>O(1),[h,y,M,D,U]);let z=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,ta.I)({queryKey:[...iN,"library",t,s,a,o,d,l??"",i??""],queryFn:()=>el(`/dashboard/usenet/library?${c.toString()}`),placeholderData:ij.rX,staleTime:1e4})}({statuses:"all"===h?[]:[h],search:y,sort:M,dir:D,limit:U,offset:(L-1)*U}),V=(i=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el(`DELETE /dashboard/usenet/library/${encodeURIComponent(e)}`),onSuccess:()=>i.invalidateQueries({queryKey:[...iN,"library"]})})),q=(d=(0,o.jE)(),(0,e2.n)({mutationFn:()=>el("DELETE /dashboard/usenet/library"),onSuccess:()=>d.invalidateQueries({queryKey:[...iN,"library"]})})),B=(c=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el("POST /dashboard/blocklist/mark",{body:{releases:e.map(iw).filter(e=>e.length>0),verdict:"dead"}}),onSuccess:()=>{c.invalidateQueries({queryKey:[...iN,"library"]}),c.invalidateQueries({queryKey:["dashboard","blocklist"]})}})),K=(u=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el("POST /dashboard/blocklist/unmark",{body:{releases:e.map(iw).filter(e=>e.length>0)}}),onSuccess:()=>{u.invalidateQueries({queryKey:[...iN,"library"]}
90),u.invalidateQueries({queryKey:["dashboard","blocklist"]})}})),H=(m=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el("POST /dashboard/usenet/library/requeue",{body:{hashes:e}}),onSuccess:()=>m.invalidateQueries({queryKey:[...iN,"library"]})})),W=(p=(0,o.jE)(),(0,e2.n)({mutationFn:e=>el(`POST /dashboard/arr/repairs/${encodeURIComponent(e)}`),onSuccess:()=>p.invalidateQueries({queryKey:[...iN,"library"]})})),Y=n.useRef([]),[J,Z]=n.useState({mode:"block",entries:[]}),Q=(null==(e=z.data)?void 0:e.entries)??[],ee=(null==(t=z.data)?void 0:t.total)??0,et=Math.max(1,Math.ceil(ee/U));n.useEffect(()=>{L>et&&O(et)},[L,et]);let es=tX({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=Y.current;0!==e.length&&Promise.allSettled(e.map(e=>V.mutateAsync(e))).then(t=>{let s=t.filter(e=>"rejected"===e.status).length;s?x.oR.error(`${s} entr${1===s?"y":"ies"} failed to delete`):x.oR.success(1===e.length?"Entry deleted":"Entries deleted"),eg()})}}),ea=tX({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:()=>{q.mutateAsync(void 0).then(()=>{x.oR.success("Library cleared"),eg()}).catch(e=>{x.oR.error((null==e?void 0:e.message)??"Failed to clear library")})}}),er=J.entries.length,en="unblock"===J.mode,ei=(null==(s=J.entries[0])?void 0:s.name)??(null==(a=J.entries[0])?void 0:a.nzbHash)??"",eo=tX({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 "${ei}" 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 "${ei}" 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?K:B).mutateAsync(J.entries).then(()=>{let e=en?"unblocked":"blocked";x.oR.success(1===er?`Release ${e}`:`${er} releases ${e}`),eg()}).catch(e=>x.oR.error((null==e?void 0:e.message)??`${en?"Unblock":"Block"} failed`))}}),ed=e=>{Z({mode:"block",entries:[e]}),eo.open()},ec=e=>{Z({mode:"unblock",entries:[e]}),eo.open()},eu=e=>{W.mutateAsync(e.nzbHash).then(e=>{let{outcome:t}=e;"repaired"===t?x.oR.success("Release marked failed; the arr will replace it"):"already-handled"===t?x.oR.info("The arr had already failed this release"):"not-linked"===t?x.oR.error("No Sonarr/Radarr instance has a grab for this download"):"deferred"===t?x.oR.warning("Repair is backing off after an earlier error"):x.oR.error("Repair gave up; see the entry details")}).catch(e=>x.oR.error((null==e?void 0:e.message)??"Repair failed"))},em=e=>{0!==e.length&&H.mutateAsync(e).then(e=>{0===e.requeued?x.oR.error(e.error??"Requeue failed"):(e.failed>0?x.oR.warning(`${e.requeued} requeued, ${e.failed} failed: ${e.error??""}`):x.oR.success(1===e.requeued?"Entry requeued":`${e.requeued} entries requeued`),eg())}).catch(e=>x.oR.error((null==e?void 0:e.message)??"Requeue failed"))},ep=e=>{Y.current=[e],es.open()},eh=(e,t)=>A(s=>{let a=new Map(s);return t?a.set(e.nzbHash,e):a.delete(e.nzbHash),a}),ex=Q.length>0&&Q.every(e=>_.has(e.nzbHash)),eg=()=>{C(!1),A(new Map)};return(0,r.jsxs)("div",{className:"space-y-4 overflow-x-hidden",children:[(0,r.jsx)(d8,{}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 xl:flex-row xl:items-center",children:[(0,r.jsx)(G,{leftIcon:(0,r.jsx)(t2.iyI,{}),placeholder:"Search by name…",value:f,onValueChange:v,fieldClass:"xl:flex-1 xl:min-w-0"}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center xl:shrink-0",children:[(0,r.jsx)(r0,{value:h,options:dJ,onValueChange:e=>g(e),fieldClass:"sm:w-36 sm:flex-auto xl:flex-none"}),(0,r.jsxs)("div",{className:"flex items-stretch gap-2 sm:flex-auto xl:flex-none",children:[(0,r.jsx)(r0,{value:M,options:dZ,onValueChange:e=>{P(e),$(dQ[e])},fieldClass:"sm:w-40 sm:flex-auto xl:flex-none"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-outline",icon:"asc"===D?(0,r.jsx)(t2.rH8,{}):(0,r.jsx)(t2.stI,{}),"aria-label":"asc"===D?"Ascending":"Descending",onClick:()=>$(e=>"asc"===e?"desc":"asc")}),children:"asc"===D?"Ascending":"Descending"})]}),(0,r.jsx)(r0,{value:String(U),options:d0,onValueChange:e=>(e=>{F(e);try{localStorage.setItem(d2,String(e))}catch{}})(Number(e)),fieldClass:"sm:w-32 sm:flex-auto xl:flex-none"}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:justify-start sm:shrink-0",children:[(0,r.jsx)("div",{className:"hidden sm:block",children:(0,r.jsx)(d4,{value:R,onChange:e=>{T(e);try{localStorage.setItem(d1,e)}catch{}}})}),(0,r.jsx)("div",{className:"flex items-center gap-1.5",children:S?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"text-xs text-[--muted] tabular-nums",children:[_.size," selected"]}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-subtle",icon:ex?(0,r.jsx)(t2.B_A,{}):(0,r.jsx)(t2.aJB,{}),"aria-label":ex?"Clear selection":"Select all",disabled:0===Q.length,onClick:()=>A(e=>{let t=new Map(e);if(ex)for(let e of Q)t.delete(e.nzbHash);else for(let e of Q)t.set(e.nzbHash,e);return t})}),children:ex?"Clear selection":"Select all"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-subtle",icon:(0,r.jsx)(t2.Zxy,{}),"aria-label":"Requeue selected",loading:H.isPending,disabled:0===_.size,onClick:()=>em([..._.keys()])}),children:"Requeue selected"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-subtle",icon:(0,r.jsx)(t2.PLI,{}),"aria-label":"Block selected",loading:B.isPending,disabled:0===_.size,onClick:()=>{let e=[..._.values()].filter(e=>iw(e).length>0);0===e.length?x.oR.error("None of the selected entries can be blocked"):(Z({mode:"block",entries:e}),eo.open())}}),children:"Block selected releases"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"md",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Delete selected",disabled:0===_.size,onClick:()=>{0!==_.size&&(Y.current=[..._.keys()],es.open())}}),children:"Delete selected"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-outline",icon:(0,r.jsx)(t2.Gsv,{}),"aria-label":"Done selecting",onClick:eg}),children:"Done"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"md",intent:"alert-subtle",icon:(0,r.jsx)(t2.id1,{}),"aria-label":"Delete all entries",loading:q.isPending,onClick:ea.open}),children:"Delete all"}),(0,r.jsx)(tO,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-outline",icon:(0,r.jsx)(t2.ekd,{}),"aria-label":"Select entries",disabled:0===Q.length,onClick:()=>C(!0)}),children:"Select"})]})})]})]})]}),(0,r.jsx)(iq,{query:z,errorTitle:"Failed to load library",children:e=>0===e.entries.length?(0,r.jsx)(X,{className:"p-6 text-center text-sm text-[--muted]",children:y.trim()?"No entries match your search.":"No entries for this filter."}):(0,r.jsx)("div",{className:b("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,r.jsx)(ce,{entry:e,view:I,selectMode:S,selected:_.has(e.nzbHash),onToggleSelect:eh,onBrowse:w,onInfo:k,onBlock:ed,onUnblock:ec,onRequeue:em,onRepair:eu,onDelete:ep},e.nzbHash))})}),et>1&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("span",{className:"text-xs text-[--muted] tabular-nums",children:["Showing ",(L-1)*U+ +(Q.length>0),"–",Math.min(L*U,ee)," of ",ee]}),(0,r.jsxs)(oq,{children:[(0,r.jsx)(oK,{direction:"previous",isDisabled:L<=1,onClick:()=>O(e=>Math.max(1,e-1))}),oW(L,et).map((e,t)=>"…"===e?(0,r.jsx)(oH,{},`e${t}`):(0,r.jsx)(oB,{value:e,"data-selected":e===L,onClick:()=>O(e)},e)),(0,r.jsx)(oK,{direction:"next",isDisabled:L>=et,onClick:()=>O(e=>Math.min(et,e+1))})]})]}
90),(0,r.jsx)(dF,{hash:(null==j?void 0:j.nzbHash)??null,name:null==j?void 0:j.name,open:null!==j,onOpenChange:e=>!e&&w(null)}),(0,r.jsx)(dG,{entry:N,open:null!==N,onOpenChange:e=>!e&&k(null)}),(0,r.jsx)(t0,{...es}),(0,r.jsx)(t0,{...ea}),(0,r.jsx)(t0,{...eo})]})}}),j9=(0,d.un)({getParentRoute:()=>j5,path:"stats",component:function(){let[e,t]=n.useState("24h"),[s,a]=n.useState(null),l=(0,ta.I)({queryKey:[...iN,"stats",e],queryFn:()=>el(`/dashboard/usenet/stats?window=${e}`),staleTime:15e3,refetchInterval:3e4});return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(cn,{value:e,onChange:t})}),(0,r.jsx)(cc,{}),(0,r.jsx)(iq,{query:l,errorTitle:"Failed to load usenet stats",children:e=>(0,r.jsx)(cf,{data:e,onReset:a})}),(0,r.jsx)(ca,{target:s,onClose:()=>a(null)})]})}}),j8=(0,d.un)({getParentRoute:()=>j5,path:"providers",component:function(){var e;let t=(0,ta.I)({queryKey:[...iN,"providers"],queryFn:()=>el("/dashboard/usenet/providers"),staleTime:1e4});return t.isLoading?(0,r.jsx)(iz,{}):t.isError?(0,r.jsx)(X,{className:"p-6 text-sm text-red-400",children:"Failed to load providers."}):(0,r.jsx)(cw,{providers:(null==(e=t.data)?void 0:e.providers)??[]})}}),j7=R.addChildren([jk,jR,jT,jI,jS,jC,j_,jE.addChildren([jM,jP,jD,j$,jO,jJ,jZ,jQ,jU.addChildren([jF,jz,jV,jq,jB]),jX.addChildren([j0,j1,j2,j3]),j5.addChildren([j4,j6,j9,j8]),jK.addChildren([jH,jW,jG,jY])])]),we=(0,u.a)({routeTree:j7,context:{queryClient:jN},trailingSlash:"never",defaultPreload:"intent"}),wt=document.getElementById("root");l.createRoot(wt).render((0,r.jsx)(n.StrictMode,{children:(0,r.jsx)(o.Ht,{client:jN,children:(0,r.jsx)(i.p,{router:we})})}))}},i={};function o(e){var t=i[e];if(void 0!==t)return t.exports;var s=i[e]={exports:{}};return l[e].call(s.exports,s,s.exports,o),s.exports}o.m=l,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(s,a){if(1&a&&(s=this(s)),8&a||"object"==typeof s&&s&&(4&a&&s.__esModule||16&a&&"function"==typeof s.then))return s;var r=Object.create(null);o.r(r);var n={};e=e||[null,t({}),t([]),t(t)];for(var l=2&a&&s;("object"==typeof l||"function"==typeof l)&&!~e.indexOf(l);l=t(l))Object.getOwnPropertyNames(l).forEach(e=>{n[e]=()=>s[e]});return n.default=()=>s,o.d(r,n),r},o.d=(e,t)=>{for(var s in t)o.o(t,s)&&!o.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nc=void 0,s=[],o.O=(e,t,a,r)=>{if(t){r=r||0;for(var n=s.length;n>0&&s[n-1][2]>r;n--)s[n]=s[n-1];s[n]=[t,a,r];return}for(var l=1/0,n=0;n<s.length;n++){for(var[t,a,r]=s[n],i=!0,d=0;d<t.length;d++)(!1&r||l>=r)&&Object.keys(o.O).every(e=>o.O[e](t[d]))?t.splice(d--,1):(i=!1,r<l&&(l=r));if(i){s.splice(n--,1);var c=a();void 0!==c&&(e=c)}}return e},a={410:0},o.O.j=e=>0===a[e],r=(e,t)=>{var s,r,[n,l,i]=t,d=0;if(n.some(e=>0!==a[e])){for(s in l)o.o(l,s)&&(o.m[s]=l[s]);if(i)var c=i(o)}for(e&&e(t);d<n.length;d++)r=n[d],o.o(a,r)&&a[r]&&a[r][0](),a[r]=0;return o.O(c)},(n=self.webpackChunk_aiostreams_frontend=self.webpackChunk_aiostreams_frontend||[]).forEach(r.bind(null,0)),n.push=r.bind(null,n.push.bind(n));var d=o.O(void 0,["783","509"],()=>o(27010));d=o.O(d)})();

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.