import{h as S}from"./vendor-html-void-elements-CkdplsNl.js";import{s as w,f as A,h as O}from"./vendor-property-information-rJCbAzvX.js";import{z as q}from"./vendor-zwitch-C2o2j-tx.js";import{s as m}from"./vendor-stringify-entities-CsH1VEn9.js";import{c as N}from"./vendor-ccount-c2V3InAJ.js";import{s as D}from"./vendor-comma-separated-tokens-D8TqSuIK.js";import{s as R}from"./vendor-space-separated-tokens-DD3iYX1K.js";import{w as p}from"./vendor-hast-util-whitespace-D4Wp6AEg.js";const j=/^>|^->|<!--|-->|--!>|<!-$/g,B=[">"],v=["<",">"];function $(n,s,e,t){return t.settings.bogusComments?"<?"+m(n.value,Object.assign({},t.settings.characterReferences,{subset:B}))+">":"<!--"+n.value.replace(j,o)+"-->";function o(r){return m(r,Object.assign({},t.settings.characterReferences,{subset:v}))}}function k(n,s,e,t){return"<!"+(t.settings.upperDoctype?"DOCTYPE":"doctype")+(t.settings.tightDoctype?"":" ")+"html>"}const i=C(1),x=C(-1),L=[];function C(n){return s;function s(e,t,o){const r=e?e.children:L;let c=(t||0)+n,a=r[c];if(!o)for(;a&&p(a);)c+=n,a=r[c];return a}}const P={}.hasOwnProperty;function _(n){return s;function s(e,t,o){return P.call(n,e.tagName)&&n[e.tagName](e,t,o)}}const h=_({body:H,caption:f,colgroup:f,dd:V,dt:I,head:f,html:z,li:U,optgroup:Y,option:F,p:T,rp:y,rt:y,tbody:J,td:b,tfoot:K,th:b,thead:G,tr:M});function f(n,s,e){const t=i(e,s,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&p(t.value.charAt(0)))}function z(n,s,e){const t=i(e,s);return!t||t.type!=="comment"}function H(n,s,e){const t=i(e,s);return!t||t.type!=="comment"}function T(n,s,e){const t=i(e,s);return t?t.type==="element"&&(t.tagName==="address"||t.tagName==="article"||t.tagName==="aside"||t.tagName==="blockquote"||t.tagName==="details"||t.tagName==="div"||t.tagName==="dl"||t.tagName==="fieldset"||t.tagName==="figcaption"||t.tagName==="figure"||t.tagName==="footer"||t.tagName==="form"||t.tagName==="h1"||t.tagName==="h2"||t.tagName==="h3"||t.tagName==="h4"||t.tagName==="h5"||t.tagName==="h6"||t.tagName==="header"||t.tagName==="hgroup"||t.tagName==="hr"||t.tagName==="main"||t.tagName==="menu"||t.tagName==="nav"||t.tagName==="ol"||t.tagName==="p"||t.tagName==="pre"||t.tagName==="section"||t.tagName==="table"||t.tagName==="ul"):!e||!(e.type==="element"&&(e.tagName==="a"||e.tagName==="audio"||e.tagName==="del"||e.tagName==="ins"||e.tagName==="map"||e.tagName==="noscript"||e.tagName==="video"))}function U(n,s,e){const t=i(e,s);return!t||t.type==="element"&&t.tagName==="li"}function I(n,s,e){const t=i(e,s);return!!(t&&t.type==="element"&&(t.tagName==="dt"||t.tagName==="dd"))}function V(n,s,e){const t=i(e,s);return!t||t.type==="element"&&(t.tagName==="dt"||t.tagName==="dd")}function y(n,s,e){const t=i(e,s);return!t||t.type==="element"&&(t.tagName==="rp"||t.tagName==="rt")}function Y(n,s,e){const t=i(e,s);return!t||t.type==="element"&&t.tagName==="optgroup"}function F(n,s,e){const t=i(e,s);return!t||t.type==="element"&&(t.tagName==="option"||t.tagName==="optgroup")}function G(n,s,e){const t=i(e,s);return!!(t&&t.type==="element"&&(t.tagName==="tbody"||t.tagName==="tfoot"))}function J(n,s,e){const t=i(e,s);return!t||t.type==="element"&&(t.tagName==="tbody"||t.tagName==="tfoot")}function K(n,s,e){return!i(e,s)}function M(n,s,e){const t=i(e,s);return!t||t.type==="element"&&t.tagName==="tr"}function b(n,s,e){const t=i(e,s);return!t||t.type==="element"&&(t.tagName==="td"||t.tagName==="th")}const Q=_({body:Z,colgroup:tt,head:X,html:W,tbody:et});function W(n){const s=i(n,-1);return!s||s.type!=="comment"}function X(n){const s=new Set;for(const t of n.children)if(t.type==="element"&&(t.tagName==="base"||t.tagName==="title")){if(s.has(t.tagName))return!1;s.add(t.tagName)}const e=n.children[0];return!e||e.type==="element"}function Z(n){const s=i(n,-1,!0);return!s||s.type!=="comment"&&!(s.type==="text"&&p(s.value.charAt(0)))&&!(s.type==="element"&&(s.tagName==="meta"||s.tagName==="link"||s.tagName==="script"||s.tagName==="style"||s.tagName==="template"))}function tt(n,s,e){const t=x(e,s),o=i(n,-1,!0);return e&&t&&t.type==="element"&&t.tagName==="colgroup"&&h(t,e.children.indexOf(t),e)?!1:!!(o&&o.type==="element"&&o.tagName==="col")}function et(n,s,e){const t=x(e,s),o=i(n,-1);return e&&t&&t.type==="element"&&(t.tagName==="thead"||t.tagName==="tbody")&&h(t,e.children.indexOf(t),e)?!1:!!(o&&o.type==="element"&&o.tagName==="tr")}const u={name:[[`	
\f\r &/=>`.split(""),`	
\f\r "&'/=>\``.split("")],[`\0	
\f\r "&'/<=>`.split(""),`\0	
\f\r "&'/<=>\``.split("")]],unquoted:[[`	
\f\r &>`.split(""),`\0	
\f\r "&'<=>\``.split("")],[`\0	
\f\r "&'<=>\``.split(""),`\0	
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function nt(n,s,e,t){const o=t.schema,r=o.space==="svg"?!1:t.settings.omitOptionalTags;let c=o.space==="svg"?t.settings.closeEmptyElements:t.settings.voids.includes(n.tagName.toLowerCase());const a=[];let l;o.space==="html"&&n.tagName==="svg"&&(t.schema=w);const g=st(t,n.properties),d=t.all(o.space==="html"&&n.tagName==="template"?n.content:n);return t.schema=o,d&&(c=!1),(g||!r||!Q(n,s,e))&&(a.push("<",n.tagName,g?" "+g:""),c&&(o.space==="svg"||t.settings.closeSelfClosing)&&(l=g.charAt(g.length-1),(!t.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&a.push(" "),a.push("/")),a.push(">")),a.push(d),!c&&(!r||!h(n,s,e))&&a.push("</"+n.tagName+">"),a.join("")}function st(n,s){const e=[];let t=-1,o;if(s){for(o in s)if(s[o]!==null&&s[o]!==void 0){const r=ot(n,o,s[o]);r&&e.push(r)}}for(;++t<e.length;){const r=n.settings.tightAttributes?e[t].charAt(e[t].length-1):void 0;t!==e.length-1&&r!=='"'&&r!=="'"&&(e[t]+=" ")}return e.join("")}function ot(n,s,e){const t=A(n.schema,s),o=n.settings.allowParseErrors&&n.schema.space==="html"?0:1,r=n.settings.allowDangerousCharacters?0:1;let c=n.quote,a;if(t.overloadedBoolean&&(e===t.attribute||e==="")?e=!0:(t.boolean||t.overloadedBoolean)&&(typeof e!="string"||e===t.attribute||e==="")&&(e=!!e),e==null||e===!1||typeof e=="number"&&Number.isNaN(e))return"";const l=m(t.attribute,Object.assign({},n.settings.characterReferences,{subset:u.name[o][r]}));return e===!0||(e=Array.isArray(e)?(t.commaSeparated?D:R)(e,{padLeft:!n.settings.tightCommaSeparatedLists}):String(e),n.settings.collapseEmptyAttributes&&!e)?l:(n.settings.preferUnquoted&&(a=m(e,Object.assign({},n.settings.characterReferences,{attribute:!0,subset:u.unquoted[o][r]}))),a!==e&&(n.settings.quoteSmart&&N(e,c)>N(e,n.alternative)&&(c=n.alternative),a=c+m(e,Object.assign({},n.settings.characterReferences,{subset:(c==="'"?u.single:u.double)[o][r],attribute:!0}))+c),l+(a&&"="+a))}const at=["<","&"];function E(n,s,e,t){return e&&e.type==="element"&&(e.tagName==="script"||e.tagName==="style")?n.value:m(n.value,Object.assign({},t.settings.characterReferences,{subset:at}))}function it(n,s,e,t){return t.settings.allowDangerousHtml?n.value:E(n,s,e,t)}function rt(n,s,e,t){return t.all(n)}const ct=q("type",{invalid:lt,unknown:mt,handlers:{comment:$,doctype:k,element:nt,raw:it,root:rt,text:E}});function lt(n){throw new Error("Expected node, not `"+n+"`")}function mt(n){const s=n;throw new Error("Cannot compile unknown node `"+s.type+"`")}const gt={},ut={},ft=[];function Et(n,s){const e=s||gt,t=e.quote||'"',o=t==='"'?"'":'"';if(t!=='"'&&t!=="'")throw new Error("Invalid quote `"+t+"`, expected `'` or `\"`");return{one:pt,all:ht,settings:{omitOptionalTags:e.omitOptionalTags||!1,allowParseErrors:e.allowParseErrors||!1,allowDangerousCharacters:e.allowDangerousCharacters||!1,quoteSmart:e.quoteSmart||!1,preferUnquoted:e.preferUnquoted||!1,tightAttributes:e.tightAttributes||!1,upperDoctype:e.upperDoctype||!1,tightDoctype:e.tightDoctype||!1,bogusComments:e.bogusComments||!1,tightCommaSeparatedLists:e.tightCommaSeparatedLists||!1,tightSelfClosing:e.tightSelfClosing||!1,collapseEmptyAttributes:e.collapseEmptyAttributes||!1,allowDangerousHtml:e.allowDangerousHtml||!1,voids:e.voids||S,characterReferences:e.characterReferences||ut,closeSelfClosing:e.closeSelfClosing||!1,closeEmptyElements:e.closeEmptyElements||!1},schema:e.space==="svg"?w:O,quote:t,alternative:o}.one(Array.isArray(n)?{type:"root",children:n}:n,void 0,void 0)}function pt(n,s,e){return ct(n,s,e,this)}function ht(n){const s=[],e=n&&n.children||ft;let t=-1;for(;++t<e.length;)s[t]=this.one(e[t],t,n);return s.join("")}export{Et as t};
