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

Defaulting to \`null\`.`}var W=P,G=I,K=(0,f.forwardRef)(function({size:e,tint:t,className:n,value:r,max:i,getValueLabel:a,...o},s){let c=i??1,l=r??c,u=(0,f.useId)(),m=a?a(l,c):null;return(0,p.jsxs)(`div`,{className:(0,d.default)(w[`progress-bar-container`],n),"data-tint":t,...o,children:[m&&(0,p.jsx)(`div`,{id:u,className:w[`progress-bar-label`],children:m}),(0,p.jsx)(W,{className:w[`progress-bar`],"data-size":e,max:c,value:l,ref:s,"aria-labelledby":m?u:void 0,getValueLabel:a,children:(0,p.jsx)(G,{className:w[`progress-bar-indicator`],style:{transform:`translateX(-${100-l/c*100}%)`}})})]})});function q(e,t){return(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,viewBox:`0 0 24 24`,ref:t,...e,children:(0,p.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`})})}q.displayName=`LockSolidIcon`;var J=(0,f.forwardRef)(q),Y=t(`
  fragment PasswordCreationDoubleInput_siteConfig on SiteConfig {
    id
    minimumPasswordComplexity
  }
`),X=c(async()=>{let{estimatePasswordComplexity:e}=await import(`./password_complexity-B-101nS8.js`);return{estimatePasswordComplexity:e}},[],import.meta.url).then(({estimatePasswordComplexity:e})=>e),Z=e=>{let{t}=i(),[n,r]=(0,f.useState)({score:0,scoreText:t(`frontend.password_strength.placeholder`),improvementsText:[]}),a=(0,f.useDeferredValue)(e);return(0,f.useEffect)(()=>{a===``?r({score:0,scoreText:t(`frontend.password_strength.placeholder`),improvementsText:[]}):X.then(e=>e(a,t)).then(e=>r(e))},[a,t]),n};function Q({siteConfig:e,forceShowNewPasswordInvalid:t}){let{t:r}=i(),{minimumPasswordComplexity:o}=n(Y,e),s=(0,f.useRef)(null),c=(0,f.useRef)(null),[l,u]=(0,f.useState)(``),d=Z(l),m;return m=l===``?void 0:[`red`,`red`,`orange`,`lime`,`green`][d.score],(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(a.Field,{name:`new_password`,children:[(0,p.jsx)(a.Label,{children:r(`frontend.password_change.new_password_label`)}),(0,p.jsx)(a.PasswordControl,{required:!0,autoComplete:`new-password`,ref:s,onBlur:()=>c.current?.value&&c.current?.reportValidity(),onChange:e=>u(e.target.value)}),(0,p.jsx)(K,{size:`sm`,getValueLabel:()=>d.scoreText,tint:m,max:4,value:d.score}),d.improvementsText.map(e=>(0,p.jsx)(a.HelpMessage,{children:e},e)),d.score<o&&(0,p.jsx)(a.ErrorMessage,{match:()=>!0,children:r(`frontend.password_strength.too_weak`)}),(0,p.jsx)(a.ErrorMessage,{match:`valueMissing`,children:r(`frontend.errors.field_required`)}),t&&(0,p.jsx)(a.ErrorMessage,{children:r(`frontend.password_change.failure.description.invalid_new_password`)})]}),(0,p.jsxs)(a.Field,{name:`new_password_again`,children:[(0,p.jsx)(a.Label,{children:r(`frontend.password_change.new_password_again_label`)}),(0,p.jsx)(a.PasswordControl,{required:!0,ref:c,autoComplete:`new-password`}),(0,p.jsx)(a.ErrorMessage,{match:`valueMissing`,children:r(`frontend.errors.field_required`)}),(0,p.jsx)(a.ErrorMessage,{match:(e,t)=>e!==t.get(`new_password`),children:r(`frontend.password_change.passwords_no_match`)}),(0,p.jsx)(a.SuccessMessage,{match:`valid`,children:r(`frontend.password_change.passwords_match`)})]})]})}function $(e,t){switch(t){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 Error(`unexpected error when changing password: ${t}`)}}export{Q as n,J as r,$ as t};
//# sourceMappingURL=password_changes-B_Q5-EtU.js.map