"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _htmlparser2 = require('htmlparser2');var j={lowerCaseTags:!1,lowerCaseAttributeNames:!1,decodeEntities:!1},O=[{name:"!doctype",start:"<",end:">"}],v=(p,f={})=>{let s=[],r=[];function i(){return s[s.length-1]}function l(e,t){return e.name instanceof RegExp?new RegExp(e.name.source,"i").test(t):t===e.name}function g(e){let t={};return Object.keys(e).forEach(n=>{let o={};o[n]=e[n].replace(/&quot;/g,'"'),Object.assign(t,o)}),t}function b(e,t){var a;let n=O.concat((a=f.directives)!=null?a:[]),o=i();for(let c of n){let d=c.start+t+c.end;if(l(c,e.toLowerCase())){if(o===void 0){r.push(d);return}typeof o=="object"&&(o.content===void 0&&(o.content=[]),o.content.push(d))}}}function h(e){let t=`<!--${e}-->`,n=i();if(n===void 0){r.push(t);return}typeof n=="object"&&(n.content===void 0&&(n.content=[]),n.content.push(t))}function m(e,t){let n={tag:e};Object.keys(t).length>0&&(n.attrs=g(t)),s.push(n)}function N(){let e=s.pop();if(e){let t=i();if(s.length<=0){r.push(e);return}typeof t=="object"&&(t.content===void 0&&(t.content=[]),t.content.push(e))}}function y(e){let t=i();if(t===void 0){r.push(e);return}if(typeof t=="object"){if(t.content&&t.content.length>0){let n=t.content[t.content.length-1];if(typeof n=="string"){t.content[t.content.length-1]=`${n}${e}`;return}}t.content===void 0&&(t.content=[]),t.content.push(e)}}let u=new (0, _htmlparser2.Parser)({onprocessinginstruction:b,oncomment:h,onopentag:m,onclosetag:N,ontext:y},{...j,...f});return u.write(p),u.end(),r},w= exports.default =v;exports.default = w;
