import{r as i,j as l,ac as M,ad as q,x as W,u as N,b as k,F as C,g as b,J as E,H as F,K as g,G,l as H,ae as z}from"./main-BiT4j4N5.js";const x={"progress-bar":"_progress-bar_1l6pa_8","progress-bar-container":"_progress-bar-container_1l6pa_24","progress-bar-label":"_progress-bar-label_1l6pa_53","progress-bar-indicator":"_progress-bar-indicator_1l6pa_59"};function B(e,r=[]){let t=[];function n(o,d){const a=i.createContext(d);a.displayName=o+"Context";const c=t.length;t=[...t,d];const u=f=>{const{scope:m,children:w,..._}=f,V=m?.[e]?.[c]||a,L=i.useMemo(()=>_,Object.values(_));return l.jsx(V.Provider,{value:L,children:w})};u.displayName=o+"Provider";function p(f,m){const w=m?.[e]?.[c]||a,_=i.useContext(w);if(_)return _;if(d!==void 0)return d;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[u,p]}const s=()=>{const o=t.map(d=>i.createContext(d));return function(a){const c=a?.[e]||o;return i.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return s.scopeName=e,[n,Y(s,...r)]}function Y(...e){const r=e[0];if(e.length===1)return r;const t=()=>{const n=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const d=n.reduce((a,{useScope:c,scopeName:u})=>{const f=c(o)[`__scope${u}`];return{...a,...f}},{});return i.useMemo(()=>({[`__scope${r.scopeName}`]:d}),[d])}};return t.scopeName=r.scopeName,t}var K=Symbol.for("react.lazy"),h=M[" use ".trim().toString()];function U(e){return typeof e=="object"&&e!==null&&"then"in e}function j(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===K&&"_payload"in e&&U(e._payload)}function Q(e){const r=X(e),t=i.forwardRef((n,s)=>{let{children:o,...d}=n;j(o)&&typeof h=="function"&&(o=h(o._payload));const a=i.Children.toArray(o),c=a.find(J);if(c){const u=c.props.children,p=a.map(f=>f===c?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:f);return l.jsx(r,{...d,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,p):null})}return l.jsx(r,{...d,ref:s,children:o})});return t.displayName=`${e}.Slot`,t}function X(e){const r=i.forwardRef((t,n)=>{let{children:s,...o}=t;if(j(s)&&typeof h=="function"&&(s=h(s._payload)),i.isValidElement(s)){const d=re(s),a=ee(o,s.props);return s.type!==i.Fragment&&(a.ref=n?q(n,d):d),i.cloneElement(s,a)}return i.Children.count(s)>1?i.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Z=Symbol("radix.slottable");function J(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Z}function ee(e,r){const t={...r};for(const n in r){const s=e[n],o=r[n];/^on[A-Z]/.test(n)?s&&o?t[n]=(...a)=>{const c=o(...a);return s(...a),c}:s&&(t[n]=s):n==="style"?t[n]={...s,...o}:n==="className"&&(t[n]=[s,o].filter(Boolean).join(" "))}return{...e,...t}}function re(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning;return t?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var se=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],I=se.reduce((e,r)=>{const t=Q(`Primitive.${r}`),n=i.forwardRef((s,o)=>{const{asChild:d,...a}=s,c=d?t:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:o})});return n.displayName=`Primitive.${r}`,{...e,[r]:n}},{}),P="Progress",y=100,[te]=B(P),[ne,oe]=te(P),A=i.forwardRef((e,r)=>{const{__scopeProgress:t,value:n=null,max:s,getValueLabel:o=ae,...d}=e;(s||s===0)&&!S(s)&&console.error(ie(`${s}`,"Progress"));const a=S(s)?s:y;n!==null&&!R(n,a)&&console.error(ce(`${n}`,"Progress"));const c=R(n,a)?n:null,u=v(c)?o(c,a):void 0;return l.jsx(ne,{scope:t,value:c,max:a,children:l.jsx(I.div,{"aria-valuemax":a,"aria-valuemin":0,"aria-valuenow":v(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":$(c,a),"data-value":c??void 0,"data-max":a,...d,ref:r})})});A.displayName=P;var T="ProgressIndicator",O=i.forwardRef((e,r)=>{const{__scopeProgress:t,...n}=e,s=oe(T,t);return l.jsx(I.div,{"data-state":$(s.value,s.max),"data-value":s.value??void 0,"data-max":s.max,...n,ref:r})});O.displayName=T;function ae(e,r){return`${Math.round(e/r*100)}%`}function $(e,r){return e==null?"indeterminate":e===r?"complete":"loading"}function v(e){return typeof e=="number"}function S(e){return v(e)&&!isNaN(e)&&e>0}function R(e,r){return v(e)&&!isNaN(e)&&e<=r&&e>=0}function ie(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${y}\`.`}function ce(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 ${y} if no \`max\` prop is set)
  - \`null\` or \`undefined\` if the progress is indeterminate.

Defaulting to \`null\`.`}var le=A,de=O;const ue=i.forwardRef(function({size:r,tint:t,className:n,value:s,max:o,getValueLabel:d,...a},c){const u=o??1,p=s??u,f=i.useId(),m=d?d(p,u):null;return l.jsxs("div",{className:W(x["progress-bar-container"],n),"data-tint":t,...a,children:[m&&l.jsx("div",{id:f,className:x["progress-bar-label"],children:m}),l.jsx(le,{className:x["progress-bar"],"data-size":r,max:u,value:p,ref:c,"aria-labelledby":m?f:void 0,getValueLabel:d,children:l.jsx(de,{className:x["progress-bar-indicator"],style:{transform:`translateX(-${100-p/u*100}%)`}})})]})});function D(e,r){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 24 24",ref:r,...e,children:l.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"})})}D.displayName="LockSolidIcon";const ge=i.forwardRef(D),pe=H(`
  fragment PasswordCreationDoubleInput_siteConfig on SiteConfig {
    id
    minimumPasswordComplexity
  }
`),fe=z(async()=>{const{estimatePasswordComplexity:e}=await import("./index-CAYJKexB.js");return{estimatePasswordComplexity:e}},[],import.meta.url).then(({estimatePasswordComplexity:e})=>e),me=e=>{const{t:r}=N(),[t,n]=i.useState({score:0,scoreText:r("frontend.password_strength.placeholder"),improvementsText:[]}),s=i.useDeferredValue(e);return i.useEffect(()=>{s===""?n({score:0,scoreText:r("frontend.password_strength.placeholder"),improvementsText:[]}):fe.then(o=>o(s,r)).then(o=>n(o))},[s,r]),t};function xe({siteConfig:e,forceShowNewPasswordInvalid:r}){const{t}=N(),{minimumPasswordComplexity:n}=k(pe,e),s=i.useRef(null),o=i.useRef(null),[d,a]=i.useState(""),c=me(d);let u;return d===""?u=void 0:u=["red","red","orange","lime","green"][c.score],l.jsxs(l.Fragment,{children:[l.jsxs(C,{name:"new_password",children:[l.jsx(b,{children:t("frontend.password_change.new_password_label")}),l.jsx(E,{required:!0,autoComplete:"new-password",ref:s,onBlur:()=>o.current?.value&&o.current?.reportValidity(),onChange:p=>a(p.target.value)}),l.jsx(ue,{size:"sm",getValueLabel:()=>c.scoreText,tint:u,max:4,value:c.score}),c.improvementsText.map(p=>l.jsx(F,{children:p},p)),c.score<n&&l.jsx(g,{match:()=>!0,children:t("frontend.password_strength.too_weak")}),l.jsx(g,{match:"valueMissing",children:t("frontend.errors.field_required")}),r&&l.jsx(g,{children:t("frontend.password_change.failure.description.invalid_new_password")})]}),l.jsxs(C,{name:"new_password_again",children:[l.jsx(b,{children:t("frontend.password_change.new_password_again_label")}),l.jsx(E,{required:!0,ref:o,autoComplete:"new-password"}),l.jsx(g,{match:"valueMissing",children:t("frontend.errors.field_required")}),l.jsx(g,{match:(p,f)=>p!==f.get("new_password"),children:t("frontend.password_change.passwords_no_match")}),l.jsx(G,{match:"valid",children:t("frontend.password_change.passwords_match")})]})]})}function he(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{ge as I,xe as P,he as t};
//# sourceMappingURL=password_changes-g3oE0t0I.js.map
