1import{j as r,ab as m,a7 as w,aE as E,T as N,N as A,a6 as B,ad as x,aF as y}from"./mui-CRsYZxVY.js";import{r as h}from"./vendor-Dwao9eNC.js";import{y as C,z as v,eU as z,C as I,T as M,e7 as P,F as D,w as F}from"./index-TALscxEc.js";import"./query-8ViTdhdk.js";import"./datePickers-BIJXYOKG.js";import"./icons-D8aatgQ4.js";import"./lab-DSem1Osk.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"2ad85febf9735404429b0670d4acf56a0af5a0a2"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new e.Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="4b0654b2-6f36-4e62-86db-c7e7793a8189",e._sentryDebugIdIdentifier="sentry-dbid-4b0654b2-6f36-4e62-86db-c7e7793a8189")})()}catch{}function j(e){if(!e)return 0;let s=0;e.length>=8&&s++,e.length>=12&&s++;const a=/[a-z]/.test(e),i=/[A-Z]/.test(e),l=/\d/.test(e),c=/[^a-zA-Z0-9]/.test(e),t=[a,i,l,c].filter(Boolean).length;t>=3&&s++,t>=4&&s++;const d=e.toLowerCase();return["123456","password","qwerty","abc123","111111","123123","admin","letmein","welcome","senha","mudar"].some(o=>d.includes(o))&&(s=Math.max(s-2,0)),new Set(e).size<=2&&(s=Math.max(s-1,0)),Math.min(s,4)}const L=C().shape({newPassword:v().test("password-strength","A senha é muito fraca",e=>j(e||"")>=2),confirmNewPassword:v().oneOf([z("newPassword")],"As senhas devem coincidir")}),n={0:{label:"Extremamente fraca",color:"error",progress:10},1:{label:"Fraca",color:"error",progress:25},2:{label:"Boa",color:"warning",progress:40},3:{label:"Forte",color:"success",progress:75},4:{label:"Muito forte",color:"success",progress:100}},_=({password:e})=>{const s=j(e);return r.jsxs(m,{spacing:0,marginBlockStart:"6px",mx:"3px",children:[r.jsx(w,{children:r.jsx(E,{variant:"determinate",value:n[s].progress,color:n[s].color})}),r.jsx(N,{variant:"caption",color:n[s].color,fontWeight:"500",mx:"3px",mt:"3px",children:n[s].label})]})},q=()=>{var b;const[e,s]=h.useState(!1),[a,i]=h.useState(!1),[l,c]=h.useState(!1),{register:t,handleSubmit:d,watch:p,setValue:o,formState:{errors:f}}=I({resolver:D(L)}),g=p("newPassword"),S=async({newPassword:T})=>{s(!0);try{const{error:u}=await F.auth.updateUser({password:T});if(u)throw new Error(u.message);i(!0)}catch{c(!0),o("newPassword",""),o("confirmNewPassword","")}finally{s(!1)}};return r.jsxs(w,{sx:{position:"relative",padding:2,overflow:"auto"},children:[r.jsx(M,{title:"Alterar senha",navigateBack:!0}),r.jsx(m,{sx:{position:"relative",marginBottom:12},children:r.jsx("form",{onSubmit:d(S),children:r.jsxs(m,{spacing:2,children:[r.jsxs(w,{children:[r.jsx(P,{label:"Nova senha",type:"password",variant:"outlined",error:!!f.newPassword,disabled:a||e,...t("newPassword"),fullWidth:!0}),g&&r.jsx(_,{password:g||""})]}),r.jsx(P,{label:"Confirmar nova senha",type:"password",variant:"outlined",error:!!f.confirmNewPassword,helperText:(b=f.confirmNewPassword)==null?void 0:b.message,disabled:a||e,...t("confirmNewPassword"),fullWidth:!0}),r.jsx(A,{type:"submit",variant:"contained",disabled:e||a,fullWidth:!0,children:e?r.jsx(B,{size:24}):"Alterar senha"}),l&&r.jsxs(x,{severity:"error",children:[r.jsx(y,{children:"Não foi possÃvel alterar a senha."}),"Por favor, tente novamente."]}),a&&r.jsxs(x,{severity:"success",children:[r.jsx(y,{children:"Senha alterada com sucesso!"}),"Você já pode fazer login com a nova senha."]})]})})})]})};export{q 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.