import{t as e}from"./rolldown-runtime-Djccxexk.js";var t=e(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BLANK_URL=e.relativeFirstCharacters=e.whitespaceEscapeCharsRegex=e.urlSchemeRegex=e.ctrlCharactersRegex=e.htmlCtrlEntityRegex=e.htmlEntitiesRegex=e.invalidProtocolRegex=void 0,e.invalidProtocolRegex=/^([^\w]*)(javascript|data|vbscript)/im,e.htmlEntitiesRegex=/&#(\w+)(^\w|;)?/g,e.htmlCtrlEntityRegex=/&(newline|tab);/gi,e.ctrlCharactersRegex=/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim,e.urlSchemeRegex=/^.+(:|&colon;)/gim,e.whitespaceEscapeCharsRegex=/(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g,e.relativeFirstCharacters=[".","/"],e.BLANK_URL="about:blank"}),r=e(e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sanitizeUrl=function(e){if(!e)return r.BLANK_URL;var t,n=i(e.trim());do{t=(n=i(n=a(n).replace(r.htmlCtrlEntityRegex,"").replace(r.ctrlCharactersRegex,"").replace(r.whitespaceEscapeCharsRegex,"").trim())).match(r.ctrlCharactersRegex)||n.match(r.htmlEntitiesRegex)||n.match(r.htmlCtrlEntityRegex)||n.match(r.whitespaceEscapeCharsRegex)}while(t&&t.length>0);var c=n;if(!c)return r.BLANK_URL;if(function(e){return r.relativeFirstCharacters.indexOf(e[0])>-1}(c))return c;var l=c.trimStart(),o=l.match(r.urlSchemeRegex);if(!o)return c;var s=o[0].toLowerCase().trim();if(r.invalidProtocolRegex.test(s))return r.BLANK_URL;var h=l.replace(/\\/g,"/");if("mailto:"===s||s.includes("://"))return h;if("http:"===s||"https:"===s){if(!function(e){return URL.canParse(e)}(h))return r.BLANK_URL;var u=new URL(h);return u.protocol=u.protocol.toLowerCase(),u.hostname=u.hostname.toLowerCase(),u.toString()}return h};var r=t();function a(e){return e.replace(r.ctrlCharactersRegex,"").replace(r.htmlEntitiesRegex,function(e,t){return String.fromCharCode(t)})}function i(e){try{return decodeURIComponent(e)}catch(t){return e}}});export{r as t};