!function(a,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((a="undefined"!=typeof globalThis?globalThis:a||self).tldts={})}(this,(function(a){"use strict";const e=/[\t\n\r]/g;let o=!1;function i(a){return a>=97&&a<=122||a>=48&&a<=57||a>127||a>=65&&a<=90||45===a||95===a}function n(a,e,o){const i=o-e,n=32|a.charCodeAt(e);if(2===i)return 119===n&&115==(32|a.charCodeAt(e+1))?1:0;if(3===i){const o=32|a.charCodeAt(e+1),i=32|a.charCodeAt(e+2);return 119===n&&115===o&&115===i||102===n&&116===o&&112===i?1:0}if(4===i){const o=32|a.charCodeAt(e+1),i=32|a.charCodeAt(e+2),s=32|a.charCodeAt(e+3);return 104===n&&116===o&&116===i&&112===s?1:102===n&&105===o&&108===i&&101===s?2:0}return 5===i&&104===n&&116==(32|a.charCodeAt(e+1))&&116==(32|a.charCodeAt(e+2))&&112==(32|a.charCodeAt(e+3))&&115==(32|a.charCodeAt(e+4))?1:0}function s(a,t,r=!1){let u=0,l=a.length,m=!1,c=!1;if(o=!1,!t){if(a.startsWith("data:"))return null;for(;uu+1&&a.charCodeAt(l-1)<=32;)l-=1;if(47===a.charCodeAt(u)&&47===a.charCodeAt(u+1))u+=2;else{const o=a.indexOf(":/",u);if(-1!==o){const i=n(a,u,o);if(1===i)for(c=!0,u=o+2;47===a.charCodeAt(u)||92===a.charCodeAt(u);)u+=1;else if(2===i){c=!0,u=o+1;let e=0;for(;(47===a.charCodeAt(u)||92===a.charCodeAt(u))&&e<2;)u+=1,e+=1;if(e<2)return null}else{for(let i=u;i=97&&o<=122||o>=48&&o<=57||46===o||45===o||43===o)){const o=a.charCodeAt(i);return 9===o||10===o||13===o?s(a.replace(e,""),t,r):null}}if(47!==a.charCodeAt(o+2))return null;u=o+3}}else if(91!==a.charCodeAt(u)){let o=-1;for(let i=u;i57){e=!1;break}}if(i===o+1&&(e=!1),!e){const e=n(a,u,o);if(0===e){let e=!1;for(let i=o+1;i64||46===f||45===f)&&(b=!1),y=e):(o<48||o>57)&&(45===o&&46!==f||(b=!1)))}else{if(c&&92===o){l=e;break}64===o?(d=e,k=-1):93===o?h=e:o>=65&&o<=90?m=!0:r&&!function(a){return a>=97&&a<=122||a>=48&&a<=57||a>127||a>=65&&a<=90||45===a||95===a}(o)&&(b=!1)}r&&(f=o)}if(p)return s(a.replace(e,""),t,r);if(-1!==d&&d>=u&&du&&g=l)return null;r&&b&&-1===d&&-1===g&&-1===h&&46!==a.charCodeAt(l-1)&&l-u<=255&&l-y-1<=63&&45!==f&&(o=!0)}for(;l>u+1&&46===a.charCodeAt(l-1);)l-=1;const d=0!==u||l!==a.length?a.slice(u,l):a;return m?d.toLowerCase():d}const t=["test","localhost","invalid","example","example.com","example.net","example.org","local","onion","alt","home.arpa","ipv4only.arpa","resolver.arpa","service.arpa","6tisch.arpa","eap.arpa"];function r(a){return a>=97&&a<=122||a>=48&&a<=57||a>127}function u(a){if(a.length>255)return!1;if(0===a.length)return!1;if(!r(a.charCodeAt(0))&&46!==a.charCodeAt(0)&&95!==a.charCodeAt(0))return!1;let e=-1,o=-1;const i=a.length;for(let n=0;n64||46===o||45===o)return!1;e=n}else if(!r(i)&&45!==i&&95!==i||45===i&&46===o)return!1;o=i}return i-e-1<=63&&45!==o}const l=function({allowIcannDomains:a=!0,allowPrivateDomains:e=!1,detectIp:o=!0,detectSpecialUse:i=!1,extractHostname:n=!0,mixedInputs:s=!0,validHosts:t=null,validateHostname:r=!0}){return{allowIcannDomains:a,allowPrivateDomains:e,detectIp:o,detectSpecialUse:i,extractHostname:n,mixedInputs:s,validHosts:t,validateHostname:r}}({});function m(a,e,i,n,r){const m=function(a){return void 0===a?l:function({allowIcannDomains:a=!0,allowPrivateDomains:e=!1,detectIp:o=!0,detectSpecialUse:i=!1,extractHostname:n=!0,mixedInputs:s=!0,validHosts:t=null,validateHostname:r=!0}){return{allowIcannDomains:a,allowPrivateDomains:e,detectIp:o,detectSpecialUse:i,extractHostname:n,mixedInputs:s,validHosts:t,validateHostname:r}}(a)}(n);if("string"!=typeof a)return r;let c=!1;return m.extractHostname?m.mixedInputs?(c=u(a),r.hostname=s(a,c,m.validateHostname)):r.hostname=s(a,!1,m.validateHostname):r.hostname=a,m.detectIp&&null!==r.hostname&&(r.isIp=function(a){if(a.length<3)return!1;let e=a.startsWith("[")?1:0,o=a.length;if("]"===a[o-1]&&(o-=1),o-e>39)return!1;let i=!1;for(;e=48&&o<=57||o>=97&&o<=102||o>=65&&o<=70))return!1}return i}(d=r.hostname)||function(a){if(a.length<7)return!1;if(a.length>15)return!1;let e=0;for(let o=0;o57)return!1}return 3===e&&46!==a.charCodeAt(0)&&46!==a.charCodeAt(a.length-1)}(d),r.isIp)?r:!m.validateHostname||!m.extractHostname||null===r.hostname||c&&r.hostname===a||o||u(r.hostname)?0===e||null===r.hostname?r:(5===e&&m.detectSpecialUse&&(r.isSpecialUse=function(a){for(const e of t)if(a.endsWith(e)&&(a.length===e.length||46===a.charCodeAt(a.length-e.length-1)))return!0;return!1}(r.hostname)),i(r.hostname,m,r),2===e||null===r.publicSuffix?r:(r.domain=function(a,e,o){if(null!==o.validHosts){const a=o.validHosts;for(const o of a)if(function(a,e){return!!a.endsWith(e)&&(a.length===e.length||"."===a[a.length-e.length-1])}(e,o))return o}let i=0;if(e.startsWith("."))for(;i=e;a-=1)n=33*n^k.charCodeAt(a);w[o]=n>>>0,1===h[o]&&42===k.charCodeAt(e)&&(x[a]=o),e=i}let z=-1,j=0,q=0;function A(a,e,o,i){if(h[a]!==i)return!1;const n=v[a];for(let a=0;a>>1,r=w[a];if(re)){for(let t=a;t>=s&&w[t]===e;t-=1)if(A(t,o,i,n))return t;for(let s=a+1;s=0;e-=1){const t=a.charCodeAt(e);if(46===t){const t=e+1;let r=C(i,s>>>0,a,t,n-t);if(-1===r&&(r=x[i]),-1===r)return-1!==z;i=g[r],c[i]&o&&(z=i,j=t,q=n),n=e,s=5381}else s=33*s^t}let t=C(i,s>>>0,a,0,n);return-1===t&&(t=x[i]),-1!==t&&(i=g[t],c[i]&o&&(z=i,j=0,q=n)),-1!==z}function I(a,e,o){if(function(a,e,o){if(!e.allowPrivateDomains&&a.length>3){const e=a.length-1,i=a.charCodeAt(e),n=a.charCodeAt(e-1),s=a.charCodeAt(e-2),t=a.charCodeAt(e-3);if(109===i&&111===n&&99===s&&46===t)return o.isIcann=!0,o.isPrivate=!1,o.publicSuffix="com",!0;if(103===i&&114===n&&111===s&&46===t)return o.isIcann=!0,o.isPrivate=!1,o.publicSuffix="org",!0;if(117===i&&100===n&&101===s&&46===t)return o.isIcann=!0,o.isPrivate=!1,o.publicSuffix="edu",!0;if(118===i&&111===n&&103===s&&46===t)return o.isIcann=!0,o.isPrivate=!1,o.publicSuffix="gov",!0;if(116===i&&101===n&&110===s&&46===t)return o.isIcann=!0,o.isPrivate=!1,o.publicSuffix="net",!0;if(101===i&&100===n&&46===s)return o.isIcann=!0,o.isPrivate=!1,o.publicSuffix="de",!0}return!1}(a,e,o))return;const i=(e.allowPrivateDomains?2:0)|(e.allowIcannDomains?1:0);if(S(a,b,i))return o.isIcann=!!(1&c[z]),o.isPrivate=!!(2&c[z]),void(o.publicSuffix=a.slice(q+1));if(S(a,p,i))return o.isIcann=!!(1&c[z]),o.isPrivate=!!(2&c[z]),void(o.publicSuffix=a.slice(j));o.isIcann=!1,o.isPrivate=!1;const n=a.lastIndexOf(".");o.publicSuffix=-1===n?a:a.slice(n+1)}const P={domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null};a.getDomain=function(a,e){var o;return(o=P).domain=null,o.domainWithoutSuffix=null,o.hostname=null,o.isIcann=null,o.isIp=null,o.isPrivate=null,o.isSpecialUse=null,o.publicSuffix=null,o.subdomain=null,m(a,3,I,e,P).domain},a.getDomainWithoutSuffix=function(a,e){var o;return(o=P).domain=null,o.domainWithoutSuffix=null,o.hostname=null,o.isIcann=null,o.isIp=null,o.isPrivate=null,o.isSpecialUse=null,o.publicSuffix=null,o.subdomain=null,m(a,5,I,e,P).domainWithoutSuffix},a.getFullDomain=function(a,e){!function(a){a.domain=null,a.domainWithoutSuffix=null,a.hostname=null,a.isIcann=null,a.isIp=null,a.isPrivate=null,a.isSpecialUse=null,a.publicSuffix=null,a.subdomain=null}(P);const o=m(a,3,I,e,P);return null===o.domain?null:o.hostname},a.getHostname=function(a,e){var o;return(o=P).domain=null,o.domainWithoutSuffix=null,o.hostname=null,o.isIcann=null,o.isIp=null,o.isPrivate=null,o.isSpecialUse=null,o.publicSuffix=null,o.subdomain=null,m(a,0,I,e,P).hostname},a.getPublicSuffix=function(a,e){var o;return(o=P).domain=null,o.domainWithoutSuffix=null,o.hostname=null,o.isIcann=null,o.isIp=null,o.isPrivate=null,o.isSpecialUse=null,o.publicSuffix=null,o.subdomain=null,m(a,2,I,e,P).publicSuffix},a.getSubdomain=function(a,e){var o;return(o=P).domain=null,o.domainWithoutSuffix=null,o.hostname=null,o.isIcann=null,o.isIp=null,o.isPrivate=null,o.isSpecialUse=null,o.publicSuffix=null,o.subdomain=null,m(a,4,I,e,P).subdomain},a.parse=function(a,e){return m(a,5,I,e,{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null})}})); //# sourceMappingURL=index.umd.min.js.map