function e(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#039;`)}var t=new Set([`http:`,`https:`,`mailto:`]);function n(e){let t={"&amp;":`&`,"&lt;":`<`,"&gt;":`>`,"&quot;":`"`,"&#039;":`'`,"&apos;":`'`,"&nbsp;":` `,"&tab;":`	`};return e.replace(/&(?:#x([0-9a-f]+)|#(\d+)|[a-z]+);/gi,(e,n,r)=>n?String.fromCodePoint(parseInt(n,16)):r?String.fromCodePoint(parseInt(r,10)):t[e.toLowerCase()]??e)}function r(e){let r=n(e).replace(/[\s\x00-\x1f]+/g,``).toLowerCase();return!r.includes(`:`)||t.has(r.slice(0,r.indexOf(`:`)+1))}function i(e){let t=new Set(`p.br.strong.em.u.code.pre.blockquote.ul.ol.li.a.img.h1.h2.h3.h4.h5.h6.table.thead.tbody.tr.th.td.hr.del.ins`.split(`.`)),n={a:new Set([`href`,`title`]),img:new Set([`src`,`alt`,`title`])};return e=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,``),e=e.replace(/\s*on\w+\s*=\s*["'][^"']*["']/gi,``),e.replace(/<\/?([a-z][a-z0-9]*)\b([^>]*)>/gi,(e,i,a)=>{let o=i.toLowerCase();if(!t.has(o))return``;if(e.startsWith(`</`))return`</${o}>`;let s=n[o];return s?`<${o}${a.replace(/([a-z][a-z0-9-]*)\s*=\s*["']([^"']*)["']/gi,(e,t,n)=>{let i=t.toLowerCase();return!s.has(i)||(i===`href`||i===`src`)&&!r(n)?``:` ${t}="${n}"`})}>`:`<${o}>`})}export{i as n,e as t};