1 |
- function h(t,r,e){for(var n=[],o=Math.max(t.length,r.length),i=0,s=0;s<o||i;){var l=s<t.length?t[s]:0,c=s<r.length?r[s]:0,a=i+l+c;n.push(a%e),i=Math.floor(a/e),s++}return n}function f(t,r,e){if(t<0)return null;if(t==0)return[];for(var n=[],o=r;t&1&&(n=h(n,o,e)),t=t>>1,t!==0;)o=h(o,o,e);return n}function m(t,r){for(var e=t.split(""),n=[],o=e.length-1;o>=0;o--){var i=parseInt(e[o],r);if(isNaN(i))return null;n.push(i)}return n}function p(t,r,e){var n=m(t,r);if(n===null)return null;for(var o=[],i=[1],s=0;s<n.length;s++)n[s]&&(o=h(o,f(n[s],i,e),e)),i=f(r,i,e);for(var l="",s=o.length-1;s>=0;s--)l+=o[s].toString(e);return l}function v(t){return t.substring(0,2)==="0x"&&(t=t.substring(2)),t=t.toLowerCase(),p(t,16,10)}class d{constructor(r){r=r||{},this.seq=0,this.mid=(r.mid||1)%1023,this.offset=r.offset||0,this.lastTime=0}generate(){const r=Date.now(),e=(r-this.offset).toString(2);this.lastTime==r?(this.seq++,this.seq>4095&&(this.seq=0)):this.seq=0,this.lastTime=r;let n=this.seq.toString(2),o=this.mid.toString(2);for(;n.length<12;)n="0"+n;for(;o.length<10;)o="0"+o;const i=e+o+n;let s="";for(let l=i.length;l>0;l-=4)s=parseInt(i.substring(l-4,l),2).toString(16)+s;return v(s)}}const u=[];for(let t=0;t<=15;t++)u[t]=t.toString(16);function q(){let t="";for(let r=1;r<=36;r++)r===9||r===14||r===19||r===24?t+="-":r===15?t+=4:r===20?t+=u[Math.random()*4|8]:t+=u[Math.random()*16|0];return t.replace(/-/g,"")}let g=0;function S(t=""){const r=Date.now(),e=Math.floor(Math.random()*1e9);return g++,t+"_"+e+g+String(r)}function M(t=0){const r=new d,e=[];for(let n=0;n<t;n++)e.push(r.generate());return t?e:r.generate()}export{M as a,q as b,S as c};
|