import{k as Be,j as o,t as Ge,h as He,m as k,n as c,p as l,q as te,i as $,v as We,A as y,z as Ye,x as d,s as Fe}from"./web.Os7kOAdY.js";import{c as Je}from"./clipboard.BNxbz_oK.js";import{g as le,t as Ke}from"./i18n-runtime._BAkvU05.js";var Qe=y('<div class=panel style=display:flex;flex-direction:column;gap:14px><div class=tool-grid-3><div class=tool-field><span class=tool-label></span><input class=tool-input type=number min=4 max=256></div><div class=tool-field><span class=tool-label></span><input class=tool-input type=number min=1 max=200></div><div class=tool-field><span class=tool-label></span><div style=display:flex;flex-wrap:wrap;gap:10px;font-size:13px><label><input type=checkbox> a-z</label><label><input type=checkbox> A-Z</label><label><input type=checkbox> 0-9</label><label><input type=checkbox> <!$><!/></label><label><input type=checkbox> <!$><!/></label></div></div></div><div class=tool-actions><button class="tool-btn is-primary"></button><button class=tool-btn></button><button class="tool-btn is-ghost"></button><!$><!/></div><!$><!/><p class=tool-hint>'),Xe=y('<span class=tool-error style="padding:6px 10px">'),et=y("<div class=tool-meter><span></span><div class=tool-meter-bar><div class=tool-meter-fill></div></div><span><!$><!/> · <!$><!/> <!$><!/><!$><!/> <!$><!/>"),tt=y("<pre class=tool-pre>");const lt="abcdefghijklmnopqrstuvwxyz",nt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",it="0123456789",st="!@#$%^&*()-_=+[]{};:,.?/~",at=/[O0Il1|`'"]/g;function ne(i,a){if(!a)return"";const e=new Uint32Array(i);crypto.getRandomValues(e);let s="";for(let u=0;u<i;u++)s+=a[e[u]%a.length];return s}function rt(i){if(!i)return{score:0,bits:0,label:"空"};let a=0;/[a-z]/.test(i)&&(a+=26),/[A-Z]/.test(i)&&(a+=26),/\d/.test(i)&&(a+=10),/[^a-zA-Z\d]/.test(i)&&(a+=32);let e=Math.log2(Math.max(a,1))*i.length;/(.)\1{2,}/.test(i)&&(e*=.7),/0123|1234|2345|abcd|qwer|asdf/i.test(i)&&(e*=.6);let s=0;e>=28&&(s=1),e>=48&&(s=2),e>=64&&(s=3),e>=90&&(s=4);const u=["极弱","弱","中","强","极强"];return{score:s,bits:Math.round(e),label:u[s]}}function dt(){const[i,a]=o(le(),{equals:!1}),e=n=>Ke(n,i());Ge(()=>{const n=_=>{const b=_.detail?.locale;b&&a(b)};window.addEventListener("taitan:locale-change",n),a(le()),Fe(()=>window.removeEventListener("taitan:locale-change",n))});const[s,u]=o(20),[U,ie]=o(!0),[I,se]=o(!0),[A,ae]=o(!0),[R,re]=o(!0),[z,oe]=o(!1),[j,ce]=o(8),[x,C]=o([]),f=He(()=>{let n="";return U()&&(n+=lt),I()&&(n+=nt),A()&&(n+=it),R()&&(n+=st),z()&&(n=n.replace(at,"")),n}),$e=()=>{const n=Math.max(1,Math.min(200,j())),_=Math.max(4,Math.min(256,s())),b=f();if(!b){C([]);return}const h=[];for(let v=0;v<n;v++)h.push(ne(_,b));C(h)},de=()=>x()[0]??ne(s(),f());return(()=>{var n=k(Qe),_=n.firstChild,b=_.firstChild,h=b.firstChild,v=h.nextSibling,q=b.nextSibling,D=q.firstChild,O=D.nextSibling,be=q.nextSibling,P=be.firstChild,ge=P.nextSibling,Z=ge.firstChild,N=Z.firstChild,V=Z.nextSibling,B=V.firstChild,G=V.nextSibling,H=G.firstChild,L=G.nextSibling,E=L.firstChild,ue=E.nextSibling,_e=ue.nextSibling,[pe,xe]=c(_e.nextSibling),W=L.nextSibling,M=W.firstChild,fe=M.nextSibling,he=fe.nextSibling,[ve,Se]=c(he.nextSibling),T=_.nextSibling,S=T.firstChild,m=S.nextSibling,w=m.nextSibling,me=w.nextSibling,[ke,ye]=c(me.nextSibling),Ce=T.nextSibling,[Y,Le]=c(Ce.nextSibling),Ee=Y.nextSibling;return l(h,()=>e("长度")),v.$$input=t=>u(parseInt(t.currentTarget.value,10)||20),l(D,()=>e("数量")),O.$$input=t=>ce(parseInt(t.currentTarget.value,10)||1),l(P,()=>e("字符集")),N.addEventListener("change",t=>ie(t.currentTarget.checked)),B.addEventListener("change",t=>se(t.currentTarget.checked)),H.addEventListener("change",t=>ae(t.currentTarget.checked)),E.addEventListener("change",t=>re(t.currentTarget.checked)),l(L,()=>e("符号"),pe,xe),M.addEventListener("change",t=>oe(t.currentTarget.checked)),l(W,()=>e("排除易混"),ve,Se),S.$$click=$e,l(S,()=>e("生成")),m.$$click=()=>Je(x().join(`
`)),l(m,()=>e("复制全部")),w.$$click=()=>C([]),l(w,()=>e("清空")),l(T,(()=>{var t=te(()=>!f());return()=>t()&&(()=>{var r=k(Xe);return l(r,()=>e("请至少选一个字符集")),r})()})(),ke,ye),l(n,(()=>{var t=te(()=>x().length>0);return()=>t()&&(()=>{const r=rt(de());return[(()=>{var g=k(et),F=g.firstChild,J=F.nextSibling,Me=J.firstChild,p=J.nextSibling,Te=p.firstChild,[K,we]=c(Te.nextSibling),Ue=K.nextSibling,Ie=Ue.nextSibling,[Q,Ae]=c(Ie.nextSibling),Re=Q.nextSibling,ze=Re.nextSibling,[X,je]=c(ze.nextSibling),qe=X.nextSibling,[ee,De]=c(qe.nextSibling),Oe=ee.nextSibling,Pe=Oe.nextSibling,[Ze,Ne]=c(Pe.nextSibling);return l(F,()=>e("强度")),l(p,()=>r.label,K,we),l(p,()=>r.bits,Q,Ae),l(p,()=>e("bits · 池"),X,je),l(p,()=>f().length,ee,De),l(p,()=>e("字符"),Ze,Ne),$(Ve=>Ye(Me,`width:${r.score*25}%`,Ve)),g})(),(()=>{var g=k(tt);return l(g,()=>x().join(`
`)),g})()]})()})(),Y,Le),l(Ee,()=>e("使用 crypto.getRandomValues 生成；强度估算仅供参考，实际安全性还要看用途与轮换策略。")),$(t=>{var r=!f(),g=!x().length;return r!==t.e&&d(S,"disabled",t.e=r),g!==t.t&&d(m,"disabled",t.t=g),t},{e:void 0,t:void 0}),$(()=>d(v,"value",s())),$(()=>d(O,"value",j())),$(()=>d(N,"checked",U())),$(()=>d(B,"checked",I())),$(()=>d(H,"checked",A())),$(()=>d(E,"checked",R())),$(()=>d(M,"checked",z())),We(),n})()}Be(["input","click"]);export{dt as default};
