Module 228785

2,250 characters · in 514.d733764d42c2ab66.js
Dependencies
Required by (1)
Lazily required by (0)none
Requires (0)none
Lazily requires (0)none
Source Raw
function(e){"use strict";let t=/^xn--/,n=/[^\0-\x7E]/,r=/[\x2E\u3002\uFF0E\uFF61]/g,i={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},a=Math.floor,o=String.fromCharCode;function s(e){throw RangeError(i[e])}function l(e,t){let n=e.split("@"),i="";return n.length>1&&(i=n[0]+"@",e=n[1]),i+(function(e,t){let n=[],r=e.length;for(;r--;)n[r]=t(e[r]);return n})((e=e.replace(r,".")).split("."),t).join(".")}function u(e){let t=[],n=0,r=e.length;for(;n<r;){let i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){let r=e.charCodeAt(n++);(64512&r)==56320?t.push(((1023&i)<<10)+(1023&r)+65536):(t.push(i),n--)}else t.push(i)}return t}let c=function(e,t){return e+22+75*(e<26)-((0!=t)<<5)},d=function(e,t,n){let r=0;for(e=n?a(e/700):e>>1,e+=a(e/t);e>455;r+=36)e=a(e/35);return a(r+36*e/(e+38))},f=function(e){let t=[],n=e.length,r=0,i=128,o=72,l=e.lastIndexOf("-");l<0&&(l=0);for(let n=0;n<l;++n)e.charCodeAt(n)>=128&&s("not-basic"),t.push(e.charCodeAt(n));for(let c=l>0?l+1:0;c<n;){let l=r;for(let t=1,i=36;;i+=36){var u;c>=n&&s("invalid-input");let l=(u=e.charCodeAt(c++))-48<10?u-22:u-65<26?u-65:u-97<26?u-97:36;(l>=36||l>a((0x7fffffff-r)/t))&&s("overflow"),r+=l*t;let d=i<=o?1:i>=o+26?26:i-o;if(l<d)break;let f=36-d;t>a(0x7fffffff/f)&&s("overflow"),t*=f}let f=t.length+1;o=d(r-l,f,0==l),a(r/f)>0x7fffffff-i&&s("overflow"),i+=a(r/f),r%=f,t.splice(r++,0,i)}return String.fromCodePoint(...t)},p=function(e){let t=[],n=(e=u(e)).length,r=128,i=0,l=72;for(let n of e)n<128&&t.push(o(n));let f=t.length,p=f;for(f&&t.push("-");p<n;){let n=0x7fffffff;for(let t of e)t>=r&&t<n&&(n=t);let u=p+1;for(let h of(n-r>a((0x7fffffff-i)/u)&&s("overflow"),i+=(n-r)*u,r=n,e))if(h<r&&++i>0x7fffffff&&s("overflow"),h==r){let e=i;for(let n=36;;n+=36){let r=n<=l?1:n>=l+26?26:n-l;if(e<r)break;let i=e-r,s=36-r;t.push(o(c(r+i%s,0))),e=a(i/s)}t.push(o(c(e,0))),l=d(i,u,p==f),i=0,++p}++i,++r}return t.join("")};e.exports={version:"2.1.0",ucs2:{decode:u,encode:e=>String.fromCodePoint(...e)},decode:f,encode:p,toASCII:function(e){return l(e,function(e){return n.test(e)?"xn--"+p(e):e})},toUnicode:function(e){return l(e,function(e){return t.test(e)?f(e.slice(4).toLowerCase()):e})}}}