PageSourceSearch

https://otoc.ai/static/js/async/5851.cfaca664be.js

js otoc.ai collected 2026-10-05 13:36:32 UTC 84,589 bytes, 1 lines download raw bytes

1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[5851],{83323(e,s,a){var t=a(72361),n=a(56275),r=a(68974),i=a(39649);function l(e){let{title:s,description:a,icon:l,action:o,children:c,disableHoverEffect:d,className:u,headerClassName:m,contentClassName:h,iconClassName:x,iconTone:p,titleClassName:g,descriptionClassName:f}=e;return(0,t.jsxs)(r.Zp,{"data-card-hover":d?"false":void 0,className:(0,n.cn)("gap-0 overflow-hidden py-0",u),children:[(0,t.jsx)(r.aR,{className:(0,n.cn)("border-b p-3 !pb-3 sm:p-5 sm:!pb-5",m),children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[null!=l&&(0,t.jsx)(i.f,{size:"title",tone:p,className:x,children:l}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)(r.ZB,{className:(0,n.cn)("text-lg tracking-tight sm:text-xl",g),children:s}),null!=a&&(0,t.jsx)(r.BT,{className:(0,n.cn)("text-xs sm:text-sm",f),children:a})]})]}),null!=o&&(0,t.jsx)("div",{className:"w-full shrink-0 sm:w-auto",children:o})]})}),(0,t.jsx)(r.Wu,{className:(0,n.cn)("p-3 sm:p-5",h),children:c})]})}a.d(s,{f:()=>l})},19784(e,s,a){var t=a(72361),n=a(63235),r=a(65291),i=a(56275);let l=(0,r.F)("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-md px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}});function o(e){let{className:s,variant:a="default",size:r="default",...o}=e;return(0,t.jsx)(n.l,{"data-slot":"toggle",className:(0,i.cn)(l({variant:a,size:r,className:s})),...o})}a.d(s,{l:()=>o},{v:l})},29607(e,s,a){var t=a(12370);let n={schedule:(e,s)=>globalThis.setTimeout(e,s),cancel:e=>globalThis.clearTimeout(e)},r={schedule:(e,s)=>globalThis.setInterval(e,s),cancel:e=>globalThis.clearInterval(e)};function i(e){return"success"!==e.telegram_bind&&"error"!==e.telegram_bind?null:e.flow_token?"success"===e.telegram_bind?{kind:"result",flowToken:e.flow_token,success:!0}:{kind:"result",flowToken:e.flow_token,success:!1,code:e.error_code}:{kind:"invalid"}}function l(e,s,a){return e?.kind==="result"&&!!s&&!s.closed&&(s.postMessage({type:t.oP,flow_token:e.flowToken,success:e.success,code:e.code},a),!0)}function o(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e4,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n,t=!0,r=a.schedule(()=>{t&&(t=!1,e())},s);return()=>{t&&(t=!1,a.cancel(r))}}function c(e,s){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r,n=!0,i=t.schedule(()=>{n&&e.closed&&(n=!1,t.cancel(i),s())},a);return()=>{n&&(n=!1,t.cancel(i))}}a.d(s,{AC:()=>l,HK:()=>c,cG:()=>o,r0:()=>i})},41804(e,s,a){var t=a(68413);function n(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{initialSeconds:s=30,autoStart:a=!1}=e,[n,r]=(0,t.useState)(s),[i,l]=(0,t.useState)(a),o=(0,t.useRef)(null),c=(0,t.useCallback)(()=>{o.current&&(window.clearInterval(o.current),o.current=null)},[]),d=(0,t.useCallback)(()=>{c(),l(!1)},[c]),u=(0,t.useCallback)(e=>{r(e??s),l(!0),c(),o.current=window.setInterval(()=>{r(e=>e<=1?(c(),l(!1),s):e-1)},1e3)},[c,s]),m=(0,t.useCallback)(()=>{d(),r(s)},[s,d]);return(0,t.useEffect)(()=>()=>c(),[c]),{secondsLeft:n,isActive:i,start:u,stop:d,reset:m}}a.d(s,{L:()=>n})},67750(e,s,a){a.r(s),a.d(s,{component:()=>sS});var t=a(72361),n=a(47745),r=a(39130),i=a(13289),l=a(52523),o=a(53540),c=a(38288),d=a(40315),u=a(37116),m=a(87159),h=a(24623),x=a(63162),p=a(68413),g=a(6702),f=a(20598),j=a(60641),y=a(55505),v=a(72868),b=a(68974),w=a(39649),N=a(97785),k=a(47303),C=a(43459),_=a(84935),F=a(56275),S=a(22990);async function A(){return(await S.FH.get("/api/user/self")).data}async function R(e){return(await S.FH.put("/api/user/self",e,{acceptAuthRotation:!!e.password})).data}async function E(e){return(await S.FH.put("/api/user/setting",e)).data}async function P(e){return(await S.FH.put("/api/user/self",{language:e})).data}async function B(e){return(await S.FH.delete("/api/user/self",{data:e})).data}async function T(){return(await S.FH.get("/api/user/token")).data}async function $(e,s){let a=new URLSearchParams({email:e});return s&&a.append("turnstile",s),(await S.FH.get(`/api/verification?${a}`)).data}async function O(e,s){return(await S.FH.post("/api/oauth/email/bind",{email:e,code:s})).data}async function z(e){return(await S.FH.post("/api/oauth/wechat/bind",{code:e},{skipBusinessError:!0,skipErrorHandler:!0})).data}async function D(){return(await S.FH.post("/api/oauth/telegram/bind/start")).data}async function U(){return(await S.FH.get("/api/user/sessions")).data}async function L(e){return(await S.FH.delete(`/api/user/sessions/${encodeURIComponent(e)}`)).data}async function M(){return(await S.FH.post("/api/user/sessions/revoke-others")).data}async function W(){return(await S.FH.get("/api/user/oauth/bindings")).data}async function q(e){return(await S.FH.delete(`/api/user/oauth/bindings/${e}`)).data}async function H(e){return(await S.FH.get(`/api/user/checkin?month=${e}`)).data}async function I(e){let s=e?`/api/user/checkin?turnstile=${encodeURIComponent(e)}`:"/api/user/checkin";return(await S.FH.post(s)).data}function J(e){let{checkinEnabled:s,turnstileEnabled:a,turnstileSiteKey:n}=e,{t:r}=(0,g.Bd)(),[i,l]=(0,p.useState)(()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth(),1)}),[S,A]=(0,p.useState)(!1),[R,E]=(0,p.useState)(!1),[P,B]=(0,p.useState)(0),[T,$]=(0,p.useState)(!1),[O,z]=(0,p.useState)(!1),D=(0,p.useMemo)(()=>{let e=i.getFullYear(),s=String(i.getMonth()+1).padStart(2,"0");return`${e}-${s}`},[i]),{data:U,isLoading:L,refetch:M}=(0,o.I)({queryKey:["checkin-status",D],queryFn:async()=>{let e=await H(D);if(e.success&&e.data)return e.data;throw Error(e.message||r("Failed to fetch checkin status"))},enabled:s,staleTime:3e4}),W=(0,p.useMemo)(()=>{let e={};
1return(U?.stats?.records||[]).forEach(s=>{e[s.checkin_date]=s.quota_awarded}),e},[U?.stats?.records]),q=(0,p.useMemo)(()=>(U?.stats?.records||[]).reduce((e,s)=>e+(s.quota_awarded||0),0),[U?.stats?.records]),J=(0,p.useMemo)(()=>{let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`},[]),Z=U?.stats?.checked_in_today===!0,Y=W[J];(0,p.useEffect)(()=>{T||L||U&&(z(Z),$(!0))},[U,Z,T,L]);let G=(0,p.useCallback)(e=>!!a&&("string"!=typeof e||e.includes("Turnstile")),[a]),V=(0,p.useCallback)(async e=>{A(!0);try{let s=await I(e);if(s.success&&s.data)f.oR.success(`${r("Check-in successful! Received")} ${(0,C.rP)(s.data.quota_awarded)}`),M(),E(!1);else{if(!e&&G(s.message)){if(!n)return void f.oR.error(r("Turnstile is enabled but site key is empty."));E(!0);return}e&&G(s.message)&&B(e=>e+1),f.oR.error(s.message||r("Check-in failed"))}}catch{f.oR.error(r("Check-in failed"))}finally{A(!1)}},[M,G,r,n]),K=(0,p.useMemo)(()=>{let e=i.getFullYear(),s=i.getMonth(),a=new Date(e,s,1),t=new Date(e,s+1,0).getDate(),n=a.getDay(),r=[];for(let a=0;a<n;a++){let t=new Date(e,s,-n+a+1);
1r.push({date:t,isCurrentMonth:!1})}for(let a=1;a<=t;a++)r.push({date:new Date(e,s,a),isCurrentMonth:!0});let l=7-r.length%7;if(l<7)for(let a=1;a<=l;a++)r.push({date:new Date(e,s+1,a),isCurrentMonth:!1});return r},[i]);if(!s)return null;if(L)return(0,t.jsx)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:(0,t.jsx)("div",{className:"p-6",children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(N.E,{className:"h-10 w-10 rounded-xl"}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(N.E,{className:"h-5 w-32"}),(0,t.jsx)(N.E,{className:"h-3 w-56"})]})]}),(0,t.jsx)(N.E,{className:"h-9 w-28 rounded-md"})]})})});let Q=r("Check in now");return S?Q=r("Loading..."):Z&&(Q=r("Checked in")),(0,t.jsxs)(k.Bc,{delay:100,children:[(0,t.jsxs)(j.l,{open:R,onOpenChange:e=>{E(e),e||B(e=>e+1)},title:r("Security Check"),contentClassName:"sm:max-w-md",contentHeight:"auto",bodyClassName:"space-y-4",children:[(0,t.jsx)("div",{className:"text-muted-foreground text-sm",children:r("Please complete the security check to continue.")}),(0,t.jsx)("div",{className:"flex justify-center py-4",children:(0,t.jsx)(y.X,{siteKey:n,onVerify:e=>{V(e)},onExpire:()=>{B(e=>e+1)}},P)})]}),(0,t.jsxs)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:[(0,t.jsx)("div",{className:"border-b p-4 sm:p-6",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[(0,t.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-3 rounded-lg text-left whitespace-normal outline-none",onClick:()=>z(e=>!e),children:[(0,t.jsx)(w.f,{tone:"neutral",size:"lg",className:"sm:size-11",children:(0,t.jsx)(c.A,{className:"h-4 w-4 sm:h-5 sm:w-5",strokeWidth:2})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,t.jsx)("h3",{className:"text-base font-semibold tracking-tight sm:text-lg",children:r("Daily Check-in")}),Z&&(0,t.jsxs)("div",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-600 sm:gap-1.5 sm:px-2.5 sm:text-xs dark:text-emerald-400",children:[(0,t.jsx)(d.A,{className:"h-2.5 w-2.5 sm:h-3 sm:w-3"}),r("Checked in")]}),(0,t.jsx)("span",{className:"text-muted-foreground inline-flex items-center",children:O?(0,t.jsx)(u.A,{className:"h-4 w-4"}):(0,t.jsx)(m.A,{className:"h-4 w-4"})})]}),(0,t.jsx)("p",{className:"text-muted-foreground mt-1 line-clamp-2 text-xs sm:text-sm",children:Z&&void 0!==Y?`${r("Today")} +${(0,C.rP)(Y)}`:r("Check in daily to receive random quota rewards")})]})]}),(0,t.jsx)(v.$,{onClick:()=>V(),disabled:S||Z,size:"sm",className:"w-full shrink-0 sm:w-auto",children:Q})]})}),O?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-px border-b",children:[(0,t.jsxs)("div",{className:"bg-card p-3 text-center sm:p-5",children:[(0,t.jsx)("div",{className:"text-xl font-semibold tracking-tight tabular-nums sm:text-2xl",children:U?.stats?.total_checkins||0}),(0,t.jsx)("div",{className:"text-muted-foreground mt-0.5 text-[10px] font-medium sm:mt-1 sm:text-xs",children:r("Total check-ins")})]}),(0,t.jsxs)("div",{className:"bg-card p-3 text-center sm:p-5",children:[(0,t.jsx)("div",{className:"text-xl font-semibold tracking-tight tabular-nums sm:text-2xl",children:(0,C.rP)(q,{digitsLarge:0})}),(0,t.jsx)("div",{className:"text-muted-foreground mt-0.5 text-[10px] font-medium sm:mt-1 sm:text-xs",children:r("This month")})]}),(0,t.jsxs)("div",{className:"bg-card p-3 text-center sm:p-5",children:[(0,t.jsx)("div",{className:"text-xl font-semibold tracking-tight tabular-nums sm:text-2xl",children:(0,C.rP)(U?.stats?.total_quota||0,{digitsLarge:0})}),(0,t.jsx)("div",{className:"text-muted-foreground mt-0.5 text-[10px] font-medium sm:mt-1 sm:text-xs",children:r("Total earned")})]})]}),(0,t.jsx)("div",{className:"p-4 sm:p-6",children:(0,t.jsxs)("div",{className:"space-y-3 sm:space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h4",{className:"text-xs font-semibold sm:text-sm",children:(0,_.A)(i).format("YYYY-MM")}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[(0,t.jsx)(v.$,{variant:"ghost",size:"icon",className:"h-7 w-7 sm:h-8 sm:w-8",onClick:()=>{l(new Date(i.getFullYear(),i.getMonth()-1,1))},children:(0,t.jsx)(h.A,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})}),(0,t.jsx)(v.$,{variant:"ghost",size:"icon",className:"h-7 w-7 sm:h-8 sm:w-8",onClick:()=>
1{l(new Date(i.getFullYear(),i.getMonth()+1,1))},children:(0,t.jsx)(x.A,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-7 gap-0.5 sm:gap-1",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(e=>(0,t.jsx)("div",{className:"text-muted-foreground flex h-7 items-center justify-center text-[10px] font-medium sm:h-8 sm:text-xs",children:e},e)),K.map(e=>{let s=`${e.date.getFullYear()}-${String(e.date.getMonth()+1).padStart(2,"0")}-${String(e.date.getDate()).padStart(2,"0")}`,a=s===J,n=W[s],i=void 0!==n,l=e.date.getDate(),o=(0,t.jsxs)(v.$,{variant:a?"default":"ghost",disabled:!e.isCurrentMonth,className:(0,F.cn)("relative flex h-9 w-full flex-col items-center justify-center rounded-lg px-0 text-xs font-medium sm:h-10 sm:text-sm",!e.isCurrentMonth&&"text-muted-foreground/40 cursor-default",!a&&i&&"font-semibold"),children:[(0,t.jsx)("span",{className:"tabular-nums",children:l}),i&&!a&&(0,t.jsx)("span",{className:"bg-success absolute bottom-0.5 size-1 rounded-full sm:bottom-1"})]},s);return i&&e.isCurrentMonth?(0,t.jsxs)(k.m_,{children:[(0,t.jsx)(k.k$,{render:o}),(0,t.jsx)(k.ZI,{children:(0,t.jsxs)("div",{className:"text-xs",children:[(0,t.jsx)("div",{className:"font-medium",children:r("Checked in")}),(0,t.jsxs)("div",{className:"text-muted-foreground mt-0.5",children:["+",(0,C.rP)(n)]})]})})]},s):o})]}),(0,t.jsx)("div",{className:"text-muted-foreground border-t pt-3 text-center text-[11px] sm:pt-4 sm:text-xs",children:r("You can only check in once per day")}),(0,t.jsx)("div",{className:"bg-muted/30 text-muted-foreground rounded-lg border p-3 text-xs",children:(0,t.jsxs)("ul",{className:"list-disc space-y-1 pl-5",children:[(0,t.jsx)("li",{children:r("Check in daily to receive random quota rewards")}),(0,t.jsx)("li",{children:r("Rewards will be added directly to your balance")}),(0,t.jsx)("li",{children:r("Do not repeat check-in; only once per day")})]})})]})})]})]})]})}var Z=a(53771),Y=a(55724),G=a(88288),V=a(83323),K=a(52048);function Q(e){if(!e)return{};try{return JSON.parse(e)}catch{return{}}}function X(e){let{t:s,i18n:a}=(0,g.Bd)(),{auth:n}=(0,l.n)(),[r,i]=(0,p.useState)(!1),o=(0,p.useMemo)(()=>{let s=Q(e.profile?.setting);return(0,K.LL)(s.language||a.language)},[e.profile?.setting,a.language]),[c,d]=(0,p.useState)(o);(0,p.useEffect)(()=>{d(o)},[o]);let u=async t=>{if(!t)return;let r=(0,K.LL)(t);if(r!==c){d(r),i(!0),await a.changeLanguage(r);try{let a=await P(r);if(!a.success)throw Error(a.message||s("Failed to update settings"));if(n.user){let e="string"==typeof n.user.setting?Q(n.user.setting):n.user.setting??{};n.setUser({...n.user,setting:JSON.stringify({...e,language:r})})}e.onProfileUpdate(),f.oR.success(s("Language preference saved"))}catch{d(c),await a.changeLanguage(c),f.oR.error(s("Failed to update settings"))}finally{i(!1)}}};return(0,t.jsx)(V.f,{title:s("Language Preferences"),description:s("Set the language used across the interface"),icon:(0,t.jsx)(Z.A,{className:"h-4 w-4"}),iconTone:"chart-4",disableHoverEffect:!0,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:s("Interface Language")}),(0,t.jsx)("p",{className:"text-muted-foreground line-clamp-2 text-xs sm:text-sm",children:s("Language preferences sync across your signed-in devices and affect API error messages.")})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 sm:min-w-48",children:[(0,t.jsxs)(G.l6,{items:K.iX.map(e=>({value:e.code,label:e.label})),value:c,onValueChange:u,disabled:r,children:[(0,t.jsx)(G.bq,{className:"w-full sm:w-48",children:(0,t.jsx)(G.yv,{placeholder:s("Select language")})}),(0,t.jsx)(G.gC,{alignItemWithTrigger:!1,children:(0,t.jsx)(G.s3,{children:K.iX.map(e=>(0,t.jsx)(G.eb,{value:e.code,children:e.label},e.code))})})]}),r&&(0,t.jsx)(Y.A,{className:"text-muted-foreground size-4 animate-spin"})]})]})})}var ee=a(52452),es=a(34673),ea=a(74401),et=a(96962),en=a(55667),er=a(82799),ei=a(12393),el=a(38939),eo=a(73280);function ec(e){let{revokeTarget:s,confirmOthers:a,revoking:n,revokingOthers:r,onRevokeTargetChange:i,onConfirmOthersChange:l,onRevoke:o,onRevokeOthers:c}=e,{t:d}=(0,g.Bd)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eo.T,{open:!!s,onOpenChange:e=>!e&&i(null),title:d(s?.current?"Sign out this device?":"Revoke session?"),desc:d("This session will lose access immediately and must sign in again."),confirmText:d(s?.current?"Sign out":"Revoke"),destructive:!0,isLoading:n,handleConfirm:o}),(0,t.jsx)(eo.T,{open:a,onOpenChange:l,title:d("Sign out other sessions?"),desc:d("Every other device will lose access immediately. This device will remain signed in."),confirmText:d("Sign out others"),destructive:!0,isLoading:r,handleConfirm:c})]})}var ed=a(50708),eu=a(90879);function em(e){let{session:s,onRevoke:a}=e,{t:n}=(0,g.Bd)();return(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-4 sm:flex-row sm:items-center",children:[(0,t.jsx)("div",{className:"bg-muted flex size-10 shrink-0 items-center justify-center rounded-lg",children:(0,t.jsx)(ea.n,{icon:ed.A,className:"size-5",strokeWidth:2})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("p",{className:"font-medium",children:function(e,s,a){if(!e)return s;let t=a;e.includes("Edg/")?t="Edge":e.includes("Chrome/")?t="Chrome":e.includes("Firefox/")?t="Firefox":e.includes("Safari/")&&(t="Safari");let n="";return e.includes("Windows")?n="Windows":e.includes("Mac OS")?n="macOS":e.includes("Android")?n="Android":e.includes("iPhone")||e.includes("iPad")?n="iOS":e.includes("Linux")&&(n="Linux"),n?`${t} \xb7 ${n}`:t}(s.user_agent,n("Unknown device"),n("Browser"))}),s.current&&(0,t.jsx)(eu.E,{variant:"secondary",children:n("Current")})]}),(0,t.jsx)("p",{className:"text-muted-foreground mt-1 text-xs",children:n("IP: {{ip}}
1 · Method: {{method}}",{ip:s.ip||n("Unknown"),method:function(e,s){let a=e.trim().toLowerCase();switch(a){case"password":return s("Password");case"2fa":return s("Two-factor Authentication");case"passkey":return s("Passkey");case"wechat":return s("WeChat");case"telegram":return s("Telegram");case"oauth":return s("OAuth");case"unknown":case"":return s("Unknown")}if(!a.startsWith("oauth:"))return e;let t=a.slice(6);return`${s("OAuth")} \xb7 ${({discord:"Discord",github:"GitHub",linuxdo:"LinuxDO",oidc:"OIDC"})[t]||t}`}(s.login_method,n)})}),(0,t.jsx)("p",{className:"text-muted-foreground mt-1 text-xs",children:n("Last active {{time}} · Expires {{expires}}",{time:_.A.unix(s.last_active_at).fromNow(),expires:_.A.unix(s.expires_at).format("YYYY-MM-DD HH:mm")})})]}),(0,t.jsx)(v.$,{type:"button",variant:s.current?"outline":"ghost",size:"sm",onClick:()=>a(s),children:n(s.current?"Sign out":"Revoke")})]})}let eh=["profile","login-sessions"];function ex(){let e,{t:s}=(0,g.Bd)(),a=(0,er.Z)(),n=(0,et.jE)(),[r,i]=(0,p.useState)(null),[l,c]=(0,p.useState)(!1),d=(0,o.I)({queryKey:eh,queryFn:async()=>{let e=await U();if(!e.success)throw Error(e.message||s("Failed to load login sessions"));return e.data??[]}}),u=(0,en.n)({mutationFn:async e=>{let a=await L(e);if(!a.success)throw Error(a.message||s("Failed to sign out session"));return e},onSuccess:async e=>{let t=d.data?.some(s=>s.sid===e&&s.current);if(i(null),t){(0,S.BR)(n),a({to:"/sign-in",replace:!0});return}f.oR.success(s("Session signed out")),await n.invalidateQueries({queryKey:eh})},onError:e=>f.oR.error(e.message)}),m=(0,en.n)({mutationFn:async()=>{let e=await M();if(!e.success)throw Error(e.message||s("Failed to sign out other sessions"))},onSuccess:async()=>{c(!1),f.oR.success(s("Other sessions signed out")),await n.invalidateQueries({queryKey:eh})},onError:e=>f.oR.error(e.message)}),h=d.data??[],x=h.some(e=>!e.current);return e=d.isLoading?(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsx)(N.E,{className:"h-20 w-full"}),(0,t.jsx)(N.E,{className:"h-20 w-full"})]}):d.isError?(0,t.jsxs)(ei.Sv,{children:[(0,t.jsxs)(ei.FT,{children:[(0,t.jsx)(ei.Kr,{variant:"icon",children:(0,t.jsx)(ea.n,{icon:ee.A,strokeWidth:2})}),(0,t.jsx)(ei.cz,{children:s("Unable to load login sessions")}),(0,t.jsx)(ei.Ou,{children:s("Refresh the list and try again.")})]}),(0,t.jsx)(v.$,{type:"button",variant:"outline",onClick:()=>d.refetch(),children:s("Retry")})]}):0===h.length?(0,t.jsx)(ei.Sv,{children:(0,t.jsxs)(ei.FT,{children:[(0,t.jsx)(ei.Kr,{variant:"icon",children:(0,t.jsx)(ea.n,{icon:ee.A,strokeWidth:2})}),(0,t.jsx)(ei.cz,{children:s("No active login sessions")})]})}):(0,t.jsx)("div",{className:"flex flex-col",children:h.map((e,s)=>(0,t.jsxs)("div",{children:[s>0&&(0,t.jsx)(el.w,{}),(0,t.jsx)(em,{session:e,onRevoke:i})]},e.sid))}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(b.Zp,{"data-card-hover":"false",children:[(0,t.jsxs)(b.aR,{children:[(0,t.jsx)(b.ZB,{children:s("Login sessions")}),(0,t.jsx)(b.BT,{children:s("Review and sign out devices currently using your account.")}),(0,t.jsx)(b.X9,{children:(0,t.jsxs)(v.$,{type:"button",variant:"outline",size:"sm",disabled:!x||m.isPending,onClick:()=>c(!0),children:[(0,t.jsx)(ea.n,{icon:es.A,"data-icon":"inline-start",strokeWidth:2}),s("Sign out other sessions")]})})]}),(0,t.jsx)(b.Wu,{children:e})]}),(0,t.jsx)(ec,{revokeTarget:r,confirmOthers:l,revoking:u.isPending,revokingOthers:m.isPending,onRevokeTargetChange:i,onConfirmOthersChange:c,onRevoke:()=>{r&&u.mutate(r.sid)},onRevokeOthers:()=>m.mutate()})]})}var ep=a(47296),eg=a(96855),ef=a(18100),ej=a(42817),ey=a(92379),ev=a(7051),eb=a(
171654);function ew(e){let{loading:s}=e,{t:a}=(0,g.Bd)(),[n,r]=(0,p.useState)(!1),[i,l]=(0,p.useState)(null),{status:o,loading:c,registering:d,removing:u,supported:m,enabled:h,lastUsed:x,register:j,remove:y}=(0,ev.D4)(),{open:k,setOpen:C,methods:F,state:S,startVerification:A,executeVerification:R,cancel:E,setCode:P,switchMethod:B,fetchVerificationMethods:T}=(0,eb.Yu)({onSuccess:()=>{l(null)}}),$=(0,p.useMemo)(()=>i?{...F,has2FA:"2fa"===i&&F.has2FA,hasPasskey:"passkey"===i&&F.hasPasskey}:F,[i,F]),O=(0,p.useCallback)(async()=>{m?(await T()).has2FA?(l("2fa"),await A(j,{scope:"passkey.register",preferredMethod:"2fa",title:a("Security verification"),description:a("Confirm your identity with Two-factor Authentication before registering a Passkey.")})):await j():f.oR.info(a("This device does not support Passkey"))},[T,j,A,m,a]),z=(0,p.useCallback)(async()=>{let e=await T(),s=null;(e.has2FA?s="2fa":e.hasPasskey&&(s="passkey"),s)?"passkey"!==s||e.passkeySupported?(r(!1),l(s),await A(y,{scope:"passkey.delete",preferredMethod:s,title:a("Security verification"),description:a("Confirm your identity before removing this Passkey from your account.")})):f.oR.info(a("This device does not support Passkey")):f.oR.error(a("Please enable Two-factor Authentication or Passkey before proceeding"))},[T,y,A,a]),D=(0,p.useCallback)(()=>{l(null),E()},[E]),U=(0,p.useCallback)(e=>{e||l(null),C(e)},[C]),L=(0,p.useCallback)(async(e,s)=>{try{await R(e,s)}catch{}},[R]);if(s||c)return(0,t.jsxs)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:[(0,t.jsxs)(b.aR,{className:"p-3 sm:p-5",children:[(0,t.jsx)(N.E,{className:"h-6 w-48"}),(0,t.jsx)(N.E,{className:"mt-2 h-4 w-64"})]}),(0,t.jsx)(b.Wu,{className:"p-3 sm:p-5",children:(0,t.jsx)(N.E,{className:"h-20 w-full"})})]});let M=x&&!Number.isNaN(Date.parse(x))?(0,_.A)(x).fromNow():a("Not used yet"),W=!m&&!h,q=null;return o?.backup_eligible!==void 0&&(q={label:a("No backup"),variant:"neutral"},o.backup_eligible&&(q={label:o.backup_state?a("Backed up"):a("Not backed up"),variant:o.backup_state?"success":"warning"})),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:[(0,t.jsxs)(b.aR,{className:"p-3 sm:p-5",children:[(0,t.jsx)(b.ZB,{className:"text-lg tracking-tight sm:text-xl",children:a("Passkey Login")}),(0,t.jsx)(b.BT,{className:"text-xs sm:text-sm",children:a("Use Passkey to sign in without entering your password.")})]}),(0,t.jsx)(b.Wu,{className:"p-3 sm:p-5",children:(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between xl:flex-col 2xl:flex-row",children:[(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)(w.f,{tone:"info",size:"sm",children:(0,t.jsx)(ep.A,{})}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("p",{className:"font-medium",children:a("Passkey Authentication")}),(0,t.jsx)(ej.Wh,{label:h?a("Enabled"):a("Disabled"),variant:h?"success":"neutral",showDot:!0,copyable:!1}),q&&(0,t.jsx)(ej.Wh,{label:q.label,variant:q.variant,showDot:!0,copyable:!1})]}),(0,t.jsxs)("p",{className:"text-muted-foreground text-sm",children:[a("Last used:")," ",M]})]})]}),!h&&(0,t.jsxs)(v.$,{className:"w-full sm:w-auto xl:w-full 2xl:w-auto",onClick:O,disabled:!m||d,children:[d&&(0,t.jsx)(Y.A,{className:"mr-2 h-4 w-4 animate-spin"}),a("Enable Passkey")]})]}),h&&(0,t.jsx)("div",{className:"flex flex-col gap-3 border-t pt-6 sm:flex-row xl:flex-col 2xl:flex-row",children:(0,t.jsxs)(ey.Lt,{open:n,onOpenChange:r,children:[(0,t.jsxs)(ey.tv,{render:(0,t.jsx)(v.$,{variant:"destructive",className:"flex-1",disabled:u}),children:[u?(0,t.jsx)(Y.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(eg.A,{className:"mr-2 h-4 w-4"}),a("Remove Passkey")]}),(0,t.jsxs)(ey.EO,{children:[(0,t.jsxs)(ey.wd,{children:[(0,t.jsx)(ey.r7,{children:a("Remove Passkey?")}),(0,t.jsx)(ey.$v,{children:a("Removing Passkey will require you to sign in with your password next time. You can re-register anytime.")})]}),(0,t.jsxs)(ey.ck,{children:[(0,t.jsx)(ey.Zr,{disabled:u,children:a("Cancel")}),(0,t.jsx)(ey.Rx,{variant:"destructive",disabled:u,onClick:e=>{e.preventDefault(),z()},children:a("Remove")})]})]})]})}),W&&(0,t.jsxs)("div",{className:"bg-muted/60 text-muted-foreground flex items-start gap-3 rounded-md p-4 text-sm",children:[(0,t.jsx)(ef.A,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-amber-500"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-foreground font-medium",children:a("Passkey not supported on this device")}),(0,t.jsx)("p",{children:a("Use a compatible browser or device with biometric authentication or a security ke
1y to register a Passkey.")})]})]})]})})]}),(0,t.jsx)(eb.x9,{open:k,onOpenChange:U,methods:$,state:S,onVerify:L,onCancel:D,onCodeChange:P,onMethodChange:B})]})}var eN=a(567),ek=a(65253),eC=a(1333),e_=a(13683),eF=a(15585),eS=a(33271),eA=a(89795);function eR(e){let{profile:s,loading:a}=e,{t:n}=(0,g.Bd)();if(a)return(0,t.jsxs)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:[(0,t.jsx)(b.Wu,{className:"p-4 sm:p-5",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center sm:flex-row sm:text-left",children:[(0,t.jsx)(N.E,{className:"h-16 w-16 rounded-2xl"}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 sm:flex-row sm:justify-start",children:[(0,t.jsx)(N.E,{className:"h-8 w-48"}),(0,t.jsx)(N.E,{className:"h-5 w-16"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1 sm:flex-row sm:justify-start sm:gap-4",children:[(0,t.jsx)(N.E,{className:"h-4 w-24"}),(0,t.jsx)(N.E,{className:"h-4 w-40"}),(0,t.jsx)(N.E,{className:"h-4 w-20"})]})]})]})}),(0,t.jsx)("div",{className:"border-t",children:(0,t.jsx)("div",{className:"divide-border/60 grid grid-cols-1 divide-y sm:grid-cols-3 sm:divide-x sm:divide-y-0",children:["balance","usage","requests"].map(e=>(0,t.jsxs)("div",{className:"px-4 py-3.5 sm:px-5 sm:py-4",children:[(0,t.jsx)(N.E,{className:"h-3.5 w-20"}),(0,t.jsx)(N.E,{className:"mt-2 h-7 w-28"}),(0,t.jsx)(N.E,{className:"mt-1.5 h-3.5 w-24"})]},e))})})]});if(!s)return null;let r=s?s.display_name||s.username:"",i=s.username||r,l=(0,eF.f)(i),o=(0,eF.u)(i),c=(0,eA.d9)(s.role),d=[{label:n("Current Balance"),value:(0,eS.eN)(s.quota),description:n("Remaining quota"),icon:eN.A,tone:"success"},{label:n("Total Usage"),value:(0,eS.eN)(s.used_quota),description:n("Total consumed quota"),icon:ek.A,tone:"info"},{label:n("API Requests"),value:(0,eS.wk)(s.request_count),description:n("Total requests made"),icon:eC.A,tone:"chart-4"}];return(0,t.jsxs)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:[(0,t.jsx)(b.Wu,{className:"p-3 sm:p-5",children:(0,t.jsxs)("div",{className:"flex items-center gap-3 text-left sm:gap-4",children:[(0,t.jsx)(e_.eu,{className:"ring-background h-12 w-12 rounded-xl text-sm ring-2 sm:h-16 sm:w-16 sm:rounded-2xl sm:text-lg sm:ring-4",children:(0,t.jsx)(e_.q5,{className:"rounded-xl font-semibold text-white sm:rounded-2xl",style:o,children:l})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1.5 sm:space-y-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("h1",{className:"truncate text-xl font-semibold tracking-tight sm:text-2xl",children:r}),(0,t.jsx)(ej.Wh,{label:c,variant:"neutral",copyable:!1}),(0,t.jsx)(ej.Wh,{label:`${n("User ID")} ${s.id}`,variant:"info",copyText:String(s.id)})]}),(0,t.jsxs)("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs sm:gap-x-4 sm:text-sm",children:[(0,t.jsxs)("span",{className:"truncate",children:["@",s.username]}),s.email&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{children:"•"}),(0,t.jsx)("span",{className:"truncate",children:s.email})]}),s.group&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{children:"•"}),(0,t.jsx)("span",{className:"truncate",children:s.group})]})]})]})]})}),(0,t.jsx)("div",{className:"border-t",children:(0,t.jsx)("div",{className:"divide-border/60 grid grid-cols-3 divide-x",children:d.map(e=>(0,t.jsxs)("div",{className:"min-w-0 px-3 py-3 sm:px-5 sm:py-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(w.f,{tone:e.tone,size:"stat",children:(0,t.jsx)(e.icon,{})}),(0,t.jsx)("div",{className:"text-muted-foreground truncate text-xs font-medium tracking-wider uppercase",children:e.label})]}),(0,t.jsx)("div",{className:"text-foreground mt-1.5 truncate font-mono text-lg font-bold tracking-tight tabular-nums sm:mt-2 sm:text-2xl",children:e.value}),(0,t.jsx)("div",{className:"text-muted-foreground/60 mt-1 hidden text-xs md:block",children:e.description})]},e.label))})})]})}var eE=a(63881),eP=a(41167),eB=a(14653),eT=a(20687),e$=a(54622),eO=a(18557),ez=a(1738),eD=a(11728),eU=a(19376),eL=a(29625);let eM={enabled:!1,locked:!1,backup_codes_remaining:0};function eW(e){let{open:s,onOpenChange:a}=e,{t:n}=(0,g.Bd)(),{token:r,generating:i,generate:l}=function(){let[e,s]=(0,p.useState)(""),[a,t]=(0,p.useState)(!1),{copyToClipboard:n}=(0,eL.C)({notify:!1});return{token:e,generating:a,generate:(0,p.useCallback)(async()=>{try{t(!0);let e=await T();if(e.success&&e.data)return s(e.data),n(e.data),f.oR.success(eU.Ay.t("Token regenerated and copied to clipboard")),!0;return f.oR.error(e.message||eU.Ay.t("Failed to generate token")),!1}catch(e){return console.error("Failed to generate token:",e),f.oR.error(eU.Ay.t("Failed to generate token")),!1}finally{t(!1)}},[n])}}();return(0,p.useEffect)(()=>{s&&!r&&l()},[s,r,l]),(0,t.jsx)(j.l,{open:s,onOpenChange:a,title:n("Access Token"),description:n("Your system access token for API authentication. Keep it secure and don't share it with others."),contentClassName:"sm:max-w-md",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(v.$,{type:"button",variant:"outline",onClick:()=>a(!1),children:n("Close")}),(0,t.jsxs)(v.$,{type:"button",onClick:l,disabled:i,className:"gap-2",children:[i?(0,t.jsx)(Y.A,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(e$.A,{className:"h-4 w-4"}),n(i?"Generating...":"Regenerate")]})]}),children:(0,t.jsx)("div",{className:"my-6 space-y-4",children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eD.J,{htmlFor:"token",children:n("Token")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(ez.p,{id:"token",type:"text",value:r,readOnly:!0,className:"font-mono text-xs",placeholder:n('Click "Generate" to create a token')}),(0,t.jsx)(eO.i,{value:r,variant:"outline",className:"size-9",iconClassName:"size-4",tooltip:n("Copy token"),"aria-label":n("Copy token")})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:n("Use this token for API authentication")})]})})})}var eq=a(28057);function eH(e){let{open:s,onOpenChange:a,username:n}=e,{t:r}=(0,g.Bd)(),[i,l]=(0,p.useState)(!1),[o,c]=(0,p.useState)({originalPassword:"",newPassword:"",confirmPassword:""}),d=(e,s)=>{c(a=>({...a,[e]:s}))},u=async e=>{if(e.preventDefault(),!o.originalPassword)return void f.oR.error(r("Please enter your current password"));if(!o.newPassword)return void f.oR.error(r("Please enter a new password"));if(o.newPassword.length<8)return void f.oR.error(r("Password must be at least 8 characters"));if(o.originalPassword===o.newPassword)return void f.oR.error(r("New password must be different from current password"));if(o.newPassword!==o.confirmPassword)return void f.oR.error(r("Passwords do not match"));try{l(!0);let e=await R({original_password:o.originalPassword,password:o.newPassword});e.success?(f.oR.success(r("Password changed successfully")),a(!1),c({originalPassword:"",newPassword:"",confirmPassword:""})):f.oR.error(e.message||r("Failed to change password"))}catch(e){f.oR.error(r("Failed to change password"))}finally{l(!1)}},m="change-password-form";return(0,t.jsx)(j.l,{open:s,onOpenChange:a,title:r("Change Password"),description:(0,t.jsxs)(t.Fragment,{children:[r("Update your password for account:")," ",(0,t.jsx)("strong",{children:n})]}),contentClassName:"sm:max-w-md",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(v.$,{type:"button",variant:"outline",onClick:()=>a(!1),disabled:i,children:r("Cancel")}),(0,t.jsxs)(v.$,{type:"submit",form:m,disabled:i,children:[i&&(0,t.jsx)(Y.A,{className:"mr-2 h-4 w-4 animate-spin"}),i?r("Changing..."):r("Change Password")]})]}),children:(0,t.jsxs)("form",{id:m,onSubmit:u,className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eD.J,{htmlFor:"currentPassword",children:r("Current Password")}),(0,t.jsx)(eq.y,{id:"currentPassword",value:o.originalPassword,onChange:e=>d("originalPassword",e.target.value),disabled:i,required:!0,autoComplete:"current-password"})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eD.J,{htmlFor:"newPassword",children:r("New Password")}),(0,t.jsx)(eq.y,{id:"newPassword",value:o.newPassword,onChange:e=>d("newPassword",e.target.value),disabled:i,required:!0,minLength:8,autoComplete:"new-password"}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:r("Must be at least 8 characters")})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eD.J,{htmlFor:"confirmPassword",children:r("Confirm New Password")}),(0,t.jsx)(eq.y,{id:"confirmPassword",value:o.confirmPassword,onChange:e=>d("confirmPassword",e.target.value),disabled:i,required:!0,autoComplete:"new-password"})]})]})})}var eI=a(43284),eJ=a(86023);function eZ(e){let{open:s,onOpenChange:a,username:n}=e,{t:r}=(0,g.Bd)(),i=(0,er.Z)(),[l,o]=(0,p.useState)(!1),[c,d]=(0,p.useState)(""),u=async()=>
1{if(c!==n)return void f.oR.error(r("Username confirmation does not match"));try{o(!0);let e=await B();if(e.success){f.oR.success(r("Account deleted successfully"));try{await (0,eJ.ri)()}catch{}(0,S.cy)(),i({to:"/sign-in"})}else f.oR.error(e.message||r("Failed to delete account"))}catch{f.oR.error(r("Failed to delete account"))}finally{o(!1)}},m=e=>{!l&&(a(e),e||d(""))};return(0,t.jsx)(j.l,{open:s,onOpenChange:m,title:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eg.A,{className:"h-5 w-5"}),r("Delete Account")]}),description:r("This action cannot be undone. This will permanently delete your account and remove all your data from our servers."),contentClassName:"sm:max-w-md",titleClassName:"text-destructive flex items-center gap-2",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(v.$,{type:"button",variant:"outline",onClick:()=>m(!1),disabled:l,children:r("Cancel")}),(0,t.jsxs)(v.$,{type:"button",variant:"destructive",onClick:u,disabled:l||c!==n,children:[l&&(0,t.jsx)(Y.A,{className:"mr-2 h-4 w-4 animate-spin"}),l?r("Deleting..."):r("Delete Account")]})]}),children:(0,t.jsxs)("div",{className:"my-6 space-y-4",children:[(0,t.jsxs)(eI.Fc,{variant:"destructive",children:[(0,t.jsx)(eg.A,{className:"h-4 w-4"}),(0,t.jsx)(eI.TN,{children:r("Warning: This action is permanent and irreversible!")})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)(eD.J,{htmlFor:"confirmation",children:[r("Type")," ",(0,t.jsx)("strong",{children:n})," ",r("to confirm")]}),(0,t.jsx)(ez.p,{id:"confirmation",type:"text",value:c,onChange:e=>d(e.target.value),disabled:l,placeholder:n,autoComplete:"off"})]})]})})}function eY(e){let{profile:s,loading:a}=e,{t:n}=(0,g.Bd)(),r=(0,eT.b9)();if(a)return(0,t.jsxs)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:[(0,t.jsxs)(b.aR,{className:"border-b p-3 !pb-3 sm:p-5 sm:!pb-5",children:[(0,t.jsx)(N.E,{className:"h-6 w-32"}),(0,t.jsx)(N.E,{className:"mt-2 h-4 w-48"})]}),(0,t.jsx)(b.Wu,{className:"space-y-3 p-3 sm:p-5",children:["password","token","delete"].map(e=>(0,t.jsx)(N.E,{className:"h-16 w-full"},e))})]});if(!s)return null;let i=[{icon:eE.A,title:n("Change Password"),description:n("Update your password to keep your account secure"),action:()=>r.open("password"),variant:"default"},{icon:eP.A,title:n("Access Token"),description:n("Generate and manage your API access token"),action:()=>r.open("token"),variant:"default"},{icon:eB.A,title:n("Delete Account"),description:n("Permanently delete your account and all data"),action:()=>r.open("delete"),variant:"destructive"}];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(V.f,{title:n("Security"),description:n("Manage your security settings and account access"),icon:(0,t.jsx)(eE.A,{className:"h-4 w-4"}),iconTone:"success",disableHoverEffect:!0,children:(0,t.jsx)("div",{className:"grid grid-cols-1 gap-2.5 sm:gap-3 md:grid-cols-3",children:i.map(e=>(0,t.jsxs)("button",{type:"button",onClick:e.action,className:`flex items-center gap-3 rounded-lg border p-3 text-left md:flex-col md:gap-2 md:p-4 md:text-center ${"destructive"===e.variant?"border-destructive/30":""}`,children:[(0,t.jsx)(w.f,{tone:"neutral",size:"sm",children:(0,t.jsx)(e.icon,{})}),(0,t.jsxs)("div",{className:"min-w-0 md:contents",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:e.title}),(0,t.jsx)("p",{className:"text-muted-foreground line-clamp-1 text-xs md:line-clamp-none",children:e.description})]})]},e.title))})}),(0,t.jsx)(eH,{open:r.isOpen("password"),onOpenChange:e=>e?r.open("password"):r.close("password"),username:s.username}),(0,t.jsx)(eW,{open:r.isOpen("token"),onOpenChange:e=>e?r.open("token"):r.close("token")}),(0,t.jsx)(eZ,{open:r.isOpen("delete"),onOpenChange:e=>e?r.open("delete"):r.close("delete"),username:s.username})]})}var eG=a(26197),eV=a(59735),eK=a(56920),eQ=a(20103),eX=a(38384),e0=a(57335),e1=a(6433),e2=a(58616),e4=a(12370),e5=a(29607),e3=a(47697),e6=a(41804);function e8(e){let{open:s,onOpenChange:a,currentEmail:n,onSuccess:r}=e,{t:i}=(0,g.Bd)(),[l,o]=(0,p.useState)(!1),[c,d]=(0,p.useState)(!1),[u,m]=(0,p.useState)(""),[h,x]=(0,p.useState)(""),{secondsLeft:y,isActive:b,start:w,reset:N}=(0,e6.L)({initialSeconds:60}),k=async()=>
1{if(!u||!u.includes("@"))return void f.oR.error(i("Please enter a valid email address"));try{d(!0);let e=await $(u);e.success?(f.oR.success(i("Verification code sent! Please check your email.")),w()):f.oR.error(e.message||i("Failed to send verification code"))}catch(e){f.oR.error(i("Failed to send verification code"))}finally{d(!1)}},C=async()=>{if(!u||!h)return void f.oR.error(i("Please enter email and verification code"));try{o(!0);let e=await O(u,h);e.success?(f.oR.success(i("Email bound successfully!")),a(!1),r(),m(""),x(""),N()):f.oR.error(e.message||i("Failed to bind email"))}catch(e){f.oR.error(i("Failed to bind email"))}finally{o(!1)}},_=e=>{!l&&(a(e),e||(m(""),x(""),N()))};return(0,t.jsx)(j.l,{open:s,onOpenChange:_,title:i("Bind Email"),description:n?i("Current email: {{email}}. Enter a new email to change.",{email:n}):i("Bind an email address to your account."),contentClassName:"sm:max-w-md",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(v.$,{type:"button",variant:"outline",onClick:()=>_(!1),disabled:l,children:i("Cancel")}),(0,t.jsxs)(v.$,{type:"button",onClick:C,disabled:l||!u||!h,children:[l&&(0,t.jsx)(Y.A,{className:"mr-2 h-4 w-4 animate-spin"}),l?i("Binding..."):i("Bind Email")]})]}),children:(0,t.jsxs)("div",{className:"space-y-4 py-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eD.J,{htmlFor:"email",children:i("Email Address")}),(0,t.jsx)(ez.p,{id:"email",type:"email",value:u,onChange:e=>m(e.target.value),placeholder:i("Enter your email"),disabled:l})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eD.J,{htmlFor:"code",children:i("Verification Code")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(ez.p,{id:"code",value:h,onChange:e=>x(e.target.value),placeholder:i("Enter code"),disabled:l,maxLength:6}),(0,t.jsx)(v.$,{type:"button",variant:"outline",onClick:k,disabled:c||b||!u,children:b?`${y}s`:c?i("Sending..."):i("Send")})]})]})]})})}var e7=a(46006);function e9(e){let{open:s,onOpenChange:a,botName:n,onSuccess:r}=e,{t:i}=(0,g.Bd)(),l=(0,p.useRef)(null),[o,c]=(0,p.useState)(null),[d,u]=(0,p.useState)(null),[m,h]=(0,p.useState)(!1),[x,y]=(0,p.useState)(null),b=(0,p.useCallback)(async()=>{h(!0),y(null);try{let e=await D();if(!e.success||!e.data?.callback_url)throw Error(e.message||i("Failed to start Telegram binding"));u(e.data.flow_token),c(new URL(e.data.callback_url,window.location.origin).toString())}catch(e){y(e instanceof Error?e.message:i("Failed to start Telegram binding"))}finally{h(!1)}},[i]);return(0,p.useEffect)(()=>{if(!s){c(null),u(null),y(null);return}b()},[b,s]),(0,p.useEffect)(()=>{if(!s||!d)return;let e=e=>{if(e.origin!==window.location.origin)return;let s=e.data;if(s&&s.type===e4.oP&&s.flow_token===d){if(!s.success)return void y(i((0,e7.I)({code:s.code})||"Telegram binding failed. Please try again."));f.oR.success(i("Binding successful!")),r(),a(!1)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[d,a,r,s,i]),(0,p.useEffect)(()=>{let e=l.current;if(!e||!o)return;e.replaceChildren();let s=document.createElement("script");return s.async=!0,s.src="https://telegram.org/js/telegram-widget.js?22",s.setAttribute("data-telegram-login",n.replace(/^@/,"")),s.setAttribute("data-size","large"),s.setAttribute("data-auth-url",o),s.setAttribute("data-request-access","write"),e.appendChild(s),()=>e.replaceChildren()},[n,o]),(0,t.jsx)(j.l,{open:s,onOpenChange:a,title:i("Bind Telegram Account"),description:i("Click the button below to bind your Telegram account"),contentClassName:"sm:max-w-md",contentHeight:"auto",bodyClassName:"space-y-4",children:(0,t.jsxs)("div",{className:"space-y-4 py-4",children:[(0,t.jsxs)(eI.Fc,{children:[(0,t.jsx)(eX.A,{className:"h-4 w-4"}),(0,t.jsx)(eI.TN,{children:i("You will be redirected to Telegram to complete the binding process.")})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 roun
1ded-lg border p-6",children:[(0,t.jsx)("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-blue-100 dark:bg-blue-900",children:(0,t.jsx)(eX.A,{className:"h-6 w-6 text-blue-600 dark:text-blue-400"})}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsxs)("p",{className:"text-muted-foreground text-sm",children:[i("Bot:")," ",(0,t.jsxs)("span",{className:"font-mono font-semibold",children:["@",n]})]}),(0,t.jsx)("p",{className:"text-muted-foreground mt-1 text-xs",children:i("After clicking the button, you'll be asked to authorize the bot")})]}),m&&(0,t.jsx)(N.E,{className:"h-10 w-52"}),x&&(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,t.jsx)("p",{className:"text-destructive text-sm",children:x}),(0,t.jsx)(v.$,{type:"button",variant:"outline",onClick:b,children:i("Retry")})]}),(0,t.jsx)("div",{ref:l,className:"flex min-h-10 justify-center"})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-center text-xs",children:i("The binding will complete automatically after authorization")})]})})}var se=a(90358),ss=a(81825);function sa(e){let{t:s}=(0,g.Bd)(),[a,n]=(0,p.useState)(""),[r,i]=(0,p.useState)(!1),l=s=>{r||(s||n(""),e.onOpenChange(s))},o=async t=>{t.preventDefault();let l=a.trim();if(l&&!r){i(!0);try{if(!(await z(l)).success)return void f.oR.error(s("Request failed"));f.oR.success(s("Binding successful!")),n(""),e.onOpenChange(!1),e.onSuccess()}catch{f.oR.error(s("Request failed"))}finally{i(!1)}}};return(0,t.jsx)(j.l,{open:e.open,onOpenChange:l,title:s("Bind WeChat Account"),description:s("Scan the QR code to follow the official account and reply with “验证码” to receive your verification code."),contentClassName:"max-w-sm",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(v.$,{type:"button",variant:"outline",disabled:r,onClick:()=>l(!1),children:s("Cancel")}),(0,t.jsxs)(v.$,{type:"submit",form:"wechat-bind-form",disabled:r||!a.trim(),children:[r&&(0,t.jsx)(ss.y,{"data-icon":"inline-start"}),s("Bind")]})]}),children:(0,t.jsx)("form",{id:"wechat-bind-form",onSubmit:o,children:(0,t.jsxs)(se.M_,{children:[e.qrCodeUrl?(0,t.jsx)("div",{className:"flex justify-center",children:(0,t.jsx)("img",{src:e.qrCodeUrl,alt:s("WeChat login QR code"),className:"size-48 rounded-lg border object-contain"})}):(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:s("QR code is not configured. Please contact support.")}),(0,t.jsxs)(se.D0,{"data-disabled":r,children:[(0,t.jsx)(se.dh,{htmlFor:"wechat-bind-code",children:s("Verification code")}),(0,t.jsx)(ez.p,{id:"wechat-bind-code",value:a,onChange:e=>n(e.target.value),placeholder:s("Enter the verification code"),autoComplete:"one-time-code",disabled:r,autoFocus:!0})]})]})})})}function st(e){let{profile:s,onUpdate:a}=e,{t:n}=(0,g.Bd)(),r=(0,eT.b9)(),{status:l,loading:o}=(0,i.s)(),[c,d]=(0,p.useState)([]),[u,m]=(0,p.useState)(null),[h,x]=(0,p.useState)(!1),j=(0,p.useRef)(null),y=(0,p.useCallback)(e=>{let s=j.current;s&&(!e||s===e)&&(s.stopCloseWatcher(),j.current=null)},[]),b=l?.custom_oauth_providers,w=(0,p.useCallback)(async()=>{if(b&&0!==b.length)try{let e=await W();e.success&&e.data&&d(e.data)}catch{}},[b]);(0,p.useEffect)(()=>{w()},[w]);let N=async()=>{if(u){x(!0);try{let e=await q(u.provider_id);e.success?(f.oR.success(n("Unbound {{provider}}",{provider:u.provider_name})),await w(),a()):f.oR.error(e.message||n("Unbind failed"))}catch{f.oR.error(n("Unbind failed"))}finally{x(!1),m(null)}}},k=(0,p.useCallback)(async(e,s)=>{let a=j.current;a&&(y(a),a.popup.closed||a.popup.close());let t=window.open("","_blank");if(!t)return void f.oR.error(n("OAuth pop-up was blocked"));let r={provider:e,state:"",popup:t,stopCloseWatcher:()=>void 0};r.stopCloseWatcher=(0,e5.HK)(t,()=>y(r)),j.current=r;try{let a=await (0,eJ.uK)(e,"bind");if(j.current!==r||t.closed)return;r.state=a,t.location.replace(s(a))}catch{let e=j.current===r;y(r),t.close(),e&&f.oR.error(n("Failed to initialize OAuth"))}},[y,n]),C=async e=>{await k(e.slug,s=>{let a=`${window.location.origin}/oauth/${e.slug}
1`,t=new URL(e.authorization_endpoint);return t.searchParams.set("client_id",e.client_id),t.searchParams.set("redirect_uri",a),t.searchParams.set("response_type","code"),t.searchParams.set("state",s),e.scopes&&t.searchParams.set("scope",e.scopes),t.toString()})};(0,p.useEffect)(()=>{if("u"<typeof window)return;let e=async e=>{if(e.origin!==window.location.origin)return;let s=e.data,t=j.current;if(!s||s.type!==e4.eK||!t||s.provider!==t.provider||s.state!==t.state||e.source!==t.popup)return;y(t);let r=!1,i=n("OAuth failed");try{if(!s.code&&!s.error)throw Error(n("Missing code"));let e={state:s.state};s.code&&(e.code=s.code),s.error&&(e.error=s.error),s.errorDescription&&(e.error_description=s.errorDescription);let t=await S.FH.get(`/api/oauth/${s.provider}`,{params:e,skipBusinessError:!0});r=!!t.data?.success,i=t.data?.message||i,r?(f.oR.success(n("Binding successful!")),a(),await w()):f.oR.error(i)}catch(e){i=e.response?.data?.message||(e instanceof Error?e.message:i),f.oR.error(i)}t.popup.postMessage({type:e4.qr,provider:s.provider,state:s.state,success:r,message:i},window.location.origin)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[y,w,a,n]),(0,p.useEffect)(()=>()=>{let e=j.current;y(e??void 0),e&&!e.popup.closed&&e.popup.close()},[y]);let _=(0,p.useMemo)(()=>s&&l?[{id:"email",label:n("Email"),icon:eQ.A,value:s.email,isBound:!!s.email,isEnabled:!0,onBind:()=>r.open("email")},{id:"wechat",label:n("WeChat"),icon:e1.SiWechat,value:void 0,isBound:!!s.wechat_id,isEnabled:l?.wechat_login||!1,onBind:()=>r.open("wechat")},{id:"github",label:n("GitHub"),icon:e1.SiGithub,value:s.github_id,isBound:!!s.github_id,isEnabled:l?.github_oauth||!1,onBind:()=>{let e=l?.github_client_id;e&&k("github",s=>(0,e3.e_)(e,s))}},{id:"discord",label:n("Discord"),icon:e2.us,value:s.discord_id,isBound:!!s.discord_id,isEnabled:l?.discord_oauth||!1,onBind:()=>{let e=l?.discord_client_id;e&&k("discord",s=>(0,e3.Nc)(e,s))}},{id:"oidc",label:n("OIDC"),icon:eE.A,value:s.oidc_id,isBound:!!s.oidc_id,isEnabled:l?.oidc_enabled||!1,onBind:()=>{let e=l?.oidc_authorization_endpoint,s=l?.oidc_client_id;e&&s&&k("oidc",a=>(0,e3.km)(e,s,a))}},{id:"telegram",label:n("Telegram"),icon:eX.A,value:s.telegram_id,isBound:!!s.telegram_id,isEnabled:l?.telegram_oauth||!1,onBind:()=>r.open("telegram")},{id:"linuxdo",label:n("LinuxDO"),icon:e1.SiLinux,value:s.linux_do_id,isBound:!!s.linux_do_id,isEnabled:l?.linuxdo_oauth||!1,onBind:()=>{let e=l?.linuxdo_client_id;e&&k("linuxdo",s=>(0,e3.yp)(e,s))}}].filter(e=>e.isEnabled):[],[s,l,n]);return!s||o?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2 sm:gap-3",children:_.map(e=>{let s=n("Bind");return e.isBound&&"email"===e.id?s=n("Change"):e.isBound&&(s=n("Bound")),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2.5 rounded-lg border p-2.5 sm:gap-3 sm:p-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5 sm:gap-3",children:[(0,t.jsx)("div",{className:"bg-muted shrink-0 rounded-md p-1.5 sm:p-2",children:(0,t.jsx)(e.icon,{className:"h-4 w-4"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:e.label}),e.isBound&&(0,t.jsx)(ej.Wh,{label:n("Bound"),variant:"success",copyable:!1})]}),(0,t.jsx)("p",{className:"text-muted-foreground truncate text-xs",children:e.value||n("Not bound")})]})]}),(0,t.jsx)(v.$,{variant:"outline",size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:e.onBind,disabled:e.isBound&&"email"!==e.id,children:s})]},e.id)})}),b&&b.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(el.w,{className:"my-4"}),(0,t.jsx)("p",{className:"text-muted-foreground mb-3 text-sm font-medium",children:n("Custom OAuth")}),(0,t.jsx)("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2 sm:gap-3",children:b.map(e=>{let s=c.find(s=>s.provider_id===String(e.id)),a=!!s;return(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2.5 rounded-lg border p-2.5 sm:gap-3 sm:p-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5 sm:gap-3",children:[(0,t.jsx)("div",{className:"bg-muted shrink-0 rounded-md p-1.5 sm:p-2",children:(0,t.jsx)(eV.A,{className:"h-4 w-4"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:e.name}),a&&(0,t.jsx)(ej.Wh,{label:n("Bound"),variant:"success",copyable:!1})]}),(0,t.jsx)("p",{className:"text-muted-foreground truncate text-xs",children:a?s?.external_id||n("Bound"):n("Not bound")})]})]}),a?(0,t.jsxs)(v.$,{variant:"ghost",size:"sm",className:"text-destructive h-7 shrink-0 px-2.5 text-xs",onClick:()=>m(s),children:[(0,t.jsx)(e0.A,{className:"mr-1 h-3 w-3"}),n("Unbind")]}):(0,t.jsx)(v.$,{variant:"outline",size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:()=>C(e),children:n("Bind")})]},e.id)})})]}),(0,t.jsx)(eo.T,{open:!!u,onOpenChange:e=>!e&&m(null),title:n("Confirm Unbind"),desc:n("Are you sure you want to unbind {{provider}}? You will no longer be able to log in via this method.",{provider:u?.provider_name||""}),confirmText:n("Confirm Unbind"),destructive:!0,handleConfirm:N,isLoading:h}),(0,t.jsx)(e8,{open:r.isOpen("email"),onOpenChange:e=>e?r.open("email"):r.close("email"),currentEmail:s.email,onSuccess:a}),(0,t.jsx)(sa,{open:r.isOpen("wechat"),qrCodeUrl:"string"==typeof l?.wechat_qrcode?l.wechat_qrcode:"",onOpenChange:e=>e?r.open("wechat"):r.close("wechat"),onSuccess:a}),l?.telegram_bot_name&&(0,t.jsx)(e9,{open:r.isOpen("telegram"),onOpenChange:e=>e?r.open("telegram"):r.close("telegram"),botName:l.telegram_bot_name,onSuccess:a})]})}var sn=a(66929),sr=a(83273),si=a(95227),sl=a(87212),so=a(63235),sc=a(79596),sd=a(19784);let su=p.createContext({size:"default",variant:"default",spacing:0,orientation:"horizontal"});function sm(e){let{className:s,variant:a,size:n,spacing:r=0,orientation:i="horizontal",children:l,...o}=e;return(0,t.jsx)(sc.O,{"data-slot":"toggle-group","data-variant":a,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:(0,F.cn)("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-vertical:flex-col data-vertical:items-stretch data-[size=sm]:rounded-md",s),...o,children:(0,t.jsx)(su.Provider,{value:{variant:a,size:n,spacing:r,orientation:i},children:l})})}function sh(e){let{className:s,children:a,variant:n="default",size:r="default",...i}=e,l=p.useContext(su);return(0,t.jsx)(so.l,{"data-slot":"toggle-group-item","data-variant":l.variant||n,"data-size":l.size||r,"data-spacing":l.spacing,className:(0,F.cn)("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",(0,sd.v)({variant:l.variant||n,size:l.size||r}),s),...i,children:a})}let sx=[{value:"email",label:"Email"},{value:"webhook",label:"Webhook"},{value:"bark",label:"Bark"},{value:"gotify",label:"Gotify"}],sp={email:eQ.A,webhook:sn.A,bark:sr.A,gotify:si.A},sg=new Set(sx.map(e=>e.value));function sf(e){return"string"==typeof e&&sg.has(e)?e:"email"}function sj(e){let{profile:s,onUpdate:a}=e,{t:n}=(0,g.Bd)(),r=(s?.role??0)>=eA.z7.ADMIN,[i,l]=(0,p.useState)(!1),[o,c]=(0,p.useState)({notify_type:"email",quota_
1warning_threshold:5e5,notification_email:"",webhook_url:"",webhook_secret:"",bark_url:"",gotify_url:"",gotify_token:"",gotify_priority:5,accept_unset_model_ratio_model:!1,record_ip_log:!1,upstream_model_update_notify_enabled:!1}),d=(0,p.useCallback)((e,s)=>{c(a=>({...a,[e]:s}))},[]);(0,p.useEffect)(()=>{if(s?.setting){let e=Q(s.setting);c({notify_type:sf(e.notify_type),quota_warning_threshold:e.quota_warning_threshold??5e5,notification_email:e.notification_email??"",webhook_url:e.webhook_url??"",webhook_secret:e.webhook_secret??"",bark_url:e.bark_url??"",gotify_url:e.gotify_url??"",gotify_token:e.gotify_token??"",gotify_priority:e.gotify_priority??5,accept_unset_model_ratio_model:e.accept_unset_model_ratio_model||!1,record_ip_log:e.record_ip_log||!1,upstream_model_update_notify_enabled:e.upstream_model_update_notify_enabled||!1})}},[s]);let u=async()=>{try{l(!0);let e=await E(o);e.success?(f.oR.success(n("Settings updated successfully")),a()):f.oR.error(e.message||n("Failed to update settings"))}catch(e){f.oR.error(n("Failed to update settings"))}finally{l(!1)}},m=sf(o.notify_type);return(0,t.jsxs)("div",{className:"space-y-4 sm:space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2.5",children:[(0,t.jsx)(eD.J,{children:n("Notification Method")}),(0,t.jsx)(sm,{value:[m],onValueChange:e=>{let s=e.find(e=>e!==m);s&&d("notify_type",sf(s))},"aria-label":n("Notification Method"),variant:"outline",size:"lg",spacing:2,className:"grid w-full grid-cols-2 gap-2 sm:grid-cols-4 sm:gap-3",children:sx.map(e=>{let s=sp[e.value];return(0,t.jsxs)(sh,{value:e.value,className:"h-auto min-h-14 w-full flex-col gap-1.5 px-3 py-3 sm:min-h-16",children:[(0,t.jsx)(s,{className:"h-4 w-4 sm:h-5 sm:w-5"}),(0,t.jsx)("span",{className:"max-w-full truncate text-xs font-medium sm:text-sm",children:n(e.label)})]},e.value)})})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(eD.J,{htmlFor:"threshold",children:n("Quota Warning Threshold")}),(0,t.jsx)(ez.p,{id:"threshold",type:"number",className:"h-9",value:o.quota_warning_threshold,onChange:e=>d("quota_warning_threshold",Number(e.target.value)),placeholder:n("Enter threshold")}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:n("Get notified when balance falls below this value")})]}),"email"===m&&(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(eD.J,{htmlFor:"notifyEmail",children:n("Notification Email")}),(0,t.jsx)(ez.p,{id:"notifyEmail",type:"email",className:"h-9",value:o.notification_email,onChange:e=>d("notification_email",e.target.value),placeholder:n("Leave empty to use account email")})]}),"webhook"===m&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(eD.J,{htmlFor:"webhookUrl",children:n("Webhook URL")}),(0,t.jsx)(ez.p,{id:"webhookUrl",type:"url",className:"h-9",value:o.webhook_url,onChange:e=>d("webhook_url",e.target.value),placeholder:n("https://example.com/webhook")})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(eD.J,{htmlFor:"webhookSecret",children:n("Webhook Secret")}),(0,t.jsx)(eq.y,{id:"webhookSecret",value:o.webhook_secret,onChange:e=>d("webhook_secret",e.target.value),placeholder:n("Enter secret key")})]})]}),"bark"===m&&(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(eD.J,{htmlFor:"barkUrl",children:n("Bark Push URL")}),(0,t.jsx)(ez.p,{id:"barkUrl",type:"url",className:"h-9",value:o.bark_url,onChange:e=>d("bark_url",e.target.value),placeholder:n("https://api.day.app/yourkey/{{title}}/{{content}}")}),(0,t.jsxs)("p",{className:"text-muted-foreground text-xs",children:[n("Template variables:")," ","{{title}}",", ","{{content}}"]})]}),"gotify"===m&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(eD.J,{htmlFor:"gotifyUrl",children:n("Gotify Server URL")}),(0,t.jsx)(ez.p,{id:"gotifyUrl",type:"url",className:"h-9",value:o.gotify_url,onChange:e=>d("gotify_url",e.target.value),placeholder:n("https://gotify.example.com")}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:n("Enter the full URL of your Gotify server")})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(eD.J,{htmlFor:"gotifyToken",children:n("Gotify Application Token")}),(0,t.jsx)(eq.y,{id:"gotifyToken",value:o.gotify_token,onChange:e=>d("gotify_token",e.target.value),placeholder:n("Enter application token")}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:n("Token obtained from your Gotify application")})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(eD.J,{htmlFor:"gotifyPriority",children:n("Message Priority")}),(0,t.jsx)(ez.p,{id:"gotifyPriority",type:"number",className:"h-9",min:"0",max:"10",value:o.gotify_priority,onChange:e=>d("gotify_priority",Number(e.target.value)),placeholder:"5"}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:n("Priority level from 0 (lowest) to 10 (highest), default is 5")})]}),(0,t.jsxs)("div",{className:"bg-muted/50 rounded-lg border p-3 sm:p-4",children:[(0,t.jsx)("h5",{className:"mb-1.5 text-sm font-medium sm:mb-2",children:n("Setup Instru
1ctions")}),(0,t.jsxs)("ol",{className:"text-muted-foreground space-y-1 text-xs",children:[(0,t.jsx)("li",{children:n("1. Create an application in your Gotify server")}),(0,t.jsx)("li",{children:n("2. Copy the application token")}),(0,t.jsx)("li",{children:n("3. Enter your Gotify server URL and token above")})]}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-3 text-xs",children:[n("Learn more:")," ",(0,t.jsx)("a",{href:"https://gotify.net/",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline underline-offset-4",children:n("Gotify Documentation")})]})]})]}),(0,t.jsx)("div",{className:"border-t"}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:n("Preferences")}),(0,t.jsx)("p",{className:"text-muted-foreground mt-1 text-xs",children:n("Configure your account behavior preferences")})]}),r&&(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3 rounded-lg border p-3 sm:items-center sm:p-4",children:[(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)(eD.J,{htmlFor:"upstreamModelUpdateNotify",children:n("Receive Upstream Model Update Notifications")}),(0,t.jsx)("p",{className:"text-muted-foreground line-clamp-3 text-xs sm:line-clamp-none sm:text-sm",children:n("Only available for admins. When enabled, you will receive a summary notification via your selected method when the scheduled model check detects upstream model changes or check failures.")})]}),(0,t.jsx)(sl.d,{id:"upstreamModelUpdateNotify",className:"shrink-0",checked:o.upstream_model_update_notify_enabled,onCheckedChange:e=>d("upstream_model_update_notify_enabled",e)})]}),(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3 rounded-lg border p-3 sm:items-center sm:p-4",children:[(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)(eD.J,{htmlFor:"acceptUnsetPrice",children:n("Accept Unpriced Models")}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs sm:text-sm",children:n("Allow using models without price configuration")})]}),(0,t.jsx)(sl.d,{id:"acceptUnsetPrice",className:"shrink-0",checked:o.accept_unset_model_ratio_model,onCheckedChange:e=>d("accept_unset_model_ratio_model",e)})]}),(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3 rounded-lg border p-3 sm:items-center sm:p-4",children:[(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)(eD.J,{htmlFor:"recordIp",children:n("Record IP Address")}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs sm:text-sm",children:n("Log IP address for usage and error logs")})]}),(0,t.jsx)(sl.d,{id:"recordIp",className:"shrink-0",checked:o.record_ip_log,onCheckedChange:e=>d("record_ip_log",e)})]})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsxs)(v.$,{onClick:u,disabled:i,children:[i&&(0,t.jsx)(Y.A,{className:"mr-2 h-4 w-4 animate-spin"}),i?n("Saving..."):n("Save Settings")]})})]})}function sy(e){let{profile:s,loading:a,onProfileUpdate:n}=e,{t:r}=(0,g.Bd)(),[i,l]=(0,p.useState)("bindings");return a?(0,t.jsxs)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:[(0,t.jsxs)(b.aR,{className:"border-b p-3 !pb-3 sm:p-5 sm:!pb-5",children:[(0,t.jsx)(N.E,{className:"h-6 w-32"}),(0,t.jsx)(N.E,{className:"mt-2 h-4 w-48"})]}),(0,t.jsxs)(b.Wu,{className:"space-y-4 p-3 sm:p-5",children:[(0,t.jsx)(N.E,{className:"h-10 w-full"}),["bindings","preferences","notifications"].map(e=>(0,t.jsx)(N.E,{className:"h-20 w-full"},e))]})]}):(0,t.jsx)(V.f,{title:r("Settings"),description:r("Configure your account preferences and integrations"),icon:(0,t.jsx)(eG.A,{className:"h-4 w-4"}),iconTone:"info",disableHoverEffect:!0,children:(0,t.jsxs)(eK.tU,{value:i,onValueChange:l,children:[(0,t.jsxs)(eK.j7,{className:"grid w-full grid-cols-2 items-stretch gap-1 rounded-xl p-1 group-data-horizontal/tabs:h-10",children:[(0,t.jsxs)(eK.Xi,{value:"bindings",className:"h-full gap-2 rounded-lg px-3 py-0 leading-none",children:[(0,t.jsx)(eV.A,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:r("Account Bindings")}),(0,t.jsx)("span",{className:"sm:hidden",children:r("Bindings")})]}),(0,t.jsxs)(eK.Xi,{value:"settings",className:"h-full gap-2 rounded-lg px-3 py-0 leading-none",children:[(0,t.jsx)(eG.A,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:r("Settings & Preferences")}),(0,t.jsx)("span",{className:"sm:hidden",children:r("Settings")})]})]}),(0,t.jsx)(eK.av,{value:"bindings",className:"mt-4 sm:mt-6",children:(0,t.jsx)(st,{profile:s,onUpdate:n})}),(0,t.jsx)(eK.av,{value:"settings",className:"mt-4 sm:mt-6",children:(0,t.jsx)(sj,{profile:s,onUpdate:n})})]})})}var sv=a(97367);
1function sb(){let{t:e}=(0,g.Bd)(),[s,a]=(0,p.useState)(!1),[n,r]=(0,p.useState)({}),i=(0,l.n)(e=>e.auth.user),o=(0,l.n)(e=>e.auth.setUser),c=[{key:"chat",title:e("Chat Area"),description:e("Playground and chat functions"),modules:[{key:"playground",title:e("Playground"),description:e("AI model testing environment")},{key:"chat",title:e("Chat"),description:e("Chat session management")}]},{key:"console",title:e("Console Area"),description:e("Data management and log viewing"),modules:[{key:"detail",title:e("Dashboard"),description:e("System data statistics")},{key:"token",title:e("Token Management"),description:e("API token management")},{key:"log",title:e("Usage Logs"),description:e("API usage records")},{key:"midjourney",title:e("Drawing Logs"),description:e("Drawing task records")},{key:"task",title:e("Task Logs"),description:e("System task records")}]},{key:"personal",title:e("Personal Center Area"),description:e("User personal functions"),modules:[{key:"topup",title:e("Wallet Management"),description:e("Balance and top-up management")},{key:"personal",title:e("Personal Settings"),description:e("Personal info settings")}]}],d=(0,p.useCallback)(async()=>{try{let e=await S.FH.get("/api/user/self");if(e.data.success&&e.data.data?.sidebar_modules){let s=e.data.data.sidebar_modules,a="string"==typeof s?JSON.parse(s):s;r(a)}else{let e={};for(let s of c)for(let a of(e[s.key]={enabled:!0},s.modules))e[s.key][a.key]=!0;r(e)}}catch{}},[]);(0,p.useEffect)(()=>{d()},[d]);let u=async()=>{a(!0);try{let s=JSON.stringify(n),a=await S.FH.put("/api/user/self",{sidebar_modules:s});a.data.success?(i&&o({...i,sidebar_modules:s}),f.oR.success(e("Saved successfully"))):f.oR.error(a.data.message||e("Save failed"))}catch{f.oR.error(e("Save failed, please retry"))}finally{a(!1)}};return(0,t.jsxs)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:[(0,t.jsx)(b.aR,{className:"border-b p-3 !pb-3 sm:p-5 sm:!pb-5",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(w.f,{tone:"info",size:"title",children:(0,t.jsx)(sv.A,{})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)(b.ZB,{className:"text-lg tracking-tight sm:text-xl",children:e("Sidebar Personal Settings")}),(0,t.jsx)(b.BT,{className:"text-xs sm:text-sm",children:e("Customize sidebar display content")})]})]})}),(0,t.jsxs)(b.Wu,{className:"space-y-4 p-3 sm:space-y-5 sm:p-5",children:[c.map(e=>{let s=n[e.key]?.enabled!==!1;return(0,t.jsxs)("div",{className:"bg-background/60 rounded-xl border p-3",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:e.title}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:e.description})]}),(0,t.jsx)(sl.d,{checked:s,onCheckedChange:s=>{var a;return a=e.key,void r(e=>({...e,[a]:{...e[a],enabled:s}}))}})]}),(0,t.jsx)("div",{className:"mt-3 grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-1",children:e.modules.map(a=>(0,t.jsxs)("div",{className:`flex min-h-16 items-center justify-between rounded-lg border p-3 ${s?"":"opacity-50"}`,children:[(0,t.jsxs)("div",{className:"mr-2 min-w-0",children:[(0,t.jsx)("p",{className:"truncate text-sm font-medium",children:a.title}),(0,t.jsx)("p",{className:"text-muted-foreground truncate text-xs",children:a.description})]}),(0,t.jsx)(sl.d,{checked:n[e.key]?.[a.key]!==!1,onCheckedChange:s=>{var t,n;return t=e.key,n=a.key,void r(e=>({...e,[t]:{...e[t],[n]:s}}))},disabled:!s})]},a.key))})]},e.key)}),(0,t.jsxs)("div",{className:"flex flex-col-reverse gap-2 border-t pt-4 sm:flex-row sm:justify-end",children:[(0,t.jsx)(v.$,{variant:"outline",onClick:()=>{let s={};for(let e of c)for(let a of(s[e.key]={enabled:!0},e.modules))s[e.key][a.key]=!0;r(s),f.oR.success(e("Reset to default configuration"))},children:e("Reset to Default")}),(0,t.jsx)(v.$,{onClick:u,disabled:s,children:s?e("Saving..."):e("Save Changes")})]})]})]})}function sw(e){let{open:s,onOpenChange:a,onSuccess:n}=e,{t:r}=(0,g.Bd)(),[i,l]=(0,p.useState)(!1),[o,c]=(0,p.useState)(""),[d,u]=(0,p.useState)([]),m=async()=>
1{if(!o)return void f.oR.error(r("Please enter your verification code"));try{l(!0);let e=await (0,S.Ac)(o);e.success&&e.data?.backup_codes?(u(e.data.backup_codes),f.oR.success(r("Backup codes regenerated successfully"))):f.oR.error(e.message||r("Failed to regenerate backup codes"))}catch(e){f.oR.error(r("Failed to regenerate backup codes"))}finally{l(!1)}},h=e=>{i||(e||(c(""),u([])),a(e))};return(0,t.jsx)(j.l,{open:s,onOpenChange:h,title:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e$.A,{className:"h-5 w-5"}),r("Regenerate Backup Codes")]}),description:d.length>0?r("Your new backup codes are ready"):r("Generate new backup codes for account recovery"),contentClassName:"sm:max-w-md",titleClassName:"flex items-center gap-2",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,t.jsx)(t.Fragment,{children:0===d.length?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(v.$,{variant:"outline",onClick:()=>h(!1),disabled:i,children:r("Cancel")}),(0,t.jsxs)(v.$,{onClick:m,disabled:i||!o,children:[i&&(0,t.jsx)(Y.A,{className:"mr-2 h-4 w-4 animate-spin"}),i?r("Generating..."):r("Generate New Codes")]})]}):(0,t.jsx)(v.$,{onClick:()=>{h(!1),n()},children:r("Done")})}),children:(0,t.jsx)("div",{className:"space-y-4 py-4",children:0===d.length?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eI.Fc,{children:(0,t.jsx)(eI.TN,{children:r("Generating new codes will invalidate all existing backup codes.")})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eD.J,{htmlFor:"code",children:r("Verification Code")}),(0,t.jsx)(ez.p,{id:"code",value:o,onChange:e=>c(e.target.value),placeholder:r("Enter authenticator code"),maxLength:6,disabled:i})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eI.Fc,{children:(0,t.jsx)(eI.TN,{children:r("Save these codes in a safe place. Each code can only be used once.")})}),(0,t.jsx)("div",{className:"rounded-lg border p-4",children:(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2",children:d.map((e,s)=>(0,t.jsx)("div",{className:"bg-muted rounded-md p-2 text-center font-mono text-sm",children:e},s))})}),(0,t.jsx)(eO.i,{value:d.join("\n"),variant:"outline",size:"default",className:"w-full",iconClassName:"mr-2 size-4",tooltip:r("Copy all backup codes"),"aria-label":r("Copy all backup codes"),children:r("Copy All Codes")})]})})})}var sN=a(82655);function sk(e){let{open:s,onOpenChange:a,onSuccess:n}=e,{t:r}=(0,g.Bd)(),[i,l]=(0,p.useState)(!1),[o,c]=(0,p.useState)(""),[d,u]=(0,p.useState)(!1),m=async()=>{if(!o)return void f.oR.error(r("Please enter your verification code or backup code"));if(!d)return void f.oR.error(r("Please confirm that you understand the consequences"));try{l(!0);let e=await (0,S.m7)(o);e.success?(f.oR.success(r("Two-factor authentication disabled")),a(!1),n(),c(""),u(!1)):f.oR.error(e.message||r("Failed to disable 2FA"))}catch(e){f.oR.error(r("Failed to disable 2FA"))}finally{l(!1)}},h=e=>{i||(e||(c(""),u(!1)),a(e))};return(0,t.jsx)(j.l,{open:s,onOpenChange:h,title:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eg.A,{className:"h-5 w-5"}),r("Disable Two-Factor Authentication")]}),description:r("This action will permanently remove 2FA protection from your account."),contentClassName:"sm:max-w-md",titleClassName:"text-destructive flex items-center gap-2",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(v.$,{variant:"outline",onClick:()=>h(!1),disabled:i,children:r("Cancel")}),(0,t.jsxs)(v.$,{variant:"destructive",onClick:m,disabled:i||!o||!d,children:[i&&(0,t.jsx)(Y.A,{className:"mr-2 h-4 w-4 animate-spin"}),i?r("Disabling..."):r("Disable 2FA")]})]}),children:(0,t.jsxs)("div",{className:"space-y-4 py-4",children:[(0,t.jsxs)(eI.Fc,{variant:"destructive",children:[(0,t.jsx)(eg.A,{className:"h-4 w-4"}),(0,t.jsx)(eI.TN,{children:r("Warning: Disabling 2FA will make your account less secure.")})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eD.J,{htmlFor:"code",children:r("Verification Code")}),(0,t.jsx)(ez.p,{id:"code",value:o,onChange:e=>c(e.target.value),placeholder:r("Enter code or backup code"),disabled:i}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:r("Enter your authenticator code or a backup code")})]}),(0,t.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,t.jsx)(sN.S,{id:"confirm",checked:d,onCheckedChange:e=>u(e)}),(0,t.jsx)(eD.J,{htmlFor:"confirm",className:"text-sm leading-tight font-normal",children:r("I understand that disabling 2FA will remove all protection and backup codes")})]})]})})}var sC=a(47888);function s_(e){let{open:s,onOpenChange:a,onSuccess:n}=e,{t:r}=(0,g.Bd)(),[i,l]=(0,p.useState)(!1),[o,c]=(0,p.useState)(!1),[d,u]=(0,p.useState)(0),[m,h]=(0,p.useState)(null),[x,y]=(0,p.useState)(""),b=[r("Scan QR Code"),r("Save Backup Codes"),r("Verify Setup")],w=(0,p.useCallback)(async()=>{try{c(!0);let e=await (0,S.D$)();e.success&&e.data?(h(e.data),u(0)):(f.oR.error(e.message||r("Failed to setup 2FA")),a(!1))}catch(e){console.error("Setup 2FA error:",e),f.oR.error(r("Failed to setup 2FA")),a(!1)}finally{c(!1)}},[a,r]),N=async()=>
1{if(!x)return void f.oR.error(r("Please enter the verification code"));try{l(!0);let e=await (0,S.Pr)(x);e.success?(f.oR.success(r("Two-factor authentication enabled successfully!")),a(!1),n(),u(0),y(""),h(null)):f.oR.error(e.message||r("Failed to enable 2FA"))}catch(e){f.oR.error(r("Failed to enable 2FA"))}finally{l(!1)}};return(0,p.useEffect)(()=>{!s||m||o||w()},[s,m,o,w]),(0,t.jsx)(j.l,{open:s,onOpenChange:e=>{i||o||(e&&!m&&w(),e||(u(0),y(""),h(null)),a(e))},title:r("Setup Two-Factor Authentication"),description:(0,t.jsxs)(t.Fragment,{children:[r("Step"),d+1,r("of 3:"),b[d]]}),contentClassName:"sm:max-w-lg",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,t.jsxs)(t.Fragment,{children:[d>0&&(0,t.jsx)(v.$,{variant:"outline",onClick:()=>u(d-1),disabled:o||i,children:r("Back")}),d<2?(0,t.jsx)(v.$,{onClick:()=>u(d+1),disabled:o||!m,children:r("Next")}):(0,t.jsxs)(v.$,{onClick:N,disabled:o||i||!x,children:[i&&(0,t.jsx)(Y.A,{className:"mr-2 h-4 w-4 animate-spin"}),i?r("Enabling..."):r("Enable 2FA")]})]}),children:(0,t.jsx)("div",{className:"space-y-4 py-4",children:o?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 py-8",children:[(0,t.jsx)("div",{className:"border-primary h-8 w-8 animate-spin rounded-full border-4 border-t-transparent"}),(0,t.jsx)("div",{className:"text-muted-foreground text-sm",children:r("Setting up 2FA...")})]}):m?(0,t.jsxs)(t.Fragment,{children:[0===d&&(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:r("Scan this QR code with your authenticator app (Google Authenticator, Microsoft Authenticator, etc.)")}),(0,t.jsx)("div",{className:"flex justify-center rounded-lg bg-white p-4",children:(0,t.jsx)(sC.h,{value:m.qr_code_data,size:200})}),(0,t.jsx)("div",{className:"bg-muted rounded-lg p-3",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:r("Or enter this key manually:")}),(0,t.jsx)("code",{className:"font-mono text-sm",children:m.secret})]}),(0,t.jsx)(eO.i,{value:m.secret,variant:"ghost",tooltip:r("Copy secret key"),"aria-label":r("Copy secret key")})]})})]}),1===d&&(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(eI.Fc,{children:(0,t.jsx)(eI.TN,{children:r("Save these backup codes in a safe place. Each code can only be used once.")})}),(0,t.jsx)("div",{className:"rounded-lg border p-4",children:(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2",children:m.backup_codes.map((e,s)=>(0,t.jsx)("div",{className:"bg-muted rounded-md p-2 text-center font-mono text-sm",children:e},s))})}),(0,t.jsx)(eO.i,{value:m.backup_codes.join("\n"),variant:"outline",size:"default",className:"w-full",iconClassName:"mr-2 size-4",tooltip:r("Copy all backup codes"),"aria-label":r("Copy all backup codes"),children:r("Copy All Codes")})]}),2===d&&(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eD.J,{htmlFor:"code",children:r("Verification Code")}),(0,t.jsx)(ez.p,{id:"code",value:x,onChange:e=>y(e.target.value),placeholder:r("Enter 6-digit code"),maxLength:6,disabled:i}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:r("Enter the 6-digit code from your authenticator app")})]})})]}):(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)("div",{className:"text-muted-foreground",children:r("Failed to load setup data")})})})})}function sF(e){let{loading:s}=e,{t:a}=(0,g.Bd)(),{status:n,loading:r,refetch:i}=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],[s,a]=(0,p.useState)(!0),[t,n]=(0,p.useState)(eM),r=(0,p.useCallback)(async()=>{if(e)try{a(!0);let e=await (0,S.sv)();e.success&&e.data&&n(e.data)}catch(e){console.error("Failed to fetch 2FA status:",e)}finally{a(!1)}},[e]);return(0,p.useEffect)(()=>{r()},[r]),{status:t,loading:s,refetch:r}}(!s),l=(0,eT.b9)();return s||r?(0,t.jsxs)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:[(0,t.jsxs)(b.aR,{className:"p-3 sm:p-5",children:[(0,t.jsx)(N.E,{className:"h-6 w-48"}),(0,t.jsx)(N.E,{className:"mt-2 h-4 w-64"})]}),(0,t.jsx)(b.Wu,{className:"p-3 sm:p-5",children:(0,t.jsx)(N.E,{className:"h-20 w-full"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(b.Zp,{"data-card-hover":"false",className:"gap-0 overflow-hidden py-0",children:[(0,t.jsxs)(b.aR,{className:"p-3 sm:p-5",children:[(0,t.jsx)(b.ZB,{className:"text-lg tracking-tight sm:text-xl",children:a("Two-Factor Authentication")}),(0,t.jsx)(b.BT,{className:"text-xs sm:text-sm",children:a("Add an extra layer of security to your account")}
1)]}),(0,t.jsx)(b.Wu,{className:"p-3 sm:p-5",children:(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between xl:flex-col 2xl:flex-row",children:[(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)(w.f,{tone:"success",size:"sm",children:(0,t.jsx)(eE.A,{})}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"font-medium",children:a("Two-Step Verification")}),n.enabled?(0,t.jsx)(ej.Wh,{label:a("Enabled"),variant:"success",showDot:!0,copyable:!1}):(0,t.jsx)(ej.Wh,{label:a("Disabled"),variant:"neutral",showDot:!0,copyable:!1}),n.locked&&(0,t.jsx)(ej.Wh,{label:a("Locked"),variant:"danger",showDot:!0,copyable:!1})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:n.enabled?a("Backup codes remaining: {{count}}",{count:n.backup_codes_remaining}):a("Add an extra layer of security to your account")})]})]}),!n.enabled&&(0,t.jsx)(v.$,{className:"w-full sm:w-auto xl:w-full 2xl:w-auto",onClick:()=>l.open("setup"),children:a("Enable")})]}),n.enabled&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t pt-6 sm:flex-row xl:flex-col 2xl:flex-row",children:[(0,t.jsxs)(v.$,{variant:"outline",className:"flex-1",onClick:()=>l.open("backup"),children:[(0,t.jsx)(e$.A,{className:"mr-2 h-4 w-4"}),a("Regenerate Backup Codes")]}),(0,t.jsxs)(v.$,{variant:"destructive",className:"flex-1",onClick:()=>l.open("disable"),children:[(0,t.jsx)(eg.A,{className:"mr-2 h-4 w-4"}),a("Disable 2FA")]})]})]})})]}),(0,t.jsx)(s_,{open:l.isOpen("setup"),onOpenChange:e=>e?l.open("setup"):l.close("setup"),onSuccess:i}),(0,t.jsx)(sk,{open:l.isOpen("disable"),onOpenChange:e=>e?l.open("disable"):l.close("disable"),onSuccess:i}),(0,t.jsx)(sw,{open:l.isOpen("backup"),onOpenChange:e=>e?l.open("backup"):l.close("backup"),onSuccess:i})]})}let sS=function(){let{profile:e,loading:s,refreshProfile:a}=function(){let[e,s]=(0,p.useState)(null),[a,t]=(0,p.useState)(!0),[n,r]=(0,p.useState)(!1),i=(0,p.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{e||t(!0);let a=await A();a.success&&a.data&&s(a.data)}catch(s){console.error("Failed to fetch profile:",s),e||f.oR.error(eU.Ay.t("Failed to load profile"))}finally{e||t(!1)}},[]),l=(0,p.useCallback)(async()=>{await i(!0)},[i]),o=(0,p.useCallback)(async e=>{try{r(!0);let s=await R(e);if(s.success)return f.oR.success(eU.Ay.t("Profile updated successfully")),await l(),!0;return f.oR.error(s.message||eU.Ay.t("Failed to update profile")),!1}catch(e){return console.error("Failed to update profile:",e),f.oR.error(eU.Ay.t("Failed to update profile")),!1}finally{r(!1)}},[l]),c=(0,p.useCallback)(async e=>{try{r(!0);let s=await E(e);if(s.success)return f.oR.success(eU.Ay.t("Settings updated successfully")),await l(),!0;return f.oR.error(s.message||eU.Ay.t("Failed to update settings")),!1}catch(e){return console.error("Failed to update settings:",e),f.oR.error(eU.Ay.t("Failed to update settings")),!1}finally{r(!1)}},[l]);return(0,p.useEffect)(()=>{i()},[i]),{profile:e,loading:a,updating:n,fetchProfile:i,refreshProfile:l,updateProfile:o,updateSettings:c}}(),{status:o}=(0,i.s)(),c=(0,l.n)(e=>e.auth.user?.permissions),d=o?.checkin_enabled===!0,u=!!(o?.turnstile_check&&o?.turnstile_site_key),m=o?.turnstile_site_key||"",h=c?.sidebar_settings!==!1;return(0,t.jsx)(n.gZ,{children:(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-auto px-3 py-3 sm:px-4 sm:py-6",children:(0,t.jsxs)(r.nD,{className:"mx-auto flex w-full max-w-7xl flex-col gap-4 sm:gap-6",children:[(0,t.jsx)(r.Hd,{children:(0,t.jsx)(eR,{profile:e,loading:s})}),(0,t.jsx)(r.Hd,{children:(0,t.jsxs)("div",{className:"grid gap-4 sm:gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(360px,0.46fr)] xl:items-start",children:[(0,t.jsxs)("div",{className:"space-y-4 sm:space-y-6",children:[(0,t.jsx)(sy,{profile:e,loading:s,onProfileUpdate:a}),(0,t.jsx)(X,{profile:e,onProfileUpdate:a}),(0,t.jsx)(eY,{profile:e,loading:s}),(0,t.jsx)(ex,{})]}
1),(0,t.jsxs)("div",{className:"space-y-4 sm:space-y-6 xl:sticky xl:top-6",children:[d&&(0,t.jsx)(J,{checkinEnabled:d,turnstileEnabled:u,turnstileSiteKey:m}),h&&(0,t.jsx)(sb,{}),(0,t.jsx)(ew,{loading:s}),(0,t.jsx)(sF,{loading:s})]})]})})]})})})}}}]);

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.