import{r as l,j as s,U as D,X as R,w as y,u as N,b as O,F as x,f as P,J as b,H as V,K as _,E as L,k as M,ac as q}from"./main-Cx2HmTrL.js";const m={"progress-bar":"_progress-bar_9g67e_8","progress-bar-container":"_progress-bar-container_9g67e_24","progress-bar-label":"_progress-bar-label_9g67e_53","progress-bar-indicator":"_progress-bar-indicator_9g67e_59"};var h="Progress",v=100,[$,J]=D(h),[k,F]=$(h),j=l.forwardRef((e,r)=>{const{__scopeProgress:o,value:t=null,max:a,getValueLabel:i=W,...p}=e;(a||a===0)&&!E(a)&&console.error(G(`${a}`,"Progress"));const d=E(a)?a:v;t!==null&&!C(t,d)&&console.error(U(`${t}`,"Progress"));const n=C(t,d)?t:null,c=f(n)?i(n,d):void 0;return s.jsx(k,{scope:o,value:n,max:d,children:s.jsx(R.div,{"aria-valuemax":d,"aria-valuemin":0,"aria-valuenow":f(n)?n:void 0,"aria-valuetext":c,role:"progressbar","data-state":A(n,d),"data-value":n??void 0,"data-max":d,...p,ref:r})})});j.displayName=h;var I="ProgressIndicator",S=l.forwardRef((e,r)=>{const{__scopeProgress:o,...t}=e,a=F(I,o);return s.jsx(R.div,{"data-state":A(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...t,ref:r})});S.displayName=I;function W(e,r){return`${Math.round(e/r*100)}%`}function A(e,r){return e==null?"indeterminate":e===r?"complete":"loading"}function f(e){return typeof e=="number"}function E(e){return f(e)&&!isNaN(e)&&e>0}function C(e,r){return f(e)&&!isNaN(e)&&e<=r&&e>=0}function G(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${v}\`.`}function U(e,r){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${r}\`. The \`value\` prop must be:
  - a positive number
  - less than the value passed to \`max\` (or ${v} if no \`max\` prop is set)
  - \`null\` or \`undefined\` if the progress is indeterminate.

Defaulting to \`null\`.`}var K=j,z=S;const H=l.forwardRef(function({size:r,tint:o,className:t,value:a,max:i,getValueLabel:p,...d},n){const c=i??1,u=a??c,g=l.useId(),w=p?p(u,c):null;return s.jsxs("div",{className:y(m["progress-bar-container"],t),"data-tint":o,...d,children:[w&&s.jsx("div",{id:g,className:m["progress-bar-label"],children:w}),s.jsx(K,{className:m["progress-bar"],"data-size":r,max:c,value:u,ref:n,"aria-labelledby":w?g:void 0,getValueLabel:p,children:s.jsx(z,{className:m["progress-bar-indicator"],style:{transform:`translateX(-${100-u/c*100}%)`}})})]})});function T(e,r){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 24 24",ref:r,...e,children:s.jsx("path",{d:"M6 22q-.824 0-1.412-.587A1.93 1.93 0 0 1 4 20V10q0-.825.588-1.412A1.93 1.93 0 0 1 6 8h1V6q0-2.075 1.463-3.537Q9.926 1 12 1q2.075 0 3.537 1.463Q17 3.925 17 6v2h1q.824 0 1.413.588Q20 9.175 20 10v10q0 .824-.587 1.413A1.93 1.93 0 0 1 18 22zM9 8h6V6q0-1.25-.875-2.125A2.9 2.9 0 0 0 12 3q-1.25 0-2.125.875A2.9 2.9 0 0 0 9 6z"})})}T.displayName="LockSolidIcon";const Z=l.forwardRef(T),X=M(`
  fragment PasswordCreationDoubleInput_siteConfig on SiteConfig {
    id
    minimumPasswordComplexity
  }
`),Y=q(async()=>{const{estimatePasswordComplexity:e}=await import("./index-CAYJKexB.js");return{estimatePasswordComplexity:e}},[],import.meta.url).then(({estimatePasswordComplexity:e})=>e),B=e=>{const{t:r}=N(),[o,t]=l.useState({score:0,scoreText:r("frontend.password_strength.placeholder"),improvementsText:[]}),a=l.useDeferredValue(e);return l.useEffect(()=>{a===""?t({score:0,scoreText:r("frontend.password_strength.placeholder"),improvementsText:[]}):Y.then(i=>i(a,r)).then(i=>t(i))},[a,r]),o};function ee({siteConfig:e,forceShowNewPasswordInvalid:r}){const{t:o}=N(),{minimumPasswordComplexity:t}=O(X,e),a=l.useRef(null),i=l.useRef(null),[p,d]=l.useState(""),n=B(p);let c;return p===""?c=void 0:c=["red","red","orange","lime","green"][n.score],s.jsxs(s.Fragment,{children:[s.jsxs(x,{name:"new_password",children:[s.jsx(P,{children:o("frontend.password_change.new_password_label")}),s.jsx(b,{required:!0,autoComplete:"new-password",ref:a,onBlur:()=>i.current?.value&&i.current?.reportValidity(),onChange:u=>d(u.target.value)}),s.jsx(H,{size:"sm",getValueLabel:()=>n.scoreText,tint:c,max:4,value:n.score}),n.improvementsText.map(u=>s.jsx(V,{children:u},u)),n.score<t&&s.jsx(_,{match:()=>!0,children:o("frontend.password_strength.too_weak")}),s.jsx(_,{match:"valueMissing",children:o("frontend.errors.field_required")}),r&&s.jsx(_,{children:o("frontend.password_change.failure.description.invalid_new_password")})]}),s.jsxs(x,{name:"new_password_again",children:[s.jsx(P,{children:o("frontend.password_change.new_password_again_label")}),s.jsx(b,{required:!0,ref:i,autoComplete:"new-password"}),s.jsx(_,{match:"valueMissing",children:o("frontend.errors.field_required")}),s.jsx(_,{match:(u,g)=>u!==g.get("new_password"),children:o("frontend.password_change.passwords_no_match")}),s.jsx(L,{match:"valid",children:o("frontend.password_change.passwords_match")})]})]})}function re(e,r){switch(r){case"NO_CURRENT_PASSWORD":return e("frontend.password_change.failure.description.no_current_password");case"PASSWORD_CHANGES_DISABLED":return e("frontend.password_change.failure.description.password_changes_disabled");case"ACCOUNT_LOCKED":return e("frontend.password_change.failure.description.account_locked");case"EXPIRED_RECOVERY_TICKET":return e("frontend.password_change.failure.description.expired_recovery_ticket");case"NO_SUCH_RECOVERY_TICKET":return e("frontend.password_change.failure.description.no_such_recovery_ticket");case"RECOVERY_TICKET_ALREADY_USED":return e("frontend.password_change.failure.description.recovery_ticket_already_used");case"WRONG_PASSWORD":case"INVALID_NEW_PASSWORD":return;case"ALLOWED":case void 0:return;default:throw new Error(`unexpected error when changing password: ${r}`)}}export{Z as I,ee as P,re as t};
//# sourceMappingURL=password_changes-C92mRK6h.js.map
