import"./rolldown-runtime-BM3Ffeng.js";import{D as e,O as t,dt as n,ot as r}from"./element-plus-vendor-BF9PNysW.js";import{A as i,D as a,N as o,P as s,Pt as c,Tt as l,Z as u,et as d,ht as f,o as p,s as m,v as h}from"./vue-vendor-DMUmTARL.js";import{Zn as g}from"./icons-vendor-Buq6V-Ga.js";import{r as _,y as v}from"./index-y6crcKNt.js";import{c as y}from"./home-CJ8x5tlQ.js";import{m as b,u as x}from"./user-CkKt4DA-.js";import{n as S,t as C}from"./PasswordStrengthIndicator-DuqIl1Ve.js";import{c as w}from"./login-redirect-DQQR56P3.js";var T={class:`fixed inset-0 z-[2000] flex items-center justify-center bg-page px-4`},E={class:`w-full max-w-md rounded-2xl border border-border-light bg-surface p-6 shadow-lg sm:p-8`},D={class:`mb-6 flex items-center gap-3`},O={class:`flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-amber-500/10 text-amber-600 dark:bg-amber-400/15 dark:text-amber-300`},k={class:`mt-2 flex items-center justify-between gap-3`},A={__name:`force-change-password`,setup(A){let j=p(),M=m(),N=v(),P=l(0),F=l(8);u(()=>{y(!1).then(e=>{P.value=e.data?.passwordMinStrength??0,F.value=e.data?.passwordMinLength??8}).catch(()=>{})});let I=l(null),L=l(!1),R=l({oldPassword:``,newPassword:``,confirmPassword:``}),z=l({oldPassword:[{required:!0,message:`请输入原密码`,trigger:[`change`,`blur`]}],newPassword:[{required:!0,message:`请输入新密码`,trigger:[`change`,`blur`]},S(()=>P.value,()=>F.value)],confirmPassword:[{required:!0,message:`请再次输入新密码`,trigger:[`change`,`blur`]},{validator:(e,t,n)=>{t===R.value.newPassword?n():n(Error(`两次输入密码不一致!`))},trigger:[`change`,`blur`]}]}),B=async()=>{if(!(!I.value||L.value)&&await I.value.validate().catch(()=>!1)){L.value=!0;try{await b(R.value),N.success(`修改成功`);let e=w(j.query.redirect)||`/`;window.location.href=e}finally{L.value=!1}}},V=async()=>{try{await x()}finally{_(),M.replace(`/login`)}};return(l,u)=>{let p=g;return d(),i(`div`,T,[a(`div`,E,[a(`div`,D,[a(`div`,O,[s(p,{class:`h-5 w-5`})]),u[3]||=a(`div`,{class:`min-w-0`},[a(`div`,{class:`truncate text-base font-semibold text-primary`},`密码已过期`),a(`div`,{class:`mt-0.5 text-xs leading-5 text-secondary`},` 为了账号安全，请先修改密码后再继续使用 `)],-1)]),s(c(e),{ref_key:`formRef`,ref:I,model:c(R),rules:c(z),"label-position":`top`,"status-icon":``,onKeyup:h(B,[`enter`])},{default:f(()=>[s(c(t),{label:`原密码`,prop:`oldPassword`},{default:f(()=>[s(c(n),{modelValue:c(R).oldPassword,"onUpdate:modelValue":u[0]||=e=>c(R).oldPassword=e,type:`password`,size:`large`,"show-password":``,autocomplete:`current-password`,placeholder:`请输入当前登录密码`,disabled:c(L)},null,8,[`modelValue`,`disabled`])]),_:1}),s(c(t),{label:`新密码`,prop:`newPassword`},{default:f(()=>[s(c(n),{modelValue:c(R).newPassword,"onUpdate:modelValue":u[1]||=e=>c(R).newPassword=e,type:`password`,size:`large`,"show-password":``,autocomplete:`new-password`,placeholder:`请输入新的登录密码`,disabled:c(L)},null,8,[`modelValue`,`disabled`]),s(C,{password:c(R).newPassword,"min-level":c(P),"min-length":c(F)},null,8,[`password`,`min-level`,`min-length`])]),_:1}),s(c(t),{label:`确认新密码`,prop:`confirmPassword`},{default:f(()=>[s(c(n),{modelValue:c(R).confirmPassword,"onUpdate:modelValue":u[2]||=e=>c(R).confirmPassword=e,type:`password`,size:`large`,"show-password":``,autocomplete:`new-password`,placeholder:`请再次输入新的登录密码`,disabled:c(L)},null,8,[`modelValue`,`disabled`])]),_:1})]),_:1},8,[`model`,`rules`]),a(`div`,k,[s(c(r),{text:``,disabled:c(L),onClick:V},{default:f(()=>[...u[4]||=[o(`退出登录`,-1)]]),_:1},8,[`disabled`]),s(c(r),{type:`primary`,loading:c(L),onClick:B},{default:f(()=>[...u[5]||=[o(`修改并继续`,-1)]]),_:1},8,[`loading`])])])])}}};export{A as default};