mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 17:37:24 +08:00
3 lines
31 KiB
JavaScript
3 lines
31 KiB
JavaScript
import{al as F,r as A,G as Le,I as je,d2 as _e,o as Oe,dH as Q,j as I,c as Y,dJ as Ne,dw as Ue,dz as ze,q as O,dI as We,b6 as $e,a6 as W,R as G,dK as Fe,dL as Ye,dM as Ge,dN as He,F as qe}from"./index.js";import{_ as Be}from"./role.vue_vue_type_script_setup_true_lang.js";import{_ as Ve}from"./index.vue_vue_type_script_setup_true_lang16.js";import{_ as Ze}from"./upload.vue_vue_type_script_setup_true_lang.js";import{u as Xe}from"./hooks2.js";import{g as Ke,b as Je,c as Qe,d as et}from"./system.js";import"./index65.js";import"./index63.js";import"./vue-tippy.esm-browser.js";const V=(r,e)=>r.push.apply(r,e),_=r=>r.sort((e,t)=>e.i-t.i||e.j-t.j),ee=r=>{const e={};let t=1;return r.forEach(s=>{e[s]=t,t+=1}),e};var tt={4:[[1,2],[2,3]],5:[[1,3],[2,3],[2,4]],6:[[1,2],[2,4],[4,5]],7:[[1,3],[2,3],[4,5],[4,6]],8:[[2,4],[4,6]]};const te=2050,se=1e3,st=tt,nt=10,rt=1e4,ce=10,le=50,ue=20,he=/^[A-Z\xbf-\xdf][^A-Z\xbf-\xdf]+$/,at=/^[^A-Z\xbf-\xdf]+[A-Z\xbf-\xdf]$/,it=/^[A-Z\xbf-\xdf]+$/,de=/^[^a-z\xdf-\xff]+$/,ot=/^[a-z\xdf-\xff]+$/,ct=/^[^A-Z\xbf-\xdf]+$/,lt=/[a-z\xdf-\xff]/,ut=/[A-Z\xbf-\xdf]/,ht=/[^A-Za-z\xbf-\xdf]/gi,dt=/^\d+$/,X=new Date().getFullYear(),ft={recentYear:/19\d\d|200\d|201\d|202\d/g},fe=[" ",",",";",":","|","/","\\","_",".","-"],gt=fe.length;class pt{match({password:e}){const t=[...this.getMatchesWithoutSeparator(e),...this.getMatchesWithSeparator(e)],s=this.filterNoise(t);return _(s)}getMatchesWithSeparator(e){const t=[],s=/^(\d{1,4})([\s/\\_.-])(\d{1,2})\2(\d{1,4})$/;for(let n=0;n<=Math.abs(e.length-6);n+=1)for(let a=n+5;a<=n+9&&!(a>=e.length);a+=1){const i=e.slice(n,+a+1||9e9),c=s.exec(i);if(c!=null){const o=this.mapIntegersToDayMonthYear([parseInt(c[1],10),parseInt(c[3],10),parseInt(c[4],10)]);o!=null&&t.push({pattern:"date",token:i,i:n,j:a,separator:c[2],year:o.year,month:o.month,day:o.day})}}return t}getMatchesWithoutSeparator(e){const t=[],s=/^\d{4,8}$/,n=a=>Math.abs(a.year-X);for(let a=0;a<=Math.abs(e.length-4);a+=1)for(let i=a+3;i<=a+7&&!(i>=e.length);i+=1){const c=e.slice(a,+i+1||9e9);if(s.exec(c)){const o=[],u=c.length;if(st[u].forEach(([p,b])=>{const y=this.mapIntegersToDayMonthYear([parseInt(c.slice(0,p),10),parseInt(c.slice(p,b),10),parseInt(c.slice(b),10)]);y!=null&&o.push(y)}),o.length>0){let p=o[0],b=n(o[0]);o.slice(1).forEach(y=>{const g=n(y);g<b&&(p=y,b=g)}),t.push({pattern:"date",token:c,i:a,j:i,separator:"",year:p.year,month:p.month,day:p.day})}}}return t}filterNoise(e){return e.filter(t=>{let s=!1;const n=e.length;for(let a=0;a<n;a+=1){const i=e[a];if(t!==i&&i.i<=t.i&&i.j>=t.j){s=!0;break}}return!s})}mapIntegersToDayMonthYear(e){if(e[1]>31||e[1]<=0)return null;let t=0,s=0,n=0;for(let a=0,i=e.length;a<i;a+=1){const c=e[a];if(c>99&&c<se||c>te)return null;c>31&&(s+=1),c>12&&(t+=1),c<=0&&(n+=1)}return s>=2||t===3||n>=2?null:this.getDayMonth(e)}getDayMonth(e){const t=[[e[2],e.slice(0,2)],[e[0],e.slice(1,3)]],s=t.length;for(let n=0;n<s;n+=1){const[a,i]=t[n];if(se<=a&&a<=te){const c=this.mapIntegersToDayMonth(i);return c!=null?{year:a,month:c.month,day:c.day}:null}}for(let n=0;n<s;n+=1){const[a,i]=t[n],c=this.mapIntegersToDayMonth(i);if(c!=null)return{year:this.twoToFourDigitYear(a),month:c.month,day:c.day}}return null}mapIntegersToDayMonth(e){const t=[e,e.slice().reverse()];for(let s=0;s<t.length;s+=1){const n=t[s],a=n[0],i=n[1];if(a>=1&&a<=31&&i>=1&&i<=12)return{day:a,month:i}}return null}twoToFourDigitYear(e){return e>99?e:e>50?e+1900:e+2e3}}const R=new Uint32Array(65536),mt=(r,e)=>{const t=r.length,s=e.length,n=1<<t-1;let a=-1,i=0,c=t,o=t;for(;o--;)R[r.charCodeAt(o)]|=1<<o;for(o=0;o<s;o++){let u=R[e.charCodeAt(o)];const f=u|i;u|=(u&a)+a^a,i|=~(u|a),a&=u,i&n&&c++,a&n&&c--,i=i<<1|1,a=a<<1|~(f|i),i&=f}for(o=t;o--;)R[r.charCodeAt(o)]=0;return c},bt=(r,e)=>{const t=e.length,s=r.length,n=[],a=[],i=Math.ceil(t/32),c=Math.ceil(s/32);for(let g=0;g<i;g++)a[g]=-1,n[g]=0;let o=0;for(;o<c-1;o++){let g=0,M=-1;const D=o*32,v=Math.min(32,s)+D;for(let m=D;m<v;m++)R[r.charCodeAt(m)]|=1<<m;for(let m=0;m<t;m++){const x=R[e.charCodeAt(m)],S=a[m/32|0]>>>m&1,T=n[m/32|0]>>>m&1,U=x|g,z=((x|T)&M)+M^M|x|T;let P=g|~(z|M),j=M&z;P>>>31^S&&(a[m/32|0]^=1<<m),j>>>31^T&&(n[m/32|0]^=1<<m),P=P<<1|S,j=j<<1|T,M=j|~(U|P),g=P&U}for(let m=D;m<v;m++)R[r.charCodeAt(m)]=0}let u=0,f=-1;const p=o*32,b=Math.min(32,s-p)+p;for(let g=p;g<b;g++)R[r.charCodeAt(g)]|=1<<g;let y=s;for(let g=0;g<t;g++){const M=R[e.charCodeAt(g)],D=a[g/32|0]>>>g&1,v=n[g/32|0]>>>g&1,m=M|u,x=((M|v)&f)+f^f|M|v;let S=u|~(x|f),T=f&x;y+=S>>>s-1&1,y-=T>>>s-1&1,S>>>31^D&&(a[g/32|0]^=1<<g),T>>>31^v&&(n[g/32|0]^=1<<g),S=S<<1|D,T=T<<1|v,f=T|~(m|S),u=S&m}for(let g=p;g<b;g++)R[r.charCodeAt(g)]=0;return y},yt=(r,e)=>{if(r.length<e.length){const t=e;e=r,r=t}return e.length===0?r.length:r.length<=32?mt(r,e):bt(r,e)},Mt=(r,e,t)=>{const s=r.length<=e.length,n=r.length<=t;return s||n?Math.ceil(r.length/4):t},vt=(r,e,t)=>{let s=0;const n=Object.keys(e).find(a=>{const i=Mt(r,a,t);if(Math.abs(r.length-a.length)>i)return!1;const c=yt(r,a),o=c<=i;return o&&(s=c),o});return n?{levenshteinDistance:s,levenshteinDistanceEntry:n}:{}};var ne={a:["4","@"],b:["8"],c:["(","{","[","<"],d:["6","|)"],e:["3"],f:["#"],g:["6","9","&"],h:["#","|-|"],i:["1","!","|"],k:["<","|<"],l:["!","1","|","7"],m:["^^","nn","2n","/\\\\/\\\\"],n:["//"],o:["0","()"],q:["9"],u:["|_|"],s:["$","5"],t:["+","7"],v:["<",">","/"],w:["^/","uu","vv","2u","2v","\\\\/\\\\/"],x:["%","><"],z:["2"]},H={warnings:{straightRow:"straightRow",keyPattern:"keyPattern",simpleRepeat:"simpleRepeat",extendedRepeat:"extendedRepeat",sequences:"sequences",recentYears:"recentYears",dates:"dates",topTen:"topTen",topHundred:"topHundred",common:"common",similarToCommon:"similarToCommon",wordByItself:"wordByItself",namesByThemselves:"namesByThemselves",commonNames:"commonNames",userInputs:"userInputs",pwned:"pwned"},suggestions:{l33t:"l33t",reverseWords:"reverseWords",allUppercase:"allUppercase",capitalization:"capitalization",dates:"dates",recentYears:"recentYears",associatedYears:"associatedYears",sequences:"sequences",repeated:"repeated",longerKeyboardPattern:"longerKeyboardPattern",anotherWord:"anotherWord",useWords:"useWords",noNeed:"noNeed",pwned:"pwned"},timeEstimation:{ltSecond:"ltSecond",second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",month:"month",months:"months",year:"year",years:"years",centuries:"centuries"}};class N{constructor(e=[]){this.parents=e,this.children=new Map}addSub(e,...t){const s=e.charAt(0);this.children.has(s)||this.children.set(s,new N([...this.parents,s]));let n=this.children.get(s);for(let a=1;a<e.length;a+=1){const i=e.charAt(a);n.hasChild(i)||n.addChild(i),n=n.getChild(i)}return n.subs=(n.subs||[]).concat(t),this}getChild(e){return this.children.get(e)}isTerminal(){return!!this.subs}addChild(e){this.hasChild(e)||this.children.set(e,new N([...this.parents,e]))}hasChild(e){return this.children.has(e)}}var re=(r,e)=>(Object.entries(r).forEach(([t,s])=>{s.forEach(n=>{e.addSub(n,t)})}),e);class xt{constructor(){this.matchers={},this.l33tTable=ne,this.trieNodeRoot=re(ne,new N),this.dictionary={userInputs:[]},this.rankedDictionaries={},this.rankedDictionariesMaxWordSize={},this.translations=H,this.graphs={},this.useLevenshteinDistance=!1,this.levenshteinThreshold=2,this.l33tMaxSubstitutions=512,this.maxLength=256,this.setRankedDictionaries()}setOptions(e={}){e.l33tTable&&(this.l33tTable=e.l33tTable,this.trieNodeRoot=re(e.l33tTable,new N)),e.dictionary&&(this.dictionary=e.dictionary,this.setRankedDictionaries()),e.translations&&this.setTranslations(e.translations),e.graphs&&(this.graphs=e.graphs),e.useLevenshteinDistance!==void 0&&(this.useLevenshteinDistance=e.useLevenshteinDistance),e.levenshteinThreshold!==void 0&&(this.levenshteinThreshold=e.levenshteinThreshold),e.l33tMaxSubstitutions!==void 0&&(this.l33tMaxSubstitutions=e.l33tMaxSubstitutions),e.maxLength!==void 0&&(this.maxLength=e.maxLength)}setTranslations(e){if(this.checkCustomTranslations(e))this.translations=e;else throw new Error("Invalid translations object fallback to keys")}checkCustomTranslations(e){let t=!0;return Object.keys(H).forEach(s=>{if(s in e){const n=s;Object.keys(H[n]).forEach(a=>{a in e[n]||(t=!1)})}else t=!1}),t}setRankedDictionaries(){const e={},t={};Object.keys(this.dictionary).forEach(s=>{e[s]=ee(this.dictionary[s]),t[s]=this.getRankedDictionariesMaxWordSize(this.dictionary[s])}),this.rankedDictionaries=e,this.rankedDictionariesMaxWordSize=t}getRankedDictionariesMaxWordSize(e){const t=e.map(s=>typeof s!="string"?s.toString().length:s.length);return t.length===0?0:t.reduce((s,n)=>Math.max(s,n),-1/0)}buildSanitizedRankedDictionary(e){const t=[];return e.forEach(s=>{const n=typeof s;(n==="string"||n==="number"||n==="boolean")&&t.push(s.toString().toLowerCase())}),ee(t)}extendUserInputsDictionary(e){this.dictionary.userInputs||(this.dictionary.userInputs=[]);const t=[...this.dictionary.userInputs,...e];this.rankedDictionaries.userInputs=this.buildSanitizedRankedDictionary(t),this.rankedDictionariesMaxWordSize.userInputs=this.getRankedDictionariesMaxWordSize(t)}addMatcher(e,t){this.matchers[e]?console.info(`Matcher ${e} already exists`):this.matchers[e]=t}}const d=new xt;class kt{constructor(e){this.defaultMatch=e}match({password:e}){const t=e.split("").reverse().join("");return this.defaultMatch({password:t}).map(s=>({...s,token:s.token.split("").reverse().join(""),reversed:!0,i:e.length-1-s.j,j:e.length-1-s.i}))}}class St{constructor({substr:e,buffer:t,limit:s,trieRoot:n}){this.finalPasswords=[],this.substr=e,this.buffer=t,this.limit=s,this.trieRoot=n}getAllPossibleSubsAtIndex(e){const t=[];let s=this.trieRoot;for(let n=e;n<this.substr.length;n+=1){const a=this.substr.charAt(n);if(s=s.getChild(a),!s)break;t.push(s)}return t}helper({onlyFullSub:e,isFullSub:t,index:s,subIndex:n,changes:a}){if(this.finalPasswords.length>=this.limit)return;if(s===this.substr.length){e===t&&this.finalPasswords.push({password:this.buffer.join(""),changes:a});return}const i=[...this.getAllPossibleSubsAtIndex(s)];let c=!1;for(let o=s+i.length-1;o>=s;o-=1){const u=i[o-s];if(u.isTerminal()){c=!0;const f=u.subs;for(const p of f){this.buffer.push(p);const b=a.concat({i:n,letter:p,substitution:u.parents.join("")});if(this.helper({onlyFullSub:e,isFullSub:t,index:o+1,subIndex:n+p.length,changes:b}),this.buffer.pop(),this.finalPasswords.length>=this.limit)return}}}if(!e||!c){const o=this.substr.charAt(s);this.buffer.push(o),this.helper({onlyFullSub:e,isFullSub:t&&!c,index:s+1,subIndex:n+1,changes:a}),this.buffer.pop()}}getAll(){return this.helper({onlyFullSub:!0,isFullSub:!0,index:0,subIndex:0,changes:[]}),this.helper({onlyFullSub:!1,isFullSub:!0,index:0,subIndex:0,changes:[]}),this.finalPasswords}}const Et=(r,e,t)=>new St({substr:r,buffer:[],limit:e,trieRoot:t}).getAll(),Dt=(r,e,t)=>{const n=r.changes.filter(u=>u.i<e).reduce((u,f)=>u-f.letter.length+f.substitution.length,e),a=r.changes.filter(u=>u.i>=e&&u.i<=t),i=a.reduce((u,f)=>u-f.letter.length+f.substitution.length,t-e+n),c=[],o=[];return a.forEach(u=>{c.findIndex(p=>p.letter===u.letter&&p.substitution===u.substitution)<0&&(c.push({letter:u.letter,substitution:u.substitution}),o.push(`${u.substitution} -> ${u.letter}`))}),{i:n,j:i,subs:c,subDisplay:o.join(", ")}};class Tt{constructor(e){this.defaultMatch=e}isAlreadyIncluded(e,t){return e.some(s=>Object.entries(s).every(([n,a])=>n==="subs"||a===t[n]))}match({password:e}){const t=[],s=Et(e,d.l33tMaxSubstitutions,d.trieNodeRoot);let n=!1,a=!0;return s.forEach(i=>{if(n)return;const c=this.defaultMatch({password:i.password,useLevenshtein:a});a=!1,c.forEach(o=>{n||(n=o.i===0&&o.j===e.length-1);const u=Dt(i,o.i,o.j),f=e.slice(u.i,+u.j+1||9e9),p={...o,l33t:!0,token:f,...u},b=this.isAlreadyIncluded(t,p);f.toLowerCase()!==o.matchedWord&&!b&&t.push(p)})}),t.filter(i=>i.token.length>1)}}class At{constructor(){this.l33t=new Tt(this.defaultMatch),this.reverse=new kt(this.defaultMatch)}match({password:e}){const t=[...this.defaultMatch({password:e}),...this.reverse.match({password:e}),...this.l33t.match({password:e})];return _(t)}defaultMatch({password:e,useLevenshtein:t=!0}){const s=[],n=e.length,a=e.toLowerCase();return Object.keys(d.rankedDictionaries).forEach(i=>{const c=d.rankedDictionaries[i],o=d.rankedDictionariesMaxWordSize[i],u=Math.min(o,n);for(let f=0;f<n;f+=1){const p=Math.min(f+u,n);for(let b=f;b<p;b+=1){const y=a.slice(f,+b+1||9e9),g=y in c;let M={};const D=f===0&&b===n-1;d.useLevenshteinDistance&&D&&!g&&t&&(M=vt(y,c,d.levenshteinThreshold));const v=Object.keys(M).length!==0;if(g||v){const m=v?M.levenshteinDistanceEntry:y,x=c[m];s.push({pattern:"dictionary",i:f,j:b,token:e.slice(f,+b+1||9e9),matchedWord:y,rank:x,dictionaryName:i,reversed:!1,l33t:!1,...M})}}}}),s}}class It{match({password:e,regexes:t=ft}){const s=[];return Object.keys(t).forEach(n=>{const a=t[n];a.lastIndex=0;let i;for(;i=a.exec(e);)if(i){const c=i[0];s.push({pattern:"regex",token:c,i:i.index,j:i.index+i[0].length-1,regexName:n,regexMatch:i})}}),_(s)}}var L={nCk(r,e){let t=r;if(e>t)return 0;if(e===0)return 1;let s=1;for(let n=1;n<=e;n+=1)s*=t,s/=n,t-=1;return s},log10(r){return r===0?0:Math.log(r)/Math.log(10)},log2(r){return Math.log(r)/Math.log(2)},factorial(r){let e=1;for(let t=2;t<=r;t+=1)e*=t;return e}},Rt=({token:r})=>{let e=nt**r.length;e===Number.POSITIVE_INFINITY&&(e=Number.MAX_VALUE);let t;return r.length===1?t=ce+1:t=le+1,Math.max(e,t)},Ct=({year:r,separator:e})=>{let s=Math.max(Math.abs(r-X),ue)*365;return e&&(s*=4),s};const wt=r=>{const e=r.split(""),t=e.filter(i=>i.match(ut)).length,s=e.filter(i=>i.match(lt)).length;let n=0;const a=Math.min(t,s);for(let i=1;i<=a;i+=1)n+=L.nCk(t+s,i);return n};var Pt=r=>{const e=r.replace(ht,"");if(e.match(ct)||e.toLowerCase()===e)return 1;const t=[he,at,de],s=t.length;for(let n=0;n<s;n+=1){const a=t[n];if(e.match(a))return 2}return wt(e)};const ae=(r,e)=>{let t=0,s=r.indexOf(e);for(;s>=0;)t+=1,s=r.indexOf(e,s+e.length);return t},Lt=({sub:r,token:e})=>{const t=e.toLowerCase(),s=ae(t,r.substitution),n=ae(t,r.letter);return{subbedCount:s,unsubbedCount:n}};var jt=({l33t:r,subs:e,token:t})=>{if(!r)return 1;let s=1;return e.forEach(n=>{const{subbedCount:a,unsubbedCount:i}=Lt({sub:n,token:t});if(a===0||i===0)s*=2;else{const c=Math.min(i,a);let o=0;for(let u=1;u<=c;u+=1)o+=L.nCk(i+a,u);s*=o}}),s},_t=({rank:r,reversed:e,l33t:t,subs:s,token:n,dictionaryName:a})=>{const i=r,c=Pt(n),o=jt({l33t:t,subs:s,token:n}),u=e&&2||1;let f;return a==="diceware"?f=6**5/2:f=i*c*o*u,{baseGuesses:i,uppercaseVariations:c,l33tVariations:o,calculation:f}},Ot=({regexName:r,regexMatch:e,token:t})=>{const s={alphaLower:26,alphaUpper:26,alpha:52,alphanumeric:62,digits:10,symbols:33};if(r in s)return s[r]**t.length;switch(r){case"recentYear":return Math.max(Math.abs(parseInt(e[0],10)-X),ue)}return 0},Nt=({baseGuesses:r,repeatCount:e})=>r*e,Ut=({token:r,ascending:e})=>{const t=r.charAt(0);let s=0;return["a","A","z","Z","0","1","9"].includes(t)?s=4:t.match(/\d/)?s=10:s=26,e||(s*=2),s*r.length};const zt=r=>{let e=0;return Object.keys(r).forEach(t=>{const s=r[t];e+=s.filter(n=>!!n).length}),e/=Object.entries(r).length,e},Wt=({token:r,graph:e,turns:t})=>{const s=Object.keys(d.graphs[e]).length,n=zt(d.graphs[e]);let a=0;const i=r.length;for(let c=2;c<=i;c+=1){const o=Math.min(t,c-1);for(let u=1;u<=o;u+=1)a+=L.nCk(c-1,u-1)*s*n**u}return a};var $t=({graph:r,token:e,shiftedCount:t,turns:s})=>{let n=Wt({token:e,graph:r,turns:s});if(t){const a=e.length-t;if(t===0||a===0)n*=2;else{let i=0;for(let c=1;c<=Math.min(t,a);c+=1)i+=L.nCk(t+a,c);n*=i}}return Math.round(n)},Ft=()=>gt;const Yt=(r,e)=>{let t=1;return r.token.length<e.length&&(r.token.length===1?t=ce:t=le),t},ie={bruteforce:Rt,date:Ct,dictionary:_t,regex:Ot,repeat:Nt,sequence:Ut,spatial:$t,separator:Ft},Gt=(r,e)=>ie[r]?ie[r](e):d.matchers[r]&&"scoring"in d.matchers[r]?d.matchers[r].scoring(e):0;var Ht=(r,e)=>{const t={};if("guesses"in r&&r.guesses!=null)return r;const s=Yt(r,e),n=Gt(r.pattern,r);let a=0;typeof n=="number"?a=n:r.pattern==="dictionary"&&(a=n.calculation,t.baseGuesses=n.baseGuesses,t.uppercaseVariations=n.uppercaseVariations,t.l33tVariations=n.l33tVariations);const i=Math.max(a,s);return{...r,...t,guesses:i,guessesLog10:L.log10(i)}};const E={password:"",optimal:{},excludeAdditive:!1,separatorRegex:void 0,fillArray(r,e){const t=[];for(let s=0;s<r;s+=1){let n=[];e==="object"&&(n={}),t.push(n)}return t},makeBruteforceMatch(r,e){return{pattern:"bruteforce",token:this.password.slice(r,+e+1||9e9),i:r,j:e}},update(r,e){const t=r.j,s=Ht(r,this.password);let n=s.guesses;e>1&&(n*=this.optimal.pi[s.i-1][e-1]);let a=L.factorial(e)*n;this.excludeAdditive||(a+=rt**(e-1));let i=!1;Object.keys(this.optimal.g[t]).forEach(c=>{const o=this.optimal.g[t][c];parseInt(c,10)<=e&&o<=a&&(i=!0)}),i||(this.optimal.g[t][e]=a,this.optimal.m[t][e]=s,this.optimal.pi[t][e]=n)},bruteforceUpdate(r){let e=this.makeBruteforceMatch(0,r);this.update(e,1);for(let t=1;t<=r;t+=1){e=this.makeBruteforceMatch(t,r);const s=this.optimal.m[t-1];Object.keys(s).forEach(n=>{s[n].pattern!=="bruteforce"&&this.update(e,parseInt(n,10)+1)})}},unwind(r){const e=[];let t=r-1,s=0,n=1/0;const a=this.optimal.g[t];for(a&&Object.keys(a).forEach(i=>{const c=a[i];c<n&&(s=parseInt(i,10),n=c)});t>=0;){const i=this.optimal.m[t][s];e.unshift(i),t=i.i-1,s-=1}return e}};var Z={mostGuessableMatchSequence(r,e,t=!1){E.password=r,E.excludeAdditive=t;const s=r.length;let n=E.fillArray(s,"array");e.forEach(o=>{n[o.j].push(o)}),n=n.map(o=>o.sort((u,f)=>u.i-f.i)),E.optimal={m:E.fillArray(s,"object"),pi:E.fillArray(s,"object"),g:E.fillArray(s,"object")};for(let o=0;o<s;o+=1)n[o].forEach(u=>{u.i>0?Object.keys(E.optimal.m[u.i-1]).forEach(f=>{E.update(u,parseInt(f,10)+1)}):E.update(u,1)}),E.bruteforceUpdate(o);const a=E.unwind(s),i=a.length,c=this.getGuesses(r,i);return{password:r,guesses:c,guessesLog10:L.log10(c),sequence:a}},getGuesses(r,e){const t=r.length;let s=0;return r.length===0?s=1:s=E.optimal.g[t-1][e],s}};function q({isLazy:r=!1,isAnchored:e=!1,flags:t=""}){return new RegExp(`${e?"^":""}(.+${r?"?":""})\\1+${e?"$":""}`,t)}class qt{match({password:e,omniMatch:t}){const s=[];let n=0;for(;n<e.length;){const i=this.getGreedyMatch(e,n),c=this.getLazyMatch(e,n);if(i==null)break;const{match:o,baseToken:u}=this.setMatchToken(i,c);if(o){const f=o.index+o[0].length-1,p=this.getBaseGuesses(u,t);s.push(this.normalizeMatch(u,f,o,p)),n=f+1}}return s.some(i=>i instanceof Promise)?Promise.all(s):s}normalizeMatch(e,t,s,n){const a={pattern:"repeat",i:s.index,j:t,token:s[0],baseToken:e,baseGuesses:0,repeatCount:s[0].length/e.length};return n instanceof Promise?n.then(i=>({...a,baseGuesses:i})):{...a,baseGuesses:n}}getGreedyMatch(e,t){const s=q({isLazy:!1,flags:"g"});return s.lastIndex=t,s.exec(e)}getLazyMatch(e,t){const s=q({isLazy:!0,flags:"g"});return s.lastIndex=t,s.exec(e)}setMatchToken(e,t){const s=q({isLazy:!0,isAnchored:!0});let n,a="";if(t&&e[0].length>t[0].length){n=e;const i=s.exec(n[0]);i&&(a=i[1])}else n=t,n&&(a=n[1]);return{match:n,baseToken:a}}getBaseGuesses(e,t){const s=t.match(e);return s instanceof Promise?s.then(a=>Z.mostGuessableMatchSequence(e,a).guesses):Z.mostGuessableMatchSequence(e,s).guesses}}class Bt{constructor(){this.MAX_DELTA=5}match({password:e}){const t=[];if(e.length===1)return[];let s=0,n=null;const a=e.length;for(let i=1;i<a;i+=1){const c=e.charCodeAt(i)-e.charCodeAt(i-1);if(n==null&&(n=c),c!==n){const o=i-1;this.update({i:s,j:o,delta:n,password:e,result:t}),s=o,n=c}}return this.update({i:s,j:a-1,delta:n,password:e,result:t}),t}update({i:e,j:t,delta:s,password:n,result:a}){if(t-e>1||Math.abs(s)===1){const i=Math.abs(s);if(i>0&&i<=this.MAX_DELTA){const c=n.slice(e,+t+1||9e9),{sequenceName:o,sequenceSpace:u}=this.getSequence(c);return a.push({pattern:"sequence",i:e,j:t,token:n.slice(e,+t+1||9e9),sequenceName:o,sequenceSpace:u,ascending:s>0})}}return null}getSequence(e){let t="unicode",s=26;return ot.test(e)?(t="lower",s=26):it.test(e)?(t="upper",s=26):dt.test(e)&&(t="digits",s=10),{sequenceName:t,sequenceSpace:s}}}class Vt{constructor(){this.SHIFTED_RX=/[~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?]/}match({password:e}){const t=[];return Object.keys(d.graphs).forEach(s=>{const n=d.graphs[s];V(t,this.helper(e,n,s))}),_(t)}checkIfShifted(e,t,s){return!e.includes("keypad")&&this.SHIFTED_RX.test(t.charAt(s))?1:0}helper(e,t,s){let n;const a=[];let i=0;const c=e.length;for(;i<c-1;){let o=i+1,u=null,f=0;for(n=this.checkIfShifted(s,e,i);;){const p=e.charAt(o-1),b=t[p]||[];let y=!1,g=-1,M=-1;if(o<c){const D=e.charAt(o),v=b.length;for(let m=0;m<v;m+=1){const x=b[m];if(M+=1,x){const S=x.indexOf(D);if(S!==-1){y=!0,g=M,S===1&&(n+=1),u!==g&&(f+=1,u=g);break}}}}if(y)o+=1;else{o-i>2&&a.push({pattern:"spatial",i,j:o-1,token:e.slice(i,o),graph:s,turns:f,shiftedCount:n}),i=o;break}}}return a}}const Zt=new RegExp(`[${fe.join("")}]`);class ${static getMostUsedSeparatorChar(e){const t=[...e.split("").filter(n=>Zt.test(n)).reduce((n,a)=>{const i=n.get(a);return i?n.set(a,i+1):n.set(a,1),n},new Map).entries()].sort(([n,a],[i,c])=>c-a);if(!t.length)return;const s=t[0];if(!(s[1]<2))return s[0]}static getSeparatorRegex(e){return new RegExp(`([^${e}
|
|
])(${e})(?!${e})`,"g")}match({password:e}){const t=[];if(e.length===0)return t;const s=$.getMostUsedSeparatorChar(e);if(s===void 0)return t;const n=$.getSeparatorRegex(s);for(const a of e.matchAll(n)){if(a.index===void 0)continue;const i=a.index+1;t.push({pattern:"separator",token:s,i,j:i})}return t}}class Xt{constructor(){this.matchers={date:pt,dictionary:At,regex:It,repeat:qt,sequence:Bt,spatial:Vt,separator:$}}match(e){const t=[],s=[];return[...Object.keys(this.matchers),...Object.keys(d.matchers)].forEach(a=>{if(!this.matchers[a]&&!d.matchers[a])return;const i=this.matchers[a]?this.matchers[a]:d.matchers[a].Matching,o=new i().match({password:e,omniMatch:this});o instanceof Promise?(o.then(u=>{V(t,u)}),s.push(o)):V(t,o)}),s.length>0?new Promise((a,i)=>{Promise.all(s).then(()=>{a(_(t))}).catch(c=>{i(c)})}):_(t)}}const ge=1,pe=ge*60,me=pe*60,be=me*24,ye=be*31,Me=ye*12,Kt=Me*100,B={second:ge,minute:pe,hour:me,day:be,month:ye,year:Me,century:Kt};class Jt{translate(e,t){let s=e;t!==void 0&&t!==1&&(s+="s");const{timeEstimation:n}=d.translations;return n[s].replace("{base}",`${t}`)}estimateAttackTimes(e){const t={onlineThrottling100PerHour:e/.027777777777777776,onlineNoThrottling10PerSecond:e/10,offlineSlowHashing1e4PerSecond:e/1e4,offlineFastHashing1e10PerSecond:e/1e10},s={onlineThrottling100PerHour:"",onlineNoThrottling10PerSecond:"",offlineSlowHashing1e4PerSecond:"",offlineFastHashing1e10PerSecond:""};return Object.keys(t).forEach(n=>{const a=t[n];s[n]=this.displayTime(a)}),{crackTimesSeconds:t,crackTimesDisplay:s,score:this.guessesToScore(e)}}guessesToScore(e){return e<1e3+5?0:e<1e6+5?1:e<1e8+5?2:e<1e10+5?3:4}displayTime(e){let t="centuries",s;const n=Object.keys(B),a=n.findIndex(i=>e<B[i]);return a>-1&&(t=n[a-1],a!==0?s=Math.round(e/B[t]):t="ltSecond"),this.translate(t,s)}}var Qt=()=>null,es=()=>({warning:d.translations.warnings.dates,suggestions:[d.translations.suggestions.dates]});const ts=(r,e)=>{let t=null;return e&&!r.l33t&&!r.reversed?r.rank<=10?t=d.translations.warnings.topTen:r.rank<=100?t=d.translations.warnings.topHundred:t=d.translations.warnings.common:r.guessesLog10<=4&&(t=d.translations.warnings.similarToCommon),t},ss=(r,e)=>{let t=null;return e&&(t=d.translations.warnings.wordByItself),t},ns=(r,e)=>e?d.translations.warnings.namesByThemselves:d.translations.warnings.commonNames,rs=(r,e)=>{let t=null;const s=r.dictionaryName,n=s==="lastnames"||s.toLowerCase().includes("firstnames");return s==="passwords"?t=ts(r,e):s.includes("wikipedia")?t=ss(r,e):n?t=ns(r,e):s==="userInputs"&&(t=d.translations.warnings.userInputs),t};var as=(r,e)=>{const t=rs(r,e),s=[],n=r.token;return n.match(he)?s.push(d.translations.suggestions.capitalization):n.match(de)&&n.toLowerCase()!==n&&s.push(d.translations.suggestions.allUppercase),r.reversed&&r.token.length>=4&&s.push(d.translations.suggestions.reverseWords),r.l33t&&s.push(d.translations.suggestions.l33t),{warning:t,suggestions:s}},is=r=>r.regexName==="recentYear"?{warning:d.translations.warnings.recentYears,suggestions:[d.translations.suggestions.recentYears,d.translations.suggestions.associatedYears]}:{warning:null,suggestions:[]},os=r=>{let e=d.translations.warnings.extendedRepeat;return r.baseToken.length===1&&(e=d.translations.warnings.simpleRepeat),{warning:e,suggestions:[d.translations.suggestions.repeated]}},cs=()=>({warning:d.translations.warnings.sequences,suggestions:[d.translations.suggestions.sequences]}),ls=r=>{let e=d.translations.warnings.keyPattern;return r.turns===1&&(e=d.translations.warnings.straightRow),{warning:e,suggestions:[d.translations.suggestions.longerKeyboardPattern]}},us=()=>null;const oe={warning:null,suggestions:[]};class hs{constructor(){this.matchers={bruteforce:Qt,date:es,dictionary:as,regex:is,repeat:os,sequence:cs,spatial:ls,separator:us},this.defaultFeedback={warning:null,suggestions:[]},this.setDefaultSuggestions()}setDefaultSuggestions(){this.defaultFeedback.suggestions.push(d.translations.suggestions.useWords,d.translations.suggestions.noNeed)}getFeedback(e,t){if(t.length===0)return this.defaultFeedback;if(e>2)return oe;const s=d.translations.suggestions.anotherWord,n=this.getLongestMatch(t);let a=this.getMatchFeedback(n,t.length===1);return a!=null?a.suggestions.unshift(s):a={warning:null,suggestions:[s]},a}getLongestMatch(e){let t=e[0];return e.slice(1).forEach(n=>{n.token.length>t.token.length&&(t=n)}),t}getMatchFeedback(e,t){return this.matchers[e.pattern]?this.matchers[e.pattern](e,t):d.matchers[e.pattern]&&"feedback"in d.matchers[e.pattern]?d.matchers[e.pattern].feedback(e,t):oe}}const ve=()=>new Date().getTime(),ds=(r,e,t)=>{const s=new hs,n=new Jt,a=Z.mostGuessableMatchSequence(e,r),i=ve()-t,c=n.estimateAttackTimes(a.guesses);return{calcTime:i,...a,...c,feedback:s.getFeedback(c.score,a.sequence)}},fs=(r,e)=>(e&&d.extendUserInputsDictionary(e),new Xt().match(r)),gs=(r,e)=>{const t=ve(),s=fs(r,e);if(s instanceof Promise)throw new Error("You are using a Promised matcher, please use `zxcvbnAsync` for it.");return ds(s,r,t)};function Es(r,e){const t=F({deptId:"",username:"",phone:"",status:""}),s=A(),n=A(),a=A([]),i=A(!0),c=A(),o=A({}),{switchStyle:u}=Xe(),f=A(),p=A([]),b=A(!0),y=A(0),g=F({total:0,pageSize:10,currentPage:1,background:!0}),M=[{label:"勾选列",type:"selection",fixed:"left",reserveSelection:!0},{label:"用户编号",prop:"id",width:90},{label:"用户头像",prop:"avatar",cellRenderer:({row:l})=>I(Y("el-image"),{fit:"cover","preview-teleported":!0,src:l.avatar,"preview-src-list":Array.of(l.avatar),class:"w-[24px] h-[24px] rounded-full align-middle"},null),width:90},{label:"用户名称",prop:"username",minWidth:130},{label:"用户昵称",prop:"nickname",minWidth:130},{label:"性别",prop:"sex",minWidth:90,cellRenderer:({row:l,props:h})=>I(Y("el-tag"),{size:h.size,type:l.sex===1?"danger":"",effect:"plain"},{default:()=>[l.sex===1?"女":"男"]})},{label:"部门",prop:"dept.name",minWidth:90},{label:"手机号码",prop:"phone",minWidth:90,formatter:({phone:l})=>Ne(l,{start:3,end:6})},{label:"状态",prop:"status",minWidth:90,cellRenderer:l=>{var h;return I(Y("el-switch"),{size:l.props.size==="small"?"small":"default",loading:(h=o.value[l.index])==null?void 0:h.loading,modelValue:l.row.status,"onUpdate:modelValue":k=>l.row.status=k,"active-value":1,"inactive-value":0,"active-text":"已启用","inactive-text":"已停用","inline-prompt":!0,style:u.value,onChange:()=>T(l)},null)}},{label:"创建时间",minWidth:90,prop:"createTime",formatter:({createTime:l})=>Ue(l).format("YYYY-MM-DD HH:mm:ss")},{label:"操作",fixed:"right",width:180,slot:"operation"}],D=Le(()=>["!h-[20px]","reset-margin","!text-gray-500","dark:!text-white","dark:hover:!text-primary"]),v=F({newPwd:""}),m=[{color:"#e74242",text:"非常弱"},{color:"#EFBD47",text:"弱"},{color:"#ffa500",text:"一般"},{color:"#1bbf1b",text:"强"},{color:"#008000",text:"非常强"}],x=A(),S=A([]);function T({row:l,index:h}){ze.confirm(`确认要<strong>${l.status===0?"停用":"启用"}</strong><strong style='color:var(--el-color-primary)'>${l.username}</strong>用户吗?`,"系统提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning",dangerouslyUseHTMLString:!0,draggable:!0}).then(()=>{o.value[h]=Object.assign({},o.value[h],{loading:!0}),setTimeout(()=>{o.value[h]=Object.assign({},o.value[h],{loading:!1}),O("已成功修改用户状态",{type:"success"})},300)}).catch(()=>{l.status===0?l.status=1:l.status=0})}function U(l){}function z(l){O(`您删除了用户编号为${l.id}的这条数据`,{type:"success"}),C()}function P(l){}function j(l){}function xe(l){y.value=l.length,r.value.setAdaptive()}function ke(){y.value=0,r.value.getTableRef().clearSelection()}function Se(){const l=r.value.getTableRef().getSelectionRows();O(`已删除用户编号为 ${We(l,"id")} 的数据`,{type:"success"}),r.value.getTableRef().clearSelection()}async function C(){i.value=!0;const{data:l}=await Qe($e(t));a.value=l.list,g.total=l.total,g.pageSize=l.pageSize,g.currentPage=l.currentPage,setTimeout(()=>{i.value=!1},500)}const Ee=l=>{l&&(l.resetFields(),t.deptId="",e.value.onTreeReset(),C())};function De({id:l,selected:h}){t.deptId=h?l:"",C()}function K(l){if(!l||!l.length)return;const h=[];for(let k=0;k<l.length;k++)l[k].disabled=l[k].status===0,K(l[k].children),h.push(l[k]);return h}function Te(l="新增",h){W({title:`${l}用户`,props:{formInline:{title:l,higherDeptOptions:K(f.value),parentId:(h==null?void 0:h.dept.id)??0,nickname:(h==null?void 0:h.nickname)??"",username:(h==null?void 0:h.username)??"",password:(h==null?void 0:h.password)??"",phone:(h==null?void 0:h.phone)??"",email:(h==null?void 0:h.email)??"",sex:(h==null?void 0:h.sex)??"",status:(h==null?void 0:h.status)??1,remark:(h==null?void 0:h.remark)??""}},width:"46%",draggable:!0,fullscreenIcon:!0,closeOnClickModal:!1,contentRenderer:()=>G(Ve,{ref:s}),beforeSure:(k,{options:w})=>{const Ce=s.value.getRef(),we=w.props.formInline;function J(){O(`您${l}了用户名称为${we.username}的这条数据`,{type:"success"}),k(),C()}Ce.validate(Pe=>{Pe&&J()})}})}function Ae(l){W({title:"裁剪、上传头像",width:"40%",draggable:!0,closeOnClickModal:!1,contentRenderer:()=>G(Ze,{imgSrc:l.avatar,onCropper:h=>c.value=h}),beforeSure:h=>{h(),C()}})}je(v,({newPwd:l})=>x.value=_e(l)?-1:gs(l).score);function Ie(l){W({title:`重置 ${l.username} 用户的密码`,width:"30%",draggable:!0,closeOnClickModal:!1,contentRenderer:()=>I(qe,null,[I(Fe,{ref:n,model:v},{default:()=>[I(Ye,{prop:"newPwd",rules:[{required:!0,message:"请输入新密码",trigger:"blur"}]},{default:()=>[I(Ge,{clearable:!0,"show-password":!0,type:"password",modelValue:v.newPwd,"onUpdate:modelValue":h=>v.newPwd=h,placeholder:"请输入新密码"},null)]})]}),I("div",{class:"mt-4 flex"},[m.map(({color:h,text:k},w)=>I("div",{class:"w-[19vw]",style:{marginLeft:w!==0?"4px":0}},[I(He,{striped:!0,"striped-flow":!0,duration:x.value===w?6:0,percentage:x.value>=w?100:0,color:h,"stroke-width":10,"show-text":!1},null),I("p",{class:"text-center",style:{color:x.value===w?h:""}},[k])]))])]),closeCallBack:()=>v.newPwd="",beforeSure:h=>{n.value.validate(k=>{k&&(O(`已成功重置 ${l.username} 用户的密码`,{type:"success"}),h(),C())})}})}async function Re(l){const h=(await et({userId:l.id})).data??[];W({title:`分配 ${l.username} 用户的角色`,props:{formInline:{username:(l==null?void 0:l.username)??"",nickname:(l==null?void 0:l.nickname)??"",roleOptions:S.value??[],ids:h}},width:"400px",draggable:!0,fullscreenIcon:!0,closeOnClickModal:!1,contentRenderer:()=>G(Be),beforeSure:(k,{options:w})=>{w.props.formInline,k()}})}return Oe(async()=>{b.value=!0,C();const{data:l}=await Ke();f.value=Q(l),p.value=Q(l),b.value=!1,S.value=(await Je()).data}),{form:t,loading:i,columns:M,dataList:a,treeData:p,treeLoading:b,selectedNum:y,pagination:g,buttonClass:D,onSearch:C,resetForm:Ee,onbatchDel:Se,openDialog:Te,onTreeSelect:De,handleUpdate:U,handleDelete:z,handleUpload:Ae,handleReset:Ie,handleRole:Re,handleSizeChange:P,onSelectionCancel:ke,handleCurrentChange:j,handleSelectionChange:xe}}export{Es as useUser};
|