import"../chunks/DsnmJJEf.js";import{p as Ne,u as Te,t as p,a as m,b as he,k as Re,d as s,c as E,$ as Ie,r as o,s as d,g as t,h as W,l as Ae,e as q,f as w,j as v,n as we,i as S}from"../chunks/BfUaJvxP.js";import{d as De,a as ye,s as _,e as Me}from"../chunks/Bci9YmGs.js";import{i as N}from"../chunks/C8yDvkQM.js";import{h as Pe}from"../chunks/DogoSe-2.js";import{h as Oe,s as Xe}from"../chunks/VWvGCFra.js";import{s as Q,r as ke,B as Le,t as T}from"../chunks/CuIpA3jY.js";import{b as Ce}from"../chunks/CH92E1A-.js";import{i as n}from"../chunks/CF1ujZlL.js";import{g as Ge}from"../chunks/TWCB2oXp.js";import{b as Y}from"../chunks/DlhQF7fG.js";import{p as J}from"../chunks/DpTm09Um.js";import{r as We}from"../chunks/B5TnUz9r.js";import{B as ze,t as Z}from"../chunks/B8gPun0s.js";import{p as z,P as Be,e as Ke}from"../chunks/CVQjyNH_.js";import{A as $e}from"../chunks/Cdd5krRs.js";import{S as je,M as Ue}from"../chunks/DEpIk0Jk.js";import{L as Fe}from"../chunks/BeSnoT4y.js";import{K as He}from"../chunks/Ba6kQPoG.js";var Ve=E('<div class="px-6 py-5 text-center text-[13px] text-muted-foreground"> </div>'),qe=E('<p class="text-xs text-red-500"> </p>'),Qe=E("<!> ",1),Ye=E("<!> Reset password",1),Je=E('<form class="space-y-4 px-6 py-5" novalidate=""><!> <div class="space-y-1.5"><label for="confirm" class="text-[13px] font-medium text-foreground"> </label> <input id="confirm" type="password" autocomplete="new-password"/> <!></div> <!></form>'),Ze=E('<div class="flex min-h-screen items-center justify-center bg-background p-4"><button type="button" class="absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground"><!></button> <div class="w-full max-w-sm"><div class="mb-8 flex flex-col items-center text-center"><div class="mb-4"><!></div> <h1 class="text-2xl font-semibold tracking-tight text-foreground"> </h1> <p class="mt-1 text-[13px] text-muted-foreground"><!></p></div> <div class="rounded-lg border border-border bg-card shadow-sm"><!> <div class="border-t border-border px-6 py-3"><a class="flex items-center justify-center gap-1.5 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground"><!> </a></div></div></div></div>');function xt(ee,te){Ne(te,!0);const D=W(()=>J.url.searchParams.get("user")??""),B=W(()=>J.url.searchParams.get("token")??"");let f=S(""),y=S(""),u=S(!1),M=S(!1),h=S(!1);Te(()=>{z.load().catch(()=>{})});const K=W(()=>!t(D)||!t(B));async function re(e){e.preventDefault(),v(M,!1),v(h,!1);const r=Ke(t(f),z.current);if(!t(f)||!r.allRulesMet){v(M,!0);return}if(t(f)!==t(y)){v(h,!0);return}v(u,!0);try{await We(t(D),t(B),t(f)),T.success(n.t("ADMIN_NEXT.RESET.PASSWORD_RESET_SUCCESSFULLY_PLEASE_SIGN")),Ge(`${Y}/login`)}catch(a){if(a&&typeof a=="object"&&"status"in a){const i=a;i.status===429?T.error(i.message||"Too many attempts. Try again later."):i.status===422||i.status===400?T.error(i.message||"Invalid or expired reset link."):T.error(i.message||"Unable to reset password")}else T.error(n.t("ADMIN_NEXT.RESET.UNABLE_TO_CONNECT_TO_SERVER"))}finally{v(u,!1)}}var P=Ze();Oe("1rnsd0w",e=>{Re(r=>{Ie.title=r??""},[()=>n.t("ADMIN_NEXT.RESET.RESET_PASSWORD_GRAV_ADMIN")])});var g=s(P),ae=s(g);{var se=e=>{je(e,{size:16})},oe=e=>{Ue(e,{size:16})};N(ae,e=>{Z.isDark?e(se):e(oe,-1)})}o(g);var $=d(g,2),O=s($),X=s(O),ie=s(X);ze(ie,{size:"login"}),o(X);var k=d(X,2),ne=s(k,!0);o(k);var j=d(k,2),le=s(j);{var de=e=>{var r=Ae();p(a=>_(r,a),[()=>n.t("ADMIN_NEXT.RESET.INVALID_LINK")]),m(e,r)},me=e=>{var r=q(),a=w(r);Pe(a,()=>n.tHtml("ADMIN_NEXT.RESET.NEW_PASSWORD_FOR",{username:t(D)})),m(e,r)};N(le,e=>{t(K)?e(de):e(me,-1)})}o(j),o(O);var U=d(O,2),F=s(U);{var ve=e=>{var r=Ve(),a=s(r,!0);o(r),p(i=>_(a,i),[()=>n.t("ADMIN_NEXT.RESET.THIS_RESET_LINK_IS_MISSING_REQUIRED")]),m(e,r)},_e=e=>{var r=Je(),a=s(r);Be(a,{id:"password",label:"New password",get policy(){return z.current},get disabled(){return t(u)},get invalid(){return t(M)},invalidMessage:"Password does not meet the required policy",get value(){return t(f)},set value(l){v(f,l,!0)}});var i=d(a,2),C=s(i),ue=s(C,!0);o(C);var x=d(C,2);ke(x);var ce=d(x,2);{var pe=l=>{var R=qe(),I=s(R,!0);o(R),p(G=>_(I,G),[()=>n.t("ADMIN_NEXT.RESET.PASSWORDS_DO_NOT_MATCH")]),m(l,R)};N(ce,l=>{t(h)&&l(pe)})}o(i);var Ee=d(i,2);Le(Ee,{type:"submit",class:"w-full",get disabled(){return t(u)},children:(l,R)=>{var I=q(),G=w(I);{var ge=c=>{var b=Qe(),A=w(b);Fe(A,{size:15,class:"animate-spin"});var be=d(A);p(Se=>_(be,` ${Se??""}`),[()=>n.t("ADMIN_NEXT.RESET.RESETTING")]),m(c,b)},xe=c=>{var b=Ye(),A=w(b);He(A,{size:15}),we(),m(c,b)};N(G,c=>{t(u)?c(ge):c(xe,-1)})}m(l,I)},$$slots:{default:!0}}),o(r),p(l=>{_(ue,l),Xe(x,1,`flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-sm shadow-sm transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring
								${t(h)?"border-red-500 ring-1 ring-red-500/30 animate-[shake_0.3s_ease-in-out]":"border-input"}`),x.disabled=t(u)},[()=>n.t("ADMIN_NEXT.RESET.CONFIRM_PASSWORD")]),Me("submit",r,re),Ce(x,()=>t(y),l=>v(y,l)),m(e,r)};N(F,e=>{t(K)?e(ve):e(_e,-1)})}var H=d(F,2),L=s(H),V=s(L);$e(V,{size:12});var fe=d(V);o(L),o(H),o(U),o($),o(P),p((e,r,a)=>{Q(g,"aria-label",e),_(ne,r),Q(L,"href",`${Y??""}/login`),_(fe,` ${a??""}`)},[()=>n.t("ADMIN_NEXT.TOGGLE_DARK_MODE"),()=>n.t("ADMIN_NEXT.RESET.RESET_PASSWORD"),()=>n.t("ADMIN_NEXT.RESET.BACK_TO_SIGN_IN")]),ye("click",g,()=>Z.toggleColorMode()),m(ee,P),he()}De(["click"]);export{xt as component};
