1/*! LICENSE: 2031.f60736df31.js.LICENSE.txt */ 2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[2031],{18557(e,n,t){var r=t(72361),l=t(67834),i=t(99893),s=t(24327),a=t(72868),o=t(47303),d=t(29625),c=t(56275);function u(e){let{value:n,children:t,className:u,iconClassName:h,variant:m="ghost",size:p="icon",tooltip:x,successTooltip:j,"aria-label":f}=e,{t:g}=(0,s.Bd)(),{copiedText:v,copyToClipboard:_}=(0,d.C)({notify:!1}),b=v===n,C=x??g("Copy to clipboard"),y=j??g("Copied!"),k=g("Copied"),w=(0,r.jsxs)(a.$,{variant:m,size:p,className:(0,c.cn)("shrink-0",u),onClick:()=>_(n),"aria-label":b?k:f??C,children:[b?(0,r.jsx)(l.A,{className:(0,c.cn)("text-success",h)}):(0,r.jsx)(i.A,{className:(0,c.cn)(h)}),t]});return x||j?(0,r.jsxs)(o.m_,{children:[(0,r.jsx)(o.k$,{render:w}),(0,r.jsx)(o.ZI,{children:(0,r.jsx)("p",{children:b?y:C})})]}):w}t.d(n,{i:()=>u})},98505(e,n,t){var r=t(72361);t(68413);var l=t(56275);function i(e){let{className:n,...t}=e;return(0,r.jsx)("div",{"data-slot":"badge-cell",className:(0,l.cn)("-ml-1.5 flex max-w-full min-w-0 items-center gap-1 overflow-hidden [&_[data-slot=status-badge]]:max-w-full [&_[data-slot=status-badge]]:min-w-0",n),...t})}t.d(n,{a:()=>i})},42817(e,n,t){var r=t(72361),l=t(68413),i=t(29625),s=t(85468),a=t(56275);let o={success:"bg-success",warning:"bg-warning",danger:"bg-destructive",info:"bg-info",neutral:"bg-neutral",purple:"bg-chart-4",amber:"bg-warning",blue:"bg-chart-1",cyan:"bg-chart-2",green:"bg-success",grey:"bg-neutral",indigo:"bg-chart-1","light-blue":"bg-info","light-green":"bg-emerald-400",lime:"bg-chart-3",orange:"bg-warning",pink:"bg-chart-5",red:"bg-destructive",teal:"bg-chart-2",violet:"bg-chart-4",yellow:"bg-warning"},d={success:"text-success",warning:"text-warning",danger:"text-destructive",info:"text-info",neutral:"text-muted-foreground",purple:"text-chart-4",amber:"text-warning",blue:"text-chart-1",cyan:"text-chart-2",green:"text-success",grey:"text-muted-foreground",indigo:"text-chart-1","light-blue":"text-info","light-green":"text-emerald-500 dark:text-emerald-300",lime:"text-chart-3",orange:"text-warning",pink:"text-chart-5",red:"text-destructive",teal:"text-chart-2",violet:"text-chart-4",yellow:"text-warning"},c=l.createContext("badge"),u={sm:"h-5 gap-1 px-1.5 text-sm leading-none",md:"h-5 gap-1 px-1.5 text-sm leading-none",lg:"h-6 gap-1.5 px-2 text-sm leading-none"},h={sm:"gap-1 text-sm leading-none",md:"gap-1 text-sm leading-none",lg:"gap-1.5 text-sm leading-none"};function m(e){let{label:n,children:t,icon:m,variant:p,size:x="sm",pulse:j=!1,showDot:f=!1,copyable:g=!0,copyText:v,autoColor:_,type:b,className:C,onClick:y,...k}=e,{copyToClipboard:w}=(0,i.C)(),R=l.useContext(c),S=b??R,A=_?(0,s.qA)(_):p??"neutral",B=t??(n?(0,r.jsx)("span",{className:"min-w-0 truncate leading-normal",children:n}):null),z=g?`Click to copy: ${v||n||""}`:n||void 0;return(0,r.jsxs)("span",{"data-slot":"status-badge",className:(0,a.cn)("inline-flex w-fit max-w-full min-w-0 shrink items-center font-medium tracking-normal whitespace-nowrap transition-colors","badge"===S?(0,a.cn)("rounded-4xl",u[x??"sm"]):(0,a.cn)(h[x??"sm"],"underline"===S&&"border-b border-current pb-px"),d[A],j&&"animate-pulse",g&&"cursor-copy hover:brightness-95 active:scale-95 dark:hover:brightness-110",C),onClick:e=>{g&&(e.stopPropagation(),w(v||n||"")),y?.(e)},title:z,...k,children:[f&&(0,r.jsx)("span",{className:(0,a.cn)("inline-block size-1.5 shrink-0 rounded-full",o[A]),"aria-hidden":"true"}),m&&(0,r.jsx)(m,{className:"size-3.5 shrink-0"}),B]})}function p(e){let{className:n,empty:t=(0,r.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"}),getKey:i,items:s,max:o=2,moreLabel:d,renderItem:c,...u}=e;if(0===s.length)return t;let h=s.slice(0,o),p=s.length-o;return(0,r.jsxs)("div",{className:(0,a.cn)("flex max-w-full min-w-0 items-center gap-1 overflow-hidden",n),...u,children:[h.map((e,n)=>(0,r.jsx)(l.Fragment,{children:c(e,n)},i?.(e,n)??n)),p>0&&(0,r.jsx)(m,{label:d?.(p)??`+${p}`,variant:"neutral",size:"sm",copyable:!1,className:"shrink-0"})]})}t.d(n,{M8:()=>p,Wh:()=>m}
2,{BQ:d,jk:o,lO:c})},43284(e,n,t){var r=t(72361),l=t(65291);t(68413);var i=t(56275);let s=(0,l.F)("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"}},defaultVariants:{variant:"default"}});function a(e){let{className:n,variant:t,...l}=e;return(0,r.jsx)("div",{"data-slot":"alert",role:"alert",className:(0,i.cn)(s({variant:t}),n),...l})}function o(e){let{className:n,...t}=e;return(0,r.jsx)("div",{"data-slot":"alert-title",className:(0,i.cn)("[&_a]:hover:text-foreground font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3",n),...t})}function d(e){let{className:n,...t}=e;return(0,r.jsx)("div",{"data-slot":"alert-description",className:(0,i.cn)("text-muted-foreground [&_a]:hover:text-foreground text-sm text-balance md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_p:not(:last-child)]:mb-4",n),...t})}function c(e){let{className:n,...t}=e;return(0,r.jsx)("div",{"data-slot":"alert-action",className:(0,i.cn)("absolute top-2 right-2",n),...t})}t.d(n,{Fc:()=>a,T2:()=>c,TN:()=>d,XL:()=>o})},27784(e,n,t){var r=t(72361),l=t(24327),i=t(31002);function s(e){let{isDirty:n,message:t}=e,{t:s}=(0,l.Bd)();return n?(0,r.jsx)(i.d1,{children:(0,r.jsxs)("span",{className:"inline-flex h-5 items-center gap-1.5 rounded-full bg-amber-500/10 px-2 text-[11px] font-medium whitespace-nowrap text-amber-700 ring-1 ring-amber-500/20 ring-inset dark:bg-amber-400/10 dark:text-amber-300 dark:ring-amber-400/20",children:[(0,r.jsx)("span",{className:"size-1.5 rounded-full bg-amber-500 dark:bg-amber-300"}),s(t||"Unsaved changes")]})}):null}t.d(n,{_:()=>s})},41064(e,n,t){var r=t(72361),l=t(88192),i=t(68413),s=t(24327),a=t(73280);function o(e){let{when:n,title:t,message:o}=e,{t:d}=(0,s.Bd)(),c=t??d("Unsaved changes"),u=o??d("You have unsaved changes. Are you sure you want to leave?"),h=(0,l.K)({condition:n}),[m,p]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{"blocked"===h.status&&p(!0)},[h.status]),(0,i.useEffect)(()=>{if(!n)return;let e=e=>(e.preventDefault(),e.returnValue="","");return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[n]),(0,r.jsx)(a.T,{open:m,onOpenChange:e=>{e||(p(!1),h.reset?.())},title:c,desc:u,confirmText:d("Leave"),cancelBtnText:d("Stay"),destructive:!0,handleConfirm:()=>{p(!1),h.proceed?.()}})}t.d(n,{s:()=>o})},43152(e,n,t){var r=t(72361),l=t(36710),i=t(11728),s=t(87212),a=t(56275);let o="flex min-w-0 flex-row items-center justify-between gap-4 py-2.5";function d(e){return(0,r.jsx)("div",{"data-settings-form-span":"full",className:(0,a.cn)("grid min-w-0 gap-x-5 gap-y-6 lg:grid-cols-2","lg:[&>[data-settings-form-span=full]]:col-span-2","[&>[data-slot=form-item]]:min-w-0","lg:[&>[data-slot=form-item]:has(textarea)]:col-span-2","lg:[&>[data-slot=form-item]:has([data-slot=switch])]:col-span-2",e.className),children:e.children})}function c(e){return(0,r.jsx)("div",{"data-settings-form-span":"full"===e.span?"full":void 0,className:(0,a.cn)("min-w-0","full"===e.span&&"lg:col-span-2",e.className),children:e.children})}function u(e){let{className:n,...t}=e;return(0,r.jsx)(l.eI,{"data-settings-form-span":"full",className:(0,a.cn)(o,n),...t})}function h(e){let{className:n,...t}=e;return(0,r.jsx)("div",{"data-settings-form-span":"full",className:(0,a.cn)(o,n),...t})}function m(e){let{checked:n,onCheckedChange:t,label:l,description:a,disabled:o,className:d,...c}=e;return(0,r.jsxs)(h,{className:d,...c,children:[(0,r.jsxs)(p,{children:[(0,r.jsx)(i.J,{className:"text-sm font-medium",children:l}),a?(0,r.jsx)("p",{className:"text-muted-foreground text-xs",children:a}):null]}),(0,r.jsx)(s.d,{checked:n,onCheckedChange:t,disabled:o})]})}function p(e){return(0,r.jsx)("div",{className:(0,a.cn)("min-w-0 space-y-0.5",e.className),children:e.children})}function x(e){let{className:n,...t}=e;return(0,r.jsx)("div",{"data-settings-form-span":"full",className:(0,a.cn)("bg-muted/20 min-w-0 space-y-3 rounded-xl border px-3 py-2.5",
2n),...t})}function j(e){let{className:n,...t}=e;return(0,r.jsx)("div",{className:(0,a.cn)("border-border/70 ml-2 min-w-0 border-l pl-3",n),...t})}function f(e){let{className:n,...t}=e;return(0,r.jsx)("form",{className:(0,a.cn)("grid min-w-0 gap-x-5 gap-y-6 lg:grid-cols-2","lg:[&>*:not([data-slot=form-item])]:col-span-2","lg:[&>[data-settings-form-span=full]]:col-span-2","lg:[&>[data-slot=alert]]:col-span-2","[&>[data-slot=form-item]]:min-w-0","lg:[&>[data-slot=form-item]:has(textarea)]:col-span-2","lg:[&>[data-slot=form-item]:has([data-slot=switch])]:col-span-2",n),...t})}t.d(n,{H:()=>u,K1:()=>d,KF:()=>j,WY:()=>x,ew:()=>m,vF:()=>c,yt:()=>f,z$:()=>p})},31002(e,n,t){var r=t(72361),l=t(23921),i=t(99597),s=t(68413),a=t(60140),o=t(24327),d=t(72868);let c=(0,s.createContext)({actionsContainer:null,titleStatusContainer:null,suppressSectionHeader:!1});function u(e){return(0,r.jsx)(c.Provider,{value:{actionsContainer:e.actionsContainer,titleStatusContainer:e.titleStatusContainer??null,suppressSectionHeader:e.suppressSectionHeader??!0},children:e.children})}function h(){return(0,s.useContext)(c).suppressSectionHeader}function m(e){let{titleStatusContainer:n}=(0,s.useContext)(c);return n?(0,a.createPortal)(e.children,n):null}function p(e){let{actionsContainer:n}=(0,s.useContext)(c);return n?(0,a.createPortal)((0,r.jsx)("div",{className:"flex flex-wrap items-center justify-end gap-2",children:e.children}),n):null}function x(e){let{t:n}=(0,o.Bd)(),t=e.isSaving?e.savingLabel??"Saving...":e.saveLabel??"Save Changes";return(0,r.jsxs)(p,{children:[e.onReset&&(0,r.jsxs)(d.$,{type:"button",size:"sm",variant:e.resetVariant??"outline",onClick:e.onReset,disabled:e.isResetDisabled||e.isSaving,children:[(0,r.jsx)(l.A,{"data-icon":"inline-start"}),(0,r.jsx)("span",{children:n(e.resetLabel??"Reset")})]}),(0,r.jsxs)(d.$,{ref:e.saveButtonRef,type:"button",size:"sm",onClick:e.onSave,disabled:e.isSaving||e.isSaveDisabled,children:[(0,r.jsx)(i.A,{"data-icon":"inline-start"}),(0,r.jsx)("span",{children:n(t)})]})]})}t.d(n,{If:()=>h,S2:()=>x,ab:()=>u,cN:()=>p,d1:()=>m})},21432(e,n,t){var r=t(72361),l=t(17034),i=t(68413),s=t(24327),a=t(42088),o=t(13581),d=t(31002);function c(e){let[n,t]=(0,i.useState)(null),[l,s]=(0,i.useState)(null);return(0,r.jsx)(d.ab,{actionsContainer:n,titleStatusContainer:l,children:(0,r.jsxs)(a.Ni,{children:[(0,r.jsx)(a.Ni.Title,{children:(0,r.jsxs)("span",{className:"inline-flex max-w-full min-w-0 items-center gap-2 align-middle",children:[(0,r.jsx)("span",{className:"truncate",children:e.title}),(0,r.jsx)("span",{ref:s,className:"inline-flex min-w-0 shrink-0 items-center"})]})}),(0,r.jsx)(a.Ni.Actions,{children:(0,r.jsx)("div",{ref:t,className:"flex flex-wrap items-center justify-end gap-2"})}),(0,r.jsx)(a.Ni.Content,{children:(0,r.jsx)("div",{className:"flex h-full min-h-0 w-full flex-col gap-4",children:e.children})})]})})}function u(e){let{routePath:n,defaultSettings:t,defaultSection:a,getSectionContent:d,getSectionMeta:u,extraArgs:h,loadingMessage:m="Loading settings...",resolveSettings:p}=e,{t:x}=(0,s.Bd)(),{data:j,isLoading:f}=(0,o.b)(),g=(0,l.g)({from:n}),v=g?.section??a,_=u(v),b=(0,i.useMemo)(()=>{let e=(0,o.n)(j?.data,t);return p?p(e,j?.data):e},[j?.data,t,p]);if(f)return(0,r.jsx)(c,{title:x(_.titleKey),children:(0,r.jsx)("div",{className:"text-muted-foreground flex min-h-40 items-center justify-center text-sm",children:x(m)})});let C=d(v,b,...h??[]);return(0,r.jsx)(c,{title:x(_.titleKey),children:C})}t.d(n,{R:()=>u})},44724(e,n,t){var r=t(72361),l=t(56275),i=t(31002);function s(e){let{title:n,titleProps:t,children:s,className:a}=e,o=(0,i.If)();return(0,r.jsxs)("section",{className:(0,l.cn)("flex flex-col gap-4",a),children:[!o&&(0,r.jsx)("div",{className:"flex flex-col gap-1",children:(0,r.jsx)("h3",{...t,className:(0,l.cn)("text-base font-semibold",t?.className),children:n})}),s]})}t.d(n,{X:()=>s})},12727(e,n,t){var r=t(68413);function l(e,n){let t=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(!n)return;let r=JSON.stringify(n);r!==t.current&&(e.reset(n),t.current=r)},[n,e])}t.d(n,{j:()=>l})},29625(e,n,t){var r=t(68413),l=t(24327),i=t(20598),s=t(11768);function a(e){let{notify:n=!0,successMessage:t,errorMessage:a,resetAfterMs:o=2e3}=e||{},{t:d}=(0,l.Bd)(),[c,u]=(0,r.useState)(null),h=(0,r.useRef)(void 0);return(0,r.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),{copiedText:c,copyToClipboard:(0,r.useCallback)(async e=>{let r=t??d("Copied to clipboard"),l=a??d("Failed to copy to clipboard");return await (0,s.l)(e)?(u(e),n&&i.oR.success(r),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{u(null)},o),!0):(console.warn("All copy methods failed"),n&&i.oR.error(l),u(null),!1)},[n,t,a,o,d])}}t.d(n,{C:()=>a})},69975(e,n,t){t.r(n),t.d(n,{component:()=>eS});var r=t(72361),l=t(21432),i=t(38159),s=t(48367),a=t(68413),o=t(86832),d=t(24327),c=t(13082),u=t
2(36710),h=t(87212),m=t(70954),p=t(43152),x=t(31002),j=t(44724),f=t(12727),g=t(47182);let v=c.Ik({PasswordLoginEnabled:c.zM(),PasswordRegisterEnabled:c.zM(),EmailCodeLoginEnabled:c.zM(),EmailVerificationEnabled:c.zM(),RegisterEnabled:c.zM(),EmailDomainRestrictionEnabled:c.zM(),EmailAliasRestrictionEnabled:c.zM(),EmailDomainWhitelist:c.Yj()});function _(e){let{defaultValues:n}=e,{t}=(0,d.Bd)(),l=(0,g.M)(),i=(0,a.useMemo)(()=>({...n,EmailDomainWhitelist:n.EmailDomainWhitelist.split(",").map(e=>e.trim()).filter(Boolean).join("\n")}),[n]),c=(0,o.mN)({resolver:(0,s.u)(v),defaultValues:i});(0,f.j)(c,i);let _=async e=>{let t=[];for(let r of(Object.entries(e).forEach(e=>{let[r,l]=e;if("EmailDomainWhitelist"===r){if("string"!=typeof l)return;let e=l.split("\n").map(e=>e.trim()).filter(Boolean).join(",");e!==n.EmailDomainWhitelist&&t.push({key:r,value:e})}else l!==n[r]&&t.push({key:r,value:l})}),t))await l.mutateAsync(r)};return(0,r.jsx)(j.X,{title:t("Basic Authentication"),children:(0,r.jsx)(u.lV,{...c,children:(0,r.jsxs)(p.yt,{onSubmit:c.handleSubmit(_),children:[(0,r.jsx)(x.S2,{onSave:c.handleSubmit(_),isSaving:l.isPending}),(0,r.jsx)(u.zB,{control:c.control,name:"PasswordLoginEnabled",render:e=>{let{field:n}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:t("Password Login")}),(0,r.jsx)(u.Rr,{children:t("Allow users to log in with password")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:n.value,onCheckedChange:n.onChange})})]})}}),(0,r.jsx)(u.zB,{control:c.control,name:"EmailCodeLoginEnabled",render:e=>{let{field:n}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:t("Email Code Login")}),(0,r.jsx)(u.Rr,{children:t("Allow passwordless sign-in with an emailed code; unknown emails are registered automatically (requires SMTP)")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:n.value,onCheckedChange:n.onChange})})]})}}),(0,r.jsx)(u.zB,{control:c.control,name:"RegisterEnabled",render:e=>{let{field:n}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:t("Registration Enabled")}),(0,r.jsx)(u.Rr,{children:t("Allow new users to register")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:n.value,onCheckedChange:n.onChange})})]})}}),(0,r.jsx)(u.zB,{control:c.control,name:"PasswordRegisterEnabled",render:e=>{let{field:n}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:t("Password Registration")}),(0,r.jsx)(u.Rr,{children:t("Allow registration with password")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:n.value,onCheckedChange:n.onChange})})]})}}),(0,r.jsx)(u.zB,{control:c.control,name:"EmailVerificationEnabled",render:e=>{let{field:n}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:t("Email Verification")}),(0,r.jsx)(u.Rr,{children:t("Require email verification for new accounts")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:n.value,onCheckedChange:n.onChange})})]})}}),(0,r.jsx)(u.zB,{control:c.control,name:"EmailDomainRestrictionEnabled",render:e=>{let{field:n}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:t("Email Domain Restriction")}),(0,r.jsx)(u.Rr,{children:t("Only allow specific email domains")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:n.value,onCheckedChange:n.onChange})})]})}}),(0,r.jsx)(u.zB,{control:c.control,name:"EmailAliasRestrictionEnabled",render:e=>{let{field:n}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:t("Email Alias Restriction")}),(0,r.jsx)(u.Rr,{children:t("Block email aliases (e.g., [email protected])")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:n.value,onCheckedChange:n.onChange})})]})}}),(0,r.jsx)(u.zB,{control:c.control,name:"EmailDomainWhitelist",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:t("Email Domain Whitelist")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(m.T,{placeholder:t("example.com company.com"),rows:4,...n})}),(0,r.jsx)(u.Rr,{children:t("One domain per line (only used when domain restriction is enabled)")}),(0,r.jsx)(u.C5,{})]})}})]})})})}var b=t(1738);let C=c.Ik({TurnstileCheckEnabled:c.zM(),TurnstileSiteKey:c.Yj().optional(),Tur
2nstileSecretKey:c.Yj().optional()});function y(e){let{defaultValues:n}=e,{t}=(0,d.Bd)(),l=(0,g.M)(),i=(0,o.mN)({resolver:(0,s.u)(C),defaultValues:n});(0,a.useEffect)(()=>{i.reset(n)},[n,i]);let c=async e=>{for(let[t,r]of Object.entries(e).filter(e=>{let[t,r]=e;return r!==n[t]}))await l.mutateAsync({key:t,value:r??""})};return(0,r.jsx)(j.X,{title:t("Bot Protection"),children:(0,r.jsx)(u.lV,{...i,children:(0,r.jsxs)(p.yt,{onSubmit:i.handleSubmit(c),autoComplete:"off",children:[(0,r.jsx)(x.S2,{onSave:i.handleSubmit(c),isSaving:l.isPending}),(0,r.jsx)(u.zB,{control:i.control,name:"TurnstileCheckEnabled",render:e=>{let{field:n}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:t("Enable Turnstile")}),(0,r.jsx)(u.Rr,{children:t("Protect login and registration with Cloudflare Turnstile")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:n.value,onCheckedChange:n.onChange})})]})}}),(0,r.jsx)(u.zB,{control:i.control,name:"TurnstileSiteKey",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:t("Site Key")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:t("Your Turnstile site key"),autoComplete:"off",...n})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:i.control,name:"TurnstileSecretKey",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:t("Secret Key")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{type:"password",placeholder:t("Your Turnstile secret key"),autoComplete:"new-password",...n})}),(0,r.jsx)(u.C5,{})]})}})]})})})}var k=t(18557),w=t(43284);function R(e,n){return e.trim().replace(/\/+$/,"")||n}function S(e,n,t){let r=R(e,t);return`${r}/oauth/${n.replace(/^\/+/,"")}`}var A=t(60641),B=t(91460),z=t(72868),N=t(88288),E=t(38939),L=t(96962),O=t(55667),D=t(19376),I=t(20598),M=t(22990);async function T(){return(await M.FH.get("/api/custom-oauth-provider/")).data}async function U(e){return(await M.FH.post("/api/custom-oauth-provider/",e)).data}async function H(e,n){return(await M.FH.put(`/api/custom-oauth-provider/${e}`,n)).data}async function J(e){return(await M.FH.delete(`/api/custom-oauth-provider/${e}`)).data}async function P(e){return(await M.FH.post("/api/custom-oauth-provider/discovery",{well_known_url:e})).data}function W(){let e=(0,L.jE)();return{onSuccess:()=>{e.invalidateQueries({queryKey:["custom-oauth-providers"]}),e.invalidateQueries({queryKey:["status"]})}}}let V=c.Ik({name:c.Yj().min(1,"Name is required"),slug:c.Yj().min(1,"Slug is required").regex(/^[a-z0-9-]+$/,"Slug must only contain lowercase letters, numbers, and hyphens"),icon:c.Yj().optional().default(""),enabled:c.zM().default(!0),client_id:c.Yj().min(1,"Client ID is required"),client_secret:c.Yj().optional().default(""),authorization_endpoint:c.Yj().min(1,"Authorization endpoint is required"),token_endpoint:c.Yj().min(1,"Token endpoint is required"),user_info_endpoint:c.Yj().min(1,"User info endpoint is required"),scopes:c.Yj().optional().default(""),user_id_field:c.Yj().min(1,"User ID field is required"),username_field:c.Yj().optional().default(""),display_name_field:c.Yj().optional().default(""),email_field:c.Yj().optional().default(""),well_known:c.Yj().optional().default(""),auth_style:c.ai().int().min(0).max(2).default(0),access_policy:c.Yj().optional().default(""),access_denied_message:c.Yj().optional().default("")}),Y=[{key:"github-enterprise",name:"GitHub Enterprise",icon:"github",authorization_endpoint:"/login/oauth/authorize",token_endpoint:"/login/oauth/access_token",user_info_endpoint:"/api/v3/user",scopes:"user:email",user_id_field:"id",username_field:"login",display_name_field:"name",email_field:"email",needsBaseUrl:!0},{key:"gitlab",name:"GitLab",icon:"gitlab",authorization_endpoint:"/oauth/authorize",token_endpoint:"/oauth/token",user_info_endpoint:"/api/v4/user",scopes:"openid profile email",user_id_field:"id",username_field:"username",display_name_field:"name",email_field:"email",needsBaseUrl:!0},{key:"gitea",name:"Gitea",icon:"gitea",authorization_endpoint:"/login/oauth/authorize",token_endpoint:"/login/oauth/access_token",user_info_endpoint:"/api/v1/user",scopes:"openid profile email",user_id_field:"id",username_field:"login",display_name_field:"full_name",email_field:"email",needsBaseUrl:!0},{key:"nextcloud",name:"Nextcloud",icon:"nextcloud",authorization_endpoint:"/apps/oauth2/authorize",token_endpoint:"/apps/oauth2/api/v1/token",user_info_endpoint:"/ocs/v2.php/cloud/user?format=json",scopes:"openid profile email",user_id_field:"ocs.data.id",username_field:"ocs.data.id",display_name_field:"ocs.data.displayname",email_field:"ocs.data.email",needsBaseUrl:!0},{key:"keycloak",name:"Keycloak",icon:"keycloak",authorization_endpoint:"/realms/{realm}/protocol/openid-connect/auth",token_endpoint:"/realms/{realm}/protocol/openid-connect/token",user_info_endpoint:"/realms/{realm}/protocol/openid-connect/userinfo",scopes:"openid profile email",user_id_field:"sub",username_field:"preferred_username",display_name_field:"name",email_field:"email",needsBaseUrl:!0},{key:"authentik",name:"Authentik",icon:"authentik",authorization_endpoint:"/application/o/authorize/",token_endpoint:"/application/o/token/",user_info_endpoint:"/application/o/userinfo/",scopes:"openid profile email",user_id_field:"sub",username_field:"preferred_username",display_name_field:"name",email_field:"email",needsBaseUrl:!0},{key:"ory",name:"ORY Hydra",icon:"openid",authorization_endpoint:"/oauth2/auth",token_endpoint:"/oauth2/token",user_info_endpoint:"/userinfo",scopes:"openid profile email",user_id_field:"sub",username_field:"preferred_username",display_name_field:"name",email_field:"email",needsBaseUrl:!0}],F=[{value:0,labelKey:"Auto Detect"},{value:1,labelKey:"Params (in body)"},{value:2,labelKey:"Header (Basic Auth)"}];var $=t(38766);function G(e){let{t:n}=(0,d.Bd)(),t=(0,O.n)({mutationFn:e=>P(e),onSuccess:e=>{e.success&&I.oR.success(D.Ay.t("OIDC endpoints discovered successfully"))},onError:e=>{I.oR.error(e.message||D.Ay.t("Failed to discover OIDC endpoints"))}}),l=async()=>{let r=e.form.getValues("well_known");if(!r)return void I.oR.error(n("Please enter a Well-Known URL first"));if(!r.startsWith("http://")&&!r.startsWith("https://"))return void I.oR.error(n("Well-Known URL must start with http:// or https://"));let l=await t.mutateAsync(r);if(l.success&&l.data?.discovery){let n=l.data.discovery;if(n.authorization_endpoint&&e.form.setValue("authorization_endpoint",n.authorization_endpoint,{shouldDirty:!0}),n.token_endpoint&&e.form.setValue("token_endpoint",n.token_endpoint,{shouldDirty:!0}),n.userinfo_endpoint&&e.form.setValue("user_info_endpoint",n.userinfo_endpoint,{shouldDirty:!0}),n.scopes_supported&&n.scopes_supported.length>0&&!e.form.getValues("scopes")){let t=n.scopes_supported.filter(e=>["openid","profile","email"].includes(e)).join(" ");t&&e.form.setValue("scopes",t,{shouldDirty:!0})}}};return(0,r.jsxs)(z.$,{type:"button",variant:"outline",size:"sm",onClick:l,disabled:t.isPending,children:[(0,r.jsx)($.A,{className:"mr-1.5 h-3.5 w-3.5"}),t.isPending?n("Discovering..."):n("Auto-discover")]})}var K=t(11728);function q(e){let{t:n}=(0,d.Bd)(),[t,l]=(0,a.useState)(""),[i,s]=(0,a.useState)(""),o=(n,t)=>{let r=t.replace(/\/+$/,"");e.form.setValue("authorization_endpoint",r+n.authorization_endpoint,{shouldDirty:!0}),e.form.setValue("token_endpoint",r+n.token_endpoint,{shouldDirty:!0}),e.form.setValue("user_info_endpoint",r+n.user_info_endpoint,{shouldDirty:!0})};return(0,r.jsxs)(p.WY,{className:"space-y-3 border-dashed",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:n("Quick Setup from Preset")}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(K.J,{children:n("Preset Template")}),(0,r.jsxs)(N.l6,{items:Y.map(e=>({value:e.key,label:e.name})),value:t,onValueChange:n=>{let t;return null!==n&&(l(n),void((t=Y.find(e=>e.key===n))&&(e.form.setValue("name",t.name,{shouldDirty:!0}),e.form.setValue("slug",n.toLowerCase().replaceAll(/\s+/g,"-"),{shouldDirty:!0}),e.form.setValue("icon",t.icon,{shouldDirty:!0}),e.form.setValue("scopes",t.scopes,{shouldDirty:!0}),e.form.setValue("user_id_field",t.user_id_field,{shouldDirty:!0}),e.form.setValue("username_field",t.username_field,{shouldDirty:!0}),e.form.setValue("display_name_field",t.display_name_field,{shouldDirty:!0}),e.form.setValue("email_field",t.email_field,{shouldDirty:!0}),i&&o(t,i))))},children:[(0,r.jsx)(N.bq,{className:"w-full",children:(0,r.jsx)(N.yv,{placeholder:n("Select a preset...")})}),(0,r.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,r.jsx)(N.s3,{children:Y.map(e=>(0,r.jsx)(N.eb,{value:e.key,children:e.name},e.key))})})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(K.J,{children:n("Base URL")}),(0,r.jsx)(b.p,{placeholder:n("https://your-server.example.com"),value:i,onChange:e=>(e=>{if(s(e),!t)return;let n=Y.find(e=>e.key===t);n&&o(n,e)})(e.target.value)})]})]})]})}let X="custom-oauth-provider-form";function Q(e){let n,t,{t:l}=(0,d.Bd)(),i=!!e.provider,c=(n=W(),(0,O.n)({mutationFn:e=>U(e),onSuccess:e=>{e.success&&(I.oR.success(D.Ay.t("Provider created successfully")),n.onSuccess())},onError:e=>{I.oR.error(e.message||D.Ay.t("Failed to create provider"))}})),m=(t=W(),(0,O.n)({mutationFn:e=>{let{id:n,data:t}=e;return H(n,t)},onSuccess:e=>{e.success&&(I.oR.success(D.Ay.t("Provider updated successfully")),t.onSuccess())},onError:e=>{I.oR.error(e.message||D.Ay.t("Failed to update provider"))}})),x=(0,o.mN)({resolver:(0,s.u)(V),defaultValues:{name:"",slug:"",icon:"",enabled:!0,client_id:"",client_secret:"",authorization_endpoint:"",token_endpoint:"",user_info_endpoint:"",scopes:"",user_id_field:"",username_field:"",display_name_field:"",email_field:"",well_known:"",auth_style:0,access_policy:"",access_de
2nied_message:""}}),j=(0,o.FH)({control:x.control,name:"slug"}),f=j?.trim()||"{slug}",g=S(e.serverAddress,f,l("Site URL"));(0,a.useEffect)(()=>{e.open&&e.provider?x.reset({name:e.provider.name,slug:e.provider.slug,icon:e.provider.icon||"",enabled:e.provider.enabled,client_id:e.provider.client_id,client_secret:e.provider.client_secret||"",authorization_endpoint:e.provider.authorization_endpoint,token_endpoint:e.provider.token_endpoint,user_info_endpoint:e.provider.user_info_endpoint,scopes:e.provider.scopes||"",user_id_field:e.provider.user_id_field,username_field:e.provider.username_field||"",display_name_field:e.provider.display_name_field||"",email_field:e.provider.email_field||"",well_known:e.provider.well_known||"",auth_style:e.provider.auth_style??0,access_policy:e.provider.access_policy||"",access_denied_message:e.provider.access_denied_message||""}):e.open&&!e.provider&&x.reset({name:"",slug:"",icon:"",enabled:!0,client_id:"",client_secret:"",authorization_endpoint:"",token_endpoint:"",user_info_endpoint:"",scopes:"",user_id_field:"",username_field:"",display_name_field:"",email_field:"",well_known:"",auth_style:0,access_policy:"",access_denied_message:""})},[e.open,e.provider,x]);let v=async n=>{i&&e.provider?(await m.mutateAsync({id:e.provider.id,data:n})).success&&e.onOpenChange(!1):(await c.mutateAsync(n)).success&&e.onOpenChange(!1)},_=c.isPending||m.isPending,C=l("Create Provider");return _?C=l("Saving..."):i&&(C=l("Update Provider")),(0,r.jsx)(A.l,{open:e.open,onOpenChange:e.onOpenChange,title:i?l("Edit OAuth Provider"):l("Add OAuth Provider"),description:i?l("Update the configuration for this custom OAuth provider."):l("Configure a new custom OAuth provider for user authentication."),contentClassName:"max-h-[85vh] overflow-y-auto sm:max-w-2xl",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(z.$,{type:"button",variant:"outline",onClick:()=>e.onOpenChange(!1),disabled:_,children:l("Cancel")}),(0,r.jsx)(z.$,{type:"submit",form:X,disabled:_,children:C})]}),children:(0,r.jsx)(u.lV,{...x,children:(0,r.jsxs)(p.yt,{id:X,onSubmit:x.handleSubmit(v),children:[!i&&(0,r.jsx)(q,{form:x}),(0,r.jsxs)(w.Fc,{children:[(0,r.jsx)(w.XL,{children:l("OAuth callback URL")}),(0,r.jsxs)(w.TN,{className:"space-y-3 text-sm",children:[(0,r.jsx)("p",{children:l("This callback URL updates from the slug field and is the value to register with your provider.")}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground shrink-0",children:l("Authorization callback URL")}),(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)("code",{className:"bg-muted text-foreground min-w-0 rounded px-1.5 py-0.5 text-xs break-all",children:g}),(0,r.jsx)(k.i,{value:g,size:"icon",className:"size-7",tooltip:l("Copy callback URL"),"aria-label":l("Copy callback URL")})]})]})]})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h4",{className:"text-sm font-medium",children:l("Basic Info")}),(0,r.jsx)(u.zB,{control:x.control,name:"enabled",render:e=>{let{field:n}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:l("Enabled")}),(0,r.jsx)(u.Rr,{children:l("Allow users to sign in with this provider")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:n.value,onCheckedChange:n.onChange})})]})}}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,r.jsx)(u.zB,{control:x.control,name:"name",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Provider Name")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:l("e.g. My GitLab"),...n})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:x.control,name:"slug",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Slug")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:l("e.g. my-gitlab"),...n})}),(0,r.jsx)(u.Rr,{children:l("Used in URLs and API routes")}),(0,r.jsx)(u.C5,{})]})}})]}),(0,r.jsx)(u.zB,{control:x.control,name:"icon",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Icon")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:l("Icon identifier (e.g. github, gitlab)"),...n})}),(0,r.jsx)(u.Rr,{children:l("Optional icon identifier for the login button")}),(0,r.jsx)(u.C5,{})]})}})]}),(0,r.jsx)(E.w,{}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h4",{className:"text-sm font-medium",children:l("Credentials")}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,r.jsx)(u.zB,{control:x.control,name:"client_id",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Client ID")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:l("OAuth Client ID"),autoComplete:"off",...n})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:x.control,name:"client_secret",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Client Secret")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{type:"password",placeholder:l("OAuth Client Secret"),autoComplete:"new-password",...n})}),(0,r.jsx)(u.C5,{})]})}})]}),(0,r.jsx)(u.zB,{control:x.control,name:"auth_style",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Auth Style")}),(0,r.jsxs)(N.l6,{items:F.map(e=>({value:String(e.value),label:l(e.labelKey)})),value:String(n.value),onValueChange:e=>n.onChange(Number(e)),children:[(0,r.jsx)(u.MJ,{children:(0,r.jsx)(N.bq,{className:"w-full",children:(0,r.jsx)(N.yv,{})})}),(0,r.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,r.jsx)(N.s3,{children:F.map(e=>(0,r.jsx)(N.eb,{value:String(e.value),children:l(e.labelKey)},e.value))})})]}),(0,r.jsx)(u.Rr,{children:l("How client credentials are sent to the token endpoint")}),(0,r.jsx)(u.C5,{})]})}})]}),(0,r.jsx)(E.w,{}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h4",{className:"text-sm font-medium",children:l("Endpoints")}),(0,r.jsx)(G,{form:x})]}),(0,r.jsx)(u.zB,{control:x.control,name:"well_known",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Well-Known URL")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:l("https://provider.com/.well-known/openid-configuration"),...n})}),(0,r.jsx)(u.Rr,{children:l('OIDC discovery URL. Click "Auto-discover" to fetch endpoints automatically.')}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:x.control,name:"authorization_endpoint",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Authorization Endpoint")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:"https://provider.com/oauth/authorize",...n})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:x.control,name:"token_endpoint",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Token Endpoint")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:"https://provider.com/oauth/token",...n})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:x.control,name:"user_info_endpoint",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("User Info Endpoint")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:"https://provider.com/api/user",...n})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:x.control,name:"scopes",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Scopes")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:l("e.g. openid profile email"),...n})}),(0,r.jsx)(u.Rr,{children:l("Space-separated OAuth scopes")}),(0,r.jsx)(u.C5,{})]})}})]}),(0,r.jsx)(E.w,{}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h4",{className:"text-sm font-medium",children:l("Field Mapping")}),(0,r.jsx)(u.Rr,{children:l("Map fields from the user info response to local user attributes. Supports nested paths (e.g. ocs.data.id).")}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,r.jsx)(u.zB,{control:x.control,name:"user_id_field",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("User ID Field")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:"id",...n})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:x.control,name:"username_field",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Username Field")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:"login",...n})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:x.control,name:"display_name_field",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Display Name Field")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:"name",...n})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:x.control,name:"email_field",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Email Field")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:"email",...n})}),(0,r.jsx)(u.C5,{})]})}})]})]}),(0,r.jsx)(E.w,{}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h4",{className:"text-sm font-medium",children:l("Advanced")}),(0,r.jsx)(u.zB,{control:x.control,name:"access_policy",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Access Policy (JSON)")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(B.B,{value:n.value||"",onChange:n.onChange,name:n.name,onBlur:n.onBlur,textareaRef:n.ref,placeholder:l("Optional JSON policy to restrict access based on user info fields"),heightClassName:"h-40 min-h-40 max-h-40"})}),(0,r.jsx)(u.Rr,{children:l("JSON-based access control rules. Leave empty to allow all users.")}),(0,r.jsx)(u.C5,{})]})}}
2),(0,r.jsx)(u.zB,{control:x.control,name:"access_denied_message",render:e=>{let{field:n}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:l("Access Denied Message")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:l("Custom message shown when access is denied"),...n})}),(0,r.jsx)(u.C5,{})]})}})]})]})})})}var Z=t(66002),ee=t(73280),en=t(98505),et=t(32348),er=t(21505),el=t(42817);function ei(e){let n,{t}=(0,d.Bd)(),l=(n=W(),(0,O.n)({mutationFn:e=>J(e),onSuccess:e=>{e.success&&(I.oR.success(D.Ay.t("Provider deleted successfully")),n.onSuccess())},onError:e=>{I.oR.error(e.message||D.Ay.t("Failed to delete provider"))}})),[i,s]=(0,a.useState)(null),o=async()=>{i&&(await l.mutateAsync(i.id),s(null))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("p",{className:"text-muted-foreground text-sm",children:t("Manage custom OAuth providers for user authentication")}),(0,r.jsxs)(z.$,{size:"sm",onClick:e.onCreate,children:[(0,r.jsx)(Z.A,{className:"mr-1.5 h-4 w-4"}),t("Add Provider")]})]}),(0,r.jsx)(et.h,{data:e.providers,getRowKey:e=>e.id,emptyClassName:"text-sm",emptyContent:t("No custom OAuth providers configured yet."),columns:[{id:"icon",header:t("Icon"),cell:e=>e.icon?(0,r.jsx)("span",{className:"text-lg",children:e.icon}):(0,r.jsx)("span",{className:"text-muted-foreground text-sm",children:"--"})},{id:"name",header:t("Name"),cellClassName:"font-medium",cell:e=>e.name},{id:"slug",header:t("Slug"),cell:e=>(0,r.jsx)(en.a,{children:(0,r.jsx)(el.Wh,{label:e.slug,variant:"neutral",copyable:!1})})},{id:"status",header:t("Status"),cell:e=>(0,r.jsx)(en.a,{children:(0,r.jsx)(el.Wh,{label:e.enabled?t("Enabled"):t("Disabled"),variant:e.enabled?"success":"neutral",copyable:!1})})},{id:"client-id",header:t("Client ID"),cellClassName:"text-muted-foreground max-w-[120px] truncate font-mono",cell:e=>e.client_id},{id:"actions",header:t("Actions"),className:"text-right",cellClassName:"text-right",cell:n=>(0,r.jsx)(er._,{editLabel:t("Edit"),deleteLabel:t("Delete"),menuLabel:t("Open menu"),onEdit:()=>e.onEdit(n),onDelete:()=>s(n)})}]}),(0,r.jsx)(ee.T,{open:!!i,onOpenChange:e=>!e&&s(null),title:t("Delete Provider"),desc:t('Are you sure you want to delete "{{name}}"? Users who authenticated with this provider will no longer be able to log in.',{name:i?.name||""}),confirmText:t("Delete"),destructive:!0,handleConfirm:o,isLoading:l.isPending})]})}var es=t(71295);function ea(e){let{t:n}=(0,d.Bd)(),{data:t=[],isLoading:l}=(0,es.I)({queryKey:["custom-oauth-providers"],queryFn:async()=>(await T()).data??[]}),[i,s]=(0,a.useState)(!1),[o,c]=(0,a.useState)(null),u=S(e.serverAddress,"{slug}",n("Site URL"));return l?(0,r.jsx)(j.X,{title:n("Custom OAuth Providers"),children:(0,r.jsx)("div",{className:"text-muted-foreground py-8 text-center text-sm",children:n("Loading...")})}):(0,r.jsxs)(j.X,{title:n("Custom OAuth Providers"),children:[(0,r.jsxs)(w.Fc,{children:[(0,r.jsx)(w.XL,{children:n("Callback URL format")}),(0,r.jsxs)(w.TN,{className:"space-y-3 text-sm",children:[(0,r.jsx)("p",{children:n("Use this callback URL pattern when registering a custom OAuth provider.")}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground shrink-0",children:n("OAuth callback URL")}),(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)("code",{className:"bg-muted text-foreground min-w-0 rounded px-1.5 py-0.5 text-xs break-all",children:u}),(0,r.jsx)(k.i,{value:u,size:"icon",className:"size-7",tooltip:n("Copy callback URL"),"aria-label":n("Copy callback URL")})]})]})]})]}),(0,r.jsx)(ei,{providers:t,onEdit:e=>{c(e),s(!0)},onCreate:()=>{c(null),s(!0)}}),(0,r.jsx)(Q,{open:i,onOpenChange:e=>{s(e),e||c(null)},provider:o,serverAddress:e.serverAddress})]})}var eo=t(29912),ed=t(66552),ec=t(56920),eu=t(27784),eh=t(41064);let em=c.Ik({GitHubOAuthEnabled:c.zM(),GitHubClientId:c.Yj(),GitHubClientSecret:c.Yj(),discord:c.Ik({enabled:c.zM(),client_id:c.Yj(),client_secret:c.Yj()}),oidc:c.Ik({enabled:c.zM(),display_name:c.Yj(),client_id:c.Yj(),client_secret:c.Yj(),well_known:c.Yj(),authorization_endpoint:c.Yj(),token_endpoint:c.Yj(),user_info_endpoint:c.Yj()}),TelegramOAuthEnabled:c.zM(),TelegramBotToken:c.Yj(),TelegramBotName:c.Yj(),LinuxDOOAuthEnabled:c.zM(),LinuxDOClientId:c.Yj(),LinuxDOClientSecret:c.Yj(),LinuxDOMinimumTrustLevel:c.Yj(),WeChatAuthEnabled:c.zM(),WeChatServerAddress:c.Yj(),WeChatServerToken:c.Yj(),WeChatAccountQRCodeImageURL:c.Yj()}),ep="grid min-w-0 gap-x-5 gap-y-6 lg:grid-cols-2 [&>[data-slot=form-item]]:min-w-0 lg:[&>[data-slot=form-item]:has([data-slot=switch])]:col-span-2";function ex(e){return(0,r.jsxs)(w.Fc,{className:"lg:col-span-2",children:[(0,r.jsx)(w.XL,{children:e.title}),(0,r.jsxs)(w.TN,{className:"space-y-3 text-sm",children:[(0,r.jsx)("div",{children:e.description}),(0,r.jsx)("div",{className:"space-y-2",children:e.rows.map(e=>(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("span",{className:"text-muted-foreground shrink-0",children:e.label}),(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)("code",{className:"bg-muted text-foreground min-w-0 rounded px-1.5 py-0.5 text-xs break-all",children:e.value}),(0,r.jsx)(k.i,{value:e.value,size:"icon",className:"size-7",tooltip:e.copyLabel,"aria-label":e.copyLabel})]})]},`${String(e.label)}-${e.value}`))}),e.children]})]})}let ej=e=>({GitHubOAuthEnabled:e.GitHubOAuthEnabled,GitHubClientId:e.GitHubClientId??"",GitHubClientSecret:e.GitHubClientSecret??"",discord:{enabled:e["discord.enabled"],client_id:e["discord.client_id"]??"",client_secret:e["discord.client_secret"]??""},oidc:{enabled:e["oidc.enabled"],display_name:e["oidc.display_name"]??"",client_id:e["oidc.client_id"]??"",client_secret:e["oidc.client_secret"]??"",well_known:e["oidc.well_known"]??"",authorization_endpoint:e["oidc.authorization_endpoint"]??"",token_endpoint:e["oidc.token_endpoint"]??"",user_info_endpoint:e["oidc.user_info_endpoint"]??""},TelegramOAuthEnabled:e.TelegramOAuthEnabled,TelegramBotToken:e.TelegramBotToken??"",TelegramBotName:e.TelegramBotName??"",LinuxDOOAuthEnabled:e.LinuxDOOAuthEnabled,LinuxDOClientId:e.LinuxDOClientId??"",LinuxDOClientSecret:e.LinuxDOClientSecret??"",LinuxDOMinimumTrustLevel:e.LinuxDOMinimumTrustLevel??"",WeChatAuthEnabled:e.WeChatAuthEnabled,WeChatServerAddress:e.WeChatServerAddress??"",WeChatServerToken:e.WeChatServerToken??"",WeChatAccountQRCodeImageURL:e.WeChatAccountQRCodeImageURL??""});function ef(e){let{t:n}=(0,d.Bd)(),t=(0,g.M)(),[l,i]=(0,a.useState)("github"),c=R(e.serverAddress,n("Site URL")),m=S(e.serverAddress,"github",n("Site URL")),f=S(e.serverAddress,"discord",
2n("Site URL")),v=S(e.serverAddress,"oidc",n("Site URL")),_=S(e.serverAddress,"linuxdo",n("Site URL")),C=(0,a.useMemo)(()=>ej(e.defaultValues),[e.defaultValues]),y=(0,o.mN)({resolver:(0,s.u)(em),defaultValues:C}),k=(0,a.useRef)(e.defaultValues),w=(0,a.useRef)(JSON.stringify(e.defaultValues));(0,a.useEffect)(()=>{let n=JSON.stringify(e.defaultValues);n!==w.current&&(k.current=e.defaultValues,w.current=n,y.reset(ej(e.defaultValues)))},[e.defaultValues,y]);let A=async e=>{let r,l=e;if(e.oidc.well_known&&""!==e.oidc.well_known.trim()){let t=e.oidc.well_known.trim();if(!t.startsWith("http://")&&!t.startsWith("https://"))return void I.oR.error(n("Well-Known URL must start with http:// or https://"));try{let r=await eo.A.create().get(t),i=r.data.authorization_endpoint||"",s=r.data.token_endpoint||"",a=r.data.userinfo_endpoint||"";l={...e,oidc:{...e.oidc,authorization_endpoint:i,token_endpoint:s,user_info_endpoint:a}},y.setValue("oidc.authorization_endpoint",i),y.setValue("oidc.token_endpoint",s),y.setValue("oidc.user_info_endpoint",a),I.oR.success(n("OIDC configuration fetched successfully"))}catch(e){console.error(e),I.oR.error(n("Failed to fetch OIDC configuration. Please check the URL and network status"));return}}let i={GitHubOAuthEnabled:(r=l).GitHubOAuthEnabled,GitHubClientId:r.GitHubClientId,GitHubClientSecret:r.GitHubClientSecret,"discord.enabled":r.discord.enabled,"discord.client_id":r.discord.client_id,"discord.client_secret":r.discord.client_secret,"oidc.enabled":r.oidc.enabled,"oidc.display_name":r.oidc.display_name,"oidc.client_id":r.oidc.client_id,"oidc.client_secret":r.oidc.client_secret,"oidc.well_known":r.oidc.well_known,"oidc.authorization_endpoint":r.oidc.authorization_endpoint,"oidc.token_endpoint":r.oidc.token_endpoint,"oidc.user_info_endpoint":r.oidc.user_info_endpoint,TelegramOAuthEnabled:r.TelegramOAuthEnabled,TelegramBotToken:r.TelegramBotToken,TelegramBotName:r.TelegramBotName,LinuxDOOAuthEnabled:r.LinuxDOOAuthEnabled,LinuxDOClientId:r.LinuxDOClientId,LinuxDOClientSecret:r.LinuxDOClientSecret,LinuxDOMinimumTrustLevel:r.LinuxDOMinimumTrustLevel,WeChatAuthEnabled:r.WeChatAuthEnabled,WeChatServerAddress:r.WeChatServerAddress,WeChatServerToken:r.WeChatServerToken,WeChatAccountQRCodeImageURL:r.WeChatAccountQRCodeImageURL},s=Object.keys(i).filter(e=>i[e]!==k.current[e]);if(0===s.length)return void I.oR.info(n("No changes to save"));for(let e of s)await t.mutateAsync({key:e,value:i[e]});k.current=i,w.current=JSON.stringify(i),y.reset(ej(i))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eh.s,{when:y.formState.isDirty}),(0,r.jsx)(j.X,{title:n("OAuth Integrations"),children:(0,r.jsx)(u.lV,{...y,children:(0,r.jsxs)(p.yt,{onSubmit:y.handleSubmit(A),children:[(0,r.jsx)(x.S2,{onSave:y.handleSubmit(A),onReset:()=>{y.reset(ej(k.current)),I.oR.success(n("Form reset to saved values"))},isSaving:t.isPending,isResetDisabled:!y.formState.isDirty}),(0,r.jsx)(eu._,{isDirty:y.formState.isDirty}),(0,r.jsxs)(ec.tU,{value:l,onValueChange:i,children:[(0,r.jsxs)(ec.j7,{className:"grid w-full grid-cols-6",children:[(0,r.jsx)(ec.Xi,{value:"github",children:n("GitHub")}),(0,r.jsx)(ec.Xi,{value:"discord",children:n("Discord")}),(0,r.jsx)(ec.Xi,{value:"oidc",children:n("OIDC")}),(0,r.jsx)(ec.Xi,{value:"telegram",children:n("Telegram")}),(0,r.jsx)(ec.Xi,{value:"linuxdo",children:n("LinuxDO")}),(0,r.jsx)(ec.Xi,{value:"wechat",children:n("WeChat")})]}),(0,r.jsxs)(ec.av,{value:"github",className:ep,children:[(0,r.jsx)(ex,{title:n("Setup guide"),description:n("Set these values in the provider application before enabling login."),rows:[{label:n("Homepage URL"),value:c,copyLabel:n("Copy homepage URL")},{label:n("Authorization callback URL"),value:m,copyLabel:n("Copy callback URL")}]}),(0,r.jsx)(u.zB,{control:y.control,name:"GitHubOAuthEnabled",render:e=>{let{field:t}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:n("Enable GitHub OAuth")}),(0,r.jsx)(u.Rr,{children:n("Allow users to sign in with GitHub")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"GitHubClientId",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Client ID")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("Your GitHub OAuth Client ID"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"GitHubClientSecret",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Client Secret")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{type:"password",placeholder:n("Your GitHub OAuth Client Secret"),autoComplete:"new-password",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}})]}),(0,r.jsxs)(ec.av,{value:"discord",className:ep,children:[(0,r.jsx)(ex,{title:n("Setup guide"),description:n("Set these values in the provider application before enabling login."),rows:[{label:n("Homepage URL"),value:c,copyLabel:n("Copy homepage URL")},{label:n("Authorization callback URL"),value:f,copyLabel:n("Copy callback URL")}]}),(0,r.jsx)(u.zB,{control:y.control,name:"discord.enabled",render:e=>{let{field:t}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:n("Enable Discord OAuth")}),(0,r.jsx)(u.Rr,{children:n("Allow users to sign in with Discord")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"discord.client_id",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Client ID")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("Your Discord OAuth Client ID"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"discord.client_secret",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Client Secret")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{type:"password",placeholder:n("Your Discord OAuth Client Secret"),autoComplete:"new-password",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}})]}),(0,r.jsxs)(ec.av,{value:"oidc",className:ep,children:[(0,r.jsx)(ex,{title:n("Setup guide"),description:(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{children:n("Set these values in the provider application before enabling login.")}),(0,r.jsx)("p",{children:n("OIDC discovery can fill the endpoint fields automatically when the provider supports it.")})]}),rows:[{label:n("Homepage URL"),value:c,copyLabel:n("Copy homepage URL")},{label:n("Redirect URL"),value:v,copyLabel:n("Copy redirect URL")}]}),(0,r.jsx)(u.zB,{control:y.control,name:"oidc.enabled",render:e=>{let{field:t}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:n("Enable OIDC")}),(0,r.jsx)(u.Rr,{children:n("Allow users to sign in with OpenID Connect")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"oidc.display_name",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("OIDC Display Name")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("e.g. Company SSO"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.Rr,{children:n('Defaults to "OIDC" if left blank')}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"oidc.client_id",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Client ID")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("OIDC Client ID"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"oidc.client_secret",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Client Secret")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{type:"password",placeholder:n("OIDC Client Secret"),autoComplete:"new-password",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"oidc.well_known",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Well-Known URL")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("https://provider.com/.well-known/openid-configuration"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.Rr,{children:n("Auto-discovers endpoints from the provider")}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"oidc.authorization_endpoint",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Authorization Endpoint (Optional)")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("Override auto-discovered endpoint"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"oidc.token_endpoint",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Token Endpoint (Optional)")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("Override auto-discovered endpoint"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"oidc.user_info_endpoint",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("User Info Endpoint (Optional)")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("Override auto-discovered endpoint"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}})]}),(0,r.jsxs)(ec.av,{value:"telegram",className:ep,children:[(0,r.jsx)(u.zB,{control:y.control,name:"TelegramOAuthEnabled",render:e=>{let{field:t}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:n("Enable Telegram OAuth")}),(0,r.jsx)(u.Rr,{children:n("Allow users to sign in with Telegram")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"TelegramBotToken",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Bot Token")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{type:"password",placeholder:n("Your Telegram Bot Token"),autoComplete:"new-password",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"TelegramBotName",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Bot Name")}
2),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("Your Bot Name"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}})]}),(0,r.jsxs)(ec.av,{value:"linuxdo",className:ep,children:[(0,r.jsx)(ex,{title:n("Setup guide"),description:n("Set these values in the provider application before enabling login."),rows:[{label:n("Authorization callback URL"),value:_,copyLabel:n("Copy callback URL")}],children:(0,r.jsxs)("a",{href:"https://connect.linux.do/",target:"_blank",rel:"noreferrer",className:"text-primary inline-flex w-fit items-center gap-1 underline underline-offset-3 hover:no-underline",children:[n("Manage your LinuxDO OAuth app"),(0,r.jsx)(ed.A,{className:"size-3","aria-hidden":"true"})]})}),(0,r.jsx)(u.zB,{control:y.control,name:"LinuxDOOAuthEnabled",render:e=>{let{field:t}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:n("Enable LinuxDO OAuth")}),(0,r.jsx)(u.Rr,{children:n("Allow users to sign in with LinuxDO")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"LinuxDOClientId",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Client ID")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("LinuxDO Client ID"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"LinuxDOClientSecret",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Client Secret")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{type:"password",placeholder:n("LinuxDO Client Secret"),autoComplete:"new-password",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"LinuxDOMinimumTrustLevel",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Minimum Trust Level")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:"0",autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.Rr,{children:n("Minimum LinuxDO trust level required")}),(0,r.jsx)(u.C5,{})]})}})]}),(0,r.jsxs)(ec.av,{value:"wechat",className:ep,children:[(0,r.jsx)(u.zB,{control:y.control,name:"WeChatAuthEnabled",render:e=>{let{field:t}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:n("Enable WeChat Auth")}),(0,r.jsx)(u.Rr,{children:n("Allow users to sign in with WeChat")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"WeChatServerAddress",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Server Address")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("https://wechat-server.example.com"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"WeChatServerToken",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Server Token")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{type:"password",placeholder:n("Server Token"),autoComplete:"new-password",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:y.control,name:"WeChatAccountQRCodeImageURL",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("QR Code Image URL")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("https://example.com/qr-code.png"),autoComplete:"off",value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.C5,{})]})}})]})]})]})})})]})}let eg=c.Ik({passkey:c.Ik({enabled:c.zM(),rp_display_name:c.Yj(),rp_id:c.Yj(),origins:c.Yj(),allow_insecure_origin:c.zM(),user_verification:c.k5(["required","preferred","discouraged"]),attachment_preference:c.k5(["none","platform","cross-platform"])})}),ev=e=>{let n;return{passkey:{enabled:e["passkey.enabled"],rp_display_name:e["passkey.rp_display_name"]??"",rp_id:e["passkey.rp_id"]??"",origins:(e["passkey.origins"]??"").split(",").map(e=>
2e.trim()).filter(Boolean).join("\n"),allow_insecure_origin:e["passkey.allow_insecure_origin"],user_verification:e["passkey.user_verification"],attachment_preference:""===(n=e["passkey.attachment_preference"])?"none":n}}};function e_(e){let{t:n}=(0,d.Bd)(),t=(0,g.M)(),l=(0,a.useMemo)(()=>ev(e.defaultValues),[e.defaultValues]),i=(0,o.mN)({resolver:(0,s.u)(eg),defaultValues:l}),c=(0,a.useRef)(e.defaultValues),f=(0,a.useRef)(JSON.stringify(e.defaultValues));(0,a.useEffect)(()=>{let n=JSON.stringify(e.defaultValues);n!==f.current&&(c.current=e.defaultValues,f.current=n,i.reset(ev(e.defaultValues)))},[e.defaultValues,i]);let v=async e=>{let r,l={"passkey.enabled":e.passkey.enabled,"passkey.rp_display_name":e.passkey.rp_display_name,"passkey.rp_id":e.passkey.rp_id,"passkey.origins":e.passkey.origins.split("\n").map(e=>e.trim()).filter(Boolean).join(","),"passkey.allow_insecure_origin":e.passkey.allow_insecure_origin,"passkey.user_verification":e.passkey.user_verification,"passkey.attachment_preference":"none"===(r=e.passkey.attachment_preference)?"":r},s=Object.keys(l).filter(e=>l[e]!==c.current[e]);if(0===s.length)return void I.oR.info(n("No changes to save"));for(let e of s)await t.mutateAsync({key:e,value:l[e]});c.current=l,f.current=JSON.stringify(l),i.reset(ev(l))};return(0,r.jsx)(j.X,{title:n("Passkey Authentication"),children:(0,r.jsx)(u.lV,{...i,children:(0,r.jsxs)(p.yt,{onSubmit:i.handleSubmit(v),children:[(0,r.jsx)(x.S2,{onSave:i.handleSubmit(v),isSaving:t.isPending}),(0,r.jsx)(u.zB,{control:i.control,name:"passkey.enabled",render:e=>{let{field:t}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:n("Enable Passkey")}),(0,r.jsx)(u.Rr,{children:n("Allow users to register and sign in with Passkey (WebAuthn)")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),(0,r.jsx)(u.zB,{control:i.control,name:"passkey.rp_display_name",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Relying Party Display Name")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("e.g. New API Console"),value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.Rr,{children:n("Human-readable name shown to users during Passkey prompts.")}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:i.control,name:"passkey.rp_id",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Relying Party ID")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(b.p,{placeholder:n("e.g. example.com"),value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.Rr,{children:n("The effective domain for Passkey registration. Must match the current domain or be its parent domain.")}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:i.control,name:"passkey.user_verification",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("User Verification")}),(0,r.jsx)(u.MJ,{children:(0,r.jsxs)(N.l6,{items:[{value:"required",label:n("Required")},{value:"preferred",label:n("Recommended")},{value:"discouraged",label:n("Discouraged")}],value:t.value,onValueChange:t.onChange,children:[(0,r.jsx)(N.bq,{children:(0,r.jsx)(N.yv,{placeholder:n("Select requirement")})}),(0,r.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,r.jsxs)(N.s3,{children:[(0,r.jsx)(N.eb,{value:"required",children:n("Required")}),(0,r.jsx)(N.eb,{value:"preferred",children:n("Recommended")}),(0,r.jsx)(N.eb,{value:"discouraged",children:n("Discouraged")})]})})]})}),(0,r.jsx)(u.Rr,{children:n("Controls whether user verification (biometrics/PIN) is required during Passkey flows.")}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:i.control,name:"passkey.attachment_preference",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Device Type Preference")}),(0,r.jsx)(u.MJ,{children:(0,r.jsxs)(N.l6,{items:[{value:"none",label:n("Unlimited")},{value:"platform",label:n("Built-in Device")}
2,{value:"cross-platform",label:n("External Device")}],value:t.value,onValueChange:t.onChange,children:[(0,r.jsx)(N.bq,{children:(0,r.jsx)(N.yv,{placeholder:n("No preference")})}),(0,r.jsx)(N.gC,{alignItemWithTrigger:!1,children:(0,r.jsxs)(N.s3,{children:[(0,r.jsx)(N.eb,{value:"none",children:n("Unlimited")}),(0,r.jsx)(N.eb,{value:"platform",children:n("Built-in Device")}),(0,r.jsx)(N.eb,{value:"cross-platform",children:n("External Device")})]})})]})}),(0,r.jsx)(u.Rr,{children:n("Built-in: phone fingerprint/face, or Windows Hello; External: USB security key")}),(0,r.jsx)(u.C5,{})]})}}),(0,r.jsx)(u.zB,{control:i.control,name:"passkey.allow_insecure_origin",render:e=>{let{field:t}=e;return(0,r.jsxs)(p.H,{children:[(0,r.jsxs)(p.z$,{children:[(0,r.jsx)(u.lR,{children:n("Allow Insecure Origins")}),(0,r.jsx)(u.Rr,{children:n("Permit Passkey registration on non-HTTPS origins (only recommended for development)")})]}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(h.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),(0,r.jsx)(u.zB,{control:i.control,name:"passkey.origins",render:e=>{let{field:t}=e;return(0,r.jsxs)(u.eI,{children:[(0,r.jsx)(u.lR,{children:n("Allowed Origins")}),(0,r.jsx)(u.MJ,{children:(0,r.jsx)(m.T,{rows:4,placeholder:n("https://example.com"),value:t.value??"",onChange:e=>t.onChange(e.target.value),name:t.name,onBlur:t.onBlur,ref:t.ref})}),(0,r.jsx)(u.Rr,{children:n("List of origins (one per line) allowed for Passkey registration and authentication.")}),(0,r.jsx)(u.C5,{})]})}})]})})})}var eb=t(27030);let eC={"basic-auth":e=>(0,r.jsx)(_,{defaultValues:{PasswordLoginEnabled:e.PasswordLoginEnabled,PasswordRegisterEnabled:e.PasswordRegisterEnabled,EmailCodeLoginEnabled:e.EmailCodeLoginEnabled,EmailVerificationEnabled:e.EmailVerificationEnabled,RegisterEnabled:e.RegisterEnabled,EmailDomainRestrictionEnabled:e.EmailDomainRestrictionEnabled,EmailAliasRestrictionEnabled:e.EmailAliasRestrictionEnabled,EmailDomainWhitelist:e.EmailDomainWhitelist}}),oauth:e=>(0,r.jsx)(ef,{serverAddress:e.ServerAddress,defaultValues:{GitHubOAuthEnabled:e.GitHubOAuthEnabled,GitHubClientId:e.GitHubClientId,GitHubClientSecret:e.GitHubClientSecret,"discord.enabled":e["discord.enabled"],"discord.client_id":e["discord.client_id"],"discord.client_secret":e["discord.client_secret"],"oidc.enabled":e["oidc.enabled"],"oidc.display_name":e["oidc.display_name"],"oidc.client_id":e["oidc.client_id"],"oidc.client_secret":e["oidc.client_secret"],"oidc.well_known":e["oidc.well_known"],"oidc.authorization_endpoint":e["oidc.authorization_endpoint"],"oidc.token_endpoint":e["oidc.token_endpoint"],"oidc.user_info_endpoint":e["oidc.user_info_endpoint"],TelegramOAuthEnabled:e.TelegramOAuthEnabled,TelegramBotToken:e.TelegramBotToken,TelegramBotName:e.TelegramBotName,LinuxDOOAuthEnabled:e.LinuxDOOAuthEnabled,LinuxDOClientId:e.LinuxDOClientId,LinuxDOClientSecret:e.LinuxDOClientSecret,LinuxDOMinimumTrustLevel:e.LinuxDOMinimumTrustLevel,WeChatAuthEnabled:e.WeChatAuthEnabled,WeChatServerAddress:e.WeChatServerAddress,WeChatServerToken:e.WeChatServerToken,WeChatAccountQRCodeImageURL:e.WeChatAccountQRCodeImageURL}}),passkey:e=>(0,r.jsx)(e_,{defaultValues:{"passkey.enabled":e["passkey.enabled"],"passkey.rp_display_name":e["passkey.rp_display_name"],"passkey.rp_id":e["passkey.rp_id"],"passkey.origins":e["passkey.origins"],"passkey.allow_insecure_origin":e["passkey.allow_insecure_origin"],"passkey.user_verification":e["passkey.user_verification"],"passkey.attachment_preference":e["passkey.attachment_preference"]}}),"bot-protection":e=>(0,r.jsx)(y,{defaultValues:{TurnstileCheckEnabled:e.TurnstileCheckEnabled,TurnstileSiteKey:e.TurnstileSiteKey,TurnstileSecretKey:e.TurnstileSecretKey}}),"custom-oauth":e=>(0,r.jsx)(ea,{serverAddress:e.ServerAddress})},ey=(0,i.h)({sections:eb.iA.map(e=>({...e,build:eC[e.id]})),defaultSection:eb.t0,basePath:"/system-settings/auth",urlStyle:"path"});ey.getSectionNavItems;let ek=ey.getSectionContent,ew=ey.getSectionMeta,eR={PasswordLoginEnabled:!0,PasswordRegisterEnabled:!0,EmailCodeLoginEnabled:!0,EmailVerificationEnabled:!1,RegisterEnabled:!0,EmailDomainRestrictionEnabled:!1,EmailAliasRestrictionEnabled:!1,EmailDomainWhitelist:"",ServerAddress:"",GitHubOAuthEnabled:!1,GitHubClientId:"",GitHubClientSecret:"","discord.enabled":!1,"discord.client_id":"","discord.client_secret":"","oidc.enabled":!1,"oidc.display_name":"","oidc.client_id":"","oidc.client_secret":"","oidc.well_known":"","oidc.authorization_endpoint":"","oidc.token_endpoint":"","oidc.user_info_endpoint":"",TelegramOAuthEnabled:!1,TelegramBotToken:"",TelegramBotName:"",LinuxDOOAuthEnabled:!1,LinuxDOClientId:"",LinuxDOClientSecret:"",LinuxDOMinimumTrustLevel:"0",WeChatAuthEnabled:!1,WeChatServerAddress:"",WeChatServerToken:"",WeChatAccountQRCodeImageURL:"",TurnstileCheckEnabled:!1,TurnstileSiteKey:"",TurnstileSecretKey:"","passkey.enabled":!1,"passkey.rp_display_name":"","passkey.rp_id":"","passkey.origins":"","passkey.allow_insecure_origin":!1,"passkey.user_verification":"preferred","passkey.attachment_preference":""},eS=function(){return(0,r.jsx)(l.R,{routePath:"/_authenticated/system-settings/auth/$section",defaultSettings:eR,defaultSection:eb.t0,getSectionContent:ek,getSectionMeta:ew})}},88192(e,n,t){var r=t(34305),l=t(68413);function i(e,n){let{shouldBlockFn:t,enableBeforeUnload:i=!0,disabled:s=!1,withResolver:a=!1}=function(e,n){if(void 0===e)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if("function"==typeof e){let t=!!(n??!0);return{shouldBlockFn:async()=>!!t&&await e(),enableBeforeUnload:t,withResolver:!1}}let t=!!(e.condition??!0),r=e.blockerFn;return{shouldBlockFn:async()=>t&&void 0!==r?await r():t,enableBeforeUnload:t,withResolver:void 0===r}}(e,n),o=(0,r.r)(),{history:d}=o,[c,u]=l.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return l.useEffect(()=>{let e=async e=>{function n(e){let n=o.parseLocation(e),t=o.getMatchedRoutes(n.pathname);return void 0===t.foundRoute?{routeId:"__notFound__",fullPath:n.pathname,pathname:n.pathname,params:t.routeParam
2s,search:o.options.parseSearch(e.search)}:{routeId:t.foundRoute.id,fullPath:t.foundRoute.fullPath,pathname:n.pathname,params:t.routeParams,search:o.options.parseSearch(e.search)}}let r=n(e.currentLocation),l=n(e.nextLocation);if("__notFound__"===r.routeId&&"__notFound__"!==l.routeId)return!1;let i=await t({action:e.action,current:r,next:l});if(!a)return i;if(!i)return!1;let s=await new Promise(n=>{u({status:"blocked",current:r,next:l,action:e.action,proceed:()=>n(!1),reset:()=>n(!0)})});return u({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),s};return s?void 0:d.block({blockerFn:e,enableBeforeUnload:i})},[t,i,s,a,d,o]),c}t.d(n,{K:()=>i})},67834(e,n,t){let r=(0,t(9781).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);t.d(n,{},{A:r})},50947(e,n,t){let r=(0,t(9781).A)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);t.d(n,{},{A:r})},65277(e,n,t){let r=(0,t(9781).A)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);t.d(n,{},{A:r})},99597(e,n,t){let r=(0,t(9781).A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);t.d(n,{},{A:r})},14653(e,n,t){let r=(0,t(9781).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);t.d(n,{},{A:r})}}]);
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.