const A="-",j=/^xn--/,k=/[^\0-\x7F]/,O=/[\x2E\u3002\uFF0E\uFF61]/g,L={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=35,l=Math.floor,C=String.fromCharCode;function p(o){throw new RangeError(L[o])}function M(o,n){const r=[];let e=o.length;for(;e--;)r[e]=n(o[e]);return r}function F(o,n){const r=o.split("@");let e="";r.length>1&&(e=r[0]+"@",o=r[1]),o=o.replace(O,".");const t=o.split("."),c=M(t,n).join(".");return e+c}function I(o){const n=[];let r=0;const e=o.length;for(;r<e;){const t=o.charCodeAt(r++);if(t>=55296&&t<=56319&&r<e){const c=o.charCodeAt(r++);(c&64512)==56320?n.push(((t&1023)<<10)+(c&1023)+65536):(n.push(t),r--)}else n.push(t)}return n}const P=o=>String.fromCodePoint(...o),B=function(o){return o>=48&&o<58?26+(o-48):o>=65&&o<91?o-65:o>=97&&o<123?o-97:36},b=function(o,n){return o+22+75*(o<26)-((n!=0)<<5)},S=function(o,n,r){let e=0;for(o=r?l(o/700):o>>1,o+=l(o/n);o>w*26>>1;e+=36)o=l(o/w);return l(e+(w+1)*o/(o+38))},m=function(o){const n=[],r=o.length;let e=0,t=128,c=72,u=o.lastIndexOf(A);u<0&&(u=0);for(let s=0;s<u;++s)o.charCodeAt(s)>=128&&p("not-basic"),n.push(o.charCodeAt(s));for(let s=u>0?u+1:0;s<r;){const i=e;for(let f=1,a=36;;a+=36){s>=r&&p("invalid-input");const h=B(o.charCodeAt(s++));h>=36&&p("invalid-input"),h>l((2147483647-e)/f)&&p("overflow"),e+=h*f;const g=a<=c?1:a>=c+26?26:a-c;if(h<g)break;const v=36-g;f>l(2147483647/v)&&p("overflow"),f*=v}const d=n.length+1;c=S(e-i,d,i==0),l(e/d)>2147483647-t&&p("overflow"),t+=l(e/d),e%=d,n.splice(e++,0,t)}return String.fromCodePoint(...n)},E=function(o){const n=[];o=I(o);const r=o.length;let e=128,t=0,c=72;for(const i of o)i<128&&n.push(C(i));const u=n.length;let s=u;for(u&&n.push(A);s<r;){let i=2147483647;for(const f of o)f>=e&&f<i&&(i=f);const d=s+1;i-e>l((2147483647-t)/d)&&p("overflow"),t+=(i-e)*d,e=i;for(const f of o)if(f<e&&++t>2147483647&&p("overflow"),f===e){let a=t;for(let h=36;;h+=36){const g=h<=c?1:h>=c+26?26:h-c;if(a<g)break;const v=a-g,x=36-g;n.push(C(b(g+v%x,0))),a=l(v/x)}n.push(C(b(a,0))),c=S(t,d,s===u),t=0,++s}++t,++e}return n.join("")},D=function(o){return F(o,function(n){return j.test(n)?m(n.slice(4).toLowerCase()):n})},N=function(o){return F(o,function(n){return k.test(n)?"xn--"+E(n):n})},R={version:"2.3.1",ucs2:{decode:I,encode:P},decode:m,encode:E,toASCII:N,toUnicode:D};export{R as V};
