import{A as e,D as t,E as n,I as r,O as i,Pt as a,Xt as o,et as s,k as c,nt as l,qt as u,x as d}from"./vue-vendor-DMUmTARL.js";import{Yr as f}from"./icons-vendor-Db5MGAkr.js";function p(e,t=8){if(!e)return 0;let n=0;return e.length>=t&&(n+=1),/[A-Za-z]/.test(e)&&/\d/.test(e)&&(n+=1),/[^A-Za-z\d]/.test(e)&&(n+=1),n<=1?1:n}var m={1:`较弱`,2:`中等`,3:`较强`};function h(e,t=8){let n=e||``;return[{key:`length`,label:`长度 ≥ ${t}`,met:n.length>=t},{key:`alnum`,label:`含字母与数字`,met:/[A-Za-z]/.test(n)&&/\d/.test(n)},{key:`symbol`,label:`含符号`,met:/[^A-Za-z\d]/.test(n)}]}function g(e,t,n=8){if(!e)return null;let r=n||8;return e.length<r?`密码长度至少 ${r} 位`:t>0&&p(e,n)<t?`密码强度需至少达到「${m[t]||``}」`:null}function _(e,t){return{validator:(n,r,i)=>{let a=g(r,e()||0,t()||8);if(a){i(Error(a));return}i()},trigger:`change`}}var v={key:0,class:`mt-3 w-full`},y={class:`mb-2 flex items-center justify-between gap-3 text-xs`},b={class:`flex gap-2`},x={key:0,class:`mt-2 space-y-1 text-xs leading-5`},S={class:`inline-flex h-3.5 w-3.5 items-center justify-center`},C={key:1,class:`bg-fill-secondary h-1.5 w-1.5 rounded-full`},w={key:1,class:`mt-2 text-xs leading-5 text-secondary`},T={key:2,class:`mt-2 text-xs leading-5 text-emerald-500 dark:text-emerald-300`},E=r({__name:`PasswordStrengthIndicator`,props:{password:{},showTip:{type:Boolean,default:!0},minLevel:{default:0},minLength:{default:8},showChecklist:{type:Boolean,default:!0}},setup(r){let g=r;function _(e){let t=p(e,g.minLength);return t===0?{level:0,label:`未设置`,textClass:`text-placeholder`,barClass:`bg-fill-secondary`}:t===1?{level:1,label:`较弱`,textClass:`text-rose-400 dark:text-rose-300`,barClass:`bg-rose-400/75 dark:bg-rose-300/70`}:t===2?{level:2,label:`中等`,textClass:`text-amber-400 dark:text-amber-300`,barClass:`bg-amber-400/75 dark:bg-amber-300/70`}:{level:3,label:`较强`,textClass:`text-emerald-400 dark:text-emerald-300`,barClass:`bg-emerald-400/75 dark:bg-emerald-300/70`}}let E=n(()=>_(g.password)),D=n(()=>h(g.password,g.minLength)),O=n(()=>g.minLevel<=0||p(g.password,g.minLength)>=g.minLevel),k=n(()=>`已满足最低强度要求（${m[g.minLevel]||``}）`);return(n,p)=>{let m=f;return r.password?(s(),e(`div`,v,[t(`div`,y,[p[0]||=t(`span`,{class:`text-secondary`},`密码强度`,-1),t(`span`,{class:u(a(E).textClass)},o(a(E).label),3)]),t(`div`,b,[(s(),e(d,null,l(3,(e,n)=>t(`div`,{key:n,class:u([`h-1 w-full rounded-full transition-all duration-300`,n<a(E).level?a(E).barClass:`bg-fill-secondary`])},null,2)),64))]),r.showChecklist?(s(),e(`ul`,x,[(s(!0),e(d,null,l(a(D),n=>(s(),e(`li`,{key:n.key,class:u([`flex items-center gap-1.5`,n.met?`text-emerald-500 dark:text-emerald-300`:`text-placeholder`])},[t(`span`,S,[n.met?(s(),i(m,{key:0,class:`h-3.5 w-3.5`})):(s(),e(`span`,C))]),t(`span`,null,o(n.label),1)],2))),128))])):c(``,!0),r.showTip&&!r.minLevel?(s(),e(`div`,w,` 建议同时包含字母、数字和符号，长度不少于 8 位。 `)):c(``,!0),r.minLevel>0&&a(O)?(s(),e(`div`,T,o(a(k)),1)):c(``,!0)])):c(``,!0)}}});export{_ as n,g as r,E as t};