1import{u as q,h as D,a as T,f as A,r as S,j as s,K as F,q as l,T as d,L as m,S as x,t as u,D as h,z as O,k as R,n as p,c as z,A as K,p as L}from"./index-CX0TxBUr.js";import{t as M}from"./zod-DpDyoOGK.js";import{E as w,a as j}from"./eye-Bad2UW2U.js";import{o as _,s as f}from"./types-DIt0oyuo.js";const V=()=>[{url:"/api/auth/new-password"}];async function B(n,a={}){const{client:t=D,...r}=a;return(await t({method:"POST",url:"/api/auth/new-password",data:n,...r})).data}function I(n={}){const{mutation:a,client:t={},shouldFetch:r=!0}=n??{},i=V();return q(r?i:null,async(o,{arg:c})=>B(c,t),a)}const Q=_({password:f().min(8),newPassword:f().min(8),repeatPassword:f().min(8)});function U({username:n}){const a=T(),t=A({resolver:M(Q)}),[r,i]=S.useState(!1),o=()=>{i(e=>!e)},[c,C]=S.useState(!1),N=()=>{C(e=>!e)},{trigger:k,isMutating:g}=I({mutation:{onSuccess:()=>{a("/auth/login"),p.success("Password changed successfully. Please login.")},onError:e=>{var P,y,v,b;e.code==="ERR_BAD_REQUEST"&&((y=(P=e.response)==null?void 0:P.data)!=null&&y.message)?p.error("Failed to change initial password. Please try again.",{description:(b=(v=e.response)==null?void 0:v.data)==null?void 0:b.message}):p.error("Failed to change initial password. Please try again.",{description:e.message})},throwOnError:!0}});function E(e){k({...e,username:n})}return s.jsx(F,{...t,children:s.jsxs("form",{onSubmit:t.handleSubmit(E),className:"grid space-y-4",children:[s.jsx(l,{control:t.control,name:"password",render:({field:e})=>s.jsxs(d,{children:[s.jsx(m,{children:"Password"}),s.jsx(x,{children:s.jsxs("div",{className:"relative",children:[s.jsx(u,{type:r?"text":"password",placeholder:"password",className:"h-11",...e}),s.jsx("div",{className:"absolute inset-y-0 right-0 flex cursor-pointer items-center pr-3 text-neutral-400",children:r?s.jsx(w,{className:"h-4 w-4",onClick:o}):s.jsx(j,{className:"h-4 w-4",onClick:o})})]})}),s.jsx(h,{})]})}),s.jsx(l,{control:t.control,name:"newPassword",render:({field:e})=>s.jsxs(d,{children:[s.jsx(m,{children:"New Password"}),s.jsx(x,{children:s.jsxs("div",{className:"relative",children:[s.jsx(u,{type:r?"text":"password",placeholder:"new password",className:"h-11",...e}),s.jsx("div",{className:"absolute inset-y-0 right-0 flex cursor-pointer items-center pr-3 text-neutral-400",children:r?s.jsx(w,{className:"h-4 w-4",onClick:o}):s.jsx(j,{className:"h-4 w-4",onClick:o})})]})}),s.jsx(h,{})]})}),s.jsx(l,{control:t.control,name:"repeatPassword",render:({field:e})=>s.jsxs(d,{children:[s.jsx(m,{children:"Confirm Password"}),s.jsx(x,{children:s.jsxs("div",{className:"relative",children:[s.jsx(u,{type:c?"text":"password",placeholder:"confirm password",className:"h-11",...e}),s.jsx("div",{className:"absolute inset-y-0 right-0 flex cursor-pointer items-center pr-3 text-neutral-400",children:c?s.jsx(w,{className:"h-4 w-4",onClick:N}):s.jsx(j,{className:"h-4 w-4",onClick:N})})]})}),s.jsx(h,{})]})}),s.jsx(O,{type:"submit",className:"mt-4 h-11",disabled:g,children:g?s.jsx(R,{className:"animate-spin"}):"Set New Password"})]})})}function X(){const[n]=z(),a=n.get("username");return s.jsx("div",{className:"container flex min-h-screen items-center justify-center px-4 py-8",children:s.jsx("div",{className:"mx-auto w-full max-w-sm space-y-4",children:s.jsxs("div",{children:[s.jsx("div",{className:"flex flex-col space-y-2 text-center",children:s.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(L,{className:"mx-auto",iconSizeClassName:"size-12 sm:size-14 mb-8"}),K.includes("appshome")&&s.jsx("div",{className:"absolute -right-4 -top-2 rounded-md bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-800 dark:bg-amber-900/30 dark:text-amber-500",children:"Staging"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h1",{className:"text-2xl font-medium tracking-tight md:text-3xl",children:"Create new password"}),a&&s.jsxs("p",{className:"text-sm text-muted-foreground",children:["for ",a]})]})]})}),s.jsx("div",{className:"mt-8",children:s.jsx(U,{username:a??""})})]})})})}export{X as default};
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.