diff --git a/asset-manifest.json b/asset-manifest.json index 492ce9c5..2dbea5e1 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,13 +1,13 @@ { "files": { "main.css": "/hotkeys-js/static/css/main.ff7ef0b5.css", - "main.js": "/hotkeys-js/static/js/main.4c74d204.js", + "main.js": "/hotkeys-js/static/js/main.8885eea2.js", "refractor-vendor.js": "/hotkeys-js/static/js/refractor-vendor.f1950cb6.js", "react-vendor.js": "/hotkeys-js/static/js/react-vendor.9808e2f4.js", "static/media/bg.jpg": "/hotkeys-js/static/media/bg.c118c911b775de37ecf2.jpg", "index.html": "/hotkeys-js/index.html", "main.ff7ef0b5.css.map": "/hotkeys-js/static/css/main.ff7ef0b5.css.map", - "main.4c74d204.js.map": "/hotkeys-js/static/js/main.4c74d204.js.map", + "main.8885eea2.js.map": "/hotkeys-js/static/js/main.8885eea2.js.map", "refractor-vendor.f1950cb6.js.map": "/hotkeys-js/static/js/refractor-vendor.f1950cb6.js.map", "react-vendor.9808e2f4.js.map": "/hotkeys-js/static/js/react-vendor.9808e2f4.js.map" }, @@ -15,6 +15,6 @@ "static/js/refractor-vendor.f1950cb6.js", "static/js/react-vendor.9808e2f4.js", "static/css/main.ff7ef0b5.css", - "static/js/main.4c74d204.js" + "static/js/main.8885eea2.js" ] } \ No newline at end of file diff --git a/index.html b/index.html index 39303cd7..f95e310c 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -hotkeys.js - A robust Javascript library for capturing keyboard input.
\ No newline at end of file +hotkeys.js - A robust Javascript library for capturing keyboard input.
\ No newline at end of file diff --git a/static/js/main.4c74d204.js b/static/js/main.8885eea2.js similarity index 99% rename from static/js/main.4c74d204.js rename to static/js/main.8885eea2.js index 57b51549..42ef76b1 100644 --- a/static/js/main.4c74d204.js +++ b/static/js/main.8885eea2.js @@ -1,3 +1,3 @@ -/*! For license information please see main.4c74d204.js.LICENSE.txt */ -(()=>{var e={4680:(e,t,n)=>{"use strict";var r={};n.r(r),n.d(r,{attentionMarkers:()=>kn,contentInitial:()=>gn,disable:()=>bn,document:()=>Tn,flow:()=>_n,flowInitial:()=>An,insideSpan:()=>Cn,string:()=>Dn,text:()=>yn});var o=n(7787),i=n(6132);function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0||(o[n]=e[n]);return o}const c=document.createElement("template");c.innerHTML='\n\n\n';class l extends HTMLElement{static get observedAttributes(){return["style","z-index","target","height","width","href","color","fill","position","top","left","right","bottom","transform"]}constructor(){super(),this.right="0",this.shadow=this.attachShadow({mode:"open"}),this.shadow.appendChild(this.ownerDocument.importNode(c.content,!0)),this.update()}setAttr(e,t){const n=this.shadow.querySelector("svg");/(href)/.test(e.toLocaleLowerCase())?n.lastElementChild.setAttribute("xlink:href",t):/(color|fill)/.test(e.toLocaleLowerCase())?n.firstElementChild.style[e]=t:/(z-index|position|top|left|right|bottom|transform)/.test(e.toLocaleLowerCase())?n.style[e]=t:n.setAttribute(e,t)}update(){[...this.getAttributeNames(),"right"].forEach((e=>{const t=this.getAttribute(e)||this[e]||"";this.setAttr(e,t)}))}attributeChangedCallback(e,t,n){t!==n&&this.setAttr(e,n)}}customElements.define("github-corners",l);var u=n(2854),h=["size","fixed","bottom","zIndex","className","style","bgColor","color","position"];function p(e){var{size:t=80,fixed:n=!1,bottom:r,zIndex:o,style:i,bgColor:c="#151513",color:l="#fff",position:p="right"}=e,d=a(e,h),f="left"===p?{left:0,right:"initial",transform:"scale(-1, 1)"}:{right:0,left:"initial",transform:"scale(1, 1)"};return r?(f.bottom=0,f.top="initial",f.transform="left"===p?"scale(-1, -1)":"scale(1, -1)"):(f.bottom="initial",f.top=0),(0,u.jsx)("github-corners",s({target:"__blank",width:t,height:t,href:e.href,position:n?"fixed":"absolute","z-index":o,style:i,fill:c,color:l},f,d))}function d(e){return o.Children.toArray(e.children).map((t=>o.isValidElement(t)?o.cloneElement(t,s({},e,t.props)):null))}d.displayName="Container";var f=["href","anchor","imgSrc","platform","type","user","repo","base","children"],m=o.forwardRef(((e,t)=>{var{href:n,anchor:r={},imgSrc:o}=e,i=a(e,f);return n?(0,u.jsx)("a",s({},r,{href:n,children:(0,u.jsx)("img",s({alt:"",ref:t,src:o},i))})):(0,u.jsx)("img",s({alt:"",ref:t,src:o},i))}));m.displayName="Internal";var E=["type","platform","base","property","user","repo","label"],T=o.forwardRef(((e,t)=>{var{type:n="issues",platform:r="github",base:o="https://img.shields.io",property:i,user:c,repo:l,label:h}=e,p=a(e,E);return(0,u.jsx)(m,s({imgSrc:"github"!==r?"":"issues"===n||/^issues-(raw|closed|closed-raw|pr|pr-raw|pr-closed|pr-closed-raw)/.test(n)?h&&("issues"===n||/^issues-(raw|pr|pr-raw)/.test(n||""))?[o,r,n,c,l,h].join("/"):[o,r,n,c,l].join("/"):"issueKind"===n?[o,r,n,"detail",i,c,l].join("/"):"",ref:t},p))}));T.displayName="Issues";var g=["type","platform","base","user","repo","path"],A=o.forwardRef(((e,t)=>{var{type:n="languages",platform:r="github",base:o="https://img.shields.io",user:i,repo:c,path:l}=e,h=a(e,g);return(0,u.jsx)(m,s({imgSrc:"github"!==r?"":"languages"===n?[o,r,n,"code-size",i,c].join("/"):"repo-size"===n?[o,r,n,i,c].join("/"):"size"===n&&l?[o,r,n,i,c,l].join("/"):"",ref:t},h))}));A.displayName="Size";var _=["platform","type","base","user","repo"],D=o.forwardRef(((e,t)=>{var{platform:n="github",type:r="license",base:o="https://img.shields.io",user:i,repo:c}=e,l=a(e,_);return(0,u.jsx)(m,s({imgSrc:"github"!==n?"":[o,n,r,i,c].join("/"),ref:t},l))}));D.displayName="License";var y=["platform","type","base","user","repo","tag","path","total"],C=o.forwardRef(((e,t)=>{var{platform:n="github",type:r="downloads",base:o="https://img.shields.io",user:i,repo:c,tag:l,path:h,total:p=!0}=e,d=a(e,y);return(0,u.jsx)(m,s({imgSrc:(()=>{if("github"!==n||!/^(downloads|downloads-pre)/.test(r||""))return"";var e=[o,n,r,i,c];return h&&l?[...e,l,h].join("/"):p&&l||"downloads-pre"===r&&l&&p?[...e,l,"total"].join("/"):p?[...e,"total"].join("/"):""})(),ref:t},d))}));C.displayName="Downloads";const k=C;var b=["platform","base","type","user","repo","interval","variant","version","branch"],N=o.forwardRef(((e,t)=>{var{platform:n="github",base:r="https://img.shields.io",type:o="commits-since",user:i,repo:c,interval:l,variant:h,version:p,branch:d}=e,f=a(e,b);return(0,u.jsx)(m,s({imgSrc:"github"!==n?"":"commits-since"===o&&p&&d?[r,n,o,i,c,p,d].join("/"):"commit-activity"===o&&l?[r,n,o,l,i,c].join("/"):"variant"===o&&h?[r,n,o,h,i,c].join("/"):"last-commit"===o?d?[r,n,o,i,c,d].join("/"):[r,n,o,i,c].join("/"):o&&/^release-(date|date-pre)/.test(o)?[r,n,o,i,c].join("/"):"",ref:t},f))}));N.displayName="Activity";const S=N;var I=["platform","type","base","user","repo","branch"];const O=o.forwardRef(((e,t)=>{var{platform:n="github",type:r="version-release",base:o="https://img.shields.io",user:i,repo:c,branch:l}=e,h=a(e,I);return(0,u.jsx)(m,s({imgSrc:(()=>{var e="";switch(r){case"version-release":e="v/release";break;case"version-tag":e="v/tag";break;case"package-json":e="package-json/v";break;case"manifest-json":e="manifest-json/v";break;case"go-mod":e="go-mod/go-version"}if("github"!==n||!e)return"";var t=[o,n,e,i,c];return/(go-mod|manifest-json|package-json)/.test(r||"")&&l?[...t,l].join("/"):t.join("/")})(),ref:t},h))}));var v=["platform","type","base","user","repo","query"],R=o.forwardRef(((e,t)=>{var{platform:n="github",type:r="languages-count",base:o="https://img.shields.io",user:i,repo:c,query:l}=e,h=a(e,v);return(0,u.jsx)(m,s({imgSrc:(()=>{var e="";switch(r){case"languages-count":e="languages/count";break;case"languages-top":e="languages/top";break;case"search":e="search"}if("github"!==n||!e)return"";var t=[o,n,e,i,c];return l?[...t,l].join("/"):t.join("/")})(),ref:t},h))}));R.displayName="Analysis";const F=R;var L=["type","platform","base","user","repo"],x=o.forwardRef(((e,t)=>{var{type:n="followers",platform:r="github",base:o="https://img.shields.io",user:i,repo:c}=e,l=a(e,L);return(0,u.jsx)(m,s({imgSrc:"github"!==r?"":"followers"===n?[o,r,n,i].join("/"):[o,r,n,i,c].join("/"),ref:t},l))}));x.displayName="Social";const P=x;var M=e=>(0,u.jsx)(d,s({},e));M.Issues=T,M.Size=A,M.Downloads=k,M.License=D,M.Activity=S,M.Analysis=F,M.Version=O,M.Social=P,M.displayName="Github";const w=M;var B=["type","platform","base","user","repo"],H=o.forwardRef(((e,t)=>{var{type:n="github",platform:r="coveralls",base:o="https://img.shields.io",user:i,repo:c}=e,l=a(e,B);return(0,u.jsx)(m,s({imgSrc:"coveralls"!==r?"":[o,r,n,i,c].join("/"),ref:t},l))}));H.displayName="Coverages";const U=H;var G=["platform","base","projectId","branch"],j=o.forwardRef(((e,t)=>{var{platform:n="coveralls",base:r="https://img.shields.io",projectId:o,branch:i}=e,c=a(e,G);return(0,u.jsx)(m,s({imgSrc:"coveralls"!==n?"":i?[r,n,o,i].join("/"):[r,"codacy/coverage",o].join("/"),ref:t},c))}));j.displayName="Codacy";const Y=j;var z=e=>(0,u.jsx)(d,s({},e));z.Coverages=U,z.Codacy=Y,z.displayName="Github";var q=["base","platform","type","scope","packageName","dependency","dependencyScope","version","registryUri"],Q=o.forwardRef(((e,t)=>{var{base:n="https://img.shields.io",platform:r="npm",type:o="version",scope:i,packageName:c,dependency:l,dependencyScope:h,version:p,registryUri:d}=e,f=a(e,q);return(0,u.jsx)(m,s({imgSrc:(()=>{if("npm"!==r||!c)return"";var e="",t=[n,r];return"version"===o&&c?(t.push("v"),i&&t.push(i),t.push(c),p&&t.push(p),e=t.join("/"),d&&(e=e+"?registry_uri="+d)):"peer-dependency"===o&&c&&l?(t.push("dependency-version"),i&&t.push(i),e=[...t,c,"peer",l].join("/")):"dev-dependency"===o&&c&&l?(t.push("dependency-version"),i&&t.push(i),t.concat([c,"dev"]),h&&t.push(h),t.push(l),e=t.join("/")):c&&l&&(t.concat([c,l]),e=t.join("/")),e})(),ref:t},f))}));Q.displayName="Version";const W=Q;var K=["base","platform","format","packageName","scope","version"],V=o.forwardRef(((e,t)=>{var{base:n="https://img.shields.io",platform:r="npm",format:o="min",packageName:i,scope:c,version:l}=e,h=a(e,K);return(0,u.jsx)(m,s({imgSrc:(()=>{if("npm"!==r)return"";var e=[n,"bundlephobia"],t="";return i&&o&&(t=[...e,o,i].join("/")),i&&o&&c&&(t=[...e,o,c,i].join("/")),i&&o&&c&&l&&(t=[...e,o,c,i,l].join("/")),i&&o&&l&&(t=[...e,o,i,l].join("/")),t})(),ref:t},h))}));V.displayName="Size";const X=V;var $=["base","platform","interval","packageName","scope"],J=o.forwardRef(((e,t)=>{var{base:n="https://img.shields.io",platform:r="npm",interval:o="dm",packageName:i,scope:c}=e,l=a(e,$);return(0,u.jsx)(m,s({imgSrc:(()=>{if("npm"!==r||!i)return"";var e=[n,"npm",o];return c&&e.push(c),e.push(i),e.join("/")})(),ref:t},l))}));J.displayName="Downloads";const Z=J;var ee=e=>(0,u.jsx)(d,s({},e));ee.Version=W,ee.Size=X,ee.Downloads=Z,ee.displayName="Npm";var te=n(5652);const ne=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,re=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,oe={};function ie(e,t){return((t||oe).jsx?re:ne).test(e)}const se=/[ \t\n\f\r]/g;function ae(e){return"object"===typeof e?"text"===e.type&&ce(e.value):ce(e)}function ce(e){return""===e.replace(se,"")}var le=n(4188),ue=n(3180);const he={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var pe=n(4090),de=n(7255);const fe=de.default||de,me=Te("end"),Ee=Te("start");function Te(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"===typeof n.line&&n.line>0&&"number"===typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"===typeof n.offset&&n.offset>-1?n.offset:void 0}}}function ge(e){return e&&"object"===typeof e?"position"in e||"type"in e?_e(e.position):"start"in e||"end"in e?_e(e):"line"in e||"column"in e?Ae(e):"":""}function Ae(e){return De(e&&e.line)+":"+De(e&&e.column)}function _e(e){return Ae(e&&e.start)+"-"+Ae(e&&e.end)}function De(e){return e&&"number"===typeof e?e:1}class ye extends Error{constructor(e,t,n){super(),"string"===typeof t&&(n=t,t=void 0);let r="",o={},i=!1;if(t&&(o="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"===typeof e?r=e:!o.cause&&e&&(i=!0,r=e.message,o.cause=e),!o.ruleId&&!o.source&&"string"===typeof n){const e=n.indexOf(":");-1===e?o.ruleId=n:(o.source=n.slice(0,e),o.ruleId=n.slice(e+1))}if(!o.place&&o.ancestors&&o.ancestors){const e=o.ancestors[o.ancestors.length-1];e&&(o.place=e.position)}const s=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=s?s.line:void 0,this.name=ge(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=i&&o.cause&&"string"===typeof o.cause.stack?o.cause.stack:"",this.actual,this.expected,this.note,this.url}}ye.prototype.file="",ye.prototype.name="",ye.prototype.reason="",ye.prototype.message="",ye.prototype.stack="",ye.prototype.column=void 0,ye.prototype.line=void 0,ye.prototype.ancestors=void 0,ye.prototype.cause=void 0,ye.prototype.fatal=void 0,ye.prototype.place=void 0,ye.prototype.ruleId=void 0,ye.prototype.source=void 0;const Ce={}.hasOwnProperty,ke=new Map,be=/[A-Z]/g,Ne=/-([a-z])/g,Se=new Set(["table","tbody","thead","tfoot","tr"]),Ie=new Set(["td","th"]),Oe="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ve(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if("function"!==typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=function(e,t){return n;function n(n,r,o,i){const s=Array.isArray(o.children),a=Ee(n);return t(r,o,i,s,{columnNumber:a?a.column-1:void 0,fileName:e,lineNumber:a?a.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!==typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!==typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");r=function(e,t,n){return r;function r(e,r,o,i){const s=Array.isArray(o.children)?n:t;return i?s(r,o,i):s(r,o)}}(0,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?le.YP:le.dy,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},i=Re(o,e,void 0);return i&&"string"!==typeof i?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function Re(e,t,n){return"element"===t.type?function(e,t,n){const r=e.schema;let o=r;"svg"===t.tagName.toLowerCase()&&"html"===r.space&&(o=le.YP,e.schema=o);e.ancestors.push(t);const i=Me(e,t.tagName,!1),s=function(e,t){const n={};let r,o;for(o in t.properties)if("children"!==o&&Ce.call(t.properties,o)){const i=Pe(e,o,t.properties[o]);if(i){const[o,s]=i;e.tableCellAlignToStyle&&"align"===o&&"string"===typeof s&&Ie.has(t.tagName)?r=s:n[o]=s}}if(r){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r}return n}(e,t);let a=xe(e,t);Se.has(t.tagName)&&(a=a.filter((function(e){return"string"!==typeof e||!ae(e)})));return Fe(e,s,i,t),Le(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}we(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const r=e.schema;let o=r;"svg"===t.name&&"html"===r.space&&(o=le.YP,e.schema=o);e.ancestors.push(t);const i=null===t.name?e.Fragment:Me(e,t.name,!0),s=function(e,t){const n={};for(const r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){const t=r.data.estree.body[0];t.type;const o=t.expression;o.type;const i=o.properties[0];i.type,Object.assign(n,e.evaluater.evaluateExpression(i.argument))}else we(e,t.position);else{const o=r.name;let i;if(r.value&&"object"===typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){const t=r.value.data.estree.body[0];t.type,i=e.evaluater.evaluateExpression(t.expression)}else we(e,t.position);else i=null===r.value||r.value;n[o]=i}return n}(e,t),a=xe(e,t);return Fe(e,s,i,t),Le(s,a),e.ancestors.pop(),e.schema=r,e.create(t,i,s,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);we(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return Le(r,xe(e,t)),e.create(t,e.Fragment,r,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function Fe(e,t,n,r){"string"!==typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Le(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function xe(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:ke;for(;++ro?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)i=Array.from(r),i.unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);s0?(Qe(e,e.length,0,t),e):t}function Ke(e){const t={};let n,r,o,i,s,a,c,l=-1;for(;++l-1&&e.test(String.fromCharCode(t))}}function ft(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let i=0;return function(r){if(ut(r))return e.enter(n),s(r);return t(r)};function s(r){return ut(r)&&i++i))return;const n=t.events.length;let o,a,c=n;for(;c--;)if("exit"===t.events[c][0]&&"chunkFlow"===t.events[c][1].type){if(o){a=t.events[c][1].end;break}o=!0}for(T(s),e=n;er;){const r=n[o];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function g(){r.write([null]),o=void 0,r=void 0,t.containerState._closeFlow=void 0}}},Tt={tokenize:function(e,t,n){return ft(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};const gt={tokenize:function(e,t,n){return function(t){return ut(t)?ft(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||ct(e)?t(e):n(e)}},partial:!0};const At={tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?o(t):ct(t)?e.check(_t,i,o)(t):(e.consume(t),r)}function o(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function i(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}},resolve:function(e){return Ke(e),e}},_t={tokenize:function(e,t,n){const r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),ft(e,o,"linePrefix")};function o(o){if(null===o||ct(o))return n(o);const i=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}},partial:!0};const Dt={tokenize:function(e){const t=this,n=e.attempt(gt,(function(r){if(null===r)return void e.consume(r);return e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}),e.attempt(this.parser.constructs.flowInitial,r,ft(e,e.attempt(this.parser.constructs.flow,r,e.attempt(At,r)),"linePrefix")));return n;function r(r){if(null!==r)return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(r)}}};const yt={resolveAll:Nt()},Ct=bt("string"),kt=bt("text");function bt(e){return{tokenize:function(t){const n=this,r=this.parser.constructs[e],o=t.attempt(r,i,s);return i;function i(e){return c(e)?o(e):s(e)}function s(e){if(null!==e)return t.enter("data"),t.consume(e),a;t.consume(e)}function a(e){return c(e)?(t.exit("data"),o(e)):(t.consume(e),a)}function c(e){if(null===e)return!0;const t=r[e];let o=-1;if(t)for(;++o-1){const e=s[0];"string"===typeof e?s[0]=e.slice(r):s.shift()}i>0&&s.push(e[o].slice(0,i))}return s}(s,e)}function f(){const{line:e,column:t,offset:n,_index:o,_bufferIndex:i}=r;return{line:e,column:t,offset:n,_index:o,_bufferIndex:i}}function m(){let e;for(;r._index=3&&(null===i||ct(i))?(e.exit("thematicBreak"),t(i)):n(i)}function s(t){return t===r?(e.consume(t),o++,s):(e.exit("thematicBreakSequence"),ut(t)?ft(e,i,"whitespace")(t):i(t))}}};const Rt={name:"list",tokenize:function(e,t,n){const r=this,o=r.events[r.events.length-1];let i=o&&"linePrefix"===o[1].type?o[2].sliceSerialize(o[1],!0).length:0,s=0;return function(t){const o=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===o?!r.containerState.marker||t===r.containerState.marker:it(t)){if(r.containerState.type||(r.containerState.type=o,e.enter(o,{_container:!0})),"listUnordered"===o)return e.enter("listItemPrefix"),42===t||45===t?e.check(vt,n,c)(t):c(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),a(t)}return n(t)};function a(t){return it(t)&&++s<10?(e.consume(t),a):(!r.interrupt||s<2)&&(r.containerState.marker?t===r.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),c(t)):n(t)}function c(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(gt,r.interrupt?n:l,e.attempt(Ft,h,u))}function l(e){return r.containerState.initialBlankLine=!0,i++,h(e)}function u(t){return ut(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),h):n(t)}function h(n){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}},continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(gt,o,i);function o(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ft(e,t,"listItemIndent",r.containerState.size+1)(n)}function i(n){return r.containerState.furtherBlankLines||!ut(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Lt,t,s)(n))}function s(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,ft(e,e.attempt(Rt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}},exit:function(e){e.exit(this.containerState.type)}},Ft={tokenize:function(e,t,n){const r=this;return ft(e,(function(e){const o=r.events[r.events.length-1];return!ut(e)&&o&&"listItemPrefixWhitespace"===o[1].type?t(e):n(e)}),"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)},partial:!0},Lt={tokenize:function(e,t,n){const r=this;return ft(e,(function(e){const o=r.events[r.events.length-1];return o&&"listItemIndent"===o[1].type&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(e):n(e)}),"listItemIndent",r.containerState.size+1)},partial:!0};const xt={name:"blockQuote",tokenize:function(e,t,n){const r=this;return function(t){if(62===t){const n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),o}return n(t)};function o(n){return ut(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}},continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(ut(t))return ft(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return o(t)};function o(r){return e.attempt(xt,t,n)(r)}}},exit:function(e){e.exit("blockQuote")}};function Pt(e,t,n,r,o,i,s,a,c){const l=c||Number.POSITIVE_INFINITY;let u=0;return function(t){if(60===t)return e.enter(r),e.enter(o),e.enter(i),e.consume(t),e.exit(i),h;if(null===t||32===t||41===t||ot(t))return n(t);return e.enter(r),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),f(t)};function h(n){return 62===n?(e.enter(i),e.consume(n),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(n))}function p(t){return 62===t?(e.exit("chunkString"),e.exit(a),h(t)):null===t||60===t||ct(t)?n(t):(e.consume(t),92===t?d:p)}function d(t){return 60===t||62===t||92===t?(e.consume(t),p):p(t)}function f(o){return u||null!==o&&41!==o&&!lt(o)?u999||null===h||91===h||93===h&&!a||94===h&&!c&&"_hiddenFootnoteSupport"in s.parser.constructs?n(h):93===h?(e.exit(i),e.enter(o),e.consume(h),e.exit(o),e.exit(r),t):ct(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),l):(e.enter("chunkString",{contentType:"string"}),u(h))}function u(t){return null===t||91===t||93===t||ct(t)||c++>999?(e.exit("chunkString"),l(t)):(e.consume(t),a||(a=!ut(t)),92===t?h:u)}function h(t){return 91===t||92===t||93===t?(e.consume(t),c++,u):u(t)}}function wt(e,t,n,r,o,i){let s;return function(t){if(34===t||39===t||40===t)return e.enter(r),e.enter(o),e.consume(t),e.exit(o),s=40===t?41:t,a;return n(t)};function a(n){return n===s?(e.enter(o),e.consume(n),e.exit(o),e.exit(r),t):(e.enter(i),c(n))}function c(t){return t===s?(e.exit(i),a(s)):null===t?n(t):ct(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),ft(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(t))}function l(t){return t===s||null===t||ct(t)?(e.exit("chunkString"),c(t)):(e.consume(t),92===t?u:l)}function u(t){return t===s||92===t?(e.consume(t),l):l(t)}}function Bt(e,t){let n;return function r(o){if(ct(o))return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r;if(ut(o))return ft(e,r,n?"linePrefix":"lineSuffix")(o);return t(o)}}function Ht(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ut={name:"definition",tokenize:function(e,t,n){const r=this;let o;return function(t){return e.enter("definition"),function(t){return Mt.call(r,e,i,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function i(t){return o=Ht(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s):n(t)}function s(t){return lt(t)?Bt(e,a)(t):a(t)}function a(t){return Pt(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function c(t){return e.attempt(Gt,l,l)(t)}function l(t){return ut(t)?ft(e,u,"whitespace")(t):u(t)}function u(i){return null===i||ct(i)?(e.exit("definition"),r.parser.defined.push(o),t(i)):n(i)}}},Gt={tokenize:function(e,t,n){return function(t){return lt(t)?Bt(e,r)(t):n(t)};function r(t){return wt(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function o(t){return ut(t)?ft(e,i,"whitespace")(t):i(t)}function i(e){return null===e||ct(e)?t(e):n(e)}},partial:!0};const jt={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),ft(e,o,"linePrefix",5)(t)};function o(e){const t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?i(e):n(e)}function i(t){return null===t?a(t):ct(t)?e.attempt(Yt,i,a)(t):(e.enter("codeFlowValue"),s(t))}function s(t){return null===t||ct(t)?(e.exit("codeFlowValue"),i(t)):(e.consume(t),s)}function a(n){return e.exit("codeIndented"),t(n)}}},Yt={tokenize:function(e,t,n){const r=this;return o;function o(t){return r.parser.lazy[r.now().line]?n(t):ct(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):ft(e,i,"linePrefix",5)(t)}function i(e){const i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(e):ct(e)?o(e):n(e)}},partial:!0};const zt={name:"headingAtx",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),o(t)}(t)};function o(t){return 35===t&&r++<6?(e.consume(t),o):null===t||lt(t)?(e.exit("atxHeadingSequence"),i(t)):n(t)}function i(n){return 35===n?(e.enter("atxHeadingSequence"),s(n)):null===n||ct(n)?(e.exit("atxHeading"),t(n)):ut(n)?ft(e,i,"whitespace")(n):(e.enter("atxHeadingText"),a(n))}function s(t){return 35===t?(e.consume(t),s):(e.exit("atxHeadingSequence"),i(t))}function a(t){return null===t||35===t||lt(t)?(e.exit("atxHeadingText"),i(t)):(e.consume(t),a)}},resolve:function(e,t){let n,r,o=e.length-2,i=3;"whitespace"===e[i][1].type&&(i+=2);o-2>i&&"whitespace"===e[o][1].type&&(o-=2);"atxHeadingSequence"===e[o][1].type&&(i===o-1||o-4>i&&"whitespace"===e[o-2][1].type)&&(o-=i+1===o?2:4);o>i&&(n={type:"atxHeadingText",start:e[i][1].start,end:e[o][1].end},r={type:"chunkText",start:e[i][1].start,end:e[o][1].end,contentType:"text"},Qe(e,i,o-i+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]]));return e}};const qt={name:"setextUnderline",tokenize:function(e,t,n){const r=this;let o;return function(t){let s,a=r.events.length;for(;a--;)if("lineEnding"!==r.events[a][1].type&&"linePrefix"!==r.events[a][1].type&&"content"!==r.events[a][1].type){s="paragraph"===r.events[a][1].type;break}if(!r.parser.lazy[r.now().line]&&(r.interrupt||s))return e.enter("setextHeadingLine"),o=t,function(t){return e.enter("setextHeadingLineSequence"),i(t)}(t);return n(t)};function i(t){return t===o?(e.consume(t),i):(e.exit("setextHeadingLineSequence"),ut(t)?ft(e,s,"lineSuffix")(t):s(t))}function s(r){return null===r||ct(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}},resolveTo:function(e,t){let n,r,o,i=e.length;for(;i--;)if("enter"===e[i][0]){if("content"===e[i][1].type){n=i;break}"paragraph"===e[i][1].type&&(r=i)}else"content"===e[i][1].type&&e.splice(i,1),o||"definition"!==e[i][1].type||(o=i);const s={type:"setextHeading",start:Object.assign({},e[r][1].start),end:Object.assign({},e[e.length-1][1].end)};e[r][1].type="setextHeadingText",o?(e.splice(r,0,["enter",s,t]),e.splice(o+1,0,["exit",e[n][1],t]),e[n][1].end=Object.assign({},e[o][1].end)):e[n][1]=s;return e.push(["exit",s,t]),e}};const Qt=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Wt=["pre","script","style","textarea"],Kt={name:"htmlFlow",tokenize:function(e,t,n){const r=this;let o,i,s,a,c;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),l}(t)};function l(a){return 33===a?(e.consume(a),u):47===a?(e.consume(a),i=!0,d):63===a?(e.consume(a),o=3,r.interrupt?t:x):tt(a)?(e.consume(a),s=String.fromCharCode(a),f):n(a)}function u(i){return 45===i?(e.consume(i),o=2,h):91===i?(e.consume(i),o=5,a=0,p):tt(i)?(e.consume(i),o=4,r.interrupt?t:x):n(i)}function h(o){return 45===o?(e.consume(o),r.interrupt?t:x):n(o)}function p(o){const i="CDATA[";return o===i.charCodeAt(a++)?(e.consume(o),6===a?r.interrupt?t:N:p):n(o)}function d(t){return tt(t)?(e.consume(t),s=String.fromCharCode(t),f):n(t)}function f(a){if(null===a||47===a||62===a||lt(a)){const c=47===a,l=s.toLowerCase();return c||i||!Wt.includes(l)?Qt.includes(s.toLowerCase())?(o=6,c?(e.consume(a),m):r.interrupt?t(a):N(a)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(a):i?E(a):T(a)):(o=1,r.interrupt?t(a):N(a))}return 45===a||nt(a)?(e.consume(a),s+=String.fromCharCode(a),f):n(a)}function m(o){return 62===o?(e.consume(o),r.interrupt?t:N):n(o)}function E(t){return ut(t)?(e.consume(t),E):k(t)}function T(t){return 47===t?(e.consume(t),k):58===t||95===t||tt(t)?(e.consume(t),g):ut(t)?(e.consume(t),T):k(t)}function g(t){return 45===t||46===t||58===t||95===t||nt(t)?(e.consume(t),g):A(t)}function A(t){return 61===t?(e.consume(t),_):ut(t)?(e.consume(t),A):T(t)}function _(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),c=t,D):ut(t)?(e.consume(t),_):y(t)}function D(t){return t===c?(e.consume(t),c=null,C):null===t||ct(t)?n(t):(e.consume(t),D)}function y(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||lt(t)?A(t):(e.consume(t),y)}function C(e){return 47===e||62===e||ut(e)?T(e):n(e)}function k(t){return 62===t?(e.consume(t),b):n(t)}function b(t){return null===t||ct(t)?N(t):ut(t)?(e.consume(t),b):n(t)}function N(t){return 45===t&&2===o?(e.consume(t),v):60===t&&1===o?(e.consume(t),R):62===t&&4===o?(e.consume(t),P):63===t&&3===o?(e.consume(t),x):93===t&&5===o?(e.consume(t),L):!ct(t)||6!==o&&7!==o?null===t||ct(t)?(e.exit("htmlFlowData"),S(t)):(e.consume(t),N):(e.exit("htmlFlowData"),e.check(Vt,M,S)(t))}function S(t){return e.check(Xt,I,M)(t)}function I(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),O}function O(t){return null===t||ct(t)?S(t):(e.enter("htmlFlowData"),N(t))}function v(t){return 45===t?(e.consume(t),x):N(t)}function R(t){return 47===t?(e.consume(t),s="",F):N(t)}function F(t){if(62===t){const n=s.toLowerCase();return Wt.includes(n)?(e.consume(t),P):N(t)}return tt(t)&&s.length<8?(e.consume(t),s+=String.fromCharCode(t),F):N(t)}function L(t){return 93===t?(e.consume(t),x):N(t)}function x(t){return 62===t?(e.consume(t),P):45===t&&2===o?(e.consume(t),x):N(t)}function P(t){return null===t||ct(t)?(e.exit("htmlFlowData"),M(t)):(e.consume(t),P)}function M(n){return e.exit("htmlFlow"),t(n)}},resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},concrete:!0},Vt={tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(gt,t,n)}},partial:!0},Xt={tokenize:function(e,t,n){const r=this;return function(t){if(ct(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o;return n(t)};function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}},partial:!0};const $t={tokenize:function(e,t,n){const r=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o};function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}},partial:!0},Jt={name:"codeFenced",tokenize:function(e,t,n){const r=this,o={tokenize:function(e,t,n){let o=0;return s;function s(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),c}function c(t){return e.enter("codeFencedFence"),ut(t)?ft(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===i?(e.enter("codeFencedFenceSequence"),u(t)):n(t)}function u(t){return t===i?(o++,e.consume(t),u):o>=a?(e.exit("codeFencedFenceSequence"),ut(t)?ft(e,h,"whitespace")(t):h(t)):n(t)}function h(r){return null===r||ct(r)?(e.exit("codeFencedFence"),t(r)):n(r)}},partial:!0};let i,s=0,a=0;return function(t){return function(t){const n=r.events[r.events.length-1];return s=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,i=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(t)}(t)};function c(t){return t===i?(a++,e.consume(t),c):a<3?n(t):(e.exit("codeFencedFenceSequence"),ut(t)?ft(e,l,"whitespace")(t):l(t))}function l(n){return null===n||ct(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check($t,d,g)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(n))}function u(t){return null===t||ct(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),l(t)):ut(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ft(e,h,"whitespace")(t)):96===t&&t===i?n(t):(e.consume(t),u)}function h(t){return null===t||ct(t)?l(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),p(t))}function p(t){return null===t||ct(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),l(t)):96===t&&t===i?n(t):(e.consume(t),p)}function d(t){return e.attempt(o,g,f)(t)}function f(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),m}function m(t){return s>0&&ut(t)?ft(e,E,"linePrefix",s+1)(t):E(t)}function E(t){return null===t||ct(t)?e.check($t,d,g)(t):(e.enter("codeFlowValue"),T(t))}function T(t){return null===t||ct(t)?(e.exit("codeFlowValue"),E(t)):(e.consume(t),T)}function g(n){return e.exit("codeFenced"),t(n)}},concrete:!0};var Zt=n(1050);const en={name:"characterReference",tokenize:function(e,t,n){const r=this;let o,i,s=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),a};function a(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),o=31,i=nt,l(t))}function c(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,i=st,l):(e.enter("characterReferenceValue"),o=7,i=it,l(t))}function l(a){if(59===a&&s){const o=e.exit("characterReferenceValue");return i!==nt||(0,Zt.T)(r.sliceSerialize(o))?(e.enter("characterReferenceMarker"),e.consume(a),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(a)}return i(a)&&s++1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const h=Object.assign({},e[n][1].end),p=Object.assign({},e[u][1].start);hn(h,-a),hn(p,a),i={type:a>1?"strongSequence":"emphasisSequence",start:h,end:Object.assign({},e[n][1].end)},s={type:a>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[u][1].start),end:p},o={type:a>1?"strongText":"emphasisText",start:Object.assign({},e[n][1].end),end:Object.assign({},e[u][1].start)},r={type:a>1?"strong":"emphasis",start:Object.assign({},i.start),end:Object.assign({},s.end)},e[n][1].end=Object.assign({},i.start),e[u][1].start=Object.assign({},s.end),c=[],e[n][1].end.offset-e[n][1].start.offset&&(c=We(c,[["enter",e[n][1],t],["exit",e[n][1],t]])),c=We(c,[["enter",r,t],["enter",i,t],["exit",i,t],["enter",o,t]]),c=We(c,It(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),c=We(c,[["exit",o,t],["enter",s,t],["exit",s,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(l=2,c=We(c,[["enter",e[u][1],t],["exit",e[u][1],t]])):l=0,Qe(e,n-1,u-n+3,c),u=n+c.length-l-2;break}u=-1;for(;++u13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||65535===(65535&n)||65534===(65535&n)||n>1114111?"\ufffd":String.fromCodePoint(n)}const In=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function On(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Sn(n.slice(t?2:1),t?16:10)}return(0,Zt.T)(n)||e}const vn={}.hasOwnProperty;function Rn(e,t,n){return"string"!==typeof t&&(n=t,t=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(ee),autolinkProtocol:b,autolinkEmail:b,atxHeading:i(X),blockQuote:i(q),characterEscape:b,characterReference:b,codeFenced:i(Q),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:i(Q,s),codeText:i(W,s),codeTextData:b,data:b,codeFlowValue:b,definition:i(K),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:i(V),hardBreakEscape:i($),hardBreakTrailing:i($),htmlFlow:i(J,s),htmlFlowData:b,htmlText:i(J,s),htmlTextData:b,image:i(Z),label:s,link:i(ee),listItem:i(ne),listItemValue:p,listOrdered:i(te,h),listUnordered:i(te),paragraph:i(re),reference:H,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:i(X),strong:i(oe),thematicBreak:i(se)},exit:{atxHeading:c(),atxHeadingSequence:D,autolink:c(),autolinkEmail:z,autolinkProtocol:Y,blockQuote:c(),characterEscapeValue:N,characterReferenceMarkerHexadecimal:G,characterReferenceMarkerNumeric:G,characterReferenceValue:j,codeFenced:c(E),codeFencedFence:m,codeFencedFenceInfo:d,codeFencedFenceMeta:f,codeFlowValue:N,codeIndented:c(T),codeText:c(R),codeTextData:N,data:N,definition:c(),definitionDestinationString:_,definitionLabelString:g,definitionTitleString:A,emphasis:c(),hardBreakEscape:c(I),hardBreakTrailing:c(I),htmlFlow:c(O),htmlFlowData:N,htmlText:c(v),htmlTextData:N,image:c(L),label:P,labelText:x,lineEnding:S,link:c(F),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:U,resourceDestinationString:M,resourceTitleString:w,resource:B,setextHeading:c(k),setextHeadingLineSequence:C,setextHeadingText:y,strong:c(),thematicBreak:c()}};Ln(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(e){let r={type:"root",children:[]};const i={stack:[r],tokenStack:[],config:t,enter:a,exit:l,buffer:s,resume:u,data:n},c=[];let h=-1;for(;++h0){const e=i.tokenStack[i.tokenStack.length-1];(e[1]||Pn).call(i,void 0,e[0])}for(r.position={start:Fn(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Fn(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},h=-1;++h((e,t)=>{const n=(t,n)=>(e.set(n,t),t),r=o=>{if(e.has(o))return e.get(o);const[i,s]=t[o];switch(i){case 0:case-1:return n(s,o);case 1:{const e=n([],o);for(const t of s)e.push(r(t));return e}case 2:{const e=n({},o);for(const[t,n]of s)e[r(t)]=r(n);return e}case 3:return n(new Date(s),o);case 4:{const{source:e,flags:t}=s;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,n]of s)e.set(r(t),r(n));return e}case 6:{const e=n(new Set,o);for(const t of s)e.add(r(t));return e}case 7:{const{name:e,message:t}=s;return n(new wn[e](t),o)}case 8:return n(BigInt(s),o);case"BigInt":return n(Object(BigInt(s)),o)}return n(new wn[i](s),o)};return r})(new Map,e)(0),Hn="",{toString:Un}={},{keys:Gn}=Object,jn=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=Un.call(e).slice(8,-1);switch(n){case"Array":return[1,Hn];case"Object":return[2,Hn];case"Date":return[3,Hn];case"RegExp":return[4,Hn];case"Map":return[5,Hn];case"Set":return[6,Hn]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Yn=e=>{let[t,n]=e;return 0===t&&("function"===n||"symbol"===n)},zn=function(e){let{json:t,lossy:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=[];return((e,t,n,r)=>{const o=(e,t)=>{const o=r.push(e)-1;return n.set(t,o),o},i=r=>{if(n.has(r))return n.get(r);let[s,a]=jn(r);switch(s){case 0:{let t=r;switch(a){case"bigint":s=8,t=r.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+a);t=null;break;case"undefined":return o([-1],r)}return o([s,t],r)}case 1:{if(a)return o([a,[...r]],r);const e=[],t=o([s,e],r);for(const n of r)e.push(i(n));return t}case 2:{if(a)switch(a){case"BigInt":return o([a,r.toString()],r);case"Boolean":case"Number":case"String":return o([a,r.valueOf()],r)}if(t&&"toJSON"in r)return i(r.toJSON());const n=[],c=o([s,n],r);for(const t of Gn(r))!e&&Yn(jn(r[t]))||n.push([i(t),i(r[t])]);return c}case 3:return o([s,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return o([s,{source:e,flags:t}],r)}case 5:{const t=[],n=o([s,t],r);for(const[o,s]of r)(e||!Yn(jn(o))&&!Yn(jn(s)))&&t.push([i(o),i(s)]);return n}case 6:{const t=[],n=o([s,t],r);for(const o of r)!e&&Yn(jn(o))||t.push(i(o));return n}}const{message:c}=r;return o([s,{name:a,message:c}],r)};return i})(!(t||n),!!t,new Map,r)(e),r},qn="function"===typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Bn(zn(e,t)):structuredClone(e):(e,t)=>Bn(zn(e,t));function Qn(e){const t=[];let n=-1,r=0,o=0;for(;++n55295&&i<57344){const t=e.charCodeAt(n+1);i<56320&&t>56319&&t<57344?(s=String.fromCharCode(i,t),o=1):s="\ufffd"}else s=String.fromCharCode(i);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+o+1,s=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function Wn(e,t){const n=[{type:"text",value:"\u21a9"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Kn(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const Vn=function(e){if(null===e||void 0===e)return $n;if("function"===typeof e)return Xn(e);if("object"===typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n":"")+")"})}return u;function u(){let l,u,h,p=Zn;if((!t||i(o,a,c[c.length-1]||void 0))&&(p=function(e){if(Array.isArray(e))return e;if("number"===typeof e)return[er,e];return null===e||void 0===e?Zn:[e]}(n(o,c)),p[0]===tr))return p;if("children"in o&&o.children){const t=o;if(t.children&&p[0]!==nr)for(u=(r?t.children.length:-1)+s,h=c.concat(t);u>-1&&u1:t}const ar=9,cr=32;function lr(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),o=0;const i=[];for(;r;)i.push(ur(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(ur(t.slice(o),o>0,!1)),i.join("")}function ur(e,t,n){let r=0,o=e.length;if(t){let t=e.codePointAt(r);for(;t===ar||t===cr;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(o-1);for(;t===ar||t===cr;)o--,t=e.codePointAt(o-1)}return o>r?e.slice(r,o):""}const hr={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",r={};t.lang&&(r.className=["language-"+t.lang]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"===typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=Qn(r.toLowerCase()),i=e.footnoteOrder.indexOf(r);let s,a=e.footnoteCounts.get(r);void 0===a?(a=0,e.footnoteOrder.push(r),s=e.footnoteOrder.length):s=i+1,a+=1,e.footnoteCounts.set(r,a);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};e.patch(t,c);const l={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ir(e,t);const o={src:Qn(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(o.title=r.title);const i={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,i),e.applyData(t,i)},image:function(e,t){const n={src:Qn(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ir(e,t);const o={href:Qn(r.url||"")};null!==r.title&&void 0!==r.title&&(o.title=r.title);const i={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},link:function(e,t){const n={href:Qn(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){const r=e.all(t),o=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let a=-1;for(;++a0){const r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},i=Ee(t.children[1]),s=me(t.children[t.children.length-1]);i&&s&&(r.position={start:i,end:s}),o.push(r)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,i),e.applyData(t,i)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const r=n?n.children:void 0,o=0===(r?r.indexOf(t):1)?"th":"td",i=n&&"table"===n.type?n.align:void 0,s=i?i.length:t.children.length;let a=-1;const c=[];for(;++a0&&n.push({type:"text",value:"\n"}),n}function Ar(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function _r(e,t){const n=function(e,t){const n=t||fr,r=new Map,o=new Map,i=new Map,s={...hr,...n.handlers},a={all:function(e){const t=[];if("children"in e){const n=e.children;let r=-1;for(;++r0&&h.push({type:"text",value:" "});let e="string"===typeof n?n:n(c,u);"string"===typeof e&&(e={type:"text",value:e}),h.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+l+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"===typeof r?r:r(c,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const d=i[i.length-1];if(d&&"element"===d.type&&"p"===d.tagName){const e=d.children[d.children.length-1];e&&"text"===e.type?e.value+=" ":d.children.push({type:"text",value:" "}),d.children.push(...h)}else i.push(...h);const f={type:"element",tagName:"li",properties:{id:t+"fn-"+l},children:e.wrap(i,!0)};e.patch(o,f),a.push(f)}if(0!==a.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...qn(s),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:"\n"}]}}(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&i.children.push({type:"text",value:"\n"},o),i}function Dr(e,t){return e&&"run"in e?async function(n,r){const o=_r(n,t);await e.run(o,r)}:function(n){return _r(n,t||e)}}function yr(e){if(e)throw e}var Cr=n(1445);function kr(e){if("object"!==typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function br(){const e=[],t={run:function(){for(var t=arguments.length,n=new Array(t),r=0;r1?c-1:0),u=1;uo.length;let l;c&&o.push(i);try{l=e.apply(this,o)}catch(r){if(c&&n)throw r;return i(r)}c||(l instanceof Promise?l.then(s,i):l instanceof Error?i(l):s(l))}function i(e){if(!n){n=!0;for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;ie.length){for(;i--;)if(47===e.codePointAt(i)){if(n){r=i+1;break}}else o<0&&(n=!0,o=i+1);return o<0?"":e.slice(r,o)}if(t===e)return"";let s=-1,a=t.length-1;for(;i--;)if(47===e.codePointAt(i)){if(n){r=i+1;break}}else s<0&&(n=!0,s=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(o=i):(a=-1,o=s));r===o?o=s:o<0&&(o=e.length);return e.slice(r,o)},dirname:function(e){if(Sr(e),0===e.length)return".";let t,n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){Sr(e);let t,n=e.length,r=-1,o=0,i=-1,s=0;for(;n--;){const a=e.codePointAt(n);if(47!==a)r<0&&(t=!0,r=n+1),46===a?i<0?i=n:1!==s&&(s=1):i>-1&&(s=-1);else if(t){o=n+1;break}}if(i<0||r<0||0===s||1===s&&i===r-1&&i===o+1)return"";return e.slice(i,r)},join:function(){let e,t=-1;for(var n=arguments.length,r=new Array(n),o=0;o2){if(r=o.lastIndexOf("/"),r!==o.length-1){r<0?(o="",i=0):(o=o.slice(0,r),i=o.length-1-o.lastIndexOf("/")),s=c,a=0;continue}}else if(o.length>0){o="",i=0,s=c,a=0;continue}t&&(o=o.length>0?o+"/..":"..",i=2)}else o.length>0?o+="/"+e.slice(s+1,c):o=e.slice(s+1,c),i=c-s-1;s=c,a=0}else 46===n&&a>-1?a++:a=-1}return o}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(e)},sep:"/"};function Sr(e){if("string"!==typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Ir={cwd:function(){return"/"}};function Or(e){return Boolean(null!==e&&"object"===typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function vr(e){if("string"===typeof e)e=new URL(e);else if(!Or(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n1?r-1:0),i=1;i0){let[r,...i]=n;const s=t[o][1];kr(s)&&kr(r)&&(r=Cr(!0,s,r)),t[o]=[e,r,...i]}}}}const Hr=(new Br).freeze();function Ur(e,t){if("function"!==typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function Gr(e,t){if("function"!==typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function jr(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Yr(e){if(!kr(e)||"string"!==typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function zr(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function qr(e){return function(e){return Boolean(e&&"object"===typeof e&&"message"in e&&"messages"in e)}(e)?e:new Fr(e)}const Qr=[],Wr={allowDangerousHtml:!0},Kr=/^(https?|ircs?|mailto|xmpp)$/i,Vr=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Xr(e){const t=e.allowedElements,n=e.allowElement,r=e.children||"",o=e.className,i=e.components,s=e.disallowedElements,a=e.rehypePlugins||Qr,c=e.remarkPlugins||Qr,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Wr}:Wr,h=e.skipHtml,p=e.unwrapDisallowed,d=e.urlTransform||$r,f=Hr().use(Mn).use(c).use(Dr,l).use(a),m=new Fr;"string"===typeof r&&(m.value=r);for(const u of Vr)Object.hasOwn(e,u.from)&&(u.from,u.to&&u.to,u.id);const E=f.parse(m);let T=f.runSync(E,m);return o&&(T={type:"element",tagName:"div",properties:{className:o},children:"root"===T.type?T.children:[T]}),or(T,(function(e,r,o){if("raw"===e.type&&o&&"number"===typeof r)return h?o.children.splice(r,1):o.children[r]={type:"text",value:e.value},r;if("element"===e.type){let t;for(t in Ge)if(Object.hasOwn(Ge,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=Ge[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=d(String(n||""),t,e))}}if("element"===e.type){let i=t?!t.includes(e.tagName):!!s&&s.includes(e.tagName);if(!i&&n&&"number"===typeof r&&(i=!n(e,r,o)),i&&o&&"number"===typeof r)return p&&e.children?o.children.splice(r,1,...e.children):o.children.splice(r,1),r}})),ve(T,{Fragment:u.Fragment,components:i,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0})}function $r(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return t<0||o>-1&&t>o||n>-1&&t>n||r>-1&&t>r||Kr.test(e.slice(0,t))?e:""}function Jr(e,t){const n=String(e);if("string"!==typeof t)throw new TypeError("Expected character");let r=0,o=n.indexOf(t);for(;-1!==o;)r++,o=n.indexOf(t,o+t.length);return r}function Zr(e,t,n){const r=Vn((n||{}).ignore||[]),o=function(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r0?{type:"text",value:i}:void 0),!1===i?r.lastIndex=n+1:(a!==n&&u.push({type:"text",value:e.value.slice(a,n)}),Array.isArray(i)?u.push(...i):i&&u.push(i),a=n+h[0].length,l=!0),!r.global)break;h=r.exec(e.value)}l?(a?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const o=Jr(e,"(");let i=Jr(e,")");for(;-1!==r&&o>i;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),i++;return[e,n]}(n+r);if(!s[0])return!1;const a={type:"link",title:null,url:i+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[a,{type:"text",value:s[1]}]:a}function po(e,t,n,r){return!(!fo(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function fo(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||pt(n)||ht(n))&&(!t||47!==n)}function mo(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Eo(){this.buffer()}function To(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Ht(this.sliceSerialize(e)).toLowerCase()}function go(e){this.exit(e)}function Ao(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function _o(){this.buffer()}function Do(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Ht(this.sliceSerialize(e)).toLowerCase()}function yo(e){this.exit(e)}function Co(e,t,n,r){const o=n.createTracker(r);let i=o.move("[^");const s=n.enter("footnoteReference"),a=n.enter("reference");return i+=o.move(n.safe(n.associationId(e),{...o.current(),before:i,after:"]"})),a(),s(),i+=o.move("]"),i}function ko(e,t,n,r){const o=n.createTracker(r);let i=o.move("[^");const s=n.enter("footnoteDefinition"),a=n.enter("label");return i+=o.move(n.safe(n.associationId(e),{...o.current(),before:i,after:"]"})),a(),i+=o.move("]:"+(e.children&&e.children.length>0?" ":"")),o.shift(4),i+=o.move(n.indentLines(n.containerFlow(e,o.current()),bo)),s(),i}function bo(e,t,n){return 0===t?e:(n?"":" ")+e}Co.peek=function(){return"["};const No=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function So(e){this.enter({type:"delete",children:[]},e)}function Io(e){this.exit(e)}function Oo(e,t,n,r){const o=n.createTracker(r),i=n.enter("strikethrough");let s=o.move("~~");return s+=n.containerPhrasing(e,{...o.current(),before:s,after:"~"}),s+=o.move("~~"),i(),s}function vo(e){return e.length}function Ro(e){const t="string"===typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}function Fo(e,t,n){return">"+(n?"":" ")+e}function Lo(e,t,n){if("string"===typeof t&&(t=[t]),!t||0===t.length)return n;let r=-1;for(;++r",...c.current()})),l+=c.move(">")):(a=n.enter("destinationRaw"),l+=c.move(n.safe(e.url,{before:l,after:e.title?" ":")",...c.current()}))),a(),e.title&&(a=n.enter("title".concat(i)),l+=c.move(" "+o),l+=c.move(n.safe(e.title,{before:l,after:o,...c.current()})),l+=c.move(o),a()),l+=c.move(")"),s(),l}function Uo(e,t,n,r){const o=e.referenceType,i=n.enter("imageReference");let s=n.enter("label");const a=n.createTracker(r);let c=a.move("![");const l=n.safe(e.alt,{before:c,after:"]",...a.current()});c+=a.move(l+"]["),s();const u=n.stack;n.stack=[],s=n.enter("reference");const h=n.safe(n.associationId(e),{before:c,after:"]",...a.current()});return s(),n.stack=u,i(),"full"!==o&&l&&l===h?"shortcut"===o?c=c.slice(0,-1):c+=a.move("]"):c+=a.move(h+"]"),c}function Go(e,t,n){let r=e.value||"",o="`",i=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(r);)o+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++i\u007F]/.test(e.url))}function Yo(e,t,n,r){const o=Mo(n),i='"'===o?"Quote":"Apostrophe",s=n.createTracker(r);let a,c;if(jo(e,n)){const t=n.stack;n.stack=[],a=n.enter("autolink");let r=s.move("<");return r+=s.move(n.containerPhrasing(e,{before:r,after:">",...s.current()})),r+=s.move(">"),a(),n.stack=t,r}a=n.enter("link"),c=n.enter("label");let l=s.move("[");return l+=s.move(n.containerPhrasing(e,{before:l,after:"](",...s.current()})),l+=s.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),l+=s.move("<"),l+=s.move(n.safe(e.url,{before:l,after:">",...s.current()})),l+=s.move(">")):(c=n.enter("destinationRaw"),l+=s.move(n.safe(e.url,{before:l,after:e.title?" ":")",...s.current()}))),c(),e.title&&(c=n.enter("title".concat(i)),l+=s.move(" "+o),l+=s.move(n.safe(e.title,{before:l,after:o,...s.current()})),l+=s.move(o),c()),l+=s.move(")"),a(),l}function zo(e,t,n,r){const o=e.referenceType,i=n.enter("linkReference");let s=n.enter("label");const a=n.createTracker(r);let c=a.move("[");const l=n.containerPhrasing(e,{before:c,after:"]",...a.current()});c+=a.move(l+"]["),s();const u=n.stack;n.stack=[],s=n.enter("reference");const h=n.safe(n.associationId(e),{before:c,after:"]",...a.current()});return s(),n.stack=u,i(),"full"!==o&&l&&l===h?"shortcut"===o?c=c.slice(0,-1):c+=a.move("]"):c+=a.move(h+"]"),c}function qo(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Qo(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}Oo.peek=function(){return"~"},wo.peek=function(e,t,n){return n.options.emphasis||"*"},Bo.peek=function(){return"<"},Ho.peek=function(){return"!"},Uo.peek=function(){return"!"},Go.peek=function(){return"`"},Yo.peek=function(e,t,n){return jo(e,n)?"<":"["},zo.peek=function(){return"["};const Wo=Vn(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","link","linkReference","strong","text"]);function Ko(e,t,n,r){const o=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),i=n.enter("strong"),s=n.createTracker(r);let a=s.move(o+o);return a+=s.move(n.containerPhrasing(e,{before:a,after:o,...s.current()})),a+=s.move(o+o),i(),a}Ko.peek=function(e,t,n){return n.options.strong||"*"};const Vo={blockquote:function(e,t,n,r){const o=n.enter("blockquote"),i=n.createTracker(r);i.move("> "),i.shift(2);const s=n.indentLines(n.containerFlow(e,i.current()),Fo);return o(),s},break:xo,code:function(e,t,n,r){const o=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),i=e.value||"",s="`"===o?"GraveAccent":"Tilde";if(function(e,t){return Boolean(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}(e,n)){const e=n.enter("codeIndented"),t=n.indentLines(i,Po);return e(),t}const a=n.createTracker(r),c=o.repeat(Math.max(function(e,t){const n=String(e);let r=n.indexOf(t),o=r,i=0,s=0;if("string"!==typeof t)throw new TypeError("Expected substring");for(;-1!==r;)r===o?++i>s&&(s=i):i=1,o=r+t.length,r=n.indexOf(t,o);return s}(i,o)+1,3)),l=n.enter("codeFenced");let u=a.move(c);if(e.lang){const t=n.enter("codeFencedLang".concat(s));u+=a.move(n.safe(e.lang,{before:u,after:" ",encode:["`"],...a.current()})),t()}if(e.lang&&e.meta){const t=n.enter("codeFencedMeta".concat(s));u+=a.move(" "),u+=a.move(n.safe(e.meta,{before:u,after:"\n",encode:["`"],...a.current()})),t()}return u+=a.move("\n"),i&&(u+=a.move(i+"\n")),u+=a.move(c),l(),u},definition:function(e,t,n,r){const o=Mo(n),i='"'===o?"Quote":"Apostrophe",s=n.enter("definition");let a=n.enter("label");const c=n.createTracker(r);let l=c.move("[");return l+=c.move(n.safe(n.associationId(e),{before:l,after:"]",...c.current()})),l+=c.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),l+=c.move("<"),l+=c.move(n.safe(e.url,{before:l,after:">",...c.current()})),l+=c.move(">")):(a=n.enter("destinationRaw"),l+=c.move(n.safe(e.url,{before:l,after:e.title?" ":"\n",...c.current()}))),a(),e.title&&(a=n.enter("title".concat(i)),l+=c.move(" "+o),l+=c.move(n.safe(e.title,{before:l,after:o,...c.current()})),l+=c.move(o),a()),s(),l},emphasis:wo,hardBreak:xo,heading:function(e,t,n,r){const o=Math.max(Math.min(6,e.depth||1),1),i=n.createTracker(r);if(function(e,t){let n=!1;return or(e,(function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,tr})),Boolean((!e.depth||e.depth<3)&&Ye(e)&&(t.options.setext||n))}(e,n)){const t=n.enter("headingSetext"),r=n.enter("phrasing"),s=n.containerPhrasing(e,{...i.current(),before:"\n",after:"\n"});return r(),t(),s+"\n"+(1===o?"=":"-").repeat(s.length-(Math.max(s.lastIndexOf("\r"),s.lastIndexOf("\n"))+1))}const s="#".repeat(o),a=n.enter("headingAtx"),c=n.enter("phrasing");i.move(s+" ");let l=n.containerPhrasing(e,{before:"# ",after:"\n",...i.current()});return/^[\t ]/.test(l)&&(l="&#x"+l.charCodeAt(0).toString(16).toUpperCase()+";"+l.slice(1)),l=l?s+" "+l:s,n.options.closeAtx&&(l+=" "+s),c(),a(),l},html:Bo,image:Ho,imageReference:Uo,inlineCode:Go,link:Yo,linkReference:zo,list:function(e,t,n,r){const o=n.enter("list"),i=n.bulletCurrent;let s=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):qo(n);const a=e.ordered?"."===s?")":".":function(e){const t=qo(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n);let c=!(!t||!n.bulletLastUsed)&&s===n.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==s&&"-"!==s||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(c=!0),Qo(n)===s&&t){let t=-1;for(;++t-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+i);let s=i.length+1;("tab"===o||"mixed"===o&&(t&&"list"===t.type&&t.spread||e.spread))&&(s=4*Math.ceil(s/4));const a=n.createTracker(r);a.move(i+" ".repeat(s-i.length)),a.shift(s);const c=n.enter("listItem"),l=n.indentLines(n.containerFlow(e,a.current()),(function(e,t,n){if(t)return(n?"":" ".repeat(s))+e;return(n?i:i+" ".repeat(s-i.length))+e}));return c(),l},paragraph:function(e,t,n,r){const o=n.enter("paragraph"),i=n.enter("phrasing"),s=n.containerPhrasing(e,r);return i(),o(),s},root:function(e,t,n,r){return(e.children.some((function(e){return Wo(e)}))?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:Ko,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(Qo(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?r.slice(0,-1):r}};function Xo(e){const t=e._align;this.enter({type:"table",align:t.map((function(e){return"none"===e?null:e})),children:[]},e),this.data.inTable=!0}function $o(e){this.exit(e),this.data.inTable=void 0}function Jo(e){this.enter({type:"tableRow",children:[]},e)}function Zo(e){this.exit(e)}function ei(e){this.enter({type:"tableCell",children:[]},e)}function ti(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,ni));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function ni(e,t){return"|"===t?t:e}function ri(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,o=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let r=Vo.inlineCode(e,t,n);n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&"));return r},table:function(e,t,n,r){return a(function(e,t,n){const r=e.children;let o=-1;const i=[],s=t.enter("table");for(;++o1&&void 0!==arguments[1]?arguments[1]:{};const n=(t.align||[]).concat(),r=t.stringLength||vo,o=[],i=[],s=[],a=[];let c=0,l=-1;for(;++lc&&(c=e[l].length);++ha[h])&&(a[h]=e)}n.push(i)}i[l]=n,s[l]=o}var u;let h=-1;if("object"===typeof n&&"length"in n)for(;++ha[h]&&(a[h]=i),d[h]=i),p[h]=s}i.splice(1,0,p),s.splice(1,0,d),l=-1;const f=[];for(;++l0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}mi[43]=fi,mi[45]=fi,mi[46]=fi,mi[95]=fi,mi[72]=[fi,di],mi[104]=[fi,di],mi[87]=[fi,pi],mi[119]=[fi,pi];const yi={tokenize:function(e,t,n){const r=this;return ft(e,(function(e){const o=r.events[r.events.length-1];return o&&"gfmFootnoteDefinitionIndent"===o[1].type&&4===o[2].sliceSerialize(o[1],!0).length?t(e):n(e)}),"gfmFootnoteDefinitionIndent",5)},partial:!0};function Ci(e,t,n){const r=this;let o=r.events.length;const i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s;for(;o--;){const e=r.events[o][1];if("labelImage"===e.type){s=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(o){if(!s||!s._balanced)return n(o);const a=Ht(r.sliceSerialize({start:s.end,end:r.now()}));if(94!==a.codePointAt(0)||!i.includes(a.slice(1)))return n(o);return e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),t(o)}}function ki(e,t){let n,r=e.length;for(;r--;)if("labelImage"===e[r][1].type&&"enter"===e[r][0]){n=e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const o={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},c=[e[r+1],e[r+2],["enter",o,t],e[r+3],e[r+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",o,t]];return e.splice(r,e.length-r+1,...c),e}function bi(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,s=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),a};function a(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(a){if(s>999||93===a&&!i||null===a||91===a||lt(a))return n(a);if(93===a){e.exit("chunkString");const i=e.exit("gfmFootnoteCallString");return o.includes(Ht(r.sliceSerialize(i)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(a)}return lt(a)||(i=!0),s++,e.consume(a),92===a?l:c}function l(t){return 91===t||92===t||93===t?(e.consume(t),s++,c):c(t)}}function Ni(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,s,a=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),c};function c(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",l):n(t)}function l(t){if(a>999||93===t&&!s||null===t||91===t||lt(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return i=Ht(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),h}return lt(t)||(s=!0),a++,e.consume(t),92===t?u:l}function u(t){return 91===t||92===t||93===t?(e.consume(t),a++,l):l(t)}function h(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o.includes(i)||o.push(i),ft(e,p,"gfmFootnoteDefinitionWhitespace")):n(t)}function p(e){return t(e)}}function Si(e,t,n){return e.check(gt,t,e.attempt(yi,t,n))}function Ii(e){e.exit("gfmFootnoteDefinition")}function Oi(e){let t=(e||{}).singleTilde;const n={tokenize:function(e,n,r){const o=this.previous,i=this.events;let s=0;return function(t){if(126===o&&"characterEscape"!==i[i.length-1][1].type)return r(t);return e.enter("strikethroughSequenceTemporary"),a(t)};function a(i){const c=ln(o);if(126===i)return s>1?r(i):(e.consume(i),s++,a);if(s<2&&!t)return r(i);const l=e.exit("strikethroughSequenceTemporary"),u=ln(i);return l._open=!u||2===u&&Boolean(c),l._close=!c||2===c&&Boolean(u),n(i)}},resolveAll:function(e,t){let n=-1;for(;++n0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push([...e]),e.length=0;let r=n.pop();for(;r;)e.push(...r),r=n.pop();this.map.length=0}}function Ri(e,t){let n=!1;const r=[];for(;t-1;){const e=r.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const o=t>-1?r.events[t][1].type:null,i="tableHead"===o||"tableRow"===o?_:a;if(i===_&&r.parser.lazy[r.now().line])return n(e);return i(e)};function a(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){if(124===e)return c(e);return o=!0,s+=1,c(e)}(t)}function c(t){return null===t?n(t):ct(t)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h):n(t):ut(t)?ft(e,c,"whitespace")(t):(s+=1,o&&(o=!1,i+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),o=!0,c):(e.enter("data"),l(t)))}function l(t){return null===t||124===t||lt(t)?(e.exit("data"),c(t)):(e.consume(t),92===t?u:l)}function u(t){return 92===t||124===t?(e.consume(t),l):l(t)}function h(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter("tableDelimiterRow"),o=!1,ut(t)?ft(e,p,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):p(t))}function p(t){return 45===t||58===t?f(t):124===t?(o=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),d):A(t)}function d(t){return ut(t)?ft(e,f,"whitespace")(t):f(t)}function f(t){return 58===t?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),m):45===t?(s+=1,m(t)):null===t||ct(t)?g(t):A(t)}function m(t){return 45===t?(e.enter("tableDelimiterFiller"),E(t)):A(t)}function E(t){return 45===t?(e.consume(t),E):58===t?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),T):(e.exit("tableDelimiterFiller"),T(t))}function T(t){return ut(t)?ft(e,g,"whitespace")(t):g(t)}function g(n){return 124===n?p(n):(null===n||ct(n))&&o&&i===s?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(n)):A(n)}function A(e){return n(e)}function _(t){return e.enter("tableRow"),D(t)}function D(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),D):null===n||ct(n)?(e.exit("tableRow"),t(n)):ut(n)?ft(e,D,"whitespace")(n):(e.enter("data"),y(n))}function y(t){return null===t||124===t||lt(t)?(e.exit("data"),D(t)):(e.consume(t),92===t?C:y)}function C(t){return 92===t||124===t?(e.consume(t),y):y(t)}}function Li(e,t){let n,r,o,i=-1,s=!0,a=0,c=[0,0,0,0],l=[0,0,0,0],u=!1,h=0;const p=new vi;for(;++in[2]+1){const t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[["exit",s,t]])}return void 0!==o&&(i.end=Object.assign({},Mi(t.events,o)),e.add(o,0,[["exit",i,t]]),i=void 0),i}function Pi(e,t,n,r,o){const i=[],s=Mi(t.events,n);o&&(o.end=Object.assign({},s),i.push(["exit",o,t])),r.end=Object.assign({},s),i.push(["exit",r,t]),e.add(n+1,0,i)}function Mi(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const wi={tokenize:function(e,t,n){const r=this;return function(t){if(null!==r.previous||!r._gfmTasklistFirstContentOfListItem)return n(t);return e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),o};function o(t){return lt(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),i):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),i):n(t)}function i(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(t)}function s(r){return ct(r)?t(r):ut(r)?e.check({tokenize:Bi},t,n)(r):n(r)}}};function Bi(e,t,n){return ft(e,(function(e){return null===e?n(e):t(e)}),"whitespace")}const Hi={};function Ui(e){const t=e||Hi,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),o=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),i=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return $e([{text:mi},{document:{91:{tokenize:Ni,continuation:{tokenize:Si},exit:Ii}},text:{91:{tokenize:bi},93:{add:"after",tokenize:Ci,resolveTo:ki}}},Oi(e),{flow:{null:{tokenize:Fi,resolveAll:Li}}},{text:{91:wi}}])}(t)),o.push([{transforms:[uo],enter:{literalAutolink:oo,literalAutolinkEmail:io,literalAutolinkHttp:io,literalAutolinkWww:io},exit:{literalAutolink:lo,literalAutolinkEmail:co,literalAutolinkHttp:so,literalAutolinkWww:ao}},{enter:{gfmFootnoteDefinition:mo,gfmFootnoteDefinitionLabelString:Eo,gfmFootnoteCall:Ao,gfmFootnoteCallString:_o},exit:{gfmFootnoteDefinition:go,gfmFootnoteDefinitionLabelString:To,gfmFootnoteCall:yo,gfmFootnoteCallString:Do}},{canContainEols:["delete"],enter:{strikethrough:So},exit:{strikethrough:Io}},{enter:{table:Xo,tableData:ei,tableHeader:ei,tableRow:Jo},exit:{codeText:ti,table:$o,tableData:Zo,tableHeader:Zo,tableRow:Zo}},{exit:{taskListCheckValueChecked:oi,taskListCheckValueUnchecked:oi,paragraph:ii}}]),i.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:no,notInConstruct:ro},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:no,notInConstruct:ro},{character:":",before:"[ps]",after:"\\/",inConstruct:no,notInConstruct:ro}]},{unsafe:[{character:"[",inConstruct:["phrasing","label","reference"]}],handlers:{footnoteDefinition:ko,footnoteReference:Co}},{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:No}],handlers:{delete:Oo}},ri(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:si}}]}}(t))}const Gi=/[#.]/g;var ji=n(2523);const Yi=new Set(["button","menu","reset","submit"]),zi={}.hasOwnProperty;function qi(e,t,n){const r=n&&function(e){const t={};let n=-1;for(;++n2?a-2:0),l=2;l-1&&ee)return{line:t+1,column:e-(t>0?n[t-1]:0)+1,offset:e}},toOffset:function(e){const t=e&&e.line,r=e&&e.column;if("number"===typeof t&&"number"===typeof r&&!Number.isNaN(t)&&!Number.isNaN(r)&&t-1 in n){const e=(n[t-2]||0)+r-1||0;if(e>-1&&e1?i-1:0),a=1;a=55296&&e<=57343}function bs(e){return 32!==e&&10!==e&&13!==e&&9!==e&&12!==e&&e>=1&&e<=31||e>=127&&e<=159}function Ns(e){return e>=64976&&e<=65007||ms.has(e)}var Ss;!function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"}(Ss=Ss||(Ss={}));class Is{constructor(e){this.handler=e,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=65536,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+Number(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(e){const{line:t,col:n,offset:r}=this;return{code:e,startLine:t,endLine:t,startCol:n,endCol:n,startOffset:r,endOffset:r}}_err(e){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(e)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(e){if(this.pos!==this.html.length-1){const t=this.html.charCodeAt(this.pos+1);if(function(e){return e>=56320&&e<=57343}(t))return this.pos++,this._addGap(),1024*(e-55296)+9216+t}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,Ts.EOF;return this._err(Ss.surrogateInInputStream),e}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(e,t){this.html.length>0?this.html+=e:this.html=e,this.endOfChunkHit=!1,this.lastChunkWritten=t}insertHtmlAtCurrentPos(e){this.html=this.html.substring(0,this.pos+1)+e+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(e,t){if(this.pos+e.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(t)return this.html.startsWith(e,this.pos);for(let n=0;n=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Ts.EOF;const n=this.html.charCodeAt(t);return n===Ts.CARRIAGE_RETURN?Ts.LINE_FEED:n}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,Ts.EOF;let e=this.html.charCodeAt(this.pos);if(e===Ts.CARRIAGE_RETURN)return this.isEol=!0,this.skipNextNewLine=!0,Ts.LINE_FEED;if(e===Ts.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine))return this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance();this.skipNextNewLine=!1,ks(e)&&(e=this._processSurrogate(e));return null===this.handler.onParseError||e>31&&e<127||e===Ts.LINE_FEED||e===Ts.CARRIAGE_RETURN||e>159&&e<64976||this._checkForProblematicCharacters(e),e}_checkForProblematicCharacters(e){bs(e)?this._err(Ss.controlCharacterInInputStream):Ns(e)&&this._err(Ss.noncharacterInInputStream)}retreat(e){for(this.pos-=e;this.pos=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}!function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"}(Os=Os||(Os={}));const Rs=new Uint16Array('\u1d41<\xd5\u0131\u028a\u049d\u057b\u05d0\u0675\u06de\u07a2\u07d6\u080f\u0a4a\u0a91\u0da1\u0e6d\u0f09\u0f26\u10ca\u1228\u12e1\u1415\u149d\u14c3\u14df\u1525\0\0\0\0\0\0\u156b\u16cd\u198d\u1c12\u1ddd\u1f7e\u2060\u21b0\u228d\u23c0\u23fb\u2442\u2824\u2912\u2d08\u2e48\u2fce\u3016\u32ba\u3639\u37ac\u38fe\u3a28\u3a71\u3ae0\u3b2e\u0800EMabcfglmnoprstu\\bfms\x7f\x84\x8b\x90\x95\x98\xa6\xb3\xb9\xc8\xcflig\u803b\xc6\u40c6P\u803b&\u4026cute\u803b\xc1\u40c1reve;\u4102\u0100iyx}rc\u803b\xc2\u40c2;\u4410r;\uc000\ud835\udd04rave\u803b\xc0\u40c0pha;\u4391acr;\u4100d;\u6a53\u0100gp\x9d\xa1on;\u4104f;\uc000\ud835\udd38plyFunction;\u6061ing\u803b\xc5\u40c5\u0100cs\xbe\xc3r;\uc000\ud835\udc9cign;\u6254ilde\u803b\xc3\u40c3ml\u803b\xc4\u40c4\u0400aceforsu\xe5\xfb\xfe\u0117\u011c\u0122\u0127\u012a\u0100cr\xea\xf2kslash;\u6216\u0176\xf6\xf8;\u6ae7ed;\u6306y;\u4411\u0180crt\u0105\u010b\u0114ause;\u6235noullis;\u612ca;\u4392r;\uc000\ud835\udd05pf;\uc000\ud835\udd39eve;\u42d8c\xf2\u0113mpeq;\u624e\u0700HOacdefhilorsu\u014d\u0151\u0156\u0180\u019e\u01a2\u01b5\u01b7\u01ba\u01dc\u0215\u0273\u0278\u027ecy;\u4427PY\u803b\xa9\u40a9\u0180cpy\u015d\u0162\u017aute;\u4106\u0100;i\u0167\u0168\u62d2talDifferentialD;\u6145leys;\u612d\u0200aeio\u0189\u018e\u0194\u0198ron;\u410cdil\u803b\xc7\u40c7rc;\u4108nint;\u6230ot;\u410a\u0100dn\u01a7\u01adilla;\u40b8terDot;\u40b7\xf2\u017fi;\u43a7rcle\u0200DMPT\u01c7\u01cb\u01d1\u01d6ot;\u6299inus;\u6296lus;\u6295imes;\u6297o\u0100cs\u01e2\u01f8kwiseContourIntegral;\u6232eCurly\u0100DQ\u0203\u020foubleQuote;\u601duote;\u6019\u0200lnpu\u021e\u0228\u0247\u0255on\u0100;e\u0225\u0226\u6237;\u6a74\u0180git\u022f\u0236\u023aruent;\u6261nt;\u622fourIntegral;\u622e\u0100fr\u024c\u024e;\u6102oduct;\u6210nterClockwiseContourIntegral;\u6233oss;\u6a2fcr;\uc000\ud835\udc9ep\u0100;C\u0284\u0285\u62d3ap;\u624d\u0580DJSZacefios\u02a0\u02ac\u02b0\u02b4\u02b8\u02cb\u02d7\u02e1\u02e6\u0333\u048d\u0100;o\u0179\u02a5trahd;\u6911cy;\u4402cy;\u4405cy;\u440f\u0180grs\u02bf\u02c4\u02c7ger;\u6021r;\u61a1hv;\u6ae4\u0100ay\u02d0\u02d5ron;\u410e;\u4414l\u0100;t\u02dd\u02de\u6207a;\u4394r;\uc000\ud835\udd07\u0100af\u02eb\u0327\u0100cm\u02f0\u0322ritical\u0200ADGT\u0300\u0306\u0316\u031ccute;\u40b4o\u0174\u030b\u030d;\u42d9bleAcute;\u42ddrave;\u4060ilde;\u42dcond;\u62c4ferentialD;\u6146\u0470\u033d\0\0\0\u0342\u0354\0\u0405f;\uc000\ud835\udd3b\u0180;DE\u0348\u0349\u034d\u40a8ot;\u60dcqual;\u6250ble\u0300CDLRUV\u0363\u0372\u0382\u03cf\u03e2\u03f8ontourIntegra\xec\u0239o\u0274\u0379\0\0\u037b\xbb\u0349nArrow;\u61d3\u0100eo\u0387\u03a4ft\u0180ART\u0390\u0396\u03a1rrow;\u61d0ightArrow;\u61d4e\xe5\u02cang\u0100LR\u03ab\u03c4eft\u0100AR\u03b3\u03b9rrow;\u67f8ightArrow;\u67faightArrow;\u67f9ight\u0100AT\u03d8\u03derrow;\u61d2ee;\u62a8p\u0241\u03e9\0\0\u03efrrow;\u61d1ownArrow;\u61d5erticalBar;\u6225n\u0300ABLRTa\u0412\u042a\u0430\u045e\u047f\u037crrow\u0180;BU\u041d\u041e\u0422\u6193ar;\u6913pArrow;\u61f5reve;\u4311eft\u02d2\u043a\0\u0446\0\u0450ightVector;\u6950eeVector;\u695eector\u0100;B\u0459\u045a\u61bdar;\u6956ight\u01d4\u0467\0\u0471eeVector;\u695fector\u0100;B\u047a\u047b\u61c1ar;\u6957ee\u0100;A\u0486\u0487\u62a4rrow;\u61a7\u0100ct\u0492\u0497r;\uc000\ud835\udc9frok;\u4110\u0800NTacdfglmopqstux\u04bd\u04c0\u04c4\u04cb\u04de\u04e2\u04e7\u04ee\u04f5\u0521\u052f\u0536\u0552\u055d\u0560\u0565G;\u414aH\u803b\xd0\u40d0cute\u803b\xc9\u40c9\u0180aiy\u04d2\u04d7\u04dcron;\u411arc\u803b\xca\u40ca;\u442dot;\u4116r;\uc000\ud835\udd08rave\u803b\xc8\u40c8ement;\u6208\u0100ap\u04fa\u04fecr;\u4112ty\u0253\u0506\0\0\u0512mallSquare;\u65fberySmallSquare;\u65ab\u0100gp\u0526\u052aon;\u4118f;\uc000\ud835\udd3csilon;\u4395u\u0100ai\u053c\u0549l\u0100;T\u0542\u0543\u6a75ilde;\u6242librium;\u61cc\u0100ci\u0557\u055ar;\u6130m;\u6a73a;\u4397ml\u803b\xcb\u40cb\u0100ip\u056a\u056fsts;\u6203onentialE;\u6147\u0280cfios\u0585\u0588\u058d\u05b2\u05ccy;\u4424r;\uc000\ud835\udd09lled\u0253\u0597\0\0\u05a3mallSquare;\u65fcerySmallSquare;\u65aa\u0370\u05ba\0\u05bf\0\0\u05c4f;\uc000\ud835\udd3dAll;\u6200riertrf;\u6131c\xf2\u05cb\u0600JTabcdfgorst\u05e8\u05ec\u05ef\u05fa\u0600\u0612\u0616\u061b\u061d\u0623\u066c\u0672cy;\u4403\u803b>\u403emma\u0100;d\u05f7\u05f8\u4393;\u43dcreve;\u411e\u0180eiy\u0607\u060c\u0610dil;\u4122rc;\u411c;\u4413ot;\u4120r;\uc000\ud835\udd0a;\u62d9pf;\uc000\ud835\udd3eeater\u0300EFGLST\u0635\u0644\u064e\u0656\u065b\u0666qual\u0100;L\u063e\u063f\u6265ess;\u62dbullEqual;\u6267reater;\u6aa2ess;\u6277lantEqual;\u6a7eilde;\u6273cr;\uc000\ud835\udca2;\u626b\u0400Aacfiosu\u0685\u068b\u0696\u069b\u069e\u06aa\u06be\u06caRDcy;\u442a\u0100ct\u0690\u0694ek;\u42c7;\u405eirc;\u4124r;\u610clbertSpace;\u610b\u01f0\u06af\0\u06b2f;\u610dizontalLine;\u6500\u0100ct\u06c3\u06c5\xf2\u06a9rok;\u4126mp\u0144\u06d0\u06d8ownHum\xf0\u012fqual;\u624f\u0700EJOacdfgmnostu\u06fa\u06fe\u0703\u0707\u070e\u071a\u071e\u0721\u0728\u0744\u0778\u078b\u078f\u0795cy;\u4415lig;\u4132cy;\u4401cute\u803b\xcd\u40cd\u0100iy\u0713\u0718rc\u803b\xce\u40ce;\u4418ot;\u4130r;\u6111rave\u803b\xcc\u40cc\u0180;ap\u0720\u072f\u073f\u0100cg\u0734\u0737r;\u412ainaryI;\u6148lie\xf3\u03dd\u01f4\u0749\0\u0762\u0100;e\u074d\u074e\u622c\u0100gr\u0753\u0758ral;\u622bsection;\u62c2isible\u0100CT\u076c\u0772omma;\u6063imes;\u6062\u0180gpt\u077f\u0783\u0788on;\u412ef;\uc000\ud835\udd40a;\u4399cr;\u6110ilde;\u4128\u01eb\u079a\0\u079ecy;\u4406l\u803b\xcf\u40cf\u0280cfosu\u07ac\u07b7\u07bc\u07c2\u07d0\u0100iy\u07b1\u07b5rc;\u4134;\u4419r;\uc000\ud835\udd0dpf;\uc000\ud835\udd41\u01e3\u07c7\0\u07ccr;\uc000\ud835\udca5rcy;\u4408kcy;\u4404\u0380HJacfos\u07e4\u07e8\u07ec\u07f1\u07fd\u0802\u0808cy;\u4425cy;\u440cppa;\u439a\u0100ey\u07f6\u07fbdil;\u4136;\u441ar;\uc000\ud835\udd0epf;\uc000\ud835\udd42cr;\uc000\ud835\udca6\u0580JTaceflmost\u0825\u0829\u082c\u0850\u0863\u09b3\u09b8\u09c7\u09cd\u0a37\u0a47cy;\u4409\u803b<\u403c\u0280cmnpr\u0837\u083c\u0841\u0844\u084dute;\u4139bda;\u439bg;\u67ealacetrf;\u6112r;\u619e\u0180aey\u0857\u085c\u0861ron;\u413ddil;\u413b;\u441b\u0100fs\u0868\u0970t\u0500ACDFRTUVar\u087e\u08a9\u08b1\u08e0\u08e6\u08fc\u092f\u095b\u0390\u096a\u0100nr\u0883\u088fgleBracket;\u67e8row\u0180;BR\u0899\u089a\u089e\u6190ar;\u61e4ightArrow;\u61c6eiling;\u6308o\u01f5\u08b7\0\u08c3bleBracket;\u67e6n\u01d4\u08c8\0\u08d2eeVector;\u6961ector\u0100;B\u08db\u08dc\u61c3ar;\u6959loor;\u630aight\u0100AV\u08ef\u08f5rrow;\u6194ector;\u694e\u0100er\u0901\u0917e\u0180;AV\u0909\u090a\u0910\u62a3rrow;\u61a4ector;\u695aiangle\u0180;BE\u0924\u0925\u0929\u62b2ar;\u69cfqual;\u62b4p\u0180DTV\u0937\u0942\u094cownVector;\u6951eeVector;\u6960ector\u0100;B\u0956\u0957\u61bfar;\u6958ector\u0100;B\u0965\u0966\u61bcar;\u6952ight\xe1\u039cs\u0300EFGLST\u097e\u098b\u0995\u099d\u09a2\u09adqualGreater;\u62daullEqual;\u6266reater;\u6276ess;\u6aa1lantEqual;\u6a7dilde;\u6272r;\uc000\ud835\udd0f\u0100;e\u09bd\u09be\u62d8ftarrow;\u61daidot;\u413f\u0180npw\u09d4\u0a16\u0a1bg\u0200LRlr\u09de\u09f7\u0a02\u0a10eft\u0100AR\u09e6\u09ecrrow;\u67f5ightArrow;\u67f7ightArrow;\u67f6eft\u0100ar\u03b3\u0a0aight\xe1\u03bfight\xe1\u03caf;\uc000\ud835\udd43er\u0100LR\u0a22\u0a2ceftArrow;\u6199ightArrow;\u6198\u0180cht\u0a3e\u0a40\u0a42\xf2\u084c;\u61b0rok;\u4141;\u626a\u0400acefiosu\u0a5a\u0a5d\u0a60\u0a77\u0a7c\u0a85\u0a8b\u0a8ep;\u6905y;\u441c\u0100dl\u0a65\u0a6fiumSpace;\u605flintrf;\u6133r;\uc000\ud835\udd10nusPlus;\u6213pf;\uc000\ud835\udd44c\xf2\u0a76;\u439c\u0480Jacefostu\u0aa3\u0aa7\u0aad\u0ac0\u0b14\u0b19\u0d91\u0d97\u0d9ecy;\u440acute;\u4143\u0180aey\u0ab4\u0ab9\u0aberon;\u4147dil;\u4145;\u441d\u0180gsw\u0ac7\u0af0\u0b0eative\u0180MTV\u0ad3\u0adf\u0ae8ediumSpace;\u600bhi\u0100cn\u0ae6\u0ad8\xeb\u0ad9eryThi\xee\u0ad9ted\u0100GL\u0af8\u0b06reaterGreate\xf2\u0673essLes\xf3\u0a48Line;\u400ar;\uc000\ud835\udd11\u0200Bnpt\u0b22\u0b28\u0b37\u0b3areak;\u6060BreakingSpace;\u40a0f;\u6115\u0680;CDEGHLNPRSTV\u0b55\u0b56\u0b6a\u0b7c\u0ba1\u0beb\u0c04\u0c5e\u0c84\u0ca6\u0cd8\u0d61\u0d85\u6aec\u0100ou\u0b5b\u0b64ngruent;\u6262pCap;\u626doubleVerticalBar;\u6226\u0180lqx\u0b83\u0b8a\u0b9bement;\u6209ual\u0100;T\u0b92\u0b93\u6260ilde;\uc000\u2242\u0338ists;\u6204reater\u0380;EFGLST\u0bb6\u0bb7\u0bbd\u0bc9\u0bd3\u0bd8\u0be5\u626fqual;\u6271ullEqual;\uc000\u2267\u0338reater;\uc000\u226b\u0338ess;\u6279lantEqual;\uc000\u2a7e\u0338ilde;\u6275ump\u0144\u0bf2\u0bfdownHump;\uc000\u224e\u0338qual;\uc000\u224f\u0338e\u0100fs\u0c0a\u0c27tTriangle\u0180;BE\u0c1a\u0c1b\u0c21\u62eaar;\uc000\u29cf\u0338qual;\u62ecs\u0300;EGLST\u0c35\u0c36\u0c3c\u0c44\u0c4b\u0c58\u626equal;\u6270reater;\u6278ess;\uc000\u226a\u0338lantEqual;\uc000\u2a7d\u0338ilde;\u6274ested\u0100GL\u0c68\u0c79reaterGreater;\uc000\u2aa2\u0338essLess;\uc000\u2aa1\u0338recedes\u0180;ES\u0c92\u0c93\u0c9b\u6280qual;\uc000\u2aaf\u0338lantEqual;\u62e0\u0100ei\u0cab\u0cb9verseElement;\u620cghtTriangle\u0180;BE\u0ccb\u0ccc\u0cd2\u62ebar;\uc000\u29d0\u0338qual;\u62ed\u0100qu\u0cdd\u0d0cuareSu\u0100bp\u0ce8\u0cf9set\u0100;E\u0cf0\u0cf3\uc000\u228f\u0338qual;\u62e2erset\u0100;E\u0d03\u0d06\uc000\u2290\u0338qual;\u62e3\u0180bcp\u0d13\u0d24\u0d4eset\u0100;E\u0d1b\u0d1e\uc000\u2282\u20d2qual;\u6288ceeds\u0200;EST\u0d32\u0d33\u0d3b\u0d46\u6281qual;\uc000\u2ab0\u0338lantEqual;\u62e1ilde;\uc000\u227f\u0338erset\u0100;E\u0d58\u0d5b\uc000\u2283\u20d2qual;\u6289ilde\u0200;EFT\u0d6e\u0d6f\u0d75\u0d7f\u6241qual;\u6244ullEqual;\u6247ilde;\u6249erticalBar;\u6224cr;\uc000\ud835\udca9ilde\u803b\xd1\u40d1;\u439d\u0700Eacdfgmoprstuv\u0dbd\u0dc2\u0dc9\u0dd5\u0ddb\u0de0\u0de7\u0dfc\u0e02\u0e20\u0e22\u0e32\u0e3f\u0e44lig;\u4152cute\u803b\xd3\u40d3\u0100iy\u0dce\u0dd3rc\u803b\xd4\u40d4;\u441eblac;\u4150r;\uc000\ud835\udd12rave\u803b\xd2\u40d2\u0180aei\u0dee\u0df2\u0df6cr;\u414cga;\u43a9cron;\u439fpf;\uc000\ud835\udd46enCurly\u0100DQ\u0e0e\u0e1aoubleQuote;\u601cuote;\u6018;\u6a54\u0100cl\u0e27\u0e2cr;\uc000\ud835\udcaaash\u803b\xd8\u40d8i\u016c\u0e37\u0e3cde\u803b\xd5\u40d5es;\u6a37ml\u803b\xd6\u40d6er\u0100BP\u0e4b\u0e60\u0100ar\u0e50\u0e53r;\u603eac\u0100ek\u0e5a\u0e5c;\u63deet;\u63b4arenthesis;\u63dc\u0480acfhilors\u0e7f\u0e87\u0e8a\u0e8f\u0e92\u0e94\u0e9d\u0eb0\u0efcrtialD;\u6202y;\u441fr;\uc000\ud835\udd13i;\u43a6;\u43a0usMinus;\u40b1\u0100ip\u0ea2\u0eadncareplan\xe5\u069df;\u6119\u0200;eio\u0eb9\u0eba\u0ee0\u0ee4\u6abbcedes\u0200;EST\u0ec8\u0ec9\u0ecf\u0eda\u627aqual;\u6aaflantEqual;\u627cilde;\u627eme;\u6033\u0100dp\u0ee9\u0eeeuct;\u620fortion\u0100;a\u0225\u0ef9l;\u621d\u0100ci\u0f01\u0f06r;\uc000\ud835\udcab;\u43a8\u0200Ufos\u0f11\u0f16\u0f1b\u0f1fOT\u803b"\u4022r;\uc000\ud835\udd14pf;\u611acr;\uc000\ud835\udcac\u0600BEacefhiorsu\u0f3e\u0f43\u0f47\u0f60\u0f73\u0fa7\u0faa\u0fad\u1096\u10a9\u10b4\u10bearr;\u6910G\u803b\xae\u40ae\u0180cnr\u0f4e\u0f53\u0f56ute;\u4154g;\u67ebr\u0100;t\u0f5c\u0f5d\u61a0l;\u6916\u0180aey\u0f67\u0f6c\u0f71ron;\u4158dil;\u4156;\u4420\u0100;v\u0f78\u0f79\u611cerse\u0100EU\u0f82\u0f99\u0100lq\u0f87\u0f8eement;\u620builibrium;\u61cbpEquilibrium;\u696fr\xbb\u0f79o;\u43a1ght\u0400ACDFTUVa\u0fc1\u0feb\u0ff3\u1022\u1028\u105b\u1087\u03d8\u0100nr\u0fc6\u0fd2gleBracket;\u67e9row\u0180;BL\u0fdc\u0fdd\u0fe1\u6192ar;\u61e5eftArrow;\u61c4eiling;\u6309o\u01f5\u0ff9\0\u1005bleBracket;\u67e7n\u01d4\u100a\0\u1014eeVector;\u695dector\u0100;B\u101d\u101e\u61c2ar;\u6955loor;\u630b\u0100er\u102d\u1043e\u0180;AV\u1035\u1036\u103c\u62a2rrow;\u61a6ector;\u695biangle\u0180;BE\u1050\u1051\u1055\u62b3ar;\u69d0qual;\u62b5p\u0180DTV\u1063\u106e\u1078ownVector;\u694feeVector;\u695cector\u0100;B\u1082\u1083\u61bear;\u6954ector\u0100;B\u1091\u1092\u61c0ar;\u6953\u0100pu\u109b\u109ef;\u611dndImplies;\u6970ightarrow;\u61db\u0100ch\u10b9\u10bcr;\u611b;\u61b1leDelayed;\u69f4\u0680HOacfhimoqstu\u10e4\u10f1\u10f7\u10fd\u1119\u111e\u1151\u1156\u1161\u1167\u11b5\u11bb\u11bf\u0100Cc\u10e9\u10eeHcy;\u4429y;\u4428FTcy;\u442ccute;\u415a\u0280;aeiy\u1108\u1109\u110e\u1113\u1117\u6abcron;\u4160dil;\u415erc;\u415c;\u4421r;\uc000\ud835\udd16ort\u0200DLRU\u112a\u1134\u113e\u1149ownArrow\xbb\u041eeftArrow\xbb\u089aightArrow\xbb\u0fddpArrow;\u6191gma;\u43a3allCircle;\u6218pf;\uc000\ud835\udd4a\u0272\u116d\0\0\u1170t;\u621aare\u0200;ISU\u117b\u117c\u1189\u11af\u65a1ntersection;\u6293u\u0100bp\u118f\u119eset\u0100;E\u1197\u1198\u628fqual;\u6291erset\u0100;E\u11a8\u11a9\u6290qual;\u6292nion;\u6294cr;\uc000\ud835\udcaear;\u62c6\u0200bcmp\u11c8\u11db\u1209\u120b\u0100;s\u11cd\u11ce\u62d0et\u0100;E\u11cd\u11d5qual;\u6286\u0100ch\u11e0\u1205eeds\u0200;EST\u11ed\u11ee\u11f4\u11ff\u627bqual;\u6ab0lantEqual;\u627dilde;\u627fTh\xe1\u0f8c;\u6211\u0180;es\u1212\u1213\u1223\u62d1rset\u0100;E\u121c\u121d\u6283qual;\u6287et\xbb\u1213\u0580HRSacfhiors\u123e\u1244\u1249\u1255\u125e\u1271\u1276\u129f\u12c2\u12c8\u12d1ORN\u803b\xde\u40deADE;\u6122\u0100Hc\u124e\u1252cy;\u440by;\u4426\u0100bu\u125a\u125c;\u4009;\u43a4\u0180aey\u1265\u126a\u126fron;\u4164dil;\u4162;\u4422r;\uc000\ud835\udd17\u0100ei\u127b\u1289\u01f2\u1280\0\u1287efore;\u6234a;\u4398\u0100cn\u128e\u1298kSpace;\uc000\u205f\u200aSpace;\u6009lde\u0200;EFT\u12ab\u12ac\u12b2\u12bc\u623cqual;\u6243ullEqual;\u6245ilde;\u6248pf;\uc000\ud835\udd4bipleDot;\u60db\u0100ct\u12d6\u12dbr;\uc000\ud835\udcafrok;\u4166\u0ae1\u12f7\u130e\u131a\u1326\0\u132c\u1331\0\0\0\0\0\u1338\u133d\u1377\u1385\0\u13ff\u1404\u140a\u1410\u0100cr\u12fb\u1301ute\u803b\xda\u40dar\u0100;o\u1307\u1308\u619fcir;\u6949r\u01e3\u1313\0\u1316y;\u440eve;\u416c\u0100iy\u131e\u1323rc\u803b\xdb\u40db;\u4423blac;\u4170r;\uc000\ud835\udd18rave\u803b\xd9\u40d9acr;\u416a\u0100di\u1341\u1369er\u0100BP\u1348\u135d\u0100ar\u134d\u1350r;\u405fac\u0100ek\u1357\u1359;\u63dfet;\u63b5arenthesis;\u63ddon\u0100;P\u1370\u1371\u62c3lus;\u628e\u0100gp\u137b\u137fon;\u4172f;\uc000\ud835\udd4c\u0400ADETadps\u1395\u13ae\u13b8\u13c4\u03e8\u13d2\u13d7\u13f3rrow\u0180;BD\u1150\u13a0\u13a4ar;\u6912ownArrow;\u61c5ownArrow;\u6195quilibrium;\u696eee\u0100;A\u13cb\u13cc\u62a5rrow;\u61a5own\xe1\u03f3er\u0100LR\u13de\u13e8eftArrow;\u6196ightArrow;\u6197i\u0100;l\u13f9\u13fa\u43d2on;\u43a5ing;\u416ecr;\uc000\ud835\udcb0ilde;\u4168ml\u803b\xdc\u40dc\u0480Dbcdefosv\u1427\u142c\u1430\u1433\u143e\u1485\u148a\u1490\u1496ash;\u62abar;\u6aeby;\u4412ash\u0100;l\u143b\u143c\u62a9;\u6ae6\u0100er\u1443\u1445;\u62c1\u0180bty\u144c\u1450\u147aar;\u6016\u0100;i\u144f\u1455cal\u0200BLST\u1461\u1465\u146a\u1474ar;\u6223ine;\u407ceparator;\u6758ilde;\u6240ThinSpace;\u600ar;\uc000\ud835\udd19pf;\uc000\ud835\udd4dcr;\uc000\ud835\udcb1dash;\u62aa\u0280cefos\u14a7\u14ac\u14b1\u14b6\u14bcirc;\u4174dge;\u62c0r;\uc000\ud835\udd1apf;\uc000\ud835\udd4ecr;\uc000\ud835\udcb2\u0200fios\u14cb\u14d0\u14d2\u14d8r;\uc000\ud835\udd1b;\u439epf;\uc000\ud835\udd4fcr;\uc000\ud835\udcb3\u0480AIUacfosu\u14f1\u14f5\u14f9\u14fd\u1504\u150f\u1514\u151a\u1520cy;\u442fcy;\u4407cy;\u442ecute\u803b\xdd\u40dd\u0100iy\u1509\u150drc;\u4176;\u442br;\uc000\ud835\udd1cpf;\uc000\ud835\udd50cr;\uc000\ud835\udcb4ml;\u4178\u0400Hacdefos\u1535\u1539\u153f\u154b\u154f\u155d\u1560\u1564cy;\u4416cute;\u4179\u0100ay\u1544\u1549ron;\u417d;\u4417ot;\u417b\u01f2\u1554\0\u155boWidt\xe8\u0ad9a;\u4396r;\u6128pf;\u6124cr;\uc000\ud835\udcb5\u0be1\u1583\u158a\u1590\0\u15b0\u15b6\u15bf\0\0\0\0\u15c6\u15db\u15eb\u165f\u166d\0\u1695\u169b\u16b2\u16b9\0\u16becute\u803b\xe1\u40e1reve;\u4103\u0300;Ediuy\u159c\u159d\u15a1\u15a3\u15a8\u15ad\u623e;\uc000\u223e\u0333;\u623frc\u803b\xe2\u40e2te\u80bb\xb4\u0306;\u4430lig\u803b\xe6\u40e6\u0100;r\xb2\u15ba;\uc000\ud835\udd1erave\u803b\xe0\u40e0\u0100ep\u15ca\u15d6\u0100fp\u15cf\u15d4sym;\u6135\xe8\u15d3ha;\u43b1\u0100ap\u15dfc\u0100cl\u15e4\u15e7r;\u4101g;\u6a3f\u0264\u15f0\0\0\u160a\u0280;adsv\u15fa\u15fb\u15ff\u1601\u1607\u6227nd;\u6a55;\u6a5clope;\u6a58;\u6a5a\u0380;elmrsz\u1618\u1619\u161b\u161e\u163f\u164f\u1659\u6220;\u69a4e\xbb\u1619sd\u0100;a\u1625\u1626\u6221\u0461\u1630\u1632\u1634\u1636\u1638\u163a\u163c\u163e;\u69a8;\u69a9;\u69aa;\u69ab;\u69ac;\u69ad;\u69ae;\u69aft\u0100;v\u1645\u1646\u621fb\u0100;d\u164c\u164d\u62be;\u699d\u0100pt\u1654\u1657h;\u6222\xbb\xb9arr;\u637c\u0100gp\u1663\u1667on;\u4105f;\uc000\ud835\udd52\u0380;Eaeiop\u12c1\u167b\u167d\u1682\u1684\u1687\u168a;\u6a70cir;\u6a6f;\u624ad;\u624bs;\u4027rox\u0100;e\u12c1\u1692\xf1\u1683ing\u803b\xe5\u40e5\u0180cty\u16a1\u16a6\u16a8r;\uc000\ud835\udcb6;\u402amp\u0100;e\u12c1\u16af\xf1\u0288ilde\u803b\xe3\u40e3ml\u803b\xe4\u40e4\u0100ci\u16c2\u16c8onin\xf4\u0272nt;\u6a11\u0800Nabcdefiklnoprsu\u16ed\u16f1\u1730\u173c\u1743\u1748\u1778\u177d\u17e0\u17e6\u1839\u1850\u170d\u193d\u1948\u1970ot;\u6aed\u0100cr\u16f6\u171ek\u0200ceps\u1700\u1705\u170d\u1713ong;\u624cpsilon;\u43f6rime;\u6035im\u0100;e\u171a\u171b\u623dq;\u62cd\u0176\u1722\u1726ee;\u62bded\u0100;g\u172c\u172d\u6305e\xbb\u172drk\u0100;t\u135c\u1737brk;\u63b6\u0100oy\u1701\u1741;\u4431quo;\u601e\u0280cmprt\u1753\u175b\u1761\u1764\u1768aus\u0100;e\u010a\u0109ptyv;\u69b0s\xe9\u170cno\xf5\u0113\u0180ahw\u176f\u1771\u1773;\u43b2;\u6136een;\u626cr;\uc000\ud835\udd1fg\u0380costuvw\u178d\u179d\u17b3\u17c1\u17d5\u17db\u17de\u0180aiu\u1794\u1796\u179a\xf0\u0760rc;\u65efp\xbb\u1371\u0180dpt\u17a4\u17a8\u17adot;\u6a00lus;\u6a01imes;\u6a02\u0271\u17b9\0\0\u17becup;\u6a06ar;\u6605riangle\u0100du\u17cd\u17d2own;\u65bdp;\u65b3plus;\u6a04e\xe5\u1444\xe5\u14adarow;\u690d\u0180ako\u17ed\u1826\u1835\u0100cn\u17f2\u1823k\u0180lst\u17fa\u05ab\u1802ozenge;\u69ebriangle\u0200;dlr\u1812\u1813\u1818\u181d\u65b4own;\u65beeft;\u65c2ight;\u65b8k;\u6423\u01b1\u182b\0\u1833\u01b2\u182f\0\u1831;\u6592;\u65914;\u6593ck;\u6588\u0100eo\u183e\u184d\u0100;q\u1843\u1846\uc000=\u20e5uiv;\uc000\u2261\u20e5t;\u6310\u0200ptwx\u1859\u185e\u1867\u186cf;\uc000\ud835\udd53\u0100;t\u13cb\u1863om\xbb\u13cctie;\u62c8\u0600DHUVbdhmptuv\u1885\u1896\u18aa\u18bb\u18d7\u18db\u18ec\u18ff\u1905\u190a\u1910\u1921\u0200LRlr\u188e\u1890\u1892\u1894;\u6557;\u6554;\u6556;\u6553\u0280;DUdu\u18a1\u18a2\u18a4\u18a6\u18a8\u6550;\u6566;\u6569;\u6564;\u6567\u0200LRlr\u18b3\u18b5\u18b7\u18b9;\u655d;\u655a;\u655c;\u6559\u0380;HLRhlr\u18ca\u18cb\u18cd\u18cf\u18d1\u18d3\u18d5\u6551;\u656c;\u6563;\u6560;\u656b;\u6562;\u655fox;\u69c9\u0200LRlr\u18e4\u18e6\u18e8\u18ea;\u6555;\u6552;\u6510;\u650c\u0280;DUdu\u06bd\u18f7\u18f9\u18fb\u18fd;\u6565;\u6568;\u652c;\u6534inus;\u629flus;\u629eimes;\u62a0\u0200LRlr\u1919\u191b\u191d\u191f;\u655b;\u6558;\u6518;\u6514\u0380;HLRhlr\u1930\u1931\u1933\u1935\u1937\u1939\u193b\u6502;\u656a;\u6561;\u655e;\u653c;\u6524;\u651c\u0100ev\u0123\u1942bar\u803b\xa6\u40a6\u0200ceio\u1951\u1956\u195a\u1960r;\uc000\ud835\udcb7mi;\u604fm\u0100;e\u171a\u171cl\u0180;bh\u1968\u1969\u196b\u405c;\u69c5sub;\u67c8\u016c\u1974\u197el\u0100;e\u1979\u197a\u6022t\xbb\u197ap\u0180;Ee\u012f\u1985\u1987;\u6aae\u0100;q\u06dc\u06db\u0ce1\u19a7\0\u19e8\u1a11\u1a15\u1a32\0\u1a37\u1a50\0\0\u1ab4\0\0\u1ac1\0\0\u1b21\u1b2e\u1b4d\u1b52\0\u1bfd\0\u1c0c\u0180cpr\u19ad\u19b2\u19ddute;\u4107\u0300;abcds\u19bf\u19c0\u19c4\u19ca\u19d5\u19d9\u6229nd;\u6a44rcup;\u6a49\u0100au\u19cf\u19d2p;\u6a4bp;\u6a47ot;\u6a40;\uc000\u2229\ufe00\u0100eo\u19e2\u19e5t;\u6041\xee\u0693\u0200aeiu\u19f0\u19fb\u1a01\u1a05\u01f0\u19f5\0\u19f8s;\u6a4don;\u410ddil\u803b\xe7\u40e7rc;\u4109ps\u0100;s\u1a0c\u1a0d\u6a4cm;\u6a50ot;\u410b\u0180dmn\u1a1b\u1a20\u1a26il\u80bb\xb8\u01adptyv;\u69b2t\u8100\xa2;e\u1a2d\u1a2e\u40a2r\xe4\u01b2r;\uc000\ud835\udd20\u0180cei\u1a3d\u1a40\u1a4dy;\u4447ck\u0100;m\u1a47\u1a48\u6713ark\xbb\u1a48;\u43c7r\u0380;Ecefms\u1a5f\u1a60\u1a62\u1a6b\u1aa4\u1aaa\u1aae\u65cb;\u69c3\u0180;el\u1a69\u1a6a\u1a6d\u42c6q;\u6257e\u0261\u1a74\0\0\u1a88rrow\u0100lr\u1a7c\u1a81eft;\u61baight;\u61bb\u0280RSacd\u1a92\u1a94\u1a96\u1a9a\u1a9f\xbb\u0f47;\u64c8st;\u629birc;\u629aash;\u629dnint;\u6a10id;\u6aefcir;\u69c2ubs\u0100;u\u1abb\u1abc\u6663it\xbb\u1abc\u02ec\u1ac7\u1ad4\u1afa\0\u1b0aon\u0100;e\u1acd\u1ace\u403a\u0100;q\xc7\xc6\u026d\u1ad9\0\0\u1ae2a\u0100;t\u1ade\u1adf\u402c;\u4040\u0180;fl\u1ae8\u1ae9\u1aeb\u6201\xee\u1160e\u0100mx\u1af1\u1af6ent\xbb\u1ae9e\xf3\u024d\u01e7\u1afe\0\u1b07\u0100;d\u12bb\u1b02ot;\u6a6dn\xf4\u0246\u0180fry\u1b10\u1b14\u1b17;\uc000\ud835\udd54o\xe4\u0254\u8100\xa9;s\u0155\u1b1dr;\u6117\u0100ao\u1b25\u1b29rr;\u61b5ss;\u6717\u0100cu\u1b32\u1b37r;\uc000\ud835\udcb8\u0100bp\u1b3c\u1b44\u0100;e\u1b41\u1b42\u6acf;\u6ad1\u0100;e\u1b49\u1b4a\u6ad0;\u6ad2dot;\u62ef\u0380delprvw\u1b60\u1b6c\u1b77\u1b82\u1bac\u1bd4\u1bf9arr\u0100lr\u1b68\u1b6a;\u6938;\u6935\u0270\u1b72\0\0\u1b75r;\u62dec;\u62dfarr\u0100;p\u1b7f\u1b80\u61b6;\u693d\u0300;bcdos\u1b8f\u1b90\u1b96\u1ba1\u1ba5\u1ba8\u622arcap;\u6a48\u0100au\u1b9b\u1b9ep;\u6a46p;\u6a4aot;\u628dr;\u6a45;\uc000\u222a\ufe00\u0200alrv\u1bb5\u1bbf\u1bde\u1be3rr\u0100;m\u1bbc\u1bbd\u61b7;\u693cy\u0180evw\u1bc7\u1bd4\u1bd8q\u0270\u1bce\0\0\u1bd2re\xe3\u1b73u\xe3\u1b75ee;\u62ceedge;\u62cfen\u803b\xa4\u40a4earrow\u0100lr\u1bee\u1bf3eft\xbb\u1b80ight\xbb\u1bbde\xe4\u1bdd\u0100ci\u1c01\u1c07onin\xf4\u01f7nt;\u6231lcty;\u632d\u0980AHabcdefhijlorstuwz\u1c38\u1c3b\u1c3f\u1c5d\u1c69\u1c75\u1c8a\u1c9e\u1cac\u1cb7\u1cfb\u1cff\u1d0d\u1d7b\u1d91\u1dab\u1dbb\u1dc6\u1dcdr\xf2\u0381ar;\u6965\u0200glrs\u1c48\u1c4d\u1c52\u1c54ger;\u6020eth;\u6138\xf2\u1133h\u0100;v\u1c5a\u1c5b\u6010\xbb\u090a\u016b\u1c61\u1c67arow;\u690fa\xe3\u0315\u0100ay\u1c6e\u1c73ron;\u410f;\u4434\u0180;ao\u0332\u1c7c\u1c84\u0100gr\u02bf\u1c81r;\u61catseq;\u6a77\u0180glm\u1c91\u1c94\u1c98\u803b\xb0\u40b0ta;\u43b4ptyv;\u69b1\u0100ir\u1ca3\u1ca8sht;\u697f;\uc000\ud835\udd21ar\u0100lr\u1cb3\u1cb5\xbb\u08dc\xbb\u101e\u0280aegsv\u1cc2\u0378\u1cd6\u1cdc\u1ce0m\u0180;os\u0326\u1cca\u1cd4nd\u0100;s\u0326\u1cd1uit;\u6666amma;\u43ddin;\u62f2\u0180;io\u1ce7\u1ce8\u1cf8\u40f7de\u8100\xf7;o\u1ce7\u1cf0ntimes;\u62c7n\xf8\u1cf7cy;\u4452c\u026f\u1d06\0\0\u1d0arn;\u631eop;\u630d\u0280lptuw\u1d18\u1d1d\u1d22\u1d49\u1d55lar;\u4024f;\uc000\ud835\udd55\u0280;emps\u030b\u1d2d\u1d37\u1d3d\u1d42q\u0100;d\u0352\u1d33ot;\u6251inus;\u6238lus;\u6214quare;\u62a1blebarwedg\xe5\xfan\u0180adh\u112e\u1d5d\u1d67ownarrow\xf3\u1c83arpoon\u0100lr\u1d72\u1d76ef\xf4\u1cb4igh\xf4\u1cb6\u0162\u1d7f\u1d85karo\xf7\u0f42\u026f\u1d8a\0\0\u1d8ern;\u631fop;\u630c\u0180cot\u1d98\u1da3\u1da6\u0100ry\u1d9d\u1da1;\uc000\ud835\udcb9;\u4455l;\u69f6rok;\u4111\u0100dr\u1db0\u1db4ot;\u62f1i\u0100;f\u1dba\u1816\u65bf\u0100ah\u1dc0\u1dc3r\xf2\u0429a\xf2\u0fa6angle;\u69a6\u0100ci\u1dd2\u1dd5y;\u445fgrarr;\u67ff\u0900Dacdefglmnopqrstux\u1e01\u1e09\u1e19\u1e38\u0578\u1e3c\u1e49\u1e61\u1e7e\u1ea5\u1eaf\u1ebd\u1ee1\u1f2a\u1f37\u1f44\u1f4e\u1f5a\u0100Do\u1e06\u1d34o\xf4\u1c89\u0100cs\u1e0e\u1e14ute\u803b\xe9\u40e9ter;\u6a6e\u0200aioy\u1e22\u1e27\u1e31\u1e36ron;\u411br\u0100;c\u1e2d\u1e2e\u6256\u803b\xea\u40ealon;\u6255;\u444dot;\u4117\u0100Dr\u1e41\u1e45ot;\u6252;\uc000\ud835\udd22\u0180;rs\u1e50\u1e51\u1e57\u6a9aave\u803b\xe8\u40e8\u0100;d\u1e5c\u1e5d\u6a96ot;\u6a98\u0200;ils\u1e6a\u1e6b\u1e72\u1e74\u6a99nters;\u63e7;\u6113\u0100;d\u1e79\u1e7a\u6a95ot;\u6a97\u0180aps\u1e85\u1e89\u1e97cr;\u4113ty\u0180;sv\u1e92\u1e93\u1e95\u6205et\xbb\u1e93p\u01001;\u1e9d\u1ea4\u0133\u1ea1\u1ea3;\u6004;\u6005\u6003\u0100gs\u1eaa\u1eac;\u414bp;\u6002\u0100gp\u1eb4\u1eb8on;\u4119f;\uc000\ud835\udd56\u0180als\u1ec4\u1ece\u1ed2r\u0100;s\u1eca\u1ecb\u62d5l;\u69e3us;\u6a71i\u0180;lv\u1eda\u1edb\u1edf\u43b5on\xbb\u1edb;\u43f5\u0200csuv\u1eea\u1ef3\u1f0b\u1f23\u0100io\u1eef\u1e31rc\xbb\u1e2e\u0269\u1ef9\0\0\u1efb\xed\u0548ant\u0100gl\u1f02\u1f06tr\xbb\u1e5dess\xbb\u1e7a\u0180aei\u1f12\u1f16\u1f1als;\u403dst;\u625fv\u0100;D\u0235\u1f20D;\u6a78parsl;\u69e5\u0100Da\u1f2f\u1f33ot;\u6253rr;\u6971\u0180cdi\u1f3e\u1f41\u1ef8r;\u612fo\xf4\u0352\u0100ah\u1f49\u1f4b;\u43b7\u803b\xf0\u40f0\u0100mr\u1f53\u1f57l\u803b\xeb\u40ebo;\u60ac\u0180cip\u1f61\u1f64\u1f67l;\u4021s\xf4\u056e\u0100eo\u1f6c\u1f74ctatio\xee\u0559nential\xe5\u0579\u09e1\u1f92\0\u1f9e\0\u1fa1\u1fa7\0\0\u1fc6\u1fcc\0\u1fd3\0\u1fe6\u1fea\u2000\0\u2008\u205allingdotse\xf1\u1e44y;\u4444male;\u6640\u0180ilr\u1fad\u1fb3\u1fc1lig;\u8000\ufb03\u0269\u1fb9\0\0\u1fbdg;\u8000\ufb00ig;\u8000\ufb04;\uc000\ud835\udd23lig;\u8000\ufb01lig;\uc000fj\u0180alt\u1fd9\u1fdc\u1fe1t;\u666dig;\u8000\ufb02ns;\u65b1of;\u4192\u01f0\u1fee\0\u1ff3f;\uc000\ud835\udd57\u0100ak\u05bf\u1ff7\u0100;v\u1ffc\u1ffd\u62d4;\u6ad9artint;\u6a0d\u0100ao\u200c\u2055\u0100cs\u2011\u2052\u03b1\u201a\u2030\u2038\u2045\u2048\0\u2050\u03b2\u2022\u2025\u2027\u202a\u202c\0\u202e\u803b\xbd\u40bd;\u6153\u803b\xbc\u40bc;\u6155;\u6159;\u615b\u01b3\u2034\0\u2036;\u6154;\u6156\u02b4\u203e\u2041\0\0\u2043\u803b\xbe\u40be;\u6157;\u615c5;\u6158\u01b6\u204c\0\u204e;\u615a;\u615d8;\u615el;\u6044wn;\u6322cr;\uc000\ud835\udcbb\u0880Eabcdefgijlnorstv\u2082\u2089\u209f\u20a5\u20b0\u20b4\u20f0\u20f5\u20fa\u20ff\u2103\u2112\u2138\u0317\u213e\u2152\u219e\u0100;l\u064d\u2087;\u6a8c\u0180cmp\u2090\u2095\u209dute;\u41f5ma\u0100;d\u209c\u1cda\u43b3;\u6a86reve;\u411f\u0100iy\u20aa\u20aerc;\u411d;\u4433ot;\u4121\u0200;lqs\u063e\u0642\u20bd\u20c9\u0180;qs\u063e\u064c\u20c4lan\xf4\u0665\u0200;cdl\u0665\u20d2\u20d5\u20e5c;\u6aa9ot\u0100;o\u20dc\u20dd\u6a80\u0100;l\u20e2\u20e3\u6a82;\u6a84\u0100;e\u20ea\u20ed\uc000\u22db\ufe00s;\u6a94r;\uc000\ud835\udd24\u0100;g\u0673\u061bmel;\u6137cy;\u4453\u0200;Eaj\u065a\u210c\u210e\u2110;\u6a92;\u6aa5;\u6aa4\u0200Eaes\u211b\u211d\u2129\u2134;\u6269p\u0100;p\u2123\u2124\u6a8arox\xbb\u2124\u0100;q\u212e\u212f\u6a88\u0100;q\u212e\u211bim;\u62e7pf;\uc000\ud835\udd58\u0100ci\u2143\u2146r;\u610am\u0180;el\u066b\u214e\u2150;\u6a8e;\u6a90\u8300>;cdlqr\u05ee\u2160\u216a\u216e\u2173\u2179\u0100ci\u2165\u2167;\u6aa7r;\u6a7aot;\u62d7Par;\u6995uest;\u6a7c\u0280adels\u2184\u216a\u2190\u0656\u219b\u01f0\u2189\0\u218epro\xf8\u209er;\u6978q\u0100lq\u063f\u2196les\xf3\u2088i\xed\u066b\u0100en\u21a3\u21adrtneqq;\uc000\u2269\ufe00\xc5\u21aa\u0500Aabcefkosy\u21c4\u21c7\u21f1\u21f5\u21fa\u2218\u221d\u222f\u2268\u227dr\xf2\u03a0\u0200ilmr\u21d0\u21d4\u21d7\u21dbrs\xf0\u1484f\xbb\u2024il\xf4\u06a9\u0100dr\u21e0\u21e4cy;\u444a\u0180;cw\u08f4\u21eb\u21efir;\u6948;\u61adar;\u610firc;\u4125\u0180alr\u2201\u220e\u2213rts\u0100;u\u2209\u220a\u6665it\xbb\u220alip;\u6026con;\u62b9r;\uc000\ud835\udd25s\u0100ew\u2223\u2229arow;\u6925arow;\u6926\u0280amopr\u223a\u223e\u2243\u225e\u2263rr;\u61fftht;\u623bk\u0100lr\u2249\u2253eftarrow;\u61a9ightarrow;\u61aaf;\uc000\ud835\udd59bar;\u6015\u0180clt\u226f\u2274\u2278r;\uc000\ud835\udcbdas\xe8\u21f4rok;\u4127\u0100bp\u2282\u2287ull;\u6043hen\xbb\u1c5b\u0ae1\u22a3\0\u22aa\0\u22b8\u22c5\u22ce\0\u22d5\u22f3\0\0\u22f8\u2322\u2367\u2362\u237f\0\u2386\u23aa\u23b4cute\u803b\xed\u40ed\u0180;iy\u0771\u22b0\u22b5rc\u803b\xee\u40ee;\u4438\u0100cx\u22bc\u22bfy;\u4435cl\u803b\xa1\u40a1\u0100fr\u039f\u22c9;\uc000\ud835\udd26rave\u803b\xec\u40ec\u0200;ino\u073e\u22dd\u22e9\u22ee\u0100in\u22e2\u22e6nt;\u6a0ct;\u622dfin;\u69dcta;\u6129lig;\u4133\u0180aop\u22fe\u231a\u231d\u0180cgt\u2305\u2308\u2317r;\u412b\u0180elp\u071f\u230f\u2313in\xe5\u078ear\xf4\u0720h;\u4131f;\u62b7ed;\u41b5\u0280;cfot\u04f4\u232c\u2331\u233d\u2341are;\u6105in\u0100;t\u2338\u2339\u621eie;\u69dddo\xf4\u2319\u0280;celp\u0757\u234c\u2350\u235b\u2361al;\u62ba\u0100gr\u2355\u2359er\xf3\u1563\xe3\u234darhk;\u6a17rod;\u6a3c\u0200cgpt\u236f\u2372\u2376\u237by;\u4451on;\u412ff;\uc000\ud835\udd5aa;\u43b9uest\u803b\xbf\u40bf\u0100ci\u238a\u238fr;\uc000\ud835\udcben\u0280;Edsv\u04f4\u239b\u239d\u23a1\u04f3;\u62f9ot;\u62f5\u0100;v\u23a6\u23a7\u62f4;\u62f3\u0100;i\u0777\u23aelde;\u4129\u01eb\u23b8\0\u23bccy;\u4456l\u803b\xef\u40ef\u0300cfmosu\u23cc\u23d7\u23dc\u23e1\u23e7\u23f5\u0100iy\u23d1\u23d5rc;\u4135;\u4439r;\uc000\ud835\udd27ath;\u4237pf;\uc000\ud835\udd5b\u01e3\u23ec\0\u23f1r;\uc000\ud835\udcbfrcy;\u4458kcy;\u4454\u0400acfghjos\u240b\u2416\u2422\u2427\u242d\u2431\u2435\u243bppa\u0100;v\u2413\u2414\u43ba;\u43f0\u0100ey\u241b\u2420dil;\u4137;\u443ar;\uc000\ud835\udd28reen;\u4138cy;\u4445cy;\u445cpf;\uc000\ud835\udd5ccr;\uc000\ud835\udcc0\u0b80ABEHabcdefghjlmnoprstuv\u2470\u2481\u2486\u248d\u2491\u250e\u253d\u255a\u2580\u264e\u265e\u2665\u2679\u267d\u269a\u26b2\u26d8\u275d\u2768\u278b\u27c0\u2801\u2812\u0180art\u2477\u247a\u247cr\xf2\u09c6\xf2\u0395ail;\u691barr;\u690e\u0100;g\u0994\u248b;\u6a8bar;\u6962\u0963\u24a5\0\u24aa\0\u24b1\0\0\0\0\0\u24b5\u24ba\0\u24c6\u24c8\u24cd\0\u24f9ute;\u413amptyv;\u69b4ra\xee\u084cbda;\u43bbg\u0180;dl\u088e\u24c1\u24c3;\u6991\xe5\u088e;\u6a85uo\u803b\xab\u40abr\u0400;bfhlpst\u0899\u24de\u24e6\u24e9\u24eb\u24ee\u24f1\u24f5\u0100;f\u089d\u24e3s;\u691fs;\u691d\xeb\u2252p;\u61abl;\u6939im;\u6973l;\u61a2\u0180;ae\u24ff\u2500\u2504\u6aabil;\u6919\u0100;s\u2509\u250a\u6aad;\uc000\u2aad\ufe00\u0180abr\u2515\u2519\u251drr;\u690crk;\u6772\u0100ak\u2522\u252cc\u0100ek\u2528\u252a;\u407b;\u405b\u0100es\u2531\u2533;\u698bl\u0100du\u2539\u253b;\u698f;\u698d\u0200aeuy\u2546\u254b\u2556\u2558ron;\u413e\u0100di\u2550\u2554il;\u413c\xec\u08b0\xe2\u2529;\u443b\u0200cqrs\u2563\u2566\u256d\u257da;\u6936uo\u0100;r\u0e19\u1746\u0100du\u2572\u2577har;\u6967shar;\u694bh;\u61b2\u0280;fgqs\u258b\u258c\u0989\u25f3\u25ff\u6264t\u0280ahlrt\u2598\u25a4\u25b7\u25c2\u25e8rrow\u0100;t\u0899\u25a1a\xe9\u24f6arpoon\u0100du\u25af\u25b4own\xbb\u045ap\xbb\u0966eftarrows;\u61c7ight\u0180ahs\u25cd\u25d6\u25derrow\u0100;s\u08f4\u08a7arpoon\xf3\u0f98quigarro\xf7\u21f0hreetimes;\u62cb\u0180;qs\u258b\u0993\u25falan\xf4\u09ac\u0280;cdgs\u09ac\u260a\u260d\u261d\u2628c;\u6aa8ot\u0100;o\u2614\u2615\u6a7f\u0100;r\u261a\u261b\u6a81;\u6a83\u0100;e\u2622\u2625\uc000\u22da\ufe00s;\u6a93\u0280adegs\u2633\u2639\u263d\u2649\u264bppro\xf8\u24c6ot;\u62d6q\u0100gq\u2643\u2645\xf4\u0989gt\xf2\u248c\xf4\u099bi\xed\u09b2\u0180ilr\u2655\u08e1\u265asht;\u697c;\uc000\ud835\udd29\u0100;E\u099c\u2663;\u6a91\u0161\u2669\u2676r\u0100du\u25b2\u266e\u0100;l\u0965\u2673;\u696alk;\u6584cy;\u4459\u0280;acht\u0a48\u2688\u268b\u2691\u2696r\xf2\u25c1orne\xf2\u1d08ard;\u696bri;\u65fa\u0100io\u269f\u26a4dot;\u4140ust\u0100;a\u26ac\u26ad\u63b0che\xbb\u26ad\u0200Eaes\u26bb\u26bd\u26c9\u26d4;\u6268p\u0100;p\u26c3\u26c4\u6a89rox\xbb\u26c4\u0100;q\u26ce\u26cf\u6a87\u0100;q\u26ce\u26bbim;\u62e6\u0400abnoptwz\u26e9\u26f4\u26f7\u271a\u272f\u2741\u2747\u2750\u0100nr\u26ee\u26f1g;\u67ecr;\u61fdr\xeb\u08c1g\u0180lmr\u26ff\u270d\u2714eft\u0100ar\u09e6\u2707ight\xe1\u09f2apsto;\u67fcight\xe1\u09fdparrow\u0100lr\u2725\u2729ef\xf4\u24edight;\u61ac\u0180afl\u2736\u2739\u273dr;\u6985;\uc000\ud835\udd5dus;\u6a2dimes;\u6a34\u0161\u274b\u274fst;\u6217\xe1\u134e\u0180;ef\u2757\u2758\u1800\u65cange\xbb\u2758ar\u0100;l\u2764\u2765\u4028t;\u6993\u0280achmt\u2773\u2776\u277c\u2785\u2787r\xf2\u08a8orne\xf2\u1d8car\u0100;d\u0f98\u2783;\u696d;\u600eri;\u62bf\u0300achiqt\u2798\u279d\u0a40\u27a2\u27ae\u27bbquo;\u6039r;\uc000\ud835\udcc1m\u0180;eg\u09b2\u27aa\u27ac;\u6a8d;\u6a8f\u0100bu\u252a\u27b3o\u0100;r\u0e1f\u27b9;\u601arok;\u4142\u8400<;cdhilqr\u082b\u27d2\u2639\u27dc\u27e0\u27e5\u27ea\u27f0\u0100ci\u27d7\u27d9;\u6aa6r;\u6a79re\xe5\u25f2mes;\u62c9arr;\u6976uest;\u6a7b\u0100Pi\u27f5\u27f9ar;\u6996\u0180;ef\u2800\u092d\u181b\u65c3r\u0100du\u2807\u280dshar;\u694ahar;\u6966\u0100en\u2817\u2821rtneqq;\uc000\u2268\ufe00\xc5\u281e\u0700Dacdefhilnopsu\u2840\u2845\u2882\u288e\u2893\u28a0\u28a5\u28a8\u28da\u28e2\u28e4\u0a83\u28f3\u2902Dot;\u623a\u0200clpr\u284e\u2852\u2863\u287dr\u803b\xaf\u40af\u0100et\u2857\u2859;\u6642\u0100;e\u285e\u285f\u6720se\xbb\u285f\u0100;s\u103b\u2868to\u0200;dlu\u103b\u2873\u2877\u287bow\xee\u048cef\xf4\u090f\xf0\u13d1ker;\u65ae\u0100oy\u2887\u288cmma;\u6a29;\u443cash;\u6014asuredangle\xbb\u1626r;\uc000\ud835\udd2ao;\u6127\u0180cdn\u28af\u28b4\u28c9ro\u803b\xb5\u40b5\u0200;acd\u1464\u28bd\u28c0\u28c4s\xf4\u16a7ir;\u6af0ot\u80bb\xb7\u01b5us\u0180;bd\u28d2\u1903\u28d3\u6212\u0100;u\u1d3c\u28d8;\u6a2a\u0163\u28de\u28e1p;\u6adb\xf2\u2212\xf0\u0a81\u0100dp\u28e9\u28eeels;\u62a7f;\uc000\ud835\udd5e\u0100ct\u28f8\u28fdr;\uc000\ud835\udcc2pos\xbb\u159d\u0180;lm\u2909\u290a\u290d\u43bctimap;\u62b8\u0c00GLRVabcdefghijlmoprstuvw\u2942\u2953\u297e\u2989\u2998\u29da\u29e9\u2a15\u2a1a\u2a58\u2a5d\u2a83\u2a95\u2aa4\u2aa8\u2b04\u2b07\u2b44\u2b7f\u2bae\u2c34\u2c67\u2c7c\u2ce9\u0100gt\u2947\u294b;\uc000\u22d9\u0338\u0100;v\u2950\u0bcf\uc000\u226b\u20d2\u0180elt\u295a\u2972\u2976ft\u0100ar\u2961\u2967rrow;\u61cdightarrow;\u61ce;\uc000\u22d8\u0338\u0100;v\u297b\u0c47\uc000\u226a\u20d2ightarrow;\u61cf\u0100Dd\u298e\u2993ash;\u62afash;\u62ae\u0280bcnpt\u29a3\u29a7\u29ac\u29b1\u29ccla\xbb\u02deute;\u4144g;\uc000\u2220\u20d2\u0280;Eiop\u0d84\u29bc\u29c0\u29c5\u29c8;\uc000\u2a70\u0338d;\uc000\u224b\u0338s;\u4149ro\xf8\u0d84ur\u0100;a\u29d3\u29d4\u666el\u0100;s\u29d3\u0b38\u01f3\u29df\0\u29e3p\u80bb\xa0\u0b37mp\u0100;e\u0bf9\u0c00\u0280aeouy\u29f4\u29fe\u2a03\u2a10\u2a13\u01f0\u29f9\0\u29fb;\u6a43on;\u4148dil;\u4146ng\u0100;d\u0d7e\u2a0aot;\uc000\u2a6d\u0338p;\u6a42;\u443dash;\u6013\u0380;Aadqsx\u0b92\u2a29\u2a2d\u2a3b\u2a41\u2a45\u2a50rr;\u61d7r\u0100hr\u2a33\u2a36k;\u6924\u0100;o\u13f2\u13f0ot;\uc000\u2250\u0338ui\xf6\u0b63\u0100ei\u2a4a\u2a4ear;\u6928\xed\u0b98ist\u0100;s\u0ba0\u0b9fr;\uc000\ud835\udd2b\u0200Eest\u0bc5\u2a66\u2a79\u2a7c\u0180;qs\u0bbc\u2a6d\u0be1\u0180;qs\u0bbc\u0bc5\u2a74lan\xf4\u0be2i\xed\u0bea\u0100;r\u0bb6\u2a81\xbb\u0bb7\u0180Aap\u2a8a\u2a8d\u2a91r\xf2\u2971rr;\u61aear;\u6af2\u0180;sv\u0f8d\u2a9c\u0f8c\u0100;d\u2aa1\u2aa2\u62fc;\u62facy;\u445a\u0380AEadest\u2ab7\u2aba\u2abe\u2ac2\u2ac5\u2af6\u2af9r\xf2\u2966;\uc000\u2266\u0338rr;\u619ar;\u6025\u0200;fqs\u0c3b\u2ace\u2ae3\u2aeft\u0100ar\u2ad4\u2ad9rro\xf7\u2ac1ightarro\xf7\u2a90\u0180;qs\u0c3b\u2aba\u2aealan\xf4\u0c55\u0100;s\u0c55\u2af4\xbb\u0c36i\xed\u0c5d\u0100;r\u0c35\u2afei\u0100;e\u0c1a\u0c25i\xe4\u0d90\u0100pt\u2b0c\u2b11f;\uc000\ud835\udd5f\u8180\xac;in\u2b19\u2b1a\u2b36\u40acn\u0200;Edv\u0b89\u2b24\u2b28\u2b2e;\uc000\u22f9\u0338ot;\uc000\u22f5\u0338\u01e1\u0b89\u2b33\u2b35;\u62f7;\u62f6i\u0100;v\u0cb8\u2b3c\u01e1\u0cb8\u2b41\u2b43;\u62fe;\u62fd\u0180aor\u2b4b\u2b63\u2b69r\u0200;ast\u0b7b\u2b55\u2b5a\u2b5flle\xec\u0b7bl;\uc000\u2afd\u20e5;\uc000\u2202\u0338lint;\u6a14\u0180;ce\u0c92\u2b70\u2b73u\xe5\u0ca5\u0100;c\u0c98\u2b78\u0100;e\u0c92\u2b7d\xf1\u0c98\u0200Aait\u2b88\u2b8b\u2b9d\u2ba7r\xf2\u2988rr\u0180;cw\u2b94\u2b95\u2b99\u619b;\uc000\u2933\u0338;\uc000\u219d\u0338ghtarrow\xbb\u2b95ri\u0100;e\u0ccb\u0cd6\u0380chimpqu\u2bbd\u2bcd\u2bd9\u2b04\u0b78\u2be4\u2bef\u0200;cer\u0d32\u2bc6\u0d37\u2bc9u\xe5\u0d45;\uc000\ud835\udcc3ort\u026d\u2b05\0\0\u2bd6ar\xe1\u2b56m\u0100;e\u0d6e\u2bdf\u0100;q\u0d74\u0d73su\u0100bp\u2beb\u2bed\xe5\u0cf8\xe5\u0d0b\u0180bcp\u2bf6\u2c11\u2c19\u0200;Ees\u2bff\u2c00\u0d22\u2c04\u6284;\uc000\u2ac5\u0338et\u0100;e\u0d1b\u2c0bq\u0100;q\u0d23\u2c00c\u0100;e\u0d32\u2c17\xf1\u0d38\u0200;Ees\u2c22\u2c23\u0d5f\u2c27\u6285;\uc000\u2ac6\u0338et\u0100;e\u0d58\u2c2eq\u0100;q\u0d60\u2c23\u0200gilr\u2c3d\u2c3f\u2c45\u2c47\xec\u0bd7lde\u803b\xf1\u40f1\xe7\u0c43iangle\u0100lr\u2c52\u2c5ceft\u0100;e\u0c1a\u2c5a\xf1\u0c26ight\u0100;e\u0ccb\u2c65\xf1\u0cd7\u0100;m\u2c6c\u2c6d\u43bd\u0180;es\u2c74\u2c75\u2c79\u4023ro;\u6116p;\u6007\u0480DHadgilrs\u2c8f\u2c94\u2c99\u2c9e\u2ca3\u2cb0\u2cb6\u2cd3\u2ce3ash;\u62adarr;\u6904p;\uc000\u224d\u20d2ash;\u62ac\u0100et\u2ca8\u2cac;\uc000\u2265\u20d2;\uc000>\u20d2nfin;\u69de\u0180Aet\u2cbd\u2cc1\u2cc5rr;\u6902;\uc000\u2264\u20d2\u0100;r\u2cca\u2ccd\uc000<\u20d2ie;\uc000\u22b4\u20d2\u0100At\u2cd8\u2cdcrr;\u6903rie;\uc000\u22b5\u20d2im;\uc000\u223c\u20d2\u0180Aan\u2cf0\u2cf4\u2d02rr;\u61d6r\u0100hr\u2cfa\u2cfdk;\u6923\u0100;o\u13e7\u13e5ear;\u6927\u1253\u1a95\0\0\0\0\0\0\0\0\0\0\0\0\0\u2d2d\0\u2d38\u2d48\u2d60\u2d65\u2d72\u2d84\u1b07\0\0\u2d8d\u2dab\0\u2dc8\u2dce\0\u2ddc\u2e19\u2e2b\u2e3e\u2e43\u0100cs\u2d31\u1a97ute\u803b\xf3\u40f3\u0100iy\u2d3c\u2d45r\u0100;c\u1a9e\u2d42\u803b\xf4\u40f4;\u443e\u0280abios\u1aa0\u2d52\u2d57\u01c8\u2d5alac;\u4151v;\u6a38old;\u69bclig;\u4153\u0100cr\u2d69\u2d6dir;\u69bf;\uc000\ud835\udd2c\u036f\u2d79\0\0\u2d7c\0\u2d82n;\u42dbave\u803b\xf2\u40f2;\u69c1\u0100bm\u2d88\u0df4ar;\u69b5\u0200acit\u2d95\u2d98\u2da5\u2da8r\xf2\u1a80\u0100ir\u2d9d\u2da0r;\u69beoss;\u69bbn\xe5\u0e52;\u69c0\u0180aei\u2db1\u2db5\u2db9cr;\u414dga;\u43c9\u0180cdn\u2dc0\u2dc5\u01cdron;\u43bf;\u69b6pf;\uc000\ud835\udd60\u0180ael\u2dd4\u2dd7\u01d2r;\u69b7rp;\u69b9\u0380;adiosv\u2dea\u2deb\u2dee\u2e08\u2e0d\u2e10\u2e16\u6228r\xf2\u1a86\u0200;efm\u2df7\u2df8\u2e02\u2e05\u6a5dr\u0100;o\u2dfe\u2dff\u6134f\xbb\u2dff\u803b\xaa\u40aa\u803b\xba\u40bagof;\u62b6r;\u6a56lope;\u6a57;\u6a5b\u0180clo\u2e1f\u2e21\u2e27\xf2\u2e01ash\u803b\xf8\u40f8l;\u6298i\u016c\u2e2f\u2e34de\u803b\xf5\u40f5es\u0100;a\u01db\u2e3as;\u6a36ml\u803b\xf6\u40f6bar;\u633d\u0ae1\u2e5e\0\u2e7d\0\u2e80\u2e9d\0\u2ea2\u2eb9\0\0\u2ecb\u0e9c\0\u2f13\0\0\u2f2b\u2fbc\0\u2fc8r\u0200;ast\u0403\u2e67\u2e72\u0e85\u8100\xb6;l\u2e6d\u2e6e\u40b6le\xec\u0403\u0269\u2e78\0\0\u2e7bm;\u6af3;\u6afdy;\u443fr\u0280cimpt\u2e8b\u2e8f\u2e93\u1865\u2e97nt;\u4025od;\u402eil;\u6030enk;\u6031r;\uc000\ud835\udd2d\u0180imo\u2ea8\u2eb0\u2eb4\u0100;v\u2ead\u2eae\u43c6;\u43d5ma\xf4\u0a76ne;\u660e\u0180;tv\u2ebf\u2ec0\u2ec8\u43c0chfork\xbb\u1ffd;\u43d6\u0100au\u2ecf\u2edfn\u0100ck\u2ed5\u2eddk\u0100;h\u21f4\u2edb;\u610e\xf6\u21f4s\u0480;abcdemst\u2ef3\u2ef4\u1908\u2ef9\u2efd\u2f04\u2f06\u2f0a\u2f0e\u402bcir;\u6a23ir;\u6a22\u0100ou\u1d40\u2f02;\u6a25;\u6a72n\u80bb\xb1\u0e9dim;\u6a26wo;\u6a27\u0180ipu\u2f19\u2f20\u2f25ntint;\u6a15f;\uc000\ud835\udd61nd\u803b\xa3\u40a3\u0500;Eaceinosu\u0ec8\u2f3f\u2f41\u2f44\u2f47\u2f81\u2f89\u2f92\u2f7e\u2fb6;\u6ab3p;\u6ab7u\xe5\u0ed9\u0100;c\u0ece\u2f4c\u0300;acens\u0ec8\u2f59\u2f5f\u2f66\u2f68\u2f7eppro\xf8\u2f43urlye\xf1\u0ed9\xf1\u0ece\u0180aes\u2f6f\u2f76\u2f7approx;\u6ab9qq;\u6ab5im;\u62e8i\xed\u0edfme\u0100;s\u2f88\u0eae\u6032\u0180Eas\u2f78\u2f90\u2f7a\xf0\u2f75\u0180dfp\u0eec\u2f99\u2faf\u0180als\u2fa0\u2fa5\u2faalar;\u632eine;\u6312urf;\u6313\u0100;t\u0efb\u2fb4\xef\u0efbrel;\u62b0\u0100ci\u2fc0\u2fc5r;\uc000\ud835\udcc5;\u43c8ncsp;\u6008\u0300fiopsu\u2fda\u22e2\u2fdf\u2fe5\u2feb\u2ff1r;\uc000\ud835\udd2epf;\uc000\ud835\udd62rime;\u6057cr;\uc000\ud835\udcc6\u0180aeo\u2ff8\u3009\u3013t\u0100ei\u2ffe\u3005rnion\xf3\u06b0nt;\u6a16st\u0100;e\u3010\u3011\u403f\xf1\u1f19\xf4\u0f14\u0a80ABHabcdefhilmnoprstux\u3040\u3051\u3055\u3059\u30e0\u310e\u312b\u3147\u3162\u3172\u318e\u3206\u3215\u3224\u3229\u3258\u326e\u3272\u3290\u32b0\u32b7\u0180art\u3047\u304a\u304cr\xf2\u10b3\xf2\u03ddail;\u691car\xf2\u1c65ar;\u6964\u0380cdenqrt\u3068\u3075\u3078\u307f\u308f\u3094\u30cc\u0100eu\u306d\u3071;\uc000\u223d\u0331te;\u4155i\xe3\u116emptyv;\u69b3g\u0200;del\u0fd1\u3089\u308b\u308d;\u6992;\u69a5\xe5\u0fd1uo\u803b\xbb\u40bbr\u0580;abcfhlpstw\u0fdc\u30ac\u30af\u30b7\u30b9\u30bc\u30be\u30c0\u30c3\u30c7\u30cap;\u6975\u0100;f\u0fe0\u30b4s;\u6920;\u6933s;\u691e\xeb\u225d\xf0\u272el;\u6945im;\u6974l;\u61a3;\u619d\u0100ai\u30d1\u30d5il;\u691ao\u0100;n\u30db\u30dc\u6236al\xf3\u0f1e\u0180abr\u30e7\u30ea\u30eer\xf2\u17e5rk;\u6773\u0100ak\u30f3\u30fdc\u0100ek\u30f9\u30fb;\u407d;\u405d\u0100es\u3102\u3104;\u698cl\u0100du\u310a\u310c;\u698e;\u6990\u0200aeuy\u3117\u311c\u3127\u3129ron;\u4159\u0100di\u3121\u3125il;\u4157\xec\u0ff2\xe2\u30fa;\u4440\u0200clqs\u3134\u3137\u313d\u3144a;\u6937dhar;\u6969uo\u0100;r\u020e\u020dh;\u61b3\u0180acg\u314e\u315f\u0f44l\u0200;ips\u0f78\u3158\u315b\u109cn\xe5\u10bbar\xf4\u0fa9t;\u65ad\u0180ilr\u3169\u1023\u316esht;\u697d;\uc000\ud835\udd2f\u0100ao\u3177\u3186r\u0100du\u317d\u317f\xbb\u047b\u0100;l\u1091\u3184;\u696c\u0100;v\u318b\u318c\u43c1;\u43f1\u0180gns\u3195\u31f9\u31fcht\u0300ahlrst\u31a4\u31b0\u31c2\u31d8\u31e4\u31eerrow\u0100;t\u0fdc\u31ada\xe9\u30c8arpoon\u0100du\u31bb\u31bfow\xee\u317ep\xbb\u1092eft\u0100ah\u31ca\u31d0rrow\xf3\u0feaarpoon\xf3\u0551ightarrows;\u61c9quigarro\xf7\u30cbhreetimes;\u62ccg;\u42daingdotse\xf1\u1f32\u0180ahm\u320d\u3210\u3213r\xf2\u0feaa\xf2\u0551;\u600foust\u0100;a\u321e\u321f\u63b1che\xbb\u321fmid;\u6aee\u0200abpt\u3232\u323d\u3240\u3252\u0100nr\u3237\u323ag;\u67edr;\u61fer\xeb\u1003\u0180afl\u3247\u324a\u324er;\u6986;\uc000\ud835\udd63us;\u6a2eimes;\u6a35\u0100ap\u325d\u3267r\u0100;g\u3263\u3264\u4029t;\u6994olint;\u6a12ar\xf2\u31e3\u0200achq\u327b\u3280\u10bc\u3285quo;\u603ar;\uc000\ud835\udcc7\u0100bu\u30fb\u328ao\u0100;r\u0214\u0213\u0180hir\u3297\u329b\u32a0re\xe5\u31f8mes;\u62cai\u0200;efl\u32aa\u1059\u1821\u32ab\u65b9tri;\u69celuhar;\u6968;\u611e\u0d61\u32d5\u32db\u32df\u332c\u3338\u3371\0\u337a\u33a4\0\0\u33ec\u33f0\0\u3428\u3448\u345a\u34ad\u34b1\u34ca\u34f1\0\u3616\0\0\u3633cute;\u415bqu\xef\u27ba\u0500;Eaceinpsy\u11ed\u32f3\u32f5\u32ff\u3302\u330b\u330f\u331f\u3326\u3329;\u6ab4\u01f0\u32fa\0\u32fc;\u6ab8on;\u4161u\xe5\u11fe\u0100;d\u11f3\u3307il;\u415frc;\u415d\u0180Eas\u3316\u3318\u331b;\u6ab6p;\u6abaim;\u62e9olint;\u6a13i\xed\u1204;\u4441ot\u0180;be\u3334\u1d47\u3335\u62c5;\u6a66\u0380Aacmstx\u3346\u334a\u3357\u335b\u335e\u3363\u336drr;\u61d8r\u0100hr\u3350\u3352\xeb\u2228\u0100;o\u0a36\u0a34t\u803b\xa7\u40a7i;\u403bwar;\u6929m\u0100in\u3369\xf0nu\xf3\xf1t;\u6736r\u0100;o\u3376\u2055\uc000\ud835\udd30\u0200acoy\u3382\u3386\u3391\u33a0rp;\u666f\u0100hy\u338b\u338fcy;\u4449;\u4448rt\u026d\u3399\0\0\u339ci\xe4\u1464ara\xec\u2e6f\u803b\xad\u40ad\u0100gm\u33a8\u33b4ma\u0180;fv\u33b1\u33b2\u33b2\u43c3;\u43c2\u0400;deglnpr\u12ab\u33c5\u33c9\u33ce\u33d6\u33de\u33e1\u33e6ot;\u6a6a\u0100;q\u12b1\u12b0\u0100;E\u33d3\u33d4\u6a9e;\u6aa0\u0100;E\u33db\u33dc\u6a9d;\u6a9fe;\u6246lus;\u6a24arr;\u6972ar\xf2\u113d\u0200aeit\u33f8\u3408\u340f\u3417\u0100ls\u33fd\u3404lsetm\xe9\u336ahp;\u6a33parsl;\u69e4\u0100dl\u1463\u3414e;\u6323\u0100;e\u341c\u341d\u6aaa\u0100;s\u3422\u3423\u6aac;\uc000\u2aac\ufe00\u0180flp\u342e\u3433\u3442tcy;\u444c\u0100;b\u3438\u3439\u402f\u0100;a\u343e\u343f\u69c4r;\u633ff;\uc000\ud835\udd64a\u0100dr\u344d\u0402es\u0100;u\u3454\u3455\u6660it\xbb\u3455\u0180csu\u3460\u3479\u349f\u0100au\u3465\u346fp\u0100;s\u1188\u346b;\uc000\u2293\ufe00p\u0100;s\u11b4\u3475;\uc000\u2294\ufe00u\u0100bp\u347f\u348f\u0180;es\u1197\u119c\u3486et\u0100;e\u1197\u348d\xf1\u119d\u0180;es\u11a8\u11ad\u3496et\u0100;e\u11a8\u349d\xf1\u11ae\u0180;af\u117b\u34a6\u05b0r\u0165\u34ab\u05b1\xbb\u117car\xf2\u1148\u0200cemt\u34b9\u34be\u34c2\u34c5r;\uc000\ud835\udcc8tm\xee\xf1i\xec\u3415ar\xe6\u11be\u0100ar\u34ce\u34d5r\u0100;f\u34d4\u17bf\u6606\u0100an\u34da\u34edight\u0100ep\u34e3\u34eapsilo\xee\u1ee0h\xe9\u2eafs\xbb\u2852\u0280bcmnp\u34fb\u355e\u1209\u358b\u358e\u0480;Edemnprs\u350e\u350f\u3511\u3515\u351e\u3523\u352c\u3531\u3536\u6282;\u6ac5ot;\u6abd\u0100;d\u11da\u351aot;\u6ac3ult;\u6ac1\u0100Ee\u3528\u352a;\u6acb;\u628alus;\u6abfarr;\u6979\u0180eiu\u353d\u3552\u3555t\u0180;en\u350e\u3545\u354bq\u0100;q\u11da\u350feq\u0100;q\u352b\u3528m;\u6ac7\u0100bp\u355a\u355c;\u6ad5;\u6ad3c\u0300;acens\u11ed\u356c\u3572\u3579\u357b\u3326ppro\xf8\u32faurlye\xf1\u11fe\xf1\u11f3\u0180aes\u3582\u3588\u331bppro\xf8\u331aq\xf1\u3317g;\u666a\u0680123;Edehlmnps\u35a9\u35ac\u35af\u121c\u35b2\u35b4\u35c0\u35c9\u35d5\u35da\u35df\u35e8\u35ed\u803b\xb9\u40b9\u803b\xb2\u40b2\u803b\xb3\u40b3;\u6ac6\u0100os\u35b9\u35bct;\u6abeub;\u6ad8\u0100;d\u1222\u35c5ot;\u6ac4s\u0100ou\u35cf\u35d2l;\u67c9b;\u6ad7arr;\u697bult;\u6ac2\u0100Ee\u35e4\u35e6;\u6acc;\u628blus;\u6ac0\u0180eiu\u35f4\u3609\u360ct\u0180;en\u121c\u35fc\u3602q\u0100;q\u1222\u35b2eq\u0100;q\u35e7\u35e4m;\u6ac8\u0100bp\u3611\u3613;\u6ad4;\u6ad6\u0180Aan\u361c\u3620\u362drr;\u61d9r\u0100hr\u3626\u3628\xeb\u222e\u0100;o\u0a2b\u0a29war;\u692alig\u803b\xdf\u40df\u0be1\u3651\u365d\u3660\u12ce\u3673\u3679\0\u367e\u36c2\0\0\0\0\0\u36db\u3703\0\u3709\u376c\0\0\0\u3787\u0272\u3656\0\0\u365bget;\u6316;\u43c4r\xeb\u0e5f\u0180aey\u3666\u366b\u3670ron;\u4165dil;\u4163;\u4442lrec;\u6315r;\uc000\ud835\udd31\u0200eiko\u3686\u369d\u36b5\u36bc\u01f2\u368b\0\u3691e\u01004f\u1284\u1281a\u0180;sv\u3698\u3699\u369b\u43b8ym;\u43d1\u0100cn\u36a2\u36b2k\u0100as\u36a8\u36aeppro\xf8\u12c1im\xbb\u12acs\xf0\u129e\u0100as\u36ba\u36ae\xf0\u12c1rn\u803b\xfe\u40fe\u01ec\u031f\u36c6\u22e7es\u8180\xd7;bd\u36cf\u36d0\u36d8\u40d7\u0100;a\u190f\u36d5r;\u6a31;\u6a30\u0180eps\u36e1\u36e3\u3700\xe1\u2a4d\u0200;bcf\u0486\u36ec\u36f0\u36f4ot;\u6336ir;\u6af1\u0100;o\u36f9\u36fc\uc000\ud835\udd65rk;\u6ada\xe1\u3362rime;\u6034\u0180aip\u370f\u3712\u3764d\xe5\u1248\u0380adempst\u3721\u374d\u3740\u3751\u3757\u375c\u375fngle\u0280;dlqr\u3730\u3731\u3736\u3740\u3742\u65b5own\xbb\u1dbbeft\u0100;e\u2800\u373e\xf1\u092e;\u625cight\u0100;e\u32aa\u374b\xf1\u105aot;\u65ecinus;\u6a3alus;\u6a39b;\u69cdime;\u6a3bezium;\u63e2\u0180cht\u3772\u377d\u3781\u0100ry\u3777\u377b;\uc000\ud835\udcc9;\u4446cy;\u445brok;\u4167\u0100io\u378b\u378ex\xf4\u1777head\u0100lr\u3797\u37a0eftarro\xf7\u084fightarrow\xbb\u0f5d\u0900AHabcdfghlmoprstuw\u37d0\u37d3\u37d7\u37e4\u37f0\u37fc\u380e\u381c\u3823\u3834\u3851\u385d\u386b\u38a9\u38cc\u38d2\u38ea\u38f6r\xf2\u03edar;\u6963\u0100cr\u37dc\u37e2ute\u803b\xfa\u40fa\xf2\u1150r\u01e3\u37ea\0\u37edy;\u445eve;\u416d\u0100iy\u37f5\u37farc\u803b\xfb\u40fb;\u4443\u0180abh\u3803\u3806\u380br\xf2\u13adlac;\u4171a\xf2\u13c3\u0100ir\u3813\u3818sht;\u697e;\uc000\ud835\udd32rave\u803b\xf9\u40f9\u0161\u3827\u3831r\u0100lr\u382c\u382e\xbb\u0957\xbb\u1083lk;\u6580\u0100ct\u3839\u384d\u026f\u383f\0\0\u384arn\u0100;e\u3845\u3846\u631cr\xbb\u3846op;\u630fri;\u65f8\u0100al\u3856\u385acr;\u416b\u80bb\xa8\u0349\u0100gp\u3862\u3866on;\u4173f;\uc000\ud835\udd66\u0300adhlsu\u114b\u3878\u387d\u1372\u3891\u38a0own\xe1\u13b3arpoon\u0100lr\u3888\u388cef\xf4\u382digh\xf4\u382fi\u0180;hl\u3899\u389a\u389c\u43c5\xbb\u13faon\xbb\u389aparrows;\u61c8\u0180cit\u38b0\u38c4\u38c8\u026f\u38b6\0\0\u38c1rn\u0100;e\u38bc\u38bd\u631dr\xbb\u38bdop;\u630eng;\u416fri;\u65f9cr;\uc000\ud835\udcca\u0180dir\u38d9\u38dd\u38e2ot;\u62f0lde;\u4169i\u0100;f\u3730\u38e8\xbb\u1813\u0100am\u38ef\u38f2r\xf2\u38a8l\u803b\xfc\u40fcangle;\u69a7\u0780ABDacdeflnoprsz\u391c\u391f\u3929\u392d\u39b5\u39b8\u39bd\u39df\u39e4\u39e8\u39f3\u39f9\u39fd\u3a01\u3a20r\xf2\u03f7ar\u0100;v\u3926\u3927\u6ae8;\u6ae9as\xe8\u03e1\u0100nr\u3932\u3937grt;\u699c\u0380eknprst\u34e3\u3946\u394b\u3952\u395d\u3964\u3996app\xe1\u2415othin\xe7\u1e96\u0180hir\u34eb\u2ec8\u3959op\xf4\u2fb5\u0100;h\u13b7\u3962\xef\u318d\u0100iu\u3969\u396dgm\xe1\u33b3\u0100bp\u3972\u3984setneq\u0100;q\u397d\u3980\uc000\u228a\ufe00;\uc000\u2acb\ufe00setneq\u0100;q\u398f\u3992\uc000\u228b\ufe00;\uc000\u2acc\ufe00\u0100hr\u399b\u399fet\xe1\u369ciangle\u0100lr\u39aa\u39afeft\xbb\u0925ight\xbb\u1051y;\u4432ash\xbb\u1036\u0180elr\u39c4\u39d2\u39d7\u0180;be\u2dea\u39cb\u39cfar;\u62bbq;\u625alip;\u62ee\u0100bt\u39dc\u1468a\xf2\u1469r;\uc000\ud835\udd33tr\xe9\u39aesu\u0100bp\u39ef\u39f1\xbb\u0d1c\xbb\u0d59pf;\uc000\ud835\udd67ro\xf0\u0efbtr\xe9\u39b4\u0100cu\u3a06\u3a0br;\uc000\ud835\udccb\u0100bp\u3a10\u3a18n\u0100Ee\u3980\u3a16\xbb\u397en\u0100Ee\u3992\u3a1e\xbb\u3990igzag;\u699a\u0380cefoprs\u3a36\u3a3b\u3a56\u3a5b\u3a54\u3a61\u3a6airc;\u4175\u0100di\u3a40\u3a51\u0100bg\u3a45\u3a49ar;\u6a5fe\u0100;q\u15fa\u3a4f;\u6259erp;\u6118r;\uc000\ud835\udd34pf;\uc000\ud835\udd68\u0100;e\u1479\u3a66at\xe8\u1479cr;\uc000\ud835\udccc\u0ae3\u178e\u3a87\0\u3a8b\0\u3a90\u3a9b\0\0\u3a9d\u3aa8\u3aab\u3aaf\0\0\u3ac3\u3ace\0\u3ad8\u17dc\u17dftr\xe9\u17d1r;\uc000\ud835\udd35\u0100Aa\u3a94\u3a97r\xf2\u03c3r\xf2\u09f6;\u43be\u0100Aa\u3aa1\u3aa4r\xf2\u03b8r\xf2\u09eba\xf0\u2713is;\u62fb\u0180dpt\u17a4\u3ab5\u3abe\u0100fl\u3aba\u17a9;\uc000\ud835\udd69im\xe5\u17b2\u0100Aa\u3ac7\u3acar\xf2\u03cer\xf2\u0a01\u0100cq\u3ad2\u17b8r;\uc000\ud835\udccd\u0100pt\u17d6\u3adcr\xe9\u17d4\u0400acefiosu\u3af0\u3afd\u3b08\u3b0c\u3b11\u3b15\u3b1b\u3b21c\u0100uy\u3af6\u3afbte\u803b\xfd\u40fd;\u444f\u0100iy\u3b02\u3b06rc;\u4177;\u444bn\u803b\xa5\u40a5r;\uc000\ud835\udd36cy;\u4457pf;\uc000\ud835\udd6acr;\uc000\ud835\udcce\u0100cm\u3b26\u3b29y;\u444el\u803b\xff\u40ff\u0500acdefhiosw\u3b42\u3b48\u3b54\u3b58\u3b64\u3b69\u3b6d\u3b74\u3b7a\u3b80cute;\u417a\u0100ay\u3b4d\u3b52ron;\u417e;\u4437ot;\u417c\u0100et\u3b5d\u3b61tr\xe6\u155fa;\u43b6r;\uc000\ud835\udd37cy;\u4436grarr;\u61ddpf;\uc000\ud835\udd6bcr;\uc000\ud835\udccf\u0100jn\u3b85\u3b87;\u600dj;\u600c'.split("").map((e=>e.charCodeAt(0)))),Fs=new Uint16Array("\u0200aglq\t\x15\x18\x1b\u026d\x0f\0\0\x12p;\u4026os;\u4027t;\u403et;\u403cuot;\u4022".split("").map((e=>e.charCodeAt(0))));var Ls;const xs=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),Ps=null!==(Ls=String.fromCodePoint)&&void 0!==Ls?Ls:function(e){let t="";return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|1023&e),t+=String.fromCharCode(e),t};function Ms(e){var t;return e>=55296&&e<=57343||e>1114111?65533:null!==(t=xs.get(e))&&void 0!==t?t:e}var ws;!function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"}(ws||(ws={}));var Bs,Hs,Us;function Gs(e){return e>=ws.ZERO&&e<=ws.NINE}function js(e){return e>=ws.UPPER_A&&e<=ws.UPPER_F||e>=ws.LOWER_A&&e<=ws.LOWER_F}function Ys(e){return e===ws.EQUALS||function(e){return e>=ws.UPPER_A&&e<=ws.UPPER_Z||e>=ws.LOWER_A&&e<=ws.LOWER_Z||Gs(e)}(e)}!function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"}(Bs||(Bs={})),function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"}(Hs||(Hs={})),function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"}(Us||(Us={}));class zs{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=Hs.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Us.Strict}startEntity(e){this.decodeMode=e,this.state=Hs.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case Hs.EntityStart:return e.charCodeAt(t)===ws.NUM?(this.state=Hs.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=Hs.NamedEntity,this.stateNamedEntity(e,t));case Hs.NumericStart:return this.stateNumericStart(e,t);case Hs.NumericDecimal:return this.stateNumericDecimal(e,t);case Hs.NumericHex:return this.stateNumericHex(e,t);case Hs.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(32|e.charCodeAt(t))===ws.LOWER_X?(this.state=Hs.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=Hs.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,n,r){if(t!==n){const o=n-t;this.result=this.result*Math.pow(r,o)+parseInt(e.substr(t,o),r),this.consumed+=o}}stateNumericHex(e,t){const n=t;for(;t>14;for(;t>14,0!==o){if(i===ws.SEMI)return this.emitNamedEntityData(this.treeIndex,o,this.consumed+this.excess);this.decodeMode!==Us.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;const{result:t,decodeTree:n}=this,r=(n[t]&Bs.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,r,this.consumed),null===(e=this.errors)||void 0===e||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,n){const{decodeTree:r}=this;return this.emitCodePoint(1===t?r[e]&~Bs.VALUE_LENGTH:r[e+1],n),3===t&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case Hs.NamedEntity:return 0===this.result||this.decodeMode===Us.Attribute&&this.result!==this.treeIndex?0:this.emitNotTerminatedNamedEntity();case Hs.NumericDecimal:return this.emitNumericEntity(0,2);case Hs.NumericHex:return this.emitNumericEntity(0,3);case Hs.NumericStart:return null===(e=this.errors)||void 0===e||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Hs.EntityStart:return 0}}}function qs(e){let t="";const n=new zs(e,(e=>t+=Ps(e)));return function(e,r){let o=0,i=0;for(;(i=e.indexOf("&",i))>=0;){t+=e.slice(o,i),n.startEntity(r);const s=n.write(e,i+1);if(s<0){o=i+n.end();break}o=i+s,i=0===s?o+1:o}const s=t+e.slice(o);return t="",s}}function Qs(e,t,n,r){const o=(t&Bs.BRANCH_LENGTH)>>7,i=t&Bs.JUMP_TABLE;if(0===o)return 0!==i&&r===i?n:-1;if(i){const t=r-i;return t<0||t>=o?-1:e[n+t]-1}let s=n,a=s+o-1;for(;s<=a;){const t=s+a>>>1,n=e[t];if(nr))return e[t+o];a=t-1}}return-1}qs(Rs),qs(Fs);var Ws,Ks,Vs,Xs,$s;!function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"}(Ws=Ws||(Ws={})),function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"}(Ks=Ks||(Ks={})),function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"}(Vs=Vs||(Vs={})),function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"}(Xs=Xs||(Xs={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SECTION=94]="SECTION",e[e.SELECT=95]="SELECT",e[e.SOURCE=96]="SOURCE",e[e.SMALL=97]="SMALL",e[e.SPAN=98]="SPAN",e[e.STRIKE=99]="STRIKE",e[e.STRONG=100]="STRONG",e[e.STYLE=101]="STYLE",e[e.SUB=102]="SUB",e[e.SUMMARY=103]="SUMMARY",e[e.SUP=104]="SUP",e[e.TABLE=105]="TABLE",e[e.TBODY=106]="TBODY",e[e.TEMPLATE=107]="TEMPLATE",e[e.TEXTAREA=108]="TEXTAREA",e[e.TFOOT=109]="TFOOT",e[e.TD=110]="TD",e[e.TH=111]="TH",e[e.THEAD=112]="THEAD",e[e.TITLE=113]="TITLE",e[e.TR=114]="TR",e[e.TRACK=115]="TRACK",e[e.TT=116]="TT",e[e.U=117]="U",e[e.UL=118]="UL",e[e.SVG=119]="SVG",e[e.VAR=120]="VAR",e[e.WBR=121]="WBR",e[e.XMP=122]="XMP"}($s=$s||($s={}));const Js=new Map([[Xs.A,$s.A],[Xs.ADDRESS,$s.ADDRESS],[Xs.ANNOTATION_XML,$s.ANNOTATION_XML],[Xs.APPLET,$s.APPLET],[Xs.AREA,$s.AREA],[Xs.ARTICLE,$s.ARTICLE],[Xs.ASIDE,$s.ASIDE],[Xs.B,$s.B],[Xs.BASE,$s.BASE],[Xs.BASEFONT,$s.BASEFONT],[Xs.BGSOUND,$s.BGSOUND],[Xs.BIG,$s.BIG],[Xs.BLOCKQUOTE,$s.BLOCKQUOTE],[Xs.BODY,$s.BODY],[Xs.BR,$s.BR],[Xs.BUTTON,$s.BUTTON],[Xs.CAPTION,$s.CAPTION],[Xs.CENTER,$s.CENTER],[Xs.CODE,$s.CODE],[Xs.COL,$s.COL],[Xs.COLGROUP,$s.COLGROUP],[Xs.DD,$s.DD],[Xs.DESC,$s.DESC],[Xs.DETAILS,$s.DETAILS],[Xs.DIALOG,$s.DIALOG],[Xs.DIR,$s.DIR],[Xs.DIV,$s.DIV],[Xs.DL,$s.DL],[Xs.DT,$s.DT],[Xs.EM,$s.EM],[Xs.EMBED,$s.EMBED],[Xs.FIELDSET,$s.FIELDSET],[Xs.FIGCAPTION,$s.FIGCAPTION],[Xs.FIGURE,$s.FIGURE],[Xs.FONT,$s.FONT],[Xs.FOOTER,$s.FOOTER],[Xs.FOREIGN_OBJECT,$s.FOREIGN_OBJECT],[Xs.FORM,$s.FORM],[Xs.FRAME,$s.FRAME],[Xs.FRAMESET,$s.FRAMESET],[Xs.H1,$s.H1],[Xs.H2,$s.H2],[Xs.H3,$s.H3],[Xs.H4,$s.H4],[Xs.H5,$s.H5],[Xs.H6,$s.H6],[Xs.HEAD,$s.HEAD],[Xs.HEADER,$s.HEADER],[Xs.HGROUP,$s.HGROUP],[Xs.HR,$s.HR],[Xs.HTML,$s.HTML],[Xs.I,$s.I],[Xs.IMG,$s.IMG],[Xs.IMAGE,$s.IMAGE],[Xs.INPUT,$s.INPUT],[Xs.IFRAME,$s.IFRAME],[Xs.KEYGEN,$s.KEYGEN],[Xs.LABEL,$s.LABEL],[Xs.LI,$s.LI],[Xs.LINK,$s.LINK],[Xs.LISTING,$s.LISTING],[Xs.MAIN,$s.MAIN],[Xs.MALIGNMARK,$s.MALIGNMARK],[Xs.MARQUEE,$s.MARQUEE],[Xs.MATH,$s.MATH],[Xs.MENU,$s.MENU],[Xs.META,$s.META],[Xs.MGLYPH,$s.MGLYPH],[Xs.MI,$s.MI],[Xs.MO,$s.MO],[Xs.MN,$s.MN],[Xs.MS,$s.MS],[Xs.MTEXT,$s.MTEXT],[Xs.NAV,$s.NAV],[Xs.NOBR,$s.NOBR],[Xs.NOFRAMES,$s.NOFRAMES],[Xs.NOEMBED,$s.NOEMBED],[Xs.NOSCRIPT,$s.NOSCRIPT],[Xs.OBJECT,$s.OBJECT],[Xs.OL,$s.OL],[Xs.OPTGROUP,$s.OPTGROUP],[Xs.OPTION,$s.OPTION],[Xs.P,$s.P],[Xs.PARAM,$s.PARAM],[Xs.PLAINTEXT,$s.PLAINTEXT],[Xs.PRE,$s.PRE],[Xs.RB,$s.RB],[Xs.RP,$s.RP],[Xs.RT,$s.RT],[Xs.RTC,$s.RTC],[Xs.RUBY,$s.RUBY],[Xs.S,$s.S],[Xs.SCRIPT,$s.SCRIPT],[Xs.SECTION,$s.SECTION],[Xs.SELECT,$s.SELECT],[Xs.SOURCE,$s.SOURCE],[Xs.SMALL,$s.SMALL],[Xs.SPAN,$s.SPAN],[Xs.STRIKE,$s.STRIKE],[Xs.STRONG,$s.STRONG],[Xs.STYLE,$s.STYLE],[Xs.SUB,$s.SUB],[Xs.SUMMARY,$s.SUMMARY],[Xs.SUP,$s.SUP],[Xs.TABLE,$s.TABLE],[Xs.TBODY,$s.TBODY],[Xs.TEMPLATE,$s.TEMPLATE],[Xs.TEXTAREA,$s.TEXTAREA],[Xs.TFOOT,$s.TFOOT],[Xs.TD,$s.TD],[Xs.TH,$s.TH],[Xs.THEAD,$s.THEAD],[Xs.TITLE,$s.TITLE],[Xs.TR,$s.TR],[Xs.TRACK,$s.TRACK],[Xs.TT,$s.TT],[Xs.U,$s.U],[Xs.UL,$s.UL],[Xs.SVG,$s.SVG],[Xs.VAR,$s.VAR],[Xs.WBR,$s.WBR],[Xs.XMP,$s.XMP]]);function Zs(e){var t;return null!==(t=Js.get(e))&&void 0!==t?t:$s.UNKNOWN}const ea=$s,ta={[Ws.HTML]:new Set([ea.ADDRESS,ea.APPLET,ea.AREA,ea.ARTICLE,ea.ASIDE,ea.BASE,ea.BASEFONT,ea.BGSOUND,ea.BLOCKQUOTE,ea.BODY,ea.BR,ea.BUTTON,ea.CAPTION,ea.CENTER,ea.COL,ea.COLGROUP,ea.DD,ea.DETAILS,ea.DIR,ea.DIV,ea.DL,ea.DT,ea.EMBED,ea.FIELDSET,ea.FIGCAPTION,ea.FIGURE,ea.FOOTER,ea.FORM,ea.FRAME,ea.FRAMESET,ea.H1,ea.H2,ea.H3,ea.H4,ea.H5,ea.H6,ea.HEAD,ea.HEADER,ea.HGROUP,ea.HR,ea.HTML,ea.IFRAME,ea.IMG,ea.INPUT,ea.LI,ea.LINK,ea.LISTING,ea.MAIN,ea.MARQUEE,ea.MENU,ea.META,ea.NAV,ea.NOEMBED,ea.NOFRAMES,ea.NOSCRIPT,ea.OBJECT,ea.OL,ea.P,ea.PARAM,ea.PLAINTEXT,ea.PRE,ea.SCRIPT,ea.SECTION,ea.SELECT,ea.SOURCE,ea.STYLE,ea.SUMMARY,ea.TABLE,ea.TBODY,ea.TD,ea.TEMPLATE,ea.TEXTAREA,ea.TFOOT,ea.TH,ea.THEAD,ea.TITLE,ea.TR,ea.TRACK,ea.UL,ea.WBR,ea.XMP]),[Ws.MATHML]:new Set([ea.MI,ea.MO,ea.MN,ea.MS,ea.MTEXT,ea.ANNOTATION_XML]),[Ws.SVG]:new Set([ea.TITLE,ea.FOREIGN_OBJECT,ea.DESC]),[Ws.XLINK]:new Set,[Ws.XML]:new Set,[Ws.XMLNS]:new Set};function na(e){return e===ea.H1||e===ea.H2||e===ea.H3||e===ea.H4||e===ea.H5||e===ea.H6}new Set([Xs.STYLE,Xs.SCRIPT,Xs.XMP,Xs.IFRAME,Xs.NOEMBED,Xs.NOFRAMES,Xs.PLAINTEXT]);const ra=new Map([[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);var oa;!function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.NAMED_CHARACTER_REFERENCE=72]="NAMED_CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=73]="AMBIGUOUS_AMPERSAND",e[e.NUMERIC_CHARACTER_REFERENCE=74]="NUMERIC_CHARACTER_REFERENCE",e[e.HEXADEMICAL_CHARACTER_REFERENCE_START=75]="HEXADEMICAL_CHARACTER_REFERENCE_START",e[e.HEXADEMICAL_CHARACTER_REFERENCE=76]="HEXADEMICAL_CHARACTER_REFERENCE",e[e.DECIMAL_CHARACTER_REFERENCE=77]="DECIMAL_CHARACTER_REFERENCE",e[e.NUMERIC_CHARACTER_REFERENCE_END=78]="NUMERIC_CHARACTER_REFERENCE_END"}(oa||(oa={}));const ia={DATA:oa.DATA,RCDATA:oa.RCDATA,RAWTEXT:oa.RAWTEXT,SCRIPT_DATA:oa.SCRIPT_DATA,PLAINTEXT:oa.PLAINTEXT,CDATA_SECTION:oa.CDATA_SECTION};function sa(e){return e>=Ts.DIGIT_0&&e<=Ts.DIGIT_9}function aa(e){return e>=Ts.LATIN_CAPITAL_A&&e<=Ts.LATIN_CAPITAL_Z}function ca(e){return function(e){return e>=Ts.LATIN_SMALL_A&&e<=Ts.LATIN_SMALL_Z}(e)||aa(e)}function la(e){return ca(e)||sa(e)}function ua(e){return e>=Ts.LATIN_CAPITAL_A&&e<=Ts.LATIN_CAPITAL_F}function ha(e){return e>=Ts.LATIN_SMALL_A&&e<=Ts.LATIN_SMALL_F}function pa(e){return e+32}function da(e){return e===Ts.SPACE||e===Ts.LINE_FEED||e===Ts.TABULATION||e===Ts.FORM_FEED}function fa(e){return da(e)||e===Ts.SOLIDUS||e===Ts.GREATER_THAN_SIGN}class ma{constructor(e,t){this.options=e,this.handler=t,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=oa.DATA,this.returnState=oa.DATA,this.charRefCode=-1,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new Is(t),this.currentLocation=this.getCurrentLocation(-1)}_err(e){var t,n;null===(n=(t=this.handler).onParseError)||void 0===n||n.call(t,this.preprocessor.getError(e))}getCurrentLocation(e){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-e,startOffset:this.preprocessor.offset-e,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const e=this._consume();this._ensureHibernation()||this._callState(e)}this.inLoop=!1}}pause(){this.paused=!0}resume(e){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,this.inLoop||(this._runParsingLoop(),this.paused||null===e||void 0===e||e())}write(e,t,n){this.active=!0,this.preprocessor.write(e,t),this._runParsingLoop(),this.paused||null===n||void 0===n||n()}insertHtmlAtCurrentPos(e){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(e),this._runParsingLoop()}_ensureHibernation(){return!!this.preprocessor.endOfChunkHit&&(this._unconsume(this.consumedAfterSnapshot),this.active=!1,!0)}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_unconsume(e){this.consumedAfterSnapshot-=e,this.preprocessor.retreat(e)}_reconsumeInState(e,t){this.state=e,this._callState(t)}_advanceBy(e){this.consumedAfterSnapshot+=e;for(let t=0;t0&&this._err(Ss.endTagWithAttributes),e.selfClosing&&this._err(Ss.endTagWithTrailingSolidus),this.handler.onEndTag(e)),this.preprocessor.dropParsedChunk()}emitCurrentComment(e){this.prepareToken(e),this.handler.onComment(e),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(e){this.prepareToken(e),this.handler.onDoctype(e),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(e){if(this.currentCharacterToken){switch(e&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=e.startLine,this.currentCharacterToken.location.endCol=e.startCol,this.currentCharacterToken.location.endOffset=e.startOffset),this.currentCharacterToken.type){case Os.CHARACTER:this.handler.onCharacter(this.currentCharacterToken);break;case Os.NULL_CHARACTER:this.handler.onNullCharacter(this.currentCharacterToken);break;case Os.WHITESPACE_CHARACTER:this.handler.onWhitespaceCharacter(this.currentCharacterToken)}this.currentCharacterToken=null}}_emitEOFToken(){const e=this.getCurrentLocation(0);e&&(e.endLine=e.startLine,e.endCol=e.startCol,e.endOffset=e.startOffset),this._emitCurrentCharacterToken(e),this.handler.onEof({type:Os.EOF,location:e}),this.active=!1}_appendCharToCurrentCharacterToken(e,t){if(this.currentCharacterToken){if(this.currentCharacterToken.type===e)return void(this.currentCharacterToken.chars+=t);this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk()}this._createCharacterToken(e,t)}_emitCodePoint(e){const t=da(e)?Os.WHITESPACE_CHARACTER:e===Ts.NULL?Os.NULL_CHARACTER:Os.CHARACTER;this._appendCharToCurrentCharacterToken(t,String.fromCodePoint(e))}_emitChars(e){this._appendCharToCurrentCharacterToken(Os.CHARACTER,e)}_matchNamedCharacterReference(e){let t=null,n=0,r=!1;for(let i=0,s=Rs[0];i>=0&&(i=Qs(Rs,s,i+1,e),!(i<0));e=this._consume()){n+=1,s=Rs[i];const a=s&Bs.VALUE_LENGTH;if(a){const s=(a>>14)-1;if(e!==Ts.SEMICOLON&&this._isCharacterReferenceInAttribute()&&((o=this.preprocessor.peek(1))===Ts.EQUALS_SIGN||la(o))?(t=[Ts.AMPERSAND],i+=s):(t=0===s?[Rs[i]&~Bs.VALUE_LENGTH]:1===s?[Rs[++i]]:[Rs[++i],Rs[++i]],n=0,r=e!==Ts.SEMICOLON),0===s){this._consume();break}}}var o;return this._unconsume(n),r&&!this.preprocessor.endOfChunkHit&&this._err(Ss.missingSemicolonAfterCharacterReference),this._unconsume(1),t}_isCharacterReferenceInAttribute(){return this.returnState===oa.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===oa.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===oa.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(e){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(e):this._emitCodePoint(e)}_callState(e){switch(this.state){case oa.DATA:this._stateData(e);break;case oa.RCDATA:this._stateRcdata(e);break;case oa.RAWTEXT:this._stateRawtext(e);break;case oa.SCRIPT_DATA:this._stateScriptData(e);break;case oa.PLAINTEXT:this._statePlaintext(e);break;case oa.TAG_OPEN:this._stateTagOpen(e);break;case oa.END_TAG_OPEN:this._stateEndTagOpen(e);break;case oa.TAG_NAME:this._stateTagName(e);break;case oa.RCDATA_LESS_THAN_SIGN:this._stateRcdataLessThanSign(e);break;case oa.RCDATA_END_TAG_OPEN:this._stateRcdataEndTagOpen(e);break;case oa.RCDATA_END_TAG_NAME:this._stateRcdataEndTagName(e);break;case oa.RAWTEXT_LESS_THAN_SIGN:this._stateRawtextLessThanSign(e);break;case oa.RAWTEXT_END_TAG_OPEN:this._stateRawtextEndTagOpen(e);break;case oa.RAWTEXT_END_TAG_NAME:this._stateRawtextEndTagName(e);break;case oa.SCRIPT_DATA_LESS_THAN_SIGN:this._stateScriptDataLessThanSign(e);break;case oa.SCRIPT_DATA_END_TAG_OPEN:this._stateScriptDataEndTagOpen(e);break;case oa.SCRIPT_DATA_END_TAG_NAME:this._stateScriptDataEndTagName(e);break;case oa.SCRIPT_DATA_ESCAPE_START:this._stateScriptDataEscapeStart(e);break;case oa.SCRIPT_DATA_ESCAPE_START_DASH:this._stateScriptDataEscapeStartDash(e);break;case oa.SCRIPT_DATA_ESCAPED:this._stateScriptDataEscaped(e);break;case oa.SCRIPT_DATA_ESCAPED_DASH:this._stateScriptDataEscapedDash(e);break;case oa.SCRIPT_DATA_ESCAPED_DASH_DASH:this._stateScriptDataEscapedDashDash(e);break;case oa.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataEscapedLessThanSign(e);break;case oa.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:this._stateScriptDataEscapedEndTagOpen(e);break;case oa.SCRIPT_DATA_ESCAPED_END_TAG_NAME:this._stateScriptDataEscapedEndTagName(e);break;case oa.SCRIPT_DATA_DOUBLE_ESCAPE_START:this._stateScriptDataDoubleEscapeStart(e);break;case oa.SCRIPT_DATA_DOUBLE_ESCAPED:this._stateScriptDataDoubleEscaped(e);break;case oa.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:this._stateScriptDataDoubleEscapedDash(e);break;case oa.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:this._stateScriptDataDoubleEscapedDashDash(e);break;case oa.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataDoubleEscapedLessThanSign(e);break;case oa.SCRIPT_DATA_DOUBLE_ESCAPE_END:this._stateScriptDataDoubleEscapeEnd(e);break;case oa.BEFORE_ATTRIBUTE_NAME:this._stateBeforeAttributeName(e);break;case oa.ATTRIBUTE_NAME:this._stateAttributeName(e);break;case oa.AFTER_ATTRIBUTE_NAME:this._stateAfterAttributeName(e);break;case oa.BEFORE_ATTRIBUTE_VALUE:this._stateBeforeAttributeValue(e);break;case oa.ATTRIBUTE_VALUE_DOUBLE_QUOTED:this._stateAttributeValueDoubleQuoted(e);break;case oa.ATTRIBUTE_VALUE_SINGLE_QUOTED:this._stateAttributeValueSingleQuoted(e);break;case oa.ATTRIBUTE_VALUE_UNQUOTED:this._stateAttributeValueUnquoted(e);break;case oa.AFTER_ATTRIBUTE_VALUE_QUOTED:this._stateAfterAttributeValueQuoted(e);break;case oa.SELF_CLOSING_START_TAG:this._stateSelfClosingStartTag(e);break;case oa.BOGUS_COMMENT:this._stateBogusComment(e);break;case oa.MARKUP_DECLARATION_OPEN:this._stateMarkupDeclarationOpen(e);break;case oa.COMMENT_START:this._stateCommentStart(e);break;case oa.COMMENT_START_DASH:this._stateCommentStartDash(e);break;case oa.COMMENT:this._stateComment(e);break;case oa.COMMENT_LESS_THAN_SIGN:this._stateCommentLessThanSign(e);break;case oa.COMMENT_LESS_THAN_SIGN_BANG:this._stateCommentLessThanSignBang(e);break;case oa.COMMENT_LESS_THAN_SIGN_BANG_DASH:this._stateCommentLessThanSignBangDash(e);break;case oa.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:this._stateCommentLessThanSignBangDashDash(e);break;case oa.COMMENT_END_DASH:this._stateCommentEndDash(e);break;case oa.COMMENT_END:this._stateCommentEnd(e);break;case oa.COMMENT_END_BANG:this._stateCommentEndBang(e);break;case oa.DOCTYPE:this._stateDoctype(e);break;case oa.BEFORE_DOCTYPE_NAME:this._stateBeforeDoctypeName(e);break;case oa.DOCTYPE_NAME:this._stateDoctypeName(e);break;case oa.AFTER_DOCTYPE_NAME:this._stateAfterDoctypeName(e);break;case oa.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._stateAfterDoctypePublicKeyword(e);break;case oa.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:this._stateBeforeDoctypePublicIdentifier(e);break;case oa.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypePublicIdentifierDoubleQuoted(e);break;case oa.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypePublicIdentifierSingleQuoted(e);break;case oa.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:this._stateAfterDoctypePublicIdentifier(e);break;case oa.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:this._stateBetweenDoctypePublicAndSystemIdentifiers(e);break;case oa.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._stateAfterDoctypeSystemKeyword(e);break;case oa.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:this._stateBeforeDoctypeSystemIdentifier(e);break;case oa.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypeSystemIdentifierDoubleQuoted(e);break;case oa.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypeSystemIdentifierSingleQuoted(e);break;case oa.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:this._stateAfterDoctypeSystemIdentifier(e);break;case oa.BOGUS_DOCTYPE:this._stateBogusDoctype(e);break;case oa.CDATA_SECTION:this._stateCdataSection(e);break;case oa.CDATA_SECTION_BRACKET:this._stateCdataSectionBracket(e);break;case oa.CDATA_SECTION_END:this._stateCdataSectionEnd(e);break;case oa.CHARACTER_REFERENCE:this._stateCharacterReference(e);break;case oa.NAMED_CHARACTER_REFERENCE:this._stateNamedCharacterReference(e);break;case oa.AMBIGUOUS_AMPERSAND:this._stateAmbiguousAmpersand(e);break;case oa.NUMERIC_CHARACTER_REFERENCE:this._stateNumericCharacterReference(e);break;case oa.HEXADEMICAL_CHARACTER_REFERENCE_START:this._stateHexademicalCharacterReferenceStart(e);break;case oa.HEXADEMICAL_CHARACTER_REFERENCE:this._stateHexademicalCharacterReference(e);break;case oa.DECIMAL_CHARACTER_REFERENCE:this._stateDecimalCharacterReference(e);break;case oa.NUMERIC_CHARACTER_REFERENCE_END:this._stateNumericCharacterReferenceEnd(e);break;default:throw new Error("Unknown state")}}_stateData(e){switch(e){case Ts.LESS_THAN_SIGN:this.state=oa.TAG_OPEN;break;case Ts.AMPERSAND:this.returnState=oa.DATA,this.state=oa.CHARACTER_REFERENCE;break;case Ts.NULL:this._err(Ss.unexpectedNullCharacter),this._emitCodePoint(e);break;case Ts.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRcdata(e){switch(e){case Ts.AMPERSAND:this.returnState=oa.RCDATA,this.state=oa.CHARACTER_REFERENCE;break;case Ts.LESS_THAN_SIGN:this.state=oa.RCDATA_LESS_THAN_SIGN;break;case Ts.NULL:this._err(Ss.unexpectedNullCharacter),this._emitChars(Es);break;case Ts.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRawtext(e){switch(e){case Ts.LESS_THAN_SIGN:this.state=oa.RAWTEXT_LESS_THAN_SIGN;break;case Ts.NULL:this._err(Ss.unexpectedNullCharacter),this._emitChars(Es);break;case Ts.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptData(e){switch(e){case Ts.LESS_THAN_SIGN:this.state=oa.SCRIPT_DATA_LESS_THAN_SIGN;break;case Ts.NULL:this._err(Ss.unexpectedNullCharacter),this._emitChars(Es);break;case Ts.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_statePlaintext(e){switch(e){case Ts.NULL:this._err(Ss.unexpectedNullCharacter),this._emitChars(Es);break;case Ts.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateTagOpen(e){if(ca(e))this._createStartTagToken(),this.state=oa.TAG_NAME,this._stateTagName(e);else switch(e){case Ts.EXCLAMATION_MARK:this.state=oa.MARKUP_DECLARATION_OPEN;break;case Ts.SOLIDUS:this.state=oa.END_TAG_OPEN;break;case Ts.QUESTION_MARK:this._err(Ss.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=oa.BOGUS_COMMENT,this._stateBogusComment(e);break;case Ts.EOF:this._err(Ss.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break;default:this._err(Ss.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=oa.DATA,this._stateData(e)}}_stateEndTagOpen(e){if(ca(e))this._createEndTagToken(),this.state=oa.TAG_NAME,this._stateTagName(e);else switch(e){case Ts.GREATER_THAN_SIGN:this._err(Ss.missingEndTagName),this.state=oa.DATA;break;case Ts.EOF:this._err(Ss.eofBeforeTagName),this._emitChars("");break;case Ts.NULL:this._err(Ss.unexpectedNullCharacter),this.state=oa.SCRIPT_DATA_ESCAPED,this._emitChars(Es);break;case Ts.EOF:this._err(Ss.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=oa.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedLessThanSign(e){e===Ts.SOLIDUS?this.state=oa.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:ca(e)?(this._emitChars("<"),this.state=oa.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(e)):(this._emitChars("<"),this.state=oa.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagOpen(e){ca(e)?(this.state=oa.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(e)):(this._emitChars("");break;case Ts.NULL:this._err(Ss.unexpectedNullCharacter),this.state=oa.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Es);break;case Ts.EOF:this._err(Ss.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=oa.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedLessThanSign(e){e===Ts.SOLIDUS?(this.state=oa.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=oa.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateScriptDataDoubleEscapeEnd(e){if(this.preprocessor.startsWith(Ds,!1)&&fa(this.preprocessor.peek(Ds.length))){this._emitCodePoint(e);for(let e=0;e1114111)this._err(Ss.characterReferenceOutsideUnicodeRange),this.charRefCode=Ts.REPLACEMENT_CHARACTER;else if(ks(this.charRefCode))this._err(Ss.surrogateCharacterReference),this.charRefCode=Ts.REPLACEMENT_CHARACTER;else if(Ns(this.charRefCode))this._err(Ss.noncharacterCharacterReference);else if(bs(this.charRefCode)||this.charRefCode===Ts.CARRIAGE_RETURN){this._err(Ss.controlCharacterReference);const e=ra.get(this.charRefCode);void 0!==e&&(this.charRefCode=e)}this._flushCodePointConsumedAsCharacterReference(this.charRefCode),this._reconsumeInState(this.returnState,e)}}const Ea=new Set([$s.DD,$s.DT,$s.LI,$s.OPTGROUP,$s.OPTION,$s.P,$s.RB,$s.RP,$s.RT,$s.RTC]),Ta=new Set([...Ea,$s.CAPTION,$s.COLGROUP,$s.TBODY,$s.TD,$s.TFOOT,$s.TH,$s.THEAD,$s.TR]),ga=new Map([[$s.APPLET,Ws.HTML],[$s.CAPTION,Ws.HTML],[$s.HTML,Ws.HTML],[$s.MARQUEE,Ws.HTML],[$s.OBJECT,Ws.HTML],[$s.TABLE,Ws.HTML],[$s.TD,Ws.HTML],[$s.TEMPLATE,Ws.HTML],[$s.TH,Ws.HTML],[$s.ANNOTATION_XML,Ws.MATHML],[$s.MI,Ws.MATHML],[$s.MN,Ws.MATHML],[$s.MO,Ws.MATHML],[$s.MS,Ws.MATHML],[$s.MTEXT,Ws.MATHML],[$s.DESC,Ws.SVG],[$s.FOREIGN_OBJECT,Ws.SVG],[$s.TITLE,Ws.SVG]]),Aa=[$s.H1,$s.H2,$s.H3,$s.H4,$s.H5,$s.H6],_a=[$s.TR,$s.TEMPLATE,$s.HTML],Da=[$s.TBODY,$s.TFOOT,$s.THEAD,$s.TEMPLATE,$s.HTML],ya=[$s.TABLE,$s.TEMPLATE,$s.HTML],Ca=[$s.TD,$s.TH];class ka{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(e,t,n){this.treeAdapter=t,this.handler=n,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=$s.UNKNOWN,this.current=e}_indexOf(e){return this.items.lastIndexOf(e,this.stackTop)}_isInTemplate(){return this.currentTagId===$s.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===Ws.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(e,t){this.stackTop++,this.items[this.stackTop]=e,this.current=e,this.tagIDs[this.stackTop]=t,this.currentTagId=t,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(e,t,!0)}pop(){const e=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!0)}replace(e,t){const n=this._indexOf(e);this.items[n]=t,n===this.stackTop&&(this.current=t)}insertAfter(e,t,n){const r=this._indexOf(e)+1;this.items.splice(r,0,t),this.tagIDs.splice(r,0,n),this.stackTop++,r===this.stackTop&&this._updateCurrentElement(),this.handler.onItemPush(this.current,this.currentTagId,r===this.stackTop)}popUntilTagNamePopped(e){let t=this.stackTop+1;do{t=this.tagIDs.lastIndexOf(e,t-1)}while(t>0&&this.treeAdapter.getNamespaceURI(this.items[t])!==Ws.HTML);this.shortenToLength(t<0?0:t)}shortenToLength(e){for(;this.stackTop>=e;){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,this.stackTop=0;n--)if(e.includes(this.tagIDs[n])&&this.treeAdapter.getNamespaceURI(this.items[n])===t)return n;return-1}clearBackTo(e,t){const n=this._indexOfTagNames(e,t);this.shortenToLength(n+1)}clearBackToTableContext(){this.clearBackTo(ya,Ws.HTML)}clearBackToTableBodyContext(){this.clearBackTo(Da,Ws.HTML)}clearBackToTableRowContext(){this.clearBackTo(_a,Ws.HTML)}remove(e){const t=this._indexOf(e);t>=0&&(t===this.stackTop?this.pop():(this.items.splice(t,1),this.tagIDs.splice(t,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===$s.BODY?this.items[1]:null}contains(e){return this._indexOf(e)>-1}getCommonAncestor(e){const t=this._indexOf(e)-1;return t>=0?this.items[t]:null}isRootHtmlElementCurrent(){return 0===this.stackTop&&this.tagIDs[0]===$s.HTML}hasInScope(e){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t],r=this.treeAdapter.getNamespaceURI(this.items[t]);if(n===e&&r===Ws.HTML)return!0;if(ga.get(n)===r)return!1}return!0}hasNumberedHeaderInScope(){for(let e=this.stackTop;e>=0;e--){const t=this.tagIDs[e],n=this.treeAdapter.getNamespaceURI(this.items[e]);if(na(t)&&n===Ws.HTML)return!0;if(ga.get(t)===n)return!1}return!0}hasInListItemScope(e){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t],r=this.treeAdapter.getNamespaceURI(this.items[t]);if(n===e&&r===Ws.HTML)return!0;if((n===$s.UL||n===$s.OL)&&r===Ws.HTML||ga.get(n)===r)return!1}return!0}hasInButtonScope(e){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t],r=this.treeAdapter.getNamespaceURI(this.items[t]);if(n===e&&r===Ws.HTML)return!0;if(n===$s.BUTTON&&r===Ws.HTML||ga.get(n)===r)return!1}return!0}hasInTableScope(e){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];if(this.treeAdapter.getNamespaceURI(this.items[t])===Ws.HTML){if(n===e)return!0;if(n===$s.TABLE||n===$s.TEMPLATE||n===$s.HTML)return!1}}return!0}hasTableBodyContextInTableScope(){for(let e=this.stackTop;e>=0;e--){const t=this.tagIDs[e];if(this.treeAdapter.getNamespaceURI(this.items[e])===Ws.HTML){if(t===$s.TBODY||t===$s.THEAD||t===$s.TFOOT)return!0;if(t===$s.TABLE||t===$s.HTML)return!1}}return!0}hasInSelectScope(e){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];if(this.treeAdapter.getNamespaceURI(this.items[t])===Ws.HTML){if(n===e)return!0;if(n!==$s.OPTION&&n!==$s.OPTGROUP)return!1}}return!0}generateImpliedEndTags(){for(;Ea.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;Ta.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(e){for(;this.currentTagId!==e&&Ta.has(this.currentTagId);)this.pop()}}var ba;!function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"}(ba=ba||(ba={}));const Na={type:ba.Marker};class Sa{constructor(e){this.treeAdapter=e,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(e,t){const n=[],r=t.length,o=this.treeAdapter.getTagName(e),i=this.treeAdapter.getNamespaceURI(e);for(let s=0;s[e.name,e.value])));let o=0;for(let i=0;ir.get(e.name)===e.value))&&(o+=1,o>=3&&this.entries.splice(e.idx,1))}}insertMarker(){this.entries.unshift(Na)}pushElement(e,t){this._ensureNoahArkCondition(e),this.entries.unshift({type:ba.Element,element:e,token:t})}insertElementAfterBookmark(e,t){const n=this.entries.indexOf(this.bookmark);this.entries.splice(n,0,{type:ba.Element,element:e,token:t})}removeEntry(e){const t=this.entries.indexOf(e);t>=0&&this.entries.splice(t,1)}clearToLastMarker(){const e=this.entries.indexOf(Na);e>=0?this.entries.splice(0,e+1):this.entries.length=0}getElementEntryInScopeWithTagName(e){const t=this.entries.find((t=>t.type===ba.Marker||this.treeAdapter.getTagName(t.element)===e));return t&&t.type===ba.Element?t:null}getElementEntry(e){return this.entries.find((t=>t.type===ba.Element&&t.element===e))}}function Ia(e){return{nodeName:"#text",value:e,parentNode:null}}const Oa={createDocument:()=>({nodeName:"#document",mode:Vs.NO_QUIRKS,childNodes:[]}),createDocumentFragment:()=>({nodeName:"#document-fragment",childNodes:[]}),createElement:(e,t,n)=>({nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}),createCommentNode:e=>({nodeName:"#comment",data:e,parentNode:null}),appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){const r=e.childNodes.indexOf(n);e.childNodes.splice(r,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent:e=>e.content,setDocumentType(e,t,n,r){const o=e.childNodes.find((e=>"#documentType"===e.nodeName));if(o)o.name=t,o.publicId=n,o.systemId=r;else{const o={nodeName:"#documentType",name:t,publicId:n,systemId:r,parentNode:null};Oa.appendChild(e,o)}},setDocumentMode(e,t){e.mode=t},getDocumentMode:e=>e.mode,detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const n=e.childNodes[e.childNodes.length-1];if(Oa.isTextNode(n))return void(n.value+=t)}Oa.appendChild(e,Ia(t))},insertTextBefore(e,t,n){const r=e.childNodes[e.childNodes.indexOf(n)-1];r&&Oa.isTextNode(r)?r.value+=t:Oa.insertBefore(e,Ia(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map((e=>e.name)));for(let r=0;re.childNodes[0],getChildNodes:e=>e.childNodes,getParentNode:e=>e.parentNode,getAttrList:e=>e.attrs,getTagName:e=>e.tagName,getNamespaceURI:e=>e.namespaceURI,getTextNodeContent:e=>e.value,getCommentNodeContent:e=>e.data,getDocumentTypeNodeName:e=>e.name,getDocumentTypeNodePublicId:e=>e.publicId,getDocumentTypeNodeSystemId:e=>e.systemId,isTextNode:e=>"#text"===e.nodeName,isCommentNode:e=>"#comment"===e.nodeName,isDocumentTypeNode:e=>"#documentType"===e.nodeName,isElementNode:e=>Object.prototype.hasOwnProperty.call(e,"tagName"),setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation:e=>e.sourceCodeLocation,updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},va="html",Ra="about:legacy-compat",Fa="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",La=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],xa=[...La,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],Pa=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),Ma=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],wa=[...Ma,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function Ba(e,t){return t.some((t=>e.startsWith(t)))}const Ha={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},Ua="definitionurl",Ga="definitionURL",ja=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map((e=>[e.toLowerCase(),e]))),Ya=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:Ws.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:Ws.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:Ws.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:Ws.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:Ws.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:Ws.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:Ws.XLINK}],["xml:base",{prefix:"xml",name:"base",namespace:Ws.XML}],["xml:lang",{prefix:"xml",name:"lang",namespace:Ws.XML}],["xml:space",{prefix:"xml",name:"space",namespace:Ws.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:Ws.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:Ws.XMLNS}]]),za=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map((e=>[e.toLowerCase(),e]))),qa=new Set([$s.B,$s.BIG,$s.BLOCKQUOTE,$s.BODY,$s.BR,$s.CENTER,$s.CODE,$s.DD,$s.DIV,$s.DL,$s.DT,$s.EM,$s.EMBED,$s.H1,$s.H2,$s.H3,$s.H4,$s.H5,$s.H6,$s.HEAD,$s.HR,$s.I,$s.IMG,$s.LI,$s.LISTING,$s.MENU,$s.META,$s.NOBR,$s.OL,$s.P,$s.PRE,$s.RUBY,$s.S,$s.SMALL,$s.SPAN,$s.STRONG,$s.STRIKE,$s.SUB,$s.SUP,$s.TABLE,$s.TT,$s.U,$s.UL,$s.VAR]);function Qa(e){for(let t=0;t2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;this.fragmentContext=n,this.scriptHandler=r,this.currentToken=null,this.stopped=!1,this.insertionMode=Za.INITIAL,this.originalInsertionMode=Za.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...nc,...e},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=null!==t&&void 0!==t?t:this.treeAdapter.createDocument(),this.tokenizer=new ma(this.options,this),this.activeFormattingElements=new Sa(this.treeAdapter),this.fragmentContextID=n?Zs(this.treeAdapter.getTagName(n)):$s.UNKNOWN,this._setContextModes(null!==n&&void 0!==n?n:this.document,this.fragmentContextID),this.openElements=new ka(this.document,this.treeAdapter,this)}static parse(e,t){const n=new this(t);return n.tokenizer.write(e,!0),n.document}static getFragmentParser(e,t){const n={...nc,...t};null!==e&&void 0!==e||(e=n.treeAdapter.createElement(Xs.TEMPLATE,Ws.HTML,[]));const r=n.treeAdapter.createElement("documentmock",Ws.HTML,[]),o=new this(n,r,e);return o.fragmentContextID===$s.TEMPLATE&&o.tmplInsertionModeStack.unshift(Za.IN_TEMPLATE),o._initTokenizerForFragmentParsing(),o._insertFakeRootElement(),o._resetInsertionMode(),o._findFormInFragmentContext(),o}getFragment(){const e=this.treeAdapter.getFirstChild(this.document),t=this.treeAdapter.createDocumentFragment();return this._adoptNodes(e,t),t}_err(e,t,n){var r;if(!this.onParseError)return;const o=null!==(r=e.location)&&void 0!==r?r:ec,i={code:t,startLine:o.startLine,startCol:o.startCol,startOffset:o.startOffset,endLine:n?o.startLine:o.endLine,endCol:n?o.startCol:o.endCol,endOffset:n?o.startOffset:o.endOffset};this.onParseError(i)}onItemPush(e,t,n){var r,o;null===(o=(r=this.treeAdapter).onItemPush)||void 0===o||o.call(r,e),n&&this.openElements.stackTop>0&&this._setContextModes(e,t)}onItemPop(e,t){var n,r;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(e,this.currentToken),null===(r=(n=this.treeAdapter).onItemPop)||void 0===r||r.call(n,e,this.openElements.current),t){let e,t;0===this.openElements.stackTop&&this.fragmentContext?(e=this.fragmentContext,t=this.fragmentContextID):({current:e,currentTagId:t}=this.openElements),this._setContextModes(e,t)}}_setContextModes(e,t){const n=e===this.document||this.treeAdapter.getNamespaceURI(e)===Ws.HTML;this.currentNotInHTML=!n,this.tokenizer.inForeignNode=!n&&!this._isIntegrationPoint(t,e)}_switchToTextParsing(e,t){this._insertElement(e,Ws.HTML),this.tokenizer.state=t,this.originalInsertionMode=this.insertionMode,this.insertionMode=Za.TEXT}switchToPlaintextParsing(){this.insertionMode=Za.TEXT,this.originalInsertionMode=Za.IN_BODY,this.tokenizer.state=ia.PLAINTEXT}_getAdjustedCurrentElement(){return 0===this.openElements.stackTop&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let e=this.fragmentContext;for(;e;){if(this.treeAdapter.getTagName(e)===Xs.FORM){this.formElement=e;break}e=this.treeAdapter.getParentNode(e)}}_initTokenizerForFragmentParsing(){if(this.fragmentContext&&this.treeAdapter.getNamespaceURI(this.fragmentContext)===Ws.HTML)switch(this.fragmentContextID){case $s.TITLE:case $s.TEXTAREA:this.tokenizer.state=ia.RCDATA;break;case $s.STYLE:case $s.XMP:case $s.IFRAME:case $s.NOEMBED:case $s.NOFRAMES:case $s.NOSCRIPT:this.tokenizer.state=ia.RAWTEXT;break;case $s.SCRIPT:this.tokenizer.state=ia.SCRIPT_DATA;break;case $s.PLAINTEXT:this.tokenizer.state=ia.PLAINTEXT}}_setDocumentType(e){const t=e.name||"",n=e.publicId||"",r=e.systemId||"";if(this.treeAdapter.setDocumentType(this.document,t,n,r),e.location){const t=this.treeAdapter.getChildNodes(this.document).find((e=>this.treeAdapter.isDocumentTypeNode(e)));t&&this.treeAdapter.setNodeSourceCodeLocation(t,e.location)}}_attachElementToTree(e,t){if(this.options.sourceCodeLocationInfo){const n=t&&{...t,startTag:t};this.treeAdapter.setNodeSourceCodeLocation(e,n)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(e);else{const t=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(t,e)}}_appendElement(e,t){const n=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(n,e.location)}_insertElement(e,t){const n=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(n,e.location),this.openElements.push(n,e.tagID)}_insertFakeElement(e,t){const n=this.treeAdapter.createElement(e,Ws.HTML,[]);this._attachElementToTree(n,null),this.openElements.push(n,t)}_insertTemplate(e){const t=this.treeAdapter.createElement(e.tagName,Ws.HTML,e.attrs),n=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(t,n),this._attachElementToTree(t,e.location),this.openElements.push(t,e.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,null)}_insertFakeRootElement(){const e=this.treeAdapter.createElement(Xs.HTML,Ws.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(e,null),this.treeAdapter.appendChild(this.openElements.current,e),this.openElements.push(e,$s.HTML)}_appendCommentNode(e,t){const n=this.treeAdapter.createCommentNode(e.data);this.treeAdapter.appendChild(t,n),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,e.location)}_insertCharacters(e){let t,n;if(this._shouldFosterParentOnInsertion()?(({parent:t,beforeElement:n}=this._findFosterParentingLocation()),n?this.treeAdapter.insertTextBefore(t,e.chars,n):this.treeAdapter.insertText(t,e.chars)):(t=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(t,e.chars)),!e.location)return;const r=this.treeAdapter.getChildNodes(t),o=n?r.lastIndexOf(n):r.length,i=r[o-1];if(this.treeAdapter.getNodeSourceCodeLocation(i)){const{endLine:t,endCol:n,endOffset:r}=e.location;this.treeAdapter.updateNodeSourceCodeLocation(i,{endLine:t,endCol:n,endOffset:r})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,e.location)}_adoptNodes(e,t){for(let n=this.treeAdapter.getFirstChild(e);n;n=this.treeAdapter.getFirstChild(e))this.treeAdapter.detachNode(n),this.treeAdapter.appendChild(t,n)}_setEndLocation(e,t){if(this.treeAdapter.getNodeSourceCodeLocation(e)&&t.location){const n=t.location,r=this.treeAdapter.getTagName(e),o=t.type===Os.END_TAG&&r===t.tagName?{endTag:{...n},endLine:n.endLine,endCol:n.endCol,endOffset:n.endOffset}:{endLine:n.startLine,endCol:n.startCol,endOffset:n.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(e,o)}}shouldProcessStartTagTokenInForeignContent(e){if(!this.currentNotInHTML)return!1;let t,n;return 0===this.openElements.stackTop&&this.fragmentContext?(t=this.fragmentContext,n=this.fragmentContextID):({current:t,currentTagId:n}=this.openElements),(e.tagID!==$s.SVG||this.treeAdapter.getTagName(t)!==Xs.ANNOTATION_XML||this.treeAdapter.getNamespaceURI(t)!==Ws.MATHML)&&(this.tokenizer.inForeignNode||(e.tagID===$s.MGLYPH||e.tagID===$s.MALIGNMARK)&&!this._isIntegrationPoint(n,t,Ws.HTML))}_processToken(e){switch(e.type){case Os.CHARACTER:this.onCharacter(e);break;case Os.NULL_CHARACTER:this.onNullCharacter(e);break;case Os.COMMENT:this.onComment(e);break;case Os.DOCTYPE:this.onDoctype(e);break;case Os.START_TAG:this._processStartTag(e);break;case Os.END_TAG:this.onEndTag(e);break;case Os.EOF:this.onEof(e);break;case Os.WHITESPACE_CHARACTER:this.onWhitespaceCharacter(e)}}_isIntegrationPoint(e,t,n){return Va(e,this.treeAdapter.getNamespaceURI(t),this.treeAdapter.getAttrList(t),n)}_reconstructActiveFormattingElements(){const e=this.activeFormattingElements.entries.length;if(e){const t=this.activeFormattingElements.entries.findIndex((e=>e.type===ba.Marker||this.openElements.contains(e.element)));for(let n=t<0?e-1:t-1;n>=0;n--){const e=this.activeFormattingElements.entries[n];this._insertElement(e.token,this.treeAdapter.getNamespaceURI(e.element)),e.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=Za.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion($s.P),this.openElements.popUntilTagNamePopped($s.P)}_resetInsertionMode(){for(let e=this.openElements.stackTop;e>=0;e--)switch(0===e&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[e]){case $s.TR:return void(this.insertionMode=Za.IN_ROW);case $s.TBODY:case $s.THEAD:case $s.TFOOT:return void(this.insertionMode=Za.IN_TABLE_BODY);case $s.CAPTION:return void(this.insertionMode=Za.IN_CAPTION);case $s.COLGROUP:return void(this.insertionMode=Za.IN_COLUMN_GROUP);case $s.TABLE:return void(this.insertionMode=Za.IN_TABLE);case $s.BODY:return void(this.insertionMode=Za.IN_BODY);case $s.FRAMESET:return void(this.insertionMode=Za.IN_FRAMESET);case $s.SELECT:return void this._resetInsertionModeForSelect(e);case $s.TEMPLATE:return void(this.insertionMode=this.tmplInsertionModeStack[0]);case $s.HTML:return void(this.insertionMode=this.headElement?Za.AFTER_HEAD:Za.BEFORE_HEAD);case $s.TD:case $s.TH:if(e>0)return void(this.insertionMode=Za.IN_CELL);break;case $s.HEAD:if(e>0)return void(this.insertionMode=Za.IN_HEAD)}this.insertionMode=Za.IN_BODY}_resetInsertionModeForSelect(e){if(e>0)for(let t=e-1;t>0;t--){const e=this.openElements.tagIDs[t];if(e===$s.TEMPLATE)break;if(e===$s.TABLE)return void(this.insertionMode=Za.IN_SELECT_IN_TABLE)}this.insertionMode=Za.IN_SELECT}_isElementCausesFosterParenting(e){return tc.has(e)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let e=this.openElements.stackTop;e>=0;e--){const t=this.openElements.items[e];switch(this.openElements.tagIDs[e]){case $s.TEMPLATE:if(this.treeAdapter.getNamespaceURI(t)===Ws.HTML)return{parent:this.treeAdapter.getTemplateContent(t),beforeElement:null};break;case $s.TABLE:{const n=this.treeAdapter.getParentNode(t);return n?{parent:n,beforeElement:t}:{parent:this.openElements.items[e-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(e){const t=this._findFosterParentingLocation();t.beforeElement?this.treeAdapter.insertBefore(t.parent,e,t.beforeElement):this.treeAdapter.appendChild(t.parent,e)}_isSpecialElement(e,t){const n=this.treeAdapter.getNamespaceURI(e);return ta[n].has(t)}onCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode)!function(e,t){e._insertCharacters(t),e.framesetOk=!1}(this,e);else switch(this.insertionMode){case Za.INITIAL:dc(this,e);break;case Za.BEFORE_HTML:fc(this,e);break;case Za.BEFORE_HEAD:mc(this,e);break;case Za.IN_HEAD:gc(this,e);break;case Za.IN_HEAD_NO_SCRIPT:Ac(this,e);break;case Za.AFTER_HEAD:_c(this,e);break;case Za.IN_BODY:case Za.IN_CAPTION:case Za.IN_CELL:case Za.IN_TEMPLATE:Cc(this,e);break;case Za.TEXT:case Za.IN_SELECT:case Za.IN_SELECT_IN_TABLE:this._insertCharacters(e);break;case Za.IN_TABLE:case Za.IN_TABLE_BODY:case Za.IN_ROW:Fc(this,e);break;case Za.IN_TABLE_TEXT:wc(this,e);break;case Za.IN_COLUMN_GROUP:Gc(this,e);break;case Za.AFTER_BODY:Xc(this,e);break;case Za.AFTER_AFTER_BODY:$c(this,e)}}onNullCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode)!function(e,t){t.chars=Es,e._insertCharacters(t)}(this,e);else switch(this.insertionMode){case Za.INITIAL:dc(this,e);break;case Za.BEFORE_HTML:fc(this,e);break;case Za.BEFORE_HEAD:mc(this,e);break;case Za.IN_HEAD:gc(this,e);break;case Za.IN_HEAD_NO_SCRIPT:Ac(this,e);break;case Za.AFTER_HEAD:_c(this,e);break;case Za.TEXT:this._insertCharacters(e);break;case Za.IN_TABLE:case Za.IN_TABLE_BODY:case Za.IN_ROW:Fc(this,e);break;case Za.IN_COLUMN_GROUP:Gc(this,e);break;case Za.AFTER_BODY:Xc(this,e);break;case Za.AFTER_AFTER_BODY:$c(this,e)}}onComment(e){if(this.skipNextNewLine=!1,this.currentNotInHTML)hc(this,e);else switch(this.insertionMode){case Za.INITIAL:case Za.BEFORE_HTML:case Za.BEFORE_HEAD:case Za.IN_HEAD:case Za.IN_HEAD_NO_SCRIPT:case Za.AFTER_HEAD:case Za.IN_BODY:case Za.IN_TABLE:case Za.IN_CAPTION:case Za.IN_COLUMN_GROUP:case Za.IN_TABLE_BODY:case Za.IN_ROW:case Za.IN_CELL:case Za.IN_SELECT:case Za.IN_SELECT_IN_TABLE:case Za.IN_TEMPLATE:case Za.IN_FRAMESET:case Za.AFTER_FRAMESET:hc(this,e);break;case Za.IN_TABLE_TEXT:Bc(this,e);break;case Za.AFTER_BODY:!function(e,t){e._appendCommentNode(t,e.openElements.items[0])}(this,e);break;case Za.AFTER_AFTER_BODY:case Za.AFTER_AFTER_FRAMESET:!function(e,t){e._appendCommentNode(t,e.document)}(this,e)}}onDoctype(e){switch(this.skipNextNewLine=!1,this.insertionMode){case Za.INITIAL:!function(e,t){e._setDocumentType(t);const n=t.forceQuirks?Vs.QUIRKS:function(e){if(e.name!==va)return Vs.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===Fa)return Vs.QUIRKS;let{publicId:n}=e;if(null!==n){if(n=n.toLowerCase(),Pa.has(n))return Vs.QUIRKS;let e=null===t?xa:La;if(Ba(n,e))return Vs.QUIRKS;if(e=null===t?Ma:wa,Ba(n,e))return Vs.LIMITED_QUIRKS}return Vs.NO_QUIRKS}(t);(function(e){return e.name===va&&null===e.publicId&&(null===e.systemId||e.systemId===Ra)})(t)||e._err(t,Ss.nonConformingDoctype);e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=Za.BEFORE_HTML}(this,e);break;case Za.BEFORE_HEAD:case Za.IN_HEAD:case Za.IN_HEAD_NO_SCRIPT:case Za.AFTER_HEAD:this._err(e,Ss.misplacedDoctype);break;case Za.IN_TABLE_TEXT:Bc(this,e)}}onStartTag(e){this.skipNextNewLine=!1,this.currentToken=e,this._processStartTag(e),e.selfClosing&&!e.ackSelfClosing&&this._err(e,Ss.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(e){this.shouldProcessStartTagTokenInForeignContent(e)?function(e,t){if(function(e){const t=e.tagID;return t===$s.FONT&&e.attrs.some((e=>{let{name:t}=e;return t===Ks.COLOR||t===Ks.SIZE||t===Ks.FACE}))||qa.has(t)}(t))Jc(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),r=e.treeAdapter.getNamespaceURI(n);r===Ws.MATHML?Qa(t):r===Ws.SVG&&(!function(e){const t=za.get(e.tagName);null!=t&&(e.tagName=t,e.tagID=Zs(e.tagName))}(t),Wa(t)),Ka(t),t.selfClosing?e._appendElement(t,r):e._insertElement(t,r),t.ackSelfClosing=!0}}(this,e):this._startTagOutsideForeignContent(e)}_startTagOutsideForeignContent(e){switch(this.insertionMode){case Za.INITIAL:dc(this,e);break;case Za.BEFORE_HTML:!function(e,t){t.tagID===$s.HTML?(e._insertElement(t,Ws.HTML),e.insertionMode=Za.BEFORE_HEAD):fc(e,t)}(this,e);break;case Za.BEFORE_HEAD:!function(e,t){switch(t.tagID){case $s.HTML:Ic(e,t);break;case $s.HEAD:e._insertElement(t,Ws.HTML),e.headElement=e.openElements.current,e.insertionMode=Za.IN_HEAD;break;default:mc(e,t)}}(this,e);break;case Za.IN_HEAD:Ec(this,e);break;case Za.IN_HEAD_NO_SCRIPT:!function(e,t){switch(t.tagID){case $s.HTML:Ic(e,t);break;case $s.BASEFONT:case $s.BGSOUND:case $s.HEAD:case $s.LINK:case $s.META:case $s.NOFRAMES:case $s.STYLE:Ec(e,t);break;case $s.NOSCRIPT:e._err(t,Ss.nestedNoscriptInHead);break;default:Ac(e,t)}}(this,e);break;case Za.AFTER_HEAD:!function(e,t){switch(t.tagID){case $s.HTML:Ic(e,t);break;case $s.BODY:e._insertElement(t,Ws.HTML),e.framesetOk=!1,e.insertionMode=Za.IN_BODY;break;case $s.FRAMESET:e._insertElement(t,Ws.HTML),e.insertionMode=Za.IN_FRAMESET;break;case $s.BASE:case $s.BASEFONT:case $s.BGSOUND:case $s.LINK:case $s.META:case $s.NOFRAMES:case $s.SCRIPT:case $s.STYLE:case $s.TEMPLATE:case $s.TITLE:e._err(t,Ss.abandonedHeadElementChild),e.openElements.push(e.headElement,$s.HEAD),Ec(e,t),e.openElements.remove(e.headElement);break;case $s.HEAD:e._err(t,Ss.misplacedStartTagForHeadElement);break;default:_c(e,t)}}(this,e);break;case Za.IN_BODY:Ic(this,e);break;case Za.IN_TABLE:Lc(this,e);break;case Za.IN_TABLE_TEXT:Bc(this,e);break;case Za.IN_CAPTION:!function(e,t){const n=t.tagID;Hc.has(n)?e.openElements.hasInTableScope($s.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped($s.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Za.IN_TABLE,Lc(e,t)):Ic(e,t)}(this,e);break;case Za.IN_COLUMN_GROUP:Uc(this,e);break;case Za.IN_TABLE_BODY:jc(this,e);break;case Za.IN_ROW:zc(this,e);break;case Za.IN_CELL:!function(e,t){const n=t.tagID;Hc.has(n)?(e.openElements.hasInTableScope($s.TD)||e.openElements.hasInTableScope($s.TH))&&(e._closeTableCell(),zc(e,t)):Ic(e,t)}(this,e);break;case Za.IN_SELECT:Qc(this,e);break;case Za.IN_SELECT_IN_TABLE:!function(e,t){const n=t.tagID;n===$s.CAPTION||n===$s.TABLE||n===$s.TBODY||n===$s.TFOOT||n===$s.THEAD||n===$s.TR||n===$s.TD||n===$s.TH?(e.openElements.popUntilTagNamePopped($s.SELECT),e._resetInsertionMode(),e._processStartTag(t)):Qc(e,t)}(this,e);break;case Za.IN_TEMPLATE:!function(e,t){switch(t.tagID){case $s.BASE:case $s.BASEFONT:case $s.BGSOUND:case $s.LINK:case $s.META:case $s.NOFRAMES:case $s.SCRIPT:case $s.STYLE:case $s.TEMPLATE:case $s.TITLE:Ec(e,t);break;case $s.CAPTION:case $s.COLGROUP:case $s.TBODY:case $s.TFOOT:case $s.THEAD:e.tmplInsertionModeStack[0]=Za.IN_TABLE,e.insertionMode=Za.IN_TABLE,Lc(e,t);break;case $s.COL:e.tmplInsertionModeStack[0]=Za.IN_COLUMN_GROUP,e.insertionMode=Za.IN_COLUMN_GROUP,Uc(e,t);break;case $s.TR:e.tmplInsertionModeStack[0]=Za.IN_TABLE_BODY,e.insertionMode=Za.IN_TABLE_BODY,jc(e,t);break;case $s.TD:case $s.TH:e.tmplInsertionModeStack[0]=Za.IN_ROW,e.insertionMode=Za.IN_ROW,zc(e,t);break;default:e.tmplInsertionModeStack[0]=Za.IN_BODY,e.insertionMode=Za.IN_BODY,Ic(e,t)}}(this,e);break;case Za.AFTER_BODY:!function(e,t){t.tagID===$s.HTML?Ic(e,t):Xc(e,t)}(this,e);break;case Za.IN_FRAMESET:!function(e,t){switch(t.tagID){case $s.HTML:Ic(e,t);break;case $s.FRAMESET:e._insertElement(t,Ws.HTML);break;case $s.FRAME:e._appendElement(t,Ws.HTML),t.ackSelfClosing=!0;break;case $s.NOFRAMES:Ec(e,t)}}(this,e);break;case Za.AFTER_FRAMESET:!function(e,t){switch(t.tagID){case $s.HTML:Ic(e,t);break;case $s.NOFRAMES:Ec(e,t)}}(this,e);break;case Za.AFTER_AFTER_BODY:!function(e,t){t.tagID===$s.HTML?Ic(e,t):$c(e,t)}(this,e);break;case Za.AFTER_AFTER_FRAMESET:!function(e,t){switch(t.tagID){case $s.HTML:Ic(e,t);break;case $s.NOFRAMES:Ec(e,t)}}(this,e)}}onEndTag(e){this.skipNextNewLine=!1,this.currentToken=e,this.currentNotInHTML?function(e,t){if(t.tagID===$s.P||t.tagID===$s.BR)return Jc(e),void e._endTagOutsideForeignContent(t);for(let n=e.openElements.stackTop;n>0;n--){const r=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(r)===Ws.HTML){e._endTagOutsideForeignContent(t);break}const o=e.treeAdapter.getTagName(r);if(o.toLowerCase()===t.tagName){t.tagName=o,e.openElements.shortenToLength(n);break}}}(this,e):this._endTagOutsideForeignContent(e)}_endTagOutsideForeignContent(e){switch(this.insertionMode){case Za.INITIAL:dc(this,e);break;case Za.BEFORE_HTML:!function(e,t){const n=t.tagID;n!==$s.HTML&&n!==$s.HEAD&&n!==$s.BODY&&n!==$s.BR||fc(e,t)}(this,e);break;case Za.BEFORE_HEAD:!function(e,t){const n=t.tagID;n===$s.HEAD||n===$s.BODY||n===$s.HTML||n===$s.BR?mc(e,t):e._err(t,Ss.endTagWithoutMatchingOpenElement)}(this,e);break;case Za.IN_HEAD:!function(e,t){switch(t.tagID){case $s.HEAD:e.openElements.pop(),e.insertionMode=Za.AFTER_HEAD;break;case $s.BODY:case $s.BR:case $s.HTML:gc(e,t);break;case $s.TEMPLATE:Tc(e,t);break;default:e._err(t,Ss.endTagWithoutMatchingOpenElement)}}(this,e);break;case Za.IN_HEAD_NO_SCRIPT:!function(e,t){switch(t.tagID){case $s.NOSCRIPT:e.openElements.pop(),e.insertionMode=Za.IN_HEAD;break;case $s.BR:Ac(e,t);break;default:e._err(t,Ss.endTagWithoutMatchingOpenElement)}}(this,e);break;case Za.AFTER_HEAD:!function(e,t){switch(t.tagID){case $s.BODY:case $s.HTML:case $s.BR:_c(e,t);break;case $s.TEMPLATE:Tc(e,t);break;default:e._err(t,Ss.endTagWithoutMatchingOpenElement)}}(this,e);break;case Za.IN_BODY:vc(this,e);break;case Za.TEXT:!function(e,t){var n;t.tagID===$s.SCRIPT&&(null===(n=e.scriptHandler)||void 0===n||n.call(e,e.openElements.current));e.openElements.pop(),e.insertionMode=e.originalInsertionMode}(this,e);break;case Za.IN_TABLE:xc(this,e);break;case Za.IN_TABLE_TEXT:Bc(this,e);break;case Za.IN_CAPTION:!function(e,t){const n=t.tagID;switch(n){case $s.CAPTION:case $s.TABLE:e.openElements.hasInTableScope($s.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped($s.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Za.IN_TABLE,n===$s.TABLE&&xc(e,t));break;case $s.BODY:case $s.COL:case $s.COLGROUP:case $s.HTML:case $s.TBODY:case $s.TD:case $s.TFOOT:case $s.TH:case $s.THEAD:case $s.TR:break;default:vc(e,t)}}(this,e);break;case Za.IN_COLUMN_GROUP:!function(e,t){switch(t.tagID){case $s.COLGROUP:e.openElements.currentTagId===$s.COLGROUP&&(e.openElements.pop(),e.insertionMode=Za.IN_TABLE);break;case $s.TEMPLATE:Tc(e,t);break;case $s.COL:break;default:Gc(e,t)}}(this,e);break;case Za.IN_TABLE_BODY:Yc(this,e);break;case Za.IN_ROW:qc(this,e);break;case Za.IN_CELL:!function(e,t){const n=t.tagID;switch(n){case $s.TD:case $s.TH:e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=Za.IN_ROW);break;case $s.TABLE:case $s.TBODY:case $s.TFOOT:case $s.THEAD:case $s.TR:e.openElements.hasInTableScope(n)&&(e._closeTableCell(),qc(e,t));break;case $s.BODY:case $s.CAPTION:case $s.COL:case $s.COLGROUP:case $s.HTML:break;default:vc(e,t)}}(this,e);break;case Za.IN_SELECT:Wc(this,e);break;case Za.IN_SELECT_IN_TABLE:!function(e,t){const n=t.tagID;n===$s.CAPTION||n===$s.TABLE||n===$s.TBODY||n===$s.TFOOT||n===$s.THEAD||n===$s.TR||n===$s.TD||n===$s.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped($s.SELECT),e._resetInsertionMode(),e.onEndTag(t)):Wc(e,t)}(this,e);break;case Za.IN_TEMPLATE:!function(e,t){t.tagID===$s.TEMPLATE&&Tc(e,t)}(this,e);break;case Za.AFTER_BODY:Vc(this,e);break;case Za.IN_FRAMESET:!function(e,t){t.tagID!==$s.FRAMESET||e.openElements.isRootHtmlElementCurrent()||(e.openElements.pop(),e.fragmentContext||e.openElements.currentTagId===$s.FRAMESET||(e.insertionMode=Za.AFTER_FRAMESET))}(this,e);break;case Za.AFTER_FRAMESET:!function(e,t){t.tagID===$s.HTML&&(e.insertionMode=Za.AFTER_AFTER_FRAMESET)}(this,e);break;case Za.AFTER_AFTER_BODY:$c(this,e)}}onEof(e){switch(this.insertionMode){case Za.INITIAL:dc(this,e);break;case Za.BEFORE_HTML:fc(this,e);break;case Za.BEFORE_HEAD:mc(this,e);break;case Za.IN_HEAD:gc(this,e);break;case Za.IN_HEAD_NO_SCRIPT:Ac(this,e);break;case Za.AFTER_HEAD:_c(this,e);break;case Za.IN_BODY:case Za.IN_TABLE:case Za.IN_CAPTION:case Za.IN_COLUMN_GROUP:case Za.IN_TABLE_BODY:case Za.IN_ROW:case Za.IN_CELL:case Za.IN_SELECT:case Za.IN_SELECT_IN_TABLE:Rc(this,e);break;case Za.TEXT:!function(e,t){e._err(t,Ss.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}(this,e);break;case Za.IN_TABLE_TEXT:Bc(this,e);break;case Za.IN_TEMPLATE:Kc(this,e);break;case Za.AFTER_BODY:case Za.IN_FRAMESET:case Za.AFTER_FRAMESET:case Za.AFTER_AFTER_BODY:case Za.AFTER_AFTER_FRAMESET:pc(this,e)}}onWhitespaceCharacter(e){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,e.chars.charCodeAt(0)===Ts.LINE_FEED)){if(1===e.chars.length)return;e.chars=e.chars.substr(1)}if(this.tokenizer.inForeignNode)this._insertCharacters(e);else switch(this.insertionMode){case Za.IN_HEAD:case Za.IN_HEAD_NO_SCRIPT:case Za.AFTER_HEAD:case Za.TEXT:case Za.IN_COLUMN_GROUP:case Za.IN_SELECT:case Za.IN_SELECT_IN_TABLE:case Za.IN_FRAMESET:case Za.AFTER_FRAMESET:this._insertCharacters(e);break;case Za.IN_BODY:case Za.IN_CAPTION:case Za.IN_CELL:case Za.IN_TEMPLATE:case Za.AFTER_BODY:case Za.AFTER_AFTER_BODY:case Za.AFTER_AFTER_FRAMESET:yc(this,e);break;case Za.IN_TABLE:case Za.IN_TABLE_BODY:case Za.IN_ROW:Fc(this,e);break;case Za.IN_TABLE_TEXT:Mc(this,e)}}}function oc(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):Oc(e,t),n}function ic(e,t){let n=null,r=e.openElements.stackTop;for(;r>=0;r--){const o=e.openElements.items[r];if(o===t.element)break;e._isSpecialElement(o,e.openElements.tagIDs[r])&&(n=o)}return n||(e.openElements.shortenToLength(r<0?0:r),e.activeFormattingElements.removeEntry(t)),n}function sc(e,t,n){let r=t,o=e.openElements.getCommonAncestor(t);for(let i=0,s=o;s!==n;i++,s=o){o=e.openElements.getCommonAncestor(s);const n=e.activeFormattingElements.getElementEntry(s),a=n&&i>=Ja;!n||a?(a&&e.activeFormattingElements.removeEntry(n),e.openElements.remove(s)):(s=ac(e,n),r===t&&(e.activeFormattingElements.bookmark=n),e.treeAdapter.detachNode(r),e.treeAdapter.appendChild(s,r),r=s)}return r}function ac(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),r=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,r),t.element=r,r}function cc(e,t,n){const r=Zs(e.treeAdapter.getTagName(t));if(e._isElementCausesFosterParenting(r))e._fosterParentElement(n);else{const o=e.treeAdapter.getNamespaceURI(t);r===$s.TEMPLATE&&o===Ws.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function lc(e,t,n){const r=e.treeAdapter.getNamespaceURI(n.element),{token:o}=n,i=e.treeAdapter.createElement(o.tagName,r,o.attrs);e._adoptNodes(t,i),e.treeAdapter.appendChild(t,i),e.activeFormattingElements.insertElementAfterBookmark(i,o),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,i,o.tagID)}function uc(e,t){for(let n=0;n<$a;n++){const n=oc(e,t);if(!n)break;const r=ic(e,n);if(!r)break;e.activeFormattingElements.bookmark=n;const o=sc(e,r,n.element),i=e.openElements.getCommonAncestor(n.element);e.treeAdapter.detachNode(o),i&&cc(e,i,o),lc(e,r,n)}}function hc(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function pc(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let r=e.openElements.stackTop;r>=n;r--)e._setEndLocation(e.openElements.items[r],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const n=e.openElements.items[0],r=e.treeAdapter.getNodeSourceCodeLocation(n);if(r&&!r.endTag&&(e._setEndLocation(n,t),e.openElements.stackTop>=1)){const n=e.openElements.items[1],r=e.treeAdapter.getNodeSourceCodeLocation(n);r&&!r.endTag&&e._setEndLocation(n,t)}}}}function dc(e,t){e._err(t,Ss.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,Vs.QUIRKS),e.insertionMode=Za.BEFORE_HTML,e._processToken(t)}function fc(e,t){e._insertFakeRootElement(),e.insertionMode=Za.BEFORE_HEAD,e._processToken(t)}function mc(e,t){e._insertFakeElement(Xs.HEAD,$s.HEAD),e.headElement=e.openElements.current,e.insertionMode=Za.IN_HEAD,e._processToken(t)}function Ec(e,t){switch(t.tagID){case $s.HTML:Ic(e,t);break;case $s.BASE:case $s.BASEFONT:case $s.BGSOUND:case $s.LINK:case $s.META:e._appendElement(t,Ws.HTML),t.ackSelfClosing=!0;break;case $s.TITLE:e._switchToTextParsing(t,ia.RCDATA);break;case $s.NOSCRIPT:e.options.scriptingEnabled?e._switchToTextParsing(t,ia.RAWTEXT):(e._insertElement(t,Ws.HTML),e.insertionMode=Za.IN_HEAD_NO_SCRIPT);break;case $s.NOFRAMES:case $s.STYLE:e._switchToTextParsing(t,ia.RAWTEXT);break;case $s.SCRIPT:e._switchToTextParsing(t,ia.SCRIPT_DATA);break;case $s.TEMPLATE:e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=Za.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(Za.IN_TEMPLATE);break;case $s.HEAD:e._err(t,Ss.misplacedStartTagForHeadElement);break;default:gc(e,t)}}function Tc(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==$s.TEMPLATE&&e._err(t,Ss.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped($s.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,Ss.endTagWithoutMatchingOpenElement)}function gc(e,t){e.openElements.pop(),e.insertionMode=Za.AFTER_HEAD,e._processToken(t)}function Ac(e,t){const n=t.type===Os.EOF?Ss.openElementsLeftAfterEof:Ss.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=Za.IN_HEAD,e._processToken(t)}function _c(e,t){e._insertFakeElement(Xs.BODY,$s.BODY),e.insertionMode=Za.IN_BODY,Dc(e,t)}function Dc(e,t){switch(t.type){case Os.CHARACTER:Cc(e,t);break;case Os.WHITESPACE_CHARACTER:yc(e,t);break;case Os.COMMENT:hc(e,t);break;case Os.START_TAG:Ic(e,t);break;case Os.END_TAG:vc(e,t);break;case Os.EOF:Rc(e,t)}}function yc(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function Cc(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function kc(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Ws.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function bc(e){const t=vs(e,Ks.TYPE);return null!=t&&t.toLowerCase()===Xa}function Nc(e,t){e._switchToTextParsing(t,ia.RAWTEXT)}function Sc(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ws.HTML)}function Ic(e,t){switch(t.tagID){case $s.I:case $s.S:case $s.B:case $s.U:case $s.EM:case $s.TT:case $s.BIG:case $s.CODE:case $s.FONT:case $s.SMALL:case $s.STRIKE:case $s.STRONG:!function(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ws.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}(e,t);break;case $s.A:!function(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(Xs.A);n&&(uc(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,Ws.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}(e,t);break;case $s.H1:case $s.H2:case $s.H3:case $s.H4:case $s.H5:case $s.H6:!function(e,t){e.openElements.hasInButtonScope($s.P)&&e._closePElement(),na(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,Ws.HTML)}(e,t);break;case $s.P:case $s.DL:case $s.OL:case $s.UL:case $s.DIV:case $s.DIR:case $s.NAV:case $s.MAIN:case $s.MENU:case $s.ASIDE:case $s.CENTER:case $s.FIGURE:case $s.FOOTER:case $s.HEADER:case $s.HGROUP:case $s.DIALOG:case $s.DETAILS:case $s.ADDRESS:case $s.ARTICLE:case $s.SECTION:case $s.SUMMARY:case $s.FIELDSET:case $s.BLOCKQUOTE:case $s.FIGCAPTION:!function(e,t){e.openElements.hasInButtonScope($s.P)&&e._closePElement(),e._insertElement(t,Ws.HTML)}(e,t);break;case $s.LI:case $s.DD:case $s.DT:!function(e,t){e.framesetOk=!1;const n=t.tagID;for(let r=e.openElements.stackTop;r>=0;r--){const t=e.openElements.tagIDs[r];if(n===$s.LI&&t===$s.LI||(n===$s.DD||n===$s.DT)&&(t===$s.DD||t===$s.DT)){e.openElements.generateImpliedEndTagsWithExclusion(t),e.openElements.popUntilTagNamePopped(t);break}if(t!==$s.ADDRESS&&t!==$s.DIV&&t!==$s.P&&e._isSpecialElement(e.openElements.items[r],t))break}e.openElements.hasInButtonScope($s.P)&&e._closePElement(),e._insertElement(t,Ws.HTML)}(e,t);break;case $s.BR:case $s.IMG:case $s.WBR:case $s.AREA:case $s.EMBED:case $s.KEYGEN:kc(e,t);break;case $s.HR:!function(e,t){e.openElements.hasInButtonScope($s.P)&&e._closePElement(),e._appendElement(t,Ws.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}(e,t);break;case $s.RB:case $s.RTC:!function(e,t){e.openElements.hasInScope($s.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,Ws.HTML)}(e,t);break;case $s.RT:case $s.RP:!function(e,t){e.openElements.hasInScope($s.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion($s.RTC),e._insertElement(t,Ws.HTML)}(e,t);break;case $s.PRE:case $s.LISTING:!function(e,t){e.openElements.hasInButtonScope($s.P)&&e._closePElement(),e._insertElement(t,Ws.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}(e,t);break;case $s.XMP:!function(e,t){e.openElements.hasInButtonScope($s.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,ia.RAWTEXT)}(e,t);break;case $s.SVG:!function(e,t){e._reconstructActiveFormattingElements(),Wa(t),Ka(t),t.selfClosing?e._appendElement(t,Ws.SVG):e._insertElement(t,Ws.SVG),t.ackSelfClosing=!0}(e,t);break;case $s.HTML:!function(e,t){0===e.openElements.tmplCount&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}(e,t);break;case $s.BASE:case $s.LINK:case $s.META:case $s.STYLE:case $s.TITLE:case $s.SCRIPT:case $s.BGSOUND:case $s.BASEFONT:case $s.TEMPLATE:Ec(e,t);break;case $s.BODY:!function(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&0===e.openElements.tmplCount&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}(e,t);break;case $s.FORM:!function(e,t){const n=e.openElements.tmplCount>0;e.formElement&&!n||(e.openElements.hasInButtonScope($s.P)&&e._closePElement(),e._insertElement(t,Ws.HTML),n||(e.formElement=e.openElements.current))}(e,t);break;case $s.NOBR:!function(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope($s.NOBR)&&(uc(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,Ws.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}(e,t);break;case $s.MATH:!function(e,t){e._reconstructActiveFormattingElements(),Qa(t),Ka(t),t.selfClosing?e._appendElement(t,Ws.MATHML):e._insertElement(t,Ws.MATHML),t.ackSelfClosing=!0}(e,t);break;case $s.TABLE:!function(e,t){e.treeAdapter.getDocumentMode(e.document)!==Vs.QUIRKS&&e.openElements.hasInButtonScope($s.P)&&e._closePElement(),e._insertElement(t,Ws.HTML),e.framesetOk=!1,e.insertionMode=Za.IN_TABLE}(e,t);break;case $s.INPUT:!function(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Ws.HTML),bc(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}(e,t);break;case $s.PARAM:case $s.TRACK:case $s.SOURCE:!function(e,t){e._appendElement(t,Ws.HTML),t.ackSelfClosing=!0}(e,t);break;case $s.IMAGE:!function(e,t){t.tagName=Xs.IMG,t.tagID=$s.IMG,kc(e,t)}(e,t);break;case $s.BUTTON:!function(e,t){e.openElements.hasInScope($s.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped($s.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,Ws.HTML),e.framesetOk=!1}(e,t);break;case $s.APPLET:case $s.OBJECT:case $s.MARQUEE:!function(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ws.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}(e,t);break;case $s.IFRAME:!function(e,t){e.framesetOk=!1,e._switchToTextParsing(t,ia.RAWTEXT)}(e,t);break;case $s.SELECT:!function(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Ws.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===Za.IN_TABLE||e.insertionMode===Za.IN_CAPTION||e.insertionMode===Za.IN_TABLE_BODY||e.insertionMode===Za.IN_ROW||e.insertionMode===Za.IN_CELL?Za.IN_SELECT_IN_TABLE:Za.IN_SELECT}(e,t);break;case $s.OPTION:case $s.OPTGROUP:!function(e,t){e.openElements.currentTagId===$s.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,Ws.HTML)}(e,t);break;case $s.NOEMBED:Nc(e,t);break;case $s.FRAMESET:!function(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,Ws.HTML),e.insertionMode=Za.IN_FRAMESET)}(e,t);break;case $s.TEXTAREA:!function(e,t){e._insertElement(t,Ws.HTML),e.skipNextNewLine=!0,e.tokenizer.state=ia.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=Za.TEXT}(e,t);break;case $s.NOSCRIPT:e.options.scriptingEnabled?Nc(e,t):Sc(e,t);break;case $s.PLAINTEXT:!function(e,t){e.openElements.hasInButtonScope($s.P)&&e._closePElement(),e._insertElement(t,Ws.HTML),e.tokenizer.state=ia.PLAINTEXT}(e,t);break;case $s.COL:case $s.TH:case $s.TD:case $s.TR:case $s.HEAD:case $s.FRAME:case $s.TBODY:case $s.TFOOT:case $s.THEAD:case $s.CAPTION:case $s.COLGROUP:break;default:Sc(e,t)}}function Oc(e,t){const n=t.tagName,r=t.tagID;for(let o=e.openElements.stackTop;o>0;o--){const t=e.openElements.items[o],i=e.openElements.tagIDs[o];if(r===i&&(r!==$s.UNKNOWN||e.treeAdapter.getTagName(t)===n)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.stackTop>=o&&e.openElements.shortenToLength(o);break}if(e._isSpecialElement(t,i))break}}function vc(e,t){switch(t.tagID){case $s.A:case $s.B:case $s.I:case $s.S:case $s.U:case $s.EM:case $s.TT:case $s.BIG:case $s.CODE:case $s.FONT:case $s.NOBR:case $s.SMALL:case $s.STRIKE:case $s.STRONG:uc(e,t);break;case $s.P:!function(e){e.openElements.hasInButtonScope($s.P)||e._insertFakeElement(Xs.P,$s.P),e._closePElement()}(e);break;case $s.DL:case $s.UL:case $s.OL:case $s.DIR:case $s.DIV:case $s.NAV:case $s.PRE:case $s.MAIN:case $s.MENU:case $s.ASIDE:case $s.BUTTON:case $s.CENTER:case $s.FIGURE:case $s.FOOTER:case $s.HEADER:case $s.HGROUP:case $s.DIALOG:case $s.ADDRESS:case $s.ARTICLE:case $s.DETAILS:case $s.SECTION:case $s.SUMMARY:case $s.LISTING:case $s.FIELDSET:case $s.BLOCKQUOTE:case $s.FIGCAPTION:!function(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}(e,t);break;case $s.LI:!function(e){e.openElements.hasInListItemScope($s.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion($s.LI),e.openElements.popUntilTagNamePopped($s.LI))}(e);break;case $s.DD:case $s.DT:!function(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}(e,t);break;case $s.H1:case $s.H2:case $s.H3:case $s.H4:case $s.H5:case $s.H6:!function(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}(e);break;case $s.BR:!function(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(Xs.BR,$s.BR),e.openElements.pop(),e.framesetOk=!1}(e);break;case $s.BODY:!function(e,t){if(e.openElements.hasInScope($s.BODY)&&(e.insertionMode=Za.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}(e,t);break;case $s.HTML:!function(e,t){e.openElements.hasInScope($s.BODY)&&(e.insertionMode=Za.AFTER_BODY,Vc(e,t))}(e,t);break;case $s.FORM:!function(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope($s.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped($s.FORM):n&&e.openElements.remove(n))}(e);break;case $s.APPLET:case $s.OBJECT:case $s.MARQUEE:!function(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}(e,t);break;case $s.TEMPLATE:Tc(e,t);break;default:Oc(e,t)}}function Rc(e,t){e.tmplInsertionModeStack.length>0?Kc(e,t):pc(e,t)}function Fc(e,t){if(tc.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=Za.IN_TABLE_TEXT,t.type){case Os.CHARACTER:wc(e,t);break;case Os.WHITESPACE_CHARACTER:Mc(e,t)}else Pc(e,t)}function Lc(e,t){switch(t.tagID){case $s.TD:case $s.TH:case $s.TR:!function(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(Xs.TBODY,$s.TBODY),e.insertionMode=Za.IN_TABLE_BODY,jc(e,t)}(e,t);break;case $s.STYLE:case $s.SCRIPT:case $s.TEMPLATE:Ec(e,t);break;case $s.COL:!function(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(Xs.COLGROUP,$s.COLGROUP),e.insertionMode=Za.IN_COLUMN_GROUP,Uc(e,t)}(e,t);break;case $s.FORM:!function(e,t){e.formElement||0!==e.openElements.tmplCount||(e._insertElement(t,Ws.HTML),e.formElement=e.openElements.current,e.openElements.pop())}(e,t);break;case $s.TABLE:!function(e,t){e.openElements.hasInTableScope($s.TABLE)&&(e.openElements.popUntilTagNamePopped($s.TABLE),e._resetInsertionMode(),e._processStartTag(t))}(e,t);break;case $s.TBODY:case $s.TFOOT:case $s.THEAD:!function(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Ws.HTML),e.insertionMode=Za.IN_TABLE_BODY}(e,t);break;case $s.INPUT:!function(e,t){bc(t)?e._appendElement(t,Ws.HTML):Pc(e,t),t.ackSelfClosing=!0}(e,t);break;case $s.CAPTION:!function(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,Ws.HTML),e.insertionMode=Za.IN_CAPTION}(e,t);break;case $s.COLGROUP:!function(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Ws.HTML),e.insertionMode=Za.IN_COLUMN_GROUP}(e,t);break;default:Pc(e,t)}}function xc(e,t){switch(t.tagID){case $s.TABLE:e.openElements.hasInTableScope($s.TABLE)&&(e.openElements.popUntilTagNamePopped($s.TABLE),e._resetInsertionMode());break;case $s.TEMPLATE:Tc(e,t);break;case $s.BODY:case $s.CAPTION:case $s.COL:case $s.COLGROUP:case $s.HTML:case $s.TBODY:case $s.TD:case $s.TFOOT:case $s.TH:case $s.THEAD:case $s.TR:break;default:Pc(e,t)}}function Pc(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,Dc(e,t),e.fosterParentingEnabled=n}function Mc(e,t){e.pendingCharacterTokens.push(t)}function wc(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function Bc(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n0&&e.openElements.currentTagId===$s.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===$s.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===$s.OPTGROUP&&e.openElements.pop();break;case $s.OPTION:e.openElements.currentTagId===$s.OPTION&&e.openElements.pop();break;case $s.SELECT:e.openElements.hasInSelectScope($s.SELECT)&&(e.openElements.popUntilTagNamePopped($s.SELECT),e._resetInsertionMode());break;case $s.TEMPLATE:Tc(e,t)}}function Kc(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped($s.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):pc(e,t)}function Vc(e,t){var n;if(t.tagID===$s.HTML){if(e.fragmentContext||(e.insertionMode=Za.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===$s.HTML){e._setEndLocation(e.openElements.items[0],t);const r=e.openElements.items[1];r&&!(null===(n=e.treeAdapter.getNodeSourceCodeLocation(r))||void 0===n?void 0:n.endTag)&&e._setEndLocation(r,t)}}else Xc(e,t)}function Xc(e,t){e.insertionMode=Za.IN_BODY,Dc(e,t)}function $c(e,t){e.insertionMode=Za.IN_BODY,Dc(e,t)}function Jc(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==Ws.HTML&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}const Zc=new Map([[34,"""],[38,"&"],[39,"'"],[60,"<"],[62,">"]]);String.prototype.codePointAt;function el(e,t){return function(n){let r,o=0,i="";for(;r=e.exec(n);)o!==r.index&&(i+=n.substring(o,r.index)),i+=t.get(r[0].charCodeAt(0)),o=r.index+1;return i+n.substring(o)}}el(/[&<>'"]/g,Zc),el(/["&\u00A0]/g,new Map([[34,"""],[38,"&"],[160," "]])),el(/[&<>\u00A0]/g,new Map([[38,"&"],[60,"<"],[62,">"],[160," "]])),new Set([Xs.AREA,Xs.BASE,Xs.BASEFONT,Xs.BGSOUND,Xs.BR,Xs.COL,Xs.EMBED,Xs.FRAME,Xs.HR,Xs.IMG,Xs.INPUT,Xs.KEYGEN,Xs.LINK,Xs.META,Xs.PARAM,Xs.SOURCE,Xs.TRACK,Xs.WBR]);const tl=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),nl={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function rl(e,t){const n=function(e){const t="root"===e.type?e.children[0]:e;return Boolean(t&&("doctype"===t.type||"element"===t.type&&"html"===t.tagName))}(e),r=as("type",{handlers:{root:il,element:sl,text:al,comment:ul,doctype:cl,raw:hl},unknown:pl}),o={parser:n?new rc(nl):rc.getFragmentParser(void 0,nl),handle(e){r(e,o)},stitches:!1,options:t||{}};r(e,o),dl(o,Ee());const i=function(e,t){const n=t||{};return ts({file:n.file||void 0,location:!1,schema:"svg"===n.space?le.YP:le.dy,verbose:n.verbose||!1},e)}(n?o.parser.document:o.parser.getFragment(),{file:o.options.file});return o.stitches&&or(i,"comment",(function(e,t,n){const r=e;if(r.value.stitch&&n&&void 0!==t){return n.children[t]=r.value.stitch,t}})),"root"===i.type&&1===i.children.length&&i.children[0].type===e.type?i.children[0]:i}function ol(e,t){let n=-1;if(e)for(;++n{var t=Al(e.target);t&&(t.classList.add("active"),gl()(t.dataset.code,(function(){setTimeout((()=>{t.classList.remove("active")}),2e3)})))};(0,o.useEffect)((()=>{var n,r;return null==(n=e.current)||n.removeEventListener("click",t,!1),null==(r=e.current)||r.addEventListener("click",t,!1),()=>{var n;null==(n=e.current)||n.removeEventListener("click",t,!1)}}),[e])}var Dl=["prefixCls","className","source","style","disableCopy","skipHtml","onScroll","onMouseOver","pluginsFilter","rehypeRewrite","wrapperElement","warpperElement"];const yl=o.forwardRef(((e,t)=>{var{prefixCls:n="wmde-markdown wmde-markdown-color",className:r,source:i,style:c,disableCopy:l=!1,skipHtml:h=!0,onScroll:p,onMouseOver:d,pluginsFilter:f,wrapperElement:m={},warpperElement:E={}}=e,T=a(e,Dl),g=o.useRef(null);(0,o.useImperativeHandle)(t,(()=>s({},e,{mdp:g})),[g,e]);var A=(n||"")+" "+(r||"");_l(g);var _=[...T.rehypePlugins||[]],D={allowElement:(e,t,n)=>T.allowElement?T.allowElement(e,t,n):/^[A-Za-z0-9]+$/.test(e.tagName)};h&&_.push(El);var y=[...T.remarkPlugins||[],Ui],C=s({},E,m);return(0,u.jsx)("div",s({ref:g,onScroll:p,onMouseOver:d},C,{className:A,style:c,children:(0,u.jsx)(Xr,s({},D,T,{skipHtml:h,rehypePlugins:f?f("rehype",_):_,remarkPlugins:f?f("remark",y):y,children:i||""}))}))})),Cl=function(e){if(void 0===e||null===e)return bl;if("string"===typeof e)return function(e){return kl(t);function t(t){return t&&t.type===e}}(e);if("object"===typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n1?n-1:0),o=1;o":"")+")"})}return u;function u(){let l,u,h,p=[];if((!t||o(s,a,c[c.length-1]||null))&&(p=function(e){if(Array.isArray(e))return e;if("number"===typeof e)return[true,e];return[e]}(n(s,c)),false===p[0]))return p;if(s.children&&"skip"!==p[0])for(u=(r?s.children.length:-1)+i,h=c.concat(s);u>-1&&u1?n-1:0),o=1;o]+)>/g,(function(e,t){var n=i[t];return"$"+(Array.isArray(n)?n.join("$"):n)})))}if("function"==typeof o){var s=this;return e[Symbol.replace].call(this,n,(function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(r(e,s)),o.apply(this,e)}))}return e[Symbol.replace].call(this,n,o)},wl.apply(this,arguments)}function Bl(e,t){return Bl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Bl(e,t)}function Hl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var Gl=function(e){return function(t){return void 0===t&&(t={}),function(e,t){if(t&&!e.registered(t))throw new Error('The default language "'+t+'" is not registered with refractor.')}(e,t.defaultLanguage),function(e){!function(e,t,n,r){"function"===typeof t&&"function"!==typeof n&&(r=n,n=t,t=null),Nl(e,t,(function(e,t){const r=t[t.length-1];return n(e,r?r.children.indexOf(e):null,r)}),r)}(e,"element",n)};function n(n,r,o){var i,s;if(o&&"pre"===o.tagName&&"code"===n.tagName){var a=(null==n||null==(i=n.data)?void 0:i.meta)||(null==n||null==(s=n.properties)?void 0:s.metastring)||"";n.properties.className?"boolean"==typeof n.properties.className?n.properties.className=[]:Array.isArray(n.properties.className)||(n.properties.className=[n.properties.className]):n.properties.className=[];var c,l,u=function(e){for(var t,n=Ul(e.properties.className);!(t=n()).done;){var r=t.value;if("language-"===r.slice(0,9))return r.slice(9).toLowerCase()}return null}(n);if(!u&&t.defaultLanguage&&n.properties.className.push("language-"+(u=t.defaultLanguage)),n.properties.className.push("code-highlight"),u)try{var h,p;p=null!=(h=u)&&h.includes("diff-")?u.split("-")[1]:u,c=e.highlight(Sl(n),p),o.properties.className=(o.properties.className||[]).concat("language-"+p)}catch(_){if(!t.ignoreMissing||!/Unknown language/.test(_.message))throw _;c=n}else c=n;c.children=(l=1,function e(t){return t.reduce((function(t,n){if("text"===n.type){var r=n.value,o=(r.match(/\n/g)||"").length;if(0===o)n.position={start:{line:l,column:1},end:{line:l,column:1}},t.push(n);else for(var i,s=r.split("\n"),a=Ul(s.entries());!(i=a()).done;){var c=i.value,u=c[0],h=c[1];t.push({type:"text",value:u===s.length-1?h:h+"\n",position:{start:{line:l+u,column:1},end:{line:l+u,column:1}}})}return l+=o,t}if(Object.prototype.hasOwnProperty.call(n,"children")){var p=l;return n.children=e(n.children),t.push(n),n.position={start:{line:p,column:1},end:{line:l,column:1}},t}return t.push(n),t}),[])})(c.children),c.position=c.children.length>0?{start:{line:c.children[0].position.start.line,column:0},end:{line:c.children[c.children.length-1].position.end.line,column:0}}:{start:{line:0,column:0},end:{line:0,column:0}};for(var d,f=function(e){var t=/{([\d,-]+)}/,n=e.split(",").map((function(e){return e.trim()})).join();if(t.test(n)){var r=t.exec(n)[1],o=xl(r);return function(e){return o.includes(e+1)}}return function(){return!1}}(a),m=function(e){var t=wl(/showLineNumbers=(\d+)/i,{lines:1});if(t.test(e)){var n=t.exec(e);return Number(n.groups.lines)}return 1}(a),E=function(e){for(var t=new Array(e),n=0;n0&&0===s.length)return null}const a={};let c;for(c in t)Ll.call(t,c)&&(a[c]="children"===c?s:t[c]);return a}(e)}(c,(function(e){return e.position.start.line<=o+1&&e.position.end.line>=o+1}));i.children=s.children,!a.toLowerCase().includes("showLineNumbers".toLowerCase())&&!t.showLineNumbers||T.some((function(e){return a.toLowerCase().includes(e)}))||(i.properties.line=[(o+m).toString()],i.properties.className.push("line-number")),f(o)&&i.properties.className.push("highlight-line"),("diff"===u||null!=(e=u)&&e.includes("diff-"))&&"-"===Sl(i).substring(0,1)?i.properties.className.push("deleted"):("diff"===u||null!=(n=u)&&n.includes("diff-"))&&"+"===Sl(i).substring(0,1)&&i.properties.className.push("inserted")},A=Ul(E.entries());!(d=A()).done;)g();E.length>0&&""===Sl(E[E.length-1]).trim()&&E.pop(),n.children=E}}}},jl=(Gl(Pl.$),Gl(Ml.$)),Yl={},zl={};function ql(e,t){for(var n=t,r=0;r","+"],attributes:{unknownCaseSensitivityModifiers:"reject",operators:["=","~=","|="]},pseudoElements:{definitions:["before","after"]},pseudoClasses:{unknown:"reject",definitions:{NoArgument:["hover","focus","first-child"],String:["lang"]}}}),hu=cu(uu,{namespace:{wildcard:!0},combinators:["~"],attributes:{operators:["^=","$=","*="]},pseudoElements:{notation:"both"},pseudoClasses:{definitions:{NoArgument:["root","last-child","first-of-type","last-of-type","only-child","only-of-type","empty","target","enabled","disabled","checked","indeterminate"],Formula:["nth-child","nth-last-child","nth-of-type","nth-last-of-type"],Selector:["not"]}}}),pu=cu(hu,{combinators:["||"],attributes:{caseSensitivityModifiers:["i","I","s","S"]},pseudoClasses:{definitions:{NoArgument:["any-link","local-link","target-within","scope","current","past","future","focus-within","focus-visible","read-write","read-only","placeholder-shown","default","valid","invalid","in-range","out-of-range","required","optional","blank","user-invalid"],Formula:["nth-col","nth-last-col"],String:["dir"],FormulaOfSelector:["nth-child","nth-last-child"],Selector:["current","is","where","has"]}}}),du={css1:lu,css2:uu,css3:hu,"selectors-3":hu,"selectors-4":pu,latest:pu,progressive:cu(pu,{pseudoElements:{unknown:"accept"},pseudoClasses:{unknown:"accept"},attributes:{unknownCaseSensitivityModifiers:"accept"}})};function fu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||"-"===e||"_"===e||"\\"===e||e>="\xa0"}function mu(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"-"===e||"_"===e||e>="\xa0"}function Eu(e){return e>="a"&&e<="f"||e>="A"&&e<="F"||e>="0"&&e<="9"}var Tu={n:"\n",r:"\r",t:"\t",f:"\f","\\":"\\"},gu={" ":!0,"\t":!0,"\n":!0,"\r":!0,"\f":!0},Au={'"':!0,"'":!0},_u={0:!0,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0,7:!0,8:!0,9:!0};var Du="css-selector-parser parse error: ";var yu=function(){return yu=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0,C=s.pseudoClasses?[!0,s.pseudoClasses.definitions?$l(s.pseudoClasses.definitions):Kl,"accept"===s.pseudoClasses.unknown]:[!1,Kl,!1],k=C[0],b=C[1],N=C[2],S=s.pseudoElements?[!0,"singleColon"===s.pseudoElements.notation||"both"===s.pseudoElements.notation,!s.pseudoElements.notation||"doubleColon"===s.pseudoElements.notation||"both"===s.pseudoElements.notation,s.pseudoElements.definitions?$l(Array.isArray(s.pseudoElements.definitions)?{NoArgument:s.pseudoElements.definitions}:s.pseudoElements.definitions):Kl,"accept"===s.pseudoElements.unknown]:[!1,!1,!1,Kl,!1],I=S[0],O=S[1],v=S[2],R=S[3],F=S[4],L="",x=L.length,P=0,M="",w=function(e){return M===e},B=function(){return w("*")||fu(M)},H=function(e){P=e,M=L.charAt(P)},U=function(){P++,M=L.charAt(P)},G=function(){var e=M;return P++,M=L.charAt(P),e};function j(e){var t=Math.min(x-1,P),n=new Error("".concat(Du).concat(e," Pos: ").concat(t,"."));throw n.position=t,n.name="ParserError",n}function Y(e,t){if(!e)return j(t)}var z=function(){Y(P=x},Q=function(e){Y(P=2&&j("Identifiers cannot start with two hyphens with strict mode on."),_u[M]&&j("Identifiers cannot start with hyphens followed by digits.");P0)return(t.commaSeparated?te.P:pe.P)(e)}}(t.properties[r.property],r);if(!e.value)return void 0!==o;e.value.type;let i=e.value.value;if("i"===e.caseSensitivityModifier&&(i=i.toLowerCase(),o&&(o=o.toLowerCase())),void 0!==o)switch(e.operator){case"=":return i===o;case"$=":return i===o.slice(-i.length);case"*=":return o.includes(i);case"^=":return i===o.slice(0,i.length);case"|=":return i===o||i===o.slice(0,i.length)&&"-"===o.charAt(i.length);case"~=":return i===o||pe.Q(o).includes(i)}return!1}const Mu=[];function wu(e,t){return(t.properties.className||Mu).includes(e.name)}function Bu(e,t){return t.properties.id===e.name}function Hu(e,t){return e.name===t.tagName}function Uu(e,t){return function(n,r){let o=ju(n,"tag");const i=ju(null===r||void 0===r?"*":r,"range"),s=[];let a=-1;for(;++ae<=n;if(0===t)return e=>e===n;if(1===t)return n<0?Ku.trueFunc:e=>e>=n;const r=Math.abs(t),o=(n%r+r)%r;return t>1?e=>e>=n&&e%r===o:e=>e<=n&&e%r===o}(function(e){if("even"===(e=e.trim().toLowerCase()))return[2,0];if("odd"===e)return[2,1];let t=0,n=0,r=i(),o=s();if(t=Qu&&e.charCodeAt(t)<=Wu;)r=10*r+(e.charCodeAt(t)-Qu),t++;return t===n?null:r}function a(){for(;t0},is:th,lang:function(e,t,n,r,o){return e.argument,e.argument.type,""!==o.language&&void 0!==o.language&&Gu(o.language,(0,te.Q)(e.argument.value)).length>0},"last-child":function(e,t,n,r,o){return Ju(o,e),Boolean(o.elementCount&&o.elementIndex===o.elementCount-1)},"last-of-type":function(e,t,n,r,o){return Ju(o,e),"number"===typeof o.typeIndex&&"number"===typeof o.typeCount&&o.typeIndex===o.typeCount-1},not:function(e,t,n,r,o){return!th(e,t,n,r,o)},"nth-child":function(e,t,n,r,o){const i=eh(e);return Ju(o,e),"number"===typeof o.elementIndex&&i(o.elementIndex)},"nth-last-child":function(e,t,n,r,o){const i=eh(e);return Ju(o,e),Boolean("number"===typeof o.elementCount&&"number"===typeof o.elementIndex&&i(o.elementCount-o.elementIndex-1))},"nth-last-of-type":function(e,t,n,r,o){const i=eh(e);return Ju(o,e),"number"===typeof o.typeCount&&"number"===typeof o.typeIndex&&i(o.typeCount-1-o.typeIndex)},"nth-of-type":function(e,t,n,r,o){const i=eh(e);return Ju(o,e),"number"===typeof o.typeIndex&&i(o.typeIndex)},"only-child":function(e,t,n,r,o){return Ju(o,e),1===o.elementCount},"only-of-type":function(e,t,n,r,o){return Ju(o,e),1===o.typeCount},optional:function(e,t){return!rh(e,t)},"read-only":function(e,t,n,r,o){return!nh(e,t,n,r,o)},"read-write":nh,required:rh,root:function(e,t,n,r,o){return Boolean((!r||"root"===r.type)&&o.schema&&("html"===o.schema.space||"svg"===o.schema.space)&&("html"===t.tagName||"svg"===t.tagName))},scope:function(e,t,n,r,o){return o.scopeElements.includes(t)}},invalid:function(){},unknown:function(e){throw new Error("Unknown pseudo-selector `"+e.name+"`")}});function Ju(e,t){if(e.shallow)throw new Error("Cannot use `:"+t.name+"` without parent")}function Zu(e,t){return("button"===t.tagName||"input"===t.tagName||"select"===t.tagName||"textarea"===t.tagName||"optgroup"===t.tagName||"option"===t.tagName||"menuitem"===t.tagName||"fieldset"===t.tagName)&&zu(t,"disabled")}function eh(e){let t=e._cachedFn;if(!t){const n=e.argument;if("Formula"!==n.type)throw new Error("Expected `nth` formula, such as `even` or `2n+1` (`of` is not yet supported)");t=Xu(n.a+"n+"+n.b),e._cachedFn=t}return t}function th(e,t,n,r,o){e.argument,e.argument.type;const i={...o,found:!1,one:!0,results:[],rootQuery:e.argument,scopeElements:[t],shallow:!1};return ah(i,t),i.results[0]===t}function nh(e,t,n,r,o){return"input"===t.tagName||"textarea"===t.tagName?!zu(t,"readOnly")&&!zu(t,"disabled"):Boolean(o.editableOrEditingHost)}function rh(e,t){return("input"===t.tagName||"textarea"===t.tagName||"select"===t.tagName)&&zu(t,"required")}function oh(e,t){const n=e.children;let r=-1;for(;++r0&&t.length>0?[...e,...t]:e&&e.length>0?e:t&&t.length>0?t:sh}function uh(e,t){if("element"===t.type){const n=t.tagName.toUpperCase(),r=(e.types.get(n)||0)+1;e.count++,e.types.set(n,r)}}function hh(e,t,n,r,o,i){let s={adjacentSibling:void 0,descendant:void 0,directChild:void 0,generalSibling:void 0};const a=function(e,t){const n=e.schema,r=e.language,o=e.direction,i=e.editableOrEditingHost;let s;if("element"===t.type){const r=t.properties.xmlLang||t.properties.lang,o=t.properties.type||"text",i=xu(t);null!==r&&void 0!==r&&(e.language=String(r)),n&&"html"===n.space?("true"===t.properties.contentEditable&&(e.editableOrEditingHost=!0),"svg"===t.tagName&&(e.schema=le.YP),"rtl"===i?s=i:"ltr"===i||"auto"!==i&&"html"===t.tagName||"auto"!==i&&"input"===t.tagName&&"tel"===o?s="ltr":"auto"!==i&&"bdi"!==t.tagName||("textarea"===t.tagName?s=Lu(vu(t)):"input"!==t.tagName||"email"!==o&&"search"!==o&&"tel"!==o&&"text"!==o?or(t,(function(e){return"text"===e.type?(s=Lu(e.value),s?tr:void 0):e===t||"element"!==e.type||"bdi"!==e.tagName&&"script"!==e.tagName&&"style"!==e.tagName&&"textare"!==e.tagName&&!xu(e)?void 0:nr})):s=t.properties.value?Lu(String(t.properties.value)):"ltr"),s&&(e.direction=s)):e.editableOrEditingHost&&(e.editableOrEditingHost=!1)}return function(){e.schema=n,e.language=r,e.direction=o,e.editableOrEditingHost=i}}(e,n);if("element"===n.type){let a=e.rootQuery.rules;o&&o!==i&&(a=e.rootQuery.rules.filter((e=>void 0===e.combinator||">"===e.combinator&&o===i))),s=function(e,t,n,r,o){const i={adjacentSibling:void 0,descendant:void 0,directChild:void 0,generalSibling:void 0};let s=-1;for(;++s"===t.combinator?"directChild":"descendant",t):(e.found=!0,e.results.includes(n)||e.results.push(n))}void 0===a.combinator?ch(i,"descendant",a):"~"===a.combinator&&ch(i,"generalSibling",a)}return i}(e,lh(t,a),n,r,o)}return!("children"in n)||e.shallow||e.one&&e.found||function(e,t,n,r){const o=lh(t.descendant,t.directChild);let i,s=-1;const a={count:0,types:new Map},c={count:0,types:new Map};for(;++s1&&void 0!==arguments[1]?arguments[1]:"";return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((t=>{"text"===t.type?e+=t.value:"element"===t.type&&t.children&&Array.isArray(t.children)&&(e+=dh(t.children))})),e},fh=e=>{const{selector:t,rewrite:n}=e||{};return e=>{if(n&&"function"===typeof n)if(t&&"string"===typeof t){const r=function(e,t,n){const r=ph(e,t,n);return ah(r,t||void 0),r.results}(t,e);r&&r.length>0&&or(e,r,((e,t,r)=>{n(e,t,r)}))}else or(e,((e,t,r)=>{n(e,t,r)}))}},mh=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,r=arguments.length>1?arguments[1]:void 0;for(;r/,"$2")||""))return;if(n){if(mh(e,r,"pre",n))return;return t.value=(t.value||"").replace(/^(\n|\s)+/,""),t}return t.value=(t.value||"").replace(/^(\n|\s)+/,""),t}}},Eh=e=>{let{value:t=""}=e;const n=function(){return((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").match(/([^?=&]+)(=([^&]*))/g)||[]).reduce(((e,t)=>(e[t.slice(0,t.indexOf("="))]=t.slice(t.indexOf("=")+1),e)),{})}(t.replace(/^/,"$1").replace(/^rehype:/,""));return Object.keys(n).forEach((e=>{"true"===n[e]&&(n[e]=!0),"false"===n[e]&&(n[e]=!1),"string"!==typeof n[e]||/^0/.test(n[e])||isNaN(+n[e])||(n[e]=+n[e])})),n},Th=(e,t,n)=>"string"===n?{...e,"data-config":JSON.stringify({...t,rehyp:!0})}:"attr"===n?{...e,...t}:{...e,"data-config":{...t,rehyp:!0}},gh=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{properties:t="data",codeBlockParames:n=!0}=e;return e=>{or(e,"element",((e,r,o)=>{if(n&&"pre"===e.tagName&&e&&Array.isArray(e.children)&&o&&Array.isArray(o.children)&&o.children.length>1){const n=e.children[0];if(n&&"code"===n.tagName&&"number"===typeof r){const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;for(;t>-1;){if(t--,!e[t])return;if(e[t]&&e[t].value&&""!==e[t].value.replace(/(\n|\s)/g,"")||"text"!==e[t].type){if(!/^rehype:/.test(e[t].value)||"comment"!==e[t].type)return;return e[t]}}}(o.children,r);if(i){const r=Eh(i);Object.keys(r).length>0&&(e.properties={...e.properties,"data-type":"rehyp"},n.properties=Th(n.properties,r,t))}}}if(/^(em|strong|b|a|i|p|pre|kbd|blockquote|h(1|2|3|4|5|6)|code|table|img|del|ul|ol)$/.test(e.tagName)&&o&&Array.isArray(o.children)&&"number"===typeof r){const i=mh(o.children,r,"",n);if(i){const n=Eh(i);Object.keys(n).length>0&&(e.properties=Th(e.properties,n,t))}}}))}};var Ah=function(e){return void 0===e&&(e={}),e=>{or(e,(e=>{"element"===e.type&&"code"===e.tagName&&e.data&&e.data.meta&&(e.properties=s({},e.properties,{"data-meta":String(e.data.meta)}))}))}},_h=function(e){return void 0===e&&(e={}),e=>{or(e,(e=>{"element"===e.type&&"code"===e.tagName&&e.properties&&e.properties.dataMeta&&(e.data||(e.data={}),e.data.meta=e.properties.dataMeta,delete e.properties.dataMeta)}))}};const Dh=/[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g,yh=Object.hasOwnProperty;function Ch(e){const t="element"===e.type?e.tagName.toLowerCase():"",n=2===t.length&&104===t.charCodeAt(0)?t.charCodeAt(1):0;return n>48&&n<55?n-48:void 0}const kh={},bh=new class{constructor(){this.occurrences,this.reset()}slug(e,t){const n=this;let r=function(e,t){if("string"!==typeof e)return"";t||(e=e.toLowerCase());return e.replace(Dh,"").replace(/ /g,"-")}(e,!0===t);const o=r;for(;yh.call(n.occurrences,r);)n.occurrences[o]++,r=o+"-"+n.occurrences[o];return n.occurrences[r]=0,r}reset(){this.occurrences=Object.create(null)}};const Nh=function(e){if(null===e||void 0===e)return Ih;if("string"===typeof e)return function(e){return Sh(t);function t(t){return t.tagName===e}}(e);if("object"===typeof e)return function(e){const t=[];let n=-1;for(;++n0&&void 0!==arguments[0]?arguments[0]:{};const{openDelimiter:t="rehype:ignore:start",closeDelimiter:n="rehype:ignore:end"}=e;return e=>{or(e,((e,r,o)=>{if("element"===e.type||"root"===e.type){let r=!1;e.children=e.children.filter((e=>{if("raw"===e.type||"comment"===e.type){let o=(e.value||"").trim();if(o=o.replace(/^/,"$1"),o===t)return r=!0,!1;if(o===n)return r=!1,!1}return!r}))}}))}};var Bh={type:"element",tagName:"svg",properties:{className:"octicon octicon-link",viewBox:"0 0 16 16",version:"1.1",width:"16",height:"16",ariaHidden:"true"},children:[{type:"element",tagName:"path",children:[],properties:{fillRule:"evenodd",d:"M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"}}]};var Hh=[function(e){const t=(e||kh).prefix||"";return function(e){bh.reset(),or(e,"element",(function(e){Ch(e)&&!e.properties.id&&(e.properties.id=t+bh.slug(vu(e)))}))}},function(e){const t=e||Rh;let n=t.properties;const r=t.headingProperties,o=t.behavior||"prepend",i=t.content,s=t.group,a=Nh(t.test);let c;return"after"===o||"before"===o?c=function(e,t,r){if("number"!==typeof t||!r)return;const a=xh(i||vh,e),c=Lh(e,Mh(n,e),a);let l="before"===o?[c,e]:[e,c];if(s){const t=Ph(s,e);t&&!Array.isArray(t)&&"element"===t.type&&(t.children=l,l=[t])}return r.children.splice(t,1,...l),[nr,t+l.length]}:"wrap"===o?c=function(e){let t=e.children,r=[];"function"===typeof i?(t=[],r=i(e)):i&&(r=Fh(i));return e.children=[Lh(e,Mh(n,e),Array.isArray(r)?[...t,...r]:[...t,r])],[nr]}:(c=function(e){const t=xh(i||vh,e);return e.children["prepend"===o?"unshift":"push"](Lh(e,Mh(n,e),t)),[nr]},n||(n={ariaHidden:"true",tabIndex:-1})),function(e){or(e,"element",(function(e,t,n){if(Ch(e)&&e.properties.id&&a(e,t,n))return Object.assign(e.properties,Mh(r,e)),c(e,t,n)}))}},wh];const Uh=o.forwardRef(((e,t)=>{var n,r,o,i=[Ah,El,_h,[jl,{ignoreMissing:!0}],...Hh,[fh,{rewrite:(r=null!=(n=e.disableCopy)&&n,o=e.rehypeRewrite,(e,t,n)=>{if("element"===e.type&&n&&"root"===n.type&&/h(1|2|3|4|5|6)/.test(e.tagName)){var i=e.children&&e.children[0];i&&i.properties&&"true"===i.properties.ariaHidden&&(i.properties=s({class:"anchor"},i.properties),i.children=[Bh])}if("element"===e.type&&"pre"===e.tagName&&!r){var a=dh(e.children);e.children.push((void 0===(c=a)&&(c=""),{type:"element",tagName:"div",properties:{class:"copied","data-code":c},children:[{type:"element",tagName:"svg",properties:{className:"octicon-copy",ariaHidden:"true",viewBox:"0 0 16 16",fill:"currentColor",height:12,width:12},children:[{type:"element",tagName:"path",properties:{fillRule:"evenodd",d:"M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"},children:[]},{type:"element",tagName:"path",properties:{fillRule:"evenodd",d:"M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"},children:[]}]},{type:"element",tagName:"svg",properties:{className:"octicon-check",ariaHidden:"true",viewBox:"0 0 16 16",fill:"currentColor",height:12,width:12},children:[{type:"element",tagName:"path",properties:{fillRule:"evenodd",d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"},children:[]}]}]}))}var c;o&&o(e,null===t?void 0:t,null===n?void 0:n)})}],[gh,{properties:"attr"}],...e.rehypePlugins||[]];return(0,u.jsx)(yl,s({},e,{rehypePlugins:i,ref:t}))}));var Gh=["prefixCls","className","style","keyCode","onMouseDown","onMouseUp"],jh=[{keycode:27,name:["esc"]},{keycode:112,name:["F1"]},{keycode:113,name:["F2"]},{keycode:114,name:["F3"]},{keycode:115,name:["F4"]},{keycode:116,name:["F5"]},{keycode:117,name:["F6"]},{keycode:118,name:["F7"]},{keycode:119,name:["F8"]},{keycode:120,name:["F9"]},{keycode:121,name:["F10"]},{keycode:122,name:["F11"]},{keycode:123,name:["F12"]},{keycode:-1,name:["\u3007"]},{keycode:192,name:["~","`"]},{keycode:49,name:["!","1"]},{keycode:50,name:["@","2"]},{keycode:51,name:["#","3"]},{keycode:52,name:["$","4"]},{keycode:53,name:["%","5"]},{keycode:54,name:["^","6"]},{keycode:55,name:["&","7"]},{keycode:56,name:["*","8"]},{keycode:57,name:["(","9"]},{keycode:48,name:[")","0"]},{keycode:189,name:["\uff3f","-"]},{keycode:187,name:["\uff0b",": "]},{keycode:8,name:["delete"]},{keycode:9,name:["tab"]},{keycode:81,name:["Q"]},{keycode:87,name:["W"]},{keycode:69,name:["E"]},{keycode:82,name:["R"]},{keycode:84,name:["T"]},{keycode:89,name:["Y"]},{keycode:85,name:["U"]},{keycode:73,name:["I"]},{keycode:79,name:["O"]},{keycode:80,name:["P"]},{keycode:219,name:["{","["]},{keycode:221,name:["}","]"]},{keycode:220,name:["|","\\"]},{keycode:20,name:["","CapsLock"]},{keycode:65,name:["A"]},{keycode:83,name:["S"]},{keycode:68,name:["D"]},{keycode:70,name:["F"]},{keycode:71,name:["G"]},{keycode:72,name:["H"]},{keycode:74,name:["J"]},{keycode:75,name:["K"]},{keycode:76,name:["L"]},{keycode:186,name:[":",";"]},{keycode:222,name:['"',"'"]},{keycode:13,name:["enter","return"]},{keycode:16,name:["\u21e7"]},{keycode:90,name:["Z"]},{keycode:88,name:["X"]},{keycode:67,name:["C"]},{keycode:86,name:["V"]},{keycode:66,name:["B"]},{keycode:78,name:["N"]},{keycode:77,name:["M"]},{keycode:188,name:["<",","]},{keycode:190,name:[">","."]},{keycode:191,name:["?","/"]},{keycode:16,name:["\u21e7"]},{keycode:-1,name:["fn"]},{keycode:17,name:["control"]},{keycode:18,name:["alt","option"]},{keycode:91,name:["command"]},{keycode:32,name:[""]},{keycode:91,name:["command"]},{keycode:18,name:["alt","option"]},{keycode:37,name:["\u25c0"]},{keycode:38,name:["\u25b2"]},{keycode:39,name:["\u25b6"]},{keycode:40,name:["\u25bc"]}];function Yh(e){var{prefixCls:t="w-mac-keyboard",className:n,style:r,keyCode:o=[],onMouseDown:i,onMouseUp:c}=e,l=a(e,Gh);return(0,u.jsx)("div",{className:(t||"")+" "+(n||""),style:r,children:(0,u.jsx)("ul",{children:jh.map(((e,t)=>{var n=e.name.map(((e,t)=>(0,u.jsx)("span",{children:e},""+t)));return(0,u.jsx)("li",s({onMouseDown:t=>i&&i(t,e),onMouseUp:t=>c&&c(t,e),className:o.indexOf(e.keycode)>-1?"pressed":"","data-key":e.keycode},l,{children:n}),t)}))})})}n(523);const zh={footer:"Footer_footer__6AZaJ"};function qh(e){let{name:t,href:n,year:r,children:o}=e;return(0,u.jsxs)("div",{className:zh.footer,children:[o,(0,u.jsxs)("div",{children:["Licensed under MIT. (Yes it\xb4s free and",(0,u.jsx)("a",{href:"https://github.com/jaywcjlove/hotkeys",children:" open-sourced"}),")"]}),(0,u.jsxs)("div",{children:["\xa9",(0,u.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:n,children:t}),r]})]})}const Qh="index_tools__z-HKb",Wh="index_version__-ytTx",Kh="index_keyCodeInfo__cHMZ+",Vh="index_header__jwPmf",Xh="index_title__X9GPx",$h="index_info__QmMpI",Jh="index_github__CJgBc",Zh="# Hotkeys\n\n\x3c!--dividing--\x3e\n\n[![Buy me a coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-048754?logo=buymeacoffee)](https://jaywcjlove.github.io/#/sponsor)\n[![](https://img.shields.io/npm/dm/hotkeys-js?logo=npm)](https://www.npmjs.com/package/hotkeys-js)\n[![](https://img.shields.io/github/stars/jaywcjlove/hotkeys-js.svg)](https://github.com/jaywcjlove/hotkeys/stargazers)\n![no dependencies](http://jaywcjlove.github.io/sb/status/no-dependencies.svg)\n[![GitHub Actions CI](https://github.com/jaywcjlove/hotkeys-js/actions/workflows/ci.yml/badge.svg)](https://github.com/jaywcjlove/hotkeys-js/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/jaywcjlove/hotkeys/badge.svg?branch=master)](https://coveralls.io/github/jaywcjlove/hotkeys?branch=master)\n[![jaywcjlove/hotkeys-js](https://jaywcjlove.github.io/sb/lang/chinese.svg)](https://github.com/jaywcjlove/hotkeys-js/blob/master/README-zh.md)\n[![jaywcjlove/hotkeys-js](https://jaywcjlove.github.io/sb/ico/gitee.svg)](https://gitee.com/jaywcjlove/hotkeys)\n\nHotKeys.js is an input capture library with some very special features, it is easy to pick up and use, has a reasonable footprint ([~6kB](https://bundlephobia.com/result?p=hotkeys-js)) (gzipped: **`2.8kB`**), and has no dependencies. It should not interfere with any JavaScript libraries or frameworks. Official document [demo preview](https://jaywcjlove.github.io/hotkeys-js). [More examples](https://github.com/jaywcjlove/hotkeys-js/issues?q=label%3ADemo+).\n\n```bash\n\u256d\u2508\u2508\u256e \u256d\u2508\u2508\u256e \u256d\u2508\u2508\u256e\n\u2506 \u251c\u2508\u2508..\u2508\u2508\u2508\u2508\u2508.\u2506 \u2514\u2508\u256e\u2506 \u251c\u2508\u2508..\u2508\u2508\u2508\u2508\u2508..\u2508\u2508.\u2508\u2508..\u2508\u2508\u2508\u2508\u2508.\n\u2506 \u2506\u2506 \u25a1 \u2506\u2506 \u2508\u2524\u2506 < \u2506 -__\u2518\u2506 \u2506 \u2506\u2506__ \u2508\u2508\u2524\n\u2570\u2508\u2508\u2534\u2508\u2508\u256f\u2570\u2508\u2508\u2508\u2508\u2508\u256f\u2570\u2508\u2508\u2508\u2508\u256f\u2570\u2508\u2508\u2534\u2508\u2508\u256f\u2570\u2508\u2508\u2508\u2508\u2508\u256f\u2570\u2508\u2508\u2508 \u2506\u2570\u2508\u2508\u2508\u2508\u2508\u256f\n \u2570\u2508\u2508\u2508\u2508\u2508\u256f\n```\n\n## Usage\n\nYou will need `Node.js` installed on your system.\n\n```bash\nnpm install hotkeys-js --save\n```\n\n```js\nimport hotkeys from 'hotkeys-js';\n\nhotkeys('f5', function(event, handler){\n // Prevent the default refresh event under WINDOWS system\n event.preventDefault()\n alert('you pressed F5!')\n});\n```\n\nOr manually download and link **hotkeys.js** in your HTML, It can also be downloaded via [UNPKG](https://unpkg.com/hotkeys-js/dist/):\n\nCDN: [UNPKG](https://unpkg.com/hotkeys-js/dist/) | [jsDelivr](https://cdn.jsdelivr.net/npm/hotkeys-js@3.7.3/) | [Githack](https://raw.githack.com/jaywcjlove/hotkeys/master/dist/hotkeys.min.js) | [Statically](https://cdn.statically.io/gh/jaywcjlove/hotkeys/master/dist/hotkeys.min.js) | [bundle.run](https://bundle.run/hotkeys-js@3.7.3)\n\n```html\n\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationRawTagOpen(code) {\n if (code === 47) {\n effects.consume(code)\n buffer = ''\n return continuationRawEndTag\n }\n return continuation(code)\n }\n\n /**\n * In raw continuation, after ` | \n * ^^^^^^\n * ```\n *\n * @type {State}\n */\n function continuationRawEndTag(code) {\n if (code === 62) {\n const name = buffer.toLowerCase()\n if (htmlRawNames.includes(name)) {\n effects.consume(code)\n return continuationClose\n }\n return continuation(code)\n }\n if (asciiAlpha(code) && buffer.length < 8) {\n effects.consume(code)\n // @ts-expect-error: not null.\n buffer += String.fromCharCode(code)\n return continuationRawEndTag\n }\n return continuation(code)\n }\n\n /**\n * In cdata continuation, after `]`, expecting `]>`.\n *\n * ```markdown\n * > | &<]]>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationCdataInside(code) {\n if (code === 93) {\n effects.consume(code)\n return continuationDeclarationInside\n }\n return continuation(code)\n }\n\n /**\n * In declaration or instruction continuation, at `>`.\n *\n * ```markdown\n * > | \n * ^\n * > | \n * ^\n * > | \n * ^\n * > | \n * ^\n * > | &<]]>\n * ^\n * ```\n *\n * @type {State}\n */\n function continuationDeclarationInside(code) {\n if (code === 62) {\n effects.consume(code)\n return continuationClose\n }\n\n // More dashes.\n if (code === 45 && marker === 2) {\n effects.consume(code)\n return continuationDeclarationInside\n }\n return continuation(code)\n }\n\n /**\n * In closed continuation: everything we get until the eol/eof is part of it.\n *\n * ```markdown\n * > | \n * ^\n * ```\n *\n * @type {State}\n */\n function continuationClose(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit('htmlFlowData')\n return continuationAfter(code)\n }\n effects.consume(code)\n return continuationClose\n }\n\n /**\n * Done.\n *\n * ```markdown\n * > | \n * ^\n * ```\n *\n * @type {State}\n */\n function continuationAfter(code) {\n effects.exit('htmlFlow')\n // // Feel free to interrupt.\n // tokenizer.interrupt = false\n // // No longer concrete.\n // tokenizer.concrete = false\n return ok(code)\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeNonLazyContinuationStart(effects, ok, nok) {\n const self = this\n return start\n\n /**\n * At eol, before continuation.\n *\n * ```markdown\n * > | * ```js\n * ^\n * | b\n * ```\n *\n * @type {State}\n */\n function start(code) {\n if (markdownLineEnding(code)) {\n effects.enter('lineEnding')\n effects.consume(code)\n effects.exit('lineEnding')\n return after\n }\n return nok(code)\n }\n\n /**\n * A continuation.\n *\n * ```markdown\n * | * ```js\n * > | b\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n return self.parser.lazy[self.now().line] ? nok(code) : ok(code)\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeBlankLineBefore(effects, ok, nok) {\n return start\n\n /**\n * Before eol, expecting blank line.\n *\n * ```markdown\n * > |
\n * ^\n * |\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('lineEnding')\n effects.consume(code)\n effects.exit('lineEnding')\n return effects.attempt(blankLine, ok, nok)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Code} Code\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {factorySpace} from 'micromark-factory-space'\nimport {markdownLineEnding, markdownSpace} from 'micromark-util-character'\n/** @type {Construct} */\nconst nonLazyContinuation = {\n tokenize: tokenizeNonLazyContinuation,\n partial: true\n}\n\n/** @type {Construct} */\nexport const codeFenced = {\n name: 'codeFenced',\n tokenize: tokenizeCodeFenced,\n concrete: true\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeCodeFenced(effects, ok, nok) {\n const self = this\n /** @type {Construct} */\n const closeStart = {\n tokenize: tokenizeCloseStart,\n partial: true\n }\n let initialPrefix = 0\n let sizeOpen = 0\n /** @type {NonNullable} */\n let marker\n return start\n\n /**\n * Start of code.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // To do: parse whitespace like `markdown-rs`.\n return beforeSequenceOpen(code)\n }\n\n /**\n * In opening fence, after prefix, at sequence.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function beforeSequenceOpen(code) {\n const tail = self.events[self.events.length - 1]\n initialPrefix =\n tail && tail[1].type === 'linePrefix'\n ? tail[2].sliceSerialize(tail[1], true).length\n : 0\n marker = code\n effects.enter('codeFenced')\n effects.enter('codeFencedFence')\n effects.enter('codeFencedFenceSequence')\n return sequenceOpen(code)\n }\n\n /**\n * In opening fence sequence.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function sequenceOpen(code) {\n if (code === marker) {\n sizeOpen++\n effects.consume(code)\n return sequenceOpen\n }\n if (sizeOpen < 3) {\n return nok(code)\n }\n effects.exit('codeFencedFenceSequence')\n return markdownSpace(code)\n ? factorySpace(effects, infoBefore, 'whitespace')(code)\n : infoBefore(code)\n }\n\n /**\n * In opening fence, after the sequence (and optional whitespace), before info.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function infoBefore(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit('codeFencedFence')\n return self.interrupt\n ? ok(code)\n : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code)\n }\n effects.enter('codeFencedFenceInfo')\n effects.enter('chunkString', {\n contentType: 'string'\n })\n return info(code)\n }\n\n /**\n * In info.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function info(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit('chunkString')\n effects.exit('codeFencedFenceInfo')\n return infoBefore(code)\n }\n if (markdownSpace(code)) {\n effects.exit('chunkString')\n effects.exit('codeFencedFenceInfo')\n return factorySpace(effects, metaBefore, 'whitespace')(code)\n }\n if (code === 96 && code === marker) {\n return nok(code)\n }\n effects.consume(code)\n return info\n }\n\n /**\n * In opening fence, after info and whitespace, before meta.\n *\n * ```markdown\n * > | ~~~js eval\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function metaBefore(code) {\n if (code === null || markdownLineEnding(code)) {\n return infoBefore(code)\n }\n effects.enter('codeFencedFenceMeta')\n effects.enter('chunkString', {\n contentType: 'string'\n })\n return meta(code)\n }\n\n /**\n * In meta.\n *\n * ```markdown\n * > | ~~~js eval\n * ^\n * | alert(1)\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function meta(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit('chunkString')\n effects.exit('codeFencedFenceMeta')\n return infoBefore(code)\n }\n if (code === 96 && code === marker) {\n return nok(code)\n }\n effects.consume(code)\n return meta\n }\n\n /**\n * At eol/eof in code, before a non-lazy closing fence or content.\n *\n * ```markdown\n * > | ~~~js\n * ^\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function atNonLazyBreak(code) {\n return effects.attempt(closeStart, after, contentBefore)(code)\n }\n\n /**\n * Before code content, not a closing fence, at eol.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function contentBefore(code) {\n effects.enter('lineEnding')\n effects.consume(code)\n effects.exit('lineEnding')\n return contentStart\n }\n\n /**\n * Before code content, not a closing fence.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function contentStart(code) {\n return initialPrefix > 0 && markdownSpace(code)\n ? factorySpace(\n effects,\n beforeContentChunk,\n 'linePrefix',\n initialPrefix + 1\n )(code)\n : beforeContentChunk(code)\n }\n\n /**\n * Before code content, after optional prefix.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function beforeContentChunk(code) {\n if (code === null || markdownLineEnding(code)) {\n return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code)\n }\n effects.enter('codeFlowValue')\n return contentChunk(code)\n }\n\n /**\n * In code content.\n *\n * ```markdown\n * | ~~~js\n * > | alert(1)\n * ^^^^^^^^\n * | ~~~\n * ```\n *\n * @type {State}\n */\n function contentChunk(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit('codeFlowValue')\n return beforeContentChunk(code)\n }\n effects.consume(code)\n return contentChunk\n }\n\n /**\n * After code.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n effects.exit('codeFenced')\n return ok(code)\n }\n\n /**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\n function tokenizeCloseStart(effects, ok, nok) {\n let size = 0\n return startBefore\n\n /**\n *\n *\n * @type {State}\n */\n function startBefore(code) {\n effects.enter('lineEnding')\n effects.consume(code)\n effects.exit('lineEnding')\n return start\n }\n\n /**\n * Before closing fence, at optional whitespace.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // Always populated by defaults.\n\n // To do: `enter` here or in next state?\n effects.enter('codeFencedFence')\n return markdownSpace(code)\n ? factorySpace(\n effects,\n beforeSequenceClose,\n 'linePrefix',\n self.parser.constructs.disable.null.includes('codeIndented')\n ? undefined\n : 4\n )(code)\n : beforeSequenceClose(code)\n }\n\n /**\n * In closing fence, after optional whitespace, at sequence.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function beforeSequenceClose(code) {\n if (code === marker) {\n effects.enter('codeFencedFenceSequence')\n return sequenceClose(code)\n }\n return nok(code)\n }\n\n /**\n * In closing fence sequence.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceClose(code) {\n if (code === marker) {\n size++\n effects.consume(code)\n return sequenceClose\n }\n if (size >= sizeOpen) {\n effects.exit('codeFencedFenceSequence')\n return markdownSpace(code)\n ? factorySpace(effects, sequenceCloseAfter, 'whitespace')(code)\n : sequenceCloseAfter(code)\n }\n return nok(code)\n }\n\n /**\n * After closing fence sequence, after optional whitespace.\n *\n * ```markdown\n * | ~~~js\n * | alert(1)\n * > | ~~~\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceCloseAfter(code) {\n if (code === null || markdownLineEnding(code)) {\n effects.exit('codeFencedFence')\n return ok(code)\n }\n return nok(code)\n }\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeNonLazyContinuation(effects, ok, nok) {\n const self = this\n return start\n\n /**\n *\n *\n * @type {State}\n */\n function start(code) {\n if (code === null) {\n return nok(code)\n }\n effects.enter('lineEnding')\n effects.consume(code)\n effects.exit('lineEnding')\n return lineStart\n }\n\n /**\n *\n *\n * @type {State}\n */\n function lineStart(code) {\n return self.parser.lazy[self.now().line] ? nok(code) : ok(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Code} Code\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {decodeNamedCharacterReference} from 'decode-named-character-reference'\nimport {\n asciiAlphanumeric,\n asciiDigit,\n asciiHexDigit\n} from 'micromark-util-character'\n/** @type {Construct} */\nexport const characterReference = {\n name: 'characterReference',\n tokenize: tokenizeCharacterReference\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeCharacterReference(effects, ok, nok) {\n const self = this\n let size = 0\n /** @type {number} */\n let max\n /** @type {(code: Code) => boolean} */\n let test\n return start\n\n /**\n * Start of character reference.\n *\n * ```markdown\n * > | a&b\n * ^\n * > | a{b\n * ^\n * > | a b\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('characterReference')\n effects.enter('characterReferenceMarker')\n effects.consume(code)\n effects.exit('characterReferenceMarker')\n return open\n }\n\n /**\n * After `&`, at `#` for numeric references or alphanumeric for named\n * references.\n *\n * ```markdown\n * > | a&b\n * ^\n * > | a{b\n * ^\n * > | a b\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 35) {\n effects.enter('characterReferenceMarkerNumeric')\n effects.consume(code)\n effects.exit('characterReferenceMarkerNumeric')\n return numeric\n }\n effects.enter('characterReferenceValue')\n max = 31\n test = asciiAlphanumeric\n return value(code)\n }\n\n /**\n * After `#`, at `x` for hexadecimals or digit for decimals.\n *\n * ```markdown\n * > | a{b\n * ^\n * > | a b\n * ^\n * ```\n *\n * @type {State}\n */\n function numeric(code) {\n if (code === 88 || code === 120) {\n effects.enter('characterReferenceMarkerHexadecimal')\n effects.consume(code)\n effects.exit('characterReferenceMarkerHexadecimal')\n effects.enter('characterReferenceValue')\n max = 6\n test = asciiHexDigit\n return value\n }\n effects.enter('characterReferenceValue')\n max = 7\n test = asciiDigit\n return value(code)\n }\n\n /**\n * After markers (`&#x`, `&#`, or `&`), in value, before `;`.\n *\n * The character reference kind defines what and how many characters are\n * allowed.\n *\n * ```markdown\n * > | a&b\n * ^^^\n * > | a{b\n * ^^^\n * > | a b\n * ^\n * ```\n *\n * @type {State}\n */\n function value(code) {\n if (code === 59 && size) {\n const token = effects.exit('characterReferenceValue')\n if (\n test === asciiAlphanumeric &&\n !decodeNamedCharacterReference(self.sliceSerialize(token))\n ) {\n return nok(code)\n }\n\n // To do: `markdown-rs` uses a different name:\n // `CharacterReferenceMarkerSemi`.\n effects.enter('characterReferenceMarker')\n effects.consume(code)\n effects.exit('characterReferenceMarker')\n effects.exit('characterReference')\n return ok\n }\n if (test(code) && size++ < max) {\n effects.consume(code)\n return value\n }\n return nok(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {asciiPunctuation} from 'micromark-util-character'\n/** @type {Construct} */\nexport const characterEscape = {\n name: 'characterEscape',\n tokenize: tokenizeCharacterEscape\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeCharacterEscape(effects, ok, nok) {\n return start\n\n /**\n * Start of character escape.\n *\n * ```markdown\n * > | a\\*b\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('characterEscape')\n effects.enter('escapeMarker')\n effects.consume(code)\n effects.exit('escapeMarker')\n return inside\n }\n\n /**\n * After `\\`, at punctuation.\n *\n * ```markdown\n * > | a\\*b\n * ^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n // ASCII punctuation.\n if (asciiPunctuation(code)) {\n effects.enter('characterEscapeValue')\n effects.consume(code)\n effects.exit('characterEscapeValue')\n effects.exit('characterEscape')\n return ok\n }\n return nok(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {factorySpace} from 'micromark-factory-space'\nimport {markdownLineEnding} from 'micromark-util-character'\n/** @type {Construct} */\nexport const lineEnding = {\n name: 'lineEnding',\n tokenize: tokenizeLineEnding\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeLineEnding(effects, ok) {\n return start\n\n /** @type {State} */\n function start(code) {\n effects.enter('lineEnding')\n effects.consume(code)\n effects.exit('lineEnding')\n return factorySpace(effects, ok, 'linePrefix')\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').Event} Event\n * @typedef {import('micromark-util-types').Resolver} Resolver\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').Token} Token\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {factoryDestination} from 'micromark-factory-destination'\nimport {factoryLabel} from 'micromark-factory-label'\nimport {factoryTitle} from 'micromark-factory-title'\nimport {factoryWhitespace} from 'micromark-factory-whitespace'\nimport {markdownLineEndingOrSpace} from 'micromark-util-character'\nimport {push, splice} from 'micromark-util-chunked'\nimport {normalizeIdentifier} from 'micromark-util-normalize-identifier'\nimport {resolveAll} from 'micromark-util-resolve-all'\n/** @type {Construct} */\nexport const labelEnd = {\n name: 'labelEnd',\n tokenize: tokenizeLabelEnd,\n resolveTo: resolveToLabelEnd,\n resolveAll: resolveAllLabelEnd\n}\n\n/** @type {Construct} */\nconst resourceConstruct = {\n tokenize: tokenizeResource\n}\n/** @type {Construct} */\nconst referenceFullConstruct = {\n tokenize: tokenizeReferenceFull\n}\n/** @type {Construct} */\nconst referenceCollapsedConstruct = {\n tokenize: tokenizeReferenceCollapsed\n}\n\n/** @type {Resolver} */\nfunction resolveAllLabelEnd(events) {\n let index = -1\n while (++index < events.length) {\n const token = events[index][1]\n if (\n token.type === 'labelImage' ||\n token.type === 'labelLink' ||\n token.type === 'labelEnd'\n ) {\n // Remove the marker.\n events.splice(index + 1, token.type === 'labelImage' ? 4 : 2)\n token.type = 'data'\n index++\n }\n }\n return events\n}\n\n/** @type {Resolver} */\nfunction resolveToLabelEnd(events, context) {\n let index = events.length\n let offset = 0\n /** @type {Token} */\n let token\n /** @type {number | undefined} */\n let open\n /** @type {number | undefined} */\n let close\n /** @type {Array} */\n let media\n\n // Find an opening.\n while (index--) {\n token = events[index][1]\n if (open) {\n // If we see another link, or inactive link label, we’ve been here before.\n if (\n token.type === 'link' ||\n (token.type === 'labelLink' && token._inactive)\n ) {\n break\n }\n\n // Mark other link openings as inactive, as we can’t have links in\n // links.\n if (events[index][0] === 'enter' && token.type === 'labelLink') {\n token._inactive = true\n }\n } else if (close) {\n if (\n events[index][0] === 'enter' &&\n (token.type === 'labelImage' || token.type === 'labelLink') &&\n !token._balanced\n ) {\n open = index\n if (token.type !== 'labelLink') {\n offset = 2\n break\n }\n }\n } else if (token.type === 'labelEnd') {\n close = index\n }\n }\n const group = {\n type: events[open][1].type === 'labelLink' ? 'link' : 'image',\n start: Object.assign({}, events[open][1].start),\n end: Object.assign({}, events[events.length - 1][1].end)\n }\n const label = {\n type: 'label',\n start: Object.assign({}, events[open][1].start),\n end: Object.assign({}, events[close][1].end)\n }\n const text = {\n type: 'labelText',\n start: Object.assign({}, events[open + offset + 2][1].end),\n end: Object.assign({}, events[close - 2][1].start)\n }\n media = [\n ['enter', group, context],\n ['enter', label, context]\n ]\n\n // Opening marker.\n media = push(media, events.slice(open + 1, open + offset + 3))\n\n // Text open.\n media = push(media, [['enter', text, context]])\n\n // Always populated by defaults.\n\n // Between.\n media = push(\n media,\n resolveAll(\n context.parser.constructs.insideSpan.null,\n events.slice(open + offset + 4, close - 3),\n context\n )\n )\n\n // Text close, marker close, label close.\n media = push(media, [\n ['exit', text, context],\n events[close - 2],\n events[close - 1],\n ['exit', label, context]\n ])\n\n // Reference, resource, or so.\n media = push(media, events.slice(close + 1))\n\n // Media close.\n media = push(media, [['exit', group, context]])\n splice(events, open, events.length, media)\n return events\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeLabelEnd(effects, ok, nok) {\n const self = this\n let index = self.events.length\n /** @type {Token} */\n let labelStart\n /** @type {boolean} */\n let defined\n\n // Find an opening.\n while (index--) {\n if (\n (self.events[index][1].type === 'labelImage' ||\n self.events[index][1].type === 'labelLink') &&\n !self.events[index][1]._balanced\n ) {\n labelStart = self.events[index][1]\n break\n }\n }\n return start\n\n /**\n * Start of label end.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * > | [a][b] c\n * ^\n * > | [a][] b\n * ^\n * > | [a] b\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // If there is not an okay opening.\n if (!labelStart) {\n return nok(code)\n }\n\n // If the corresponding label (link) start is marked as inactive,\n // it means we’d be wrapping a link, like this:\n //\n // ```markdown\n // > | a [b [c](d) e](f) g.\n // ^\n // ```\n //\n // We can’t have that, so it’s just balanced brackets.\n if (labelStart._inactive) {\n return labelEndNok(code)\n }\n defined = self.parser.defined.includes(\n normalizeIdentifier(\n self.sliceSerialize({\n start: labelStart.end,\n end: self.now()\n })\n )\n )\n effects.enter('labelEnd')\n effects.enter('labelMarker')\n effects.consume(code)\n effects.exit('labelMarker')\n effects.exit('labelEnd')\n return after\n }\n\n /**\n * After `]`.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * > | [a][b] c\n * ^\n * > | [a][] b\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n // Note: `markdown-rs` also parses GFM footnotes here, which for us is in\n // an extension.\n\n // Resource (`[asd](fgh)`)?\n if (code === 40) {\n return effects.attempt(\n resourceConstruct,\n labelEndOk,\n defined ? labelEndOk : labelEndNok\n )(code)\n }\n\n // Full (`[asd][fgh]`) or collapsed (`[asd][]`) reference?\n if (code === 91) {\n return effects.attempt(\n referenceFullConstruct,\n labelEndOk,\n defined ? referenceNotFull : labelEndNok\n )(code)\n }\n\n // Shortcut (`[asd]`) reference?\n return defined ? labelEndOk(code) : labelEndNok(code)\n }\n\n /**\n * After `]`, at `[`, but not at a full reference.\n *\n * > 👉 **Note**: we only get here if the label is defined.\n *\n * ```markdown\n * > | [a][] b\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceNotFull(code) {\n return effects.attempt(\n referenceCollapsedConstruct,\n labelEndOk,\n labelEndNok\n )(code)\n }\n\n /**\n * Done, we found something.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * > | [a][b] c\n * ^\n * > | [a][] b\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function labelEndOk(code) {\n // Note: `markdown-rs` does a bunch of stuff here.\n return ok(code)\n }\n\n /**\n * Done, it’s nothing.\n *\n * There was an okay opening, but we didn’t match anything.\n *\n * ```markdown\n * > | [a](b c\n * ^\n * > | [a][b c\n * ^\n * > | [a] b\n * ^\n * ```\n *\n * @type {State}\n */\n function labelEndNok(code) {\n labelStart._balanced = true\n return nok(code)\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeResource(effects, ok, nok) {\n return resourceStart\n\n /**\n * At a resource.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceStart(code) {\n effects.enter('resource')\n effects.enter('resourceMarker')\n effects.consume(code)\n effects.exit('resourceMarker')\n return resourceBefore\n }\n\n /**\n * In resource, after `(`, at optional whitespace.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceBefore(code) {\n return markdownLineEndingOrSpace(code)\n ? factoryWhitespace(effects, resourceOpen)(code)\n : resourceOpen(code)\n }\n\n /**\n * In resource, after optional whitespace, at `)` or a destination.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceOpen(code) {\n if (code === 41) {\n return resourceEnd(code)\n }\n return factoryDestination(\n effects,\n resourceDestinationAfter,\n resourceDestinationMissing,\n 'resourceDestination',\n 'resourceDestinationLiteral',\n 'resourceDestinationLiteralMarker',\n 'resourceDestinationRaw',\n 'resourceDestinationString',\n 32\n )(code)\n }\n\n /**\n * In resource, after destination, at optional whitespace.\n *\n * ```markdown\n * > | [a](b) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceDestinationAfter(code) {\n return markdownLineEndingOrSpace(code)\n ? factoryWhitespace(effects, resourceBetween)(code)\n : resourceEnd(code)\n }\n\n /**\n * At invalid destination.\n *\n * ```markdown\n * > | [a](<<) b\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceDestinationMissing(code) {\n return nok(code)\n }\n\n /**\n * In resource, after destination and whitespace, at `(` or title.\n *\n * ```markdown\n * > | [a](b ) c\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceBetween(code) {\n if (code === 34 || code === 39 || code === 40) {\n return factoryTitle(\n effects,\n resourceTitleAfter,\n nok,\n 'resourceTitle',\n 'resourceTitleMarker',\n 'resourceTitleString'\n )(code)\n }\n return resourceEnd(code)\n }\n\n /**\n * In resource, after title, at optional whitespace.\n *\n * ```markdown\n * > | [a](b \"c\") d\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceTitleAfter(code) {\n return markdownLineEndingOrSpace(code)\n ? factoryWhitespace(effects, resourceEnd)(code)\n : resourceEnd(code)\n }\n\n /**\n * In resource, at `)`.\n *\n * ```markdown\n * > | [a](b) d\n * ^\n * ```\n *\n * @type {State}\n */\n function resourceEnd(code) {\n if (code === 41) {\n effects.enter('resourceMarker')\n effects.consume(code)\n effects.exit('resourceMarker')\n effects.exit('resource')\n return ok\n }\n return nok(code)\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeReferenceFull(effects, ok, nok) {\n const self = this\n return referenceFull\n\n /**\n * In a reference (full), at the `[`.\n *\n * ```markdown\n * > | [a][b] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceFull(code) {\n return factoryLabel.call(\n self,\n effects,\n referenceFullAfter,\n referenceFullMissing,\n 'reference',\n 'referenceMarker',\n 'referenceString'\n )(code)\n }\n\n /**\n * In a reference (full), after `]`.\n *\n * ```markdown\n * > | [a][b] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceFullAfter(code) {\n return self.parser.defined.includes(\n normalizeIdentifier(\n self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1)\n )\n )\n ? ok(code)\n : nok(code)\n }\n\n /**\n * In reference (full) that was missing.\n *\n * ```markdown\n * > | [a][b d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceFullMissing(code) {\n return nok(code)\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeReferenceCollapsed(effects, ok, nok) {\n return referenceCollapsedStart\n\n /**\n * In reference (collapsed), at `[`.\n *\n * > 👉 **Note**: we only get here if the label is defined.\n *\n * ```markdown\n * > | [a][] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceCollapsedStart(code) {\n // We only attempt a collapsed label if there’s a `[`.\n\n effects.enter('reference')\n effects.enter('referenceMarker')\n effects.consume(code)\n effects.exit('referenceMarker')\n return referenceCollapsedOpen\n }\n\n /**\n * In reference (collapsed), at `]`.\n *\n * > 👉 **Note**: we only get here if the label is defined.\n *\n * ```markdown\n * > | [a][] d\n * ^\n * ```\n *\n * @type {State}\n */\n function referenceCollapsedOpen(code) {\n if (code === 93) {\n effects.enter('referenceMarker')\n effects.consume(code)\n effects.exit('referenceMarker')\n effects.exit('reference')\n return ok\n }\n return nok(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {labelEnd} from './label-end.js'\n\n/** @type {Construct} */\nexport const labelStartImage = {\n name: 'labelStartImage',\n tokenize: tokenizeLabelStartImage,\n resolveAll: labelEnd.resolveAll\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeLabelStartImage(effects, ok, nok) {\n const self = this\n return start\n\n /**\n * Start of label (image) start.\n *\n * ```markdown\n * > | a ![b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('labelImage')\n effects.enter('labelImageMarker')\n effects.consume(code)\n effects.exit('labelImageMarker')\n return open\n }\n\n /**\n * After `!`, at `[`.\n *\n * ```markdown\n * > | a ![b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 91) {\n effects.enter('labelMarker')\n effects.consume(code)\n effects.exit('labelMarker')\n effects.exit('labelImage')\n return after\n }\n return nok(code)\n }\n\n /**\n * After `![`.\n *\n * ```markdown\n * > | a ![b] c\n * ^\n * ```\n *\n * This is needed in because, when GFM footnotes are enabled, images never\n * form when started with a `^`.\n * Instead, links form:\n *\n * ```markdown\n * ![^a](b)\n *\n * ![^a][b]\n *\n * [b]: c\n * ```\n *\n * ```html\n *

!^a

\n *

!^a

\n * ```\n *\n * @type {State}\n */\n function after(code) {\n // To do: use a new field to do this, this is still needed for\n // `micromark-extension-gfm-footnote`, but the `label-start-link`\n // behavior isn’t.\n // Hidden footnotes hook.\n /* c8 ignore next 3 */\n return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs\n ? nok(code)\n : ok(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Code} Code\n */\n\nimport {\n markdownLineEndingOrSpace,\n unicodePunctuation,\n unicodeWhitespace\n} from 'micromark-util-character'\n/**\n * Classify whether a code represents whitespace, punctuation, or something\n * else.\n *\n * Used for attention (emphasis, strong), whose sequences can open or close\n * based on the class of surrounding characters.\n *\n * > 👉 **Note**: eof (`null`) is seen as whitespace.\n *\n * @param {Code} code\n * Code.\n * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}\n * Group.\n */\nexport function classifyCharacter(code) {\n if (\n code === null ||\n markdownLineEndingOrSpace(code) ||\n unicodeWhitespace(code)\n ) {\n return 1\n }\n if (unicodePunctuation(code)) {\n return 2\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Code} Code\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').Event} Event\n * @typedef {import('micromark-util-types').Point} Point\n * @typedef {import('micromark-util-types').Resolver} Resolver\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').Token} Token\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {push, splice} from 'micromark-util-chunked'\nimport {classifyCharacter} from 'micromark-util-classify-character'\nimport {resolveAll} from 'micromark-util-resolve-all'\n/** @type {Construct} */\nexport const attention = {\n name: 'attention',\n tokenize: tokenizeAttention,\n resolveAll: resolveAllAttention\n}\n\n/**\n * Take all events and resolve attention to emphasis or strong.\n *\n * @type {Resolver}\n */\n// eslint-disable-next-line complexity\nfunction resolveAllAttention(events, context) {\n let index = -1\n /** @type {number} */\n let open\n /** @type {Token} */\n let group\n /** @type {Token} */\n let text\n /** @type {Token} */\n let openingSequence\n /** @type {Token} */\n let closingSequence\n /** @type {number} */\n let use\n /** @type {Array} */\n let nextEvents\n /** @type {number} */\n let offset\n\n // Walk through all events.\n //\n // Note: performance of this is fine on an mb of normal markdown, but it’s\n // a bottleneck for malicious stuff.\n while (++index < events.length) {\n // Find a token that can close.\n if (\n events[index][0] === 'enter' &&\n events[index][1].type === 'attentionSequence' &&\n events[index][1]._close\n ) {\n open = index\n\n // Now walk back to find an opener.\n while (open--) {\n // Find a token that can open the closer.\n if (\n events[open][0] === 'exit' &&\n events[open][1].type === 'attentionSequence' &&\n events[open][1]._open &&\n // If the markers are the same:\n context.sliceSerialize(events[open][1]).charCodeAt(0) ===\n context.sliceSerialize(events[index][1]).charCodeAt(0)\n ) {\n // If the opening can close or the closing can open,\n // and the close size *is not* a multiple of three,\n // but the sum of the opening and closing size *is* multiple of three,\n // then don’t match.\n if (\n (events[open][1]._close || events[index][1]._open) &&\n (events[index][1].end.offset - events[index][1].start.offset) % 3 &&\n !(\n (events[open][1].end.offset -\n events[open][1].start.offset +\n events[index][1].end.offset -\n events[index][1].start.offset) %\n 3\n )\n ) {\n continue\n }\n\n // Number of markers to use from the sequence.\n use =\n events[open][1].end.offset - events[open][1].start.offset > 1 &&\n events[index][1].end.offset - events[index][1].start.offset > 1\n ? 2\n : 1\n const start = Object.assign({}, events[open][1].end)\n const end = Object.assign({}, events[index][1].start)\n movePoint(start, -use)\n movePoint(end, use)\n openingSequence = {\n type: use > 1 ? 'strongSequence' : 'emphasisSequence',\n start,\n end: Object.assign({}, events[open][1].end)\n }\n closingSequence = {\n type: use > 1 ? 'strongSequence' : 'emphasisSequence',\n start: Object.assign({}, events[index][1].start),\n end\n }\n text = {\n type: use > 1 ? 'strongText' : 'emphasisText',\n start: Object.assign({}, events[open][1].end),\n end: Object.assign({}, events[index][1].start)\n }\n group = {\n type: use > 1 ? 'strong' : 'emphasis',\n start: Object.assign({}, openingSequence.start),\n end: Object.assign({}, closingSequence.end)\n }\n events[open][1].end = Object.assign({}, openingSequence.start)\n events[index][1].start = Object.assign({}, closingSequence.end)\n nextEvents = []\n\n // If there are more markers in the opening, add them before.\n if (events[open][1].end.offset - events[open][1].start.offset) {\n nextEvents = push(nextEvents, [\n ['enter', events[open][1], context],\n ['exit', events[open][1], context]\n ])\n }\n\n // Opening.\n nextEvents = push(nextEvents, [\n ['enter', group, context],\n ['enter', openingSequence, context],\n ['exit', openingSequence, context],\n ['enter', text, context]\n ])\n\n // Always populated by defaults.\n\n // Between.\n nextEvents = push(\n nextEvents,\n resolveAll(\n context.parser.constructs.insideSpan.null,\n events.slice(open + 1, index),\n context\n )\n )\n\n // Closing.\n nextEvents = push(nextEvents, [\n ['exit', text, context],\n ['enter', closingSequence, context],\n ['exit', closingSequence, context],\n ['exit', group, context]\n ])\n\n // If there are more markers in the closing, add them after.\n if (events[index][1].end.offset - events[index][1].start.offset) {\n offset = 2\n nextEvents = push(nextEvents, [\n ['enter', events[index][1], context],\n ['exit', events[index][1], context]\n ])\n } else {\n offset = 0\n }\n splice(events, open - 1, index - open + 3, nextEvents)\n index = open + nextEvents.length - offset - 2\n break\n }\n }\n }\n }\n\n // Remove remaining sequences.\n index = -1\n while (++index < events.length) {\n if (events[index][1].type === 'attentionSequence') {\n events[index][1].type = 'data'\n }\n }\n return events\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeAttention(effects, ok) {\n const attentionMarkers = this.parser.constructs.attentionMarkers.null\n const previous = this.previous\n const before = classifyCharacter(previous)\n\n /** @type {NonNullable} */\n let marker\n return start\n\n /**\n * Before a sequence.\n *\n * ```markdown\n * > | **\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n marker = code\n effects.enter('attentionSequence')\n return inside(code)\n }\n\n /**\n * In a sequence.\n *\n * ```markdown\n * > | **\n * ^^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n if (code === marker) {\n effects.consume(code)\n return inside\n }\n const token = effects.exit('attentionSequence')\n\n // To do: next major: move this to resolver, just like `markdown-rs`.\n const after = classifyCharacter(code)\n\n // Always populated by defaults.\n\n const open =\n !after || (after === 2 && before) || attentionMarkers.includes(code)\n const close =\n !before || (before === 2 && after) || attentionMarkers.includes(previous)\n token._open = Boolean(marker === 42 ? open : open && (before || !close))\n token._close = Boolean(marker === 42 ? close : close && (after || !open))\n return ok(code)\n }\n}\n\n/**\n * Move a point a bit.\n *\n * Note: `move` only works inside lines! It’s not possible to move past other\n * chunks (replacement characters, tabs, or line endings).\n *\n * @param {Point} point\n * @param {number} offset\n * @returns {undefined}\n */\nfunction movePoint(point, offset) {\n point.column += offset\n point.offset += offset\n point._bufferIndex += offset\n}\n","/**\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {\n asciiAlpha,\n asciiAlphanumeric,\n asciiAtext,\n asciiControl\n} from 'micromark-util-character'\n/** @type {Construct} */\nexport const autolink = {\n name: 'autolink',\n tokenize: tokenizeAutolink\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeAutolink(effects, ok, nok) {\n let size = 0\n return start\n\n /**\n * Start of an autolink.\n *\n * ```markdown\n * > | ab\n * ^\n * > | ab\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('autolink')\n effects.enter('autolinkMarker')\n effects.consume(code)\n effects.exit('autolinkMarker')\n effects.enter('autolinkProtocol')\n return open\n }\n\n /**\n * After `<`, at protocol or atext.\n *\n * ```markdown\n * > | ab\n * ^\n * > | ab\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (asciiAlpha(code)) {\n effects.consume(code)\n return schemeOrEmailAtext\n }\n return emailAtext(code)\n }\n\n /**\n * At second byte of protocol or atext.\n *\n * ```markdown\n * > | ab\n * ^\n * > | ab\n * ^\n * ```\n *\n * @type {State}\n */\n function schemeOrEmailAtext(code) {\n // ASCII alphanumeric and `+`, `-`, and `.`.\n if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {\n // Count the previous alphabetical from `open` too.\n size = 1\n return schemeInsideOrEmailAtext(code)\n }\n return emailAtext(code)\n }\n\n /**\n * In ambiguous protocol or atext.\n *\n * ```markdown\n * > | ab\n * ^\n * > | ab\n * ^\n * ```\n *\n * @type {State}\n */\n function schemeInsideOrEmailAtext(code) {\n if (code === 58) {\n effects.consume(code)\n size = 0\n return urlInside\n }\n\n // ASCII alphanumeric and `+`, `-`, and `.`.\n if (\n (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) &&\n size++ < 32\n ) {\n effects.consume(code)\n return schemeInsideOrEmailAtext\n }\n size = 0\n return emailAtext(code)\n }\n\n /**\n * After protocol, in URL.\n *\n * ```markdown\n * > | ab\n * ^\n * ```\n *\n * @type {State}\n */\n function urlInside(code) {\n if (code === 62) {\n effects.exit('autolinkProtocol')\n effects.enter('autolinkMarker')\n effects.consume(code)\n effects.exit('autolinkMarker')\n effects.exit('autolink')\n return ok\n }\n\n // ASCII control, space, or `<`.\n if (code === null || code === 32 || code === 60 || asciiControl(code)) {\n return nok(code)\n }\n effects.consume(code)\n return urlInside\n }\n\n /**\n * In email atext.\n *\n * ```markdown\n * > | ab\n * ^\n * ```\n *\n * @type {State}\n */\n function emailAtext(code) {\n if (code === 64) {\n effects.consume(code)\n return emailAtSignOrDot\n }\n if (asciiAtext(code)) {\n effects.consume(code)\n return emailAtext\n }\n return nok(code)\n }\n\n /**\n * In label, after at-sign or dot.\n *\n * ```markdown\n * > | ab\n * ^ ^\n * ```\n *\n * @type {State}\n */\n function emailAtSignOrDot(code) {\n return asciiAlphanumeric(code) ? emailLabel(code) : nok(code)\n }\n\n /**\n * In label, where `.` and `>` are allowed.\n *\n * ```markdown\n * > | ab\n * ^\n * ```\n *\n * @type {State}\n */\n function emailLabel(code) {\n if (code === 46) {\n effects.consume(code)\n size = 0\n return emailAtSignOrDot\n }\n if (code === 62) {\n // Exit, then change the token type.\n effects.exit('autolinkProtocol').type = 'autolinkEmail'\n effects.enter('autolinkMarker')\n effects.consume(code)\n effects.exit('autolinkMarker')\n effects.exit('autolink')\n return ok\n }\n return emailValue(code)\n }\n\n /**\n * In label, where `.` and `>` are *not* allowed.\n *\n * Though, this is also used in `emailLabel` to parse other values.\n *\n * ```markdown\n * > | ab\n * ^\n * ```\n *\n * @type {State}\n */\n function emailValue(code) {\n // ASCII alphanumeric or `-`.\n if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {\n const next = code === 45 ? emailValue : emailLabel\n effects.consume(code)\n return next\n }\n return nok(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Code} Code\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {factorySpace} from 'micromark-factory-space'\nimport {\n asciiAlpha,\n asciiAlphanumeric,\n markdownLineEnding,\n markdownLineEndingOrSpace,\n markdownSpace\n} from 'micromark-util-character'\n/** @type {Construct} */\nexport const htmlText = {\n name: 'htmlText',\n tokenize: tokenizeHtmlText\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeHtmlText(effects, ok, nok) {\n const self = this\n /** @type {NonNullable | undefined} */\n let marker\n /** @type {number} */\n let index\n /** @type {State} */\n let returnState\n return start\n\n /**\n * Start of HTML (text).\n *\n * ```markdown\n * > | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('htmlText')\n effects.enter('htmlTextData')\n effects.consume(code)\n return open\n }\n\n /**\n * After `<`, at tag name or other stuff.\n *\n * ```markdown\n * > | a c\n * ^\n * > | a c\n * ^\n * > | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (code === 33) {\n effects.consume(code)\n return declarationOpen\n }\n if (code === 47) {\n effects.consume(code)\n return tagCloseStart\n }\n if (code === 63) {\n effects.consume(code)\n return instruction\n }\n\n // ASCII alphabetical.\n if (asciiAlpha(code)) {\n effects.consume(code)\n return tagOpen\n }\n return nok(code)\n }\n\n /**\n * After ` | a c\n * ^\n * > | a c\n * ^\n * > | a &<]]> c\n * ^\n * ```\n *\n * @type {State}\n */\n function declarationOpen(code) {\n if (code === 45) {\n effects.consume(code)\n return commentOpenInside\n }\n if (code === 91) {\n effects.consume(code)\n index = 0\n return cdataOpenInside\n }\n if (asciiAlpha(code)) {\n effects.consume(code)\n return declaration\n }\n return nok(code)\n }\n\n /**\n * In a comment, after ` | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function commentOpenInside(code) {\n if (code === 45) {\n effects.consume(code)\n return commentEnd\n }\n return nok(code)\n }\n\n /**\n * In comment.\n *\n * ```markdown\n * > | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function comment(code) {\n if (code === null) {\n return nok(code)\n }\n if (code === 45) {\n effects.consume(code)\n return commentClose\n }\n if (markdownLineEnding(code)) {\n returnState = comment\n return lineEndingBefore(code)\n }\n effects.consume(code)\n return comment\n }\n\n /**\n * In comment, after `-`.\n *\n * ```markdown\n * > | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function commentClose(code) {\n if (code === 45) {\n effects.consume(code)\n return commentEnd\n }\n return comment(code)\n }\n\n /**\n * In comment, after `--`.\n *\n * ```markdown\n * > | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function commentEnd(code) {\n return code === 62\n ? end(code)\n : code === 45\n ? commentClose(code)\n : comment(code)\n }\n\n /**\n * After ` | a &<]]> b\n * ^^^^^^\n * ```\n *\n * @type {State}\n */\n function cdataOpenInside(code) {\n const value = 'CDATA['\n if (code === value.charCodeAt(index++)) {\n effects.consume(code)\n return index === value.length ? cdata : cdataOpenInside\n }\n return nok(code)\n }\n\n /**\n * In CDATA.\n *\n * ```markdown\n * > | a &<]]> b\n * ^^^\n * ```\n *\n * @type {State}\n */\n function cdata(code) {\n if (code === null) {\n return nok(code)\n }\n if (code === 93) {\n effects.consume(code)\n return cdataClose\n }\n if (markdownLineEnding(code)) {\n returnState = cdata\n return lineEndingBefore(code)\n }\n effects.consume(code)\n return cdata\n }\n\n /**\n * In CDATA, after `]`, at another `]`.\n *\n * ```markdown\n * > | a &<]]> b\n * ^\n * ```\n *\n * @type {State}\n */\n function cdataClose(code) {\n if (code === 93) {\n effects.consume(code)\n return cdataEnd\n }\n return cdata(code)\n }\n\n /**\n * In CDATA, after `]]`, at `>`.\n *\n * ```markdown\n * > | a &<]]> b\n * ^\n * ```\n *\n * @type {State}\n */\n function cdataEnd(code) {\n if (code === 62) {\n return end(code)\n }\n if (code === 93) {\n effects.consume(code)\n return cdataEnd\n }\n return cdata(code)\n }\n\n /**\n * In declaration.\n *\n * ```markdown\n * > | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function declaration(code) {\n if (code === null || code === 62) {\n return end(code)\n }\n if (markdownLineEnding(code)) {\n returnState = declaration\n return lineEndingBefore(code)\n }\n effects.consume(code)\n return declaration\n }\n\n /**\n * In instruction.\n *\n * ```markdown\n * > | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function instruction(code) {\n if (code === null) {\n return nok(code)\n }\n if (code === 63) {\n effects.consume(code)\n return instructionClose\n }\n if (markdownLineEnding(code)) {\n returnState = instruction\n return lineEndingBefore(code)\n }\n effects.consume(code)\n return instruction\n }\n\n /**\n * In instruction, after `?`, at `>`.\n *\n * ```markdown\n * > | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function instructionClose(code) {\n return code === 62 ? end(code) : instruction(code)\n }\n\n /**\n * After ` | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagCloseStart(code) {\n // ASCII alphabetical.\n if (asciiAlpha(code)) {\n effects.consume(code)\n return tagClose\n }\n return nok(code)\n }\n\n /**\n * After ` | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagClose(code) {\n // ASCII alphanumerical and `-`.\n if (code === 45 || asciiAlphanumeric(code)) {\n effects.consume(code)\n return tagClose\n }\n return tagCloseBetween(code)\n }\n\n /**\n * In closing tag, after tag name.\n *\n * ```markdown\n * > | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagCloseBetween(code) {\n if (markdownLineEnding(code)) {\n returnState = tagCloseBetween\n return lineEndingBefore(code)\n }\n if (markdownSpace(code)) {\n effects.consume(code)\n return tagCloseBetween\n }\n return end(code)\n }\n\n /**\n * After ` | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpen(code) {\n // ASCII alphanumerical and `-`.\n if (code === 45 || asciiAlphanumeric(code)) {\n effects.consume(code)\n return tagOpen\n }\n if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n return tagOpenBetween(code)\n }\n return nok(code)\n }\n\n /**\n * In opening tag, after tag name.\n *\n * ```markdown\n * > | a c\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenBetween(code) {\n if (code === 47) {\n effects.consume(code)\n return end\n }\n\n // ASCII alphabetical and `:` and `_`.\n if (code === 58 || code === 95 || asciiAlpha(code)) {\n effects.consume(code)\n return tagOpenAttributeName\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenBetween\n return lineEndingBefore(code)\n }\n if (markdownSpace(code)) {\n effects.consume(code)\n return tagOpenBetween\n }\n return end(code)\n }\n\n /**\n * In attribute name.\n *\n * ```markdown\n * > | a d\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeName(code) {\n // ASCII alphabetical and `-`, `.`, `:`, and `_`.\n if (\n code === 45 ||\n code === 46 ||\n code === 58 ||\n code === 95 ||\n asciiAlphanumeric(code)\n ) {\n effects.consume(code)\n return tagOpenAttributeName\n }\n return tagOpenAttributeNameAfter(code)\n }\n\n /**\n * After attribute name, before initializer, the end of the tag, or\n * whitespace.\n *\n * ```markdown\n * > | a d\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeNameAfter(code) {\n if (code === 61) {\n effects.consume(code)\n return tagOpenAttributeValueBefore\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenAttributeNameAfter\n return lineEndingBefore(code)\n }\n if (markdownSpace(code)) {\n effects.consume(code)\n return tagOpenAttributeNameAfter\n }\n return tagOpenBetween(code)\n }\n\n /**\n * Before unquoted, double quoted, or single quoted attribute value, allowing\n * whitespace.\n *\n * ```markdown\n * > | a e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueBefore(code) {\n if (\n code === null ||\n code === 60 ||\n code === 61 ||\n code === 62 ||\n code === 96\n ) {\n return nok(code)\n }\n if (code === 34 || code === 39) {\n effects.consume(code)\n marker = code\n return tagOpenAttributeValueQuoted\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenAttributeValueBefore\n return lineEndingBefore(code)\n }\n if (markdownSpace(code)) {\n effects.consume(code)\n return tagOpenAttributeValueBefore\n }\n effects.consume(code)\n return tagOpenAttributeValueUnquoted\n }\n\n /**\n * In double or single quoted attribute value.\n *\n * ```markdown\n * > | a e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueQuoted(code) {\n if (code === marker) {\n effects.consume(code)\n marker = undefined\n return tagOpenAttributeValueQuotedAfter\n }\n if (code === null) {\n return nok(code)\n }\n if (markdownLineEnding(code)) {\n returnState = tagOpenAttributeValueQuoted\n return lineEndingBefore(code)\n }\n effects.consume(code)\n return tagOpenAttributeValueQuoted\n }\n\n /**\n * In unquoted attribute value.\n *\n * ```markdown\n * > | a e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueUnquoted(code) {\n if (\n code === null ||\n code === 34 ||\n code === 39 ||\n code === 60 ||\n code === 61 ||\n code === 96\n ) {\n return nok(code)\n }\n if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n return tagOpenBetween(code)\n }\n effects.consume(code)\n return tagOpenAttributeValueUnquoted\n }\n\n /**\n * After double or single quoted attribute value, before whitespace or the end\n * of the tag.\n *\n * ```markdown\n * > | a e\n * ^\n * ```\n *\n * @type {State}\n */\n function tagOpenAttributeValueQuotedAfter(code) {\n if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {\n return tagOpenBetween(code)\n }\n return nok(code)\n }\n\n /**\n * In certain circumstances of a tag where only an `>` is allowed.\n *\n * ```markdown\n * > | a e\n * ^\n * ```\n *\n * @type {State}\n */\n function end(code) {\n if (code === 62) {\n effects.consume(code)\n effects.exit('htmlTextData')\n effects.exit('htmlText')\n return ok\n }\n return nok(code)\n }\n\n /**\n * At eol.\n *\n * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about\n * > empty tokens.\n *\n * ```markdown\n * > | a \n * ```\n *\n * @type {State}\n */\n function lineEndingBefore(code) {\n effects.exit('htmlTextData')\n effects.enter('lineEnding')\n effects.consume(code)\n effects.exit('lineEnding')\n return lineEndingAfter\n }\n\n /**\n * After eol, at optional whitespace.\n *\n * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about\n * > empty tokens.\n *\n * ```markdown\n * | a \n * ^\n * ```\n *\n * @type {State}\n */\n function lineEndingAfter(code) {\n // Always populated by defaults.\n\n return markdownSpace(code)\n ? factorySpace(\n effects,\n lineEndingAfterPrefix,\n 'linePrefix',\n self.parser.constructs.disable.null.includes('codeIndented')\n ? undefined\n : 4\n )(code)\n : lineEndingAfterPrefix(code)\n }\n\n /**\n * After eol, after optional whitespace.\n *\n * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about\n * > empty tokens.\n *\n * ```markdown\n * | a \n * ^\n * ```\n *\n * @type {State}\n */\n function lineEndingAfterPrefix(code) {\n effects.enter('htmlTextData')\n return returnState(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {labelEnd} from './label-end.js'\n\n/** @type {Construct} */\nexport const labelStartLink = {\n name: 'labelStartLink',\n tokenize: tokenizeLabelStartLink,\n resolveAll: labelEnd.resolveAll\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeLabelStartLink(effects, ok, nok) {\n const self = this\n return start\n\n /**\n * Start of label (link) start.\n *\n * ```markdown\n * > | a [b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('labelLink')\n effects.enter('labelMarker')\n effects.consume(code)\n effects.exit('labelMarker')\n effects.exit('labelLink')\n return after\n }\n\n /** @type {State} */\n function after(code) {\n // To do: this isn’t needed in `micromark-extension-gfm-footnote`,\n // remove.\n // Hidden footnotes hook.\n /* c8 ignore next 3 */\n return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs\n ? nok(code)\n : ok(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {markdownLineEnding} from 'micromark-util-character'\n/** @type {Construct} */\nexport const hardBreakEscape = {\n name: 'hardBreakEscape',\n tokenize: tokenizeHardBreakEscape\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeHardBreakEscape(effects, ok, nok) {\n return start\n\n /**\n * Start of a hard break (escape).\n *\n * ```markdown\n * > | a\\\n * ^\n * | b\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('hardBreakEscape')\n effects.consume(code)\n return after\n }\n\n /**\n * After `\\`, at eol.\n *\n * ```markdown\n * > | a\\\n * ^\n * | b\n * ```\n *\n * @type {State}\n */\n function after(code) {\n if (markdownLineEnding(code)) {\n effects.exit('hardBreakEscape')\n return ok(code)\n }\n return nok(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Construct} Construct\n * @typedef {import('micromark-util-types').Previous} Previous\n * @typedef {import('micromark-util-types').Resolver} Resolver\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').Token} Token\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {markdownLineEnding} from 'micromark-util-character'\n/** @type {Construct} */\nexport const codeText = {\n name: 'codeText',\n tokenize: tokenizeCodeText,\n resolve: resolveCodeText,\n previous\n}\n\n// To do: next major: don’t resolve, like `markdown-rs`.\n/** @type {Resolver} */\nfunction resolveCodeText(events) {\n let tailExitIndex = events.length - 4\n let headEnterIndex = 3\n /** @type {number} */\n let index\n /** @type {number | undefined} */\n let enter\n\n // If we start and end with an EOL or a space.\n if (\n (events[headEnterIndex][1].type === 'lineEnding' ||\n events[headEnterIndex][1].type === 'space') &&\n (events[tailExitIndex][1].type === 'lineEnding' ||\n events[tailExitIndex][1].type === 'space')\n ) {\n index = headEnterIndex\n\n // And we have data.\n while (++index < tailExitIndex) {\n if (events[index][1].type === 'codeTextData') {\n // Then we have padding.\n events[headEnterIndex][1].type = 'codeTextPadding'\n events[tailExitIndex][1].type = 'codeTextPadding'\n headEnterIndex += 2\n tailExitIndex -= 2\n break\n }\n }\n }\n\n // Merge adjacent spaces and data.\n index = headEnterIndex - 1\n tailExitIndex++\n while (++index <= tailExitIndex) {\n if (enter === undefined) {\n if (index !== tailExitIndex && events[index][1].type !== 'lineEnding') {\n enter = index\n }\n } else if (\n index === tailExitIndex ||\n events[index][1].type === 'lineEnding'\n ) {\n events[enter][1].type = 'codeTextData'\n if (index !== enter + 2) {\n events[enter][1].end = events[index - 1][1].end\n events.splice(enter + 2, index - enter - 2)\n tailExitIndex -= index - enter - 2\n index = enter + 2\n }\n enter = undefined\n }\n }\n return events\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Previous}\n */\nfunction previous(code) {\n // If there is a previous code, there will always be a tail.\n return (\n code !== 96 ||\n this.events[this.events.length - 1][1].type === 'characterEscape'\n )\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeCodeText(effects, ok, nok) {\n const self = this\n let sizeOpen = 0\n /** @type {number} */\n let size\n /** @type {Token} */\n let token\n return start\n\n /**\n * Start of code (text).\n *\n * ```markdown\n * > | `a`\n * ^\n * > | \\`a`\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('codeText')\n effects.enter('codeTextSequence')\n return sequenceOpen(code)\n }\n\n /**\n * In opening sequence.\n *\n * ```markdown\n * > | `a`\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceOpen(code) {\n if (code === 96) {\n effects.consume(code)\n sizeOpen++\n return sequenceOpen\n }\n effects.exit('codeTextSequence')\n return between(code)\n }\n\n /**\n * Between something and something else.\n *\n * ```markdown\n * > | `a`\n * ^^\n * ```\n *\n * @type {State}\n */\n function between(code) {\n // EOF.\n if (code === null) {\n return nok(code)\n }\n\n // To do: next major: don’t do spaces in resolve, but when compiling,\n // like `markdown-rs`.\n // Tabs don’t work, and virtual spaces don’t make sense.\n if (code === 32) {\n effects.enter('space')\n effects.consume(code)\n effects.exit('space')\n return between\n }\n\n // Closing fence? Could also be data.\n if (code === 96) {\n token = effects.enter('codeTextSequence')\n size = 0\n return sequenceClose(code)\n }\n if (markdownLineEnding(code)) {\n effects.enter('lineEnding')\n effects.consume(code)\n effects.exit('lineEnding')\n return between\n }\n\n // Data.\n effects.enter('codeTextData')\n return data(code)\n }\n\n /**\n * In data.\n *\n * ```markdown\n * > | `a`\n * ^\n * ```\n *\n * @type {State}\n */\n function data(code) {\n if (\n code === null ||\n code === 32 ||\n code === 96 ||\n markdownLineEnding(code)\n ) {\n effects.exit('codeTextData')\n return between(code)\n }\n effects.consume(code)\n return data\n }\n\n /**\n * In closing sequence.\n *\n * ```markdown\n * > | `a`\n * ^\n * ```\n *\n * @type {State}\n */\n function sequenceClose(code) {\n // More.\n if (code === 96) {\n effects.consume(code)\n size++\n return sequenceClose\n }\n\n // Done!\n if (size === sizeOpen) {\n effects.exit('codeTextSequence')\n effects.exit('codeText')\n return ok(code)\n }\n\n // More or less accents: mark as data.\n token.type = 'codeTextData'\n return data(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Extension} Extension\n */\n\nimport {\n attention,\n autolink,\n blockQuote,\n characterEscape,\n characterReference,\n codeFenced,\n codeIndented,\n codeText,\n definition,\n hardBreakEscape,\n headingAtx,\n htmlFlow,\n htmlText,\n labelEnd,\n labelStartImage,\n labelStartLink,\n lineEnding,\n list,\n setextUnderline,\n thematicBreak\n} from 'micromark-core-commonmark'\nimport {resolver as resolveText} from './initialize/text.js'\n\n/** @satisfies {Extension['document']} */\nexport const document = {\n [42]: list,\n [43]: list,\n [45]: list,\n [48]: list,\n [49]: list,\n [50]: list,\n [51]: list,\n [52]: list,\n [53]: list,\n [54]: list,\n [55]: list,\n [56]: list,\n [57]: list,\n [62]: blockQuote\n}\n\n/** @satisfies {Extension['contentInitial']} */\nexport const contentInitial = {\n [91]: definition\n}\n\n/** @satisfies {Extension['flowInitial']} */\nexport const flowInitial = {\n [-2]: codeIndented,\n [-1]: codeIndented,\n [32]: codeIndented\n}\n\n/** @satisfies {Extension['flow']} */\nexport const flow = {\n [35]: headingAtx,\n [42]: thematicBreak,\n [45]: [setextUnderline, thematicBreak],\n [60]: htmlFlow,\n [61]: setextUnderline,\n [95]: thematicBreak,\n [96]: codeFenced,\n [126]: codeFenced\n}\n\n/** @satisfies {Extension['string']} */\nexport const string = {\n [38]: characterReference,\n [92]: characterEscape\n}\n\n/** @satisfies {Extension['text']} */\nexport const text = {\n [-5]: lineEnding,\n [-4]: lineEnding,\n [-3]: lineEnding,\n [33]: labelStartImage,\n [38]: characterReference,\n [42]: attention,\n [60]: [autolink, htmlText],\n [91]: labelStartLink,\n [92]: [hardBreakEscape, characterEscape],\n [93]: labelEnd,\n [95]: attention,\n [96]: codeText\n}\n\n/** @satisfies {Extension['insideSpan']} */\nexport const insideSpan = {\n null: [attention, resolveText]\n}\n\n/** @satisfies {Extension['attentionMarkers']} */\nexport const attentionMarkers = {\n null: [42, 95]\n}\n\n/** @satisfies {Extension['disable']} */\nexport const disable = {\n null: []\n}\n","/**\n * @typedef {import('micromark-util-types').Chunk} Chunk\n * @typedef {import('micromark-util-types').Code} Code\n * @typedef {import('micromark-util-types').Encoding} Encoding\n * @typedef {import('micromark-util-types').Value} Value\n */\n\n/**\n * @callback Preprocessor\n * @param {Value} value\n * @param {Encoding | null | undefined} [encoding]\n * @param {boolean | null | undefined} [end=false]\n * @returns {Array}\n */\n\nconst search = /[\\0\\t\\n\\r]/g\n\n/**\n * @returns {Preprocessor}\n */\nexport function preprocess() {\n let column = 1\n let buffer = ''\n /** @type {boolean | undefined} */\n let start = true\n /** @type {boolean | undefined} */\n let atCarriageReturn\n return preprocessor\n\n /** @type {Preprocessor} */\n // eslint-disable-next-line complexity\n function preprocessor(value, encoding, end) {\n /** @type {Array} */\n const chunks = []\n /** @type {RegExpMatchArray | null} */\n let match\n /** @type {number} */\n let next\n /** @type {number} */\n let startPosition\n /** @type {number} */\n let endPosition\n /** @type {Code} */\n let code\n value =\n buffer +\n (typeof value === 'string'\n ? value.toString()\n : new TextDecoder(encoding || undefined).decode(value))\n startPosition = 0\n buffer = ''\n if (start) {\n // To do: `markdown-rs` actually parses BOMs (byte order mark).\n if (value.charCodeAt(0) === 65279) {\n startPosition++\n }\n start = undefined\n }\n while (startPosition < value.length) {\n search.lastIndex = startPosition\n match = search.exec(value)\n endPosition =\n match && match.index !== undefined ? match.index : value.length\n code = value.charCodeAt(endPosition)\n if (!match) {\n buffer = value.slice(startPosition)\n break\n }\n if (code === 10 && startPosition === endPosition && atCarriageReturn) {\n chunks.push(-3)\n atCarriageReturn = undefined\n } else {\n if (atCarriageReturn) {\n chunks.push(-5)\n atCarriageReturn = undefined\n }\n if (startPosition < endPosition) {\n chunks.push(value.slice(startPosition, endPosition))\n column += endPosition - startPosition\n }\n switch (code) {\n case 0: {\n chunks.push(65533)\n column++\n break\n }\n case 9: {\n next = Math.ceil(column / 4) * 4\n chunks.push(-2)\n while (column++ < next) chunks.push(-1)\n break\n }\n case 10: {\n chunks.push(-4)\n column = 1\n break\n }\n default: {\n atCarriageReturn = true\n column = 1\n }\n }\n }\n startPosition = endPosition + 1\n }\n if (end) {\n if (atCarriageReturn) chunks.push(-5)\n if (buffer) chunks.push(buffer)\n chunks.push(null)\n }\n return chunks\n }\n}\n","/**\n * Turn the number (in string form as either hexa- or plain decimal) coming from\n * a numeric character reference into a character.\n *\n * Sort of like `String.fromCodePoint(Number.parseInt(value, base))`, but makes\n * non-characters and control characters safe.\n *\n * @param {string} value\n * Value to decode.\n * @param {number} base\n * Numeric base.\n * @returns {string}\n * Character.\n */\nexport function decodeNumericCharacterReference(value, base) {\n const code = Number.parseInt(value, base);\n if (\n // C0 except for HT, LF, FF, CR, space.\n code < 9 || code === 11 || code > 13 && code < 32 ||\n // Control character (DEL) of C0, and C1 controls.\n code > 126 && code < 160 ||\n // Lone high surrogates and low surrogates.\n code > 55_295 && code < 57_344 ||\n // Noncharacters.\n code > 64_975 && code < 65_008 || /* eslint-disable no-bitwise */\n (code & 65_535) === 65_535 || (code & 65_535) === 65_534 || /* eslint-enable no-bitwise */\n // Out of range\n code > 1_114_111) {\n return \"\\uFFFD\";\n }\n return String.fromCodePoint(code);\n}","import {decodeNamedCharacterReference} from 'decode-named-character-reference'\nimport {decodeNumericCharacterReference} from 'micromark-util-decode-numeric-character-reference'\nconst characterEscapeOrReference =\n /\\\\([!-/:-@[-`{-~])|&(#(?:\\d{1,7}|x[\\da-f]{1,6})|[\\da-z]{1,31});/gi\n\n/**\n * Decode markdown strings (which occur in places such as fenced code info\n * strings, destinations, labels, and titles).\n *\n * The “string” content type allows character escapes and -references.\n * This decodes those.\n *\n * @param {string} value\n * Value to decode.\n * @returns {string}\n * Decoded value.\n */\nexport function decodeString(value) {\n return value.replace(characterEscapeOrReference, decode)\n}\n\n/**\n * @param {string} $0\n * @param {string} $1\n * @param {string} $2\n * @returns {string}\n */\nfunction decode($0, $1, $2) {\n if ($1) {\n // Escape.\n return $1\n }\n\n // Reference.\n const head = $2.charCodeAt(0)\n if (head === 35) {\n const head = $2.charCodeAt(1)\n const hex = head === 120 || head === 88\n return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10)\n }\n return decodeNamedCharacterReference($2) || $0\n}\n","/**\n * @typedef {import('mdast').Break} Break\n * @typedef {import('mdast').Blockquote} Blockquote\n * @typedef {import('mdast').Code} Code\n * @typedef {import('mdast').Definition} Definition\n * @typedef {import('mdast').Emphasis} Emphasis\n * @typedef {import('mdast').Heading} Heading\n * @typedef {import('mdast').Html} Html\n * @typedef {import('mdast').Image} Image\n * @typedef {import('mdast').InlineCode} InlineCode\n * @typedef {import('mdast').Link} Link\n * @typedef {import('mdast').List} List\n * @typedef {import('mdast').ListItem} ListItem\n * @typedef {import('mdast').Nodes} Nodes\n * @typedef {import('mdast').Paragraph} Paragraph\n * @typedef {import('mdast').Parent} Parent\n * @typedef {import('mdast').PhrasingContent} PhrasingContent\n * @typedef {import('mdast').ReferenceType} ReferenceType\n * @typedef {import('mdast').Root} Root\n * @typedef {import('mdast').Strong} Strong\n * @typedef {import('mdast').Text} Text\n * @typedef {import('mdast').ThematicBreak} ThematicBreak\n *\n * @typedef {import('micromark-util-types').Encoding} Encoding\n * @typedef {import('micromark-util-types').Event} Event\n * @typedef {import('micromark-util-types').ParseOptions} ParseOptions\n * @typedef {import('micromark-util-types').Token} Token\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Value} Value\n *\n * @typedef {import('unist').Point} Point\n *\n * @typedef {import('../index.js').CompileData} CompileData\n */\n\n/**\n * @typedef {Omit & {type: 'fragment', children: Array}} Fragment\n */\n\n/**\n * @callback Transform\n * Extra transform, to change the AST afterwards.\n * @param {Root} tree\n * Tree to transform.\n * @returns {Root | null | undefined | void}\n * New tree or nothing (in which case the current tree is used).\n *\n * @callback Handle\n * Handle a token.\n * @param {CompileContext} this\n * Context.\n * @param {Token} token\n * Current token.\n * @returns {undefined | void}\n * Nothing.\n *\n * @typedef {Record} Handles\n * Token types mapping to handles\n *\n * @callback OnEnterError\n * Handle the case where the `right` token is open, but it is closed (by the\n * `left` token) or because we reached the end of the document.\n * @param {Omit} this\n * Context.\n * @param {Token | undefined} left\n * Left token.\n * @param {Token} right\n * Right token.\n * @returns {undefined}\n * Nothing.\n *\n * @callback OnExitError\n * Handle the case where the `right` token is open but it is closed by\n * exiting the `left` token.\n * @param {Omit} this\n * Context.\n * @param {Token} left\n * Left token.\n * @param {Token} right\n * Right token.\n * @returns {undefined}\n * Nothing.\n *\n * @typedef {[Token, OnEnterError | undefined]} TokenTuple\n * Open token on the stack, with an optional error handler for when\n * that token isn’t closed properly.\n */\n\n/**\n * @typedef Config\n * Configuration.\n *\n * We have our defaults, but extensions will add more.\n * @property {Array} canContainEols\n * Token types where line endings are used.\n * @property {Handles} enter\n * Opening handles.\n * @property {Handles} exit\n * Closing handles.\n * @property {Array} transforms\n * Tree transforms.\n *\n * @typedef {Partial} Extension\n * Change how markdown tokens from micromark are turned into mdast.\n *\n * @typedef CompileContext\n * mdast compiler context.\n * @property {Array} stack\n * Stack of nodes.\n * @property {Array} tokenStack\n * Stack of tokens.\n * @property {(this: CompileContext) => undefined} buffer\n * Capture some of the output data.\n * @property {(this: CompileContext) => string} resume\n * Stop capturing and access the output data.\n * @property {(this: CompileContext, node: Nodes, token: Token, onError?: OnEnterError) => undefined} enter\n * Enter a node.\n * @property {(this: CompileContext, token: Token, onError?: OnExitError) => undefined} exit\n * Exit a node.\n * @property {TokenizeContext['sliceSerialize']} sliceSerialize\n * Get the string value of a token.\n * @property {Config} config\n * Configuration.\n * @property {CompileData} data\n * Info passed around; key/value store.\n *\n * @typedef FromMarkdownOptions\n * Configuration for how to build mdast.\n * @property {Array> | null | undefined} [mdastExtensions]\n * Extensions for this utility to change how tokens are turned into a tree.\n *\n * @typedef {ParseOptions & FromMarkdownOptions} Options\n * Configuration.\n */\n\nimport {toString} from 'mdast-util-to-string'\nimport {parse, postprocess, preprocess} from 'micromark'\nimport {decodeNumericCharacterReference} from 'micromark-util-decode-numeric-character-reference'\nimport {decodeString} from 'micromark-util-decode-string'\nimport {normalizeIdentifier} from 'micromark-util-normalize-identifier'\nimport {decodeNamedCharacterReference} from 'decode-named-character-reference'\nimport {stringifyPosition} from 'unist-util-stringify-position'\nconst own = {}.hasOwnProperty\n\n/**\n * Turn markdown into a syntax tree.\n *\n * @overload\n * @param {Value} value\n * @param {Encoding | null | undefined} [encoding]\n * @param {Options | null | undefined} [options]\n * @returns {Root}\n *\n * @overload\n * @param {Value} value\n * @param {Options | null | undefined} [options]\n * @returns {Root}\n *\n * @param {Value} value\n * Markdown to parse.\n * @param {Encoding | Options | null | undefined} [encoding]\n * Character encoding for when `value` is `Buffer`.\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {Root}\n * mdast tree.\n */\nexport function fromMarkdown(value, encoding, options) {\n if (typeof encoding !== 'string') {\n options = encoding\n encoding = undefined\n }\n return compiler(options)(\n postprocess(\n parse(options).document().write(preprocess()(value, encoding, true))\n )\n )\n}\n\n/**\n * Note this compiler only understand complete buffering, not streaming.\n *\n * @param {Options | null | undefined} [options]\n */\nfunction compiler(options) {\n /** @type {Config} */\n const config = {\n transforms: [],\n canContainEols: ['emphasis', 'fragment', 'heading', 'paragraph', 'strong'],\n enter: {\n autolink: opener(link),\n autolinkProtocol: onenterdata,\n autolinkEmail: onenterdata,\n atxHeading: opener(heading),\n blockQuote: opener(blockQuote),\n characterEscape: onenterdata,\n characterReference: onenterdata,\n codeFenced: opener(codeFlow),\n codeFencedFenceInfo: buffer,\n codeFencedFenceMeta: buffer,\n codeIndented: opener(codeFlow, buffer),\n codeText: opener(codeText, buffer),\n codeTextData: onenterdata,\n data: onenterdata,\n codeFlowValue: onenterdata,\n definition: opener(definition),\n definitionDestinationString: buffer,\n definitionLabelString: buffer,\n definitionTitleString: buffer,\n emphasis: opener(emphasis),\n hardBreakEscape: opener(hardBreak),\n hardBreakTrailing: opener(hardBreak),\n htmlFlow: opener(html, buffer),\n htmlFlowData: onenterdata,\n htmlText: opener(html, buffer),\n htmlTextData: onenterdata,\n image: opener(image),\n label: buffer,\n link: opener(link),\n listItem: opener(listItem),\n listItemValue: onenterlistitemvalue,\n listOrdered: opener(list, onenterlistordered),\n listUnordered: opener(list),\n paragraph: opener(paragraph),\n reference: onenterreference,\n referenceString: buffer,\n resourceDestinationString: buffer,\n resourceTitleString: buffer,\n setextHeading: opener(heading),\n strong: opener(strong),\n thematicBreak: opener(thematicBreak)\n },\n exit: {\n atxHeading: closer(),\n atxHeadingSequence: onexitatxheadingsequence,\n autolink: closer(),\n autolinkEmail: onexitautolinkemail,\n autolinkProtocol: onexitautolinkprotocol,\n blockQuote: closer(),\n characterEscapeValue: onexitdata,\n characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,\n characterReferenceMarkerNumeric: onexitcharacterreferencemarker,\n characterReferenceValue: onexitcharacterreferencevalue,\n codeFenced: closer(onexitcodefenced),\n codeFencedFence: onexitcodefencedfence,\n codeFencedFenceInfo: onexitcodefencedfenceinfo,\n codeFencedFenceMeta: onexitcodefencedfencemeta,\n codeFlowValue: onexitdata,\n codeIndented: closer(onexitcodeindented),\n codeText: closer(onexitcodetext),\n codeTextData: onexitdata,\n data: onexitdata,\n definition: closer(),\n definitionDestinationString: onexitdefinitiondestinationstring,\n definitionLabelString: onexitdefinitionlabelstring,\n definitionTitleString: onexitdefinitiontitlestring,\n emphasis: closer(),\n hardBreakEscape: closer(onexithardbreak),\n hardBreakTrailing: closer(onexithardbreak),\n htmlFlow: closer(onexithtmlflow),\n htmlFlowData: onexitdata,\n htmlText: closer(onexithtmltext),\n htmlTextData: onexitdata,\n image: closer(onexitimage),\n label: onexitlabel,\n labelText: onexitlabeltext,\n lineEnding: onexitlineending,\n link: closer(onexitlink),\n listItem: closer(),\n listOrdered: closer(),\n listUnordered: closer(),\n paragraph: closer(),\n referenceString: onexitreferencestring,\n resourceDestinationString: onexitresourcedestinationstring,\n resourceTitleString: onexitresourcetitlestring,\n resource: onexitresource,\n setextHeading: closer(onexitsetextheading),\n setextHeadingLineSequence: onexitsetextheadinglinesequence,\n setextHeadingText: onexitsetextheadingtext,\n strong: closer(),\n thematicBreak: closer()\n }\n }\n configure(config, (options || {}).mdastExtensions || [])\n\n /** @type {CompileData} */\n const data = {}\n return compile\n\n /**\n * Turn micromark events into an mdast tree.\n *\n * @param {Array} events\n * Events.\n * @returns {Root}\n * mdast tree.\n */\n function compile(events) {\n /** @type {Root} */\n let tree = {\n type: 'root',\n children: []\n }\n /** @type {Omit} */\n const context = {\n stack: [tree],\n tokenStack: [],\n config,\n enter,\n exit,\n buffer,\n resume,\n data\n }\n /** @type {Array} */\n const listStack = []\n let index = -1\n while (++index < events.length) {\n // We preprocess lists to add `listItem` tokens, and to infer whether\n // items the list itself are spread out.\n if (\n events[index][1].type === 'listOrdered' ||\n events[index][1].type === 'listUnordered'\n ) {\n if (events[index][0] === 'enter') {\n listStack.push(index)\n } else {\n const tail = listStack.pop()\n index = prepareList(events, tail, index)\n }\n }\n }\n index = -1\n while (++index < events.length) {\n const handler = config[events[index][0]]\n if (own.call(handler, events[index][1].type)) {\n handler[events[index][1].type].call(\n Object.assign(\n {\n sliceSerialize: events[index][2].sliceSerialize\n },\n context\n ),\n events[index][1]\n )\n }\n }\n\n // Handle tokens still being open.\n if (context.tokenStack.length > 0) {\n const tail = context.tokenStack[context.tokenStack.length - 1]\n const handler = tail[1] || defaultOnError\n handler.call(context, undefined, tail[0])\n }\n\n // Figure out `root` position.\n tree.position = {\n start: point(\n events.length > 0\n ? events[0][1].start\n : {\n line: 1,\n column: 1,\n offset: 0\n }\n ),\n end: point(\n events.length > 0\n ? events[events.length - 2][1].end\n : {\n line: 1,\n column: 1,\n offset: 0\n }\n )\n }\n\n // Call transforms.\n index = -1\n while (++index < config.transforms.length) {\n tree = config.transforms[index](tree) || tree\n }\n return tree\n }\n\n /**\n * @param {Array} events\n * @param {number} start\n * @param {number} length\n * @returns {number}\n */\n function prepareList(events, start, length) {\n let index = start - 1\n let containerBalance = -1\n let listSpread = false\n /** @type {Token | undefined} */\n let listItem\n /** @type {number | undefined} */\n let lineIndex\n /** @type {number | undefined} */\n let firstBlankLineIndex\n /** @type {boolean | undefined} */\n let atMarker\n while (++index <= length) {\n const event = events[index]\n switch (event[1].type) {\n case 'listUnordered':\n case 'listOrdered':\n case 'blockQuote': {\n if (event[0] === 'enter') {\n containerBalance++\n } else {\n containerBalance--\n }\n atMarker = undefined\n break\n }\n case 'lineEndingBlank': {\n if (event[0] === 'enter') {\n if (\n listItem &&\n !atMarker &&\n !containerBalance &&\n !firstBlankLineIndex\n ) {\n firstBlankLineIndex = index\n }\n atMarker = undefined\n }\n break\n }\n case 'linePrefix':\n case 'listItemValue':\n case 'listItemMarker':\n case 'listItemPrefix':\n case 'listItemPrefixWhitespace': {\n // Empty.\n\n break\n }\n default: {\n atMarker = undefined\n }\n }\n if (\n (!containerBalance &&\n event[0] === 'enter' &&\n event[1].type === 'listItemPrefix') ||\n (containerBalance === -1 &&\n event[0] === 'exit' &&\n (event[1].type === 'listUnordered' ||\n event[1].type === 'listOrdered'))\n ) {\n if (listItem) {\n let tailIndex = index\n lineIndex = undefined\n while (tailIndex--) {\n const tailEvent = events[tailIndex]\n if (\n tailEvent[1].type === 'lineEnding' ||\n tailEvent[1].type === 'lineEndingBlank'\n ) {\n if (tailEvent[0] === 'exit') continue\n if (lineIndex) {\n events[lineIndex][1].type = 'lineEndingBlank'\n listSpread = true\n }\n tailEvent[1].type = 'lineEnding'\n lineIndex = tailIndex\n } else if (\n tailEvent[1].type === 'linePrefix' ||\n tailEvent[1].type === 'blockQuotePrefix' ||\n tailEvent[1].type === 'blockQuotePrefixWhitespace' ||\n tailEvent[1].type === 'blockQuoteMarker' ||\n tailEvent[1].type === 'listItemIndent'\n ) {\n // Empty\n } else {\n break\n }\n }\n if (\n firstBlankLineIndex &&\n (!lineIndex || firstBlankLineIndex < lineIndex)\n ) {\n listItem._spread = true\n }\n\n // Fix position.\n listItem.end = Object.assign(\n {},\n lineIndex ? events[lineIndex][1].start : event[1].end\n )\n events.splice(lineIndex || index, 0, ['exit', listItem, event[2]])\n index++\n length++\n }\n\n // Create a new list item.\n if (event[1].type === 'listItemPrefix') {\n /** @type {Token} */\n const item = {\n type: 'listItem',\n _spread: false,\n start: Object.assign({}, event[1].start),\n // @ts-expect-error: we’ll add `end` in a second.\n end: undefined\n }\n listItem = item\n events.splice(index, 0, ['enter', item, event[2]])\n index++\n length++\n firstBlankLineIndex = undefined\n atMarker = true\n }\n }\n }\n events[start][1]._spread = listSpread\n return length\n }\n\n /**\n * Create an opener handle.\n *\n * @param {(token: Token) => Nodes} create\n * Create a node.\n * @param {Handle | undefined} [and]\n * Optional function to also run.\n * @returns {Handle}\n * Handle.\n */\n function opener(create, and) {\n return open\n\n /**\n * @this {CompileContext}\n * @param {Token} token\n * @returns {undefined}\n */\n function open(token) {\n enter.call(this, create(token), token)\n if (and) and.call(this, token)\n }\n }\n\n /**\n * @this {CompileContext}\n * @returns {undefined}\n */\n function buffer() {\n this.stack.push({\n type: 'fragment',\n children: []\n })\n }\n\n /**\n * @this {CompileContext}\n * Context.\n * @param {Nodes} node\n * Node to enter.\n * @param {Token} token\n * Corresponding token.\n * @param {OnEnterError | undefined} [errorHandler]\n * Handle the case where this token is open, but it is closed by something else.\n * @returns {undefined}\n * Nothing.\n */\n function enter(node, token, errorHandler) {\n const parent = this.stack[this.stack.length - 1]\n /** @type {Array} */\n const siblings = parent.children\n siblings.push(node)\n this.stack.push(node)\n this.tokenStack.push([token, errorHandler])\n node.position = {\n start: point(token.start),\n // @ts-expect-error: `end` will be patched later.\n end: undefined\n }\n }\n\n /**\n * Create a closer handle.\n *\n * @param {Handle | undefined} [and]\n * Optional function to also run.\n * @returns {Handle}\n * Handle.\n */\n function closer(and) {\n return close\n\n /**\n * @this {CompileContext}\n * @param {Token} token\n * @returns {undefined}\n */\n function close(token) {\n if (and) and.call(this, token)\n exit.call(this, token)\n }\n }\n\n /**\n * @this {CompileContext}\n * Context.\n * @param {Token} token\n * Corresponding token.\n * @param {OnExitError | undefined} [onExitError]\n * Handle the case where another token is open.\n * @returns {undefined}\n * Nothing.\n */\n function exit(token, onExitError) {\n const node = this.stack.pop()\n const open = this.tokenStack.pop()\n if (!open) {\n throw new Error(\n 'Cannot close `' +\n token.type +\n '` (' +\n stringifyPosition({\n start: token.start,\n end: token.end\n }) +\n '): it’s not open'\n )\n } else if (open[0].type !== token.type) {\n if (onExitError) {\n onExitError.call(this, token, open[0])\n } else {\n const handler = open[1] || defaultOnError\n handler.call(this, token, open[0])\n }\n }\n node.position.end = point(token.end)\n }\n\n /**\n * @this {CompileContext}\n * @returns {string}\n */\n function resume() {\n return toString(this.stack.pop())\n }\n\n //\n // Handlers.\n //\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistordered() {\n this.data.expectingFirstListItemValue = true\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onenterlistitemvalue(token) {\n if (this.data.expectingFirstListItemValue) {\n const ancestor = this.stack[this.stack.length - 2]\n ancestor.start = Number.parseInt(this.sliceSerialize(token), 10)\n this.data.expectingFirstListItemValue = undefined\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfenceinfo() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.lang = data\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfencemeta() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.meta = data\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefencedfence() {\n // Exit if this is the closing fence.\n if (this.data.flowCodeInside) return\n this.buffer()\n this.data.flowCodeInside = true\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodefenced() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.value = data.replace(/^(\\r?\\n|\\r)|(\\r?\\n|\\r)$/g, '')\n this.data.flowCodeInside = undefined\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcodeindented() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.value = data.replace(/(\\r?\\n|\\r)$/g, '')\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitionlabelstring(token) {\n const label = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.label = label\n node.identifier = normalizeIdentifier(\n this.sliceSerialize(token)\n ).toLowerCase()\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitiontitlestring() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.title = data\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitdefinitiondestinationstring() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.url = data\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitatxheadingsequence(token) {\n const node = this.stack[this.stack.length - 1]\n if (!node.depth) {\n const depth = this.sliceSerialize(token).length\n node.depth = depth\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheadingtext() {\n this.data.setextHeadingSlurpLineEnding = true\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheadinglinesequence(token) {\n const node = this.stack[this.stack.length - 1]\n node.depth = this.sliceSerialize(token).codePointAt(0) === 61 ? 1 : 2\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitsetextheading() {\n this.data.setextHeadingSlurpLineEnding = undefined\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onenterdata(token) {\n const node = this.stack[this.stack.length - 1]\n /** @type {Array} */\n const siblings = node.children\n let tail = siblings[siblings.length - 1]\n if (!tail || tail.type !== 'text') {\n // Add a new text node.\n tail = text()\n tail.position = {\n start: point(token.start),\n // @ts-expect-error: we’ll add `end` later.\n end: undefined\n }\n siblings.push(tail)\n }\n this.stack.push(tail)\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitdata(token) {\n const tail = this.stack.pop()\n tail.value += this.sliceSerialize(token)\n tail.position.end = point(token.end)\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlineending(token) {\n const context = this.stack[this.stack.length - 1]\n // If we’re at a hard break, include the line ending in there.\n if (this.data.atHardBreak) {\n const tail = context.children[context.children.length - 1]\n tail.position.end = point(token.end)\n this.data.atHardBreak = undefined\n return\n }\n if (\n !this.data.setextHeadingSlurpLineEnding &&\n config.canContainEols.includes(context.type)\n ) {\n onenterdata.call(this, token)\n onexitdata.call(this, token)\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexithardbreak() {\n this.data.atHardBreak = true\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexithtmlflow() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.value = data\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexithtmltext() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.value = data\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitcodetext() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.value = data\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlink() {\n const node = this.stack[this.stack.length - 1]\n // Note: there are also `identifier` and `label` fields on this link node!\n // These are used / cleaned here.\n // To do: clean.\n if (this.data.inReference) {\n /** @type {ReferenceType} */\n const referenceType = this.data.referenceType || 'shortcut'\n node.type += 'Reference'\n // @ts-expect-error: mutate.\n node.referenceType = referenceType\n // @ts-expect-error: mutate.\n delete node.url\n delete node.title\n } else {\n // @ts-expect-error: mutate.\n delete node.identifier\n // @ts-expect-error: mutate.\n delete node.label\n }\n this.data.referenceType = undefined\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitimage() {\n const node = this.stack[this.stack.length - 1]\n // Note: there are also `identifier` and `label` fields on this link node!\n // These are used / cleaned here.\n // To do: clean.\n if (this.data.inReference) {\n /** @type {ReferenceType} */\n const referenceType = this.data.referenceType || 'shortcut'\n node.type += 'Reference'\n // @ts-expect-error: mutate.\n node.referenceType = referenceType\n // @ts-expect-error: mutate.\n delete node.url\n delete node.title\n } else {\n // @ts-expect-error: mutate.\n delete node.identifier\n // @ts-expect-error: mutate.\n delete node.label\n }\n this.data.referenceType = undefined\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlabeltext(token) {\n const string = this.sliceSerialize(token)\n const ancestor = this.stack[this.stack.length - 2]\n // @ts-expect-error: stash this on the node, as it might become a reference\n // later.\n ancestor.label = decodeString(string)\n // @ts-expect-error: same as above.\n ancestor.identifier = normalizeIdentifier(string).toLowerCase()\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitlabel() {\n const fragment = this.stack[this.stack.length - 1]\n const value = this.resume()\n const node = this.stack[this.stack.length - 1]\n // Assume a reference.\n this.data.inReference = true\n if (node.type === 'link') {\n /** @type {Array} */\n const children = fragment.children\n node.children = children\n } else {\n node.alt = value\n }\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitresourcedestinationstring() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.url = data\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitresourcetitlestring() {\n const data = this.resume()\n const node = this.stack[this.stack.length - 1]\n node.title = data\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitresource() {\n this.data.inReference = undefined\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onenterreference() {\n this.data.referenceType = 'collapsed'\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitreferencestring(token) {\n const label = this.resume()\n const node = this.stack[this.stack.length - 1]\n // @ts-expect-error: stash this on the node, as it might become a reference\n // later.\n node.label = label\n // @ts-expect-error: same as above.\n node.identifier = normalizeIdentifier(\n this.sliceSerialize(token)\n ).toLowerCase()\n this.data.referenceType = 'full'\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n\n function onexitcharacterreferencemarker(token) {\n this.data.characterReferenceType = token.type\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitcharacterreferencevalue(token) {\n const data = this.sliceSerialize(token)\n const type = this.data.characterReferenceType\n /** @type {string} */\n let value\n if (type) {\n value = decodeNumericCharacterReference(\n data,\n type === 'characterReferenceMarkerNumeric' ? 10 : 16\n )\n this.data.characterReferenceType = undefined\n } else {\n const result = decodeNamedCharacterReference(data)\n value = result\n }\n const tail = this.stack.pop()\n tail.value += value\n tail.position.end = point(token.end)\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitautolinkprotocol(token) {\n onexitdata.call(this, token)\n const node = this.stack[this.stack.length - 1]\n node.url = this.sliceSerialize(token)\n }\n\n /**\n * @this {CompileContext}\n * @type {Handle}\n */\n function onexitautolinkemail(token) {\n onexitdata.call(this, token)\n const node = this.stack[this.stack.length - 1]\n node.url = 'mailto:' + this.sliceSerialize(token)\n }\n\n //\n // Creaters.\n //\n\n /** @returns {Blockquote} */\n function blockQuote() {\n return {\n type: 'blockquote',\n children: []\n }\n }\n\n /** @returns {Code} */\n function codeFlow() {\n return {\n type: 'code',\n lang: null,\n meta: null,\n value: ''\n }\n }\n\n /** @returns {InlineCode} */\n function codeText() {\n return {\n type: 'inlineCode',\n value: ''\n }\n }\n\n /** @returns {Definition} */\n function definition() {\n return {\n type: 'definition',\n identifier: '',\n label: null,\n title: null,\n url: ''\n }\n }\n\n /** @returns {Emphasis} */\n function emphasis() {\n return {\n type: 'emphasis',\n children: []\n }\n }\n\n /** @returns {Heading} */\n function heading() {\n return {\n type: 'heading',\n // @ts-expect-error `depth` will be set later.\n depth: 0,\n children: []\n }\n }\n\n /** @returns {Break} */\n function hardBreak() {\n return {\n type: 'break'\n }\n }\n\n /** @returns {Html} */\n function html() {\n return {\n type: 'html',\n value: ''\n }\n }\n\n /** @returns {Image} */\n function image() {\n return {\n type: 'image',\n title: null,\n url: '',\n alt: null\n }\n }\n\n /** @returns {Link} */\n function link() {\n return {\n type: 'link',\n title: null,\n url: '',\n children: []\n }\n }\n\n /**\n * @param {Token} token\n * @returns {List}\n */\n function list(token) {\n return {\n type: 'list',\n ordered: token.type === 'listOrdered',\n start: null,\n spread: token._spread,\n children: []\n }\n }\n\n /**\n * @param {Token} token\n * @returns {ListItem}\n */\n function listItem(token) {\n return {\n type: 'listItem',\n spread: token._spread,\n checked: null,\n children: []\n }\n }\n\n /** @returns {Paragraph} */\n function paragraph() {\n return {\n type: 'paragraph',\n children: []\n }\n }\n\n /** @returns {Strong} */\n function strong() {\n return {\n type: 'strong',\n children: []\n }\n }\n\n /** @returns {Text} */\n function text() {\n return {\n type: 'text',\n value: ''\n }\n }\n\n /** @returns {ThematicBreak} */\n function thematicBreak() {\n return {\n type: 'thematicBreak'\n }\n }\n}\n\n/**\n * Copy a point-like value.\n *\n * @param {Point} d\n * Point-like value.\n * @returns {Point}\n * unist point.\n */\nfunction point(d) {\n return {\n line: d.line,\n column: d.column,\n offset: d.offset\n }\n}\n\n/**\n * @param {Config} combined\n * @param {Array | Extension>} extensions\n * @returns {undefined}\n */\nfunction configure(combined, extensions) {\n let index = -1\n while (++index < extensions.length) {\n const value = extensions[index]\n if (Array.isArray(value)) {\n configure(combined, value)\n } else {\n extension(combined, value)\n }\n }\n}\n\n/**\n * @param {Config} combined\n * @param {Extension} extension\n * @returns {undefined}\n */\nfunction extension(combined, extension) {\n /** @type {keyof Extension} */\n let key\n for (key in extension) {\n if (own.call(extension, key)) {\n switch (key) {\n case 'canContainEols': {\n const right = extension[key]\n if (right) {\n combined[key].push(...right)\n }\n break\n }\n case 'transforms': {\n const right = extension[key]\n if (right) {\n combined[key].push(...right)\n }\n break\n }\n case 'enter':\n case 'exit': {\n const right = extension[key]\n if (right) {\n Object.assign(combined[key], right)\n }\n break\n }\n // No default\n }\n }\n }\n}\n\n/** @type {OnEnterError} */\nfunction defaultOnError(left, right) {\n if (left) {\n throw new Error(\n 'Cannot close `' +\n left.type +\n '` (' +\n stringifyPosition({\n start: left.start,\n end: left.end\n }) +\n '): a different token (`' +\n right.type +\n '`, ' +\n stringifyPosition({\n start: right.start,\n end: right.end\n }) +\n ') is open'\n )\n } else {\n throw new Error(\n 'Cannot close document, a token (`' +\n right.type +\n '`, ' +\n stringifyPosition({\n start: right.start,\n end: right.end\n }) +\n ') is still open'\n )\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Event} Event\n */\n\nimport {subtokenize} from 'micromark-util-subtokenize'\n\n/**\n * @param {Array} events\n * @returns {Array}\n */\nexport function postprocess(events) {\n while (!subtokenize(events)) {\n // Empty\n }\n return events\n}\n","/**\n * @typedef {import('micromark-util-types').Create} Create\n * @typedef {import('micromark-util-types').FullNormalizedExtension} FullNormalizedExtension\n * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct\n * @typedef {import('micromark-util-types').ParseContext} ParseContext\n * @typedef {import('micromark-util-types').ParseOptions} ParseOptions\n */\n\nimport {combineExtensions} from 'micromark-util-combine-extensions'\nimport {content} from './initialize/content.js'\nimport {document} from './initialize/document.js'\nimport {flow} from './initialize/flow.js'\nimport {string, text} from './initialize/text.js'\nimport {createTokenizer} from './create-tokenizer.js'\nimport * as defaultConstructs from './constructs.js'\n\n/**\n * @param {ParseOptions | null | undefined} [options]\n * @returns {ParseContext}\n */\nexport function parse(options) {\n const settings = options || {}\n const constructs =\n /** @type {FullNormalizedExtension} */\n combineExtensions([defaultConstructs, ...(settings.extensions || [])])\n\n /** @type {ParseContext} */\n const parser = {\n defined: [],\n lazy: {},\n constructs,\n content: create(content),\n document: create(document),\n flow: create(flow),\n string: create(string),\n text: create(text)\n }\n return parser\n\n /**\n * @param {InitialConstruct} initial\n */\n function create(initial) {\n return creator\n /** @type {Create} */\n function creator(from) {\n return createTokenizer(parser, initial, from)\n }\n }\n}\n","/**\n * @typedef {import('mdast').Root} Root\n * @typedef {import('mdast-util-from-markdown').Options} FromMarkdownOptions\n * @typedef {import('unified').Parser} Parser\n * @typedef {import('unified').Processor} Processor\n */\n\n/**\n * @typedef {Omit} Options\n */\n\nimport {fromMarkdown} from 'mdast-util-from-markdown'\n\n/**\n * Aadd support for parsing from markdown.\n *\n * @param {Readonly | null | undefined} [options]\n * Configuration (optional).\n * @returns {undefined}\n * Nothing.\n */\nexport default function remarkParse(options) {\n /** @type {Processor} */\n // @ts-expect-error: TS in JSDoc generates wrong types if `this` is typed regularly.\n const self = this\n\n self.parser = parser\n\n /**\n * @type {Parser}\n */\n function parser(doc) {\n return fromMarkdown(doc, {\n ...self.data('settings'),\n ...options,\n // Note: these options are not in the readme.\n // The goal is for them to be set by plugins on `data` instead of being\n // passed by users.\n extensions: self.data('micromarkExtensions') || [],\n mdastExtensions: self.data('fromMarkdownExtensions') || []\n })\n }\n}\n","export const VOID = -1;\nexport const PRIMITIVE = 0;\nexport const ARRAY = 1;\nexport const OBJECT = 2;\nexport const DATE = 3;\nexport const REGEXP = 4;\nexport const MAP = 5;\nexport const SET = 6;\nexport const ERROR = 7;\nexport const BIGINT = 8;\n// export const SYMBOL = 9;\n","import {\n VOID, PRIMITIVE,\n ARRAY, OBJECT,\n DATE, REGEXP, MAP, SET,\n ERROR, BIGINT\n} from './types.js';\n\nconst env = typeof self === 'object' ? self : globalThis;\n\nconst deserializer = ($, _) => {\n const as = (out, index) => {\n $.set(index, out);\n return out;\n };\n\n const unpair = index => {\n if ($.has(index))\n return $.get(index);\n\n const [type, value] = _[index];\n switch (type) {\n case PRIMITIVE:\n case VOID:\n return as(value, index);\n case ARRAY: {\n const arr = as([], index);\n for (const index of value)\n arr.push(unpair(index));\n return arr;\n }\n case OBJECT: {\n const object = as({}, index);\n for (const [key, index] of value)\n object[unpair(key)] = unpair(index);\n return object;\n }\n case DATE:\n return as(new Date(value), index);\n case REGEXP: {\n const {source, flags} = value;\n return as(new RegExp(source, flags), index);\n }\n case MAP: {\n const map = as(new Map, index);\n for (const [key, index] of value)\n map.set(unpair(key), unpair(index));\n return map;\n }\n case SET: {\n const set = as(new Set, index);\n for (const index of value)\n set.add(unpair(index));\n return set;\n }\n case ERROR: {\n const {name, message} = value;\n return as(new env[name](message), index);\n }\n case BIGINT:\n return as(BigInt(value), index);\n case 'BigInt':\n return as(Object(BigInt(value)), index);\n }\n return as(new env[type](value), index);\n };\n\n return unpair;\n};\n\n/**\n * @typedef {Array} Record a type representation\n */\n\n/**\n * Returns a deserialized value from a serialized array of Records.\n * @param {Record[]} serialized a previously serialized value.\n * @returns {any}\n */\nexport const deserialize = serialized => deserializer(new Map, serialized)(0);\n","import {\n VOID, PRIMITIVE,\n ARRAY, OBJECT,\n DATE, REGEXP, MAP, SET,\n ERROR, BIGINT\n} from './types.js';\n\nconst EMPTY = '';\n\nconst {toString} = {};\nconst {keys} = Object;\n\nconst typeOf = value => {\n const type = typeof value;\n if (type !== 'object' || !value)\n return [PRIMITIVE, type];\n\n const asString = toString.call(value).slice(8, -1);\n switch (asString) {\n case 'Array':\n return [ARRAY, EMPTY];\n case 'Object':\n return [OBJECT, EMPTY];\n case 'Date':\n return [DATE, EMPTY];\n case 'RegExp':\n return [REGEXP, EMPTY];\n case 'Map':\n return [MAP, EMPTY];\n case 'Set':\n return [SET, EMPTY];\n }\n\n if (asString.includes('Array'))\n return [ARRAY, asString];\n\n if (asString.includes('Error'))\n return [ERROR, asString];\n\n return [OBJECT, asString];\n};\n\nconst shouldSkip = ([TYPE, type]) => (\n TYPE === PRIMITIVE &&\n (type === 'function' || type === 'symbol')\n);\n\nconst serializer = (strict, json, $, _) => {\n\n const as = (out, value) => {\n const index = _.push(out) - 1;\n $.set(value, index);\n return index;\n };\n\n const pair = value => {\n if ($.has(value))\n return $.get(value);\n\n let [TYPE, type] = typeOf(value);\n switch (TYPE) {\n case PRIMITIVE: {\n let entry = value;\n switch (type) {\n case 'bigint':\n TYPE = BIGINT;\n entry = value.toString();\n break;\n case 'function':\n case 'symbol':\n if (strict)\n throw new TypeError('unable to serialize ' + type);\n entry = null;\n break;\n case 'undefined':\n return as([VOID], value);\n }\n return as([TYPE, entry], value);\n }\n case ARRAY: {\n if (type)\n return as([type, [...value]], value);\n \n const arr = [];\n const index = as([TYPE, arr], value);\n for (const entry of value)\n arr.push(pair(entry));\n return index;\n }\n case OBJECT: {\n if (type) {\n switch (type) {\n case 'BigInt':\n return as([type, value.toString()], value);\n case 'Boolean':\n case 'Number':\n case 'String':\n return as([type, value.valueOf()], value);\n }\n }\n\n if (json && ('toJSON' in value))\n return pair(value.toJSON());\n\n const entries = [];\n const index = as([TYPE, entries], value);\n for (const key of keys(value)) {\n if (strict || !shouldSkip(typeOf(value[key])))\n entries.push([pair(key), pair(value[key])]);\n }\n return index;\n }\n case DATE:\n return as([TYPE, value.toISOString()], value);\n case REGEXP: {\n const {source, flags} = value;\n return as([TYPE, {source, flags}], value);\n }\n case MAP: {\n const entries = [];\n const index = as([TYPE, entries], value);\n for (const [key, entry] of value) {\n if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry))))\n entries.push([pair(key), pair(entry)]);\n }\n return index;\n }\n case SET: {\n const entries = [];\n const index = as([TYPE, entries], value);\n for (const entry of value) {\n if (strict || !shouldSkip(typeOf(entry)))\n entries.push(pair(entry));\n }\n return index;\n }\n }\n\n const {message} = value;\n return as([TYPE, {name: type, message}], value);\n };\n\n return pair;\n};\n\n/**\n * @typedef {Array} Record a type representation\n */\n\n/**\n * Returns an array of serialized Records.\n * @param {any} value a serializable value.\n * @param {{json?: boolean, lossy?: boolean}?} options an object with a `lossy` or `json` property that,\n * if `true`, will not throw errors on incompatible types, and behave more\n * like JSON stringify would behave. Symbol and Function will be discarded.\n * @returns {Record[]}\n */\n export const serialize = (value, {json, lossy} = {}) => {\n const _ = [];\n return serializer(!(json || lossy), !!json, new Map, _)(value), _;\n};\n","import {deserialize} from './deserialize.js';\nimport {serialize} from './serialize.js';\n\n/**\n * @typedef {Array} Record a type representation\n */\n\n/**\n * Returns an array of serialized Records.\n * @param {any} any a serializable value.\n * @param {{transfer?: any[], json?: boolean, lossy?: boolean}?} options an object with\n * a transfer option (ignored when polyfilled) and/or non standard fields that\n * fallback to the polyfill if present.\n * @returns {Record[]}\n */\nexport default typeof structuredClone === \"function\" ?\n /* c8 ignore start */\n (any, options) => (\n options && ('json' in options || 'lossy' in options) ?\n deserialize(serialize(any, options)) : structuredClone(any)\n ) :\n (any, options) => deserialize(serialize(any, options));\n /* c8 ignore stop */\n\nexport {deserialize, serialize};\n","import {asciiAlphanumeric} from 'micromark-util-character'\nimport {encode} from 'micromark-util-encode'\n/**\n * Make a value safe for injection as a URL.\n *\n * This encodes unsafe characters with percent-encoding and skips already\n * encoded sequences (see `normalizeUri`).\n * Further unsafe characters are encoded as character references (see\n * `micromark-util-encode`).\n *\n * A regex of allowed protocols can be given, in which case the URL is\n * sanitized.\n * For example, `/^(https?|ircs?|mailto|xmpp)$/i` can be used for `a[href]`, or\n * `/^https?$/i` for `img[src]` (this is what `github.com` allows).\n * If the URL includes an unknown protocol (one not matched by `protocol`, such\n * as a dangerous example, `javascript:`), the value is ignored.\n *\n * @param {string | null | undefined} url\n * URI to sanitize.\n * @param {RegExp | null | undefined} [protocol]\n * Allowed protocols.\n * @returns {string}\n * Sanitized URI.\n */\nexport function sanitizeUri(url, protocol) {\n const value = encode(normalizeUri(url || ''))\n if (!protocol) {\n return value\n }\n const colon = value.indexOf(':')\n const questionMark = value.indexOf('?')\n const numberSign = value.indexOf('#')\n const slash = value.indexOf('/')\n if (\n // If there is no protocol, it’s relative.\n colon < 0 ||\n // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.\n (slash > -1 && colon > slash) ||\n (questionMark > -1 && colon > questionMark) ||\n (numberSign > -1 && colon > numberSign) ||\n // It is a protocol, it should be allowed.\n protocol.test(value.slice(0, colon))\n ) {\n return value\n }\n return ''\n}\n\n/**\n * Normalize a URL.\n *\n * Encode unsafe characters with percent-encoding, skipping already encoded\n * sequences.\n *\n * @param {string} value\n * URI to normalize.\n * @returns {string}\n * Normalized URI.\n */\nexport function normalizeUri(value) {\n /** @type {Array} */\n const result = []\n let index = -1\n let start = 0\n let skip = 0\n while (++index < value.length) {\n const code = value.charCodeAt(index)\n /** @type {string} */\n let replace = ''\n\n // A correct percent encoded value.\n if (\n code === 37 &&\n asciiAlphanumeric(value.charCodeAt(index + 1)) &&\n asciiAlphanumeric(value.charCodeAt(index + 2))\n ) {\n skip = 2\n }\n // ASCII.\n else if (code < 128) {\n if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) {\n replace = String.fromCharCode(code)\n }\n }\n // Astral.\n else if (code > 55_295 && code < 57_344) {\n const next = value.charCodeAt(index + 1)\n\n // A correct surrogate pair.\n if (code < 56_320 && next > 56_319 && next < 57_344) {\n replace = String.fromCharCode(code, next)\n skip = 1\n }\n // Lone surrogate.\n else {\n replace = '\\uFFFD'\n }\n }\n // Unicode.\n else {\n replace = String.fromCharCode(code)\n }\n if (replace) {\n result.push(value.slice(start, index), encodeURIComponent(replace))\n start = index + skip + 1\n replace = ''\n }\n if (skip) {\n index += skip\n skip = 0\n }\n }\n return result.join('') + value.slice(start)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').ElementContent} ElementContent\n *\n * @typedef {import('./state.js').State} State\n */\n\n/**\n * @callback FootnoteBackContentTemplate\n * Generate content for the backreference dynamically.\n *\n * For the following markdown:\n *\n * ```markdown\n * Alpha[^micromark], bravo[^micromark], and charlie[^remark].\n *\n * [^remark]: things about remark\n * [^micromark]: things about micromark\n * ```\n *\n * This function will be called with:\n *\n * * `0` and `0` for the backreference from `things about micromark` to\n * `alpha`, as it is the first used definition, and the first call to it\n * * `0` and `1` for the backreference from `things about micromark` to\n * `bravo`, as it is the first used definition, and the second call to it\n * * `1` and `0` for the backreference from `things about remark` to\n * `charlie`, as it is the second used definition\n * @param {number} referenceIndex\n * Index of the definition in the order that they are first referenced,\n * 0-indexed.\n * @param {number} rereferenceIndex\n * Index of calls to the same definition, 0-indexed.\n * @returns {Array | ElementContent | string}\n * Content for the backreference when linking back from definitions to their\n * reference.\n *\n * @callback FootnoteBackLabelTemplate\n * Generate a back label dynamically.\n *\n * For the following markdown:\n *\n * ```markdown\n * Alpha[^micromark], bravo[^micromark], and charlie[^remark].\n *\n * [^remark]: things about remark\n * [^micromark]: things about micromark\n * ```\n *\n * This function will be called with:\n *\n * * `0` and `0` for the backreference from `things about micromark` to\n * `alpha`, as it is the first used definition, and the first call to it\n * * `0` and `1` for the backreference from `things about micromark` to\n * `bravo`, as it is the first used definition, and the second call to it\n * * `1` and `0` for the backreference from `things about remark` to\n * `charlie`, as it is the second used definition\n * @param {number} referenceIndex\n * Index of the definition in the order that they are first referenced,\n * 0-indexed.\n * @param {number} rereferenceIndex\n * Index of calls to the same definition, 0-indexed.\n * @returns {string}\n * Back label to use when linking back from definitions to their reference.\n */\n\nimport structuredClone from '@ungap/structured-clone'\nimport {normalizeUri} from 'micromark-util-sanitize-uri'\n\n/**\n * Generate the default content that GitHub uses on backreferences.\n *\n * @param {number} _\n * Index of the definition in the order that they are first referenced,\n * 0-indexed.\n * @param {number} rereferenceIndex\n * Index of calls to the same definition, 0-indexed.\n * @returns {Array}\n * Content.\n */\nexport function defaultFootnoteBackContent(_, rereferenceIndex) {\n /** @type {Array} */\n const result = [{type: 'text', value: '↩'}]\n\n if (rereferenceIndex > 1) {\n result.push({\n type: 'element',\n tagName: 'sup',\n properties: {},\n children: [{type: 'text', value: String(rereferenceIndex)}]\n })\n }\n\n return result\n}\n\n/**\n * Generate the default label that GitHub uses on backreferences.\n *\n * @param {number} referenceIndex\n * Index of the definition in the order that they are first referenced,\n * 0-indexed.\n * @param {number} rereferenceIndex\n * Index of calls to the same definition, 0-indexed.\n * @returns {string}\n * Label.\n */\nexport function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) {\n return (\n 'Back to reference ' +\n (referenceIndex + 1) +\n (rereferenceIndex > 1 ? '-' + rereferenceIndex : '')\n )\n}\n\n/**\n * Generate a hast footer for called footnote definitions.\n *\n * @param {State} state\n * Info passed around.\n * @returns {Element | undefined}\n * `section` element or `undefined`.\n */\n// eslint-disable-next-line complexity\nexport function footer(state) {\n const clobberPrefix =\n typeof state.options.clobberPrefix === 'string'\n ? state.options.clobberPrefix\n : 'user-content-'\n const footnoteBackContent =\n state.options.footnoteBackContent || defaultFootnoteBackContent\n const footnoteBackLabel =\n state.options.footnoteBackLabel || defaultFootnoteBackLabel\n const footnoteLabel = state.options.footnoteLabel || 'Footnotes'\n const footnoteLabelTagName = state.options.footnoteLabelTagName || 'h2'\n const footnoteLabelProperties = state.options.footnoteLabelProperties || {\n className: ['sr-only']\n }\n /** @type {Array} */\n const listItems = []\n let referenceIndex = -1\n\n while (++referenceIndex < state.footnoteOrder.length) {\n const def = state.footnoteById.get(state.footnoteOrder[referenceIndex])\n\n if (!def) {\n continue\n }\n\n const content = state.all(def)\n const id = String(def.identifier).toUpperCase()\n const safeId = normalizeUri(id.toLowerCase())\n let rereferenceIndex = 0\n /** @type {Array} */\n const backReferences = []\n const counts = state.footnoteCounts.get(id)\n\n // eslint-disable-next-line no-unmodified-loop-condition\n while (counts !== undefined && ++rereferenceIndex <= counts) {\n if (backReferences.length > 0) {\n backReferences.push({type: 'text', value: ' '})\n }\n\n let children =\n typeof footnoteBackContent === 'string'\n ? footnoteBackContent\n : footnoteBackContent(referenceIndex, rereferenceIndex)\n\n if (typeof children === 'string') {\n children = {type: 'text', value: children}\n }\n\n backReferences.push({\n type: 'element',\n tagName: 'a',\n properties: {\n href:\n '#' +\n clobberPrefix +\n 'fnref-' +\n safeId +\n (rereferenceIndex > 1 ? '-' + rereferenceIndex : ''),\n dataFootnoteBackref: '',\n ariaLabel:\n typeof footnoteBackLabel === 'string'\n ? footnoteBackLabel\n : footnoteBackLabel(referenceIndex, rereferenceIndex),\n className: ['data-footnote-backref']\n },\n children: Array.isArray(children) ? children : [children]\n })\n }\n\n const tail = content[content.length - 1]\n\n if (tail && tail.type === 'element' && tail.tagName === 'p') {\n const tailTail = tail.children[tail.children.length - 1]\n if (tailTail && tailTail.type === 'text') {\n tailTail.value += ' '\n } else {\n tail.children.push({type: 'text', value: ' '})\n }\n\n tail.children.push(...backReferences)\n } else {\n content.push(...backReferences)\n }\n\n /** @type {Element} */\n const listItem = {\n type: 'element',\n tagName: 'li',\n properties: {id: clobberPrefix + 'fn-' + safeId},\n children: state.wrap(content, true)\n }\n\n state.patch(def, listItem)\n\n listItems.push(listItem)\n }\n\n if (listItems.length === 0) {\n return\n }\n\n return {\n type: 'element',\n tagName: 'section',\n properties: {dataFootnotes: true, className: ['footnotes']},\n children: [\n {\n type: 'element',\n tagName: footnoteLabelTagName,\n properties: {\n ...structuredClone(footnoteLabelProperties),\n id: 'footnote-label'\n },\n children: [{type: 'text', value: footnoteLabel}]\n },\n {type: 'text', value: '\\n'},\n {\n type: 'element',\n tagName: 'ol',\n properties: {},\n children: state.wrap(listItems, true)\n },\n {type: 'text', value: '\\n'}\n ]\n }\n}\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n */\n\n/**\n * @template Fn\n * @template Fallback\n * @typedef {Fn extends (value: any) => value is infer Thing ? Thing : Fallback} Predicate\n */\n\n/**\n * @callback Check\n * Check that an arbitrary value is a node.\n * @param {unknown} this\n * The given context.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean}\n * Whether this is a node and passes a test.\n *\n * @typedef {Record | Node} Props\n * Object to check for equivalence.\n *\n * Note: `Node` is included as it is common but is not indexable.\n *\n * @typedef {Array | Props | TestFunction | string | null | undefined} Test\n * Check for an arbitrary node.\n *\n * @callback TestFunction\n * Check if a node passes a test.\n * @param {unknown} this\n * The given context.\n * @param {Node} node\n * A node.\n * @param {number | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | undefined} [parent]\n * The node’s parent.\n * @returns {boolean | undefined | void}\n * Whether this node passes the test.\n *\n * Note: `void` is included until TS sees no return as `undefined`.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param {unknown} node\n * Thing to check, typically `Node`.\n * @param {Test} test\n * A check for a specific node.\n * @param {number | null | undefined} index\n * The node’s position in its parent.\n * @param {Parent | null | undefined} parent\n * The node’s parent.\n * @param {unknown} context\n * Context object (`this`) to pass to `test` functions.\n * @returns {boolean}\n * Whether `node` is a node and passes a test.\n */\nexport const is =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * ((node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * ((node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * ((node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate) &\n * ((node?: null | undefined) => false) &\n * ((node: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((node: unknown, test?: Test, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => boolean)\n * )}\n */\n (\n /**\n * @param {unknown} [node]\n * @param {Test} [test]\n * @param {number | null | undefined} [index]\n * @param {Parent | null | undefined} [parent]\n * @param {unknown} [context]\n * @returns {boolean}\n */\n // eslint-disable-next-line max-params\n function (node, test, index, parent, context) {\n const check = convert(test)\n\n if (\n index !== undefined &&\n index !== null &&\n (typeof index !== 'number' ||\n index < 0 ||\n index === Number.POSITIVE_INFINITY)\n ) {\n throw new Error('Expected positive finite index')\n }\n\n if (\n parent !== undefined &&\n parent !== null &&\n (!is(parent) || !parent.children)\n ) {\n throw new Error('Expected parent node')\n }\n\n if (\n (parent === undefined || parent === null) !==\n (index === undefined || index === null)\n ) {\n throw new Error('Expected both parent and index')\n }\n\n return looksLikeANode(node)\n ? check.call(context, node, index, parent)\n : false\n }\n )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param {Test} test\n * * when nullish, checks if `node` is a `Node`.\n * * when `string`, works like passing `(node) => node.type === test`.\n * * when `function` checks if function passed the node is true.\n * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n * * when `array`, checks if any one of the subtests pass.\n * @returns {Check}\n * An assertion.\n */\nexport const convert =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * ((test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * ((test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * ((test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate) &\n * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((test?: Test) => Check)\n * )}\n */\n (\n /**\n * @param {Test} [test]\n * @returns {Check}\n */\n function (test) {\n if (test === null || test === undefined) {\n return ok\n }\n\n if (typeof test === 'function') {\n return castFactory(test)\n }\n\n if (typeof test === 'object') {\n return Array.isArray(test) ? anyFactory(test) : propsFactory(test)\n }\n\n if (typeof test === 'string') {\n return typeFactory(test)\n }\n\n throw new Error('Expected function, string, or object as test')\n }\n )\n\n/**\n * @param {Array} tests\n * @returns {Check}\n */\nfunction anyFactory(tests) {\n /** @type {Array} */\n const checks = []\n let index = -1\n\n while (++index < tests.length) {\n checks[index] = convert(tests[index])\n }\n\n return castFactory(any)\n\n /**\n * @this {unknown}\n * @type {TestFunction}\n */\n function any(...parameters) {\n let index = -1\n\n while (++index < checks.length) {\n if (checks[index].apply(this, parameters)) return true\n }\n\n return false\n }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {Check}\n */\nfunction propsFactory(check) {\n const checkAsRecord = /** @type {Record} */ (check)\n\n return castFactory(all)\n\n /**\n * @param {Node} node\n * @returns {boolean}\n */\n function all(node) {\n const nodeAsRecord = /** @type {Record} */ (\n /** @type {unknown} */ (node)\n )\n\n /** @type {string} */\n let key\n\n for (key in check) {\n if (nodeAsRecord[key] !== checkAsRecord[key]) return false\n }\n\n return true\n }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {Check}\n */\nfunction typeFactory(check) {\n return castFactory(type)\n\n /**\n * @param {Node} node\n */\n function type(node) {\n return node && node.type === check\n }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunction} testFunction\n * @returns {Check}\n */\nfunction castFactory(testFunction) {\n return check\n\n /**\n * @this {unknown}\n * @type {Check}\n */\n function check(value, index, parent) {\n return Boolean(\n looksLikeANode(value) &&\n testFunction.call(\n this,\n value,\n typeof index === 'number' ? index : undefined,\n parent || undefined\n )\n )\n }\n}\n\nfunction ok() {\n return true\n}\n\n/**\n * @param {unknown} value\n * @returns {value is Node}\n */\nfunction looksLikeANode(value) {\n return value !== null && typeof value === 'object' && 'type' in value\n}\n","/**\n * @typedef {import('unist').Node} UnistNode\n * @typedef {import('unist').Parent} UnistParent\n */\n\n/**\n * @typedef {Exclude | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate extends Value\n * ? Predicate\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends Array\n * ? MatchesOne\n * : MatchesOne\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent\n * | InternalAncestor, Max, Increment>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {InternalAncestor, Child>} Ancestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {'skip' | boolean} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [VisitedParents=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor, Check>, Ancestor, Check>>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n * @template {UnistNode} [Tree=UnistNode]\n * Tree type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from 'unist-util-visit-parents/do-not-use-color'\n\n/** @type {Readonly} */\nconst empty = []\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} test\n * `unist-util-is`-compatible test\n * @param {Visitor | boolean | null | undefined} [visitor]\n * Handle each node.\n * @param {boolean | null | undefined} [reverse]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visitParents(tree, test, visitor, reverse) {\n /** @type {Test} */\n let check\n\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n } else {\n // @ts-expect-error visitor given, so `test` isn’t a visitor.\n check = test\n }\n\n const is = convert(check)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {UnistNode} node\n * @param {number | undefined} index\n * @param {Array} parents\n */\n function factory(node, index, parents) {\n const value = /** @type {Record} */ (\n node && typeof node === 'object' ? node : {}\n )\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {Readonly} */\n let result = empty\n /** @type {Readonly} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || undefined)) {\n // @ts-expect-error: `visitor` is now a visitor.\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n if ('children' in node && node.children) {\n const nodeAsParent = /** @type {UnistParent} */ (node)\n\n if (nodeAsParent.children && result[0] !== SKIP) {\n offset = (reverse ? nodeAsParent.children.length : -1) + step\n grandparents = parents.concat(nodeAsParent)\n\n while (offset > -1 && offset < nodeAsParent.children.length) {\n const child = nodeAsParent.children[offset]\n\n subresult = factory(child, offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n }\n\n return result\n }\n }\n}\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {Readonly}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return value === null || value === undefined ? empty : [value]\n}\n","/**\n * @typedef {import('unist').Node} UnistNode\n * @typedef {import('unist').Parent} UnistParent\n * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult\n */\n\n/**\n * @typedef {Exclude | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n// To do: use types from `unist-util-visit-parents` when it’s released.\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate extends Value\n * ? Predicate\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends Array\n * ? MatchesOne\n * : MatchesOne\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent\n * | InternalAncestor, Max, Increment>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform `parent`.\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of `parent` still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor>} BuildVisitorFromMatch\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Visited\n * Node type.\n * @template {UnistParent} Ancestor\n * Parent type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromMatch<\n * Matches,\n * Extract\n * >\n * )} BuildVisitorFromDescendants\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromDescendants<\n * InclusiveDescendant,\n * Check\n * >\n * )} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} testOrVisitor\n * `unist-util-is`-compatible test (optional, omit to pass a visitor).\n * @param {Visitor | boolean | null | undefined} [visitorOrReverse]\n * Handle each node (when test is omitted, pass `reverse`).\n * @param {boolean | null | undefined} [maybeReverse=false]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {\n /** @type {boolean | null | undefined} */\n let reverse\n /** @type {Test} */\n let test\n /** @type {Visitor} */\n let visitor\n\n if (\n typeof testOrVisitor === 'function' &&\n typeof visitorOrReverse !== 'function'\n ) {\n test = undefined\n visitor = testOrVisitor\n reverse = visitorOrReverse\n } else {\n // @ts-expect-error: assume the overload with test was given.\n test = testOrVisitor\n // @ts-expect-error: assume the overload with test was given.\n visitor = visitorOrReverse\n reverse = maybeReverse\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {UnistNode} node\n * @param {Array} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n const index = parent ? parent.children.indexOf(node) : undefined\n return visitor(node, index, parent)\n }\n}\n","/**\n * @typedef {import('hast').ElementContent} ElementContent\n *\n * @typedef {import('mdast').Nodes} Nodes\n * @typedef {import('mdast').Reference} Reference\n *\n * @typedef {import('./state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Return the content of a reference without definition as plain text.\n *\n * @param {State} state\n * Info passed around.\n * @param {Extract} node\n * Reference node (image, link).\n * @returns {Array}\n * hast content.\n */\nexport function revert(state, node) {\n const subtype = node.referenceType\n let suffix = ']'\n\n if (subtype === 'collapsed') {\n suffix += '[]'\n } else if (subtype === 'full') {\n suffix += '[' + (node.label || node.identifier) + ']'\n }\n\n if (node.type === 'imageReference') {\n return [{type: 'text', value: '![' + node.alt + suffix}]\n }\n\n const contents = state.all(node)\n const head = contents[0]\n\n if (head && head.type === 'text') {\n head.value = '[' + head.value\n } else {\n contents.unshift({type: 'text', value: '['})\n }\n\n const tail = contents[contents.length - 1]\n\n if (tail && tail.type === 'text') {\n tail.value += suffix\n } else {\n contents.push({type: 'text', value: suffix})\n }\n\n return contents\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').ElementContent} ElementContent\n * @typedef {import('hast').Properties} Properties\n * @typedef {import('mdast').ListItem} ListItem\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `listItem` node into hast.\n *\n * @param {State} state\n * Info passed around.\n * @param {ListItem} node\n * mdast node.\n * @param {Parents | undefined} parent\n * Parent of `node`.\n * @returns {Element}\n * hast node.\n */\nexport function listItem(state, node, parent) {\n const results = state.all(node)\n const loose = parent ? listLoose(parent) : listItemLoose(node)\n /** @type {Properties} */\n const properties = {}\n /** @type {Array} */\n const children = []\n\n if (typeof node.checked === 'boolean') {\n const head = results[0]\n /** @type {Element} */\n let paragraph\n\n if (head && head.type === 'element' && head.tagName === 'p') {\n paragraph = head\n } else {\n paragraph = {type: 'element', tagName: 'p', properties: {}, children: []}\n results.unshift(paragraph)\n }\n\n if (paragraph.children.length > 0) {\n paragraph.children.unshift({type: 'text', value: ' '})\n }\n\n paragraph.children.unshift({\n type: 'element',\n tagName: 'input',\n properties: {type: 'checkbox', checked: node.checked, disabled: true},\n children: []\n })\n\n // According to github-markdown-css, this class hides bullet.\n // See: .\n properties.className = ['task-list-item']\n }\n\n let index = -1\n\n while (++index < results.length) {\n const child = results[index]\n\n // Add eols before nodes, except if this is a loose, first paragraph.\n if (\n loose ||\n index !== 0 ||\n child.type !== 'element' ||\n child.tagName !== 'p'\n ) {\n children.push({type: 'text', value: '\\n'})\n }\n\n if (child.type === 'element' && child.tagName === 'p' && !loose) {\n children.push(...child.children)\n } else {\n children.push(child)\n }\n }\n\n const tail = results[results.length - 1]\n\n // Add a final eol.\n if (tail && (loose || tail.type !== 'element' || tail.tagName !== 'p')) {\n children.push({type: 'text', value: '\\n'})\n }\n\n /** @type {Element} */\n const result = {type: 'element', tagName: 'li', properties, children}\n state.patch(node, result)\n return state.applyData(node, result)\n}\n\n/**\n * @param {Parents} node\n * @return {Boolean}\n */\nfunction listLoose(node) {\n let loose = false\n if (node.type === 'list') {\n loose = node.spread || false\n const children = node.children\n let index = -1\n\n while (!loose && ++index < children.length) {\n loose = listItemLoose(children[index])\n }\n }\n\n return loose\n}\n\n/**\n * @param {ListItem} node\n * @return {Boolean}\n */\nfunction listItemLoose(node) {\n const spread = node.spread\n\n return spread === null || spread === undefined\n ? node.children.length > 1\n : spread\n}\n","const tab = 9 /* `\\t` */\nconst space = 32 /* ` ` */\n\n/**\n * Remove initial and final spaces and tabs at the line breaks in `value`.\n * Does not trim initial and final spaces and tabs of the value itself.\n *\n * @param {string} value\n * Value to trim.\n * @returns {string}\n * Trimmed value.\n */\nexport function trimLines(value) {\n const source = String(value)\n const search = /\\r?\\n|\\r/g\n let match = search.exec(source)\n let last = 0\n /** @type {Array} */\n const lines = []\n\n while (match) {\n lines.push(\n trimLine(source.slice(last, match.index), last > 0, true),\n match[0]\n )\n\n last = match.index + match[0].length\n match = search.exec(source)\n }\n\n lines.push(trimLine(source.slice(last), last > 0, false))\n\n return lines.join('')\n}\n\n/**\n * @param {string} value\n * Line to trim.\n * @param {boolean} start\n * Whether to trim the start of the line.\n * @param {boolean} end\n * Whether to trim the end of the line.\n * @returns {string}\n * Trimmed line.\n */\nfunction trimLine(value, start, end) {\n let startIndex = 0\n let endIndex = value.length\n\n if (start) {\n let code = value.codePointAt(startIndex)\n\n while (code === tab || code === space) {\n startIndex++\n code = value.codePointAt(startIndex)\n }\n }\n\n if (end) {\n let code = value.codePointAt(endIndex - 1)\n\n while (code === tab || code === space) {\n endIndex--\n code = value.codePointAt(endIndex - 1)\n }\n }\n\n return endIndex > startIndex ? value.slice(startIndex, endIndex) : ''\n}\n","import {blockquote} from './blockquote.js'\nimport {hardBreak} from './break.js'\nimport {code} from './code.js'\nimport {strikethrough} from './delete.js'\nimport {emphasis} from './emphasis.js'\nimport {footnoteReference} from './footnote-reference.js'\nimport {heading} from './heading.js'\nimport {html} from './html.js'\nimport {imageReference} from './image-reference.js'\nimport {image} from './image.js'\nimport {inlineCode} from './inline-code.js'\nimport {linkReference} from './link-reference.js'\nimport {link} from './link.js'\nimport {listItem} from './list-item.js'\nimport {list} from './list.js'\nimport {paragraph} from './paragraph.js'\nimport {root} from './root.js'\nimport {strong} from './strong.js'\nimport {table} from './table.js'\nimport {tableRow} from './table-row.js'\nimport {tableCell} from './table-cell.js'\nimport {text} from './text.js'\nimport {thematicBreak} from './thematic-break.js'\n\n/**\n * Default handlers for nodes.\n *\n * @satisfies {import('../state.js').Handlers}\n */\nexport const handlers = {\n blockquote,\n break: hardBreak,\n code,\n delete: strikethrough,\n emphasis,\n footnoteReference,\n heading,\n html,\n imageReference,\n image,\n inlineCode,\n linkReference,\n link,\n listItem,\n list,\n paragraph,\n // @ts-expect-error: root is different, but hard to type.\n root,\n strong,\n table,\n tableCell,\n tableRow,\n text,\n thematicBreak,\n toml: ignore,\n yaml: ignore,\n definition: ignore,\n footnoteDefinition: ignore\n}\n\n// Return nothing for nodes that are ignored.\nfunction ignore() {\n return undefined\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').Blockquote} Blockquote\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `blockquote` node into hast.\n *\n * @param {State} state\n * Info passed around.\n * @param {Blockquote} node\n * mdast node.\n * @returns {Element}\n * hast node.\n */\nexport function blockquote(state, node) {\n /** @type {Element} */\n const result = {\n type: 'element',\n tagName: 'blockquote',\n properties: {},\n children: state.wrap(state.all(node), true)\n }\n state.patch(node, result)\n return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').Text} Text\n * @typedef {import('mdast').Break} Break\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `break` node into hast.\n *\n * @param {State} state\n * Info passed around.\n * @param {Break} node\n * mdast node.\n * @returns {Array}\n * hast element content.\n */\nexport function hardBreak(state, node) {\n /** @type {Element} */\n const result = {type: 'element', tagName: 'br', properties: {}, children: []}\n state.patch(node, result)\n return [state.applyData(node, result), {type: 'text', value: '\\n'}]\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').Properties} Properties\n * @typedef {import('mdast').Code} Code\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `code` node into hast.\n *\n * @param {State} state\n * Info passed around.\n * @param {Code} node\n * mdast node.\n * @returns {Element}\n * hast node.\n */\nexport function code(state, node) {\n const value = node.value ? node.value + '\\n' : ''\n /** @type {Properties} */\n const properties = {}\n\n if (node.lang) {\n properties.className = ['language-' + node.lang]\n }\n\n // Create ``.\n /** @type {Element} */\n let result = {\n type: 'element',\n tagName: 'code',\n properties,\n children: [{type: 'text', value}]\n }\n\n if (node.meta) {\n result.data = {meta: node.meta}\n }\n\n state.patch(node, result)\n result = state.applyData(node, result)\n\n // Create `
`.\n  result = {type: 'element', tagName: 'pre', properties: {}, children: [result]}\n  state.patch(node, result)\n  return result\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').Delete} Delete\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `delete` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {Delete} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function strikethrough(state, node) {\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'del',\n    properties: {},\n    children: state.all(node)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').Emphasis} Emphasis\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `emphasis` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {Emphasis} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function emphasis(state, node) {\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'em',\n    properties: {},\n    children: state.all(node)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').FootnoteReference} FootnoteReference\n * @typedef {import('../state.js').State} State\n */\n\nimport {normalizeUri} from 'micromark-util-sanitize-uri'\n\n/**\n * Turn an mdast `footnoteReference` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {FootnoteReference} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function footnoteReference(state, node) {\n  const clobberPrefix =\n    typeof state.options.clobberPrefix === 'string'\n      ? state.options.clobberPrefix\n      : 'user-content-'\n  const id = String(node.identifier).toUpperCase()\n  const safeId = normalizeUri(id.toLowerCase())\n  const index = state.footnoteOrder.indexOf(id)\n  /** @type {number} */\n  let counter\n\n  let reuseCounter = state.footnoteCounts.get(id)\n\n  if (reuseCounter === undefined) {\n    reuseCounter = 0\n    state.footnoteOrder.push(id)\n    counter = state.footnoteOrder.length\n  } else {\n    counter = index + 1\n  }\n\n  reuseCounter += 1\n  state.footnoteCounts.set(id, reuseCounter)\n\n  /** @type {Element} */\n  const link = {\n    type: 'element',\n    tagName: 'a',\n    properties: {\n      href: '#' + clobberPrefix + 'fn-' + safeId,\n      id:\n        clobberPrefix +\n        'fnref-' +\n        safeId +\n        (reuseCounter > 1 ? '-' + reuseCounter : ''),\n      dataFootnoteRef: true,\n      ariaDescribedBy: ['footnote-label']\n    },\n    children: [{type: 'text', value: String(counter)}]\n  }\n  state.patch(node, link)\n\n  /** @type {Element} */\n  const sup = {\n    type: 'element',\n    tagName: 'sup',\n    properties: {},\n    children: [link]\n  }\n  state.patch(node, sup)\n  return state.applyData(node, sup)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').Heading} Heading\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `heading` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {Heading} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function heading(state, node) {\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'h' + node.depth,\n    properties: {},\n    children: state.all(node)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').Html} Html\n * @typedef {import('../state.js').State} State\n * @typedef {import('../../index.js').Raw} Raw\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `html` node into hast (`raw` node in dangerous mode, otherwise\n * nothing).\n *\n * @param {State} state\n *   Info passed around.\n * @param {Html} node\n *   mdast node.\n * @returns {Element | Raw | undefined}\n *   hast node.\n */\nexport function html(state, node) {\n  if (state.options.allowDangerousHtml) {\n    /** @type {Raw} */\n    const result = {type: 'raw', value: node.value}\n    state.patch(node, result)\n    return state.applyData(node, result)\n  }\n\n  return undefined\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').ElementContent} ElementContent\n * @typedef {import('hast').Properties} Properties\n * @typedef {import('mdast').ImageReference} ImageReference\n * @typedef {import('../state.js').State} State\n */\n\nimport {normalizeUri} from 'micromark-util-sanitize-uri'\nimport {revert} from '../revert.js'\n\n/**\n * Turn an mdast `imageReference` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {ImageReference} node\n *   mdast node.\n * @returns {Array | ElementContent}\n *   hast node.\n */\nexport function imageReference(state, node) {\n  const id = String(node.identifier).toUpperCase()\n  const def = state.definitionById.get(id)\n\n  if (!def) {\n    return revert(state, node)\n  }\n\n  /** @type {Properties} */\n  const properties = {src: normalizeUri(def.url || ''), alt: node.alt}\n\n  if (def.title !== null && def.title !== undefined) {\n    properties.title = def.title\n  }\n\n  /** @type {Element} */\n  const result = {type: 'element', tagName: 'img', properties, children: []}\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').Properties} Properties\n * @typedef {import('mdast').Image} Image\n * @typedef {import('../state.js').State} State\n */\n\nimport {normalizeUri} from 'micromark-util-sanitize-uri'\n\n/**\n * Turn an mdast `image` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {Image} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function image(state, node) {\n  /** @type {Properties} */\n  const properties = {src: normalizeUri(node.url)}\n\n  if (node.alt !== null && node.alt !== undefined) {\n    properties.alt = node.alt\n  }\n\n  if (node.title !== null && node.title !== undefined) {\n    properties.title = node.title\n  }\n\n  /** @type {Element} */\n  const result = {type: 'element', tagName: 'img', properties, children: []}\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').Text} Text\n * @typedef {import('mdast').InlineCode} InlineCode\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `inlineCode` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {InlineCode} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function inlineCode(state, node) {\n  /** @type {Text} */\n  const text = {type: 'text', value: node.value.replace(/\\r?\\n|\\r/g, ' ')}\n  state.patch(node, text)\n\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'code',\n    properties: {},\n    children: [text]\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').ElementContent} ElementContent\n * @typedef {import('hast').Properties} Properties\n * @typedef {import('mdast').LinkReference} LinkReference\n * @typedef {import('../state.js').State} State\n */\n\nimport {normalizeUri} from 'micromark-util-sanitize-uri'\nimport {revert} from '../revert.js'\n\n/**\n * Turn an mdast `linkReference` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {LinkReference} node\n *   mdast node.\n * @returns {Array | ElementContent}\n *   hast node.\n */\nexport function linkReference(state, node) {\n  const id = String(node.identifier).toUpperCase()\n  const def = state.definitionById.get(id)\n\n  if (!def) {\n    return revert(state, node)\n  }\n\n  /** @type {Properties} */\n  const properties = {href: normalizeUri(def.url || '')}\n\n  if (def.title !== null && def.title !== undefined) {\n    properties.title = def.title\n  }\n\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'a',\n    properties,\n    children: state.all(node)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').Properties} Properties\n * @typedef {import('mdast').Link} Link\n * @typedef {import('../state.js').State} State\n */\n\nimport {normalizeUri} from 'micromark-util-sanitize-uri'\n\n/**\n * Turn an mdast `link` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {Link} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function link(state, node) {\n  /** @type {Properties} */\n  const properties = {href: normalizeUri(node.url)}\n\n  if (node.title !== null && node.title !== undefined) {\n    properties.title = node.title\n  }\n\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'a',\n    properties,\n    children: state.all(node)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').Properties} Properties\n * @typedef {import('mdast').List} List\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `list` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {List} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function list(state, node) {\n  /** @type {Properties} */\n  const properties = {}\n  const results = state.all(node)\n  let index = -1\n\n  if (typeof node.start === 'number' && node.start !== 1) {\n    properties.start = node.start\n  }\n\n  // Like GitHub, add a class for custom styling.\n  while (++index < results.length) {\n    const child = results[index]\n\n    if (\n      child.type === 'element' &&\n      child.tagName === 'li' &&\n      child.properties &&\n      Array.isArray(child.properties.className) &&\n      child.properties.className.includes('task-list-item')\n    ) {\n      properties.className = ['contains-task-list']\n      break\n    }\n  }\n\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: node.ordered ? 'ol' : 'ul',\n    properties,\n    children: state.wrap(results, true)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').Paragraph} Paragraph\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `paragraph` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {Paragraph} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function paragraph(state, node) {\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'p',\n    properties: {},\n    children: state.all(node)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Parents} HastParents\n * @typedef {import('hast').Root} HastRoot\n * @typedef {import('mdast').Root} MdastRoot\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `root` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {MdastRoot} node\n *   mdast node.\n * @returns {HastParents}\n *   hast node.\n */\nexport function root(state, node) {\n  /** @type {HastRoot} */\n  const result = {type: 'root', children: state.wrap(state.all(node))}\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').Strong} Strong\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `strong` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {Strong} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function strong(state, node) {\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'strong',\n    properties: {},\n    children: state.all(node)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').Table} Table\n * @typedef {import('../state.js').State} State\n */\n\nimport {pointEnd, pointStart} from 'unist-util-position'\n\n/**\n * Turn an mdast `table` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {Table} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function table(state, node) {\n  const rows = state.all(node)\n  const firstRow = rows.shift()\n  /** @type {Array} */\n  const tableContent = []\n\n  if (firstRow) {\n    /** @type {Element} */\n    const head = {\n      type: 'element',\n      tagName: 'thead',\n      properties: {},\n      children: state.wrap([firstRow], true)\n    }\n    state.patch(node.children[0], head)\n    tableContent.push(head)\n  }\n\n  if (rows.length > 0) {\n    /** @type {Element} */\n    const body = {\n      type: 'element',\n      tagName: 'tbody',\n      properties: {},\n      children: state.wrap(rows, true)\n    }\n\n    const start = pointStart(node.children[1])\n    const end = pointEnd(node.children[node.children.length - 1])\n    if (start && end) body.position = {start, end}\n    tableContent.push(body)\n  }\n\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'table',\n    properties: {},\n    children: state.wrap(tableContent, true)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').TableCell} TableCell\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `tableCell` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {TableCell} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function tableCell(state, node) {\n  // Note: this function is normally not called: see `table-row` for how rows\n  // and their cells are compiled.\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'td', // Assume body cell.\n    properties: {},\n    children: state.all(node)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').ElementContent} ElementContent\n * @typedef {import('hast').Properties} Properties\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('mdast').TableRow} TableRow\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `tableRow` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {TableRow} node\n *   mdast node.\n * @param {Parents | undefined} parent\n *   Parent of `node`.\n * @returns {Element}\n *   hast node.\n */\nexport function tableRow(state, node, parent) {\n  const siblings = parent ? parent.children : undefined\n  // Generate a body row when without parent.\n  const rowIndex = siblings ? siblings.indexOf(node) : 1\n  const tagName = rowIndex === 0 ? 'th' : 'td'\n  // To do: option to use `style`?\n  const align = parent && parent.type === 'table' ? parent.align : undefined\n  const length = align ? align.length : node.children.length\n  let cellIndex = -1\n  /** @type {Array} */\n  const cells = []\n\n  while (++cellIndex < length) {\n    // Note: can also be undefined.\n    const cell = node.children[cellIndex]\n    /** @type {Properties} */\n    const properties = {}\n    const alignValue = align ? align[cellIndex] : undefined\n\n    if (alignValue) {\n      properties.align = alignValue\n    }\n\n    /** @type {Element} */\n    let result = {type: 'element', tagName, properties, children: []}\n\n    if (cell) {\n      result.children = state.all(cell)\n      state.patch(cell, result)\n      result = state.applyData(cell, result)\n    }\n\n    cells.push(result)\n  }\n\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'tr',\n    properties: {},\n    children: state.wrap(cells, true)\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} HastElement\n * @typedef {import('hast').Text} HastText\n * @typedef {import('mdast').Text} MdastText\n * @typedef {import('../state.js').State} State\n */\n\nimport {trimLines} from 'trim-lines'\n\n/**\n * Turn an mdast `text` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {MdastText} node\n *   mdast node.\n * @returns {HastElement | HastText}\n *   hast node.\n */\nexport function text(state, node) {\n  /** @type {HastText} */\n  const result = {type: 'text', value: trimLines(String(node.value))}\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('mdast').ThematicBreak} ThematicBreak\n * @typedef {import('../state.js').State} State\n */\n\n// Make VS Code show references to the above types.\n''\n\n/**\n * Turn an mdast `thematicBreak` node into hast.\n *\n * @param {State} state\n *   Info passed around.\n * @param {ThematicBreak} node\n *   mdast node.\n * @returns {Element}\n *   hast node.\n */\nexport function thematicBreak(state, node) {\n  /** @type {Element} */\n  const result = {\n    type: 'element',\n    tagName: 'hr',\n    properties: {},\n    children: []\n  }\n  state.patch(node, result)\n  return state.applyData(node, result)\n}\n","/**\n * @typedef {import('hast').Element} HastElement\n * @typedef {import('hast').ElementContent} HastElementContent\n * @typedef {import('hast').Nodes} HastNodes\n * @typedef {import('hast').Properties} HastProperties\n * @typedef {import('hast').RootContent} HastRootContent\n * @typedef {import('hast').Text} HastText\n *\n * @typedef {import('mdast').Definition} MdastDefinition\n * @typedef {import('mdast').FootnoteDefinition} MdastFootnoteDefinition\n * @typedef {import('mdast').Nodes} MdastNodes\n * @typedef {import('mdast').Parents} MdastParents\n *\n * @typedef {import('./footer.js').FootnoteBackContentTemplate} FootnoteBackContentTemplate\n * @typedef {import('./footer.js').FootnoteBackLabelTemplate} FootnoteBackLabelTemplate\n */\n\n/**\n * @callback Handler\n *   Handle a node.\n * @param {State} state\n *   Info passed around.\n * @param {any} node\n *   mdast node to handle.\n * @param {MdastParents | undefined} parent\n *   Parent of `node`.\n * @returns {Array | HastElementContent | undefined}\n *   hast node.\n *\n * @typedef {Partial>} Handlers\n *   Handle nodes.\n *\n * @typedef Options\n *   Configuration (optional).\n * @property {boolean | null | undefined} [allowDangerousHtml=false]\n *   Whether to persist raw HTML in markdown in the hast tree (default:\n *   `false`).\n * @property {string | null | undefined} [clobberPrefix='user-content-']\n *   Prefix to use before the `id` property on footnotes to prevent them from\n *   *clobbering* (default: `'user-content-'`).\n *\n *   Pass `''` for trusted markdown and when you are careful with\n *   polyfilling.\n *   You could pass a different prefix.\n *\n *   DOM clobbering is this:\n *\n *   ```html\n *   

\n * \n * ```\n *\n * The above example shows that elements are made available by browsers, by\n * their ID, on the `window` object.\n * This is a security risk because you might be expecting some other variable\n * at that place.\n * It can also break polyfills.\n * Using a prefix solves these problems.\n * @property {FootnoteBackContentTemplate | string | null | undefined} [footnoteBackContent]\n * Content of the backreference back to references (default: `defaultFootnoteBackContent`).\n *\n * The default value is:\n *\n * ```js\n * function defaultFootnoteBackContent(_, rereferenceIndex) {\n * const result = [{type: 'text', value: '↩'}]\n *\n * if (rereferenceIndex > 1) {\n * result.push({\n * type: 'element',\n * tagName: 'sup',\n * properties: {},\n * children: [{type: 'text', value: String(rereferenceIndex)}]\n * })\n * }\n *\n * return result\n * }\n * ```\n *\n * This content is used in the `a` element of each backreference (the `↩`\n * links).\n * @property {FootnoteBackLabelTemplate | string | null | undefined} [footnoteBackLabel]\n * Label to describe the backreference back to references (default:\n * `defaultFootnoteBackLabel`).\n *\n * The default value is:\n *\n * ```js\n * function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) {\n * return (\n * 'Back to reference ' +\n * (referenceIndex + 1) +\n * (rereferenceIndex > 1 ? '-' + rereferenceIndex : '')\n * )\n * }\n * ```\n *\n * Change it when the markdown is not in English.\n *\n * This label is used in the `ariaLabel` property on each backreference\n * (the `↩` links).\n * It affects users of assistive technology.\n * @property {string | null | undefined} [footnoteLabel='Footnotes']\n * Textual label to use for the footnotes section (default: `'Footnotes'`).\n *\n * Change it when the markdown is not in English.\n *\n * This label is typically hidden visually (assuming a `sr-only` CSS class\n * is defined that does that) and so affects screen readers only.\n * If you do have such a class, but want to show this section to everyone,\n * pass different properties with the `footnoteLabelProperties` option.\n * @property {HastProperties | null | undefined} [footnoteLabelProperties={className: ['sr-only']}]\n * Properties to use on the footnote label (default: `{className:\n * ['sr-only']}`).\n *\n * Change it to show the label and add other properties.\n *\n * This label is typically hidden visually (assuming an `sr-only` CSS class\n * is defined that does that) and so affects screen readers only.\n * If you do have such a class, but want to show this section to everyone,\n * pass an empty string.\n * You can also add different properties.\n *\n * > 👉 **Note**: `id: 'footnote-label'` is always added, because footnote\n * > calls use it with `aria-describedby` to provide an accessible label.\n * @property {string | null | undefined} [footnoteLabelTagName='h2']\n * HTML tag name to use for the footnote label element (default: `'h2'`).\n *\n * Change it to match your document structure.\n *\n * This label is typically hidden visually (assuming a `sr-only` CSS class\n * is defined that does that) and so affects screen readers only.\n * If you do have such a class, but want to show this section to everyone,\n * pass different properties with the `footnoteLabelProperties` option.\n * @property {Handlers | null | undefined} [handlers]\n * Extra handlers for nodes (optional).\n * @property {Array | null | undefined} [passThrough]\n * List of custom mdast node types to pass through (keep) in hast (note that\n * the node itself is passed, but eventual children are transformed)\n * (optional).\n * @property {Handler | null | undefined} [unknownHandler]\n * Handler for all unknown nodes (optional).\n *\n * @typedef State\n * Info passed around.\n * @property {(node: MdastNodes) => Array} all\n * Transform the children of an mdast parent to hast.\n * @property {(from: MdastNodes, to: Type) => HastElement | Type} applyData\n * Honor the `data` of `from`, and generate an element instead of `node`.\n * @property {Map} definitionById\n * Definitions by their identifier.\n * @property {Map} footnoteById\n * Footnote definitions by their identifier.\n * @property {Map} footnoteCounts\n * Counts for how often the same footnote was called.\n * @property {Array} footnoteOrder\n * Identifiers of order when footnote calls first appear in tree order.\n * @property {Handlers} handlers\n * Applied handlers.\n * @property {(node: MdastNodes, parent: MdastParents | undefined) => Array | HastElementContent | undefined} one\n * Transform an mdast node to hast.\n * @property {Options} options\n * Configuration.\n * @property {(from: MdastNodes, node: HastNodes) => undefined} patch\n * Copy a node’s positional info.\n * @property {(nodes: Array, loose?: boolean | undefined) => Array} wrap\n * Wrap `nodes` with line endings between each node, adds initial/final line endings when `loose`.\n */\n\nimport structuredClone from '@ungap/structured-clone'\nimport {visit} from 'unist-util-visit'\nimport {position} from 'unist-util-position'\nimport {handlers as defaultHandlers} from './handlers/index.js'\n\nconst own = {}.hasOwnProperty\n\n/** @type {Options} */\nconst emptyOptions = {}\n\n/**\n * Create `state` from an mdast tree.\n *\n * @param {MdastNodes} tree\n * mdast node to transform.\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {State}\n * `state` function.\n */\nexport function createState(tree, options) {\n const settings = options || emptyOptions\n /** @type {Map} */\n const definitionById = new Map()\n /** @type {Map} */\n const footnoteById = new Map()\n /** @type {Map} */\n const footnoteCounts = new Map()\n /** @type {Handlers} */\n // @ts-expect-error: the root handler returns a root.\n // Hard to type.\n const handlers = {...defaultHandlers, ...settings.handlers}\n\n /** @type {State} */\n const state = {\n all,\n applyData,\n definitionById,\n footnoteById,\n footnoteCounts,\n footnoteOrder: [],\n handlers,\n one,\n options: settings,\n patch,\n wrap\n }\n\n visit(tree, function (node) {\n if (node.type === 'definition' || node.type === 'footnoteDefinition') {\n const map = node.type === 'definition' ? definitionById : footnoteById\n const id = String(node.identifier).toUpperCase()\n\n // Mimick CM behavior of link definitions.\n // See: .\n if (!map.has(id)) {\n // @ts-expect-error: node type matches map.\n map.set(id, node)\n }\n }\n })\n\n return state\n\n /**\n * Transform an mdast node into a hast node.\n *\n * @param {MdastNodes} node\n * mdast node.\n * @param {MdastParents | undefined} [parent]\n * Parent of `node`.\n * @returns {Array | HastElementContent | undefined}\n * Resulting hast node.\n */\n function one(node, parent) {\n const type = node.type\n const handle = state.handlers[type]\n\n if (own.call(state.handlers, type) && handle) {\n return handle(state, node, parent)\n }\n\n if (state.options.passThrough && state.options.passThrough.includes(type)) {\n if ('children' in node) {\n const {children, ...shallow} = node\n const result = structuredClone(shallow)\n // @ts-expect-error: TS doesn’t understand…\n result.children = state.all(node)\n // @ts-expect-error: TS doesn’t understand…\n return result\n }\n\n // @ts-expect-error: it’s custom.\n return structuredClone(node)\n }\n\n const unknown = state.options.unknownHandler || defaultUnknownHandler\n\n return unknown(state, node, parent)\n }\n\n /**\n * Transform the children of an mdast node into hast nodes.\n *\n * @param {MdastNodes} parent\n * mdast node to compile\n * @returns {Array}\n * Resulting hast nodes.\n */\n function all(parent) {\n /** @type {Array} */\n const values = []\n\n if ('children' in parent) {\n const nodes = parent.children\n let index = -1\n while (++index < nodes.length) {\n const result = state.one(nodes[index], parent)\n\n // To do: see if we van clean this? Can we merge texts?\n if (result) {\n if (index && nodes[index - 1].type === 'break') {\n if (!Array.isArray(result) && result.type === 'text') {\n result.value = trimMarkdownSpaceStart(result.value)\n }\n\n if (!Array.isArray(result) && result.type === 'element') {\n const head = result.children[0]\n\n if (head && head.type === 'text') {\n head.value = trimMarkdownSpaceStart(head.value)\n }\n }\n }\n\n if (Array.isArray(result)) {\n values.push(...result)\n } else {\n values.push(result)\n }\n }\n }\n }\n\n return values\n }\n}\n\n/**\n * Copy a node’s positional info.\n *\n * @param {MdastNodes} from\n * mdast node to copy from.\n * @param {HastNodes} to\n * hast node to copy into.\n * @returns {undefined}\n * Nothing.\n */\nfunction patch(from, to) {\n if (from.position) to.position = position(from)\n}\n\n/**\n * Honor the `data` of `from` and maybe generate an element instead of `to`.\n *\n * @template {HastNodes} Type\n * Node type.\n * @param {MdastNodes} from\n * mdast node to use data from.\n * @param {Type} to\n * hast node to change.\n * @returns {HastElement | Type}\n * Nothing.\n */\nfunction applyData(from, to) {\n /** @type {HastElement | Type} */\n let result = to\n\n // Handle `data.hName`, `data.hProperties, `data.hChildren`.\n if (from && from.data) {\n const hName = from.data.hName\n const hChildren = from.data.hChildren\n const hProperties = from.data.hProperties\n\n if (typeof hName === 'string') {\n // Transforming the node resulted in an element with a different name\n // than wanted:\n if (result.type === 'element') {\n result.tagName = hName\n }\n // Transforming the node resulted in a non-element, which happens for\n // raw, text, and root nodes (unless custom handlers are passed).\n // The intent of `hName` is to create an element, but likely also to keep\n // the content around (otherwise: pass `hChildren`).\n else {\n /** @type {Array} */\n // @ts-expect-error: assume no doctypes in `root`.\n const children = 'children' in result ? result.children : [result]\n result = {type: 'element', tagName: hName, properties: {}, children}\n }\n }\n\n if (result.type === 'element' && hProperties) {\n Object.assign(result.properties, structuredClone(hProperties))\n }\n\n if (\n 'children' in result &&\n result.children &&\n hChildren !== null &&\n hChildren !== undefined\n ) {\n result.children = hChildren\n }\n }\n\n return result\n}\n\n/**\n * Transform an unknown node.\n *\n * @param {State} state\n * Info passed around.\n * @param {MdastNodes} node\n * Unknown mdast node.\n * @returns {HastElement | HastText}\n * Resulting hast node.\n */\nfunction defaultUnknownHandler(state, node) {\n const data = node.data || {}\n /** @type {HastElement | HastText} */\n const result =\n 'value' in node &&\n !(own.call(data, 'hProperties') || own.call(data, 'hChildren'))\n ? {type: 'text', value: node.value}\n : {\n type: 'element',\n tagName: 'div',\n properties: {},\n children: state.all(node)\n }\n\n state.patch(node, result)\n return state.applyData(node, result)\n}\n\n/**\n * Wrap `nodes` with line endings between each node.\n *\n * @template {HastRootContent} Type\n * Node type.\n * @param {Array} nodes\n * List of nodes to wrap.\n * @param {boolean | undefined} [loose=false]\n * Whether to add line endings at start and end (default: `false`).\n * @returns {Array}\n * Wrapped nodes.\n */\nexport function wrap(nodes, loose) {\n /** @type {Array} */\n const result = []\n let index = -1\n\n if (loose) {\n result.push({type: 'text', value: '\\n'})\n }\n\n while (++index < nodes.length) {\n if (index) result.push({type: 'text', value: '\\n'})\n result.push(nodes[index])\n }\n\n if (loose && nodes.length > 0) {\n result.push({type: 'text', value: '\\n'})\n }\n\n return result\n}\n\n/**\n * Trim spaces and tabs at the start of `value`.\n *\n * @param {string} value\n * Value to trim.\n * @returns {string}\n * Result.\n */\nfunction trimMarkdownSpaceStart(value) {\n let index = 0\n let code = value.charCodeAt(index)\n\n while (code === 9 || code === 32) {\n index++\n code = value.charCodeAt(index)\n }\n\n return value.slice(index)\n}\n","/**\n * @typedef {import('hast').Nodes} HastNodes\n * @typedef {import('mdast').Nodes} MdastNodes\n * @typedef {import('./state.js').Options} Options\n */\n\nimport {ok as assert} from 'devlop'\nimport {footer} from './footer.js'\nimport {createState} from './state.js'\n\n/**\n * Transform mdast to hast.\n *\n * ##### Notes\n *\n * ###### HTML\n *\n * Raw HTML is available in mdast as `html` nodes and can be embedded in hast\n * as semistandard `raw` nodes.\n * Most utilities ignore `raw` nodes but two notable ones don’t:\n *\n * * `hast-util-to-html` also has an option `allowDangerousHtml` which will\n * output the raw HTML.\n * This is typically discouraged as noted by the option name but is useful\n * if you completely trust authors\n * * `hast-util-raw` can handle the raw embedded HTML strings by parsing them\n * into standard hast nodes (`element`, `text`, etc).\n * This is a heavy task as it needs a full HTML parser, but it is the only\n * way to support untrusted content\n *\n * ###### Footnotes\n *\n * Many options supported here relate to footnotes.\n * Footnotes are not specified by CommonMark, which we follow by default.\n * They are supported by GitHub, so footnotes can be enabled in markdown with\n * `mdast-util-gfm`.\n *\n * The options `footnoteBackLabel` and `footnoteLabel` define natural language\n * that explains footnotes, which is hidden for sighted users but shown to\n * assistive technology.\n * When your page is not in English, you must define translated values.\n *\n * Back references use ARIA attributes, but the section label itself uses a\n * heading that is hidden with an `sr-only` class.\n * To show it to sighted users, define different attributes in\n * `footnoteLabelProperties`.\n *\n * ###### Clobbering\n *\n * Footnotes introduces a problem, as it links footnote calls to footnote\n * definitions on the page through `id` attributes generated from user content,\n * which results in DOM clobbering.\n *\n * DOM clobbering is this:\n *\n * ```html\n *

\n * \n * ```\n *\n * Elements by their ID are made available by browsers on the `window` object,\n * which is a security risk.\n * Using a prefix solves this problem.\n *\n * More information on how to handle clobbering and the prefix is explained in\n * Example: headings (DOM clobbering) in `rehype-sanitize`.\n *\n * ###### Unknown nodes\n *\n * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.\n * The default behavior for unknown nodes is:\n *\n * * when the node has a `value` (and doesn’t have `data.hName`,\n * `data.hProperties`, or `data.hChildren`, see later), create a hast `text`\n * node\n * * otherwise, create a `
` element (which could be changed with\n * `data.hName`), with its children mapped from mdast to hast as well\n *\n * This behavior can be changed by passing an `unknownHandler`.\n *\n * @param {MdastNodes} tree\n * mdast tree.\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {HastNodes}\n * hast tree.\n */\nexport function toHast(tree, options) {\n const state = createState(tree, options)\n const node = state.one(tree, undefined)\n const foot = footer(state)\n /** @type {HastNodes} */\n const result = Array.isArray(node)\n ? {type: 'root', children: node}\n : node || {type: 'root', children: []}\n\n if (foot) {\n // If there’s a footer, there were definitions, meaning block\n // content.\n // So `result` is a parent node.\n assert('children' in result)\n result.children.push({type: 'text', value: '\\n'}, foot)\n }\n\n return result\n}\n","// Include `data` fields in mdast and `raw` nodes in hast.\n/// \n\n/**\n * @typedef {import('hast').Root} HastRoot\n * @typedef {import('mdast').Root} MdastRoot\n * @typedef {import('mdast-util-to-hast').Options} Options\n * @typedef {import('unified').Processor} Processor\n * @typedef {import('vfile').VFile} VFile\n */\n\n/**\n * @callback TransformBridge\n * Bridge-mode.\n *\n * Runs the destination with the new hast tree.\n * Discards result.\n * @param {MdastRoot} tree\n * Tree.\n * @param {VFile} file\n * File.\n * @returns {Promise}\n * Nothing.\n *\n * @callback TransformMutate\n * Mutate-mode.\n *\n * Further transformers run on the hast tree.\n * @param {MdastRoot} tree\n * Tree.\n * @param {VFile} file\n * File.\n * @returns {HastRoot}\n * Tree (hast).\n */\n\nimport {toHast} from 'mdast-util-to-hast'\n\n/**\n * Turn markdown into HTML.\n *\n * ##### Notes\n *\n * ###### Signature\n *\n * * if a processor is given, runs the (rehype) plugins used on it with a\n * hast tree, then discards the result (*bridge mode*)\n * * otherwise, returns a hast tree, the plugins used after `remarkRehype`\n * are rehype plugins (*mutate mode*)\n *\n * > 👉 **Note**: It’s highly unlikely that you want to pass a `processor`.\n *\n * ###### HTML\n *\n * Raw HTML is available in mdast as `html` nodes and can be embedded in hast\n * as semistandard `raw` nodes.\n * Most plugins ignore `raw` nodes but two notable ones don’t:\n *\n * * `rehype-stringify` also has an option `allowDangerousHtml` which will\n * output the raw HTML.\n * This is typically discouraged as noted by the option name but is useful if\n * you completely trust authors\n * * `rehype-raw` can handle the raw embedded HTML strings by parsing them\n * into standard hast nodes (`element`, `text`, etc).\n * This is a heavy task as it needs a full HTML parser, but it is the only way\n * to support untrusted content\n *\n * ###### Footnotes\n *\n * Many options supported here relate to footnotes.\n * Footnotes are not specified by CommonMark, which we follow by default.\n * They are supported by GitHub, so footnotes can be enabled in markdown with\n * `remark-gfm`.\n *\n * The options `footnoteBackLabel` and `footnoteLabel` define natural language\n * that explains footnotes, which is hidden for sighted users but shown to\n * assistive technology.\n * When your page is not in English, you must define translated values.\n *\n * Back references use ARIA attributes, but the section label itself uses a\n * heading that is hidden with an `sr-only` class.\n * To show it to sighted users, define different attributes in\n * `footnoteLabelProperties`.\n *\n * ###### Clobbering\n *\n * Footnotes introduces a problem, as it links footnote calls to footnote\n * definitions on the page through `id` attributes generated from user content,\n * which results in DOM clobbering.\n *\n * DOM clobbering is this:\n *\n * ```html\n *

\n * \n * ```\n *\n * Elements by their ID are made available by browsers on the `window` object,\n * which is a security risk.\n * Using a prefix solves this problem.\n *\n * More information on how to handle clobbering and the prefix is explained in\n * *Example: headings (DOM clobbering)* in `rehype-sanitize`.\n *\n * ###### Unknown nodes\n *\n * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.\n * The default behavior for unknown nodes is:\n *\n * * when the node has a `value` (and doesn’t have `data.hName`,\n * `data.hProperties`, or `data.hChildren`, see later), create a hast `text`\n * node\n * * otherwise, create a `
` element (which could be changed with\n * `data.hName`), with its children mapped from mdast to hast as well\n *\n * This behavior can be changed by passing an `unknownHandler`.\n *\n * @overload\n * @param {Processor} processor\n * @param {Readonly | null | undefined} [options]\n * @returns {TransformBridge}\n *\n * @overload\n * @param {Readonly | null | undefined} [options]\n * @returns {TransformMutate}\n *\n * @param {Readonly | Processor | null | undefined} [destination]\n * Processor or configuration (optional).\n * @param {Readonly | null | undefined} [options]\n * When a processor was given, configuration (optional).\n * @returns {TransformBridge | TransformMutate}\n * Transform.\n */\nexport default function remarkRehype(destination, options) {\n if (destination && 'run' in destination) {\n /**\n * @type {TransformBridge}\n */\n return async function (tree, file) {\n // Cast because root in -> root out.\n const hastTree = /** @type {HastRoot} */ (toHast(tree, options))\n await destination.run(hastTree, file)\n }\n }\n\n /**\n * @type {TransformMutate}\n */\n return function (tree) {\n // Cast because root in -> root out.\n return /** @type {HastRoot} */ (toHast(tree, options || destination))\n }\n}\n","/**\n * Throw a given error.\n *\n * @param {Error|null|undefined} [error]\n * Maybe error.\n * @returns {asserts error is null|undefined}\n */\nexport function bail(error) {\n if (error) {\n throw error\n }\n}\n","export default function isPlainObject(value) {\n\tif (typeof value !== 'object' || value === null) {\n\t\treturn false;\n\t}\n\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);\n}\n","/**\n * @typedef {(error?: Error|null|undefined, ...output: Array) => void} Callback\n * @typedef {(...input: Array) => any} Middleware\n *\n * @typedef {(...input: Array) => void} Run\n * Call all middleware.\n * @typedef {(fn: Middleware) => Pipeline} Use\n * Add `fn` (middleware) to the list.\n * @typedef {{run: Run, use: Use}} Pipeline\n * Middleware.\n */\n\n/**\n * Create new middleware.\n *\n * @returns {Pipeline}\n */\nexport function trough() {\n /** @type {Array} */\n const fns = []\n /** @type {Pipeline} */\n const pipeline = {run, use}\n\n return pipeline\n\n /** @type {Run} */\n function run(...values) {\n let middlewareIndex = -1\n /** @type {Callback} */\n const callback = values.pop()\n\n if (typeof callback !== 'function') {\n throw new TypeError('Expected function as last argument, not ' + callback)\n }\n\n next(null, ...values)\n\n /**\n * Run the next `fn`, or we’re done.\n *\n * @param {Error|null|undefined} error\n * @param {Array} output\n */\n function next(error, ...output) {\n const fn = fns[++middlewareIndex]\n let index = -1\n\n if (error) {\n callback(error)\n return\n }\n\n // Copy non-nullish input into values.\n while (++index < values.length) {\n if (output[index] === null || output[index] === undefined) {\n output[index] = values[index]\n }\n }\n\n // Save the newly created `output` for the next call.\n values = output\n\n // Next or done.\n if (fn) {\n wrap(fn, next)(...output)\n } else {\n callback(null, ...output)\n }\n }\n }\n\n /** @type {Use} */\n function use(middelware) {\n if (typeof middelware !== 'function') {\n throw new TypeError(\n 'Expected `middelware` to be a function, not ' + middelware\n )\n }\n\n fns.push(middelware)\n return pipeline\n }\n}\n\n/**\n * Wrap `middleware`.\n * Can be sync or async; return a promise, receive a callback, or return new\n * values and errors.\n *\n * @param {Middleware} middleware\n * @param {Callback} callback\n */\nexport function wrap(middleware, callback) {\n /** @type {boolean} */\n let called\n\n return wrapped\n\n /**\n * Call `middleware`.\n * @this {any}\n * @param {Array} parameters\n * @returns {void}\n */\n function wrapped(...parameters) {\n const fnExpectsCallback = middleware.length > parameters.length\n /** @type {any} */\n let result\n\n if (fnExpectsCallback) {\n parameters.push(done)\n }\n\n try {\n result = middleware.apply(this, parameters)\n } catch (error) {\n const exception = /** @type {Error} */ (error)\n\n // Well, this is quite the pickle.\n // `middleware` received a callback and called it synchronously, but that\n // threw an error.\n // The only thing left to do is to throw the thing instead.\n if (fnExpectsCallback && called) {\n throw exception\n }\n\n return done(exception)\n }\n\n if (!fnExpectsCallback) {\n if (result instanceof Promise) {\n result.then(then, done)\n } else if (result instanceof Error) {\n done(result)\n } else {\n then(result)\n }\n }\n }\n\n /**\n * Call `callback`, only once.\n * @type {Callback}\n */\n function done(error, ...output) {\n if (!called) {\n called = true\n callback(error, ...output)\n }\n }\n\n /**\n * Call `done` with one value.\n *\n * @param {any} [value]\n */\n function then(value) {\n done(null, value)\n }\n}\n","// A derivative work based on:\n// .\n// Which is licensed:\n//\n// MIT License\n//\n// Copyright (c) 2013 James Halliday\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of\n// this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to\n// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n// the Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// A derivative work based on:\n//\n// Parts of that are extracted from Node’s internal `path` module:\n// .\n// Which is licensed:\n//\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nexport const path = {basename, dirname, extname, join, sep: '/'}\n\n/* eslint-disable max-depth, complexity */\n\n/**\n * Get the basename from a path.\n *\n * @param {string} path\n * File path.\n * @param {string | null | undefined} [ext]\n * Extension to strip.\n * @returns {string}\n * Stem or basename.\n */\nfunction basename(path, ext) {\n if (ext !== undefined && typeof ext !== 'string') {\n throw new TypeError('\"ext\" argument must be a string')\n }\n\n assertPath(path)\n let start = 0\n let end = -1\n let index = path.length\n /** @type {boolean | undefined} */\n let seenNonSlash\n\n if (ext === undefined || ext.length === 0 || ext.length > path.length) {\n while (index--) {\n if (path.codePointAt(index) === 47 /* `/` */) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now.\n if (seenNonSlash) {\n start = index + 1\n break\n }\n } else if (end < 0) {\n // We saw the first non-path separator, mark this as the end of our\n // path component.\n seenNonSlash = true\n end = index + 1\n }\n }\n\n return end < 0 ? '' : path.slice(start, end)\n }\n\n if (ext === path) {\n return ''\n }\n\n let firstNonSlashEnd = -1\n let extIndex = ext.length - 1\n\n while (index--) {\n if (path.codePointAt(index) === 47 /* `/` */) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now.\n if (seenNonSlash) {\n start = index + 1\n break\n }\n } else {\n if (firstNonSlashEnd < 0) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching.\n seenNonSlash = true\n firstNonSlashEnd = index + 1\n }\n\n if (extIndex > -1) {\n // Try to match the explicit extension.\n if (path.codePointAt(index) === ext.codePointAt(extIndex--)) {\n if (extIndex < 0) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = index\n }\n } else {\n // Extension does not match, so our result is the entire path\n // component\n extIndex = -1\n end = firstNonSlashEnd\n }\n }\n }\n }\n\n if (start === end) {\n end = firstNonSlashEnd\n } else if (end < 0) {\n end = path.length\n }\n\n return path.slice(start, end)\n}\n\n/**\n * Get the dirname from a path.\n *\n * @param {string} path\n * File path.\n * @returns {string}\n * File path.\n */\nfunction dirname(path) {\n assertPath(path)\n\n if (path.length === 0) {\n return '.'\n }\n\n let end = -1\n let index = path.length\n /** @type {boolean | undefined} */\n let unmatchedSlash\n\n // Prefix `--` is important to not run on `0`.\n while (--index) {\n if (path.codePointAt(index) === 47 /* `/` */) {\n if (unmatchedSlash) {\n end = index\n break\n }\n } else if (!unmatchedSlash) {\n // We saw the first non-path separator\n unmatchedSlash = true\n }\n }\n\n return end < 0\n ? path.codePointAt(0) === 47 /* `/` */\n ? '/'\n : '.'\n : end === 1 && path.codePointAt(0) === 47 /* `/` */\n ? '//'\n : path.slice(0, end)\n}\n\n/**\n * Get an extname from a path.\n *\n * @param {string} path\n * File path.\n * @returns {string}\n * Extname.\n */\nfunction extname(path) {\n assertPath(path)\n\n let index = path.length\n\n let end = -1\n let startPart = 0\n let startDot = -1\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find.\n let preDotState = 0\n /** @type {boolean | undefined} */\n let unmatchedSlash\n\n while (index--) {\n const code = path.codePointAt(index)\n\n if (code === 47 /* `/` */) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now.\n if (unmatchedSlash) {\n startPart = index + 1\n break\n }\n\n continue\n }\n\n if (end < 0) {\n // We saw the first non-path separator, mark this as the end of our\n // extension.\n unmatchedSlash = true\n end = index + 1\n }\n\n if (code === 46 /* `.` */) {\n // If this is our first dot, mark it as the start of our extension.\n if (startDot < 0) {\n startDot = index\n } else if (preDotState !== 1) {\n preDotState = 1\n }\n } else if (startDot > -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension.\n preDotState = -1\n }\n }\n\n if (\n startDot < 0 ||\n end < 0 ||\n // We saw a non-dot character immediately before the dot.\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly `..`.\n (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)\n ) {\n return ''\n }\n\n return path.slice(startDot, end)\n}\n\n/**\n * Join segments from a path.\n *\n * @param {Array} segments\n * Path segments.\n * @returns {string}\n * File path.\n */\nfunction join(...segments) {\n let index = -1\n /** @type {string | undefined} */\n let joined\n\n while (++index < segments.length) {\n assertPath(segments[index])\n\n if (segments[index]) {\n joined =\n joined === undefined ? segments[index] : joined + '/' + segments[index]\n }\n }\n\n return joined === undefined ? '.' : normalize(joined)\n}\n\n/**\n * Normalize a basic file path.\n *\n * @param {string} path\n * File path.\n * @returns {string}\n * File path.\n */\n// Note: `normalize` is not exposed as `path.normalize`, so some code is\n// manually removed from it.\nfunction normalize(path) {\n assertPath(path)\n\n const absolute = path.codePointAt(0) === 47 /* `/` */\n\n // Normalize the path according to POSIX rules.\n let value = normalizeString(path, !absolute)\n\n if (value.length === 0 && !absolute) {\n value = '.'\n }\n\n if (value.length > 0 && path.codePointAt(path.length - 1) === 47 /* / */) {\n value += '/'\n }\n\n return absolute ? '/' + value : value\n}\n\n/**\n * Resolve `.` and `..` elements in a path with directory names.\n *\n * @param {string} path\n * File path.\n * @param {boolean} allowAboveRoot\n * Whether `..` can move above root.\n * @returns {string}\n * File path.\n */\nfunction normalizeString(path, allowAboveRoot) {\n let result = ''\n let lastSegmentLength = 0\n let lastSlash = -1\n let dots = 0\n let index = -1\n /** @type {number | undefined} */\n let code\n /** @type {number} */\n let lastSlashIndex\n\n while (++index <= path.length) {\n if (index < path.length) {\n code = path.codePointAt(index)\n } else if (code === 47 /* `/` */) {\n break\n } else {\n code = 47 /* `/` */\n }\n\n if (code === 47 /* `/` */) {\n if (lastSlash === index - 1 || dots === 1) {\n // Empty.\n } else if (lastSlash !== index - 1 && dots === 2) {\n if (\n result.length < 2 ||\n lastSegmentLength !== 2 ||\n result.codePointAt(result.length - 1) !== 46 /* `.` */ ||\n result.codePointAt(result.length - 2) !== 46 /* `.` */\n ) {\n if (result.length > 2) {\n lastSlashIndex = result.lastIndexOf('/')\n\n if (lastSlashIndex !== result.length - 1) {\n if (lastSlashIndex < 0) {\n result = ''\n lastSegmentLength = 0\n } else {\n result = result.slice(0, lastSlashIndex)\n lastSegmentLength = result.length - 1 - result.lastIndexOf('/')\n }\n\n lastSlash = index\n dots = 0\n continue\n }\n } else if (result.length > 0) {\n result = ''\n lastSegmentLength = 0\n lastSlash = index\n dots = 0\n continue\n }\n }\n\n if (allowAboveRoot) {\n result = result.length > 0 ? result + '/..' : '..'\n lastSegmentLength = 2\n }\n } else {\n if (result.length > 0) {\n result += '/' + path.slice(lastSlash + 1, index)\n } else {\n result = path.slice(lastSlash + 1, index)\n }\n\n lastSegmentLength = index - lastSlash - 1\n }\n\n lastSlash = index\n dots = 0\n } else if (code === 46 /* `.` */ && dots > -1) {\n dots++\n } else {\n dots = -1\n }\n }\n\n return result\n}\n\n/**\n * Make sure `path` is a string.\n *\n * @param {string} path\n * File path.\n * @returns {asserts path is string}\n * Nothing.\n */\nfunction assertPath(path) {\n if (typeof path !== 'string') {\n throw new TypeError(\n 'Path must be a string. Received ' + JSON.stringify(path)\n )\n }\n}\n\n/* eslint-enable max-depth, complexity */\n","// Somewhat based on:\n// .\n// But I don’t think one tiny line of code can be copyrighted. 😅\nexport const proc = {cwd}\n\nfunction cwd() {\n return '/'\n}\n","/**\n * Checks if a value has the shape of a WHATWG URL object.\n *\n * Using a symbol or instanceof would not be able to recognize URL objects\n * coming from other implementations (e.g. in Electron), so instead we are\n * checking some well known properties for a lack of a better test.\n *\n * We use `href` and `protocol` as they are the only properties that are\n * easy to retrieve and calculate due to the lazy nature of the getters.\n *\n * We check for auth attribute to distinguish legacy url instance with\n * WHATWG URL instance.\n *\n * @param {unknown} fileUrlOrPath\n * File path or URL.\n * @returns {fileUrlOrPath is URL}\n * Whether it’s a URL.\n */\n// From: \nexport function isUrl(fileUrlOrPath) {\n return Boolean(\n fileUrlOrPath !== null &&\n typeof fileUrlOrPath === 'object' &&\n 'href' in fileUrlOrPath &&\n fileUrlOrPath.href &&\n 'protocol' in fileUrlOrPath &&\n fileUrlOrPath.protocol &&\n // @ts-expect-error: indexing is fine.\n fileUrlOrPath.auth === undefined\n )\n}\n","import {isUrl} from './minurl.shared.js'\n\nexport {isUrl} from './minurl.shared.js'\n\n// See: \n\n/**\n * @param {URL | string} path\n * File URL.\n * @returns {string}\n * File URL.\n */\nexport function urlToPath(path) {\n if (typeof path === 'string') {\n path = new URL(path)\n } else if (!isUrl(path)) {\n /** @type {NodeJS.ErrnoException} */\n const error = new TypeError(\n 'The \"path\" argument must be of type string or an instance of URL. Received `' +\n path +\n '`'\n )\n error.code = 'ERR_INVALID_ARG_TYPE'\n throw error\n }\n\n if (path.protocol !== 'file:') {\n /** @type {NodeJS.ErrnoException} */\n const error = new TypeError('The URL must be of scheme file')\n error.code = 'ERR_INVALID_URL_SCHEME'\n throw error\n }\n\n return getPathFromURLPosix(path)\n}\n\n/**\n * Get a path from a POSIX URL.\n *\n * @param {URL} url\n * URL.\n * @returns {string}\n * File path.\n */\nfunction getPathFromURLPosix(url) {\n if (url.hostname !== '') {\n /** @type {NodeJS.ErrnoException} */\n const error = new TypeError(\n 'File URL host must be \"localhost\" or empty on darwin'\n )\n error.code = 'ERR_INVALID_FILE_URL_HOST'\n throw error\n }\n\n const pathname = url.pathname\n let index = -1\n\n while (++index < pathname.length) {\n if (\n pathname.codePointAt(index) === 37 /* `%` */ &&\n pathname.codePointAt(index + 1) === 50 /* `2` */\n ) {\n const third = pathname.codePointAt(index + 2)\n if (third === 70 /* `F` */ || third === 102 /* `f` */) {\n /** @type {NodeJS.ErrnoException} */\n const error = new TypeError(\n 'File URL path must not include encoded / characters'\n )\n error.code = 'ERR_INVALID_FILE_URL_PATH'\n throw error\n }\n }\n }\n\n return decodeURIComponent(pathname)\n}\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Point} Point\n * @typedef {import('unist').Position} Position\n * @typedef {import('vfile-message').Options} MessageOptions\n * @typedef {import('../index.js').Data} Data\n * @typedef {import('../index.js').Value} Value\n */\n\n/**\n * @typedef {object & {type: string, position?: Position | undefined}} NodeLike\n *\n * @typedef {Options | URL | VFile | Value} Compatible\n * Things that can be passed to the constructor.\n *\n * @typedef VFileCoreOptions\n * Set multiple values.\n * @property {string | null | undefined} [basename]\n * Set `basename` (name).\n * @property {string | null | undefined} [cwd]\n * Set `cwd` (working directory).\n * @property {Data | null | undefined} [data]\n * Set `data` (associated info).\n * @property {string | null | undefined} [dirname]\n * Set `dirname` (path w/o basename).\n * @property {string | null | undefined} [extname]\n * Set `extname` (extension with dot).\n * @property {Array | null | undefined} [history]\n * Set `history` (paths the file moved between).\n * @property {URL | string | null | undefined} [path]\n * Set `path` (current path).\n * @property {string | null | undefined} [stem]\n * Set `stem` (name without extension).\n * @property {Value | null | undefined} [value]\n * Set `value` (the contents of the file).\n *\n * @typedef Map\n * Raw source map.\n *\n * See:\n * .\n * @property {number} version\n * Which version of the source map spec this map is following.\n * @property {Array} sources\n * An array of URLs to the original source files.\n * @property {Array} names\n * An array of identifiers which can be referenced by individual mappings.\n * @property {string | undefined} [sourceRoot]\n * The URL root from which all sources are relative.\n * @property {Array | undefined} [sourcesContent]\n * An array of contents of the original source files.\n * @property {string} mappings\n * A string of base64 VLQs which contain the actual mappings.\n * @property {string} file\n * The generated file this source map is associated with.\n *\n * @typedef {Record & VFileCoreOptions} Options\n * Configuration.\n *\n * A bunch of keys that will be shallow copied over to the new file.\n *\n * @typedef {Record} ReporterSettings\n * Configuration for reporters.\n */\n\n/**\n * @template [Settings=ReporterSettings]\n * Options type.\n * @callback Reporter\n * Type for a reporter.\n * @param {Array} files\n * Files to report.\n * @param {Settings} options\n * Configuration.\n * @returns {string}\n * Report.\n */\n\nimport {VFileMessage} from 'vfile-message'\nimport {path} from 'vfile/do-not-use-conditional-minpath'\nimport {proc} from 'vfile/do-not-use-conditional-minproc'\nimport {urlToPath, isUrl} from 'vfile/do-not-use-conditional-minurl'\n\n/**\n * Order of setting (least specific to most), we need this because otherwise\n * `{stem: 'a', path: '~/b.js'}` would throw, as a path is needed before a\n * stem can be set.\n */\nconst order = /** @type {const} */ ([\n 'history',\n 'path',\n 'basename',\n 'stem',\n 'extname',\n 'dirname'\n])\n\nexport class VFile {\n /**\n * Create a new virtual file.\n *\n * `options` is treated as:\n *\n * * `string` or `Uint8Array` — `{value: options}`\n * * `URL` — `{path: options}`\n * * `VFile` — shallow copies its data over to the new file\n * * `object` — all fields are shallow copied over to the new file\n *\n * Path related fields are set in the following order (least specific to\n * most specific): `history`, `path`, `basename`, `stem`, `extname`,\n * `dirname`.\n *\n * You cannot set `dirname` or `extname` without setting either `history`,\n * `path`, `basename`, or `stem` too.\n *\n * @param {Compatible | null | undefined} [value]\n * File value.\n * @returns\n * New instance.\n */\n constructor(value) {\n /** @type {Options | VFile} */\n let options\n\n if (!value) {\n options = {}\n } else if (isUrl(value)) {\n options = {path: value}\n } else if (typeof value === 'string' || isUint8Array(value)) {\n options = {value}\n } else {\n options = value\n }\n\n /* eslint-disable no-unused-expressions */\n\n /**\n * Base of `path` (default: `process.cwd()` or `'/'` in browsers).\n *\n * @type {string}\n */\n this.cwd = proc.cwd()\n\n /**\n * Place to store custom info (default: `{}`).\n *\n * It’s OK to store custom data directly on the file but moving it to\n * `data` is recommended.\n *\n * @type {Data}\n */\n this.data = {}\n\n /**\n * List of file paths the file moved between.\n *\n * The first is the original path and the last is the current path.\n *\n * @type {Array}\n */\n this.history = []\n\n /**\n * List of messages associated with the file.\n *\n * @type {Array}\n */\n this.messages = []\n\n /**\n * Raw value.\n *\n * @type {Value}\n */\n this.value\n\n // The below are non-standard, they are “well-known”.\n // As in, used in several tools.\n /**\n * Source map.\n *\n * This type is equivalent to the `RawSourceMap` type from the `source-map`\n * module.\n *\n * @type {Map | null | undefined}\n */\n this.map\n\n /**\n * Custom, non-string, compiled, representation.\n *\n * This is used by unified to store non-string results.\n * One example is when turning markdown into React nodes.\n *\n * @type {unknown}\n */\n this.result\n\n /**\n * Whether a file was saved to disk.\n *\n * This is used by vfile reporters.\n *\n * @type {boolean}\n */\n this.stored\n /* eslint-enable no-unused-expressions */\n\n // Set path related properties in the correct order.\n let index = -1\n\n while (++index < order.length) {\n const prop = order[index]\n\n // Note: we specifically use `in` instead of `hasOwnProperty` to accept\n // `vfile`s too.\n if (\n prop in options &&\n options[prop] !== undefined &&\n options[prop] !== null\n ) {\n // @ts-expect-error: TS doesn’t understand basic reality.\n this[prop] = prop === 'history' ? [...options[prop]] : options[prop]\n }\n }\n\n /** @type {string} */\n let prop\n\n // Set non-path related properties.\n for (prop in options) {\n // @ts-expect-error: fine to set other things.\n if (!order.includes(prop)) {\n // @ts-expect-error: fine to set other things.\n this[prop] = options[prop]\n }\n }\n }\n\n /**\n * Get the basename (including extname) (example: `'index.min.js'`).\n *\n * @returns {string | undefined}\n * Basename.\n */\n get basename() {\n return typeof this.path === 'string' ? path.basename(this.path) : undefined\n }\n\n /**\n * Set basename (including extname) (`'index.min.js'`).\n *\n * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\\'`\n * on windows).\n * Cannot be nullified (use `file.path = file.dirname` instead).\n *\n * @param {string} basename\n * Basename.\n * @returns {undefined}\n * Nothing.\n */\n set basename(basename) {\n assertNonEmpty(basename, 'basename')\n assertPart(basename, 'basename')\n this.path = path.join(this.dirname || '', basename)\n }\n\n /**\n * Get the parent path (example: `'~'`).\n *\n * @returns {string | undefined}\n * Dirname.\n */\n get dirname() {\n return typeof this.path === 'string' ? path.dirname(this.path) : undefined\n }\n\n /**\n * Set the parent path (example: `'~'`).\n *\n * Cannot be set if there’s no `path` yet.\n *\n * @param {string | undefined} dirname\n * Dirname.\n * @returns {undefined}\n * Nothing.\n */\n set dirname(dirname) {\n assertPath(this.basename, 'dirname')\n this.path = path.join(dirname || '', this.basename)\n }\n\n /**\n * Get the extname (including dot) (example: `'.js'`).\n *\n * @returns {string | undefined}\n * Extname.\n */\n get extname() {\n return typeof this.path === 'string' ? path.extname(this.path) : undefined\n }\n\n /**\n * Set the extname (including dot) (example: `'.js'`).\n *\n * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\\'`\n * on windows).\n * Cannot be set if there’s no `path` yet.\n *\n * @param {string | undefined} extname\n * Extname.\n * @returns {undefined}\n * Nothing.\n */\n set extname(extname) {\n assertPart(extname, 'extname')\n assertPath(this.dirname, 'extname')\n\n if (extname) {\n if (extname.codePointAt(0) !== 46 /* `.` */) {\n throw new Error('`extname` must start with `.`')\n }\n\n if (extname.includes('.', 1)) {\n throw new Error('`extname` cannot contain multiple dots')\n }\n }\n\n this.path = path.join(this.dirname, this.stem + (extname || ''))\n }\n\n /**\n * Get the full path (example: `'~/index.min.js'`).\n *\n * @returns {string}\n * Path.\n */\n get path() {\n return this.history[this.history.length - 1]\n }\n\n /**\n * Set the full path (example: `'~/index.min.js'`).\n *\n * Cannot be nullified.\n * You can set a file URL (a `URL` object with a `file:` protocol) which will\n * be turned into a path with `url.fileURLToPath`.\n *\n * @param {URL | string} path\n * Path.\n * @returns {undefined}\n * Nothing.\n */\n set path(path) {\n if (isUrl(path)) {\n path = urlToPath(path)\n }\n\n assertNonEmpty(path, 'path')\n\n if (this.path !== path) {\n this.history.push(path)\n }\n }\n\n /**\n * Get the stem (basename w/o extname) (example: `'index.min'`).\n *\n * @returns {string | undefined}\n * Stem.\n */\n get stem() {\n return typeof this.path === 'string'\n ? path.basename(this.path, this.extname)\n : undefined\n }\n\n /**\n * Set the stem (basename w/o extname) (example: `'index.min'`).\n *\n * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\\'`\n * on windows).\n * Cannot be nullified (use `file.path = file.dirname` instead).\n *\n * @param {string} stem\n * Stem.\n * @returns {undefined}\n * Nothing.\n */\n set stem(stem) {\n assertNonEmpty(stem, 'stem')\n assertPart(stem, 'stem')\n this.path = path.join(this.dirname || '', stem + (this.extname || ''))\n }\n\n // Normal prototypal methods.\n /**\n * Create a fatal message for `reason` associated with the file.\n *\n * The `fatal` field of the message is set to `true` (error; file not usable)\n * and the `file` field is set to the current file path.\n * The message is added to the `messages` field on `file`.\n *\n * > 🪦 **Note**: also has obsolete signatures.\n *\n * @overload\n * @param {string} reason\n * @param {MessageOptions | null | undefined} [options]\n * @returns {never}\n *\n * @overload\n * @param {string} reason\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @overload\n * @param {string} reason\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @overload\n * @param {string} reason\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {string | null | undefined} [origin]\n * @returns {never}\n *\n * @param {Error | VFileMessage | string} causeOrReason\n * Reason for message, should use markdown.\n * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]\n * Configuration (optional).\n * @param {string | null | undefined} [origin]\n * Place in code where the message originates (example:\n * `'my-package:my-rule'` or `'my-rule'`).\n * @returns {never}\n * Never.\n * @throws {VFileMessage}\n * Message.\n */\n fail(causeOrReason, optionsOrParentOrPlace, origin) {\n // @ts-expect-error: the overloads are fine.\n const message = this.message(causeOrReason, optionsOrParentOrPlace, origin)\n\n message.fatal = true\n\n throw message\n }\n\n /**\n * Create an info message for `reason` associated with the file.\n *\n * The `fatal` field of the message is set to `undefined` (info; change\n * likely not needed) and the `file` field is set to the current file path.\n * The message is added to the `messages` field on `file`.\n *\n * > 🪦 **Note**: also has obsolete signatures.\n *\n * @overload\n * @param {string} reason\n * @param {MessageOptions | null | undefined} [options]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @param {Error | VFileMessage | string} causeOrReason\n * Reason for message, should use markdown.\n * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]\n * Configuration (optional).\n * @param {string | null | undefined} [origin]\n * Place in code where the message originates (example:\n * `'my-package:my-rule'` or `'my-rule'`).\n * @returns {VFileMessage}\n * Message.\n */\n info(causeOrReason, optionsOrParentOrPlace, origin) {\n // @ts-expect-error: the overloads are fine.\n const message = this.message(causeOrReason, optionsOrParentOrPlace, origin)\n\n message.fatal = undefined\n\n return message\n }\n\n /**\n * Create a message for `reason` associated with the file.\n *\n * The `fatal` field of the message is set to `false` (warning; change may be\n * needed) and the `file` field is set to the current file path.\n * The message is added to the `messages` field on `file`.\n *\n * > 🪦 **Note**: also has obsolete signatures.\n *\n * @overload\n * @param {string} reason\n * @param {MessageOptions | null | undefined} [options]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {string} reason\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Node | NodeLike | null | undefined} parent\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {Point | Position | null | undefined} place\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @overload\n * @param {Error | VFileMessage} cause\n * @param {string | null | undefined} [origin]\n * @returns {VFileMessage}\n *\n * @param {Error | VFileMessage | string} causeOrReason\n * Reason for message, should use markdown.\n * @param {Node | NodeLike | MessageOptions | Point | Position | string | null | undefined} [optionsOrParentOrPlace]\n * Configuration (optional).\n * @param {string | null | undefined} [origin]\n * Place in code where the message originates (example:\n * `'my-package:my-rule'` or `'my-rule'`).\n * @returns {VFileMessage}\n * Message.\n */\n message(causeOrReason, optionsOrParentOrPlace, origin) {\n const message = new VFileMessage(\n // @ts-expect-error: the overloads are fine.\n causeOrReason,\n optionsOrParentOrPlace,\n origin\n )\n\n if (this.path) {\n message.name = this.path + ':' + message.name\n message.file = this.path\n }\n\n message.fatal = false\n\n this.messages.push(message)\n\n return message\n }\n\n /**\n * Serialize the file.\n *\n * > **Note**: which encodings are supported depends on the engine.\n * > For info on Node.js, see:\n * > .\n *\n * @param {string | null | undefined} [encoding='utf8']\n * Character encoding to understand `value` as when it’s a `Uint8Array`\n * (default: `'utf-8'`).\n * @returns {string}\n * Serialized file.\n */\n toString(encoding) {\n if (this.value === undefined) {\n return ''\n }\n\n if (typeof this.value === 'string') {\n return this.value\n }\n\n const decoder = new TextDecoder(encoding || undefined)\n return decoder.decode(this.value)\n }\n}\n\n/**\n * Assert that `part` is not a path (as in, does not contain `path.sep`).\n *\n * @param {string | null | undefined} part\n * File path part.\n * @param {string} name\n * Part name.\n * @returns {undefined}\n * Nothing.\n */\nfunction assertPart(part, name) {\n if (part && part.includes(path.sep)) {\n throw new Error(\n '`' + name + '` cannot be a path: did not expect `' + path.sep + '`'\n )\n }\n}\n\n/**\n * Assert that `part` is not empty.\n *\n * @param {string | undefined} part\n * Thing.\n * @param {string} name\n * Part name.\n * @returns {asserts part is string}\n * Nothing.\n */\nfunction assertNonEmpty(part, name) {\n if (!part) {\n throw new Error('`' + name + '` cannot be empty')\n }\n}\n\n/**\n * Assert `path` exists.\n *\n * @param {string | undefined} path\n * Path.\n * @param {string} name\n * Dependency name.\n * @returns {asserts path is string}\n * Nothing.\n */\nfunction assertPath(path, name) {\n if (!path) {\n throw new Error('Setting `' + name + '` requires `path` to be set too')\n }\n}\n\n/**\n * Assert `value` is an `Uint8Array`.\n *\n * @param {unknown} value\n * thing.\n * @returns {value is Uint8Array}\n * Whether `value` is an `Uint8Array`.\n */\nfunction isUint8Array(value) {\n return Boolean(\n value &&\n typeof value === 'object' &&\n 'byteLength' in value &&\n 'byteOffset' in value\n )\n}\n","export const CallableInstance =\n /**\n * @type {new , Result>(property: string | symbol) => (...parameters: Parameters) => Result}\n */\n (\n /** @type {unknown} */\n (\n /**\n * @this {Function}\n * @param {string | symbol} property\n * @returns {(...parameters: Array) => unknown}\n */\n function (property) {\n const self = this\n const constr = self.constructor\n const proto = /** @type {Record} */ (\n // Prototypes do exist.\n // type-coverage:ignore-next-line\n constr.prototype\n )\n const func = proto[property]\n /** @type {(...parameters: Array) => unknown} */\n const apply = function () {\n return func.apply(apply, arguments)\n }\n\n Object.setPrototypeOf(apply, proto)\n\n const names = Object.getOwnPropertyNames(func)\n\n for (const p of names) {\n const descriptor = Object.getOwnPropertyDescriptor(func, p)\n if (descriptor) Object.defineProperty(apply, p, descriptor)\n }\n\n return apply\n }\n )\n )\n","/**\n * @typedef {import('trough').Pipeline} Pipeline\n *\n * @typedef {import('unist').Node} Node\n *\n * @typedef {import('vfile').Compatible} Compatible\n * @typedef {import('vfile').Value} Value\n *\n * @typedef {import('../index.js').CompileResultMap} CompileResultMap\n * @typedef {import('../index.js').Data} Data\n * @typedef {import('../index.js').Settings} Settings\n */\n\n/**\n * @typedef {CompileResultMap[keyof CompileResultMap]} CompileResults\n * Acceptable results from compilers.\n *\n * To register custom results, add them to\n * {@link CompileResultMap `CompileResultMap`}.\n */\n\n/**\n * @template {Node} [Tree=Node]\n * The node that the compiler receives (default: `Node`).\n * @template {CompileResults} [Result=CompileResults]\n * The thing that the compiler yields (default: `CompileResults`).\n * @callback Compiler\n * A **compiler** handles the compiling of a syntax tree to something else\n * (in most cases, text) (TypeScript type).\n *\n * It is used in the stringify phase and called with a {@link Node `Node`}\n * and {@link VFile `VFile`} representation of the document to compile.\n * It should return the textual representation of the given tree (typically\n * `string`).\n *\n * > 👉 **Note**: unified typically compiles by serializing: most compilers\n * > return `string` (or `Uint8Array`).\n * > Some compilers, such as the one configured with\n * > [`rehype-react`][rehype-react], return other values (in this case, a\n * > React tree).\n * > If you’re using a compiler that doesn’t serialize, expect different\n * > result values.\n * >\n * > To register custom results in TypeScript, add them to\n * > {@link CompileResultMap `CompileResultMap`}.\n *\n * [rehype-react]: https://github.com/rehypejs/rehype-react\n * @param {Tree} tree\n * Tree to compile.\n * @param {VFile} file\n * File associated with `tree`.\n * @returns {Result}\n * New content: compiled text (`string` or `Uint8Array`, for `file.value`) or\n * something else (for `file.result`).\n */\n\n/**\n * @template {Node} [Tree=Node]\n * The node that the parser yields (default: `Node`)\n * @callback Parser\n * A **parser** handles the parsing of text to a syntax tree.\n *\n * It is used in the parse phase and is called with a `string` and\n * {@link VFile `VFile`} of the document to parse.\n * It must return the syntax tree representation of the given file\n * ({@link Node `Node`}).\n * @param {string} document\n * Document to parse.\n * @param {VFile} file\n * File associated with `document`.\n * @returns {Tree}\n * Node representing the given file.\n */\n\n/**\n * @typedef {(\n * Plugin, any, any> |\n * PluginTuple, any, any> |\n * Preset\n * )} Pluggable\n * Union of the different ways to add plugins and settings.\n */\n\n/**\n * @typedef {Array} PluggableList\n * List of plugins and presets.\n */\n\n// Note: we can’t use `callback` yet as it messes up `this`:\n// .\n/**\n * @template {Array} [PluginParameters=[]]\n * Arguments passed to the plugin (default: `[]`, the empty tuple).\n * @template {Node | string | undefined} [Input=Node]\n * Value that is expected as input (default: `Node`).\n *\n * * If the plugin returns a {@link Transformer `Transformer`}, this\n * should be the node it expects.\n * * If the plugin sets a {@link Parser `Parser`}, this should be\n * `string`.\n * * If the plugin sets a {@link Compiler `Compiler`}, this should be the\n * node it expects.\n * @template [Output=Input]\n * Value that is yielded as output (default: `Input`).\n *\n * * If the plugin returns a {@link Transformer `Transformer`}, this\n * should be the node that that yields.\n * * If the plugin sets a {@link Parser `Parser`}, this should be the\n * node that it yields.\n * * If the plugin sets a {@link Compiler `Compiler`}, this should be\n * result it yields.\n * @typedef {(\n * (this: Processor, ...parameters: PluginParameters) =>\n * Input extends string ? // Parser.\n * Output extends Node | undefined ? undefined | void : never :\n * Output extends CompileResults ? // Compiler.\n * Input extends Node | undefined ? undefined | void : never :\n * Transformer<\n * Input extends Node ? Input : Node,\n * Output extends Node ? Output : Node\n * > | undefined | void\n * )} Plugin\n * Single plugin.\n *\n * Plugins configure the processors they are applied on in the following\n * ways:\n *\n * * they change the processor, such as the parser, the compiler, or by\n * configuring data\n * * they specify how to handle trees and files\n *\n * In practice, they are functions that can receive options and configure the\n * processor (`this`).\n *\n * > 👉 **Note**: plugins are called when the processor is *frozen*, not when\n * > they are applied.\n */\n\n/**\n * Tuple of a plugin and its configuration.\n *\n * The first item is a plugin, the rest are its parameters.\n *\n * @template {Array} [TupleParameters=[]]\n * Arguments passed to the plugin (default: `[]`, the empty tuple).\n * @template {Node | string | undefined} [Input=undefined]\n * Value that is expected as input (optional).\n *\n * * If the plugin returns a {@link Transformer `Transformer`}, this\n * should be the node it expects.\n * * If the plugin sets a {@link Parser `Parser`}, this should be\n * `string`.\n * * If the plugin sets a {@link Compiler `Compiler`}, this should be the\n * node it expects.\n * @template [Output=undefined] (optional).\n * Value that is yielded as output.\n *\n * * If the plugin returns a {@link Transformer `Transformer`}, this\n * should be the node that that yields.\n * * If the plugin sets a {@link Parser `Parser`}, this should be the\n * node that it yields.\n * * If the plugin sets a {@link Compiler `Compiler`}, this should be\n * result it yields.\n * @typedef {(\n * [\n * plugin: Plugin,\n * ...parameters: TupleParameters\n * ]\n * )} PluginTuple\n */\n\n/**\n * @typedef Preset\n * Sharable configuration.\n *\n * They can contain plugins and settings.\n * @property {PluggableList | undefined} [plugins]\n * List of plugins and presets (optional).\n * @property {Settings | undefined} [settings]\n * Shared settings for parsers and compilers (optional).\n */\n\n/**\n * @template {VFile} [File=VFile]\n * The file that the callback receives (default: `VFile`).\n * @callback ProcessCallback\n * Callback called when the process is done.\n *\n * Called with either an error or a result.\n * @param {Error | undefined} [error]\n * Fatal error (optional).\n * @param {File | undefined} [file]\n * Processed file (optional).\n * @returns {undefined}\n * Nothing.\n */\n\n/**\n * @template {Node} [Tree=Node]\n * The tree that the callback receives (default: `Node`).\n * @callback RunCallback\n * Callback called when transformers are done.\n *\n * Called with either an error or results.\n * @param {Error | undefined} [error]\n * Fatal error (optional).\n * @param {Tree | undefined} [tree]\n * Transformed tree (optional).\n * @param {VFile | undefined} [file]\n * File (optional).\n * @returns {undefined}\n * Nothing.\n */\n\n/**\n * @template {Node} [Output=Node]\n * Node type that the transformer yields (default: `Node`).\n * @callback TransformCallback\n * Callback passed to transforms.\n *\n * If the signature of a `transformer` accepts a third argument, the\n * transformer may perform asynchronous operations, and must call it.\n * @param {Error | undefined} [error]\n * Fatal error to stop the process (optional).\n * @param {Output | undefined} [tree]\n * New, changed, tree (optional).\n * @param {VFile | undefined} [file]\n * New, changed, file (optional).\n * @returns {undefined}\n * Nothing.\n */\n\n/**\n * @template {Node} [Input=Node]\n * Node type that the transformer expects (default: `Node`).\n * @template {Node} [Output=Input]\n * Node type that the transformer yields (default: `Input`).\n * @callback Transformer\n * Transformers handle syntax trees and files.\n *\n * They are functions that are called each time a syntax tree and file are\n * passed through the run phase.\n * When an error occurs in them (either because it’s thrown, returned,\n * rejected, or passed to `next`), the process stops.\n *\n * The run phase is handled by [`trough`][trough], see its documentation for\n * the exact semantics of these functions.\n *\n * > 👉 **Note**: you should likely ignore `next`: don’t accept it.\n * > it supports callback-style async work.\n * > But promises are likely easier to reason about.\n *\n * [trough]: https://github.com/wooorm/trough#function-fninput-next\n * @param {Input} tree\n * Tree to handle.\n * @param {VFile} file\n * File to handle.\n * @param {TransformCallback} next\n * Callback.\n * @returns {(\n * Promise |\n * Promise | // For some reason this is needed separately.\n * Output |\n * Error |\n * undefined |\n * void\n * )}\n * If you accept `next`, nothing.\n * Otherwise:\n *\n * * `Error` — fatal error to stop the process\n * * `Promise` or `undefined` — the next transformer keeps using\n * same tree\n * * `Promise` or `Node` — new, changed, tree\n */\n\n/**\n * @template {Node | undefined} ParseTree\n * Output of `parse`.\n * @template {Node | undefined} HeadTree\n * Input for `run`.\n * @template {Node | undefined} TailTree\n * Output for `run`.\n * @template {Node | undefined} CompileTree\n * Input of `stringify`.\n * @template {CompileResults | undefined} CompileResult\n * Output of `stringify`.\n * @template {Node | string | undefined} Input\n * Input of plugin.\n * @template Output\n * Output of plugin (optional).\n * @typedef {(\n * Input extends string\n * ? Output extends Node | undefined\n * ? // Parser.\n * Processor<\n * Output extends undefined ? ParseTree : Output,\n * HeadTree,\n * TailTree,\n * CompileTree,\n * CompileResult\n * >\n * : // Unknown.\n * Processor\n * : Output extends CompileResults\n * ? Input extends Node | undefined\n * ? // Compiler.\n * Processor<\n * ParseTree,\n * HeadTree,\n * TailTree,\n * Input extends undefined ? CompileTree : Input,\n * Output extends undefined ? CompileResult : Output\n * >\n * : // Unknown.\n * Processor\n * : Input extends Node | undefined\n * ? Output extends Node | undefined\n * ? // Transform.\n * Processor<\n * ParseTree,\n * HeadTree extends undefined ? Input : HeadTree,\n * Output extends undefined ? TailTree : Output,\n * CompileTree,\n * CompileResult\n * >\n * : // Unknown.\n * Processor\n * : // Unknown.\n * Processor\n * )} UsePlugin\n * Create a processor based on the input/output of a {@link Plugin plugin}.\n */\n\n/**\n * @template {CompileResults | undefined} Result\n * Node type that the transformer yields.\n * @typedef {(\n * Result extends Value | undefined ?\n * VFile :\n * VFile & {result: Result}\n * )} VFileWithOutput\n * Type to generate a {@link VFile `VFile`} corresponding to a compiler result.\n *\n * If a result that is not acceptable on a `VFile` is used, that will\n * be stored on the `result` field of {@link VFile `VFile`}.\n */\n\nimport {bail} from 'bail'\nimport extend from 'extend'\nimport {ok as assert} from 'devlop'\nimport isPlainObj from 'is-plain-obj'\nimport {trough} from 'trough'\nimport {VFile} from 'vfile'\nimport {CallableInstance} from './callable-instance.js'\n\n// To do: next major: drop `Compiler`, `Parser`: prefer lowercase.\n\n// To do: we could start yielding `never` in TS when a parser is missing and\n// `parse` is called.\n// Currently, we allow directly setting `processor.parser`, which is untyped.\n\nconst own = {}.hasOwnProperty\n\n/**\n * @template {Node | undefined} [ParseTree=undefined]\n * Output of `parse` (optional).\n * @template {Node | undefined} [HeadTree=undefined]\n * Input for `run` (optional).\n * @template {Node | undefined} [TailTree=undefined]\n * Output for `run` (optional).\n * @template {Node | undefined} [CompileTree=undefined]\n * Input of `stringify` (optional).\n * @template {CompileResults | undefined} [CompileResult=undefined]\n * Output of `stringify` (optional).\n * @extends {CallableInstance<[], Processor>}\n */\nexport class Processor extends CallableInstance {\n /**\n * Create a processor.\n */\n constructor() {\n // If `Processor()` is called (w/o new), `copy` is called instead.\n super('copy')\n\n /**\n * Compiler to use (deprecated).\n *\n * @deprecated\n * Use `compiler` instead.\n * @type {(\n * Compiler<\n * CompileTree extends undefined ? Node : CompileTree,\n * CompileResult extends undefined ? CompileResults : CompileResult\n * > |\n * undefined\n * )}\n */\n this.Compiler = undefined\n\n /**\n * Parser to use (deprecated).\n *\n * @deprecated\n * Use `parser` instead.\n * @type {(\n * Parser |\n * undefined\n * )}\n */\n this.Parser = undefined\n\n // Note: the following fields are considered private.\n // However, they are needed for tests, and TSC generates an untyped\n // `private freezeIndex` field for, which trips `type-coverage` up.\n // Instead, we use `@deprecated` to visualize that they shouldn’t be used.\n /**\n * Internal list of configured plugins.\n *\n * @deprecated\n * This is a private internal property and should not be used.\n * @type {Array>>}\n */\n this.attachers = []\n\n /**\n * Compiler to use.\n *\n * @type {(\n * Compiler<\n * CompileTree extends undefined ? Node : CompileTree,\n * CompileResult extends undefined ? CompileResults : CompileResult\n * > |\n * undefined\n * )}\n */\n this.compiler = undefined\n\n /**\n * Internal state to track where we are while freezing.\n *\n * @deprecated\n * This is a private internal property and should not be used.\n * @type {number}\n */\n this.freezeIndex = -1\n\n /**\n * Internal state to track whether we’re frozen.\n *\n * @deprecated\n * This is a private internal property and should not be used.\n * @type {boolean | undefined}\n */\n this.frozen = undefined\n\n /**\n * Internal state.\n *\n * @deprecated\n * This is a private internal property and should not be used.\n * @type {Data}\n */\n this.namespace = {}\n\n /**\n * Parser to use.\n *\n * @type {(\n * Parser |\n * undefined\n * )}\n */\n this.parser = undefined\n\n /**\n * Internal list of configured transformers.\n *\n * @deprecated\n * This is a private internal property and should not be used.\n * @type {Pipeline}\n */\n this.transformers = trough()\n }\n\n /**\n * Copy a processor.\n *\n * @deprecated\n * This is a private internal method and should not be used.\n * @returns {Processor}\n * New *unfrozen* processor ({@link Processor `Processor`}) that is\n * configured to work the same as its ancestor.\n * When the descendant processor is configured in the future it does not\n * affect the ancestral processor.\n */\n copy() {\n // Cast as the type parameters will be the same after attaching.\n const destination =\n /** @type {Processor} */ (\n new Processor()\n )\n let index = -1\n\n while (++index < this.attachers.length) {\n const attacher = this.attachers[index]\n destination.use(...attacher)\n }\n\n destination.data(extend(true, {}, this.namespace))\n\n return destination\n }\n\n /**\n * Configure the processor with info available to all plugins.\n * Information is stored in an object.\n *\n * Typically, options can be given to a specific plugin, but sometimes it\n * makes sense to have information shared with several plugins.\n * For example, a list of HTML elements that are self-closing, which is\n * needed during all phases.\n *\n * > 👉 **Note**: setting information cannot occur on *frozen* processors.\n * > Call the processor first to create a new unfrozen processor.\n *\n * > 👉 **Note**: to register custom data in TypeScript, augment the\n * > {@link Data `Data`} interface.\n *\n * @example\n * This example show how to get and set info:\n *\n * ```js\n * import {unified} from 'unified'\n *\n * const processor = unified().data('alpha', 'bravo')\n *\n * processor.data('alpha') // => 'bravo'\n *\n * processor.data() // => {alpha: 'bravo'}\n *\n * processor.data({charlie: 'delta'})\n *\n * processor.data() // => {charlie: 'delta'}\n * ```\n *\n * @template {keyof Data} Key\n *\n * @overload\n * @returns {Data}\n *\n * @overload\n * @param {Data} dataset\n * @returns {Processor}\n *\n * @overload\n * @param {Key} key\n * @returns {Data[Key]}\n *\n * @overload\n * @param {Key} key\n * @param {Data[Key]} value\n * @returns {Processor}\n *\n * @param {Data | Key} [key]\n * Key to get or set, or entire dataset to set, or nothing to get the\n * entire dataset (optional).\n * @param {Data[Key]} [value]\n * Value to set (optional).\n * @returns {unknown}\n * The current processor when setting, the value at `key` when getting, or\n * the entire dataset when getting without key.\n */\n data(key, value) {\n if (typeof key === 'string') {\n // Set `key`.\n if (arguments.length === 2) {\n assertUnfrozen('data', this.frozen)\n this.namespace[key] = value\n return this\n }\n\n // Get `key`.\n return (own.call(this.namespace, key) && this.namespace[key]) || undefined\n }\n\n // Set space.\n if (key) {\n assertUnfrozen('data', this.frozen)\n this.namespace = key\n return this\n }\n\n // Get space.\n return this.namespace\n }\n\n /**\n * Freeze a processor.\n *\n * Frozen processors are meant to be extended and not to be configured\n * directly.\n *\n * When a processor is frozen it cannot be unfrozen.\n * New processors working the same way can be created by calling the\n * processor.\n *\n * It’s possible to freeze processors explicitly by calling `.freeze()`.\n * Processors freeze automatically when `.parse()`, `.run()`, `.runSync()`,\n * `.stringify()`, `.process()`, or `.processSync()` are called.\n *\n * @returns {Processor}\n * The current processor.\n */\n freeze() {\n if (this.frozen) {\n return this\n }\n\n // Cast so that we can type plugins easier.\n // Plugins are supposed to be usable on different processors, not just on\n // this exact processor.\n const self = /** @type {Processor} */ (/** @type {unknown} */ (this))\n\n while (++this.freezeIndex < this.attachers.length) {\n const [attacher, ...options] = this.attachers[this.freezeIndex]\n\n if (options[0] === false) {\n continue\n }\n\n if (options[0] === true) {\n options[0] = undefined\n }\n\n const transformer = attacher.call(self, ...options)\n\n if (typeof transformer === 'function') {\n this.transformers.use(transformer)\n }\n }\n\n this.frozen = true\n this.freezeIndex = Number.POSITIVE_INFINITY\n\n return this\n }\n\n /**\n * Parse text to a syntax tree.\n *\n * > 👉 **Note**: `parse` freezes the processor if not already *frozen*.\n *\n * > 👉 **Note**: `parse` performs the parse phase, not the run phase or other\n * > phases.\n *\n * @param {Compatible | undefined} [file]\n * file to parse (optional); typically `string` or `VFile`; any value\n * accepted as `x` in `new VFile(x)`.\n * @returns {ParseTree extends undefined ? Node : ParseTree}\n * Syntax tree representing `file`.\n */\n parse(file) {\n this.freeze()\n const realFile = vfile(file)\n const parser = this.parser || this.Parser\n assertParser('parse', parser)\n return parser(String(realFile), realFile)\n }\n\n /**\n * Process the given file as configured on the processor.\n *\n * > 👉 **Note**: `process` freezes the processor if not already *frozen*.\n *\n * > 👉 **Note**: `process` performs the parse, run, and stringify phases.\n *\n * @overload\n * @param {Compatible | undefined} file\n * @param {ProcessCallback>} done\n * @returns {undefined}\n *\n * @overload\n * @param {Compatible | undefined} [file]\n * @returns {Promise>}\n *\n * @param {Compatible | undefined} [file]\n * File (optional); typically `string` or `VFile`]; any value accepted as\n * `x` in `new VFile(x)`.\n * @param {ProcessCallback> | undefined} [done]\n * Callback (optional).\n * @returns {Promise | undefined}\n * Nothing if `done` is given.\n * Otherwise a promise, rejected with a fatal error or resolved with the\n * processed file.\n *\n * The parsed, transformed, and compiled value is available at\n * `file.value` (see note).\n *\n * > 👉 **Note**: unified typically compiles by serializing: most\n * > compilers return `string` (or `Uint8Array`).\n * > Some compilers, such as the one configured with\n * > [`rehype-react`][rehype-react], return other values (in this case, a\n * > React tree).\n * > If you’re using a compiler that doesn’t serialize, expect different\n * > result values.\n * >\n * > To register custom results in TypeScript, add them to\n * > {@link CompileResultMap `CompileResultMap`}.\n *\n * [rehype-react]: https://github.com/rehypejs/rehype-react\n */\n process(file, done) {\n const self = this\n\n this.freeze()\n assertParser('process', this.parser || this.Parser)\n assertCompiler('process', this.compiler || this.Compiler)\n\n return done ? executor(undefined, done) : new Promise(executor)\n\n // Note: `void`s needed for TS.\n /**\n * @param {((file: VFileWithOutput) => undefined | void) | undefined} resolve\n * @param {(error: Error | undefined) => undefined | void} reject\n * @returns {undefined}\n */\n function executor(resolve, reject) {\n const realFile = vfile(file)\n // Assume `ParseTree` (the result of the parser) matches `HeadTree` (the\n // input of the first transform).\n const parseTree =\n /** @type {HeadTree extends undefined ? Node : HeadTree} */ (\n /** @type {unknown} */ (self.parse(realFile))\n )\n\n self.run(parseTree, realFile, function (error, tree, file) {\n if (error || !tree || !file) {\n return realDone(error)\n }\n\n // Assume `TailTree` (the output of the last transform) matches\n // `CompileTree` (the input of the compiler).\n const compileTree =\n /** @type {CompileTree extends undefined ? Node : CompileTree} */ (\n /** @type {unknown} */ (tree)\n )\n\n const compileResult = self.stringify(compileTree, file)\n\n if (looksLikeAValue(compileResult)) {\n file.value = compileResult\n } else {\n file.result = compileResult\n }\n\n realDone(error, /** @type {VFileWithOutput} */ (file))\n })\n\n /**\n * @param {Error | undefined} error\n * @param {VFileWithOutput | undefined} [file]\n * @returns {undefined}\n */\n function realDone(error, file) {\n if (error || !file) {\n reject(error)\n } else if (resolve) {\n resolve(file)\n } else {\n assert(done, '`done` is defined if `resolve` is not')\n done(undefined, file)\n }\n }\n }\n }\n\n /**\n * Process the given file as configured on the processor.\n *\n * An error is thrown if asynchronous transforms are configured.\n *\n * > 👉 **Note**: `processSync` freezes the processor if not already *frozen*.\n *\n * > 👉 **Note**: `processSync` performs the parse, run, and stringify phases.\n *\n * @param {Compatible | undefined} [file]\n * File (optional); typically `string` or `VFile`; any value accepted as\n * `x` in `new VFile(x)`.\n * @returns {VFileWithOutput}\n * The processed file.\n *\n * The parsed, transformed, and compiled value is available at\n * `file.value` (see note).\n *\n * > 👉 **Note**: unified typically compiles by serializing: most\n * > compilers return `string` (or `Uint8Array`).\n * > Some compilers, such as the one configured with\n * > [`rehype-react`][rehype-react], return other values (in this case, a\n * > React tree).\n * > If you’re using a compiler that doesn’t serialize, expect different\n * > result values.\n * >\n * > To register custom results in TypeScript, add them to\n * > {@link CompileResultMap `CompileResultMap`}.\n *\n * [rehype-react]: https://github.com/rehypejs/rehype-react\n */\n processSync(file) {\n /** @type {boolean} */\n let complete = false\n /** @type {VFileWithOutput | undefined} */\n let result\n\n this.freeze()\n assertParser('processSync', this.parser || this.Parser)\n assertCompiler('processSync', this.compiler || this.Compiler)\n\n this.process(file, realDone)\n assertDone('processSync', 'process', complete)\n assert(result, 'we either bailed on an error or have a tree')\n\n return result\n\n /**\n * @type {ProcessCallback>}\n */\n function realDone(error, file) {\n complete = true\n bail(error)\n result = file\n }\n }\n\n /**\n * Run *transformers* on a syntax tree.\n *\n * > 👉 **Note**: `run` freezes the processor if not already *frozen*.\n *\n * > 👉 **Note**: `run` performs the run phase, not other phases.\n *\n * @overload\n * @param {HeadTree extends undefined ? Node : HeadTree} tree\n * @param {RunCallback} done\n * @returns {undefined}\n *\n * @overload\n * @param {HeadTree extends undefined ? Node : HeadTree} tree\n * @param {Compatible | undefined} file\n * @param {RunCallback} done\n * @returns {undefined}\n *\n * @overload\n * @param {HeadTree extends undefined ? Node : HeadTree} tree\n * @param {Compatible | undefined} [file]\n * @returns {Promise}\n *\n * @param {HeadTree extends undefined ? Node : HeadTree} tree\n * Tree to transform and inspect.\n * @param {(\n * RunCallback |\n * Compatible\n * )} [file]\n * File associated with `node` (optional); any value accepted as `x` in\n * `new VFile(x)`.\n * @param {RunCallback} [done]\n * Callback (optional).\n * @returns {Promise | undefined}\n * Nothing if `done` is given.\n * Otherwise, a promise rejected with a fatal error or resolved with the\n * transformed tree.\n */\n run(tree, file, done) {\n assertNode(tree)\n this.freeze()\n\n const transformers = this.transformers\n\n if (!done && typeof file === 'function') {\n done = file\n file = undefined\n }\n\n return done ? executor(undefined, done) : new Promise(executor)\n\n // Note: `void`s needed for TS.\n /**\n * @param {(\n * ((tree: TailTree extends undefined ? Node : TailTree) => undefined | void) |\n * undefined\n * )} resolve\n * @param {(error: Error) => undefined | void} reject\n * @returns {undefined}\n */\n function executor(resolve, reject) {\n assert(\n typeof file !== 'function',\n '`file` can’t be a `done` anymore, we checked'\n )\n const realFile = vfile(file)\n transformers.run(tree, realFile, realDone)\n\n /**\n * @param {Error | undefined} error\n * @param {Node} outputTree\n * @param {VFile} file\n * @returns {undefined}\n */\n function realDone(error, outputTree, file) {\n const resultingTree =\n /** @type {TailTree extends undefined ? Node : TailTree} */ (\n outputTree || tree\n )\n\n if (error) {\n reject(error)\n } else if (resolve) {\n resolve(resultingTree)\n } else {\n assert(done, '`done` is defined if `resolve` is not')\n done(undefined, resultingTree, file)\n }\n }\n }\n }\n\n /**\n * Run *transformers* on a syntax tree.\n *\n * An error is thrown if asynchronous transforms are configured.\n *\n * > 👉 **Note**: `runSync` freezes the processor if not already *frozen*.\n *\n * > 👉 **Note**: `runSync` performs the run phase, not other phases.\n *\n * @param {HeadTree extends undefined ? Node : HeadTree} tree\n * Tree to transform and inspect.\n * @param {Compatible | undefined} [file]\n * File associated with `node` (optional); any value accepted as `x` in\n * `new VFile(x)`.\n * @returns {TailTree extends undefined ? Node : TailTree}\n * Transformed tree.\n */\n runSync(tree, file) {\n /** @type {boolean} */\n let complete = false\n /** @type {(TailTree extends undefined ? Node : TailTree) | undefined} */\n let result\n\n this.run(tree, file, realDone)\n\n assertDone('runSync', 'run', complete)\n assert(result, 'we either bailed on an error or have a tree')\n return result\n\n /**\n * @type {RunCallback}\n */\n function realDone(error, tree) {\n bail(error)\n result = tree\n complete = true\n }\n }\n\n /**\n * Compile a syntax tree.\n *\n * > 👉 **Note**: `stringify` freezes the processor if not already *frozen*.\n *\n * > 👉 **Note**: `stringify` performs the stringify phase, not the run phase\n * > or other phases.\n *\n * @param {CompileTree extends undefined ? Node : CompileTree} tree\n * Tree to compile.\n * @param {Compatible | undefined} [file]\n * File associated with `node` (optional); any value accepted as `x` in\n * `new VFile(x)`.\n * @returns {CompileResult extends undefined ? Value : CompileResult}\n * Textual representation of the tree (see note).\n *\n * > 👉 **Note**: unified typically compiles by serializing: most compilers\n * > return `string` (or `Uint8Array`).\n * > Some compilers, such as the one configured with\n * > [`rehype-react`][rehype-react], return other values (in this case, a\n * > React tree).\n * > If you’re using a compiler that doesn’t serialize, expect different\n * > result values.\n * >\n * > To register custom results in TypeScript, add them to\n * > {@link CompileResultMap `CompileResultMap`}.\n *\n * [rehype-react]: https://github.com/rehypejs/rehype-react\n */\n stringify(tree, file) {\n this.freeze()\n const realFile = vfile(file)\n const compiler = this.compiler || this.Compiler\n assertCompiler('stringify', compiler)\n assertNode(tree)\n\n return compiler(tree, realFile)\n }\n\n /**\n * Configure the processor to use a plugin, a list of usable values, or a\n * preset.\n *\n * If the processor is already using a plugin, the previous plugin\n * configuration is changed based on the options that are passed in.\n * In other words, the plugin is not added a second time.\n *\n * > 👉 **Note**: `use` cannot be called on *frozen* processors.\n * > Call the processor first to create a new unfrozen processor.\n *\n * @example\n * There are many ways to pass plugins to `.use()`.\n * This example gives an overview:\n *\n * ```js\n * import {unified} from 'unified'\n *\n * unified()\n * // Plugin with options:\n * .use(pluginA, {x: true, y: true})\n * // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):\n * .use(pluginA, {y: false, z: true})\n * // Plugins:\n * .use([pluginB, pluginC])\n * // Two plugins, the second with options:\n * .use([pluginD, [pluginE, {}]])\n * // Preset with plugins and settings:\n * .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})\n * // Settings only:\n * .use({settings: {position: false}})\n * ```\n *\n * @template {Array} [Parameters=[]]\n * @template {Node | string | undefined} [Input=undefined]\n * @template [Output=Input]\n *\n * @overload\n * @param {Preset | null | undefined} [preset]\n * @returns {Processor}\n *\n * @overload\n * @param {PluggableList} list\n * @returns {Processor}\n *\n * @overload\n * @param {Plugin} plugin\n * @param {...(Parameters | [boolean])} parameters\n * @returns {UsePlugin}\n *\n * @param {PluggableList | Plugin | Preset | null | undefined} value\n * Usable value.\n * @param {...unknown} parameters\n * Parameters, when a plugin is given as a usable value.\n * @returns {Processor}\n * Current processor.\n */\n use(value, ...parameters) {\n const attachers = this.attachers\n const namespace = this.namespace\n\n assertUnfrozen('use', this.frozen)\n\n if (value === null || value === undefined) {\n // Empty.\n } else if (typeof value === 'function') {\n addPlugin(value, parameters)\n } else if (typeof value === 'object') {\n if (Array.isArray(value)) {\n addList(value)\n } else {\n addPreset(value)\n }\n } else {\n throw new TypeError('Expected usable value, not `' + value + '`')\n }\n\n return this\n\n /**\n * @param {Pluggable} value\n * @returns {undefined}\n */\n function add(value) {\n if (typeof value === 'function') {\n addPlugin(value, [])\n } else if (typeof value === 'object') {\n if (Array.isArray(value)) {\n const [plugin, ...parameters] =\n /** @type {PluginTuple>} */ (value)\n addPlugin(plugin, parameters)\n } else {\n addPreset(value)\n }\n } else {\n throw new TypeError('Expected usable value, not `' + value + '`')\n }\n }\n\n /**\n * @param {Preset} result\n * @returns {undefined}\n */\n function addPreset(result) {\n if (!('plugins' in result) && !('settings' in result)) {\n throw new Error(\n 'Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither'\n )\n }\n\n addList(result.plugins)\n\n if (result.settings) {\n namespace.settings = extend(true, namespace.settings, result.settings)\n }\n }\n\n /**\n * @param {PluggableList | null | undefined} plugins\n * @returns {undefined}\n */\n function addList(plugins) {\n let index = -1\n\n if (plugins === null || plugins === undefined) {\n // Empty.\n } else if (Array.isArray(plugins)) {\n while (++index < plugins.length) {\n const thing = plugins[index]\n add(thing)\n }\n } else {\n throw new TypeError('Expected a list of plugins, not `' + plugins + '`')\n }\n }\n\n /**\n * @param {Plugin} plugin\n * @param {Array} parameters\n * @returns {undefined}\n */\n function addPlugin(plugin, parameters) {\n let index = -1\n let entryIndex = -1\n\n while (++index < attachers.length) {\n if (attachers[index][0] === plugin) {\n entryIndex = index\n break\n }\n }\n\n if (entryIndex === -1) {\n attachers.push([plugin, ...parameters])\n }\n // Only set if there was at least a `primary` value, otherwise we’d change\n // `arguments.length`.\n else if (parameters.length > 0) {\n let [primary, ...rest] = parameters\n const currentPrimary = attachers[entryIndex][1]\n if (isPlainObj(currentPrimary) && isPlainObj(primary)) {\n primary = extend(true, currentPrimary, primary)\n }\n\n attachers[entryIndex] = [plugin, primary, ...rest]\n }\n }\n }\n}\n\n// Note: this returns a *callable* instance.\n// That’s why it’s documented as a function.\n/**\n * Create a new processor.\n *\n * @example\n * This example shows how a new processor can be created (from `remark`) and linked\n * to **stdin**(4) and **stdout**(4).\n *\n * ```js\n * import process from 'node:process'\n * import concatStream from 'concat-stream'\n * import {remark} from 'remark'\n *\n * process.stdin.pipe(\n * concatStream(function (buf) {\n * process.stdout.write(String(remark().processSync(buf)))\n * })\n * )\n * ```\n *\n * @returns\n * New *unfrozen* processor (`processor`).\n *\n * This processor is configured to work the same as its ancestor.\n * When the descendant processor is configured in the future it does not\n * affect the ancestral processor.\n */\nexport const unified = new Processor().freeze()\n\n/**\n * Assert a parser is available.\n *\n * @param {string} name\n * @param {unknown} value\n * @returns {asserts value is Parser}\n */\nfunction assertParser(name, value) {\n if (typeof value !== 'function') {\n throw new TypeError('Cannot `' + name + '` without `parser`')\n }\n}\n\n/**\n * Assert a compiler is available.\n *\n * @param {string} name\n * @param {unknown} value\n * @returns {asserts value is Compiler}\n */\nfunction assertCompiler(name, value) {\n if (typeof value !== 'function') {\n throw new TypeError('Cannot `' + name + '` without `compiler`')\n }\n}\n\n/**\n * Assert the processor is not frozen.\n *\n * @param {string} name\n * @param {unknown} frozen\n * @returns {asserts frozen is false}\n */\nfunction assertUnfrozen(name, frozen) {\n if (frozen) {\n throw new Error(\n 'Cannot call `' +\n name +\n '` on a frozen processor.\\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.'\n )\n }\n}\n\n/**\n * Assert `node` is a unist node.\n *\n * @param {unknown} node\n * @returns {asserts node is Node}\n */\nfunction assertNode(node) {\n // `isPlainObj` unfortunately uses `any` instead of `unknown`.\n // type-coverage:ignore-next-line\n if (!isPlainObj(node) || typeof node.type !== 'string') {\n throw new TypeError('Expected node, got `' + node + '`')\n // Fine.\n }\n}\n\n/**\n * Assert that `complete` is `true`.\n *\n * @param {string} name\n * @param {string} asyncName\n * @param {unknown} complete\n * @returns {asserts complete is true}\n */\nfunction assertDone(name, asyncName, complete) {\n if (!complete) {\n throw new Error(\n '`' + name + '` finished async. Use `' + asyncName + '` instead'\n )\n }\n}\n\n/**\n * @param {Compatible | undefined} [value]\n * @returns {VFile}\n */\nfunction vfile(value) {\n return looksLikeAVFile(value) ? value : new VFile(value)\n}\n\n/**\n * @param {Compatible | undefined} [value]\n * @returns {value is VFile}\n */\nfunction looksLikeAVFile(value) {\n return Boolean(\n value &&\n typeof value === 'object' &&\n 'message' in value &&\n 'messages' in value\n )\n}\n\n/**\n * @param {unknown} [value]\n * @returns {value is Value}\n */\nfunction looksLikeAValue(value) {\n return typeof value === 'string' || isUint8Array(value)\n}\n\n/**\n * Assert `value` is an `Uint8Array`.\n *\n * @param {unknown} value\n * thing.\n * @returns {value is Uint8Array}\n * Whether `value` is an `Uint8Array`.\n */\nfunction isUint8Array(value) {\n return Boolean(\n value &&\n typeof value === 'object' &&\n 'byteLength' in value &&\n 'byteOffset' in value\n )\n}\n","// Register `Raw` in tree:\n/// \n\n/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').ElementContent} ElementContent\n * @typedef {import('hast').Nodes} Nodes\n * @typedef {import('hast').Parents} Parents\n * @typedef {import('hast').Root} Root\n * @typedef {import('hast-util-to-jsx-runtime').Components} JsxRuntimeComponents\n * @typedef {import('remark-rehype').Options} RemarkRehypeOptions\n * @typedef {import('unist-util-visit').BuildVisitor} Visitor\n * @typedef {import('unified').PluggableList} PluggableList\n */\n\n/**\n * @callback AllowElement\n * Filter elements.\n * @param {Readonly} element\n * Element to check.\n * @param {number} index\n * Index of `element` in `parent`.\n * @param {Readonly | undefined} parent\n * Parent of `element`.\n * @returns {boolean | null | undefined}\n * Whether to allow `element` (default: `false`).\n *\n * @typedef {Partial} Components\n * Map tag names to components.\n *\n * @typedef Deprecation\n * Deprecation.\n * @property {string} from\n * Old field.\n * @property {string} id\n * ID in readme.\n * @property {keyof Options} [to]\n * New field.\n *\n * @typedef Options\n * Configuration.\n * @property {AllowElement | null | undefined} [allowElement]\n * Filter elements (optional);\n * `allowedElements` / `disallowedElements` is used first.\n * @property {ReadonlyArray | null | undefined} [allowedElements]\n * Tag names to allow (default: all tag names);\n * cannot combine w/ `disallowedElements`.\n * @property {string | null | undefined} [children]\n * Markdown.\n * @property {string | null | undefined} [className]\n * Wrap in a `div` with this class name.\n * @property {Components | null | undefined} [components]\n * Map tag names to components.\n * @property {ReadonlyArray | null | undefined} [disallowedElements]\n * Tag names to disallow (default: `[]`);\n * cannot combine w/ `allowedElements`.\n * @property {PluggableList | null | undefined} [rehypePlugins]\n * List of rehype plugins to use.\n * @property {PluggableList | null | undefined} [remarkPlugins]\n * List of remark plugins to use.\n * @property {Readonly | null | undefined} [remarkRehypeOptions]\n * Options to pass through to `remark-rehype`.\n * @property {boolean | null | undefined} [skipHtml=false]\n * Ignore HTML in markdown completely (default: `false`).\n * @property {boolean | null | undefined} [unwrapDisallowed=false]\n * Extract (unwrap) what’s in disallowed elements (default: `false`);\n * normally when say `strong` is not allowed, it and it’s children are dropped,\n * with `unwrapDisallowed` the element itself is replaced by its children.\n * @property {UrlTransform | null | undefined} [urlTransform]\n * Change URLs (default: `defaultUrlTransform`)\n *\n * @callback UrlTransform\n * Transform all URLs.\n * @param {string} url\n * URL.\n * @param {string} key\n * Property name (example: `'href'`).\n * @param {Readonly} node\n * Node.\n * @returns {string | null | undefined}\n * Transformed URL (optional).\n */\n\nimport {unreachable} from 'devlop'\nimport {toJsxRuntime} from 'hast-util-to-jsx-runtime'\nimport {urlAttributes} from 'html-url-attributes'\n// @ts-expect-error: untyped.\nimport {Fragment, jsx, jsxs} from 'react/jsx-runtime'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport {unified} from 'unified'\nimport {visit} from 'unist-util-visit'\nimport {VFile} from 'vfile'\n\nconst changelog =\n 'https://github.com/remarkjs/react-markdown/blob/main/changelog.md'\n\n/** @type {PluggableList} */\nconst emptyPlugins = []\n/** @type {Readonly} */\nconst emptyRemarkRehypeOptions = {allowDangerousHtml: true}\nconst safeProtocol = /^(https?|ircs?|mailto|xmpp)$/i\n\n// Mutable because we `delete` any time it’s used and a message is sent.\n/** @type {ReadonlyArray>} */\nconst deprecations = [\n {from: 'astPlugins', id: 'remove-buggy-html-in-markdown-parser'},\n {from: 'allowDangerousHtml', id: 'remove-buggy-html-in-markdown-parser'},\n {\n from: 'allowNode',\n id: 'replace-allownode-allowedtypes-and-disallowedtypes',\n to: 'allowElement'\n },\n {\n from: 'allowedTypes',\n id: 'replace-allownode-allowedtypes-and-disallowedtypes',\n to: 'allowedElements'\n },\n {\n from: 'disallowedTypes',\n id: 'replace-allownode-allowedtypes-and-disallowedtypes',\n to: 'disallowedElements'\n },\n {from: 'escapeHtml', id: 'remove-buggy-html-in-markdown-parser'},\n {from: 'includeElementIndex', id: '#remove-includeelementindex'},\n {\n from: 'includeNodeIndex',\n id: 'change-includenodeindex-to-includeelementindex'\n },\n {from: 'linkTarget', id: 'remove-linktarget'},\n {from: 'plugins', id: 'change-plugins-to-remarkplugins', to: 'remarkPlugins'},\n {from: 'rawSourcePos', id: '#remove-rawsourcepos'},\n {from: 'renderers', id: 'change-renderers-to-components', to: 'components'},\n {from: 'source', id: 'change-source-to-children', to: 'children'},\n {from: 'sourcePos', id: '#remove-sourcepos'},\n {from: 'transformImageUri', id: '#add-urltransform', to: 'urlTransform'},\n {from: 'transformLinkUri', id: '#add-urltransform', to: 'urlTransform'}\n]\n\n/**\n * Component to render markdown.\n *\n * @param {Readonly} options\n * Props.\n * @returns {JSX.Element}\n * React element.\n */\nexport function Markdown(options) {\n const allowedElements = options.allowedElements\n const allowElement = options.allowElement\n const children = options.children || ''\n const className = options.className\n const components = options.components\n const disallowedElements = options.disallowedElements\n const rehypePlugins = options.rehypePlugins || emptyPlugins\n const remarkPlugins = options.remarkPlugins || emptyPlugins\n const remarkRehypeOptions = options.remarkRehypeOptions\n ? {...options.remarkRehypeOptions, ...emptyRemarkRehypeOptions}\n : emptyRemarkRehypeOptions\n const skipHtml = options.skipHtml\n const unwrapDisallowed = options.unwrapDisallowed\n const urlTransform = options.urlTransform || defaultUrlTransform\n\n const processor = unified()\n .use(remarkParse)\n .use(remarkPlugins)\n .use(remarkRehype, remarkRehypeOptions)\n .use(rehypePlugins)\n\n const file = new VFile()\n\n if (typeof children === 'string') {\n file.value = children\n } else {\n unreachable(\n 'Unexpected value `' +\n children +\n '` for `children` prop, expected `string`'\n )\n }\n\n if (allowedElements && disallowedElements) {\n unreachable(\n 'Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other'\n )\n }\n\n for (const deprecation of deprecations) {\n if (Object.hasOwn(options, deprecation.from)) {\n unreachable(\n 'Unexpected `' +\n deprecation.from +\n '` prop, ' +\n (deprecation.to\n ? 'use `' + deprecation.to + '` instead'\n : 'remove it') +\n ' (see <' +\n changelog +\n '#' +\n deprecation.id +\n '> for more info)'\n )\n }\n }\n\n const mdastTree = processor.parse(file)\n /** @type {Nodes} */\n let hastTree = processor.runSync(mdastTree, file)\n\n // Wrap in `div` if there’s a class name.\n if (className) {\n hastTree = {\n type: 'element',\n tagName: 'div',\n properties: {className},\n // Assume no doctypes.\n children: /** @type {Array} */ (\n hastTree.type === 'root' ? hastTree.children : [hastTree]\n )\n }\n }\n\n visit(hastTree, transform)\n\n return toJsxRuntime(hastTree, {\n Fragment,\n components,\n ignoreInvalidStyle: true,\n jsx,\n jsxs,\n passKeys: true,\n passNode: true\n })\n\n /** @type {Visitor} */\n function transform(node, index, parent) {\n if (node.type === 'raw' && parent && typeof index === 'number') {\n if (skipHtml) {\n parent.children.splice(index, 1)\n } else {\n parent.children[index] = {type: 'text', value: node.value}\n }\n\n return index\n }\n\n if (node.type === 'element') {\n /** @type {string} */\n let key\n\n for (key in urlAttributes) {\n if (\n Object.hasOwn(urlAttributes, key) &&\n Object.hasOwn(node.properties, key)\n ) {\n const value = node.properties[key]\n const test = urlAttributes[key]\n if (test === null || test.includes(node.tagName)) {\n node.properties[key] = urlTransform(String(value || ''), key, node)\n }\n }\n }\n }\n\n if (node.type === 'element') {\n let remove = allowedElements\n ? !allowedElements.includes(node.tagName)\n : disallowedElements\n ? disallowedElements.includes(node.tagName)\n : false\n\n if (!remove && allowElement && typeof index === 'number') {\n remove = !allowElement(node, index, parent)\n }\n\n if (remove && parent && typeof index === 'number') {\n if (unwrapDisallowed && node.children) {\n parent.children.splice(index, 1, ...node.children)\n } else {\n parent.children.splice(index, 1)\n }\n\n return index\n }\n }\n }\n}\n\n/**\n * Make a URL safe.\n *\n * @satisfies {UrlTransform}\n * @param {string} value\n * URL.\n * @returns {string}\n * Safe URL.\n */\nexport function defaultUrlTransform(value) {\n // Same as:\n // \n // But without the `encode` part.\n const colon = value.indexOf(':')\n const questionMark = value.indexOf('?')\n const numberSign = value.indexOf('#')\n const slash = value.indexOf('/')\n\n if (\n // If there is no protocol, it’s relative.\n colon < 0 ||\n // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.\n (slash > -1 && colon > slash) ||\n (questionMark > -1 && colon > questionMark) ||\n (numberSign > -1 && colon > numberSign) ||\n // It is a protocol, it should be allowed.\n safeProtocol.test(value.slice(0, colon))\n ) {\n return value\n }\n\n return ''\n}\n","/**\n * Count how often a character (or substring) is used in a string.\n *\n * @param {string} value\n * Value to search in.\n * @param {string} character\n * Character (or substring) to look for.\n * @return {number}\n * Number of times `character` occurred in `value`.\n */\nexport function ccount(value, character) {\n const source = String(value)\n\n if (typeof character !== 'string') {\n throw new TypeError('Expected character')\n }\n\n let count = 0\n let index = source.indexOf(character)\n\n while (index !== -1) {\n count++\n index = source.indexOf(character, index + character.length)\n }\n\n return count\n}\n","/**\n * @typedef {import('mdast').Nodes} Nodes\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('mdast').PhrasingContent} PhrasingContent\n * @typedef {import('mdast').Root} Root\n * @typedef {import('mdast').Text} Text\n * @typedef {import('unist-util-visit-parents').Test} Test\n * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult\n */\n\n/**\n * @typedef RegExpMatchObject\n * Info on the match.\n * @property {number} index\n * The index of the search at which the result was found.\n * @property {string} input\n * A copy of the search string in the text node.\n * @property {[...Array, Text]} stack\n * All ancestors of the text node, where the last node is the text itself.\n *\n * @typedef {RegExp | string} Find\n * Pattern to find.\n *\n * Strings are escaped and then turned into global expressions.\n *\n * @typedef {Array} FindAndReplaceList\n * Several find and replaces, in array form.\n *\n * @typedef {[Find, Replace?]} FindAndReplaceTuple\n * Find and replace in tuple form.\n *\n * @typedef {ReplaceFunction | string | null | undefined} Replace\n * Thing to replace with.\n *\n * @callback ReplaceFunction\n * Callback called when a search matches.\n * @param {...any} parameters\n * The parameters are the result of corresponding search expression:\n *\n * * `value` (`string`) — whole match\n * * `...capture` (`Array`) — matches from regex capture groups\n * * `match` (`RegExpMatchObject`) — info on the match\n * @returns {Array | PhrasingContent | string | false | null | undefined}\n * Thing to replace with.\n *\n * * when `null`, `undefined`, `''`, remove the match\n * * …or when `false`, do not replace at all\n * * …or when `string`, replace with a text node of that value\n * * …or when `Node` or `Array`, replace with those nodes\n *\n * @typedef {[RegExp, ReplaceFunction]} Pair\n * Normalized find and replace.\n *\n * @typedef {Array} Pairs\n * All find and replaced.\n *\n * @typedef Options\n * Configuration.\n * @property {Test | null | undefined} [ignore]\n * Test for which nodes to ignore (optional).\n */\n\nimport escape from 'escape-string-regexp'\nimport {visitParents} from 'unist-util-visit-parents'\nimport {convert} from 'unist-util-is'\n\n/**\n * Find patterns in a tree and replace them.\n *\n * The algorithm searches the tree in *preorder* for complete values in `Text`\n * nodes.\n * Partial matches are not supported.\n *\n * @param {Nodes} tree\n * Tree to change.\n * @param {FindAndReplaceList | FindAndReplaceTuple} list\n * Patterns to find.\n * @param {Options | null | undefined} [options]\n * Configuration (when `find` is not `Find`).\n * @returns {undefined}\n * Nothing.\n */\nexport function findAndReplace(tree, list, options) {\n const settings = options || {}\n const ignored = convert(settings.ignore || [])\n const pairs = toPairs(list)\n let pairIndex = -1\n\n while (++pairIndex < pairs.length) {\n visitParents(tree, 'text', visitor)\n }\n\n /** @type {import('unist-util-visit-parents').BuildVisitor} */\n function visitor(node, parents) {\n let index = -1\n /** @type {Parents | undefined} */\n let grandparent\n\n while (++index < parents.length) {\n const parent = parents[index]\n /** @type {Array | undefined} */\n const siblings = grandparent ? grandparent.children : undefined\n\n if (\n ignored(\n parent,\n siblings ? siblings.indexOf(parent) : undefined,\n grandparent\n )\n ) {\n return\n }\n\n grandparent = parent\n }\n\n if (grandparent) {\n return handler(node, parents)\n }\n }\n\n /**\n * Handle a text node which is not in an ignored parent.\n *\n * @param {Text} node\n * Text node.\n * @param {Array} parents\n * Parents.\n * @returns {VisitorResult}\n * Result.\n */\n function handler(node, parents) {\n const parent = parents[parents.length - 1]\n const find = pairs[pairIndex][0]\n const replace = pairs[pairIndex][1]\n let start = 0\n /** @type {Array} */\n const siblings = parent.children\n const index = siblings.indexOf(node)\n let change = false\n /** @type {Array} */\n let nodes = []\n\n find.lastIndex = 0\n\n let match = find.exec(node.value)\n\n while (match) {\n const position = match.index\n /** @type {RegExpMatchObject} */\n const matchObject = {\n index: match.index,\n input: match.input,\n stack: [...parents, node]\n }\n let value = replace(...match, matchObject)\n\n if (typeof value === 'string') {\n value = value.length > 0 ? {type: 'text', value} : undefined\n }\n\n // It wasn’t a match after all.\n if (value === false) {\n // False acts as if there was no match.\n // So we need to reset `lastIndex`, which currently being at the end of\n // the current match, to the beginning.\n find.lastIndex = position + 1\n } else {\n if (start !== position) {\n nodes.push({\n type: 'text',\n value: node.value.slice(start, position)\n })\n }\n\n if (Array.isArray(value)) {\n nodes.push(...value)\n } else if (value) {\n nodes.push(value)\n }\n\n start = position + match[0].length\n change = true\n }\n\n if (!find.global) {\n break\n }\n\n match = find.exec(node.value)\n }\n\n if (change) {\n if (start < node.value.length) {\n nodes.push({type: 'text', value: node.value.slice(start)})\n }\n\n parent.children.splice(index, 1, ...nodes)\n } else {\n nodes = [node]\n }\n\n return index + nodes.length\n }\n}\n\n/**\n * Turn a tuple or a list of tuples into pairs.\n *\n * @param {FindAndReplaceList | FindAndReplaceTuple} tupleOrList\n * Schema.\n * @returns {Pairs}\n * Clean pairs.\n */\nfunction toPairs(tupleOrList) {\n /** @type {Pairs} */\n const result = []\n\n if (!Array.isArray(tupleOrList)) {\n throw new TypeError('Expected find and replace tuple or list of tuples')\n }\n\n /** @type {FindAndReplaceList} */\n // @ts-expect-error: correct.\n const list =\n !tupleOrList[0] || Array.isArray(tupleOrList[0])\n ? tupleOrList\n : [tupleOrList]\n\n let index = -1\n\n while (++index < list.length) {\n const tuple = list[index]\n result.push([toExpression(tuple[0]), toFunction(tuple[1])])\n }\n\n return result\n}\n\n/**\n * Turn a find into an expression.\n *\n * @param {Find} find\n * Find.\n * @returns {RegExp}\n * Expression.\n */\nfunction toExpression(find) {\n return typeof find === 'string' ? new RegExp(escape(find), 'g') : find\n}\n\n/**\n * Turn a replace into a function.\n *\n * @param {Replace} replace\n * Replace.\n * @returns {ReplaceFunction}\n * Function.\n */\nfunction toFunction(replace) {\n return typeof replace === 'function'\n ? replace\n : function () {\n return replace\n }\n}\n","export default function escapeStringRegexp(string) {\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError('Expected a string');\n\t}\n\n\t// Escape characters with special meaning either inside or outside character sets.\n\t// Use a simple backslash escape when it’s always valid, and a `\\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.\n\treturn string\n\t\t.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&')\n\t\t.replace(/-/g, '\\\\x2d');\n}\n","/**\n * @typedef {import('mdast').Link} Link\n * @typedef {import('mdast').PhrasingContent} PhrasingContent\n *\n * @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext\n * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension\n * @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle\n * @typedef {import('mdast-util-from-markdown').Transform} FromMarkdownTransform\n *\n * @typedef {import('mdast-util-to-markdown').ConstructName} ConstructName\n * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension\n *\n * @typedef {import('mdast-util-find-and-replace').RegExpMatchObject} RegExpMatchObject\n * @typedef {import('mdast-util-find-and-replace').ReplaceFunction} ReplaceFunction\n */\n\nimport {ccount} from 'ccount'\nimport {ok as assert} from 'devlop'\nimport {unicodePunctuation, unicodeWhitespace} from 'micromark-util-character'\nimport {findAndReplace} from 'mdast-util-find-and-replace'\n\n/** @type {ConstructName} */\nconst inConstruct = 'phrasing'\n/** @type {Array} */\nconst notInConstruct = ['autolink', 'link', 'image', 'label']\n\n/**\n * Create an extension for `mdast-util-from-markdown` to enable GFM autolink\n * literals in markdown.\n *\n * @returns {FromMarkdownExtension}\n * Extension for `mdast-util-to-markdown` to enable GFM autolink literals.\n */\nexport function gfmAutolinkLiteralFromMarkdown() {\n return {\n transforms: [transformGfmAutolinkLiterals],\n enter: {\n literalAutolink: enterLiteralAutolink,\n literalAutolinkEmail: enterLiteralAutolinkValue,\n literalAutolinkHttp: enterLiteralAutolinkValue,\n literalAutolinkWww: enterLiteralAutolinkValue\n },\n exit: {\n literalAutolink: exitLiteralAutolink,\n literalAutolinkEmail: exitLiteralAutolinkEmail,\n literalAutolinkHttp: exitLiteralAutolinkHttp,\n literalAutolinkWww: exitLiteralAutolinkWww\n }\n }\n}\n\n/**\n * Create an extension for `mdast-util-to-markdown` to enable GFM autolink\n * literals in markdown.\n *\n * @returns {ToMarkdownExtension}\n * Extension for `mdast-util-to-markdown` to enable GFM autolink literals.\n */\nexport function gfmAutolinkLiteralToMarkdown() {\n return {\n unsafe: [\n {\n character: '@',\n before: '[+\\\\-.\\\\w]',\n after: '[\\\\-.\\\\w]',\n inConstruct,\n notInConstruct\n },\n {\n character: '.',\n before: '[Ww]',\n after: '[\\\\-.\\\\w]',\n inConstruct,\n notInConstruct\n },\n {\n character: ':',\n before: '[ps]',\n after: '\\\\/',\n inConstruct,\n notInConstruct\n }\n ]\n }\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterLiteralAutolink(token) {\n this.enter({type: 'link', title: null, url: '', children: []}, token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterLiteralAutolinkValue(token) {\n this.config.enter.autolinkProtocol.call(this, token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitLiteralAutolinkHttp(token) {\n this.config.exit.autolinkProtocol.call(this, token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitLiteralAutolinkWww(token) {\n this.config.exit.data.call(this, token)\n const node = this.stack[this.stack.length - 1]\n assert(node.type === 'link')\n node.url = 'http://' + this.sliceSerialize(token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitLiteralAutolinkEmail(token) {\n this.config.exit.autolinkEmail.call(this, token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitLiteralAutolink(token) {\n this.exit(token)\n}\n\n/** @type {FromMarkdownTransform} */\nfunction transformGfmAutolinkLiterals(tree) {\n findAndReplace(\n tree,\n [\n [/(https?:\\/\\/|www(?=\\.))([-.\\w]+)([^ \\t\\r\\n]*)/gi, findUrl],\n [/([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)/g, findEmail]\n ],\n {ignore: ['link', 'linkReference']}\n )\n}\n\n/**\n * @type {ReplaceFunction}\n * @param {string} _\n * @param {string} protocol\n * @param {string} domain\n * @param {string} path\n * @param {RegExpMatchObject} match\n * @returns {Array | Link | false}\n */\n// eslint-disable-next-line max-params\nfunction findUrl(_, protocol, domain, path, match) {\n let prefix = ''\n\n // Not an expected previous character.\n if (!previous(match)) {\n return false\n }\n\n // Treat `www` as part of the domain.\n if (/^w/i.test(protocol)) {\n domain = protocol + domain\n protocol = ''\n prefix = 'http://'\n }\n\n if (!isCorrectDomain(domain)) {\n return false\n }\n\n const parts = splitUrl(domain + path)\n\n if (!parts[0]) return false\n\n /** @type {Link} */\n const result = {\n type: 'link',\n title: null,\n url: prefix + protocol + parts[0],\n children: [{type: 'text', value: protocol + parts[0]}]\n }\n\n if (parts[1]) {\n return [result, {type: 'text', value: parts[1]}]\n }\n\n return result\n}\n\n/**\n * @type {ReplaceFunction}\n * @param {string} _\n * @param {string} atext\n * @param {string} label\n * @param {RegExpMatchObject} match\n * @returns {Link | false}\n */\nfunction findEmail(_, atext, label, match) {\n if (\n // Not an expected previous character.\n !previous(match, true) ||\n // Label ends in not allowed character.\n /[-\\d_]$/.test(label)\n ) {\n return false\n }\n\n return {\n type: 'link',\n title: null,\n url: 'mailto:' + atext + '@' + label,\n children: [{type: 'text', value: atext + '@' + label}]\n }\n}\n\n/**\n * @param {string} domain\n * @returns {boolean}\n */\nfunction isCorrectDomain(domain) {\n const parts = domain.split('.')\n\n if (\n parts.length < 2 ||\n (parts[parts.length - 1] &&\n (/_/.test(parts[parts.length - 1]) ||\n !/[a-zA-Z\\d]/.test(parts[parts.length - 1]))) ||\n (parts[parts.length - 2] &&\n (/_/.test(parts[parts.length - 2]) ||\n !/[a-zA-Z\\d]/.test(parts[parts.length - 2])))\n ) {\n return false\n }\n\n return true\n}\n\n/**\n * @param {string} url\n * @returns {[string, string | undefined]}\n */\nfunction splitUrl(url) {\n const trailExec = /[!\"&'),.:;<>?\\]}]+$/.exec(url)\n\n if (!trailExec) {\n return [url, undefined]\n }\n\n url = url.slice(0, trailExec.index)\n\n let trail = trailExec[0]\n let closingParenIndex = trail.indexOf(')')\n const openingParens = ccount(url, '(')\n let closingParens = ccount(url, ')')\n\n while (closingParenIndex !== -1 && openingParens > closingParens) {\n url += trail.slice(0, closingParenIndex + 1)\n trail = trail.slice(closingParenIndex + 1)\n closingParenIndex = trail.indexOf(')')\n closingParens++\n }\n\n return [url, trail]\n}\n\n/**\n * @param {RegExpMatchObject} match\n * @param {boolean | null | undefined} [email=false]\n * @returns {boolean}\n */\nfunction previous(match, email) {\n const code = match.input.charCodeAt(match.index - 1)\n\n return (\n (match.index === 0 ||\n unicodeWhitespace(code) ||\n unicodePunctuation(code)) &&\n (!email || code !== 47)\n )\n}\n","/**\n * @typedef {import('mdast').FootnoteDefinition} FootnoteDefinition\n * @typedef {import('mdast').FootnoteReference} FootnoteReference\n * @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext\n * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension\n * @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle\n * @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle\n * @typedef {import('mdast-util-to-markdown').Map} Map\n * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension\n */\n\nimport {ok as assert} from 'devlop'\nimport {normalizeIdentifier} from 'micromark-util-normalize-identifier'\n\nfootnoteReference.peek = footnoteReferencePeek\n\n/**\n * Create an extension for `mdast-util-from-markdown` to enable GFM footnotes\n * in markdown.\n *\n * @returns {FromMarkdownExtension}\n * Extension for `mdast-util-from-markdown`.\n */\nexport function gfmFootnoteFromMarkdown() {\n return {\n enter: {\n gfmFootnoteDefinition: enterFootnoteDefinition,\n gfmFootnoteDefinitionLabelString: enterFootnoteDefinitionLabelString,\n gfmFootnoteCall: enterFootnoteCall,\n gfmFootnoteCallString: enterFootnoteCallString\n },\n exit: {\n gfmFootnoteDefinition: exitFootnoteDefinition,\n gfmFootnoteDefinitionLabelString: exitFootnoteDefinitionLabelString,\n gfmFootnoteCall: exitFootnoteCall,\n gfmFootnoteCallString: exitFootnoteCallString\n }\n }\n}\n\n/**\n * Create an extension for `mdast-util-to-markdown` to enable GFM footnotes\n * in markdown.\n *\n * @returns {ToMarkdownExtension}\n * Extension for `mdast-util-to-markdown`.\n */\nexport function gfmFootnoteToMarkdown() {\n return {\n // This is on by default already.\n unsafe: [{character: '[', inConstruct: ['phrasing', 'label', 'reference']}],\n handlers: {footnoteDefinition, footnoteReference}\n }\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterFootnoteDefinition(token) {\n this.enter(\n {type: 'footnoteDefinition', identifier: '', label: '', children: []},\n token\n )\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterFootnoteDefinitionLabelString() {\n this.buffer()\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitFootnoteDefinitionLabelString(token) {\n const label = this.resume()\n const node = this.stack[this.stack.length - 1]\n assert(node.type === 'footnoteDefinition')\n node.label = label\n node.identifier = normalizeIdentifier(\n this.sliceSerialize(token)\n ).toLowerCase()\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitFootnoteDefinition(token) {\n this.exit(token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterFootnoteCall(token) {\n this.enter({type: 'footnoteReference', identifier: '', label: ''}, token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterFootnoteCallString() {\n this.buffer()\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitFootnoteCallString(token) {\n const label = this.resume()\n const node = this.stack[this.stack.length - 1]\n assert(node.type === 'footnoteReference')\n node.label = label\n node.identifier = normalizeIdentifier(\n this.sliceSerialize(token)\n ).toLowerCase()\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitFootnoteCall(token) {\n this.exit(token)\n}\n\n/**\n * @type {ToMarkdownHandle}\n * @param {FootnoteReference} node\n */\nfunction footnoteReference(node, _, state, info) {\n const tracker = state.createTracker(info)\n let value = tracker.move('[^')\n const exit = state.enter('footnoteReference')\n const subexit = state.enter('reference')\n value += tracker.move(\n state.safe(state.associationId(node), {\n ...tracker.current(),\n before: value,\n after: ']'\n })\n )\n subexit()\n exit()\n value += tracker.move(']')\n return value\n}\n\n/** @type {ToMarkdownHandle} */\nfunction footnoteReferencePeek() {\n return '['\n}\n\n/**\n * @type {ToMarkdownHandle}\n * @param {FootnoteDefinition} node\n */\nfunction footnoteDefinition(node, _, state, info) {\n const tracker = state.createTracker(info)\n let value = tracker.move('[^')\n const exit = state.enter('footnoteDefinition')\n const subexit = state.enter('label')\n value += tracker.move(\n state.safe(state.associationId(node), {\n ...tracker.current(),\n before: value,\n after: ']'\n })\n )\n subexit()\n value += tracker.move(\n ']:' + (node.children && node.children.length > 0 ? ' ' : '')\n )\n tracker.shift(4)\n value += tracker.move(\n state.indentLines(state.containerFlow(node, tracker.current()), map)\n )\n exit()\n\n return value\n}\n\n/** @type {Map} */\nfunction map(line, index, blank) {\n if (index === 0) {\n return line\n }\n\n return (blank ? '' : ' ') + line\n}\n","/**\n * @typedef {import('mdast').Delete} Delete\n *\n * @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext\n * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension\n * @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle\n *\n * @typedef {import('mdast-util-to-markdown').ConstructName} ConstructName\n * @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle\n * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension\n */\n\n/**\n * List of constructs that occur in phrasing (paragraphs, headings), but cannot\n * contain strikethrough.\n * So they sort of cancel each other out.\n * Note: could use a better name.\n *\n * Note: keep in sync with: \n *\n * @type {Array}\n */\nconst constructsWithoutStrikethrough = [\n 'autolink',\n 'destinationLiteral',\n 'destinationRaw',\n 'reference',\n 'titleQuote',\n 'titleApostrophe'\n]\n\nhandleDelete.peek = peekDelete\n\n/**\n * Create an extension for `mdast-util-from-markdown` to enable GFM\n * strikethrough in markdown.\n *\n * @returns {FromMarkdownExtension}\n * Extension for `mdast-util-from-markdown` to enable GFM strikethrough.\n */\nexport function gfmStrikethroughFromMarkdown() {\n return {\n canContainEols: ['delete'],\n enter: {strikethrough: enterStrikethrough},\n exit: {strikethrough: exitStrikethrough}\n }\n}\n\n/**\n * Create an extension for `mdast-util-to-markdown` to enable GFM\n * strikethrough in markdown.\n *\n * @returns {ToMarkdownExtension}\n * Extension for `mdast-util-to-markdown` to enable GFM strikethrough.\n */\nexport function gfmStrikethroughToMarkdown() {\n return {\n unsafe: [\n {\n character: '~',\n inConstruct: 'phrasing',\n notInConstruct: constructsWithoutStrikethrough\n }\n ],\n handlers: {delete: handleDelete}\n }\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterStrikethrough(token) {\n this.enter({type: 'delete', children: []}, token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitStrikethrough(token) {\n this.exit(token)\n}\n\n/**\n * @type {ToMarkdownHandle}\n * @param {Delete} node\n */\nfunction handleDelete(node, _, state, info) {\n const tracker = state.createTracker(info)\n const exit = state.enter('strikethrough')\n let value = tracker.move('~~')\n value += state.containerPhrasing(node, {\n ...tracker.current(),\n before: value,\n after: '~'\n })\n value += tracker.move('~~')\n exit()\n return value\n}\n\n/** @type {ToMarkdownHandle} */\nfunction peekDelete() {\n return '~'\n}\n","/**\n * @typedef Options\n * Configuration (optional).\n * @property {string|null|ReadonlyArray} [align]\n * One style for all columns, or styles for their respective columns.\n * Each style is either `'l'` (left), `'r'` (right), or `'c'` (center).\n * Other values are treated as `''`, which doesn’t place the colon in the\n * alignment row but does align left.\n * *Only the lowercased first character is used, so `Right` is fine.*\n * @property {boolean} [padding=true]\n * Whether to add a space of padding between delimiters and cells.\n *\n * When `true`, there is padding:\n *\n * ```markdown\n * | Alpha | B |\n * | ----- | ----- |\n * | C | Delta |\n * ```\n *\n * When `false`, there is no padding:\n *\n * ```markdown\n * |Alpha|B |\n * |-----|-----|\n * |C |Delta|\n * ```\n * @property {boolean} [delimiterStart=true]\n * Whether to begin each row with the delimiter.\n *\n * > 👉 **Note**: please don’t use this: it could create fragile structures\n * > that aren’t understandable to some markdown parsers.\n *\n * When `true`, there are starting delimiters:\n *\n * ```markdown\n * | Alpha | B |\n * | ----- | ----- |\n * | C | Delta |\n * ```\n *\n * When `false`, there are no starting delimiters:\n *\n * ```markdown\n * Alpha | B |\n * ----- | ----- |\n * C | Delta |\n * ```\n * @property {boolean} [delimiterEnd=true]\n * Whether to end each row with the delimiter.\n *\n * > 👉 **Note**: please don’t use this: it could create fragile structures\n * > that aren’t understandable to some markdown parsers.\n *\n * When `true`, there are ending delimiters:\n *\n * ```markdown\n * | Alpha | B |\n * | ----- | ----- |\n * | C | Delta |\n * ```\n *\n * When `false`, there are no ending delimiters:\n *\n * ```markdown\n * | Alpha | B\n * | ----- | -----\n * | C | Delta\n * ```\n * @property {boolean} [alignDelimiters=true]\n * Whether to align the delimiters.\n * By default, they are aligned:\n *\n * ```markdown\n * | Alpha | B |\n * | ----- | ----- |\n * | C | Delta |\n * ```\n *\n * Pass `false` to make them staggered:\n *\n * ```markdown\n * | Alpha | B |\n * | - | - |\n * | C | Delta |\n * ```\n * @property {(value: string) => number} [stringLength]\n * Function to detect the length of table cell content.\n * This is used when aligning the delimiters (`|`) between table cells.\n * Full-width characters and emoji mess up delimiter alignment when viewing\n * the markdown source.\n * To fix this, you can pass this function, which receives the cell content\n * and returns its “visible” size.\n * Note that what is and isn’t visible depends on where the text is displayed.\n *\n * Without such a function, the following:\n *\n * ```js\n * markdownTable([\n * ['Alpha', 'Bravo'],\n * ['中文', 'Charlie'],\n * ['👩‍❤️‍👩', 'Delta']\n * ])\n * ```\n *\n * Yields:\n *\n * ```markdown\n * | Alpha | Bravo |\n * | - | - |\n * | 中文 | Charlie |\n * | 👩‍❤️‍👩 | Delta |\n * ```\n *\n * With [`string-width`](https://github.com/sindresorhus/string-width):\n *\n * ```js\n * import stringWidth from 'string-width'\n *\n * markdownTable(\n * [\n * ['Alpha', 'Bravo'],\n * ['中文', 'Charlie'],\n * ['👩‍❤️‍👩', 'Delta']\n * ],\n * {stringLength: stringWidth}\n * )\n * ```\n *\n * Yields:\n *\n * ```markdown\n * | Alpha | Bravo |\n * | ----- | ------- |\n * | 中文 | Charlie |\n * | 👩‍❤️‍👩 | Delta |\n * ```\n */\n\n/**\n * @typedef {Options} MarkdownTableOptions\n * @todo\n * Remove next major.\n */\n\n/**\n * Generate a markdown ([GFM](https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables)) table..\n *\n * @param {ReadonlyArray>} table\n * Table data (matrix of strings).\n * @param {Options} [options]\n * Configuration (optional).\n * @returns {string}\n */\nexport function markdownTable(table, options = {}) {\n const align = (options.align || []).concat()\n const stringLength = options.stringLength || defaultStringLength\n /** @type {Array} Character codes as symbols for alignment per column. */\n const alignments = []\n /** @type {Array>} Cells per row. */\n const cellMatrix = []\n /** @type {Array>} Sizes of each cell per row. */\n const sizeMatrix = []\n /** @type {Array} */\n const longestCellByColumn = []\n let mostCellsPerRow = 0\n let rowIndex = -1\n\n // This is a superfluous loop if we don’t align delimiters, but otherwise we’d\n // do superfluous work when aligning, so optimize for aligning.\n while (++rowIndex < table.length) {\n /** @type {Array} */\n const row = []\n /** @type {Array} */\n const sizes = []\n let columnIndex = -1\n\n if (table[rowIndex].length > mostCellsPerRow) {\n mostCellsPerRow = table[rowIndex].length\n }\n\n while (++columnIndex < table[rowIndex].length) {\n const cell = serialize(table[rowIndex][columnIndex])\n\n if (options.alignDelimiters !== false) {\n const size = stringLength(cell)\n sizes[columnIndex] = size\n\n if (\n longestCellByColumn[columnIndex] === undefined ||\n size > longestCellByColumn[columnIndex]\n ) {\n longestCellByColumn[columnIndex] = size\n }\n }\n\n row.push(cell)\n }\n\n cellMatrix[rowIndex] = row\n sizeMatrix[rowIndex] = sizes\n }\n\n // Figure out which alignments to use.\n let columnIndex = -1\n\n if (typeof align === 'object' && 'length' in align) {\n while (++columnIndex < mostCellsPerRow) {\n alignments[columnIndex] = toAlignment(align[columnIndex])\n }\n } else {\n const code = toAlignment(align)\n\n while (++columnIndex < mostCellsPerRow) {\n alignments[columnIndex] = code\n }\n }\n\n // Inject the alignment row.\n columnIndex = -1\n /** @type {Array} */\n const row = []\n /** @type {Array} */\n const sizes = []\n\n while (++columnIndex < mostCellsPerRow) {\n const code = alignments[columnIndex]\n let before = ''\n let after = ''\n\n if (code === 99 /* `c` */) {\n before = ':'\n after = ':'\n } else if (code === 108 /* `l` */) {\n before = ':'\n } else if (code === 114 /* `r` */) {\n after = ':'\n }\n\n // There *must* be at least one hyphen-minus in each alignment cell.\n let size =\n options.alignDelimiters === false\n ? 1\n : Math.max(\n 1,\n longestCellByColumn[columnIndex] - before.length - after.length\n )\n\n const cell = before + '-'.repeat(size) + after\n\n if (options.alignDelimiters !== false) {\n size = before.length + size + after.length\n\n if (size > longestCellByColumn[columnIndex]) {\n longestCellByColumn[columnIndex] = size\n }\n\n sizes[columnIndex] = size\n }\n\n row[columnIndex] = cell\n }\n\n // Inject the alignment row.\n cellMatrix.splice(1, 0, row)\n sizeMatrix.splice(1, 0, sizes)\n\n rowIndex = -1\n /** @type {Array} */\n const lines = []\n\n while (++rowIndex < cellMatrix.length) {\n const row = cellMatrix[rowIndex]\n const sizes = sizeMatrix[rowIndex]\n columnIndex = -1\n /** @type {Array} */\n const line = []\n\n while (++columnIndex < mostCellsPerRow) {\n const cell = row[columnIndex] || ''\n let before = ''\n let after = ''\n\n if (options.alignDelimiters !== false) {\n const size =\n longestCellByColumn[columnIndex] - (sizes[columnIndex] || 0)\n const code = alignments[columnIndex]\n\n if (code === 114 /* `r` */) {\n before = ' '.repeat(size)\n } else if (code === 99 /* `c` */) {\n if (size % 2) {\n before = ' '.repeat(size / 2 + 0.5)\n after = ' '.repeat(size / 2 - 0.5)\n } else {\n before = ' '.repeat(size / 2)\n after = before\n }\n } else {\n after = ' '.repeat(size)\n }\n }\n\n if (options.delimiterStart !== false && !columnIndex) {\n line.push('|')\n }\n\n if (\n options.padding !== false &&\n // Don’t add the opening space if we’re not aligning and the cell is\n // empty: there will be a closing space.\n !(options.alignDelimiters === false && cell === '') &&\n (options.delimiterStart !== false || columnIndex)\n ) {\n line.push(' ')\n }\n\n if (options.alignDelimiters !== false) {\n line.push(before)\n }\n\n line.push(cell)\n\n if (options.alignDelimiters !== false) {\n line.push(after)\n }\n\n if (options.padding !== false) {\n line.push(' ')\n }\n\n if (\n options.delimiterEnd !== false ||\n columnIndex !== mostCellsPerRow - 1\n ) {\n line.push('|')\n }\n }\n\n lines.push(\n options.delimiterEnd === false\n ? line.join('').replace(/ +$/, '')\n : line.join('')\n )\n }\n\n return lines.join('\\n')\n}\n\n/**\n * @param {string|null|undefined} [value]\n * @returns {string}\n */\nfunction serialize(value) {\n return value === null || value === undefined ? '' : String(value)\n}\n\n/**\n * @param {string} value\n * @returns {number}\n */\nfunction defaultStringLength(value) {\n return value.length\n}\n\n/**\n * @param {string|null|undefined} value\n * @returns {number}\n */\nfunction toAlignment(value) {\n const code = typeof value === 'string' ? value.codePointAt(0) : 0\n\n return code === 67 /* `C` */ || code === 99 /* `c` */\n ? 99 /* `c` */\n : code === 76 /* `L` */ || code === 108 /* `l` */\n ? 108 /* `l` */\n : code === 82 /* `R` */ || code === 114 /* `r` */\n ? 114 /* `r` */\n : 0\n}\n","/**\n * @typedef {import('mdast').Blockquote} Blockquote\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').Map} Map\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {Blockquote} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function blockquote(node, _, state, info) {\n const exit = state.enter('blockquote')\n const tracker = state.createTracker(info)\n tracker.move('> ')\n tracker.shift(2)\n const value = state.indentLines(\n state.containerFlow(node, tracker.current()),\n map\n )\n exit()\n return value\n}\n\n/** @type {Map} */\nfunction map(line, _, blank) {\n return '>' + (blank ? '' : ' ') + line\n}\n","/**\n * @typedef {import('../types.js').ConstructName} ConstructName\n * @typedef {import('../types.js').Unsafe} Unsafe\n */\n\n/**\n * @param {Array} stack\n * @param {Unsafe} pattern\n * @returns {boolean}\n */\nexport function patternInScope(stack, pattern) {\n return (\n listInScope(stack, pattern.inConstruct, true) &&\n !listInScope(stack, pattern.notInConstruct, false)\n )\n}\n\n/**\n * @param {Array} stack\n * @param {Unsafe['inConstruct']} list\n * @param {boolean} none\n * @returns {boolean}\n */\nfunction listInScope(stack, list, none) {\n if (typeof list === 'string') {\n list = [list]\n }\n\n if (!list || list.length === 0) {\n return none\n }\n\n let index = -1\n\n while (++index < list.length) {\n if (stack.includes(list[index])) {\n return true\n }\n }\n\n return false\n}\n","/**\n * @typedef {import('mdast').Break} Break\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nimport {patternInScope} from '../util/pattern-in-scope.js'\n\n/**\n * @param {Break} _\n * @param {Parents | undefined} _1\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function hardBreak(_, _1, state, info) {\n let index = -1\n\n while (++index < state.unsafe.length) {\n // If we can’t put eols in this construct (setext headings, tables), use a\n // space instead.\n if (\n state.unsafe[index].character === '\\n' &&\n patternInScope(state.stack, state.unsafe[index])\n ) {\n return /[ \\t]/.test(info.before) ? '' : ' '\n }\n }\n\n return '\\\\\\n'\n}\n","/**\n * @typedef {import('mdast').Code} Code\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').Map} Map\n * @typedef {import('../types.js').State} State\n */\n\nimport {longestStreak} from 'longest-streak'\nimport {formatCodeAsIndented} from '../util/format-code-as-indented.js'\nimport {checkFence} from '../util/check-fence.js'\n\n/**\n * @param {Code} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function code(node, _, state, info) {\n const marker = checkFence(state)\n const raw = node.value || ''\n const suffix = marker === '`' ? 'GraveAccent' : 'Tilde'\n\n if (formatCodeAsIndented(node, state)) {\n const exit = state.enter('codeIndented')\n const value = state.indentLines(raw, map)\n exit()\n return value\n }\n\n const tracker = state.createTracker(info)\n const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3))\n const exit = state.enter('codeFenced')\n let value = tracker.move(sequence)\n\n if (node.lang) {\n const subexit = state.enter(`codeFencedLang${suffix}`)\n value += tracker.move(\n state.safe(node.lang, {\n before: value,\n after: ' ',\n encode: ['`'],\n ...tracker.current()\n })\n )\n subexit()\n }\n\n if (node.lang && node.meta) {\n const subexit = state.enter(`codeFencedMeta${suffix}`)\n value += tracker.move(' ')\n value += tracker.move(\n state.safe(node.meta, {\n before: value,\n after: '\\n',\n encode: ['`'],\n ...tracker.current()\n })\n )\n subexit()\n }\n\n value += tracker.move('\\n')\n\n if (raw) {\n value += tracker.move(raw + '\\n')\n }\n\n value += tracker.move(sequence)\n exit()\n return value\n}\n\n/** @type {Map} */\nfunction map(line, _, blank) {\n return (blank ? '' : ' ') + line\n}\n","/**\n * @typedef {import('../types.js').Options} Options\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {State} state\n * @returns {Exclude}\n */\nexport function checkQuote(state) {\n const marker = state.options.quote || '\"'\n\n if (marker !== '\"' && marker !== \"'\") {\n throw new Error(\n 'Cannot serialize title with `' +\n marker +\n '` for `options.quote`, expected `\"`, or `\\'`'\n )\n }\n\n return marker\n}\n","/**\n * @typedef {import('mdast').Emphasis} Emphasis\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nimport {checkEmphasis} from '../util/check-emphasis.js'\n\nemphasis.peek = emphasisPeek\n\n// To do: there are cases where emphasis cannot “form” depending on the\n// previous or next character of sequences.\n// There’s no way around that though, except for injecting zero-width stuff.\n// Do we need to safeguard against that?\n/**\n * @param {Emphasis} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function emphasis(node, _, state, info) {\n const marker = checkEmphasis(state)\n const exit = state.enter('emphasis')\n const tracker = state.createTracker(info)\n let value = tracker.move(marker)\n value += tracker.move(\n state.containerPhrasing(node, {\n before: value,\n after: marker,\n ...tracker.current()\n })\n )\n value += tracker.move(marker)\n exit()\n return value\n}\n\n/**\n * @param {Emphasis} _\n * @param {Parents | undefined} _1\n * @param {State} state\n * @returns {string}\n */\nfunction emphasisPeek(_, _1, state) {\n return state.options.emphasis || '*'\n}\n","/**\n * @typedef {import('../types.js').Options} Options\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {State} state\n * @returns {Exclude}\n */\nexport function checkEmphasis(state) {\n const marker = state.options.emphasis || '*'\n\n if (marker !== '*' && marker !== '_') {\n throw new Error(\n 'Cannot serialize emphasis with `' +\n marker +\n '` for `options.emphasis`, expected `*`, or `_`'\n )\n }\n\n return marker\n}\n","/**\n * @typedef {import('mdast').Html} Html\n */\n\nhtml.peek = htmlPeek\n\n/**\n * @param {Html} node\n * @returns {string}\n */\nexport function html(node) {\n return node.value || ''\n}\n\n/**\n * @returns {string}\n */\nfunction htmlPeek() {\n return '<'\n}\n","/**\n * @typedef {import('mdast').Image} Image\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nimport {checkQuote} from '../util/check-quote.js'\n\nimage.peek = imagePeek\n\n/**\n * @param {Image} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function image(node, _, state, info) {\n const quote = checkQuote(state)\n const suffix = quote === '\"' ? 'Quote' : 'Apostrophe'\n const exit = state.enter('image')\n let subexit = state.enter('label')\n const tracker = state.createTracker(info)\n let value = tracker.move('![')\n value += tracker.move(\n state.safe(node.alt, {before: value, after: ']', ...tracker.current()})\n )\n value += tracker.move('](')\n\n subexit()\n\n if (\n // If there’s no url but there is a title…\n (!node.url && node.title) ||\n // If there are control characters or whitespace.\n /[\\0- \\u007F]/.test(node.url)\n ) {\n subexit = state.enter('destinationLiteral')\n value += tracker.move('<')\n value += tracker.move(\n state.safe(node.url, {before: value, after: '>', ...tracker.current()})\n )\n value += tracker.move('>')\n } else {\n // No whitespace, raw is prettier.\n subexit = state.enter('destinationRaw')\n value += tracker.move(\n state.safe(node.url, {\n before: value,\n after: node.title ? ' ' : ')',\n ...tracker.current()\n })\n )\n }\n\n subexit()\n\n if (node.title) {\n subexit = state.enter(`title${suffix}`)\n value += tracker.move(' ' + quote)\n value += tracker.move(\n state.safe(node.title, {\n before: value,\n after: quote,\n ...tracker.current()\n })\n )\n value += tracker.move(quote)\n subexit()\n }\n\n value += tracker.move(')')\n exit()\n\n return value\n}\n\n/**\n * @returns {string}\n */\nfunction imagePeek() {\n return '!'\n}\n","/**\n * @typedef {import('mdast').ImageReference} ImageReference\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nimageReference.peek = imageReferencePeek\n\n/**\n * @param {ImageReference} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function imageReference(node, _, state, info) {\n const type = node.referenceType\n const exit = state.enter('imageReference')\n let subexit = state.enter('label')\n const tracker = state.createTracker(info)\n let value = tracker.move('![')\n const alt = state.safe(node.alt, {\n before: value,\n after: ']',\n ...tracker.current()\n })\n value += tracker.move(alt + '][')\n\n subexit()\n // Hide the fact that we’re in phrasing, because escapes don’t work.\n const stack = state.stack\n state.stack = []\n subexit = state.enter('reference')\n // Note: for proper tracking, we should reset the output positions when we end\n // up making a `shortcut` reference, because then there is no brace output.\n // Practically, in that case, there is no content, so it doesn’t matter that\n // we’ve tracked one too many characters.\n const reference = state.safe(state.associationId(node), {\n before: value,\n after: ']',\n ...tracker.current()\n })\n subexit()\n state.stack = stack\n exit()\n\n if (type === 'full' || !alt || alt !== reference) {\n value += tracker.move(reference + ']')\n } else if (type === 'shortcut') {\n // Remove the unwanted `[`.\n value = value.slice(0, -1)\n } else {\n value += tracker.move(']')\n }\n\n return value\n}\n\n/**\n * @returns {string}\n */\nfunction imageReferencePeek() {\n return '!'\n}\n","/**\n * @typedef {import('mdast').InlineCode} InlineCode\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').State} State\n */\n\ninlineCode.peek = inlineCodePeek\n\n/**\n * @param {InlineCode} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @returns {string}\n */\nexport function inlineCode(node, _, state) {\n let value = node.value || ''\n let sequence = '`'\n let index = -1\n\n // If there is a single grave accent on its own in the code, use a fence of\n // two.\n // If there are two in a row, use one.\n while (new RegExp('(^|[^`])' + sequence + '([^`]|$)').test(value)) {\n sequence += '`'\n }\n\n // If this is not just spaces or eols (tabs don’t count), and either the\n // first or last character are a space, eol, or tick, then pad with spaces.\n if (\n /[^ \\r\\n]/.test(value) &&\n ((/^[ \\r\\n]/.test(value) && /[ \\r\\n]$/.test(value)) || /^`|`$/.test(value))\n ) {\n value = ' ' + value + ' '\n }\n\n // We have a potential problem: certain characters after eols could result in\n // blocks being seen.\n // For example, if someone injected the string `'\\n# b'`, then that would\n // result in an ATX heading.\n // We can’t escape characters in `inlineCode`, but because eols are\n // transformed to spaces when going from markdown to HTML anyway, we can swap\n // them out.\n while (++index < state.unsafe.length) {\n const pattern = state.unsafe[index]\n const expression = state.compilePattern(pattern)\n /** @type {RegExpExecArray | null} */\n let match\n\n // Only look for `atBreak`s.\n // Btw: note that `atBreak` patterns will always start the regex at LF or\n // CR.\n if (!pattern.atBreak) continue\n\n while ((match = expression.exec(value))) {\n let position = match.index\n\n // Support CRLF (patterns only look for one of the characters).\n if (\n value.charCodeAt(position) === 10 /* `\\n` */ &&\n value.charCodeAt(position - 1) === 13 /* `\\r` */\n ) {\n position--\n }\n\n value = value.slice(0, position) + ' ' + value.slice(match.index + 1)\n }\n }\n\n return sequence + value + sequence\n}\n\n/**\n * @returns {string}\n */\nfunction inlineCodePeek() {\n return '`'\n}\n","/**\n * @typedef {import('mdast').Link} Link\n * @typedef {import('../types.js').State} State\n */\n\nimport {toString} from 'mdast-util-to-string'\n\n/**\n * @param {Link} node\n * @param {State} state\n * @returns {boolean}\n */\nexport function formatLinkAsAutolink(node, state) {\n const raw = toString(node)\n\n return Boolean(\n !state.options.resourceLink &&\n // If there’s a url…\n node.url &&\n // And there’s a no title…\n !node.title &&\n // And the content of `node` is a single text node…\n node.children &&\n node.children.length === 1 &&\n node.children[0].type === 'text' &&\n // And if the url is the same as the content…\n (raw === node.url || 'mailto:' + raw === node.url) &&\n // And that starts w/ a protocol…\n /^[a-z][a-z+.-]+:/i.test(node.url) &&\n // And that doesn’t contain ASCII control codes (character escapes and\n // references don’t work), space, or angle brackets…\n !/[\\0- <>\\u007F]/.test(node.url)\n )\n}\n","/**\n * @typedef {import('mdast').Link} Link\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Exit} Exit\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nimport {checkQuote} from '../util/check-quote.js'\nimport {formatLinkAsAutolink} from '../util/format-link-as-autolink.js'\n\nlink.peek = linkPeek\n\n/**\n * @param {Link} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function link(node, _, state, info) {\n const quote = checkQuote(state)\n const suffix = quote === '\"' ? 'Quote' : 'Apostrophe'\n const tracker = state.createTracker(info)\n /** @type {Exit} */\n let exit\n /** @type {Exit} */\n let subexit\n\n if (formatLinkAsAutolink(node, state)) {\n // Hide the fact that we’re in phrasing, because escapes don’t work.\n const stack = state.stack\n state.stack = []\n exit = state.enter('autolink')\n let value = tracker.move('<')\n value += tracker.move(\n state.containerPhrasing(node, {\n before: value,\n after: '>',\n ...tracker.current()\n })\n )\n value += tracker.move('>')\n exit()\n state.stack = stack\n return value\n }\n\n exit = state.enter('link')\n subexit = state.enter('label')\n let value = tracker.move('[')\n value += tracker.move(\n state.containerPhrasing(node, {\n before: value,\n after: '](',\n ...tracker.current()\n })\n )\n value += tracker.move('](')\n subexit()\n\n if (\n // If there’s no url but there is a title…\n (!node.url && node.title) ||\n // If there are control characters or whitespace.\n /[\\0- \\u007F]/.test(node.url)\n ) {\n subexit = state.enter('destinationLiteral')\n value += tracker.move('<')\n value += tracker.move(\n state.safe(node.url, {before: value, after: '>', ...tracker.current()})\n )\n value += tracker.move('>')\n } else {\n // No whitespace, raw is prettier.\n subexit = state.enter('destinationRaw')\n value += tracker.move(\n state.safe(node.url, {\n before: value,\n after: node.title ? ' ' : ')',\n ...tracker.current()\n })\n )\n }\n\n subexit()\n\n if (node.title) {\n subexit = state.enter(`title${suffix}`)\n value += tracker.move(' ' + quote)\n value += tracker.move(\n state.safe(node.title, {\n before: value,\n after: quote,\n ...tracker.current()\n })\n )\n value += tracker.move(quote)\n subexit()\n }\n\n value += tracker.move(')')\n\n exit()\n return value\n}\n\n/**\n * @param {Link} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @returns {string}\n */\nfunction linkPeek(node, _, state) {\n return formatLinkAsAutolink(node, state) ? '<' : '['\n}\n","/**\n * @typedef {import('mdast').LinkReference} LinkReference\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nlinkReference.peek = linkReferencePeek\n\n/**\n * @param {LinkReference} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function linkReference(node, _, state, info) {\n const type = node.referenceType\n const exit = state.enter('linkReference')\n let subexit = state.enter('label')\n const tracker = state.createTracker(info)\n let value = tracker.move('[')\n const text = state.containerPhrasing(node, {\n before: value,\n after: ']',\n ...tracker.current()\n })\n value += tracker.move(text + '][')\n\n subexit()\n // Hide the fact that we’re in phrasing, because escapes don’t work.\n const stack = state.stack\n state.stack = []\n subexit = state.enter('reference')\n // Note: for proper tracking, we should reset the output positions when we end\n // up making a `shortcut` reference, because then there is no brace output.\n // Practically, in that case, there is no content, so it doesn’t matter that\n // we’ve tracked one too many characters.\n const reference = state.safe(state.associationId(node), {\n before: value,\n after: ']',\n ...tracker.current()\n })\n subexit()\n state.stack = stack\n exit()\n\n if (type === 'full' || !text || text !== reference) {\n value += tracker.move(reference + ']')\n } else if (type === 'shortcut') {\n // Remove the unwanted `[`.\n value = value.slice(0, -1)\n } else {\n value += tracker.move(']')\n }\n\n return value\n}\n\n/**\n * @returns {string}\n */\nfunction linkReferencePeek() {\n return '['\n}\n","/**\n * @typedef {import('../types.js').Options} Options\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {State} state\n * @returns {Exclude}\n */\nexport function checkBullet(state) {\n const marker = state.options.bullet || '*'\n\n if (marker !== '*' && marker !== '+' && marker !== '-') {\n throw new Error(\n 'Cannot serialize items with `' +\n marker +\n '` for `options.bullet`, expected `*`, `+`, or `-`'\n )\n }\n\n return marker\n}\n","/**\n * @typedef {import('../types.js').Options} Options\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {State} state\n * @returns {Exclude}\n */\nexport function checkRule(state) {\n const marker = state.options.rule || '*'\n\n if (marker !== '*' && marker !== '-' && marker !== '_') {\n throw new Error(\n 'Cannot serialize rules with `' +\n marker +\n '` for `options.rule`, expected `*`, `-`, or `_`'\n )\n }\n\n return marker\n}\n","/**\n * @typedef {import('mdast').PhrasingContent} PhrasingContent\n */\n\nimport {convert} from 'unist-util-is'\n\n/**\n * Check if the given value is *phrasing content*.\n *\n * > 👉 **Note**: Excludes `html`, which can be both phrasing or flow.\n *\n * @param node\n * Thing to check, typically `Node`.\n * @returns\n * Whether `value` is phrasing content.\n */\n\nexport const phrasing =\n /** @type {(node?: unknown) => node is PhrasingContent} */\n (\n convert([\n 'break',\n 'delete',\n 'emphasis',\n 'footnote',\n 'footnoteReference',\n 'image',\n 'imageReference',\n 'inlineCode',\n 'link',\n 'linkReference',\n 'strong',\n 'text'\n ])\n )\n","/**\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('mdast').Strong} Strong\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nimport {checkStrong} from '../util/check-strong.js'\n\nstrong.peek = strongPeek\n\n// To do: there are cases where emphasis cannot “form” depending on the\n// previous or next character of sequences.\n// There’s no way around that though, except for injecting zero-width stuff.\n// Do we need to safeguard against that?\n/**\n * @param {Strong} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function strong(node, _, state, info) {\n const marker = checkStrong(state)\n const exit = state.enter('strong')\n const tracker = state.createTracker(info)\n let value = tracker.move(marker + marker)\n value += tracker.move(\n state.containerPhrasing(node, {\n before: value,\n after: marker,\n ...tracker.current()\n })\n )\n value += tracker.move(marker + marker)\n exit()\n return value\n}\n\n/**\n * @param {Strong} _\n * @param {Parents | undefined} _1\n * @param {State} state\n * @returns {string}\n */\nfunction strongPeek(_, _1, state) {\n return state.options.strong || '*'\n}\n","/**\n * @typedef {import('../types.js').Options} Options\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {State} state\n * @returns {Exclude}\n */\nexport function checkStrong(state) {\n const marker = state.options.strong || '*'\n\n if (marker !== '*' && marker !== '_') {\n throw new Error(\n 'Cannot serialize strong with `' +\n marker +\n '` for `options.strong`, expected `*`, or `_`'\n )\n }\n\n return marker\n}\n","import {blockquote} from './blockquote.js'\nimport {hardBreak} from './break.js'\nimport {code} from './code.js'\nimport {definition} from './definition.js'\nimport {emphasis} from './emphasis.js'\nimport {heading} from './heading.js'\nimport {html} from './html.js'\nimport {image} from './image.js'\nimport {imageReference} from './image-reference.js'\nimport {inlineCode} from './inline-code.js'\nimport {link} from './link.js'\nimport {linkReference} from './link-reference.js'\nimport {list} from './list.js'\nimport {listItem} from './list-item.js'\nimport {paragraph} from './paragraph.js'\nimport {root} from './root.js'\nimport {strong} from './strong.js'\nimport {text} from './text.js'\nimport {thematicBreak} from './thematic-break.js'\n\n/**\n * Default (CommonMark) handlers.\n */\nexport const handle = {\n blockquote,\n break: hardBreak,\n code,\n definition,\n emphasis,\n hardBreak,\n heading,\n html,\n image,\n imageReference,\n inlineCode,\n link,\n linkReference,\n list,\n listItem,\n paragraph,\n root,\n strong,\n text,\n thematicBreak\n}\n","/**\n * @typedef {import('../types.js').Options} Options\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {State} state\n * @returns {Exclude}\n */\nexport function checkFence(state) {\n const marker = state.options.fence || '`'\n\n if (marker !== '`' && marker !== '~') {\n throw new Error(\n 'Cannot serialize code with `' +\n marker +\n '` for `options.fence`, expected `` ` `` or `~`'\n )\n }\n\n return marker\n}\n","/**\n * @typedef {import('mdast').Code} Code\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {Code} node\n * @param {State} state\n * @returns {boolean}\n */\nexport function formatCodeAsIndented(node, state) {\n return Boolean(\n state.options.fences === false &&\n node.value &&\n // If there’s no info…\n !node.lang &&\n // And there’s a non-whitespace character…\n /[^ \\r\\n]/.test(node.value) &&\n // And the value doesn’t start or end in a blank…\n !/^[\\t ]*(?:[\\r\\n]|$)|(?:^|[\\r\\n])[\\t ]*$/.test(node.value)\n )\n}\n","/**\n * Get the count of the longest repeating streak of `substring` in `value`.\n *\n * @param {string} value\n * Content to search in.\n * @param {string} substring\n * Substring to look for, typically one character.\n * @returns {number}\n * Count of most frequent adjacent `substring`s in `value`.\n */\nexport function longestStreak(value, substring) {\n const source = String(value)\n let index = source.indexOf(substring)\n let expected = index\n let count = 0\n let max = 0\n\n if (typeof substring !== 'string') {\n throw new TypeError('Expected substring')\n }\n\n while (index !== -1) {\n if (index === expected) {\n if (++count > max) {\n max = count\n }\n } else {\n count = 1\n }\n\n expected = index + substring.length\n index = source.indexOf(substring, expected)\n }\n\n return max\n}\n","/**\n * @typedef {import('mdast').Definition} Definition\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nimport {checkQuote} from '../util/check-quote.js'\n\n/**\n * @param {Definition} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function definition(node, _, state, info) {\n const quote = checkQuote(state)\n const suffix = quote === '\"' ? 'Quote' : 'Apostrophe'\n const exit = state.enter('definition')\n let subexit = state.enter('label')\n const tracker = state.createTracker(info)\n let value = tracker.move('[')\n value += tracker.move(\n state.safe(state.associationId(node), {\n before: value,\n after: ']',\n ...tracker.current()\n })\n )\n value += tracker.move(']: ')\n\n subexit()\n\n if (\n // If there’s no url, or…\n !node.url ||\n // If there are control characters or whitespace.\n /[\\0- \\u007F]/.test(node.url)\n ) {\n subexit = state.enter('destinationLiteral')\n value += tracker.move('<')\n value += tracker.move(\n state.safe(node.url, {before: value, after: '>', ...tracker.current()})\n )\n value += tracker.move('>')\n } else {\n // No whitespace, raw is prettier.\n subexit = state.enter('destinationRaw')\n value += tracker.move(\n state.safe(node.url, {\n before: value,\n after: node.title ? ' ' : '\\n',\n ...tracker.current()\n })\n )\n }\n\n subexit()\n\n if (node.title) {\n subexit = state.enter(`title${suffix}`)\n value += tracker.move(' ' + quote)\n value += tracker.move(\n state.safe(node.title, {\n before: value,\n after: quote,\n ...tracker.current()\n })\n )\n value += tracker.move(quote)\n subexit()\n }\n\n exit()\n\n return value\n}\n","/**\n * @typedef {import('mdast').Heading} Heading\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nimport {formatHeadingAsSetext} from '../util/format-heading-as-setext.js'\n\n/**\n * @param {Heading} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function heading(node, _, state, info) {\n const rank = Math.max(Math.min(6, node.depth || 1), 1)\n const tracker = state.createTracker(info)\n\n if (formatHeadingAsSetext(node, state)) {\n const exit = state.enter('headingSetext')\n const subexit = state.enter('phrasing')\n const value = state.containerPhrasing(node, {\n ...tracker.current(),\n before: '\\n',\n after: '\\n'\n })\n subexit()\n exit()\n\n return (\n value +\n '\\n' +\n (rank === 1 ? '=' : '-').repeat(\n // The whole size…\n value.length -\n // Minus the position of the character after the last EOL (or\n // 0 if there is none)…\n (Math.max(value.lastIndexOf('\\r'), value.lastIndexOf('\\n')) + 1)\n )\n )\n }\n\n const sequence = '#'.repeat(rank)\n const exit = state.enter('headingAtx')\n const subexit = state.enter('phrasing')\n\n // Note: for proper tracking, we should reset the output positions when there\n // is no content returned, because then the space is not output.\n // Practically, in that case, there is no content, so it doesn’t matter that\n // we’ve tracked one too many characters.\n tracker.move(sequence + ' ')\n\n let value = state.containerPhrasing(node, {\n before: '# ',\n after: '\\n',\n ...tracker.current()\n })\n\n if (/^[\\t ]/.test(value)) {\n // To do: what effect has the character reference on tracking?\n value =\n '&#x' +\n value.charCodeAt(0).toString(16).toUpperCase() +\n ';' +\n value.slice(1)\n }\n\n value = value ? sequence + ' ' + value : sequence\n\n if (state.options.closeAtx) {\n value += ' ' + sequence\n }\n\n subexit()\n exit()\n\n return value\n}\n","/**\n * @typedef {import('mdast').Heading} Heading\n * @typedef {import('../types.js').State} State\n */\n\nimport {EXIT, visit} from 'unist-util-visit'\nimport {toString} from 'mdast-util-to-string'\n\n/**\n * @param {Heading} node\n * @param {State} state\n * @returns {boolean}\n */\nexport function formatHeadingAsSetext(node, state) {\n let literalWithBreak = false\n\n // Look for literals with a line break.\n // Note that this also\n visit(node, function (node) {\n if (\n ('value' in node && /\\r?\\n|\\r/.test(node.value)) ||\n node.type === 'break'\n ) {\n literalWithBreak = true\n return EXIT\n }\n })\n\n return Boolean(\n (!node.depth || node.depth < 3) &&\n toString(node) &&\n (state.options.setext || literalWithBreak)\n )\n}\n","/**\n * @typedef {import('mdast').List} List\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nimport {checkBullet} from '../util/check-bullet.js'\nimport {checkBulletOther} from '../util/check-bullet-other.js'\nimport {checkBulletOrdered} from '../util/check-bullet-ordered.js'\nimport {checkRule} from '../util/check-rule.js'\n\n/**\n * @param {List} node\n * @param {Parents | undefined} parent\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function list(node, parent, state, info) {\n const exit = state.enter('list')\n const bulletCurrent = state.bulletCurrent\n /** @type {string} */\n let bullet = node.ordered ? checkBulletOrdered(state) : checkBullet(state)\n /** @type {string} */\n const bulletOther = node.ordered\n ? bullet === '.'\n ? ')'\n : '.'\n : checkBulletOther(state)\n let useDifferentMarker =\n parent && state.bulletLastUsed ? bullet === state.bulletLastUsed : false\n\n if (!node.ordered) {\n const firstListItem = node.children ? node.children[0] : undefined\n\n // If there’s an empty first list item directly in two list items,\n // we have to use a different bullet:\n //\n // ```markdown\n // * - *\n // ```\n //\n // …because otherwise it would become one big thematic break.\n if (\n // Bullet could be used as a thematic break marker:\n (bullet === '*' || bullet === '-') &&\n // Empty first list item:\n firstListItem &&\n (!firstListItem.children || !firstListItem.children[0]) &&\n // Directly in two other list items:\n state.stack[state.stack.length - 1] === 'list' &&\n state.stack[state.stack.length - 2] === 'listItem' &&\n state.stack[state.stack.length - 3] === 'list' &&\n state.stack[state.stack.length - 4] === 'listItem' &&\n // That are each the first child.\n state.indexStack[state.indexStack.length - 1] === 0 &&\n state.indexStack[state.indexStack.length - 2] === 0 &&\n state.indexStack[state.indexStack.length - 3] === 0\n ) {\n useDifferentMarker = true\n }\n\n // If there’s a thematic break at the start of the first list item,\n // we have to use a different bullet:\n //\n // ```markdown\n // * ---\n // ```\n //\n // …because otherwise it would become one big thematic break.\n if (checkRule(state) === bullet && firstListItem) {\n let index = -1\n\n while (++index < node.children.length) {\n const item = node.children[index]\n\n if (\n item &&\n item.type === 'listItem' &&\n item.children &&\n item.children[0] &&\n item.children[0].type === 'thematicBreak'\n ) {\n useDifferentMarker = true\n break\n }\n }\n }\n }\n\n if (useDifferentMarker) {\n bullet = bulletOther\n }\n\n state.bulletCurrent = bullet\n const value = state.containerFlow(node, info)\n state.bulletLastUsed = bullet\n state.bulletCurrent = bulletCurrent\n exit()\n return value\n}\n","/**\n * @typedef {import('../types.js').Options} Options\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {State} state\n * @returns {Exclude}\n */\nexport function checkBulletOrdered(state) {\n const marker = state.options.bulletOrdered || '.'\n\n if (marker !== '.' && marker !== ')') {\n throw new Error(\n 'Cannot serialize items with `' +\n marker +\n '` for `options.bulletOrdered`, expected `.` or `)`'\n )\n }\n\n return marker\n}\n","/**\n * @typedef {import('../types.js').Options} Options\n * @typedef {import('../types.js').State} State\n */\n\nimport {checkBullet} from './check-bullet.js'\n\n/**\n * @param {State} state\n * @returns {Exclude}\n */\nexport function checkBulletOther(state) {\n const bullet = checkBullet(state)\n const bulletOther = state.options.bulletOther\n\n if (!bulletOther) {\n return bullet === '*' ? '-' : '*'\n }\n\n if (bulletOther !== '*' && bulletOther !== '+' && bulletOther !== '-') {\n throw new Error(\n 'Cannot serialize items with `' +\n bulletOther +\n '` for `options.bulletOther`, expected `*`, `+`, or `-`'\n )\n }\n\n if (bulletOther === bullet) {\n throw new Error(\n 'Expected `bullet` (`' +\n bullet +\n '`) and `bulletOther` (`' +\n bulletOther +\n '`) to be different'\n )\n }\n\n return bulletOther\n}\n","/**\n * @typedef {import('mdast').ListItem} ListItem\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').Map} Map\n * @typedef {import('../types.js').State} State\n */\n\nimport {checkBullet} from '../util/check-bullet.js'\nimport {checkListItemIndent} from '../util/check-list-item-indent.js'\n\n/**\n * @param {ListItem} node\n * @param {Parents | undefined} parent\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function listItem(node, parent, state, info) {\n const listItemIndent = checkListItemIndent(state)\n let bullet = state.bulletCurrent || checkBullet(state)\n\n // Add the marker value for ordered lists.\n if (parent && parent.type === 'list' && parent.ordered) {\n bullet =\n (typeof parent.start === 'number' && parent.start > -1\n ? parent.start\n : 1) +\n (state.options.incrementListMarker === false\n ? 0\n : parent.children.indexOf(node)) +\n bullet\n }\n\n let size = bullet.length + 1\n\n if (\n listItemIndent === 'tab' ||\n (listItemIndent === 'mixed' &&\n ((parent && parent.type === 'list' && parent.spread) || node.spread))\n ) {\n size = Math.ceil(size / 4) * 4\n }\n\n const tracker = state.createTracker(info)\n tracker.move(bullet + ' '.repeat(size - bullet.length))\n tracker.shift(size)\n const exit = state.enter('listItem')\n const value = state.indentLines(\n state.containerFlow(node, tracker.current()),\n map\n )\n exit()\n\n return value\n\n /** @type {Map} */\n function map(line, index, blank) {\n if (index) {\n return (blank ? '' : ' '.repeat(size)) + line\n }\n\n return (blank ? bullet : bullet + ' '.repeat(size - bullet.length)) + line\n }\n}\n","/**\n * @typedef {import('../types.js').Options} Options\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {State} state\n * @returns {Exclude}\n */\nexport function checkListItemIndent(state) {\n const style = state.options.listItemIndent || 'one'\n\n if (style !== 'tab' && style !== 'one' && style !== 'mixed') {\n throw new Error(\n 'Cannot serialize items with `' +\n style +\n '` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`'\n )\n }\n\n return style\n}\n","/**\n * @typedef {import('mdast').Paragraph} Paragraph\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {Paragraph} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function paragraph(node, _, state, info) {\n const exit = state.enter('paragraph')\n const subexit = state.enter('phrasing')\n const value = state.containerPhrasing(node, info)\n subexit()\n exit()\n return value\n}\n","/**\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('mdast').Root} Root\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\nimport {phrasing} from 'mdast-util-phrasing'\n\n/**\n * @param {Root} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function root(node, _, state, info) {\n // Note: `html` nodes are ambiguous.\n const hasPhrasing = node.children.some(function (d) {\n return phrasing(d)\n })\n const fn = hasPhrasing ? state.containerPhrasing : state.containerFlow\n return fn.call(state, node, info)\n}\n","/**\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('mdast').Text} Text\n * @typedef {import('../types.js').Info} Info\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {Text} node\n * @param {Parents | undefined} _\n * @param {State} state\n * @param {Info} info\n * @returns {string}\n */\nexport function text(node, _, state, info) {\n return state.safe(node.value, info)\n}\n","/**\n * @typedef {import('mdast').Parents} Parents\n * @typedef {import('mdast').ThematicBreak} ThematicBreak\n * @typedef {import('../types.js').State} State\n */\n\nimport {checkRuleRepetition} from '../util/check-rule-repetition.js'\nimport {checkRule} from '../util/check-rule.js'\n\n/**\n * @param {ThematicBreak} _\n * @param {Parents | undefined} _1\n * @param {State} state\n * @returns {string}\n */\nexport function thematicBreak(_, _1, state) {\n const value = (\n checkRule(state) + (state.options.ruleSpaces ? ' ' : '')\n ).repeat(checkRuleRepetition(state))\n\n return state.options.ruleSpaces ? value.slice(0, -1) : value\n}\n","/**\n * @typedef {import('../types.js').Options} Options\n * @typedef {import('../types.js').State} State\n */\n\n/**\n * @param {State} state\n * @returns {Exclude}\n */\nexport function checkRuleRepetition(state) {\n const repetition = state.options.ruleRepetition || 3\n\n if (repetition < 3) {\n throw new Error(\n 'Cannot serialize rules with repetition `' +\n repetition +\n '` for `options.ruleRepetition`, expected `3` or more'\n )\n }\n\n return repetition\n}\n","/**\n * @typedef {import('mdast').InlineCode} InlineCode\n * @typedef {import('mdast').Table} Table\n * @typedef {import('mdast').TableCell} TableCell\n * @typedef {import('mdast').TableRow} TableRow\n *\n * @typedef {import('markdown-table').Options} MarkdownTableOptions\n *\n * @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext\n * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension\n * @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle\n *\n * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension\n * @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle\n * @typedef {import('mdast-util-to-markdown').State} State\n * @typedef {import('mdast-util-to-markdown').Info} Info\n */\n\n/**\n * @typedef Options\n * Configuration.\n * @property {boolean | null | undefined} [tableCellPadding=true]\n * Whether to add a space of padding between delimiters and cells (default:\n * `true`).\n * @property {boolean | null | undefined} [tablePipeAlign=true]\n * Whether to align the delimiters (default: `true`).\n * @property {MarkdownTableOptions['stringLength'] | null | undefined} [stringLength]\n * Function to detect the length of table cell content, used when aligning\n * the delimiters between cells (optional).\n */\n\nimport {ok as assert} from 'devlop'\nimport {markdownTable} from 'markdown-table'\nimport {defaultHandlers} from 'mdast-util-to-markdown'\n\n/**\n * Create an extension for `mdast-util-from-markdown` to enable GFM tables in\n * markdown.\n *\n * @returns {FromMarkdownExtension}\n * Extension for `mdast-util-from-markdown` to enable GFM tables.\n */\nexport function gfmTableFromMarkdown() {\n return {\n enter: {\n table: enterTable,\n tableData: enterCell,\n tableHeader: enterCell,\n tableRow: enterRow\n },\n exit: {\n codeText: exitCodeText,\n table: exitTable,\n tableData: exit,\n tableHeader: exit,\n tableRow: exit\n }\n }\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterTable(token) {\n const align = token._align\n assert(align, 'expected `_align` on table')\n this.enter(\n {\n type: 'table',\n align: align.map(function (d) {\n return d === 'none' ? null : d\n }),\n children: []\n },\n token\n )\n this.data.inTable = true\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitTable(token) {\n this.exit(token)\n this.data.inTable = undefined\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterRow(token) {\n this.enter({type: 'tableRow', children: []}, token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exit(token) {\n this.exit(token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterCell(token) {\n this.enter({type: 'tableCell', children: []}, token)\n}\n\n// Overwrite the default code text data handler to unescape escaped pipes when\n// they are in tables.\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitCodeText(token) {\n let value = this.resume()\n\n if (this.data.inTable) {\n value = value.replace(/\\\\([\\\\|])/g, replace)\n }\n\n const node = this.stack[this.stack.length - 1]\n assert(node.type === 'inlineCode')\n node.value = value\n this.exit(token)\n}\n\n/**\n * @param {string} $0\n * @param {string} $1\n * @returns {string}\n */\nfunction replace($0, $1) {\n // Pipes work, backslashes don’t (but can’t escape pipes).\n return $1 === '|' ? $1 : $0\n}\n\n/**\n * Create an extension for `mdast-util-to-markdown` to enable GFM tables in\n * markdown.\n *\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {ToMarkdownExtension}\n * Extension for `mdast-util-to-markdown` to enable GFM tables.\n */\nexport function gfmTableToMarkdown(options) {\n const settings = options || {}\n const padding = settings.tableCellPadding\n const alignDelimiters = settings.tablePipeAlign\n const stringLength = settings.stringLength\n const around = padding ? ' ' : '|'\n\n return {\n unsafe: [\n {character: '\\r', inConstruct: 'tableCell'},\n {character: '\\n', inConstruct: 'tableCell'},\n // A pipe, when followed by a tab or space (padding), or a dash or colon\n // (unpadded delimiter row), could result in a table.\n {atBreak: true, character: '|', after: '[\\t :-]'},\n // A pipe in a cell must be encoded.\n {character: '|', inConstruct: 'tableCell'},\n // A colon must be followed by a dash, in which case it could start a\n // delimiter row.\n {atBreak: true, character: ':', after: '-'},\n // A delimiter row can also start with a dash, when followed by more\n // dashes, a colon, or a pipe.\n // This is a stricter version than the built in check for lists, thematic\n // breaks, and setex heading underlines though:\n // \n {atBreak: true, character: '-', after: '[:|-]'}\n ],\n handlers: {\n inlineCode: inlineCodeWithTable,\n table: handleTable,\n tableCell: handleTableCell,\n tableRow: handleTableRow\n }\n }\n\n /**\n * @type {ToMarkdownHandle}\n * @param {Table} node\n */\n function handleTable(node, _, state, info) {\n return serializeData(handleTableAsData(node, state, info), node.align)\n }\n\n /**\n * This function isn’t really used normally, because we handle rows at the\n * table level.\n * But, if someone passes in a table row, this ensures we make somewhat sense.\n *\n * @type {ToMarkdownHandle}\n * @param {TableRow} node\n */\n function handleTableRow(node, _, state, info) {\n const row = handleTableRowAsData(node, state, info)\n const value = serializeData([row])\n // `markdown-table` will always add an align row\n return value.slice(0, value.indexOf('\\n'))\n }\n\n /**\n * @type {ToMarkdownHandle}\n * @param {TableCell} node\n */\n function handleTableCell(node, _, state, info) {\n const exit = state.enter('tableCell')\n const subexit = state.enter('phrasing')\n const value = state.containerPhrasing(node, {\n ...info,\n before: around,\n after: around\n })\n subexit()\n exit()\n return value\n }\n\n /**\n * @param {Array>} matrix\n * @param {Array | null | undefined} [align]\n */\n function serializeData(matrix, align) {\n return markdownTable(matrix, {\n align,\n // @ts-expect-error: `markdown-table` types should support `null`.\n alignDelimiters,\n // @ts-expect-error: `markdown-table` types should support `null`.\n padding,\n // @ts-expect-error: `markdown-table` types should support `null`.\n stringLength\n })\n }\n\n /**\n * @param {Table} node\n * @param {State} state\n * @param {Info} info\n */\n function handleTableAsData(node, state, info) {\n const children = node.children\n let index = -1\n /** @type {Array>} */\n const result = []\n const subexit = state.enter('table')\n\n while (++index < children.length) {\n result[index] = handleTableRowAsData(children[index], state, info)\n }\n\n subexit()\n\n return result\n }\n\n /**\n * @param {TableRow} node\n * @param {State} state\n * @param {Info} info\n */\n function handleTableRowAsData(node, state, info) {\n const children = node.children\n let index = -1\n /** @type {Array} */\n const result = []\n const subexit = state.enter('tableRow')\n\n while (++index < children.length) {\n // Note: the positional info as used here is incorrect.\n // Making it correct would be impossible due to aligning cells?\n // And it would need copy/pasting `markdown-table` into this project.\n result[index] = handleTableCell(children[index], node, state, info)\n }\n\n subexit()\n\n return result\n }\n\n /**\n * @type {ToMarkdownHandle}\n * @param {InlineCode} node\n */\n function inlineCodeWithTable(node, parent, state) {\n let value = defaultHandlers.inlineCode(node, parent, state)\n\n if (state.stack.includes('tableCell')) {\n value = value.replace(/\\|/g, '\\\\$&')\n }\n\n return value\n }\n}\n","/**\n * @typedef {import('mdast').ListItem} ListItem\n * @typedef {import('mdast').Paragraph} Paragraph\n * @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext\n * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension\n * @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle\n * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension\n * @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle\n */\n\nimport {ok as assert} from 'devlop'\nimport {defaultHandlers} from 'mdast-util-to-markdown'\n\n/**\n * Create an extension for `mdast-util-from-markdown` to enable GFM task\n * list items in markdown.\n *\n * @returns {FromMarkdownExtension}\n * Extension for `mdast-util-from-markdown` to enable GFM task list items.\n */\nexport function gfmTaskListItemFromMarkdown() {\n return {\n exit: {\n taskListCheckValueChecked: exitCheck,\n taskListCheckValueUnchecked: exitCheck,\n paragraph: exitParagraphWithTaskListItem\n }\n }\n}\n\n/**\n * Create an extension for `mdast-util-to-markdown` to enable GFM task list\n * items in markdown.\n *\n * @returns {ToMarkdownExtension}\n * Extension for `mdast-util-to-markdown` to enable GFM task list items.\n */\nexport function gfmTaskListItemToMarkdown() {\n return {\n unsafe: [{atBreak: true, character: '-', after: '[:|-]'}],\n handlers: {listItem: listItemWithTaskListItem}\n }\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitCheck(token) {\n // We’re always in a paragraph, in a list item.\n const node = this.stack[this.stack.length - 2]\n assert(node.type === 'listItem')\n node.checked = token.type === 'taskListCheckValueChecked'\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitParagraphWithTaskListItem(token) {\n const parent = this.stack[this.stack.length - 2]\n\n if (\n parent &&\n parent.type === 'listItem' &&\n typeof parent.checked === 'boolean'\n ) {\n const node = this.stack[this.stack.length - 1]\n assert(node.type === 'paragraph')\n const head = node.children[0]\n\n if (head && head.type === 'text') {\n const siblings = parent.children\n let index = -1\n /** @type {Paragraph | undefined} */\n let firstParaghraph\n\n while (++index < siblings.length) {\n const sibling = siblings[index]\n if (sibling.type === 'paragraph') {\n firstParaghraph = sibling\n break\n }\n }\n\n if (firstParaghraph === node) {\n // Must start with a space or a tab.\n head.value = head.value.slice(1)\n\n if (head.value.length === 0) {\n node.children.shift()\n } else if (\n node.position &&\n head.position &&\n typeof head.position.start.offset === 'number'\n ) {\n head.position.start.column++\n head.position.start.offset++\n node.position.start = Object.assign({}, head.position.start)\n }\n }\n }\n }\n\n this.exit(token)\n}\n\n/**\n * @type {ToMarkdownHandle}\n * @param {ListItem} node\n */\nfunction listItemWithTaskListItem(node, parent, state, info) {\n const head = node.children[0]\n const checkable =\n typeof node.checked === 'boolean' && head && head.type === 'paragraph'\n const checkbox = '[' + (node.checked ? 'x' : ' ') + '] '\n const tracker = state.createTracker(info)\n\n if (checkable) {\n tracker.move(checkbox)\n }\n\n let value = defaultHandlers.listItem(node, parent, state, {\n ...info,\n ...tracker.current()\n })\n\n if (checkable) {\n value = value.replace(/^(?:[*+-]|\\d+\\.)([\\r\\n]| {1,3})/, check)\n }\n\n return value\n\n /**\n * @param {string} $0\n * @returns {string}\n */\n function check($0) {\n return $0 + checkbox\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Code} Code\n * @typedef {import('micromark-util-types').ConstructRecord} ConstructRecord\n * @typedef {import('micromark-util-types').Event} Event\n * @typedef {import('micromark-util-types').Extension} Extension\n * @typedef {import('micromark-util-types').Previous} Previous\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {\n asciiAlpha,\n asciiAlphanumeric,\n asciiControl,\n markdownLineEndingOrSpace,\n unicodePunctuation,\n unicodeWhitespace\n} from 'micromark-util-character'\nconst wwwPrefix = {\n tokenize: tokenizeWwwPrefix,\n partial: true\n}\nconst domain = {\n tokenize: tokenizeDomain,\n partial: true\n}\nconst path = {\n tokenize: tokenizePath,\n partial: true\n}\nconst trail = {\n tokenize: tokenizeTrail,\n partial: true\n}\nconst emailDomainDotTrail = {\n tokenize: tokenizeEmailDomainDotTrail,\n partial: true\n}\nconst wwwAutolink = {\n tokenize: tokenizeWwwAutolink,\n previous: previousWww\n}\nconst protocolAutolink = {\n tokenize: tokenizeProtocolAutolink,\n previous: previousProtocol\n}\nconst emailAutolink = {\n tokenize: tokenizeEmailAutolink,\n previous: previousEmail\n}\n\n/** @type {ConstructRecord} */\nconst text = {}\n\n/**\n * Create an extension for `micromark` to support GitHub autolink literal\n * syntax.\n *\n * @returns {Extension}\n * Extension for `micromark` that can be passed in `extensions` to enable GFM\n * autolink literal syntax.\n */\nexport function gfmAutolinkLiteral() {\n return {\n text\n }\n}\n\n/** @type {Code} */\nlet code = 48\n\n// Add alphanumerics.\nwhile (code < 123) {\n text[code] = emailAutolink\n code++\n if (code === 58) code = 65\n else if (code === 91) code = 97\n}\ntext[43] = emailAutolink\ntext[45] = emailAutolink\ntext[46] = emailAutolink\ntext[95] = emailAutolink\ntext[72] = [emailAutolink, protocolAutolink]\ntext[104] = [emailAutolink, protocolAutolink]\ntext[87] = [emailAutolink, wwwAutolink]\ntext[119] = [emailAutolink, wwwAutolink]\n\n// To do: perform email autolink literals on events, afterwards.\n// That’s where `markdown-rs` and `cmark-gfm` perform it.\n// It should look for `@`, then for atext backwards, and then for a label\n// forwards.\n// To do: `mailto:`, `xmpp:` protocol as prefix.\n\n/**\n * Email autolink literal.\n *\n * ```markdown\n * > | a contact@example.org b\n * ^^^^^^^^^^^^^^^^^^^\n * ```\n *\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeEmailAutolink(effects, ok, nok) {\n const self = this\n /** @type {boolean | undefined} */\n let dot\n /** @type {boolean} */\n let data\n return start\n\n /**\n * Start of email autolink literal.\n *\n * ```markdown\n * > | a contact@example.org b\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n if (\n !gfmAtext(code) ||\n !previousEmail.call(self, self.previous) ||\n previousUnbalanced(self.events)\n ) {\n return nok(code)\n }\n effects.enter('literalAutolink')\n effects.enter('literalAutolinkEmail')\n return atext(code)\n }\n\n /**\n * In email atext.\n *\n * ```markdown\n * > | a contact@example.org b\n * ^\n * ```\n *\n * @type {State}\n */\n function atext(code) {\n if (gfmAtext(code)) {\n effects.consume(code)\n return atext\n }\n if (code === 64) {\n effects.consume(code)\n return emailDomain\n }\n return nok(code)\n }\n\n /**\n * In email domain.\n *\n * The reference code is a bit overly complex as it handles the `@`, of which\n * there may be just one.\n * Source: \n *\n * ```markdown\n * > | a contact@example.org b\n * ^\n * ```\n *\n * @type {State}\n */\n function emailDomain(code) {\n // Dot followed by alphanumerical (not `-` or `_`).\n if (code === 46) {\n return effects.check(\n emailDomainDotTrail,\n emailDomainAfter,\n emailDomainDot\n )(code)\n }\n\n // Alphanumerical, `-`, and `_`.\n if (code === 45 || code === 95 || asciiAlphanumeric(code)) {\n data = true\n effects.consume(code)\n return emailDomain\n }\n\n // To do: `/` if xmpp.\n\n // Note: normally we’d truncate trailing punctuation from the link.\n // However, email autolink literals cannot contain any of those markers,\n // except for `.`, but that can only occur if it isn’t trailing.\n // So we can ignore truncating!\n return emailDomainAfter(code)\n }\n\n /**\n * In email domain, on dot that is not a trail.\n *\n * ```markdown\n * > | a contact@example.org b\n * ^\n * ```\n *\n * @type {State}\n */\n function emailDomainDot(code) {\n effects.consume(code)\n dot = true\n return emailDomain\n }\n\n /**\n * After email domain.\n *\n * ```markdown\n * > | a contact@example.org b\n * ^\n * ```\n *\n * @type {State}\n */\n function emailDomainAfter(code) {\n // Domain must not be empty, must include a dot, and must end in alphabetical.\n // Source: .\n if (data && dot && asciiAlpha(self.previous)) {\n effects.exit('literalAutolinkEmail')\n effects.exit('literalAutolink')\n return ok(code)\n }\n return nok(code)\n }\n}\n\n/**\n * `www` autolink literal.\n *\n * ```markdown\n * > | a www.example.org b\n * ^^^^^^^^^^^^^^^\n * ```\n *\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeWwwAutolink(effects, ok, nok) {\n const self = this\n return wwwStart\n\n /**\n * Start of www autolink literal.\n *\n * ```markdown\n * > | www.example.com/a?b#c\n * ^\n * ```\n *\n * @type {State}\n */\n function wwwStart(code) {\n if (\n (code !== 87 && code !== 119) ||\n !previousWww.call(self, self.previous) ||\n previousUnbalanced(self.events)\n ) {\n return nok(code)\n }\n effects.enter('literalAutolink')\n effects.enter('literalAutolinkWww')\n // Note: we *check*, so we can discard the `www.` we parsed.\n // If it worked, we consider it as a part of the domain.\n return effects.check(\n wwwPrefix,\n effects.attempt(domain, effects.attempt(path, wwwAfter), nok),\n nok\n )(code)\n }\n\n /**\n * After a www autolink literal.\n *\n * ```markdown\n * > | www.example.com/a?b#c\n * ^\n * ```\n *\n * @type {State}\n */\n function wwwAfter(code) {\n effects.exit('literalAutolinkWww')\n effects.exit('literalAutolink')\n return ok(code)\n }\n}\n\n/**\n * Protocol autolink literal.\n *\n * ```markdown\n * > | a https://example.org b\n * ^^^^^^^^^^^^^^^^^^^\n * ```\n *\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeProtocolAutolink(effects, ok, nok) {\n const self = this\n let buffer = ''\n let seen = false\n return protocolStart\n\n /**\n * Start of protocol autolink literal.\n *\n * ```markdown\n * > | https://example.com/a?b#c\n * ^\n * ```\n *\n * @type {State}\n */\n function protocolStart(code) {\n if (\n (code === 72 || code === 104) &&\n previousProtocol.call(self, self.previous) &&\n !previousUnbalanced(self.events)\n ) {\n effects.enter('literalAutolink')\n effects.enter('literalAutolinkHttp')\n buffer += String.fromCodePoint(code)\n effects.consume(code)\n return protocolPrefixInside\n }\n return nok(code)\n }\n\n /**\n * In protocol.\n *\n * ```markdown\n * > | https://example.com/a?b#c\n * ^^^^^\n * ```\n *\n * @type {State}\n */\n function protocolPrefixInside(code) {\n // `5` is size of `https`\n if (asciiAlpha(code) && buffer.length < 5) {\n // @ts-expect-error: definitely number.\n buffer += String.fromCodePoint(code)\n effects.consume(code)\n return protocolPrefixInside\n }\n if (code === 58) {\n const protocol = buffer.toLowerCase()\n if (protocol === 'http' || protocol === 'https') {\n effects.consume(code)\n return protocolSlashesInside\n }\n }\n return nok(code)\n }\n\n /**\n * In slashes.\n *\n * ```markdown\n * > | https://example.com/a?b#c\n * ^^\n * ```\n *\n * @type {State}\n */\n function protocolSlashesInside(code) {\n if (code === 47) {\n effects.consume(code)\n if (seen) {\n return afterProtocol\n }\n seen = true\n return protocolSlashesInside\n }\n return nok(code)\n }\n\n /**\n * After protocol, before domain.\n *\n * ```markdown\n * > | https://example.com/a?b#c\n * ^\n * ```\n *\n * @type {State}\n */\n function afterProtocol(code) {\n // To do: this is different from `markdown-rs`:\n // https://github.com/wooorm/markdown-rs/blob/b3a921c761309ae00a51fe348d8a43adbc54b518/src/construct/gfm_autolink_literal.rs#L172-L182\n return code === null ||\n asciiControl(code) ||\n markdownLineEndingOrSpace(code) ||\n unicodeWhitespace(code) ||\n unicodePunctuation(code)\n ? nok(code)\n : effects.attempt(domain, effects.attempt(path, protocolAfter), nok)(code)\n }\n\n /**\n * After a protocol autolink literal.\n *\n * ```markdown\n * > | https://example.com/a?b#c\n * ^\n * ```\n *\n * @type {State}\n */\n function protocolAfter(code) {\n effects.exit('literalAutolinkHttp')\n effects.exit('literalAutolink')\n return ok(code)\n }\n}\n\n/**\n * `www` prefix.\n *\n * ```markdown\n * > | a www.example.org b\n * ^^^^\n * ```\n *\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeWwwPrefix(effects, ok, nok) {\n let size = 0\n return wwwPrefixInside\n\n /**\n * In www prefix.\n *\n * ```markdown\n * > | www.example.com\n * ^^^^\n * ```\n *\n * @type {State}\n */\n function wwwPrefixInside(code) {\n if ((code === 87 || code === 119) && size < 3) {\n size++\n effects.consume(code)\n return wwwPrefixInside\n }\n if (code === 46 && size === 3) {\n effects.consume(code)\n return wwwPrefixAfter\n }\n return nok(code)\n }\n\n /**\n * After www prefix.\n *\n * ```markdown\n * > | www.example.com\n * ^\n * ```\n *\n * @type {State}\n */\n function wwwPrefixAfter(code) {\n // If there is *anything*, we can link.\n return code === null ? nok(code) : ok(code)\n }\n}\n\n/**\n * Domain.\n *\n * ```markdown\n * > | a https://example.org b\n * ^^^^^^^^^^^\n * ```\n *\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeDomain(effects, ok, nok) {\n /** @type {boolean | undefined} */\n let underscoreInLastSegment\n /** @type {boolean | undefined} */\n let underscoreInLastLastSegment\n /** @type {boolean | undefined} */\n let seen\n return domainInside\n\n /**\n * In domain.\n *\n * ```markdown\n * > | https://example.com/a\n * ^^^^^^^^^^^\n * ```\n *\n * @type {State}\n */\n function domainInside(code) {\n // Check whether this marker, which is a trailing punctuation\n // marker, optionally followed by more trailing markers, and then\n // followed by an end.\n if (code === 46 || code === 95) {\n return effects.check(trail, domainAfter, domainAtPunctuation)(code)\n }\n\n // GH documents that only alphanumerics (other than `-`, `.`, and `_`) can\n // occur, which sounds like ASCII only, but they also support `www.點看.com`,\n // so that’s Unicode.\n // Instead of some new production for Unicode alphanumerics, markdown\n // already has that for Unicode punctuation and whitespace, so use those.\n // Source: .\n if (\n code === null ||\n markdownLineEndingOrSpace(code) ||\n unicodeWhitespace(code) ||\n (code !== 45 && unicodePunctuation(code))\n ) {\n return domainAfter(code)\n }\n seen = true\n effects.consume(code)\n return domainInside\n }\n\n /**\n * In domain, at potential trailing punctuation, that was not trailing.\n *\n * ```markdown\n * > | https://example.com\n * ^\n * ```\n *\n * @type {State}\n */\n function domainAtPunctuation(code) {\n // There is an underscore in the last segment of the domain\n if (code === 95) {\n underscoreInLastSegment = true\n }\n // Otherwise, it’s a `.`: save the last segment underscore in the\n // penultimate segment slot.\n else {\n underscoreInLastLastSegment = underscoreInLastSegment\n underscoreInLastSegment = undefined\n }\n effects.consume(code)\n return domainInside\n }\n\n /**\n * After domain.\n *\n * ```markdown\n * > | https://example.com/a\n * ^\n * ```\n *\n * @type {State} */\n function domainAfter(code) {\n // Note: that’s GH says a dot is needed, but it’s not true:\n // \n if (underscoreInLastLastSegment || underscoreInLastSegment || !seen) {\n return nok(code)\n }\n return ok(code)\n }\n}\n\n/**\n * Path.\n *\n * ```markdown\n * > | a https://example.org/stuff b\n * ^^^^^^\n * ```\n *\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizePath(effects, ok) {\n let sizeOpen = 0\n let sizeClose = 0\n return pathInside\n\n /**\n * In path.\n *\n * ```markdown\n * > | https://example.com/a\n * ^^\n * ```\n *\n * @type {State}\n */\n function pathInside(code) {\n if (code === 40) {\n sizeOpen++\n effects.consume(code)\n return pathInside\n }\n\n // To do: `markdown-rs` also needs this.\n // If this is a paren, and there are less closings than openings,\n // we don’t check for a trail.\n if (code === 41 && sizeClose < sizeOpen) {\n return pathAtPunctuation(code)\n }\n\n // Check whether this trailing punctuation marker is optionally\n // followed by more trailing markers, and then followed\n // by an end.\n if (\n code === 33 ||\n code === 34 ||\n code === 38 ||\n code === 39 ||\n code === 41 ||\n code === 42 ||\n code === 44 ||\n code === 46 ||\n code === 58 ||\n code === 59 ||\n code === 60 ||\n code === 63 ||\n code === 93 ||\n code === 95 ||\n code === 126\n ) {\n return effects.check(trail, ok, pathAtPunctuation)(code)\n }\n if (\n code === null ||\n markdownLineEndingOrSpace(code) ||\n unicodeWhitespace(code)\n ) {\n return ok(code)\n }\n effects.consume(code)\n return pathInside\n }\n\n /**\n * In path, at potential trailing punctuation, that was not trailing.\n *\n * ```markdown\n * > | https://example.com/a\"b\n * ^\n * ```\n *\n * @type {State}\n */\n function pathAtPunctuation(code) {\n // Count closing parens.\n if (code === 41) {\n sizeClose++\n }\n effects.consume(code)\n return pathInside\n }\n}\n\n/**\n * Trail.\n *\n * This calls `ok` if this *is* the trail, followed by an end, which means\n * the entire trail is not part of the link.\n * It calls `nok` if this *is* part of the link.\n *\n * ```markdown\n * > | https://example.com\").\n * ^^^\n * ```\n *\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeTrail(effects, ok, nok) {\n return trail\n\n /**\n * In trail of domain or path.\n *\n * ```markdown\n * > | https://example.com\").\n * ^\n * ```\n *\n * @type {State}\n */\n function trail(code) {\n // Regular trailing punctuation.\n if (\n code === 33 ||\n code === 34 ||\n code === 39 ||\n code === 41 ||\n code === 42 ||\n code === 44 ||\n code === 46 ||\n code === 58 ||\n code === 59 ||\n code === 63 ||\n code === 95 ||\n code === 126\n ) {\n effects.consume(code)\n return trail\n }\n\n // `&` followed by one or more alphabeticals and then a `;`, is\n // as a whole considered as trailing punctuation.\n // In all other cases, it is considered as continuation of the URL.\n if (code === 38) {\n effects.consume(code)\n return trailCharRefStart\n }\n\n // Needed because we allow literals after `[`, as we fix:\n // .\n // Check that it is not followed by `(` or `[`.\n if (code === 93) {\n effects.consume(code)\n return trailBracketAfter\n }\n if (\n // `<` is an end.\n code === 60 ||\n // So is whitespace.\n code === null ||\n markdownLineEndingOrSpace(code) ||\n unicodeWhitespace(code)\n ) {\n return ok(code)\n }\n return nok(code)\n }\n\n /**\n * In trail, after `]`.\n *\n * > 👉 **Note**: this deviates from `cmark-gfm` to fix a bug.\n * > See end of for more.\n *\n * ```markdown\n * > | https://example.com](\n * ^\n * ```\n *\n * @type {State}\n */\n function trailBracketAfter(code) {\n // Whitespace or something that could start a resource or reference is the end.\n // Switch back to trail otherwise.\n if (\n code === null ||\n code === 40 ||\n code === 91 ||\n markdownLineEndingOrSpace(code) ||\n unicodeWhitespace(code)\n ) {\n return ok(code)\n }\n return trail(code)\n }\n\n /**\n * In character-reference like trail, after `&`.\n *\n * ```markdown\n * > | https://example.com&).\n * ^\n * ```\n *\n * @type {State}\n */\n function trailCharRefStart(code) {\n // When non-alpha, it’s not a trail.\n return asciiAlpha(code) ? trailCharRefInside(code) : nok(code)\n }\n\n /**\n * In character-reference like trail.\n *\n * ```markdown\n * > | https://example.com&).\n * ^\n * ```\n *\n * @type {State}\n */\n function trailCharRefInside(code) {\n // Switch back to trail if this is well-formed.\n if (code === 59) {\n effects.consume(code)\n return trail\n }\n if (asciiAlpha(code)) {\n effects.consume(code)\n return trailCharRefInside\n }\n\n // It’s not a trail.\n return nok(code)\n }\n}\n\n/**\n * Dot in email domain trail.\n *\n * This calls `ok` if this *is* the trail, followed by an end, which means\n * the trail is not part of the link.\n * It calls `nok` if this *is* part of the link.\n *\n * ```markdown\n * > | contact@example.org.\n * ^\n * ```\n *\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeEmailDomainDotTrail(effects, ok, nok) {\n return start\n\n /**\n * Dot.\n *\n * ```markdown\n * > | contact@example.org.\n * ^ ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n // Must be dot.\n effects.consume(code)\n return after\n }\n\n /**\n * After dot.\n *\n * ```markdown\n * > | contact@example.org.\n * ^ ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n // Not a trail if alphanumeric.\n return asciiAlphanumeric(code) ? nok(code) : ok(code)\n }\n}\n\n/**\n * See:\n * .\n *\n * @type {Previous}\n */\nfunction previousWww(code) {\n return (\n code === null ||\n code === 40 ||\n code === 42 ||\n code === 95 ||\n code === 91 ||\n code === 93 ||\n code === 126 ||\n markdownLineEndingOrSpace(code)\n )\n}\n\n/**\n * See:\n * .\n *\n * @type {Previous}\n */\nfunction previousProtocol(code) {\n return !asciiAlpha(code)\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Previous}\n */\nfunction previousEmail(code) {\n // Do not allow a slash “inside” atext.\n // The reference code is a bit weird, but that’s what it results in.\n // Source: .\n // Other than slash, every preceding character is allowed.\n return !(code === 47 || gfmAtext(code))\n}\n\n/**\n * @param {Code} code\n * @returns {boolean}\n */\nfunction gfmAtext(code) {\n return (\n code === 43 ||\n code === 45 ||\n code === 46 ||\n code === 95 ||\n asciiAlphanumeric(code)\n )\n}\n\n/**\n * @param {Array} events\n * @returns {boolean}\n */\nfunction previousUnbalanced(events) {\n let index = events.length\n let result = false\n while (index--) {\n const token = events[index][1]\n if (\n (token.type === 'labelLink' || token.type === 'labelImage') &&\n !token._balanced\n ) {\n result = true\n break\n }\n\n // If we’ve seen this token, and it was marked as not having any unbalanced\n // bracket before it, we can exit.\n if (token._gfmAutolinkLiteralWalkedInto) {\n result = false\n break\n }\n }\n if (events.length > 0 && !result) {\n // Mark the last token as “walked into” w/o finding\n // anything.\n events[events.length - 1][1]._gfmAutolinkLiteralWalkedInto = true\n }\n return result\n}\n","/**\n * @typedef {import('micromark-util-types').Event} Event\n * @typedef {import('micromark-util-types').Exiter} Exiter\n * @typedef {import('micromark-util-types').Extension} Extension\n * @typedef {import('micromark-util-types').Resolver} Resolver\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').Token} Token\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {blankLine} from 'micromark-core-commonmark'\nimport {factorySpace} from 'micromark-factory-space'\nimport {markdownLineEndingOrSpace} from 'micromark-util-character'\nimport {normalizeIdentifier} from 'micromark-util-normalize-identifier'\nconst indent = {\n tokenize: tokenizeIndent,\n partial: true\n}\n\n// To do: micromark should support a `_hiddenGfmFootnoteSupport`, which only\n// affects label start (image).\n// That will let us drop `tokenizePotentialGfmFootnote*`.\n// It currently has a `_hiddenFootnoteSupport`, which affects that and more.\n// That can be removed when `micromark-extension-footnote` is archived.\n\n/**\n * Create an extension for `micromark` to enable GFM footnote syntax.\n *\n * @returns {Extension}\n * Extension for `micromark` that can be passed in `extensions` to\n * enable GFM footnote syntax.\n */\nexport function gfmFootnote() {\n /** @type {Extension} */\n return {\n document: {\n [91]: {\n tokenize: tokenizeDefinitionStart,\n continuation: {\n tokenize: tokenizeDefinitionContinuation\n },\n exit: gfmFootnoteDefinitionEnd\n }\n },\n text: {\n [91]: {\n tokenize: tokenizeGfmFootnoteCall\n },\n [93]: {\n add: 'after',\n tokenize: tokenizePotentialGfmFootnoteCall,\n resolveTo: resolveToPotentialGfmFootnoteCall\n }\n }\n }\n}\n\n// To do: remove after micromark update.\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizePotentialGfmFootnoteCall(effects, ok, nok) {\n const self = this\n let index = self.events.length\n const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = [])\n /** @type {Token} */\n let labelStart\n\n // Find an opening.\n while (index--) {\n const token = self.events[index][1]\n if (token.type === 'labelImage') {\n labelStart = token\n break\n }\n\n // Exit if we’ve walked far enough.\n if (\n token.type === 'gfmFootnoteCall' ||\n token.type === 'labelLink' ||\n token.type === 'label' ||\n token.type === 'image' ||\n token.type === 'link'\n ) {\n break\n }\n }\n return start\n\n /**\n * @type {State}\n */\n function start(code) {\n if (!labelStart || !labelStart._balanced) {\n return nok(code)\n }\n const id = normalizeIdentifier(\n self.sliceSerialize({\n start: labelStart.end,\n end: self.now()\n })\n )\n if (id.codePointAt(0) !== 94 || !defined.includes(id.slice(1))) {\n return nok(code)\n }\n effects.enter('gfmFootnoteCallLabelMarker')\n effects.consume(code)\n effects.exit('gfmFootnoteCallLabelMarker')\n return ok(code)\n }\n}\n\n// To do: remove after micromark update.\n/** @type {Resolver} */\nfunction resolveToPotentialGfmFootnoteCall(events, context) {\n let index = events.length\n /** @type {Token | undefined} */\n let labelStart\n\n // Find an opening.\n while (index--) {\n if (\n events[index][1].type === 'labelImage' &&\n events[index][0] === 'enter'\n ) {\n labelStart = events[index][1]\n break\n }\n }\n // Change the `labelImageMarker` to a `data`.\n events[index + 1][1].type = 'data'\n events[index + 3][1].type = 'gfmFootnoteCallLabelMarker'\n\n // The whole (without `!`):\n /** @type {Token} */\n const call = {\n type: 'gfmFootnoteCall',\n start: Object.assign({}, events[index + 3][1].start),\n end: Object.assign({}, events[events.length - 1][1].end)\n }\n // The `^` marker\n /** @type {Token} */\n const marker = {\n type: 'gfmFootnoteCallMarker',\n start: Object.assign({}, events[index + 3][1].end),\n end: Object.assign({}, events[index + 3][1].end)\n }\n // Increment the end 1 character.\n marker.end.column++\n marker.end.offset++\n marker.end._bufferIndex++\n /** @type {Token} */\n const string = {\n type: 'gfmFootnoteCallString',\n start: Object.assign({}, marker.end),\n end: Object.assign({}, events[events.length - 1][1].start)\n }\n /** @type {Token} */\n const chunk = {\n type: 'chunkString',\n contentType: 'string',\n start: Object.assign({}, string.start),\n end: Object.assign({}, string.end)\n }\n\n /** @type {Array} */\n const replacement = [\n // Take the `labelImageMarker` (now `data`, the `!`)\n events[index + 1],\n events[index + 2],\n ['enter', call, context],\n // The `[`\n events[index + 3],\n events[index + 4],\n // The `^`.\n ['enter', marker, context],\n ['exit', marker, context],\n // Everything in between.\n ['enter', string, context],\n ['enter', chunk, context],\n ['exit', chunk, context],\n ['exit', string, context],\n // The ending (`]`, properly parsed and labelled).\n events[events.length - 2],\n events[events.length - 1],\n ['exit', call, context]\n ]\n events.splice(index, events.length - index + 1, ...replacement)\n return events\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeGfmFootnoteCall(effects, ok, nok) {\n const self = this\n const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = [])\n let size = 0\n /** @type {boolean} */\n let data\n\n // Note: the implementation of `markdown-rs` is different, because it houses\n // core *and* extensions in one project.\n // Therefore, it can include footnote logic inside `label-end`.\n // We can’t do that, but luckily, we can parse footnotes in a simpler way than\n // needed for labels.\n return start\n\n /**\n * Start of footnote label.\n *\n * ```markdown\n * > | a [^b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('gfmFootnoteCall')\n effects.enter('gfmFootnoteCallLabelMarker')\n effects.consume(code)\n effects.exit('gfmFootnoteCallLabelMarker')\n return callStart\n }\n\n /**\n * After `[`, at `^`.\n *\n * ```markdown\n * > | a [^b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function callStart(code) {\n if (code !== 94) return nok(code)\n effects.enter('gfmFootnoteCallMarker')\n effects.consume(code)\n effects.exit('gfmFootnoteCallMarker')\n effects.enter('gfmFootnoteCallString')\n effects.enter('chunkString').contentType = 'string'\n return callData\n }\n\n /**\n * In label.\n *\n * ```markdown\n * > | a [^b] c\n * ^\n * ```\n *\n * @type {State}\n */\n function callData(code) {\n if (\n // Too long.\n size > 999 ||\n // Closing brace with nothing.\n (code === 93 && !data) ||\n // Space or tab is not supported by GFM for some reason.\n // `\\n` and `[` not being supported makes sense.\n code === null ||\n code === 91 ||\n markdownLineEndingOrSpace(code)\n ) {\n return nok(code)\n }\n if (code === 93) {\n effects.exit('chunkString')\n const token = effects.exit('gfmFootnoteCallString')\n if (!defined.includes(normalizeIdentifier(self.sliceSerialize(token)))) {\n return nok(code)\n }\n effects.enter('gfmFootnoteCallLabelMarker')\n effects.consume(code)\n effects.exit('gfmFootnoteCallLabelMarker')\n effects.exit('gfmFootnoteCall')\n return ok\n }\n if (!markdownLineEndingOrSpace(code)) {\n data = true\n }\n size++\n effects.consume(code)\n return code === 92 ? callEscape : callData\n }\n\n /**\n * On character after escape.\n *\n * ```markdown\n * > | a [^b\\c] d\n * ^\n * ```\n *\n * @type {State}\n */\n function callEscape(code) {\n if (code === 91 || code === 92 || code === 93) {\n effects.consume(code)\n size++\n return callData\n }\n return callData(code)\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeDefinitionStart(effects, ok, nok) {\n const self = this\n const defined = self.parser.gfmFootnotes || (self.parser.gfmFootnotes = [])\n /** @type {string} */\n let identifier\n let size = 0\n /** @type {boolean | undefined} */\n let data\n return start\n\n /**\n * Start of GFM footnote definition.\n *\n * ```markdown\n * > | [^a]: b\n * ^\n * ```\n *\n * @type {State}\n */\n function start(code) {\n effects.enter('gfmFootnoteDefinition')._container = true\n effects.enter('gfmFootnoteDefinitionLabel')\n effects.enter('gfmFootnoteDefinitionLabelMarker')\n effects.consume(code)\n effects.exit('gfmFootnoteDefinitionLabelMarker')\n return labelAtMarker\n }\n\n /**\n * In label, at caret.\n *\n * ```markdown\n * > | [^a]: b\n * ^\n * ```\n *\n * @type {State}\n */\n function labelAtMarker(code) {\n if (code === 94) {\n effects.enter('gfmFootnoteDefinitionMarker')\n effects.consume(code)\n effects.exit('gfmFootnoteDefinitionMarker')\n effects.enter('gfmFootnoteDefinitionLabelString')\n effects.enter('chunkString').contentType = 'string'\n return labelInside\n }\n return nok(code)\n }\n\n /**\n * In label.\n *\n * > 👉 **Note**: `cmark-gfm` prevents whitespace from occurring in footnote\n * > definition labels.\n *\n * ```markdown\n * > | [^a]: b\n * ^\n * ```\n *\n * @type {State}\n */\n function labelInside(code) {\n if (\n // Too long.\n size > 999 ||\n // Closing brace with nothing.\n (code === 93 && !data) ||\n // Space or tab is not supported by GFM for some reason.\n // `\\n` and `[` not being supported makes sense.\n code === null ||\n code === 91 ||\n markdownLineEndingOrSpace(code)\n ) {\n return nok(code)\n }\n if (code === 93) {\n effects.exit('chunkString')\n const token = effects.exit('gfmFootnoteDefinitionLabelString')\n identifier = normalizeIdentifier(self.sliceSerialize(token))\n effects.enter('gfmFootnoteDefinitionLabelMarker')\n effects.consume(code)\n effects.exit('gfmFootnoteDefinitionLabelMarker')\n effects.exit('gfmFootnoteDefinitionLabel')\n return labelAfter\n }\n if (!markdownLineEndingOrSpace(code)) {\n data = true\n }\n size++\n effects.consume(code)\n return code === 92 ? labelEscape : labelInside\n }\n\n /**\n * After `\\`, at a special character.\n *\n * > 👉 **Note**: `cmark-gfm` currently does not support escaped brackets:\n * > \n *\n * ```markdown\n * > | [^a\\*b]: c\n * ^\n * ```\n *\n * @type {State}\n */\n function labelEscape(code) {\n if (code === 91 || code === 92 || code === 93) {\n effects.consume(code)\n size++\n return labelInside\n }\n return labelInside(code)\n }\n\n /**\n * After definition label.\n *\n * ```markdown\n * > | [^a]: b\n * ^\n * ```\n *\n * @type {State}\n */\n function labelAfter(code) {\n if (code === 58) {\n effects.enter('definitionMarker')\n effects.consume(code)\n effects.exit('definitionMarker')\n if (!defined.includes(identifier)) {\n defined.push(identifier)\n }\n\n // Any whitespace after the marker is eaten, forming indented code\n // is not possible.\n // No space is also fine, just like a block quote marker.\n return factorySpace(\n effects,\n whitespaceAfter,\n 'gfmFootnoteDefinitionWhitespace'\n )\n }\n return nok(code)\n }\n\n /**\n * After definition prefix.\n *\n * ```markdown\n * > | [^a]: b\n * ^\n * ```\n *\n * @type {State}\n */\n function whitespaceAfter(code) {\n // `markdown-rs` has a wrapping token for the prefix that is closed here.\n return ok(code)\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeDefinitionContinuation(effects, ok, nok) {\n /// Start of footnote definition continuation.\n ///\n /// ```markdown\n /// | [^a]: b\n /// > | c\n /// ^\n /// ```\n //\n // Either a blank line, which is okay, or an indented thing.\n return effects.check(blankLine, ok, effects.attempt(indent, ok, nok))\n}\n\n/** @type {Exiter} */\nfunction gfmFootnoteDefinitionEnd(effects) {\n effects.exit('gfmFootnoteDefinition')\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeIndent(effects, ok, nok) {\n const self = this\n return factorySpace(\n effects,\n afterPrefix,\n 'gfmFootnoteDefinitionIndent',\n 4 + 1\n )\n\n /**\n * @type {State}\n */\n function afterPrefix(code) {\n const tail = self.events[self.events.length - 1]\n return tail &&\n tail[1].type === 'gfmFootnoteDefinitionIndent' &&\n tail[2].sliceSerialize(tail[1], true).length === 4\n ? ok(code)\n : nok(code)\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Event} Event\n * @typedef {import('micromark-util-types').Extension} Extension\n * @typedef {import('micromark-util-types').Resolver} Resolver\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').Token} Token\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n *\n * @typedef Options\n * Configuration (optional).\n * @property {boolean | null | undefined} [singleTilde=true]\n * Whether to support strikethrough with a single tilde (default: `true`).\n *\n * Single tildes work on github.com, but are technically prohibited by the\n * GFM spec.\n */\n\nimport {splice} from 'micromark-util-chunked'\nimport {classifyCharacter} from 'micromark-util-classify-character'\nimport {resolveAll} from 'micromark-util-resolve-all'\n/**\n * Create an extension for `micromark` to enable GFM strikethrough syntax.\n *\n * @param {Options | null | undefined} [options={}]\n * Configuration.\n * @returns {Extension}\n * Extension for `micromark` that can be passed in `extensions`, to\n * enable GFM strikethrough syntax.\n */\nexport function gfmStrikethrough(options) {\n const options_ = options || {}\n let single = options_.singleTilde\n const tokenizer = {\n tokenize: tokenizeStrikethrough,\n resolveAll: resolveAllStrikethrough\n }\n if (single === null || single === undefined) {\n single = true\n }\n return {\n text: {\n [126]: tokenizer\n },\n insideSpan: {\n null: [tokenizer]\n },\n attentionMarkers: {\n null: [126]\n }\n }\n\n /**\n * Take events and resolve strikethrough.\n *\n * @type {Resolver}\n */\n function resolveAllStrikethrough(events, context) {\n let index = -1\n\n // Walk through all events.\n while (++index < events.length) {\n // Find a token that can close.\n if (\n events[index][0] === 'enter' &&\n events[index][1].type === 'strikethroughSequenceTemporary' &&\n events[index][1]._close\n ) {\n let open = index\n\n // Now walk back to find an opener.\n while (open--) {\n // Find a token that can open the closer.\n if (\n events[open][0] === 'exit' &&\n events[open][1].type === 'strikethroughSequenceTemporary' &&\n events[open][1]._open &&\n // If the sizes are the same:\n events[index][1].end.offset - events[index][1].start.offset ===\n events[open][1].end.offset - events[open][1].start.offset\n ) {\n events[index][1].type = 'strikethroughSequence'\n events[open][1].type = 'strikethroughSequence'\n\n /** @type {Token} */\n const strikethrough = {\n type: 'strikethrough',\n start: Object.assign({}, events[open][1].start),\n end: Object.assign({}, events[index][1].end)\n }\n\n /** @type {Token} */\n const text = {\n type: 'strikethroughText',\n start: Object.assign({}, events[open][1].end),\n end: Object.assign({}, events[index][1].start)\n }\n\n // Opening.\n /** @type {Array} */\n const nextEvents = [\n ['enter', strikethrough, context],\n ['enter', events[open][1], context],\n ['exit', events[open][1], context],\n ['enter', text, context]\n ]\n const insideSpan = context.parser.constructs.insideSpan.null\n if (insideSpan) {\n // Between.\n splice(\n nextEvents,\n nextEvents.length,\n 0,\n resolveAll(insideSpan, events.slice(open + 1, index), context)\n )\n }\n\n // Closing.\n splice(nextEvents, nextEvents.length, 0, [\n ['exit', text, context],\n ['enter', events[index][1], context],\n ['exit', events[index][1], context],\n ['exit', strikethrough, context]\n ])\n splice(events, open - 1, index - open + 3, nextEvents)\n index = open + nextEvents.length - 2\n break\n }\n }\n }\n }\n index = -1\n while (++index < events.length) {\n if (events[index][1].type === 'strikethroughSequenceTemporary') {\n events[index][1].type = 'data'\n }\n }\n return events\n }\n\n /**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\n function tokenizeStrikethrough(effects, ok, nok) {\n const previous = this.previous\n const events = this.events\n let size = 0\n return start\n\n /** @type {State} */\n function start(code) {\n if (\n previous === 126 &&\n events[events.length - 1][1].type !== 'characterEscape'\n ) {\n return nok(code)\n }\n effects.enter('strikethroughSequenceTemporary')\n return more(code)\n }\n\n /** @type {State} */\n function more(code) {\n const before = classifyCharacter(previous)\n if (code === 126) {\n // If this is the third marker, exit.\n if (size > 1) return nok(code)\n effects.consume(code)\n size++\n return more\n }\n if (size < 2 && !single) return nok(code)\n const token = effects.exit('strikethroughSequenceTemporary')\n const after = classifyCharacter(code)\n token._open = !after || (after === 2 && Boolean(before))\n token._close = !before || (before === 2 && Boolean(after))\n return ok(code)\n }\n }\n}\n","/**\n * @typedef {import('micromark-util-types').Event} Event\n */\n\n// Port of `edit_map.rs` from `markdown-rs`.\n// This should move to `markdown-js` later.\n\n// Deal with several changes in events, batching them together.\n//\n// Preferably, changes should be kept to a minimum.\n// Sometimes, it’s needed to change the list of events, because parsing can be\n// messy, and it helps to expose a cleaner interface of events to the compiler\n// and other users.\n// It can also help to merge many adjacent similar events.\n// And, in other cases, it’s needed to parse subcontent: pass some events\n// through another tokenizer and inject the result.\n\n/**\n * @typedef {[number, number, Array]} Change\n * @typedef {[number, number, number]} Jump\n */\n\n/**\n * Tracks a bunch of edits.\n */\nexport class EditMap {\n /**\n * Create a new edit map.\n */\n constructor() {\n /**\n * Record of changes.\n *\n * @type {Array}\n */\n this.map = []\n }\n\n /**\n * Create an edit: a remove and/or add at a certain place.\n *\n * @param {number} index\n * @param {number} remove\n * @param {Array} add\n * @returns {undefined}\n */\n add(index, remove, add) {\n addImpl(this, index, remove, add)\n }\n\n // To do: add this when moving to `micromark`.\n // /**\n // * Create an edit: but insert `add` before existing additions.\n // *\n // * @param {number} index\n // * @param {number} remove\n // * @param {Array} add\n // * @returns {undefined}\n // */\n // addBefore(index, remove, add) {\n // addImpl(this, index, remove, add, true)\n // }\n\n /**\n * Done, change the events.\n *\n * @param {Array} events\n * @returns {undefined}\n */\n consume(events) {\n this.map.sort(function (a, b) {\n return a[0] - b[0]\n })\n\n /* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */\n if (this.map.length === 0) {\n return\n }\n\n // To do: if links are added in events, like they are in `markdown-rs`,\n // this is needed.\n // // Calculate jumps: where items in the current list move to.\n // /** @type {Array} */\n // const jumps = []\n // let index = 0\n // let addAcc = 0\n // let removeAcc = 0\n // while (index < this.map.length) {\n // const [at, remove, add] = this.map[index]\n // removeAcc += remove\n // addAcc += add.length\n // jumps.push([at, removeAcc, addAcc])\n // index += 1\n // }\n //\n // . shiftLinks(events, jumps)\n\n let index = this.map.length\n /** @type {Array>} */\n const vecs = []\n while (index > 0) {\n index -= 1\n vecs.push(\n events.slice(this.map[index][0] + this.map[index][1]),\n this.map[index][2]\n )\n\n // Truncate rest.\n events.length = this.map[index][0]\n }\n vecs.push([...events])\n events.length = 0\n let slice = vecs.pop()\n while (slice) {\n events.push(...slice)\n slice = vecs.pop()\n }\n\n // Truncate everything.\n this.map.length = 0\n }\n}\n\n/**\n * Create an edit.\n *\n * @param {EditMap} editMap\n * @param {number} at\n * @param {number} remove\n * @param {Array} add\n * @returns {undefined}\n */\nfunction addImpl(editMap, at, remove, add) {\n let index = 0\n\n /* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */\n if (remove === 0 && add.length === 0) {\n return\n }\n while (index < editMap.map.length) {\n if (editMap.map[index][0] === at) {\n editMap.map[index][1] += remove\n\n // To do: before not used by tables, use when moving to micromark.\n // if (before) {\n // add.push(...editMap.map[index][2])\n // editMap.map[index][2] = add\n // } else {\n editMap.map[index][2].push(...add)\n // }\n\n return\n }\n index += 1\n }\n editMap.map.push([at, remove, add])\n}\n\n// /**\n// * Shift `previous` and `next` links according to `jumps`.\n// *\n// * This fixes links in case there are events removed or added between them.\n// *\n// * @param {Array} events\n// * @param {Array} jumps\n// */\n// function shiftLinks(events, jumps) {\n// let jumpIndex = 0\n// let index = 0\n// let add = 0\n// let rm = 0\n\n// while (index < events.length) {\n// const rmCurr = rm\n\n// while (jumpIndex < jumps.length && jumps[jumpIndex][0] <= index) {\n// add = jumps[jumpIndex][2]\n// rm = jumps[jumpIndex][1]\n// jumpIndex += 1\n// }\n\n// // Ignore items that will be removed.\n// if (rm > rmCurr) {\n// index += rm - rmCurr\n// } else {\n// // ?\n// // if let Some(link) = &events[index].link {\n// // if let Some(next) = link.next {\n// // events[next].link.as_mut().unwrap().previous = Some(index + add - rm);\n// // while jumpIndex < jumps.len() && jumps[jumpIndex].0 <= next {\n// // add = jumps[jumpIndex].2;\n// // rm = jumps[jumpIndex].1;\n// // jumpIndex += 1;\n// // }\n// // events[index].link.as_mut().unwrap().next = Some(next + add - rm);\n// // index = next;\n// // continue;\n// // }\n// // }\n// index += 1\n// }\n// }\n// }\n","/**\n * @typedef {import('micromark-util-types').Event} Event\n */\n\n/**\n * @typedef {'center' | 'left' | 'none' | 'right'} Align\n */\n\n/**\n * Figure out the alignment of a GFM table.\n *\n * @param {Readonly>} events\n * List of events.\n * @param {number} index\n * Table enter event.\n * @returns {Array}\n * List of aligns.\n */\nexport function gfmTableAlign(events, index) {\n let inDelimiterRow = false\n /** @type {Array} */\n const align = []\n while (index < events.length) {\n const event = events[index]\n if (inDelimiterRow) {\n if (event[0] === 'enter') {\n // Start of alignment value: set a new column.\n // To do: `markdown-rs` uses `tableDelimiterCellValue`.\n if (event[1].type === 'tableContent') {\n align.push(\n events[index + 1][1].type === 'tableDelimiterMarker'\n ? 'left'\n : 'none'\n )\n }\n }\n // Exits:\n // End of alignment value: change the column.\n // To do: `markdown-rs` uses `tableDelimiterCellValue`.\n else if (event[1].type === 'tableContent') {\n if (events[index - 1][1].type === 'tableDelimiterMarker') {\n const alignIndex = align.length - 1\n align[alignIndex] = align[alignIndex] === 'left' ? 'center' : 'right'\n }\n }\n // Done!\n else if (event[1].type === 'tableDelimiterRow') {\n break\n }\n } else if (event[0] === 'enter' && event[1].type === 'tableDelimiterRow') {\n inDelimiterRow = true\n }\n index += 1\n }\n return align\n}\n","/**\n * @typedef {import('micromark-util-types').Event} Event\n * @typedef {import('micromark-util-types').Extension} Extension\n * @typedef {import('micromark-util-types').Point} Point\n * @typedef {import('micromark-util-types').Resolver} Resolver\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').Token} Token\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\n/**\n * @typedef {[number, number, number, number]} Range\n * Cell info.\n *\n * @typedef {0 | 1 | 2 | 3} RowKind\n * Where we are: `1` for head row, `2` for delimiter row, `3` for body row.\n */\n\nimport {factorySpace} from 'micromark-factory-space'\nimport {\n markdownLineEnding,\n markdownLineEndingOrSpace,\n markdownSpace\n} from 'micromark-util-character'\nimport {EditMap} from './edit-map.js'\nimport {gfmTableAlign} from './infer.js'\n\n/**\n * Create an HTML extension for `micromark` to support GitHub tables syntax.\n *\n * @returns {Extension}\n * Extension for `micromark` that can be passed in `extensions` to enable GFM\n * table syntax.\n */\nexport function gfmTable() {\n return {\n flow: {\n null: {\n tokenize: tokenizeTable,\n resolveAll: resolveTable\n }\n }\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeTable(effects, ok, nok) {\n const self = this\n let size = 0\n let sizeB = 0\n /** @type {boolean | undefined} */\n let seen\n return start\n\n /**\n * Start of a GFM table.\n *\n * If there is a valid table row or table head before, then we try to parse\n * another row.\n * Otherwise, we try to parse a head.\n *\n * ```markdown\n * > | | a |\n * ^\n * | | - |\n * > | | b |\n * ^\n * ```\n * @type {State}\n */\n function start(code) {\n let index = self.events.length - 1\n while (index > -1) {\n const type = self.events[index][1].type\n if (\n type === 'lineEnding' ||\n // Note: markdown-rs uses `whitespace` instead of `linePrefix`\n type === 'linePrefix'\n )\n index--\n else break\n }\n const tail = index > -1 ? self.events[index][1].type : null\n const next =\n tail === 'tableHead' || tail === 'tableRow' ? bodyRowStart : headRowBefore\n\n // Don’t allow lazy body rows.\n if (next === bodyRowStart && self.parser.lazy[self.now().line]) {\n return nok(code)\n }\n return next(code)\n }\n\n /**\n * Before table head row.\n *\n * ```markdown\n * > | | a |\n * ^\n * | | - |\n * | | b |\n * ```\n *\n * @type {State}\n */\n function headRowBefore(code) {\n effects.enter('tableHead')\n effects.enter('tableRow')\n return headRowStart(code)\n }\n\n /**\n * Before table head row, after whitespace.\n *\n * ```markdown\n * > | | a |\n * ^\n * | | - |\n * | | b |\n * ```\n *\n * @type {State}\n */\n function headRowStart(code) {\n if (code === 124) {\n return headRowBreak(code)\n }\n\n // To do: micromark-js should let us parse our own whitespace in extensions,\n // like `markdown-rs`:\n //\n // ```js\n // // 4+ spaces.\n // if (markdownSpace(code)) {\n // return nok(code)\n // }\n // ```\n\n seen = true\n // Count the first character, that isn’t a pipe, double.\n sizeB += 1\n return headRowBreak(code)\n }\n\n /**\n * At break in table head row.\n *\n * ```markdown\n * > | | a |\n * ^\n * ^\n * ^\n * | | - |\n * | | b |\n * ```\n *\n * @type {State}\n */\n function headRowBreak(code) {\n if (code === null) {\n // Note: in `markdown-rs`, we need to reset, in `micromark-js` we don‘t.\n return nok(code)\n }\n if (markdownLineEnding(code)) {\n // If anything other than one pipe (ignoring whitespace) was used, it’s fine.\n if (sizeB > 1) {\n sizeB = 0\n // To do: check if this works.\n // Feel free to interrupt:\n self.interrupt = true\n effects.exit('tableRow')\n effects.enter('lineEnding')\n effects.consume(code)\n effects.exit('lineEnding')\n return headDelimiterStart\n }\n\n // Note: in `markdown-rs`, we need to reset, in `micromark-js` we don‘t.\n return nok(code)\n }\n if (markdownSpace(code)) {\n // To do: check if this is fine.\n // effects.attempt(State::Next(StateName::GfmTableHeadRowBreak), State::Nok)\n // State::Retry(space_or_tab(tokenizer))\n return factorySpace(effects, headRowBreak, 'whitespace')(code)\n }\n sizeB += 1\n if (seen) {\n seen = false\n // Header cell count.\n size += 1\n }\n if (code === 124) {\n effects.enter('tableCellDivider')\n effects.consume(code)\n effects.exit('tableCellDivider')\n // Whether a delimiter was seen.\n seen = true\n return headRowBreak\n }\n\n // Anything else is cell data.\n effects.enter('data')\n return headRowData(code)\n }\n\n /**\n * In table head row data.\n *\n * ```markdown\n * > | | a |\n * ^\n * | | - |\n * | | b |\n * ```\n *\n * @type {State}\n */\n function headRowData(code) {\n if (code === null || code === 124 || markdownLineEndingOrSpace(code)) {\n effects.exit('data')\n return headRowBreak(code)\n }\n effects.consume(code)\n return code === 92 ? headRowEscape : headRowData\n }\n\n /**\n * In table head row escape.\n *\n * ```markdown\n * > | | a\\-b |\n * ^\n * | | ---- |\n * | | c |\n * ```\n *\n * @type {State}\n */\n function headRowEscape(code) {\n if (code === 92 || code === 124) {\n effects.consume(code)\n return headRowData\n }\n return headRowData(code)\n }\n\n /**\n * Before delimiter row.\n *\n * ```markdown\n * | | a |\n * > | | - |\n * ^\n * | | b |\n * ```\n *\n * @type {State}\n */\n function headDelimiterStart(code) {\n // Reset `interrupt`.\n self.interrupt = false\n\n // Note: in `markdown-rs`, we need to handle piercing here too.\n if (self.parser.lazy[self.now().line]) {\n return nok(code)\n }\n effects.enter('tableDelimiterRow')\n // Track if we’ve seen a `:` or `|`.\n seen = false\n if (markdownSpace(code)) {\n return factorySpace(\n effects,\n headDelimiterBefore,\n 'linePrefix',\n self.parser.constructs.disable.null.includes('codeIndented')\n ? undefined\n : 4\n )(code)\n }\n return headDelimiterBefore(code)\n }\n\n /**\n * Before delimiter row, after optional whitespace.\n *\n * Reused when a `|` is found later, to parse another cell.\n *\n * ```markdown\n * | | a |\n * > | | - |\n * ^\n * | | b |\n * ```\n *\n * @type {State}\n */\n function headDelimiterBefore(code) {\n if (code === 45 || code === 58) {\n return headDelimiterValueBefore(code)\n }\n if (code === 124) {\n seen = true\n // If we start with a pipe, we open a cell marker.\n effects.enter('tableCellDivider')\n effects.consume(code)\n effects.exit('tableCellDivider')\n return headDelimiterCellBefore\n }\n\n // More whitespace / empty row not allowed at start.\n return headDelimiterNok(code)\n }\n\n /**\n * After `|`, before delimiter cell.\n *\n * ```markdown\n * | | a |\n * > | | - |\n * ^\n * ```\n *\n * @type {State}\n */\n function headDelimiterCellBefore(code) {\n if (markdownSpace(code)) {\n return factorySpace(effects, headDelimiterValueBefore, 'whitespace')(code)\n }\n return headDelimiterValueBefore(code)\n }\n\n /**\n * Before delimiter cell value.\n *\n * ```markdown\n * | | a |\n * > | | - |\n * ^\n * ```\n *\n * @type {State}\n */\n function headDelimiterValueBefore(code) {\n // Align: left.\n if (code === 58) {\n sizeB += 1\n seen = true\n effects.enter('tableDelimiterMarker')\n effects.consume(code)\n effects.exit('tableDelimiterMarker')\n return headDelimiterLeftAlignmentAfter\n }\n\n // Align: none.\n if (code === 45) {\n sizeB += 1\n // To do: seems weird that this *isn’t* left aligned, but that state is used?\n return headDelimiterLeftAlignmentAfter(code)\n }\n if (code === null || markdownLineEnding(code)) {\n return headDelimiterCellAfter(code)\n }\n return headDelimiterNok(code)\n }\n\n /**\n * After delimiter cell left alignment marker.\n *\n * ```markdown\n * | | a |\n * > | | :- |\n * ^\n * ```\n *\n * @type {State}\n */\n function headDelimiterLeftAlignmentAfter(code) {\n if (code === 45) {\n effects.enter('tableDelimiterFiller')\n return headDelimiterFiller(code)\n }\n\n // Anything else is not ok after the left-align colon.\n return headDelimiterNok(code)\n }\n\n /**\n * In delimiter cell filler.\n *\n * ```markdown\n * | | a |\n * > | | - |\n * ^\n * ```\n *\n * @type {State}\n */\n function headDelimiterFiller(code) {\n if (code === 45) {\n effects.consume(code)\n return headDelimiterFiller\n }\n\n // Align is `center` if it was `left`, `right` otherwise.\n if (code === 58) {\n seen = true\n effects.exit('tableDelimiterFiller')\n effects.enter('tableDelimiterMarker')\n effects.consume(code)\n effects.exit('tableDelimiterMarker')\n return headDelimiterRightAlignmentAfter\n }\n effects.exit('tableDelimiterFiller')\n return headDelimiterRightAlignmentAfter(code)\n }\n\n /**\n * After delimiter cell right alignment marker.\n *\n * ```markdown\n * | | a |\n * > | | -: |\n * ^\n * ```\n *\n * @type {State}\n */\n function headDelimiterRightAlignmentAfter(code) {\n if (markdownSpace(code)) {\n return factorySpace(effects, headDelimiterCellAfter, 'whitespace')(code)\n }\n return headDelimiterCellAfter(code)\n }\n\n /**\n * After delimiter cell.\n *\n * ```markdown\n * | | a |\n * > | | -: |\n * ^\n * ```\n *\n * @type {State}\n */\n function headDelimiterCellAfter(code) {\n if (code === 124) {\n return headDelimiterBefore(code)\n }\n if (code === null || markdownLineEnding(code)) {\n // Exit when:\n // * there was no `:` or `|` at all (it’s a thematic break or setext\n // underline instead)\n // * the header cell count is not the delimiter cell count\n if (!seen || size !== sizeB) {\n return headDelimiterNok(code)\n }\n\n // Note: in markdown-rs`, a reset is needed here.\n effects.exit('tableDelimiterRow')\n effects.exit('tableHead')\n // To do: in `markdown-rs`, resolvers need to be registered manually.\n // effects.register_resolver(ResolveName::GfmTable)\n return ok(code)\n }\n return headDelimiterNok(code)\n }\n\n /**\n * In delimiter row, at a disallowed byte.\n *\n * ```markdown\n * | | a |\n * > | | x |\n * ^\n * ```\n *\n * @type {State}\n */\n function headDelimiterNok(code) {\n // Note: in `markdown-rs`, we need to reset, in `micromark-js` we don‘t.\n return nok(code)\n }\n\n /**\n * Before table body row.\n *\n * ```markdown\n * | | a |\n * | | - |\n * > | | b |\n * ^\n * ```\n *\n * @type {State}\n */\n function bodyRowStart(code) {\n // Note: in `markdown-rs` we need to manually take care of a prefix,\n // but in `micromark-js` that is done for us, so if we’re here, we’re\n // never at whitespace.\n effects.enter('tableRow')\n return bodyRowBreak(code)\n }\n\n /**\n * At break in table body row.\n *\n * ```markdown\n * | | a |\n * | | - |\n * > | | b |\n * ^\n * ^\n * ^\n * ```\n *\n * @type {State}\n */\n function bodyRowBreak(code) {\n if (code === 124) {\n effects.enter('tableCellDivider')\n effects.consume(code)\n effects.exit('tableCellDivider')\n return bodyRowBreak\n }\n if (code === null || markdownLineEnding(code)) {\n effects.exit('tableRow')\n return ok(code)\n }\n if (markdownSpace(code)) {\n return factorySpace(effects, bodyRowBreak, 'whitespace')(code)\n }\n\n // Anything else is cell content.\n effects.enter('data')\n return bodyRowData(code)\n }\n\n /**\n * In table body row data.\n *\n * ```markdown\n * | | a |\n * | | - |\n * > | | b |\n * ^\n * ```\n *\n * @type {State}\n */\n function bodyRowData(code) {\n if (code === null || code === 124 || markdownLineEndingOrSpace(code)) {\n effects.exit('data')\n return bodyRowBreak(code)\n }\n effects.consume(code)\n return code === 92 ? bodyRowEscape : bodyRowData\n }\n\n /**\n * In table body row escape.\n *\n * ```markdown\n * | | a |\n * | | ---- |\n * > | | b\\-c |\n * ^\n * ```\n *\n * @type {State}\n */\n function bodyRowEscape(code) {\n if (code === 92 || code === 124) {\n effects.consume(code)\n return bodyRowData\n }\n return bodyRowData(code)\n }\n}\n\n/** @type {Resolver} */\n\nfunction resolveTable(events, context) {\n let index = -1\n let inFirstCellAwaitingPipe = true\n /** @type {RowKind} */\n let rowKind = 0\n /** @type {Range} */\n let lastCell = [0, 0, 0, 0]\n /** @type {Range} */\n let cell = [0, 0, 0, 0]\n let afterHeadAwaitingFirstBodyRow = false\n let lastTableEnd = 0\n /** @type {Token | undefined} */\n let currentTable\n /** @type {Token | undefined} */\n let currentBody\n /** @type {Token | undefined} */\n let currentCell\n const map = new EditMap()\n while (++index < events.length) {\n const event = events[index]\n const token = event[1]\n if (event[0] === 'enter') {\n // Start of head.\n if (token.type === 'tableHead') {\n afterHeadAwaitingFirstBodyRow = false\n\n // Inject previous (body end and) table end.\n if (lastTableEnd !== 0) {\n flushTableEnd(map, context, lastTableEnd, currentTable, currentBody)\n currentBody = undefined\n lastTableEnd = 0\n }\n\n // Inject table start.\n currentTable = {\n type: 'table',\n start: Object.assign({}, token.start),\n // Note: correct end is set later.\n end: Object.assign({}, token.end)\n }\n map.add(index, 0, [['enter', currentTable, context]])\n } else if (\n token.type === 'tableRow' ||\n token.type === 'tableDelimiterRow'\n ) {\n inFirstCellAwaitingPipe = true\n currentCell = undefined\n lastCell = [0, 0, 0, 0]\n cell = [0, index + 1, 0, 0]\n\n // Inject table body start.\n if (afterHeadAwaitingFirstBodyRow) {\n afterHeadAwaitingFirstBodyRow = false\n currentBody = {\n type: 'tableBody',\n start: Object.assign({}, token.start),\n // Note: correct end is set later.\n end: Object.assign({}, token.end)\n }\n map.add(index, 0, [['enter', currentBody, context]])\n }\n rowKind = token.type === 'tableDelimiterRow' ? 2 : currentBody ? 3 : 1\n }\n // Cell data.\n else if (\n rowKind &&\n (token.type === 'data' ||\n token.type === 'tableDelimiterMarker' ||\n token.type === 'tableDelimiterFiller')\n ) {\n inFirstCellAwaitingPipe = false\n\n // First value in cell.\n if (cell[2] === 0) {\n if (lastCell[1] !== 0) {\n cell[0] = cell[1]\n currentCell = flushCell(\n map,\n context,\n lastCell,\n rowKind,\n undefined,\n currentCell\n )\n lastCell = [0, 0, 0, 0]\n }\n cell[2] = index\n }\n } else if (token.type === 'tableCellDivider') {\n if (inFirstCellAwaitingPipe) {\n inFirstCellAwaitingPipe = false\n } else {\n if (lastCell[1] !== 0) {\n cell[0] = cell[1]\n currentCell = flushCell(\n map,\n context,\n lastCell,\n rowKind,\n undefined,\n currentCell\n )\n }\n lastCell = cell\n cell = [lastCell[1], index, 0, 0]\n }\n }\n }\n // Exit events.\n else if (token.type === 'tableHead') {\n afterHeadAwaitingFirstBodyRow = true\n lastTableEnd = index\n } else if (\n token.type === 'tableRow' ||\n token.type === 'tableDelimiterRow'\n ) {\n lastTableEnd = index\n if (lastCell[1] !== 0) {\n cell[0] = cell[1]\n currentCell = flushCell(\n map,\n context,\n lastCell,\n rowKind,\n index,\n currentCell\n )\n } else if (cell[1] !== 0) {\n currentCell = flushCell(map, context, cell, rowKind, index, currentCell)\n }\n rowKind = 0\n } else if (\n rowKind &&\n (token.type === 'data' ||\n token.type === 'tableDelimiterMarker' ||\n token.type === 'tableDelimiterFiller')\n ) {\n cell[3] = index\n }\n }\n if (lastTableEnd !== 0) {\n flushTableEnd(map, context, lastTableEnd, currentTable, currentBody)\n }\n map.consume(context.events)\n\n // To do: move this into `html`, when events are exposed there.\n // That’s what `markdown-rs` does.\n // That needs updates to `mdast-util-gfm-table`.\n index = -1\n while (++index < context.events.length) {\n const event = context.events[index]\n if (event[0] === 'enter' && event[1].type === 'table') {\n event[1]._align = gfmTableAlign(context.events, index)\n }\n }\n return events\n}\n\n/**\n * Generate a cell.\n *\n * @param {EditMap} map\n * @param {Readonly} context\n * @param {Readonly} range\n * @param {RowKind} rowKind\n * @param {number | undefined} rowEnd\n * @param {Token | undefined} previousCell\n * @returns {Token | undefined}\n */\n// eslint-disable-next-line max-params\nfunction flushCell(map, context, range, rowKind, rowEnd, previousCell) {\n // `markdown-rs` uses:\n // rowKind === 2 ? 'tableDelimiterCell' : 'tableCell'\n const groupName =\n rowKind === 1\n ? 'tableHeader'\n : rowKind === 2\n ? 'tableDelimiter'\n : 'tableData'\n // `markdown-rs` uses:\n // rowKind === 2 ? 'tableDelimiterCellValue' : 'tableCellText'\n const valueName = 'tableContent'\n\n // Insert an exit for the previous cell, if there is one.\n //\n // ```markdown\n // > | | aa | bb | cc |\n // ^-- exit\n // ^^^^-- this cell\n // ```\n if (range[0] !== 0) {\n previousCell.end = Object.assign({}, getPoint(context.events, range[0]))\n map.add(range[0], 0, [['exit', previousCell, context]])\n }\n\n // Insert enter of this cell.\n //\n // ```markdown\n // > | | aa | bb | cc |\n // ^-- enter\n // ^^^^-- this cell\n // ```\n const now = getPoint(context.events, range[1])\n previousCell = {\n type: groupName,\n start: Object.assign({}, now),\n // Note: correct end is set later.\n end: Object.assign({}, now)\n }\n map.add(range[1], 0, [['enter', previousCell, context]])\n\n // Insert text start at first data start and end at last data end, and\n // remove events between.\n //\n // ```markdown\n // > | | aa | bb | cc |\n // ^-- enter\n // ^-- exit\n // ^^^^-- this cell\n // ```\n if (range[2] !== 0) {\n const relatedStart = getPoint(context.events, range[2])\n const relatedEnd = getPoint(context.events, range[3])\n /** @type {Token} */\n const valueToken = {\n type: valueName,\n start: Object.assign({}, relatedStart),\n end: Object.assign({}, relatedEnd)\n }\n map.add(range[2], 0, [['enter', valueToken, context]])\n if (rowKind !== 2) {\n // Fix positional info on remaining events\n const start = context.events[range[2]]\n const end = context.events[range[3]]\n start[1].end = Object.assign({}, end[1].end)\n start[1].type = 'chunkText'\n start[1].contentType = 'text'\n\n // Remove if needed.\n if (range[3] > range[2] + 1) {\n const a = range[2] + 1\n const b = range[3] - range[2] - 1\n map.add(a, b, [])\n }\n }\n map.add(range[3] + 1, 0, [['exit', valueToken, context]])\n }\n\n // Insert an exit for the last cell, if at the row end.\n //\n // ```markdown\n // > | | aa | bb | cc |\n // ^-- exit\n // ^^^^^^-- this cell (the last one contains two “between” parts)\n // ```\n if (rowEnd !== undefined) {\n previousCell.end = Object.assign({}, getPoint(context.events, rowEnd))\n map.add(rowEnd, 0, [['exit', previousCell, context]])\n previousCell = undefined\n }\n return previousCell\n}\n\n/**\n * Generate table end (and table body end).\n *\n * @param {Readonly} map\n * @param {Readonly} context\n * @param {number} index\n * @param {Token} table\n * @param {Token | undefined} tableBody\n */\n// eslint-disable-next-line max-params\nfunction flushTableEnd(map, context, index, table, tableBody) {\n /** @type {Array} */\n const exits = []\n const related = getPoint(context.events, index)\n if (tableBody) {\n tableBody.end = Object.assign({}, related)\n exits.push(['exit', tableBody, context])\n }\n table.end = Object.assign({}, related)\n exits.push(['exit', table, context])\n map.add(index + 1, 0, exits)\n}\n\n/**\n * @param {Readonly>} events\n * @param {number} index\n * @returns {Readonly}\n */\nfunction getPoint(events, index) {\n const event = events[index]\n const side = event[0] === 'enter' ? 'start' : 'end'\n return event[1][side]\n}\n","/**\n * @typedef {import('micromark-util-types').Extension} Extension\n * @typedef {import('micromark-util-types').State} State\n * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext\n * @typedef {import('micromark-util-types').Tokenizer} Tokenizer\n */\n\nimport {factorySpace} from 'micromark-factory-space'\nimport {\n markdownLineEnding,\n markdownLineEndingOrSpace,\n markdownSpace\n} from 'micromark-util-character'\nconst tasklistCheck = {\n tokenize: tokenizeTasklistCheck\n}\n\n/**\n * Create an HTML extension for `micromark` to support GFM task list items\n * syntax.\n *\n * @returns {Extension}\n * Extension for `micromark` that can be passed in `htmlExtensions` to\n * support GFM task list items when serializing to HTML.\n */\nexport function gfmTaskListItem() {\n return {\n text: {\n [91]: tasklistCheck\n }\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction tokenizeTasklistCheck(effects, ok, nok) {\n const self = this\n return open\n\n /**\n * At start of task list item check.\n *\n * ```markdown\n * > | * [x] y.\n * ^\n * ```\n *\n * @type {State}\n */\n function open(code) {\n if (\n // Exit if there’s stuff before.\n self.previous !== null ||\n // Exit if not in the first content that is the first child of a list\n // item.\n !self._gfmTasklistFirstContentOfListItem\n ) {\n return nok(code)\n }\n effects.enter('taskListCheck')\n effects.enter('taskListCheckMarker')\n effects.consume(code)\n effects.exit('taskListCheckMarker')\n return inside\n }\n\n /**\n * In task list item check.\n *\n * ```markdown\n * > | * [x] y.\n * ^\n * ```\n *\n * @type {State}\n */\n function inside(code) {\n // Currently we match how GH works in files.\n // To match how GH works in comments, use `markdownSpace` (`[\\t ]`) instead\n // of `markdownLineEndingOrSpace` (`[\\t\\n\\r ]`).\n if (markdownLineEndingOrSpace(code)) {\n effects.enter('taskListCheckValueUnchecked')\n effects.consume(code)\n effects.exit('taskListCheckValueUnchecked')\n return close\n }\n if (code === 88 || code === 120) {\n effects.enter('taskListCheckValueChecked')\n effects.consume(code)\n effects.exit('taskListCheckValueChecked')\n return close\n }\n return nok(code)\n }\n\n /**\n * At close of task list item check.\n *\n * ```markdown\n * > | * [x] y.\n * ^\n * ```\n *\n * @type {State}\n */\n function close(code) {\n if (code === 93) {\n effects.enter('taskListCheckMarker')\n effects.consume(code)\n effects.exit('taskListCheckMarker')\n effects.exit('taskListCheck')\n return after\n }\n return nok(code)\n }\n\n /**\n * @type {State}\n */\n function after(code) {\n // EOL in paragraph means there must be something else after it.\n if (markdownLineEnding(code)) {\n return ok(code)\n }\n\n // Space or tab?\n // Check what comes after.\n if (markdownSpace(code)) {\n return effects.check(\n {\n tokenize: spaceThenNonSpace\n },\n ok,\n nok\n )(code)\n }\n\n // EOF, or non-whitespace, both wrong.\n return nok(code)\n }\n}\n\n/**\n * @this {TokenizeContext}\n * @type {Tokenizer}\n */\nfunction spaceThenNonSpace(effects, ok, nok) {\n return factorySpace(effects, after, 'whitespace')\n\n /**\n * After whitespace, after task list item check.\n *\n * ```markdown\n * > | * [x] y.\n * ^\n * ```\n *\n * @type {State}\n */\n function after(code) {\n // EOF means there was nothing, so bad.\n // EOL means there’s content after it, so good.\n // Impossible to have more spaces.\n // Anything else is good.\n return code === null ? nok(code) : ok(code)\n }\n}\n","/// \n/// \n\n/**\n * @typedef {import('mdast').Root} Root\n * @typedef {import('mdast-util-gfm').Options} MdastOptions\n * @typedef {import('micromark-extension-gfm').Options} MicromarkOptions\n * @typedef {import('unified').Processor} Processor\n */\n\n/**\n * @typedef {MicromarkOptions & MdastOptions} Options\n * Configuration.\n */\n\nimport {gfmFromMarkdown, gfmToMarkdown} from 'mdast-util-gfm'\nimport {gfm} from 'micromark-extension-gfm'\n\n/** @type {Options} */\nconst emptyOptions = {}\n\n/**\n * Add support GFM (autolink literals, footnotes, strikethrough, tables,\n * tasklists).\n *\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {undefined}\n * Nothing.\n */\nexport default function remarkGfm(options) {\n // @ts-expect-error: TS is wrong about `this`.\n // eslint-disable-next-line unicorn/no-this-assignment\n const self = /** @type {Processor} */ (this)\n const settings = options || emptyOptions\n const data = self.data()\n\n const micromarkExtensions =\n data.micromarkExtensions || (data.micromarkExtensions = [])\n const fromMarkdownExtensions =\n data.fromMarkdownExtensions || (data.fromMarkdownExtensions = [])\n const toMarkdownExtensions =\n data.toMarkdownExtensions || (data.toMarkdownExtensions = [])\n\n micromarkExtensions.push(gfm(settings))\n fromMarkdownExtensions.push(gfmFromMarkdown())\n toMarkdownExtensions.push(gfmToMarkdown(settings))\n}\n","/**\n * @typedef {import('micromark-extension-gfm-footnote').HtmlOptions} HtmlOptions\n * @typedef {import('micromark-extension-gfm-strikethrough').Options} Options\n * @typedef {import('micromark-util-types').Extension} Extension\n * @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension\n */\n\nimport {\n combineExtensions,\n combineHtmlExtensions\n} from 'micromark-util-combine-extensions'\nimport {\n gfmAutolinkLiteral,\n gfmAutolinkLiteralHtml\n} from 'micromark-extension-gfm-autolink-literal'\nimport {gfmFootnote, gfmFootnoteHtml} from 'micromark-extension-gfm-footnote'\nimport {\n gfmStrikethrough,\n gfmStrikethroughHtml\n} from 'micromark-extension-gfm-strikethrough'\nimport {gfmTable, gfmTableHtml} from 'micromark-extension-gfm-table'\nimport {gfmTagfilterHtml} from 'micromark-extension-gfm-tagfilter'\nimport {\n gfmTaskListItem,\n gfmTaskListItemHtml\n} from 'micromark-extension-gfm-task-list-item'\n\n/**\n * Create an extension for `micromark` to enable GFM syntax.\n *\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n *\n * Passed to `micromark-extens-gfm-strikethrough`.\n * @returns {Extension}\n * Extension for `micromark` that can be passed in `extensions` to enable GFM\n * syntax.\n */\nexport function gfm(options) {\n return combineExtensions([\n gfmAutolinkLiteral(),\n gfmFootnote(),\n gfmStrikethrough(options),\n gfmTable(),\n gfmTaskListItem()\n ])\n}\n\n/**\n * Create an extension for `micromark` to support GFM when serializing to HTML.\n *\n * @param {HtmlOptions | null | undefined} [options]\n * Configuration (optional).\n *\n * Passed to `micromark-extens-gfm-footnote`.\n * @returns {HtmlExtension}\n * Extension for `micromark` that can be passed in `htmlExtensions` to\n * support GFM when serializing to HTML.\n */\nexport function gfmHtml(options) {\n return combineHtmlExtensions([\n gfmAutolinkLiteralHtml(),\n gfmFootnoteHtml(options),\n gfmStrikethroughHtml(),\n gfmTableHtml(),\n gfmTagfilterHtml(),\n gfmTaskListItemHtml()\n ])\n}\n","/**\n * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension\n * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension\n */\n\n/**\n * @typedef {import('mdast-util-gfm-table').Options} Options\n * Configuration.\n */\n\nimport {\n gfmAutolinkLiteralFromMarkdown,\n gfmAutolinkLiteralToMarkdown\n} from 'mdast-util-gfm-autolink-literal'\nimport {\n gfmFootnoteFromMarkdown,\n gfmFootnoteToMarkdown\n} from 'mdast-util-gfm-footnote'\nimport {\n gfmStrikethroughFromMarkdown,\n gfmStrikethroughToMarkdown\n} from 'mdast-util-gfm-strikethrough'\nimport {gfmTableFromMarkdown, gfmTableToMarkdown} from 'mdast-util-gfm-table'\nimport {\n gfmTaskListItemFromMarkdown,\n gfmTaskListItemToMarkdown\n} from 'mdast-util-gfm-task-list-item'\n\n/**\n * Create an extension for `mdast-util-from-markdown` to enable GFM (autolink\n * literals, footnotes, strikethrough, tables, tasklists).\n *\n * @returns {Array}\n * Extension for `mdast-util-from-markdown` to enable GFM (autolink literals,\n * footnotes, strikethrough, tables, tasklists).\n */\nexport function gfmFromMarkdown() {\n return [\n gfmAutolinkLiteralFromMarkdown(),\n gfmFootnoteFromMarkdown(),\n gfmStrikethroughFromMarkdown(),\n gfmTableFromMarkdown(),\n gfmTaskListItemFromMarkdown()\n ]\n}\n\n/**\n * Create an extension for `mdast-util-to-markdown` to enable GFM (autolink\n * literals, footnotes, strikethrough, tables, tasklists).\n *\n * @param {Options | null | undefined} [options]\n * Configuration.\n * @returns {ToMarkdownExtension}\n * Extension for `mdast-util-to-markdown` to enable GFM (autolink literals,\n * footnotes, strikethrough, tables, tasklists).\n */\nexport function gfmToMarkdown(options) {\n return {\n extensions: [\n gfmAutolinkLiteralToMarkdown(),\n gfmFootnoteToMarkdown(),\n gfmStrikethroughToMarkdown(),\n gfmTableToMarkdown(options),\n gfmTaskListItemToMarkdown()\n ]\n }\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').Properties} Properties\n */\n\n/**\n * @template {string} SimpleSelector\n * Selector type.\n * @template {string} DefaultTagName\n * Default tag name.\n * @typedef {(\n * SimpleSelector extends ''\n * ? DefaultTagName\n * : SimpleSelector extends `${infer TagName}.${infer Rest}`\n * ? ExtractTagName\n * : SimpleSelector extends `${infer TagName}#${infer Rest}`\n * ? ExtractTagName\n * : SimpleSelector extends string\n * ? SimpleSelector\n * : DefaultTagName\n * )} ExtractTagName\n * Extract tag name from a simple selector.\n */\n\nconst search = /[#.]/g\n\n/**\n * Create a hast element from a simple CSS selector.\n *\n * @template {string} Selector\n * Type of selector.\n * @template {string} [DefaultTagName='div']\n * Type of default tag name (default: `'div'`).\n * @param {Selector | null | undefined} [selector]\n * Simple CSS selector (optional).\n *\n * Can contain a tag name (`foo`), classes (`.bar`), and an ID (`#baz`).\n * Multiple classes are allowed.\n * Uses the last ID if multiple IDs are found.\n * @param {DefaultTagName | null | undefined} [defaultTagName='div']\n * Tag name to use if `selector` does not specify one (default: `'div'`).\n * @returns {Element & {tagName: ExtractTagName}}\n * Built element.\n */\nexport function parseSelector(selector, defaultTagName) {\n const value = selector || ''\n /** @type {Properties} */\n const props = {}\n let start = 0\n /** @type {string | undefined} */\n let previous\n /** @type {string | undefined} */\n let tagName\n\n while (start < value.length) {\n search.lastIndex = start\n const match = search.exec(value)\n const subvalue = value.slice(start, match ? match.index : value.length)\n\n if (subvalue) {\n if (!previous) {\n tagName = subvalue\n } else if (previous === '#') {\n props.id = subvalue\n } else if (Array.isArray(props.className)) {\n props.className.push(subvalue)\n } else {\n props.className = [subvalue]\n }\n\n start += subvalue.length\n }\n\n if (match) {\n previous = match[0]\n start++\n }\n }\n\n return {\n type: 'element',\n // @ts-expect-error: tag name is parsed.\n tagName: tagName || defaultTagName || 'div',\n properties: props,\n children: []\n }\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').Nodes} Nodes\n * @typedef {import('hast').Root} Root\n * @typedef {import('hast').RootContent} RootContent\n *\n * @typedef {import('property-information').Info} Info\n * @typedef {import('property-information').Schema} Schema\n */\n\n/**\n * @typedef {Element | Root} Result\n * Result from a `h` (or `s`) call.\n *\n * @typedef {number | string} StyleValue\n * Value for a CSS style field.\n * @typedef {Record} Style\n * Supported value of a `style` prop.\n * @typedef {boolean | number | string | null | undefined} PrimitiveValue\n * Primitive property value.\n * @typedef {Array} ArrayValue\n * List of property values for space- or comma separated values (such as `className`).\n * @typedef {ArrayValue | PrimitiveValue} PropertyValue\n * Primitive value or list value.\n * @typedef {{[property: string]: PropertyValue | Style}} Properties\n * Acceptable value for element properties.\n *\n * @typedef {number | string | null | undefined} PrimitiveChild\n * Primitive children, either ignored (nullish), or turned into text nodes.\n * @typedef {Array} ArrayChild\n * List of children.\n * @typedef {Array} ArrayChildNested\n * List of children (deep).\n * @typedef {ArrayChild | Nodes | PrimitiveChild} Child\n * Acceptable child value.\n */\n\nimport {parse as commas} from 'comma-separated-tokens'\nimport {parseSelector} from 'hast-util-parse-selector'\nimport {find, normalize} from 'property-information'\nimport {parse as spaces} from 'space-separated-tokens'\n\nconst buttonTypes = new Set(['button', 'menu', 'reset', 'submit'])\n\nconst own = {}.hasOwnProperty\n\n/**\n * @param {Schema} schema\n * Schema to use.\n * @param {string} defaultTagName\n * Default tag name.\n * @param {Array | undefined} [caseSensitive]\n * Case-sensitive tag names (default: `undefined`).\n * @returns\n * `h`.\n */\nexport function createH(schema, defaultTagName, caseSensitive) {\n const adjust = caseSensitive && createAdjustMap(caseSensitive)\n\n /**\n * Hyperscript compatible DSL for creating virtual hast trees.\n *\n * @overload\n * @param {null | undefined} [selector]\n * @param {...Child} children\n * @returns {Root}\n *\n * @overload\n * @param {string} selector\n * @param {Properties} properties\n * @param {...Child} children\n * @returns {Element}\n *\n * @overload\n * @param {string} selector\n * @param {...Child} children\n * @returns {Element}\n *\n * @param {string | null | undefined} [selector]\n * Selector.\n * @param {Child | Properties | null | undefined} [properties]\n * Properties (or first child) (default: `undefined`).\n * @param {...Child} children\n * Children.\n * @returns {Result}\n * Result.\n */\n function h(selector, properties, ...children) {\n let index = -1\n /** @type {Result} */\n let node\n\n if (selector === undefined || selector === null) {\n node = {type: 'root', children: []}\n // Properties are not supported for roots.\n const child = /** @type {Child} */ (properties)\n children.unshift(child)\n } else {\n node = parseSelector(selector, defaultTagName)\n // Normalize the name.\n node.tagName = node.tagName.toLowerCase()\n if (adjust && own.call(adjust, node.tagName)) {\n node.tagName = adjust[node.tagName]\n }\n\n // Handle props.\n if (isProperties(properties, node.tagName)) {\n /** @type {string} */\n let key\n\n for (key in properties) {\n if (own.call(properties, key)) {\n addProperty(schema, node.properties, key, properties[key])\n }\n }\n } else {\n children.unshift(properties)\n }\n }\n\n // Handle children.\n while (++index < children.length) {\n addChild(node.children, children[index])\n }\n\n if (node.type === 'element' && node.tagName === 'template') {\n node.content = {type: 'root', children: node.children}\n node.children = []\n }\n\n return node\n }\n\n return h\n}\n\n/**\n * Check if something is properties or a child.\n *\n * @param {Child | Properties} value\n * Value to check.\n * @param {string} name\n * Tag name.\n * @returns {value is Properties}\n * Whether `value` is a properties object.\n */\nfunction isProperties(value, name) {\n if (\n value === null ||\n value === undefined ||\n typeof value !== 'object' ||\n Array.isArray(value)\n ) {\n return false\n }\n\n if (name === 'input' || !value.type || typeof value.type !== 'string') {\n return true\n }\n\n if ('children' in value && Array.isArray(value.children)) {\n return false\n }\n\n if (name === 'button') {\n return buttonTypes.has(value.type.toLowerCase())\n }\n\n return !('value' in value)\n}\n\n/**\n * @param {Schema} schema\n * Schema.\n * @param {Properties} properties\n * Properties object.\n * @param {string} key\n * Property name.\n * @param {PropertyValue | Style} value\n * Property value.\n * @returns {undefined}\n * Nothing.\n */\nfunction addProperty(schema, properties, key, value) {\n const info = find(schema, key)\n let index = -1\n /** @type {PropertyValue} */\n let result\n\n // Ignore nullish and NaN values.\n if (value === undefined || value === null) return\n\n if (typeof value === 'number') {\n // Ignore NaN.\n if (Number.isNaN(value)) return\n\n result = value\n }\n // Booleans.\n else if (typeof value === 'boolean') {\n result = value\n }\n // Handle list values.\n else if (typeof value === 'string') {\n if (info.spaceSeparated) {\n result = spaces(value)\n } else if (info.commaSeparated) {\n result = commas(value)\n } else if (info.commaOrSpaceSeparated) {\n result = spaces(commas(value).join(' '))\n } else {\n result = parsePrimitive(info, info.property, value)\n }\n } else if (Array.isArray(value)) {\n result = value.concat()\n } else {\n result = info.property === 'style' ? style(value) : String(value)\n }\n\n if (Array.isArray(result)) {\n /** @type {Array} */\n const finalResult = []\n\n while (++index < result.length) {\n // Assume no booleans in array.\n const value = /** @type {number | string} */ (\n parsePrimitive(info, info.property, result[index])\n )\n finalResult[index] = value\n }\n\n result = finalResult\n }\n\n // Class names (which can be added both on the `selector` and here).\n if (info.property === 'className' && Array.isArray(properties.className)) {\n // Assume no booleans in `className`.\n const value = /** @type {number | string} */ (result)\n result = properties.className.concat(value)\n }\n\n properties[info.property] = result\n}\n\n/**\n * @param {Array} nodes\n * Children.\n * @param {Child} value\n * Child.\n * @returns {undefined}\n * Nothing.\n */\nfunction addChild(nodes, value) {\n let index = -1\n\n if (value === undefined || value === null) {\n // Empty.\n } else if (typeof value === 'string' || typeof value === 'number') {\n nodes.push({type: 'text', value: String(value)})\n } else if (Array.isArray(value)) {\n while (++index < value.length) {\n addChild(nodes, value[index])\n }\n } else if (typeof value === 'object' && 'type' in value) {\n if (value.type === 'root') {\n addChild(nodes, value.children)\n } else {\n nodes.push(value)\n }\n } else {\n throw new Error('Expected node, nodes, or string, got `' + value + '`')\n }\n}\n\n/**\n * Parse a single primitives.\n *\n * @param {Info} info\n * Property information.\n * @param {string} name\n * Property name.\n * @param {PrimitiveValue} value\n * Property value.\n * @returns {PrimitiveValue}\n * Property value.\n */\nfunction parsePrimitive(info, name, value) {\n if (typeof value === 'string') {\n if (info.number && value && !Number.isNaN(Number(value))) {\n return Number(value)\n }\n\n if (\n (info.boolean || info.overloadedBoolean) &&\n (value === '' || normalize(value) === normalize(name))\n ) {\n return true\n }\n }\n\n return value\n}\n\n/**\n * Serialize a `style` object as a string.\n *\n * @param {Style} value\n * Style object.\n * @returns {string}\n * CSS string.\n */\nfunction style(value) {\n /** @type {Array} */\n const result = []\n /** @type {string} */\n let key\n\n for (key in value) {\n if (own.call(value, key)) {\n result.push([key, value[key]].join(': '))\n }\n }\n\n return result.join('; ')\n}\n\n/**\n * Create a map to adjust casing.\n *\n * @param {Array} values\n * List of properly cased keys.\n * @returns {Record}\n * Map of lowercase keys to uppercase keys.\n */\nfunction createAdjustMap(values) {\n /** @type {Record} */\n const result = {}\n let index = -1\n\n while (++index < values.length) {\n result[values[index].toLowerCase()] = values[index]\n }\n\n return result\n}\n","export const svgCaseSensitiveTagNames = [\n 'altGlyph',\n 'altGlyphDef',\n 'altGlyphItem',\n 'animateColor',\n 'animateMotion',\n 'animateTransform',\n 'clipPath',\n 'feBlend',\n 'feColorMatrix',\n 'feComponentTransfer',\n 'feComposite',\n 'feConvolveMatrix',\n 'feDiffuseLighting',\n 'feDisplacementMap',\n 'feDistantLight',\n 'feDropShadow',\n 'feFlood',\n 'feFuncA',\n 'feFuncB',\n 'feFuncG',\n 'feFuncR',\n 'feGaussianBlur',\n 'feImage',\n 'feMerge',\n 'feMergeNode',\n 'feMorphology',\n 'feOffset',\n 'fePointLight',\n 'feSpecularLighting',\n 'feSpotLight',\n 'feTile',\n 'feTurbulence',\n 'foreignObject',\n 'glyphRef',\n 'linearGradient',\n 'radialGradient',\n 'solidColor',\n 'textArea',\n 'textPath'\n]\n","/**\n * @typedef {import('./create-h.js').Child} Child\n * Acceptable child value.\n * @typedef {import('./create-h.js').Properties} Properties\n * Acceptable value for element properties.\n * @typedef {import('./create-h.js').Result} Result\n * Result from a `h` (or `s`) call.\n */\n\n// Register the JSX namespace on `h`.\n/**\n * @typedef {import('./jsx-classic.js').Element} h.JSX.Element\n * @typedef {import('./jsx-classic.js').ElementChildrenAttribute} h.JSX.ElementChildrenAttribute\n * @typedef {import('./jsx-classic.js').IntrinsicAttributes} h.JSX.IntrinsicAttributes\n * @typedef {import('./jsx-classic.js').IntrinsicElements} h.JSX.IntrinsicElements\n */\n\n// Register the JSX namespace on `s`.\n/**\n * @typedef {import('./jsx-classic.js').Element} s.JSX.Element\n * @typedef {import('./jsx-classic.js').ElementChildrenAttribute} s.JSX.ElementChildrenAttribute\n * @typedef {import('./jsx-classic.js').IntrinsicAttributes} s.JSX.IntrinsicAttributes\n * @typedef {import('./jsx-classic.js').IntrinsicElements} s.JSX.IntrinsicElements\n */\n\nimport {html, svg} from 'property-information'\nimport {createH} from './create-h.js'\nimport {svgCaseSensitiveTagNames} from './svg-case-sensitive-tag-names.js'\n\n// Note: this explicit type is needed, otherwise TS creates broken types.\n/** @type {ReturnType} */\nexport const h = createH(html, 'div')\n\n// Note: this explicit type is needed, otherwise TS creates broken types.\n/** @type {ReturnType} */\nexport const s = createH(svg, 'g', svgCaseSensitiveTagNames)\n","/**\n * @typedef {import('vfile').VFile} VFile\n * @typedef {import('vfile').Value} Value\n * @typedef {import('unist').Point} UnistPoint\n */\n\n/**\n *\n * @typedef PointLike\n * unist point, allowed as input.\n * @property {number | null | undefined} [line]\n * Line.\n * @property {number | null | undefined} [column]\n * Column.\n * @property {number | null | undefined} [offset]\n * Offset.\n *\n * @callback ToPoint\n * Get the line/column based `Point` for `offset` in the bound indices.\n *\n * Returns `undefined` when given out of bounds input.\n *\n * Also implemented in Rust in [`wooorm/markdown-rs`][markdown-rs].\n *\n * [markdown-rs]: https://github.com/wooorm/markdown-rs/blob/main/src/util/location.rs\n * @param {number | null | undefined} [offset]\n * Something that should be an `offset.\n * @returns {UnistPoint | undefined}\n * Point, if `offset` is valid and in-bounds input.\n *\n * @callback ToOffset\n * Get the `offset` from a line/column based `Point` in the bound indices.\n * @param {PointLike | null | undefined} [point]\n * Something that should be a `point.\n * @returns {number | undefined}\n * Offset (`number`) or `undefined` for invalid or out of bounds input.\n *\n * @typedef Location\n * Accessors for index.\n * @property {ToPoint} toPoint\n * Get the line/column based `Point` for `offset` in the bound indices.\n * @property {ToOffset} toOffset\n * Get the `offset` from a line/column based `Point` in the bound indices.\n */\n\nconst search = /\\r?\\n|\\r/g\n\n/**\n * Create an index of the given document to translate between line/column and\n * offset based positional info.\n *\n * Also implemented in Rust in [`wooorm/markdown-rs`][markdown-rs].\n *\n * [markdown-rs]: https://github.com/wooorm/markdown-rs/blob/main/src/util/location.rs\n *\n * @param {VFile | Value} file\n * File to index.\n * @returns {Location}\n * Accessors for index.\n */\nexport function location(file) {\n const value = String(file)\n /**\n * List, where each index is a line number (0-based), and each value is the\n * byte index *after* where the line ends.\n *\n * @type {Array}\n */\n const indices = []\n\n search.lastIndex = 0\n\n while (search.test(value)) {\n indices.push(search.lastIndex)\n }\n\n indices.push(value.length + 1)\n\n return {toPoint, toOffset}\n\n /** @type {ToPoint} */\n function toPoint(offset) {\n let index = -1\n\n if (\n typeof offset === 'number' &&\n offset > -1 &&\n offset < indices[indices.length - 1]\n ) {\n while (++index < indices.length) {\n if (indices[index] > offset) {\n return {\n line: index + 1,\n column: offset - (index > 0 ? indices[index - 1] : 0) + 1,\n offset\n }\n }\n }\n }\n }\n\n /** @type {ToOffset} */\n function toOffset(point) {\n const line = point && point.line\n const column = point && point.column\n\n if (\n typeof line === 'number' &&\n typeof column === 'number' &&\n !Number.isNaN(line) &&\n !Number.isNaN(column) &&\n line - 1 in indices\n ) {\n const offset = (indices[line - 2] || 0) + column - 1 || 0\n\n if (offset > -1 && offset < indices[indices.length - 1]) {\n return offset\n }\n }\n }\n}\n","/**\n * Map of web namespaces.\n *\n * @type {Record}\n */\nexport const webNamespaces = {\n html: 'http://www.w3.org/1999/xhtml',\n mathml: 'http://www.w3.org/1998/Math/MathML',\n svg: 'http://www.w3.org/2000/svg',\n xlink: 'http://www.w3.org/1999/xlink',\n xml: 'http://www.w3.org/XML/1998/namespace',\n xmlns: 'http://www.w3.org/2000/xmlns/'\n}\n","/**\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').ElementData} ElementData\n * @typedef {import('hast').Nodes} Nodes\n * @typedef {import('hast').Root} Root\n * @typedef {import('hast').RootContent} RootContent\n *\n * @typedef {import('parse5').DefaultTreeAdapterMap} DefaultTreeAdapterMap\n * @typedef {import('parse5').Token.ElementLocation} P5ElementLocation\n * @typedef {import('parse5').Token.Location} P5Location\n *\n * @typedef {import('property-information').Schema} Schema\n *\n * @typedef {import('unist').Point} Point\n * @typedef {import('unist').Position} Position\n *\n * @typedef {import('vfile').VFile} VFile\n */\n\n/**\n * @typedef {DefaultTreeAdapterMap['document']} P5Document\n * @typedef {DefaultTreeAdapterMap['documentFragment']} P5DocumentFragment\n * @typedef {DefaultTreeAdapterMap['documentType']} P5DocumentType\n * @typedef {DefaultTreeAdapterMap['commentNode']} P5Comment\n * @typedef {DefaultTreeAdapterMap['textNode']} P5Text\n * @typedef {DefaultTreeAdapterMap['element']} P5Element\n * @typedef {DefaultTreeAdapterMap['node']} P5Node\n * @typedef {DefaultTreeAdapterMap['template']} P5Template\n */\n\n/**\n * @typedef Options\n * Configuration.\n * @property {Space | null | undefined} [space='html']\n * Which space the document is in (default: `'html'`).\n *\n * When an `` element is found in the HTML space, this package already\n * automatically switches to and from the SVG space when entering and exiting\n * it.\n * @property {VFile | null | undefined} [file]\n * File used to add positional info to nodes (optional).\n *\n * If given, the file should represent the original HTML source.\n * @property {boolean | null | undefined} [verbose=false]\n * Whether to add extra positional info about starting tags, closing tags,\n * and attributes to elements (default: `false`).\n *\n * > 👉 **Note**: only used when `file` is given.\n *\n * @typedef {'html' | 'svg'} Space\n * Namespace.\n *\n * @typedef State\n * Info passed around about the current state.\n * @property {VFile | undefined} file\n * Corresponding file.\n * @property {boolean} location\n * Whether location info was found.\n * @property {Schema} schema\n * Current schema.\n * @property {boolean | undefined} verbose\n * Add extra positional info.\n */\n\nimport {ok as assert} from 'devlop'\nimport {h, s} from 'hastscript'\nimport {find, html, svg} from 'property-information'\nimport {location} from 'vfile-location'\nimport {webNamespaces} from 'web-namespaces'\n\nconst own = {}.hasOwnProperty\n/** @type {unknown} */\n// type-coverage:ignore-next-line\nconst proto = Object.prototype\n\n/**\n * Transform a `parse5` AST to hast.\n *\n * @param {P5Node} tree\n * `parse5` tree to transform.\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {Nodes}\n * hast tree.\n */\nexport function fromParse5(tree, options) {\n const settings = options || {}\n\n return one(\n {\n file: settings.file || undefined,\n location: false,\n schema: settings.space === 'svg' ? svg : html,\n verbose: settings.verbose || false\n },\n tree\n )\n}\n\n/**\n * Transform a node.\n *\n * @param {State} state\n * Info passed around about the current state.\n * @param {P5Node} node\n * p5 node.\n * @returns {Nodes}\n * hast node.\n */\nfunction one(state, node) {\n /** @type {Nodes} */\n let result\n\n switch (node.nodeName) {\n case '#comment': {\n const reference = /** @type {P5Comment} */ (node)\n result = {type: 'comment', value: reference.data}\n patch(state, reference, result)\n return result\n }\n\n case '#document':\n case '#document-fragment': {\n const reference = /** @type {P5Document | P5DocumentFragment} */ (node)\n const quirksMode =\n 'mode' in reference\n ? reference.mode === 'quirks' || reference.mode === 'limited-quirks'\n : false\n\n result = {\n type: 'root',\n children: all(state, node.childNodes),\n data: {quirksMode}\n }\n\n if (state.file && state.location) {\n const doc = String(state.file)\n const loc = location(doc)\n const start = loc.toPoint(0)\n const end = loc.toPoint(doc.length)\n // Always defined as we give valid input.\n assert(start, 'expected `start`')\n assert(end, 'expected `end`')\n result.position = {start, end}\n }\n\n return result\n }\n\n case '#documentType': {\n const reference = /** @type {P5DocumentType} */ (node)\n result = {type: 'doctype'}\n patch(state, reference, result)\n return result\n }\n\n case '#text': {\n const reference = /** @type {P5Text} */ (node)\n result = {type: 'text', value: reference.value}\n patch(state, reference, result)\n return result\n }\n\n // Element.\n default: {\n const reference = /** @type {P5Element} */ (node)\n result = element(state, reference)\n return result\n }\n }\n}\n\n/**\n * Transform children.\n *\n * @param {State} state\n * Info passed around about the current state.\n * @param {Array} nodes\n * Nodes.\n * @returns {Array}\n * hast nodes.\n */\nfunction all(state, nodes) {\n let index = -1\n /** @type {Array} */\n const results = []\n\n while (++index < nodes.length) {\n // Assume no roots in `nodes`.\n const result = /** @type {RootContent} */ (one(state, nodes[index]))\n results.push(result)\n }\n\n return results\n}\n\n/**\n * Transform an element.\n *\n * @param {State} state\n * Info passed around about the current state.\n * @param {P5Element} node\n * `parse5` node to transform.\n * @returns {Element}\n * hast node.\n */\nfunction element(state, node) {\n const schema = state.schema\n\n state.schema = node.namespaceURI === webNamespaces.svg ? svg : html\n\n // Props.\n let index = -1\n /** @type {Record} */\n const props = {}\n\n while (++index < node.attrs.length) {\n const attribute = node.attrs[index]\n const name =\n (attribute.prefix ? attribute.prefix + ':' : '') + attribute.name\n if (!own.call(proto, name)) {\n props[name] = attribute.value\n }\n }\n\n // Build.\n const fn = state.schema.space === 'svg' ? s : h\n const result = fn(node.tagName, props, all(state, node.childNodes))\n patch(state, node, result)\n\n // Switch content.\n if (result.tagName === 'template') {\n const reference = /** @type {P5Template} */ (node)\n const pos = reference.sourceCodeLocation\n const startTag = pos && pos.startTag && position(pos.startTag)\n const endTag = pos && pos.endTag && position(pos.endTag)\n\n // Root in, root out.\n const content = /** @type {Root} */ (one(state, reference.content))\n\n if (startTag && endTag && state.file) {\n content.position = {start: startTag.end, end: endTag.start}\n }\n\n result.content = content\n }\n\n state.schema = schema\n\n return result\n}\n\n/**\n * Patch positional info from `from` onto `to`.\n *\n * @param {State} state\n * Info passed around about the current state.\n * @param {P5Node} from\n * p5 node.\n * @param {Nodes} to\n * hast node.\n * @returns {undefined}\n * Nothing.\n */\nfunction patch(state, from, to) {\n if ('sourceCodeLocation' in from && from.sourceCodeLocation && state.file) {\n const position = createLocation(state, to, from.sourceCodeLocation)\n\n if (position) {\n state.location = true\n to.position = position\n }\n }\n}\n\n/**\n * Create clean positional information.\n *\n * @param {State} state\n * Info passed around about the current state.\n * @param {Nodes} node\n * hast node.\n * @param {P5ElementLocation} location\n * p5 location info.\n * @returns {Position | undefined}\n * Position, or nothing.\n */\nfunction createLocation(state, node, location) {\n const result = position(location)\n\n if (node.type === 'element') {\n const tail = node.children[node.children.length - 1]\n\n // Bug for unclosed with children.\n // See: .\n if (\n result &&\n !location.endTag &&\n tail &&\n tail.position &&\n tail.position.end\n ) {\n result.end = Object.assign({}, tail.position.end)\n }\n\n if (state.verbose) {\n /** @type {Record} */\n const props = {}\n /** @type {string} */\n let key\n\n if (location.attrs) {\n for (key in location.attrs) {\n if (own.call(location.attrs, key)) {\n props[find(state.schema, key).property] = position(\n location.attrs[key]\n )\n }\n }\n }\n\n assert(location.startTag, 'a start tag should exist')\n const opening = position(location.startTag)\n const closing = location.endTag ? position(location.endTag) : undefined\n /** @type {ElementData['position']} */\n const data = {opening}\n if (closing) data.closing = closing\n data.properties = props\n\n node.data = {position: data}\n }\n }\n\n return result\n}\n\n/**\n * Turn a p5 location into a position.\n *\n * @param {P5Location} loc\n * Location.\n * @returns {Position | undefined}\n * Position or nothing.\n */\nfunction position(loc) {\n const start = point({\n line: loc.startLine,\n column: loc.startCol,\n offset: loc.startOffset\n })\n const end = point({\n line: loc.endLine,\n column: loc.endCol,\n offset: loc.endOffset\n })\n\n // @ts-expect-error: we do use `undefined` for points if one or the other\n // exists.\n return start || end ? {start, end} : undefined\n}\n\n/**\n * Filter out invalid points.\n *\n * @param {Point} point\n * Point with potentially `undefined` values.\n * @returns {Point | undefined}\n * Point or nothing.\n */\nfunction point(point) {\n return point.line && point.column ? point : undefined\n}\n","/**\n * @callback Handler\n * Handle a value, with a certain ID field set to a certain value.\n * The ID field is passed to `zwitch`, and it’s value is this function’s\n * place on the `handlers` record.\n * @param {...any} parameters\n * Arbitrary parameters passed to the zwitch.\n * The first will be an object with a certain ID field set to a certain value.\n * @returns {any}\n * Anything!\n */\n\n/**\n * @callback UnknownHandler\n * Handle values that do have a certain ID field, but it’s set to a value\n * that is not listed in the `handlers` record.\n * @param {unknown} value\n * An object with a certain ID field set to an unknown value.\n * @param {...any} rest\n * Arbitrary parameters passed to the zwitch.\n * @returns {any}\n * Anything!\n */\n\n/**\n * @callback InvalidHandler\n * Handle values that do not have a certain ID field.\n * @param {unknown} value\n * Any unknown value.\n * @param {...any} rest\n * Arbitrary parameters passed to the zwitch.\n * @returns {void|null|undefined|never}\n * This should crash or return nothing.\n */\n\n/**\n * @template {InvalidHandler} [Invalid=InvalidHandler]\n * @template {UnknownHandler} [Unknown=UnknownHandler]\n * @template {Record} [Handlers=Record]\n * @typedef Options\n * Configuration (required).\n * @property {Invalid} [invalid]\n * Handler to use for invalid values.\n * @property {Unknown} [unknown]\n * Handler to use for unknown values.\n * @property {Handlers} [handlers]\n * Handlers to use.\n */\n\nconst own = {}.hasOwnProperty\n\n/**\n * Handle values based on a field.\n *\n * @template {InvalidHandler} [Invalid=InvalidHandler]\n * @template {UnknownHandler} [Unknown=UnknownHandler]\n * @template {Record} [Handlers=Record]\n * @param {string} key\n * Field to switch on.\n * @param {Options} [options]\n * Configuration (required).\n * @returns {{unknown: Unknown, invalid: Invalid, handlers: Handlers, (...parameters: Parameters): ReturnType, (...parameters: Parameters): ReturnType}}\n */\nexport function zwitch(key, options) {\n const settings = options || {}\n\n /**\n * Handle one value.\n *\n * Based on the bound `key`, a respective handler will be called.\n * If `value` is not an object, or doesn’t have a `key` property, the special\n * “invalid” handler will be called.\n * If `value` has an unknown `key`, the special “unknown” handler will be\n * called.\n *\n * All arguments, and the context object, are passed through to the handler,\n * and it’s result is returned.\n *\n * @this {unknown}\n * Any context object.\n * @param {unknown} [value]\n * Any value.\n * @param {...unknown} parameters\n * Arbitrary parameters passed to the zwitch.\n * @property {Handler} invalid\n * Handle for values that do not have a certain ID field.\n * @property {Handler} unknown\n * Handle values that do have a certain ID field, but it’s set to a value\n * that is not listed in the `handlers` record.\n * @property {Handlers} handlers\n * Record of handlers.\n * @returns {unknown}\n * Anything.\n */\n function one(value, ...parameters) {\n /** @type {Handler|undefined} */\n let fn = one.invalid\n const handlers = one.handlers\n\n if (value && own.call(value, key)) {\n // @ts-expect-error Indexable.\n const id = String(value[key])\n // @ts-expect-error Indexable.\n fn = own.call(handlers, id) ? handlers[id] : one.unknown\n }\n\n if (fn) {\n return fn.call(this, value, ...parameters)\n }\n }\n\n one.handlers = settings.handlers || {}\n one.invalid = settings.invalid\n one.unknown = settings.unknown\n\n // @ts-expect-error: matches!\n return one\n}\n","/**\n * @typedef {import('hast').Comment} Comment\n * @typedef {import('hast').Doctype} Doctype\n * @typedef {import('hast').Element} Element\n * @typedef {import('hast').Nodes} Nodes\n * @typedef {import('hast').Root} Root\n * @typedef {import('hast').RootContent} RootContent\n * @typedef {import('hast').Text} Text\n *\n * @typedef {import('parse5').DefaultTreeAdapterMap['document']} Parse5Document\n * @typedef {import('parse5').DefaultTreeAdapterMap['documentFragment']} Parse5Fragment\n * @typedef {import('parse5').DefaultTreeAdapterMap['element']} Parse5Element\n * @typedef {import('parse5').DefaultTreeAdapterMap['node']} Parse5Nodes\n * @typedef {import('parse5').DefaultTreeAdapterMap['documentType']} Parse5Doctype\n * @typedef {import('parse5').DefaultTreeAdapterMap['commentNode']} Parse5Comment\n * @typedef {import('parse5').DefaultTreeAdapterMap['textNode']} Parse5Text\n * @typedef {import('parse5').DefaultTreeAdapterMap['parentNode']} Parse5Parent\n * @typedef {import('parse5').Token.Attribute} Parse5Attribute\n *\n * @typedef {import('property-information').Schema} Schema\n */\n\n/**\n * @typedef Options\n * Configuration.\n * @property {Space | null | undefined} [space='html']\n * Which space the document is in (default: `'html'`).\n *\n * When an `` element is found in the HTML space, this package already\n * automatically switches to and from the SVG space when entering and exiting\n * it.\n *\n * @typedef {Exclude} Parse5Content\n *\n * @typedef {'html' | 'svg'} Space\n */\n\nimport {stringify as commas} from 'comma-separated-tokens'\nimport {ok as assert} from 'devlop'\nimport {find, html, svg} from 'property-information'\nimport {stringify as spaces} from 'space-separated-tokens'\nimport {webNamespaces} from 'web-namespaces'\nimport {zwitch} from 'zwitch'\n\n/** @type {Options} */\nconst emptyOptions = {}\n\nconst own = {}.hasOwnProperty\n\nconst one = zwitch('type', {handlers: {root, element, text, comment, doctype}})\n\n/**\n * Transform a hast tree to a `parse5` AST.\n *\n * @param {Nodes} tree\n * Tree to transform.\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {Parse5Nodes}\n * `parse5` node.\n */\nexport function toParse5(tree, options) {\n const settings = options || emptyOptions\n const space = settings.space\n return one(tree, space === 'svg' ? svg : html)\n}\n\n/**\n * @param {Root} node\n * Node (hast) to transform.\n * @param {Schema} schema\n * Current schema.\n * @returns {Parse5Document}\n * Parse5 node.\n */\nfunction root(node, schema) {\n /** @type {Parse5Document} */\n const result = {\n nodeName: '#document',\n // @ts-expect-error: `parse5` uses enums, which are actually strings.\n mode: (node.data || {}).quirksMode ? 'quirks' : 'no-quirks',\n childNodes: []\n }\n result.childNodes = all(node.children, result, schema)\n patch(node, result)\n return result\n}\n\n/**\n * @param {Root} node\n * Node (hast) to transform.\n * @param {Schema} schema\n * Current schema.\n * @returns {Parse5Fragment}\n * Parse5 node.\n */\nfunction fragment(node, schema) {\n /** @type {Parse5Fragment} */\n const result = {nodeName: '#document-fragment', childNodes: []}\n result.childNodes = all(node.children, result, schema)\n patch(node, result)\n return result\n}\n\n/**\n * @param {Doctype} node\n * Node (hast) to transform.\n * @returns {Parse5Doctype}\n * Parse5 node.\n */\nfunction doctype(node) {\n /** @type {Parse5Doctype} */\n const result = {\n nodeName: '#documentType',\n name: 'html',\n publicId: '',\n systemId: '',\n parentNode: null\n }\n\n patch(node, result)\n return result\n}\n\n/**\n * @param {Text} node\n * Node (hast) to transform.\n * @returns {Parse5Text}\n * Parse5 node.\n */\nfunction text(node) {\n /** @type {Parse5Text} */\n const result = {\n nodeName: '#text',\n value: node.value,\n parentNode: null\n }\n patch(node, result)\n return result\n}\n\n/**\n * @param {Comment} node\n * Node (hast) to transform.\n * @returns {Parse5Comment}\n * Parse5 node.\n */\nfunction comment(node) {\n /** @type {Parse5Comment} */\n const result = {\n nodeName: '#comment',\n data: node.value,\n parentNode: null\n }\n\n patch(node, result)\n\n return result\n}\n\n/**\n * @param {Element} node\n * Node (hast) to transform.\n * @param {Schema} schema\n * Current schema.\n * @returns {Parse5Element}\n * Parse5 node.\n */\nfunction element(node, schema) {\n const parentSchema = schema\n let currentSchema = parentSchema\n\n if (\n node.type === 'element' &&\n node.tagName.toLowerCase() === 'svg' &&\n parentSchema.space === 'html'\n ) {\n currentSchema = svg\n }\n\n /** @type {Array} */\n const attrs = []\n /** @type {string} */\n let prop\n\n if (node.properties) {\n for (prop in node.properties) {\n if (prop !== 'children' && own.call(node.properties, prop)) {\n const result = createProperty(\n currentSchema,\n prop,\n node.properties[prop]\n )\n\n if (result) {\n attrs.push(result)\n }\n }\n }\n }\n\n const space = currentSchema.space\n // `html` and `svg` both have a space.\n assert(space)\n\n /** @type {Parse5Element} */\n const result = {\n nodeName: node.tagName,\n tagName: node.tagName,\n attrs,\n // @ts-expect-error: `parse5` types are wrong.\n namespaceURI: webNamespaces[space],\n childNodes: [],\n parentNode: null\n }\n result.childNodes = all(node.children, result, currentSchema)\n patch(node, result)\n\n if (node.tagName === 'template' && node.content) {\n // @ts-expect-error: `parse5` types are wrong.\n result.content = fragment(node.content, currentSchema)\n }\n\n return result\n}\n\n/**\n * Handle a property.\n *\n * @param {Schema} schema\n * Current schema.\n * @param {string} prop\n * Key.\n * @param {Array | boolean | number | string | null | undefined} value\n * hast property value.\n * @returns {Parse5Attribute | undefined}\n * Field for runtime, optional.\n */\nfunction createProperty(schema, prop, value) {\n const info = find(schema, prop)\n\n // Ignore nullish and `NaN` values.\n if (\n value === false ||\n value === null ||\n value === undefined ||\n (typeof value === 'number' && Number.isNaN(value)) ||\n (!value && info.boolean)\n ) {\n return\n }\n\n if (Array.isArray(value)) {\n // Accept `array`.\n // Most props are space-separated.\n value = info.commaSeparated ? commas(value) : spaces(value)\n }\n\n /** @type {Parse5Attribute} */\n const attribute = {\n name: info.attribute,\n value: value === true ? '' : String(value)\n }\n\n if (info.space && info.space !== 'html' && info.space !== 'svg') {\n const index = attribute.name.indexOf(':')\n\n if (index < 0) {\n attribute.prefix = ''\n } else {\n attribute.name = attribute.name.slice(index + 1)\n attribute.prefix = info.attribute.slice(0, index)\n }\n\n attribute.namespace = webNamespaces[info.space]\n }\n\n return attribute\n}\n\n/**\n * Transform all hast nodes.\n *\n * @param {Array} children\n * List of children.\n * @param {Parse5Parent} parentNode\n * `parse5` parent node.\n * @param {Schema} schema\n * Current schema.\n * @returns {Array}\n * Transformed children.\n */\nfunction all(children, parentNode, schema) {\n let index = -1\n /** @type {Array} */\n const results = []\n\n if (children) {\n while (++index < children.length) {\n /** @type {Parse5Content} */\n const child = one(children[index], schema)\n\n child.parentNode = parentNode\n\n results.push(child)\n }\n }\n\n return results\n}\n\n/**\n * Add position info from `from` to `to`.\n *\n * @param {Nodes} from\n * hast node.\n * @param {Parse5Nodes} to\n * `parse5` node.\n * @returns {undefined}\n * Nothing.\n */\nfunction patch(from, to) {\n const position = from.position\n\n if (position && position.start && position.end) {\n assert(typeof position.start.offset === 'number')\n assert(typeof position.end.offset === 'number')\n\n to.sourceCodeLocation = {\n startLine: position.start.line,\n startCol: position.start.column,\n startOffset: position.start.offset,\n endLine: position.end.line,\n endCol: position.end.column,\n endOffset: position.end.offset\n }\n }\n}\n","/**\n * List of HTML void tag names.\n *\n * @type {Array}\n */\nexport const htmlVoidElements = [\n 'area',\n 'base',\n 'basefont',\n 'bgsound',\n 'br',\n 'col',\n 'command',\n 'embed',\n 'frame',\n 'hr',\n 'image',\n 'img',\n 'input',\n 'keygen',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr'\n]\n","const UNDEFINED_CODE_POINTS = new Set([\n 65534, 65535, 131070, 131071, 196606, 196607, 262142, 262143, 327678, 327679, 393214,\n 393215, 458750, 458751, 524286, 524287, 589822, 589823, 655358, 655359, 720894,\n 720895, 786430, 786431, 851966, 851967, 917502, 917503, 983038, 983039, 1048574,\n 1048575, 1114110, 1114111,\n]);\nexport const REPLACEMENT_CHARACTER = '\\uFFFD';\nexport var CODE_POINTS;\n(function (CODE_POINTS) {\n CODE_POINTS[CODE_POINTS[\"EOF\"] = -1] = \"EOF\";\n CODE_POINTS[CODE_POINTS[\"NULL\"] = 0] = \"NULL\";\n CODE_POINTS[CODE_POINTS[\"TABULATION\"] = 9] = \"TABULATION\";\n CODE_POINTS[CODE_POINTS[\"CARRIAGE_RETURN\"] = 13] = \"CARRIAGE_RETURN\";\n CODE_POINTS[CODE_POINTS[\"LINE_FEED\"] = 10] = \"LINE_FEED\";\n CODE_POINTS[CODE_POINTS[\"FORM_FEED\"] = 12] = \"FORM_FEED\";\n CODE_POINTS[CODE_POINTS[\"SPACE\"] = 32] = \"SPACE\";\n CODE_POINTS[CODE_POINTS[\"EXCLAMATION_MARK\"] = 33] = \"EXCLAMATION_MARK\";\n CODE_POINTS[CODE_POINTS[\"QUOTATION_MARK\"] = 34] = \"QUOTATION_MARK\";\n CODE_POINTS[CODE_POINTS[\"NUMBER_SIGN\"] = 35] = \"NUMBER_SIGN\";\n CODE_POINTS[CODE_POINTS[\"AMPERSAND\"] = 38] = \"AMPERSAND\";\n CODE_POINTS[CODE_POINTS[\"APOSTROPHE\"] = 39] = \"APOSTROPHE\";\n CODE_POINTS[CODE_POINTS[\"HYPHEN_MINUS\"] = 45] = \"HYPHEN_MINUS\";\n CODE_POINTS[CODE_POINTS[\"SOLIDUS\"] = 47] = \"SOLIDUS\";\n CODE_POINTS[CODE_POINTS[\"DIGIT_0\"] = 48] = \"DIGIT_0\";\n CODE_POINTS[CODE_POINTS[\"DIGIT_9\"] = 57] = \"DIGIT_9\";\n CODE_POINTS[CODE_POINTS[\"SEMICOLON\"] = 59] = \"SEMICOLON\";\n CODE_POINTS[CODE_POINTS[\"LESS_THAN_SIGN\"] = 60] = \"LESS_THAN_SIGN\";\n CODE_POINTS[CODE_POINTS[\"EQUALS_SIGN\"] = 61] = \"EQUALS_SIGN\";\n CODE_POINTS[CODE_POINTS[\"GREATER_THAN_SIGN\"] = 62] = \"GREATER_THAN_SIGN\";\n CODE_POINTS[CODE_POINTS[\"QUESTION_MARK\"] = 63] = \"QUESTION_MARK\";\n CODE_POINTS[CODE_POINTS[\"LATIN_CAPITAL_A\"] = 65] = \"LATIN_CAPITAL_A\";\n CODE_POINTS[CODE_POINTS[\"LATIN_CAPITAL_F\"] = 70] = \"LATIN_CAPITAL_F\";\n CODE_POINTS[CODE_POINTS[\"LATIN_CAPITAL_X\"] = 88] = \"LATIN_CAPITAL_X\";\n CODE_POINTS[CODE_POINTS[\"LATIN_CAPITAL_Z\"] = 90] = \"LATIN_CAPITAL_Z\";\n CODE_POINTS[CODE_POINTS[\"RIGHT_SQUARE_BRACKET\"] = 93] = \"RIGHT_SQUARE_BRACKET\";\n CODE_POINTS[CODE_POINTS[\"GRAVE_ACCENT\"] = 96] = \"GRAVE_ACCENT\";\n CODE_POINTS[CODE_POINTS[\"LATIN_SMALL_A\"] = 97] = \"LATIN_SMALL_A\";\n CODE_POINTS[CODE_POINTS[\"LATIN_SMALL_F\"] = 102] = \"LATIN_SMALL_F\";\n CODE_POINTS[CODE_POINTS[\"LATIN_SMALL_X\"] = 120] = \"LATIN_SMALL_X\";\n CODE_POINTS[CODE_POINTS[\"LATIN_SMALL_Z\"] = 122] = \"LATIN_SMALL_Z\";\n CODE_POINTS[CODE_POINTS[\"REPLACEMENT_CHARACTER\"] = 65533] = \"REPLACEMENT_CHARACTER\";\n})(CODE_POINTS = CODE_POINTS || (CODE_POINTS = {}));\nexport const SEQUENCES = {\n DASH_DASH: '--',\n CDATA_START: '[CDATA[',\n DOCTYPE: 'doctype',\n SCRIPT: 'script',\n PUBLIC: 'public',\n SYSTEM: 'system',\n};\n//Surrogates\nexport function isSurrogate(cp) {\n return cp >= 55296 && cp <= 57343;\n}\nexport function isSurrogatePair(cp) {\n return cp >= 56320 && cp <= 57343;\n}\nexport function getSurrogatePairCodePoint(cp1, cp2) {\n return (cp1 - 55296) * 1024 + 9216 + cp2;\n}\n//NOTE: excluding NULL and ASCII whitespace\nexport function isControlCodePoint(cp) {\n return ((cp !== 0x20 && cp !== 0x0a && cp !== 0x0d && cp !== 0x09 && cp !== 0x0c && cp >= 0x01 && cp <= 0x1f) ||\n (cp >= 0x7f && cp <= 0x9f));\n}\nexport function isUndefinedCodePoint(cp) {\n return (cp >= 64976 && cp <= 65007) || UNDEFINED_CODE_POINTS.has(cp);\n}\n//# sourceMappingURL=unicode.js.map","export var ERR;\n(function (ERR) {\n ERR[\"controlCharacterInInputStream\"] = \"control-character-in-input-stream\";\n ERR[\"noncharacterInInputStream\"] = \"noncharacter-in-input-stream\";\n ERR[\"surrogateInInputStream\"] = \"surrogate-in-input-stream\";\n ERR[\"nonVoidHtmlElementStartTagWithTrailingSolidus\"] = \"non-void-html-element-start-tag-with-trailing-solidus\";\n ERR[\"endTagWithAttributes\"] = \"end-tag-with-attributes\";\n ERR[\"endTagWithTrailingSolidus\"] = \"end-tag-with-trailing-solidus\";\n ERR[\"unexpectedSolidusInTag\"] = \"unexpected-solidus-in-tag\";\n ERR[\"unexpectedNullCharacter\"] = \"unexpected-null-character\";\n ERR[\"unexpectedQuestionMarkInsteadOfTagName\"] = \"unexpected-question-mark-instead-of-tag-name\";\n ERR[\"invalidFirstCharacterOfTagName\"] = \"invalid-first-character-of-tag-name\";\n ERR[\"unexpectedEqualsSignBeforeAttributeName\"] = \"unexpected-equals-sign-before-attribute-name\";\n ERR[\"missingEndTagName\"] = \"missing-end-tag-name\";\n ERR[\"unexpectedCharacterInAttributeName\"] = \"unexpected-character-in-attribute-name\";\n ERR[\"unknownNamedCharacterReference\"] = \"unknown-named-character-reference\";\n ERR[\"missingSemicolonAfterCharacterReference\"] = \"missing-semicolon-after-character-reference\";\n ERR[\"unexpectedCharacterAfterDoctypeSystemIdentifier\"] = \"unexpected-character-after-doctype-system-identifier\";\n ERR[\"unexpectedCharacterInUnquotedAttributeValue\"] = \"unexpected-character-in-unquoted-attribute-value\";\n ERR[\"eofBeforeTagName\"] = \"eof-before-tag-name\";\n ERR[\"eofInTag\"] = \"eof-in-tag\";\n ERR[\"missingAttributeValue\"] = \"missing-attribute-value\";\n ERR[\"missingWhitespaceBetweenAttributes\"] = \"missing-whitespace-between-attributes\";\n ERR[\"missingWhitespaceAfterDoctypePublicKeyword\"] = \"missing-whitespace-after-doctype-public-keyword\";\n ERR[\"missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers\"] = \"missing-whitespace-between-doctype-public-and-system-identifiers\";\n ERR[\"missingWhitespaceAfterDoctypeSystemKeyword\"] = \"missing-whitespace-after-doctype-system-keyword\";\n ERR[\"missingQuoteBeforeDoctypePublicIdentifier\"] = \"missing-quote-before-doctype-public-identifier\";\n ERR[\"missingQuoteBeforeDoctypeSystemIdentifier\"] = \"missing-quote-before-doctype-system-identifier\";\n ERR[\"missingDoctypePublicIdentifier\"] = \"missing-doctype-public-identifier\";\n ERR[\"missingDoctypeSystemIdentifier\"] = \"missing-doctype-system-identifier\";\n ERR[\"abruptDoctypePublicIdentifier\"] = \"abrupt-doctype-public-identifier\";\n ERR[\"abruptDoctypeSystemIdentifier\"] = \"abrupt-doctype-system-identifier\";\n ERR[\"cdataInHtmlContent\"] = \"cdata-in-html-content\";\n ERR[\"incorrectlyOpenedComment\"] = \"incorrectly-opened-comment\";\n ERR[\"eofInScriptHtmlCommentLikeText\"] = \"eof-in-script-html-comment-like-text\";\n ERR[\"eofInDoctype\"] = \"eof-in-doctype\";\n ERR[\"nestedComment\"] = \"nested-comment\";\n ERR[\"abruptClosingOfEmptyComment\"] = \"abrupt-closing-of-empty-comment\";\n ERR[\"eofInComment\"] = \"eof-in-comment\";\n ERR[\"incorrectlyClosedComment\"] = \"incorrectly-closed-comment\";\n ERR[\"eofInCdata\"] = \"eof-in-cdata\";\n ERR[\"absenceOfDigitsInNumericCharacterReference\"] = \"absence-of-digits-in-numeric-character-reference\";\n ERR[\"nullCharacterReference\"] = \"null-character-reference\";\n ERR[\"surrogateCharacterReference\"] = \"surrogate-character-reference\";\n ERR[\"characterReferenceOutsideUnicodeRange\"] = \"character-reference-outside-unicode-range\";\n ERR[\"controlCharacterReference\"] = \"control-character-reference\";\n ERR[\"noncharacterCharacterReference\"] = \"noncharacter-character-reference\";\n ERR[\"missingWhitespaceBeforeDoctypeName\"] = \"missing-whitespace-before-doctype-name\";\n ERR[\"missingDoctypeName\"] = \"missing-doctype-name\";\n ERR[\"invalidCharacterSequenceAfterDoctypeName\"] = \"invalid-character-sequence-after-doctype-name\";\n ERR[\"duplicateAttribute\"] = \"duplicate-attribute\";\n ERR[\"nonConformingDoctype\"] = \"non-conforming-doctype\";\n ERR[\"missingDoctype\"] = \"missing-doctype\";\n ERR[\"misplacedDoctype\"] = \"misplaced-doctype\";\n ERR[\"endTagWithoutMatchingOpenElement\"] = \"end-tag-without-matching-open-element\";\n ERR[\"closingOfElementWithOpenChildElements\"] = \"closing-of-element-with-open-child-elements\";\n ERR[\"disallowedContentInNoscriptInHead\"] = \"disallowed-content-in-noscript-in-head\";\n ERR[\"openElementsLeftAfterEof\"] = \"open-elements-left-after-eof\";\n ERR[\"abandonedHeadElementChild\"] = \"abandoned-head-element-child\";\n ERR[\"misplacedStartTagForHeadElement\"] = \"misplaced-start-tag-for-head-element\";\n ERR[\"nestedNoscriptInHead\"] = \"nested-noscript-in-head\";\n ERR[\"eofInElementThatCanContainOnlyText\"] = \"eof-in-element-that-can-contain-only-text\";\n})(ERR = ERR || (ERR = {}));\n//# sourceMappingURL=error-codes.js.map","import { CODE_POINTS as $, getSurrogatePairCodePoint, isControlCodePoint, isSurrogate, isSurrogatePair, isUndefinedCodePoint, } from '../common/unicode.js';\nimport { ERR } from '../common/error-codes.js';\n//Const\nconst DEFAULT_BUFFER_WATERLINE = 1 << 16;\n//Preprocessor\n//NOTE: HTML input preprocessing\n//(see: http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#preprocessing-the-input-stream)\nexport class Preprocessor {\n constructor(handler) {\n this.handler = handler;\n this.html = '';\n this.pos = -1;\n // NOTE: Initial `lastGapPos` is -2, to ensure `col` on initialisation is 0\n this.lastGapPos = -2;\n this.gapStack = [];\n this.skipNextNewLine = false;\n this.lastChunkWritten = false;\n this.endOfChunkHit = false;\n this.bufferWaterline = DEFAULT_BUFFER_WATERLINE;\n this.isEol = false;\n this.lineStartPos = 0;\n this.droppedBufferSize = 0;\n this.line = 1;\n //NOTE: avoid reporting errors twice on advance/retreat\n this.lastErrOffset = -1;\n }\n /** The column on the current line. If we just saw a gap (eg. a surrogate pair), return the index before. */\n get col() {\n return this.pos - this.lineStartPos + Number(this.lastGapPos !== this.pos);\n }\n get offset() {\n return this.droppedBufferSize + this.pos;\n }\n getError(code) {\n const { line, col, offset } = this;\n return {\n code,\n startLine: line,\n endLine: line,\n startCol: col,\n endCol: col,\n startOffset: offset,\n endOffset: offset,\n };\n }\n _err(code) {\n if (this.handler.onParseError && this.lastErrOffset !== this.offset) {\n this.lastErrOffset = this.offset;\n this.handler.onParseError(this.getError(code));\n }\n }\n _addGap() {\n this.gapStack.push(this.lastGapPos);\n this.lastGapPos = this.pos;\n }\n _processSurrogate(cp) {\n //NOTE: try to peek a surrogate pair\n if (this.pos !== this.html.length - 1) {\n const nextCp = this.html.charCodeAt(this.pos + 1);\n if (isSurrogatePair(nextCp)) {\n //NOTE: we have a surrogate pair. Peek pair character and recalculate code point.\n this.pos++;\n //NOTE: add a gap that should be avoided during retreat\n this._addGap();\n return getSurrogatePairCodePoint(cp, nextCp);\n }\n }\n //NOTE: we are at the end of a chunk, therefore we can't infer the surrogate pair yet.\n else if (!this.lastChunkWritten) {\n this.endOfChunkHit = true;\n return $.EOF;\n }\n //NOTE: isolated surrogate\n this._err(ERR.surrogateInInputStream);\n return cp;\n }\n willDropParsedChunk() {\n return this.pos > this.bufferWaterline;\n }\n dropParsedChunk() {\n if (this.willDropParsedChunk()) {\n this.html = this.html.substring(this.pos);\n this.lineStartPos -= this.pos;\n this.droppedBufferSize += this.pos;\n this.pos = 0;\n this.lastGapPos = -2;\n this.gapStack.length = 0;\n }\n }\n write(chunk, isLastChunk) {\n if (this.html.length > 0) {\n this.html += chunk;\n }\n else {\n this.html = chunk;\n }\n this.endOfChunkHit = false;\n this.lastChunkWritten = isLastChunk;\n }\n insertHtmlAtCurrentPos(chunk) {\n this.html = this.html.substring(0, this.pos + 1) + chunk + this.html.substring(this.pos + 1);\n this.endOfChunkHit = false;\n }\n startsWith(pattern, caseSensitive) {\n // Check if our buffer has enough characters\n if (this.pos + pattern.length > this.html.length) {\n this.endOfChunkHit = !this.lastChunkWritten;\n return false;\n }\n if (caseSensitive) {\n return this.html.startsWith(pattern, this.pos);\n }\n for (let i = 0; i < pattern.length; i++) {\n const cp = this.html.charCodeAt(this.pos + i) | 0x20;\n if (cp !== pattern.charCodeAt(i)) {\n return false;\n }\n }\n return true;\n }\n peek(offset) {\n const pos = this.pos + offset;\n if (pos >= this.html.length) {\n this.endOfChunkHit = !this.lastChunkWritten;\n return $.EOF;\n }\n const code = this.html.charCodeAt(pos);\n return code === $.CARRIAGE_RETURN ? $.LINE_FEED : code;\n }\n advance() {\n this.pos++;\n //NOTE: LF should be in the last column of the line\n if (this.isEol) {\n this.isEol = false;\n this.line++;\n this.lineStartPos = this.pos;\n }\n if (this.pos >= this.html.length) {\n this.endOfChunkHit = !this.lastChunkWritten;\n return $.EOF;\n }\n let cp = this.html.charCodeAt(this.pos);\n //NOTE: all U+000D CARRIAGE RETURN (CR) characters must be converted to U+000A LINE FEED (LF) characters\n if (cp === $.CARRIAGE_RETURN) {\n this.isEol = true;\n this.skipNextNewLine = true;\n return $.LINE_FEED;\n }\n //NOTE: any U+000A LINE FEED (LF) characters that immediately follow a U+000D CARRIAGE RETURN (CR) character\n //must be ignored.\n if (cp === $.LINE_FEED) {\n this.isEol = true;\n if (this.skipNextNewLine) {\n // `line` will be bumped again in the recursive call.\n this.line--;\n this.skipNextNewLine = false;\n this._addGap();\n return this.advance();\n }\n }\n this.skipNextNewLine = false;\n if (isSurrogate(cp)) {\n cp = this._processSurrogate(cp);\n }\n //OPTIMIZATION: first check if code point is in the common allowed\n //range (ASCII alphanumeric, whitespaces, big chunk of BMP)\n //before going into detailed performance cost validation.\n const isCommonValidRange = this.handler.onParseError === null ||\n (cp > 0x1f && cp < 0x7f) ||\n cp === $.LINE_FEED ||\n cp === $.CARRIAGE_RETURN ||\n (cp > 0x9f && cp < 64976);\n if (!isCommonValidRange) {\n this._checkForProblematicCharacters(cp);\n }\n return cp;\n }\n _checkForProblematicCharacters(cp) {\n if (isControlCodePoint(cp)) {\n this._err(ERR.controlCharacterInInputStream);\n }\n else if (isUndefinedCodePoint(cp)) {\n this._err(ERR.noncharacterInInputStream);\n }\n }\n retreat(count) {\n this.pos -= count;\n while (this.pos < this.lastGapPos) {\n this.lastGapPos = this.gapStack.pop();\n this.pos--;\n }\n this.isEol = false;\n }\n}\n//# sourceMappingURL=preprocessor.js.map","export var TokenType;\n(function (TokenType) {\n TokenType[TokenType[\"CHARACTER\"] = 0] = \"CHARACTER\";\n TokenType[TokenType[\"NULL_CHARACTER\"] = 1] = \"NULL_CHARACTER\";\n TokenType[TokenType[\"WHITESPACE_CHARACTER\"] = 2] = \"WHITESPACE_CHARACTER\";\n TokenType[TokenType[\"START_TAG\"] = 3] = \"START_TAG\";\n TokenType[TokenType[\"END_TAG\"] = 4] = \"END_TAG\";\n TokenType[TokenType[\"COMMENT\"] = 5] = \"COMMENT\";\n TokenType[TokenType[\"DOCTYPE\"] = 6] = \"DOCTYPE\";\n TokenType[TokenType[\"EOF\"] = 7] = \"EOF\";\n TokenType[TokenType[\"HIBERNATION\"] = 8] = \"HIBERNATION\";\n})(TokenType = TokenType || (TokenType = {}));\nexport function getTokenAttr(token, attrName) {\n for (let i = token.attrs.length - 1; i >= 0; i--) {\n if (token.attrs[i].name === attrName) {\n return token.attrs[i].value;\n }\n }\n return null;\n}\n//# sourceMappingURL=token.js.map",null,null,null,null,"/** All valid namespaces in HTML. */\nexport var NS;\n(function (NS) {\n NS[\"HTML\"] = \"http://www.w3.org/1999/xhtml\";\n NS[\"MATHML\"] = \"http://www.w3.org/1998/Math/MathML\";\n NS[\"SVG\"] = \"http://www.w3.org/2000/svg\";\n NS[\"XLINK\"] = \"http://www.w3.org/1999/xlink\";\n NS[\"XML\"] = \"http://www.w3.org/XML/1998/namespace\";\n NS[\"XMLNS\"] = \"http://www.w3.org/2000/xmlns/\";\n})(NS = NS || (NS = {}));\nexport var ATTRS;\n(function (ATTRS) {\n ATTRS[\"TYPE\"] = \"type\";\n ATTRS[\"ACTION\"] = \"action\";\n ATTRS[\"ENCODING\"] = \"encoding\";\n ATTRS[\"PROMPT\"] = \"prompt\";\n ATTRS[\"NAME\"] = \"name\";\n ATTRS[\"COLOR\"] = \"color\";\n ATTRS[\"FACE\"] = \"face\";\n ATTRS[\"SIZE\"] = \"size\";\n})(ATTRS = ATTRS || (ATTRS = {}));\n/**\n * The mode of the document.\n *\n * @see {@link https://dom.spec.whatwg.org/#concept-document-limited-quirks}\n */\nexport var DOCUMENT_MODE;\n(function (DOCUMENT_MODE) {\n DOCUMENT_MODE[\"NO_QUIRKS\"] = \"no-quirks\";\n DOCUMENT_MODE[\"QUIRKS\"] = \"quirks\";\n DOCUMENT_MODE[\"LIMITED_QUIRKS\"] = \"limited-quirks\";\n})(DOCUMENT_MODE = DOCUMENT_MODE || (DOCUMENT_MODE = {}));\nexport var TAG_NAMES;\n(function (TAG_NAMES) {\n TAG_NAMES[\"A\"] = \"a\";\n TAG_NAMES[\"ADDRESS\"] = \"address\";\n TAG_NAMES[\"ANNOTATION_XML\"] = \"annotation-xml\";\n TAG_NAMES[\"APPLET\"] = \"applet\";\n TAG_NAMES[\"AREA\"] = \"area\";\n TAG_NAMES[\"ARTICLE\"] = \"article\";\n TAG_NAMES[\"ASIDE\"] = \"aside\";\n TAG_NAMES[\"B\"] = \"b\";\n TAG_NAMES[\"BASE\"] = \"base\";\n TAG_NAMES[\"BASEFONT\"] = \"basefont\";\n TAG_NAMES[\"BGSOUND\"] = \"bgsound\";\n TAG_NAMES[\"BIG\"] = \"big\";\n TAG_NAMES[\"BLOCKQUOTE\"] = \"blockquote\";\n TAG_NAMES[\"BODY\"] = \"body\";\n TAG_NAMES[\"BR\"] = \"br\";\n TAG_NAMES[\"BUTTON\"] = \"button\";\n TAG_NAMES[\"CAPTION\"] = \"caption\";\n TAG_NAMES[\"CENTER\"] = \"center\";\n TAG_NAMES[\"CODE\"] = \"code\";\n TAG_NAMES[\"COL\"] = \"col\";\n TAG_NAMES[\"COLGROUP\"] = \"colgroup\";\n TAG_NAMES[\"DD\"] = \"dd\";\n TAG_NAMES[\"DESC\"] = \"desc\";\n TAG_NAMES[\"DETAILS\"] = \"details\";\n TAG_NAMES[\"DIALOG\"] = \"dialog\";\n TAG_NAMES[\"DIR\"] = \"dir\";\n TAG_NAMES[\"DIV\"] = \"div\";\n TAG_NAMES[\"DL\"] = \"dl\";\n TAG_NAMES[\"DT\"] = \"dt\";\n TAG_NAMES[\"EM\"] = \"em\";\n TAG_NAMES[\"EMBED\"] = \"embed\";\n TAG_NAMES[\"FIELDSET\"] = \"fieldset\";\n TAG_NAMES[\"FIGCAPTION\"] = \"figcaption\";\n TAG_NAMES[\"FIGURE\"] = \"figure\";\n TAG_NAMES[\"FONT\"] = \"font\";\n TAG_NAMES[\"FOOTER\"] = \"footer\";\n TAG_NAMES[\"FOREIGN_OBJECT\"] = \"foreignObject\";\n TAG_NAMES[\"FORM\"] = \"form\";\n TAG_NAMES[\"FRAME\"] = \"frame\";\n TAG_NAMES[\"FRAMESET\"] = \"frameset\";\n TAG_NAMES[\"H1\"] = \"h1\";\n TAG_NAMES[\"H2\"] = \"h2\";\n TAG_NAMES[\"H3\"] = \"h3\";\n TAG_NAMES[\"H4\"] = \"h4\";\n TAG_NAMES[\"H5\"] = \"h5\";\n TAG_NAMES[\"H6\"] = \"h6\";\n TAG_NAMES[\"HEAD\"] = \"head\";\n TAG_NAMES[\"HEADER\"] = \"header\";\n TAG_NAMES[\"HGROUP\"] = \"hgroup\";\n TAG_NAMES[\"HR\"] = \"hr\";\n TAG_NAMES[\"HTML\"] = \"html\";\n TAG_NAMES[\"I\"] = \"i\";\n TAG_NAMES[\"IMG\"] = \"img\";\n TAG_NAMES[\"IMAGE\"] = \"image\";\n TAG_NAMES[\"INPUT\"] = \"input\";\n TAG_NAMES[\"IFRAME\"] = \"iframe\";\n TAG_NAMES[\"KEYGEN\"] = \"keygen\";\n TAG_NAMES[\"LABEL\"] = \"label\";\n TAG_NAMES[\"LI\"] = \"li\";\n TAG_NAMES[\"LINK\"] = \"link\";\n TAG_NAMES[\"LISTING\"] = \"listing\";\n TAG_NAMES[\"MAIN\"] = \"main\";\n TAG_NAMES[\"MALIGNMARK\"] = \"malignmark\";\n TAG_NAMES[\"MARQUEE\"] = \"marquee\";\n TAG_NAMES[\"MATH\"] = \"math\";\n TAG_NAMES[\"MENU\"] = \"menu\";\n TAG_NAMES[\"META\"] = \"meta\";\n TAG_NAMES[\"MGLYPH\"] = \"mglyph\";\n TAG_NAMES[\"MI\"] = \"mi\";\n TAG_NAMES[\"MO\"] = \"mo\";\n TAG_NAMES[\"MN\"] = \"mn\";\n TAG_NAMES[\"MS\"] = \"ms\";\n TAG_NAMES[\"MTEXT\"] = \"mtext\";\n TAG_NAMES[\"NAV\"] = \"nav\";\n TAG_NAMES[\"NOBR\"] = \"nobr\";\n TAG_NAMES[\"NOFRAMES\"] = \"noframes\";\n TAG_NAMES[\"NOEMBED\"] = \"noembed\";\n TAG_NAMES[\"NOSCRIPT\"] = \"noscript\";\n TAG_NAMES[\"OBJECT\"] = \"object\";\n TAG_NAMES[\"OL\"] = \"ol\";\n TAG_NAMES[\"OPTGROUP\"] = \"optgroup\";\n TAG_NAMES[\"OPTION\"] = \"option\";\n TAG_NAMES[\"P\"] = \"p\";\n TAG_NAMES[\"PARAM\"] = \"param\";\n TAG_NAMES[\"PLAINTEXT\"] = \"plaintext\";\n TAG_NAMES[\"PRE\"] = \"pre\";\n TAG_NAMES[\"RB\"] = \"rb\";\n TAG_NAMES[\"RP\"] = \"rp\";\n TAG_NAMES[\"RT\"] = \"rt\";\n TAG_NAMES[\"RTC\"] = \"rtc\";\n TAG_NAMES[\"RUBY\"] = \"ruby\";\n TAG_NAMES[\"S\"] = \"s\";\n TAG_NAMES[\"SCRIPT\"] = \"script\";\n TAG_NAMES[\"SECTION\"] = \"section\";\n TAG_NAMES[\"SELECT\"] = \"select\";\n TAG_NAMES[\"SOURCE\"] = \"source\";\n TAG_NAMES[\"SMALL\"] = \"small\";\n TAG_NAMES[\"SPAN\"] = \"span\";\n TAG_NAMES[\"STRIKE\"] = \"strike\";\n TAG_NAMES[\"STRONG\"] = \"strong\";\n TAG_NAMES[\"STYLE\"] = \"style\";\n TAG_NAMES[\"SUB\"] = \"sub\";\n TAG_NAMES[\"SUMMARY\"] = \"summary\";\n TAG_NAMES[\"SUP\"] = \"sup\";\n TAG_NAMES[\"TABLE\"] = \"table\";\n TAG_NAMES[\"TBODY\"] = \"tbody\";\n TAG_NAMES[\"TEMPLATE\"] = \"template\";\n TAG_NAMES[\"TEXTAREA\"] = \"textarea\";\n TAG_NAMES[\"TFOOT\"] = \"tfoot\";\n TAG_NAMES[\"TD\"] = \"td\";\n TAG_NAMES[\"TH\"] = \"th\";\n TAG_NAMES[\"THEAD\"] = \"thead\";\n TAG_NAMES[\"TITLE\"] = \"title\";\n TAG_NAMES[\"TR\"] = \"tr\";\n TAG_NAMES[\"TRACK\"] = \"track\";\n TAG_NAMES[\"TT\"] = \"tt\";\n TAG_NAMES[\"U\"] = \"u\";\n TAG_NAMES[\"UL\"] = \"ul\";\n TAG_NAMES[\"SVG\"] = \"svg\";\n TAG_NAMES[\"VAR\"] = \"var\";\n TAG_NAMES[\"WBR\"] = \"wbr\";\n TAG_NAMES[\"XMP\"] = \"xmp\";\n})(TAG_NAMES = TAG_NAMES || (TAG_NAMES = {}));\n/**\n * Tag IDs are numeric IDs for known tag names.\n *\n * We use tag IDs to improve the performance of tag name comparisons.\n */\nexport var TAG_ID;\n(function (TAG_ID) {\n TAG_ID[TAG_ID[\"UNKNOWN\"] = 0] = \"UNKNOWN\";\n TAG_ID[TAG_ID[\"A\"] = 1] = \"A\";\n TAG_ID[TAG_ID[\"ADDRESS\"] = 2] = \"ADDRESS\";\n TAG_ID[TAG_ID[\"ANNOTATION_XML\"] = 3] = \"ANNOTATION_XML\";\n TAG_ID[TAG_ID[\"APPLET\"] = 4] = \"APPLET\";\n TAG_ID[TAG_ID[\"AREA\"] = 5] = \"AREA\";\n TAG_ID[TAG_ID[\"ARTICLE\"] = 6] = \"ARTICLE\";\n TAG_ID[TAG_ID[\"ASIDE\"] = 7] = \"ASIDE\";\n TAG_ID[TAG_ID[\"B\"] = 8] = \"B\";\n TAG_ID[TAG_ID[\"BASE\"] = 9] = \"BASE\";\n TAG_ID[TAG_ID[\"BASEFONT\"] = 10] = \"BASEFONT\";\n TAG_ID[TAG_ID[\"BGSOUND\"] = 11] = \"BGSOUND\";\n TAG_ID[TAG_ID[\"BIG\"] = 12] = \"BIG\";\n TAG_ID[TAG_ID[\"BLOCKQUOTE\"] = 13] = \"BLOCKQUOTE\";\n TAG_ID[TAG_ID[\"BODY\"] = 14] = \"BODY\";\n TAG_ID[TAG_ID[\"BR\"] = 15] = \"BR\";\n TAG_ID[TAG_ID[\"BUTTON\"] = 16] = \"BUTTON\";\n TAG_ID[TAG_ID[\"CAPTION\"] = 17] = \"CAPTION\";\n TAG_ID[TAG_ID[\"CENTER\"] = 18] = \"CENTER\";\n TAG_ID[TAG_ID[\"CODE\"] = 19] = \"CODE\";\n TAG_ID[TAG_ID[\"COL\"] = 20] = \"COL\";\n TAG_ID[TAG_ID[\"COLGROUP\"] = 21] = \"COLGROUP\";\n TAG_ID[TAG_ID[\"DD\"] = 22] = \"DD\";\n TAG_ID[TAG_ID[\"DESC\"] = 23] = \"DESC\";\n TAG_ID[TAG_ID[\"DETAILS\"] = 24] = \"DETAILS\";\n TAG_ID[TAG_ID[\"DIALOG\"] = 25] = \"DIALOG\";\n TAG_ID[TAG_ID[\"DIR\"] = 26] = \"DIR\";\n TAG_ID[TAG_ID[\"DIV\"] = 27] = \"DIV\";\n TAG_ID[TAG_ID[\"DL\"] = 28] = \"DL\";\n TAG_ID[TAG_ID[\"DT\"] = 29] = \"DT\";\n TAG_ID[TAG_ID[\"EM\"] = 30] = \"EM\";\n TAG_ID[TAG_ID[\"EMBED\"] = 31] = \"EMBED\";\n TAG_ID[TAG_ID[\"FIELDSET\"] = 32] = \"FIELDSET\";\n TAG_ID[TAG_ID[\"FIGCAPTION\"] = 33] = \"FIGCAPTION\";\n TAG_ID[TAG_ID[\"FIGURE\"] = 34] = \"FIGURE\";\n TAG_ID[TAG_ID[\"FONT\"] = 35] = \"FONT\";\n TAG_ID[TAG_ID[\"FOOTER\"] = 36] = \"FOOTER\";\n TAG_ID[TAG_ID[\"FOREIGN_OBJECT\"] = 37] = \"FOREIGN_OBJECT\";\n TAG_ID[TAG_ID[\"FORM\"] = 38] = \"FORM\";\n TAG_ID[TAG_ID[\"FRAME\"] = 39] = \"FRAME\";\n TAG_ID[TAG_ID[\"FRAMESET\"] = 40] = \"FRAMESET\";\n TAG_ID[TAG_ID[\"H1\"] = 41] = \"H1\";\n TAG_ID[TAG_ID[\"H2\"] = 42] = \"H2\";\n TAG_ID[TAG_ID[\"H3\"] = 43] = \"H3\";\n TAG_ID[TAG_ID[\"H4\"] = 44] = \"H4\";\n TAG_ID[TAG_ID[\"H5\"] = 45] = \"H5\";\n TAG_ID[TAG_ID[\"H6\"] = 46] = \"H6\";\n TAG_ID[TAG_ID[\"HEAD\"] = 47] = \"HEAD\";\n TAG_ID[TAG_ID[\"HEADER\"] = 48] = \"HEADER\";\n TAG_ID[TAG_ID[\"HGROUP\"] = 49] = \"HGROUP\";\n TAG_ID[TAG_ID[\"HR\"] = 50] = \"HR\";\n TAG_ID[TAG_ID[\"HTML\"] = 51] = \"HTML\";\n TAG_ID[TAG_ID[\"I\"] = 52] = \"I\";\n TAG_ID[TAG_ID[\"IMG\"] = 53] = \"IMG\";\n TAG_ID[TAG_ID[\"IMAGE\"] = 54] = \"IMAGE\";\n TAG_ID[TAG_ID[\"INPUT\"] = 55] = \"INPUT\";\n TAG_ID[TAG_ID[\"IFRAME\"] = 56] = \"IFRAME\";\n TAG_ID[TAG_ID[\"KEYGEN\"] = 57] = \"KEYGEN\";\n TAG_ID[TAG_ID[\"LABEL\"] = 58] = \"LABEL\";\n TAG_ID[TAG_ID[\"LI\"] = 59] = \"LI\";\n TAG_ID[TAG_ID[\"LINK\"] = 60] = \"LINK\";\n TAG_ID[TAG_ID[\"LISTING\"] = 61] = \"LISTING\";\n TAG_ID[TAG_ID[\"MAIN\"] = 62] = \"MAIN\";\n TAG_ID[TAG_ID[\"MALIGNMARK\"] = 63] = \"MALIGNMARK\";\n TAG_ID[TAG_ID[\"MARQUEE\"] = 64] = \"MARQUEE\";\n TAG_ID[TAG_ID[\"MATH\"] = 65] = \"MATH\";\n TAG_ID[TAG_ID[\"MENU\"] = 66] = \"MENU\";\n TAG_ID[TAG_ID[\"META\"] = 67] = \"META\";\n TAG_ID[TAG_ID[\"MGLYPH\"] = 68] = \"MGLYPH\";\n TAG_ID[TAG_ID[\"MI\"] = 69] = \"MI\";\n TAG_ID[TAG_ID[\"MO\"] = 70] = \"MO\";\n TAG_ID[TAG_ID[\"MN\"] = 71] = \"MN\";\n TAG_ID[TAG_ID[\"MS\"] = 72] = \"MS\";\n TAG_ID[TAG_ID[\"MTEXT\"] = 73] = \"MTEXT\";\n TAG_ID[TAG_ID[\"NAV\"] = 74] = \"NAV\";\n TAG_ID[TAG_ID[\"NOBR\"] = 75] = \"NOBR\";\n TAG_ID[TAG_ID[\"NOFRAMES\"] = 76] = \"NOFRAMES\";\n TAG_ID[TAG_ID[\"NOEMBED\"] = 77] = \"NOEMBED\";\n TAG_ID[TAG_ID[\"NOSCRIPT\"] = 78] = \"NOSCRIPT\";\n TAG_ID[TAG_ID[\"OBJECT\"] = 79] = \"OBJECT\";\n TAG_ID[TAG_ID[\"OL\"] = 80] = \"OL\";\n TAG_ID[TAG_ID[\"OPTGROUP\"] = 81] = \"OPTGROUP\";\n TAG_ID[TAG_ID[\"OPTION\"] = 82] = \"OPTION\";\n TAG_ID[TAG_ID[\"P\"] = 83] = \"P\";\n TAG_ID[TAG_ID[\"PARAM\"] = 84] = \"PARAM\";\n TAG_ID[TAG_ID[\"PLAINTEXT\"] = 85] = \"PLAINTEXT\";\n TAG_ID[TAG_ID[\"PRE\"] = 86] = \"PRE\";\n TAG_ID[TAG_ID[\"RB\"] = 87] = \"RB\";\n TAG_ID[TAG_ID[\"RP\"] = 88] = \"RP\";\n TAG_ID[TAG_ID[\"RT\"] = 89] = \"RT\";\n TAG_ID[TAG_ID[\"RTC\"] = 90] = \"RTC\";\n TAG_ID[TAG_ID[\"RUBY\"] = 91] = \"RUBY\";\n TAG_ID[TAG_ID[\"S\"] = 92] = \"S\";\n TAG_ID[TAG_ID[\"SCRIPT\"] = 93] = \"SCRIPT\";\n TAG_ID[TAG_ID[\"SECTION\"] = 94] = \"SECTION\";\n TAG_ID[TAG_ID[\"SELECT\"] = 95] = \"SELECT\";\n TAG_ID[TAG_ID[\"SOURCE\"] = 96] = \"SOURCE\";\n TAG_ID[TAG_ID[\"SMALL\"] = 97] = \"SMALL\";\n TAG_ID[TAG_ID[\"SPAN\"] = 98] = \"SPAN\";\n TAG_ID[TAG_ID[\"STRIKE\"] = 99] = \"STRIKE\";\n TAG_ID[TAG_ID[\"STRONG\"] = 100] = \"STRONG\";\n TAG_ID[TAG_ID[\"STYLE\"] = 101] = \"STYLE\";\n TAG_ID[TAG_ID[\"SUB\"] = 102] = \"SUB\";\n TAG_ID[TAG_ID[\"SUMMARY\"] = 103] = \"SUMMARY\";\n TAG_ID[TAG_ID[\"SUP\"] = 104] = \"SUP\";\n TAG_ID[TAG_ID[\"TABLE\"] = 105] = \"TABLE\";\n TAG_ID[TAG_ID[\"TBODY\"] = 106] = \"TBODY\";\n TAG_ID[TAG_ID[\"TEMPLATE\"] = 107] = \"TEMPLATE\";\n TAG_ID[TAG_ID[\"TEXTAREA\"] = 108] = \"TEXTAREA\";\n TAG_ID[TAG_ID[\"TFOOT\"] = 109] = \"TFOOT\";\n TAG_ID[TAG_ID[\"TD\"] = 110] = \"TD\";\n TAG_ID[TAG_ID[\"TH\"] = 111] = \"TH\";\n TAG_ID[TAG_ID[\"THEAD\"] = 112] = \"THEAD\";\n TAG_ID[TAG_ID[\"TITLE\"] = 113] = \"TITLE\";\n TAG_ID[TAG_ID[\"TR\"] = 114] = \"TR\";\n TAG_ID[TAG_ID[\"TRACK\"] = 115] = \"TRACK\";\n TAG_ID[TAG_ID[\"TT\"] = 116] = \"TT\";\n TAG_ID[TAG_ID[\"U\"] = 117] = \"U\";\n TAG_ID[TAG_ID[\"UL\"] = 118] = \"UL\";\n TAG_ID[TAG_ID[\"SVG\"] = 119] = \"SVG\";\n TAG_ID[TAG_ID[\"VAR\"] = 120] = \"VAR\";\n TAG_ID[TAG_ID[\"WBR\"] = 121] = \"WBR\";\n TAG_ID[TAG_ID[\"XMP\"] = 122] = \"XMP\";\n})(TAG_ID = TAG_ID || (TAG_ID = {}));\nconst TAG_NAME_TO_ID = new Map([\n [TAG_NAMES.A, TAG_ID.A],\n [TAG_NAMES.ADDRESS, TAG_ID.ADDRESS],\n [TAG_NAMES.ANNOTATION_XML, TAG_ID.ANNOTATION_XML],\n [TAG_NAMES.APPLET, TAG_ID.APPLET],\n [TAG_NAMES.AREA, TAG_ID.AREA],\n [TAG_NAMES.ARTICLE, TAG_ID.ARTICLE],\n [TAG_NAMES.ASIDE, TAG_ID.ASIDE],\n [TAG_NAMES.B, TAG_ID.B],\n [TAG_NAMES.BASE, TAG_ID.BASE],\n [TAG_NAMES.BASEFONT, TAG_ID.BASEFONT],\n [TAG_NAMES.BGSOUND, TAG_ID.BGSOUND],\n [TAG_NAMES.BIG, TAG_ID.BIG],\n [TAG_NAMES.BLOCKQUOTE, TAG_ID.BLOCKQUOTE],\n [TAG_NAMES.BODY, TAG_ID.BODY],\n [TAG_NAMES.BR, TAG_ID.BR],\n [TAG_NAMES.BUTTON, TAG_ID.BUTTON],\n [TAG_NAMES.CAPTION, TAG_ID.CAPTION],\n [TAG_NAMES.CENTER, TAG_ID.CENTER],\n [TAG_NAMES.CODE, TAG_ID.CODE],\n [TAG_NAMES.COL, TAG_ID.COL],\n [TAG_NAMES.COLGROUP, TAG_ID.COLGROUP],\n [TAG_NAMES.DD, TAG_ID.DD],\n [TAG_NAMES.DESC, TAG_ID.DESC],\n [TAG_NAMES.DETAILS, TAG_ID.DETAILS],\n [TAG_NAMES.DIALOG, TAG_ID.DIALOG],\n [TAG_NAMES.DIR, TAG_ID.DIR],\n [TAG_NAMES.DIV, TAG_ID.DIV],\n [TAG_NAMES.DL, TAG_ID.DL],\n [TAG_NAMES.DT, TAG_ID.DT],\n [TAG_NAMES.EM, TAG_ID.EM],\n [TAG_NAMES.EMBED, TAG_ID.EMBED],\n [TAG_NAMES.FIELDSET, TAG_ID.FIELDSET],\n [TAG_NAMES.FIGCAPTION, TAG_ID.FIGCAPTION],\n [TAG_NAMES.FIGURE, TAG_ID.FIGURE],\n [TAG_NAMES.FONT, TAG_ID.FONT],\n [TAG_NAMES.FOOTER, TAG_ID.FOOTER],\n [TAG_NAMES.FOREIGN_OBJECT, TAG_ID.FOREIGN_OBJECT],\n [TAG_NAMES.FORM, TAG_ID.FORM],\n [TAG_NAMES.FRAME, TAG_ID.FRAME],\n [TAG_NAMES.FRAMESET, TAG_ID.FRAMESET],\n [TAG_NAMES.H1, TAG_ID.H1],\n [TAG_NAMES.H2, TAG_ID.H2],\n [TAG_NAMES.H3, TAG_ID.H3],\n [TAG_NAMES.H4, TAG_ID.H4],\n [TAG_NAMES.H5, TAG_ID.H5],\n [TAG_NAMES.H6, TAG_ID.H6],\n [TAG_NAMES.HEAD, TAG_ID.HEAD],\n [TAG_NAMES.HEADER, TAG_ID.HEADER],\n [TAG_NAMES.HGROUP, TAG_ID.HGROUP],\n [TAG_NAMES.HR, TAG_ID.HR],\n [TAG_NAMES.HTML, TAG_ID.HTML],\n [TAG_NAMES.I, TAG_ID.I],\n [TAG_NAMES.IMG, TAG_ID.IMG],\n [TAG_NAMES.IMAGE, TAG_ID.IMAGE],\n [TAG_NAMES.INPUT, TAG_ID.INPUT],\n [TAG_NAMES.IFRAME, TAG_ID.IFRAME],\n [TAG_NAMES.KEYGEN, TAG_ID.KEYGEN],\n [TAG_NAMES.LABEL, TAG_ID.LABEL],\n [TAG_NAMES.LI, TAG_ID.LI],\n [TAG_NAMES.LINK, TAG_ID.LINK],\n [TAG_NAMES.LISTING, TAG_ID.LISTING],\n [TAG_NAMES.MAIN, TAG_ID.MAIN],\n [TAG_NAMES.MALIGNMARK, TAG_ID.MALIGNMARK],\n [TAG_NAMES.MARQUEE, TAG_ID.MARQUEE],\n [TAG_NAMES.MATH, TAG_ID.MATH],\n [TAG_NAMES.MENU, TAG_ID.MENU],\n [TAG_NAMES.META, TAG_ID.META],\n [TAG_NAMES.MGLYPH, TAG_ID.MGLYPH],\n [TAG_NAMES.MI, TAG_ID.MI],\n [TAG_NAMES.MO, TAG_ID.MO],\n [TAG_NAMES.MN, TAG_ID.MN],\n [TAG_NAMES.MS, TAG_ID.MS],\n [TAG_NAMES.MTEXT, TAG_ID.MTEXT],\n [TAG_NAMES.NAV, TAG_ID.NAV],\n [TAG_NAMES.NOBR, TAG_ID.NOBR],\n [TAG_NAMES.NOFRAMES, TAG_ID.NOFRAMES],\n [TAG_NAMES.NOEMBED, TAG_ID.NOEMBED],\n [TAG_NAMES.NOSCRIPT, TAG_ID.NOSCRIPT],\n [TAG_NAMES.OBJECT, TAG_ID.OBJECT],\n [TAG_NAMES.OL, TAG_ID.OL],\n [TAG_NAMES.OPTGROUP, TAG_ID.OPTGROUP],\n [TAG_NAMES.OPTION, TAG_ID.OPTION],\n [TAG_NAMES.P, TAG_ID.P],\n [TAG_NAMES.PARAM, TAG_ID.PARAM],\n [TAG_NAMES.PLAINTEXT, TAG_ID.PLAINTEXT],\n [TAG_NAMES.PRE, TAG_ID.PRE],\n [TAG_NAMES.RB, TAG_ID.RB],\n [TAG_NAMES.RP, TAG_ID.RP],\n [TAG_NAMES.RT, TAG_ID.RT],\n [TAG_NAMES.RTC, TAG_ID.RTC],\n [TAG_NAMES.RUBY, TAG_ID.RUBY],\n [TAG_NAMES.S, TAG_ID.S],\n [TAG_NAMES.SCRIPT, TAG_ID.SCRIPT],\n [TAG_NAMES.SECTION, TAG_ID.SECTION],\n [TAG_NAMES.SELECT, TAG_ID.SELECT],\n [TAG_NAMES.SOURCE, TAG_ID.SOURCE],\n [TAG_NAMES.SMALL, TAG_ID.SMALL],\n [TAG_NAMES.SPAN, TAG_ID.SPAN],\n [TAG_NAMES.STRIKE, TAG_ID.STRIKE],\n [TAG_NAMES.STRONG, TAG_ID.STRONG],\n [TAG_NAMES.STYLE, TAG_ID.STYLE],\n [TAG_NAMES.SUB, TAG_ID.SUB],\n [TAG_NAMES.SUMMARY, TAG_ID.SUMMARY],\n [TAG_NAMES.SUP, TAG_ID.SUP],\n [TAG_NAMES.TABLE, TAG_ID.TABLE],\n [TAG_NAMES.TBODY, TAG_ID.TBODY],\n [TAG_NAMES.TEMPLATE, TAG_ID.TEMPLATE],\n [TAG_NAMES.TEXTAREA, TAG_ID.TEXTAREA],\n [TAG_NAMES.TFOOT, TAG_ID.TFOOT],\n [TAG_NAMES.TD, TAG_ID.TD],\n [TAG_NAMES.TH, TAG_ID.TH],\n [TAG_NAMES.THEAD, TAG_ID.THEAD],\n [TAG_NAMES.TITLE, TAG_ID.TITLE],\n [TAG_NAMES.TR, TAG_ID.TR],\n [TAG_NAMES.TRACK, TAG_ID.TRACK],\n [TAG_NAMES.TT, TAG_ID.TT],\n [TAG_NAMES.U, TAG_ID.U],\n [TAG_NAMES.UL, TAG_ID.UL],\n [TAG_NAMES.SVG, TAG_ID.SVG],\n [TAG_NAMES.VAR, TAG_ID.VAR],\n [TAG_NAMES.WBR, TAG_ID.WBR],\n [TAG_NAMES.XMP, TAG_ID.XMP],\n]);\nexport function getTagID(tagName) {\n var _a;\n return (_a = TAG_NAME_TO_ID.get(tagName)) !== null && _a !== void 0 ? _a : TAG_ID.UNKNOWN;\n}\nconst $ = TAG_ID;\nexport const SPECIAL_ELEMENTS = {\n [NS.HTML]: new Set([\n $.ADDRESS,\n $.APPLET,\n $.AREA,\n $.ARTICLE,\n $.ASIDE,\n $.BASE,\n $.BASEFONT,\n $.BGSOUND,\n $.BLOCKQUOTE,\n $.BODY,\n $.BR,\n $.BUTTON,\n $.CAPTION,\n $.CENTER,\n $.COL,\n $.COLGROUP,\n $.DD,\n $.DETAILS,\n $.DIR,\n $.DIV,\n $.DL,\n $.DT,\n $.EMBED,\n $.FIELDSET,\n $.FIGCAPTION,\n $.FIGURE,\n $.FOOTER,\n $.FORM,\n $.FRAME,\n $.FRAMESET,\n $.H1,\n $.H2,\n $.H3,\n $.H4,\n $.H5,\n $.H6,\n $.HEAD,\n $.HEADER,\n $.HGROUP,\n $.HR,\n $.HTML,\n $.IFRAME,\n $.IMG,\n $.INPUT,\n $.LI,\n $.LINK,\n $.LISTING,\n $.MAIN,\n $.MARQUEE,\n $.MENU,\n $.META,\n $.NAV,\n $.NOEMBED,\n $.NOFRAMES,\n $.NOSCRIPT,\n $.OBJECT,\n $.OL,\n $.P,\n $.PARAM,\n $.PLAINTEXT,\n $.PRE,\n $.SCRIPT,\n $.SECTION,\n $.SELECT,\n $.SOURCE,\n $.STYLE,\n $.SUMMARY,\n $.TABLE,\n $.TBODY,\n $.TD,\n $.TEMPLATE,\n $.TEXTAREA,\n $.TFOOT,\n $.TH,\n $.THEAD,\n $.TITLE,\n $.TR,\n $.TRACK,\n $.UL,\n $.WBR,\n $.XMP,\n ]),\n [NS.MATHML]: new Set([$.MI, $.MO, $.MN, $.MS, $.MTEXT, $.ANNOTATION_XML]),\n [NS.SVG]: new Set([$.TITLE, $.FOREIGN_OBJECT, $.DESC]),\n [NS.XLINK]: new Set(),\n [NS.XML]: new Set(),\n [NS.XMLNS]: new Set(),\n};\nexport function isNumberedHeader(tn) {\n return tn === $.H1 || tn === $.H2 || tn === $.H3 || tn === $.H4 || tn === $.H5 || tn === $.H6;\n}\nconst UNESCAPED_TEXT = new Set([\n TAG_NAMES.STYLE,\n TAG_NAMES.SCRIPT,\n TAG_NAMES.XMP,\n TAG_NAMES.IFRAME,\n TAG_NAMES.NOEMBED,\n TAG_NAMES.NOFRAMES,\n TAG_NAMES.PLAINTEXT,\n]);\nexport function hasUnescapedText(tn, scriptingEnabled) {\n return UNESCAPED_TEXT.has(tn) || (scriptingEnabled && tn === TAG_NAMES.NOSCRIPT);\n}\n//# sourceMappingURL=html.js.map","import { Preprocessor } from './preprocessor.js';\nimport { CODE_POINTS as $, SEQUENCES as $$, REPLACEMENT_CHARACTER, isSurrogate, isUndefinedCodePoint, isControlCodePoint, } from '../common/unicode.js';\nimport { TokenType, getTokenAttr, } from '../common/token.js';\nimport { htmlDecodeTree, BinTrieFlags, determineBranch } from 'entities/lib/decode.js';\nimport { ERR } from '../common/error-codes.js';\nimport { TAG_ID, getTagID } from '../common/html.js';\n//C1 Unicode control character reference replacements\nconst C1_CONTROLS_REFERENCE_REPLACEMENTS = new Map([\n [0x80, 8364],\n [0x82, 8218],\n [0x83, 402],\n [0x84, 8222],\n [0x85, 8230],\n [0x86, 8224],\n [0x87, 8225],\n [0x88, 710],\n [0x89, 8240],\n [0x8a, 352],\n [0x8b, 8249],\n [0x8c, 338],\n [0x8e, 381],\n [0x91, 8216],\n [0x92, 8217],\n [0x93, 8220],\n [0x94, 8221],\n [0x95, 8226],\n [0x96, 8211],\n [0x97, 8212],\n [0x98, 732],\n [0x99, 8482],\n [0x9a, 353],\n [0x9b, 8250],\n [0x9c, 339],\n [0x9e, 382],\n [0x9f, 376],\n]);\n//States\nvar State;\n(function (State) {\n State[State[\"DATA\"] = 0] = \"DATA\";\n State[State[\"RCDATA\"] = 1] = \"RCDATA\";\n State[State[\"RAWTEXT\"] = 2] = \"RAWTEXT\";\n State[State[\"SCRIPT_DATA\"] = 3] = \"SCRIPT_DATA\";\n State[State[\"PLAINTEXT\"] = 4] = \"PLAINTEXT\";\n State[State[\"TAG_OPEN\"] = 5] = \"TAG_OPEN\";\n State[State[\"END_TAG_OPEN\"] = 6] = \"END_TAG_OPEN\";\n State[State[\"TAG_NAME\"] = 7] = \"TAG_NAME\";\n State[State[\"RCDATA_LESS_THAN_SIGN\"] = 8] = \"RCDATA_LESS_THAN_SIGN\";\n State[State[\"RCDATA_END_TAG_OPEN\"] = 9] = \"RCDATA_END_TAG_OPEN\";\n State[State[\"RCDATA_END_TAG_NAME\"] = 10] = \"RCDATA_END_TAG_NAME\";\n State[State[\"RAWTEXT_LESS_THAN_SIGN\"] = 11] = \"RAWTEXT_LESS_THAN_SIGN\";\n State[State[\"RAWTEXT_END_TAG_OPEN\"] = 12] = \"RAWTEXT_END_TAG_OPEN\";\n State[State[\"RAWTEXT_END_TAG_NAME\"] = 13] = \"RAWTEXT_END_TAG_NAME\";\n State[State[\"SCRIPT_DATA_LESS_THAN_SIGN\"] = 14] = \"SCRIPT_DATA_LESS_THAN_SIGN\";\n State[State[\"SCRIPT_DATA_END_TAG_OPEN\"] = 15] = \"SCRIPT_DATA_END_TAG_OPEN\";\n State[State[\"SCRIPT_DATA_END_TAG_NAME\"] = 16] = \"SCRIPT_DATA_END_TAG_NAME\";\n State[State[\"SCRIPT_DATA_ESCAPE_START\"] = 17] = \"SCRIPT_DATA_ESCAPE_START\";\n State[State[\"SCRIPT_DATA_ESCAPE_START_DASH\"] = 18] = \"SCRIPT_DATA_ESCAPE_START_DASH\";\n State[State[\"SCRIPT_DATA_ESCAPED\"] = 19] = \"SCRIPT_DATA_ESCAPED\";\n State[State[\"SCRIPT_DATA_ESCAPED_DASH\"] = 20] = \"SCRIPT_DATA_ESCAPED_DASH\";\n State[State[\"SCRIPT_DATA_ESCAPED_DASH_DASH\"] = 21] = \"SCRIPT_DATA_ESCAPED_DASH_DASH\";\n State[State[\"SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN\"] = 22] = \"SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN\";\n State[State[\"SCRIPT_DATA_ESCAPED_END_TAG_OPEN\"] = 23] = \"SCRIPT_DATA_ESCAPED_END_TAG_OPEN\";\n State[State[\"SCRIPT_DATA_ESCAPED_END_TAG_NAME\"] = 24] = \"SCRIPT_DATA_ESCAPED_END_TAG_NAME\";\n State[State[\"SCRIPT_DATA_DOUBLE_ESCAPE_START\"] = 25] = \"SCRIPT_DATA_DOUBLE_ESCAPE_START\";\n State[State[\"SCRIPT_DATA_DOUBLE_ESCAPED\"] = 26] = \"SCRIPT_DATA_DOUBLE_ESCAPED\";\n State[State[\"SCRIPT_DATA_DOUBLE_ESCAPED_DASH\"] = 27] = \"SCRIPT_DATA_DOUBLE_ESCAPED_DASH\";\n State[State[\"SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH\"] = 28] = \"SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH\";\n State[State[\"SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN\"] = 29] = \"SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN\";\n State[State[\"SCRIPT_DATA_DOUBLE_ESCAPE_END\"] = 30] = \"SCRIPT_DATA_DOUBLE_ESCAPE_END\";\n State[State[\"BEFORE_ATTRIBUTE_NAME\"] = 31] = \"BEFORE_ATTRIBUTE_NAME\";\n State[State[\"ATTRIBUTE_NAME\"] = 32] = \"ATTRIBUTE_NAME\";\n State[State[\"AFTER_ATTRIBUTE_NAME\"] = 33] = \"AFTER_ATTRIBUTE_NAME\";\n State[State[\"BEFORE_ATTRIBUTE_VALUE\"] = 34] = \"BEFORE_ATTRIBUTE_VALUE\";\n State[State[\"ATTRIBUTE_VALUE_DOUBLE_QUOTED\"] = 35] = \"ATTRIBUTE_VALUE_DOUBLE_QUOTED\";\n State[State[\"ATTRIBUTE_VALUE_SINGLE_QUOTED\"] = 36] = \"ATTRIBUTE_VALUE_SINGLE_QUOTED\";\n State[State[\"ATTRIBUTE_VALUE_UNQUOTED\"] = 37] = \"ATTRIBUTE_VALUE_UNQUOTED\";\n State[State[\"AFTER_ATTRIBUTE_VALUE_QUOTED\"] = 38] = \"AFTER_ATTRIBUTE_VALUE_QUOTED\";\n State[State[\"SELF_CLOSING_START_TAG\"] = 39] = \"SELF_CLOSING_START_TAG\";\n State[State[\"BOGUS_COMMENT\"] = 40] = \"BOGUS_COMMENT\";\n State[State[\"MARKUP_DECLARATION_OPEN\"] = 41] = \"MARKUP_DECLARATION_OPEN\";\n State[State[\"COMMENT_START\"] = 42] = \"COMMENT_START\";\n State[State[\"COMMENT_START_DASH\"] = 43] = \"COMMENT_START_DASH\";\n State[State[\"COMMENT\"] = 44] = \"COMMENT\";\n State[State[\"COMMENT_LESS_THAN_SIGN\"] = 45] = \"COMMENT_LESS_THAN_SIGN\";\n State[State[\"COMMENT_LESS_THAN_SIGN_BANG\"] = 46] = \"COMMENT_LESS_THAN_SIGN_BANG\";\n State[State[\"COMMENT_LESS_THAN_SIGN_BANG_DASH\"] = 47] = \"COMMENT_LESS_THAN_SIGN_BANG_DASH\";\n State[State[\"COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH\"] = 48] = \"COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH\";\n State[State[\"COMMENT_END_DASH\"] = 49] = \"COMMENT_END_DASH\";\n State[State[\"COMMENT_END\"] = 50] = \"COMMENT_END\";\n State[State[\"COMMENT_END_BANG\"] = 51] = \"COMMENT_END_BANG\";\n State[State[\"DOCTYPE\"] = 52] = \"DOCTYPE\";\n State[State[\"BEFORE_DOCTYPE_NAME\"] = 53] = \"BEFORE_DOCTYPE_NAME\";\n State[State[\"DOCTYPE_NAME\"] = 54] = \"DOCTYPE_NAME\";\n State[State[\"AFTER_DOCTYPE_NAME\"] = 55] = \"AFTER_DOCTYPE_NAME\";\n State[State[\"AFTER_DOCTYPE_PUBLIC_KEYWORD\"] = 56] = \"AFTER_DOCTYPE_PUBLIC_KEYWORD\";\n State[State[\"BEFORE_DOCTYPE_PUBLIC_IDENTIFIER\"] = 57] = \"BEFORE_DOCTYPE_PUBLIC_IDENTIFIER\";\n State[State[\"DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED\"] = 58] = \"DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED\";\n State[State[\"DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED\"] = 59] = \"DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED\";\n State[State[\"AFTER_DOCTYPE_PUBLIC_IDENTIFIER\"] = 60] = \"AFTER_DOCTYPE_PUBLIC_IDENTIFIER\";\n State[State[\"BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS\"] = 61] = \"BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS\";\n State[State[\"AFTER_DOCTYPE_SYSTEM_KEYWORD\"] = 62] = \"AFTER_DOCTYPE_SYSTEM_KEYWORD\";\n State[State[\"BEFORE_DOCTYPE_SYSTEM_IDENTIFIER\"] = 63] = \"BEFORE_DOCTYPE_SYSTEM_IDENTIFIER\";\n State[State[\"DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED\"] = 64] = \"DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED\";\n State[State[\"DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED\"] = 65] = \"DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED\";\n State[State[\"AFTER_DOCTYPE_SYSTEM_IDENTIFIER\"] = 66] = \"AFTER_DOCTYPE_SYSTEM_IDENTIFIER\";\n State[State[\"BOGUS_DOCTYPE\"] = 67] = \"BOGUS_DOCTYPE\";\n State[State[\"CDATA_SECTION\"] = 68] = \"CDATA_SECTION\";\n State[State[\"CDATA_SECTION_BRACKET\"] = 69] = \"CDATA_SECTION_BRACKET\";\n State[State[\"CDATA_SECTION_END\"] = 70] = \"CDATA_SECTION_END\";\n State[State[\"CHARACTER_REFERENCE\"] = 71] = \"CHARACTER_REFERENCE\";\n State[State[\"NAMED_CHARACTER_REFERENCE\"] = 72] = \"NAMED_CHARACTER_REFERENCE\";\n State[State[\"AMBIGUOUS_AMPERSAND\"] = 73] = \"AMBIGUOUS_AMPERSAND\";\n State[State[\"NUMERIC_CHARACTER_REFERENCE\"] = 74] = \"NUMERIC_CHARACTER_REFERENCE\";\n State[State[\"HEXADEMICAL_CHARACTER_REFERENCE_START\"] = 75] = \"HEXADEMICAL_CHARACTER_REFERENCE_START\";\n State[State[\"HEXADEMICAL_CHARACTER_REFERENCE\"] = 76] = \"HEXADEMICAL_CHARACTER_REFERENCE\";\n State[State[\"DECIMAL_CHARACTER_REFERENCE\"] = 77] = \"DECIMAL_CHARACTER_REFERENCE\";\n State[State[\"NUMERIC_CHARACTER_REFERENCE_END\"] = 78] = \"NUMERIC_CHARACTER_REFERENCE_END\";\n})(State || (State = {}));\n//Tokenizer initial states for different modes\nexport const TokenizerMode = {\n DATA: State.DATA,\n RCDATA: State.RCDATA,\n RAWTEXT: State.RAWTEXT,\n SCRIPT_DATA: State.SCRIPT_DATA,\n PLAINTEXT: State.PLAINTEXT,\n CDATA_SECTION: State.CDATA_SECTION,\n};\n//Utils\n//OPTIMIZATION: these utility functions should not be moved out of this module. V8 Crankshaft will not inline\n//this functions if they will be situated in another module due to context switch.\n//Always perform inlining check before modifying this functions ('node --trace-inlining').\nfunction isAsciiDigit(cp) {\n return cp >= $.DIGIT_0 && cp <= $.DIGIT_9;\n}\nfunction isAsciiUpper(cp) {\n return cp >= $.LATIN_CAPITAL_A && cp <= $.LATIN_CAPITAL_Z;\n}\nfunction isAsciiLower(cp) {\n return cp >= $.LATIN_SMALL_A && cp <= $.LATIN_SMALL_Z;\n}\nfunction isAsciiLetter(cp) {\n return isAsciiLower(cp) || isAsciiUpper(cp);\n}\nfunction isAsciiAlphaNumeric(cp) {\n return isAsciiLetter(cp) || isAsciiDigit(cp);\n}\nfunction isAsciiUpperHexDigit(cp) {\n return cp >= $.LATIN_CAPITAL_A && cp <= $.LATIN_CAPITAL_F;\n}\nfunction isAsciiLowerHexDigit(cp) {\n return cp >= $.LATIN_SMALL_A && cp <= $.LATIN_SMALL_F;\n}\nfunction isAsciiHexDigit(cp) {\n return isAsciiDigit(cp) || isAsciiUpperHexDigit(cp) || isAsciiLowerHexDigit(cp);\n}\nfunction toAsciiLower(cp) {\n return cp + 32;\n}\nfunction isWhitespace(cp) {\n return cp === $.SPACE || cp === $.LINE_FEED || cp === $.TABULATION || cp === $.FORM_FEED;\n}\nfunction isEntityInAttributeInvalidEnd(nextCp) {\n return nextCp === $.EQUALS_SIGN || isAsciiAlphaNumeric(nextCp);\n}\nfunction isScriptDataDoubleEscapeSequenceEnd(cp) {\n return isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN;\n}\n//Tokenizer\nexport class Tokenizer {\n constructor(options, handler) {\n this.options = options;\n this.handler = handler;\n this.paused = false;\n /** Ensures that the parsing loop isn't run multiple times at once. */\n this.inLoop = false;\n /**\n * Indicates that the current adjusted node exists, is not an element in the HTML namespace,\n * and that it is not an integration point for either MathML or HTML.\n *\n * @see {@link https://html.spec.whatwg.org/multipage/parsing.html#tree-construction}\n */\n this.inForeignNode = false;\n this.lastStartTagName = '';\n this.active = false;\n this.state = State.DATA;\n this.returnState = State.DATA;\n this.charRefCode = -1;\n this.consumedAfterSnapshot = -1;\n this.currentCharacterToken = null;\n this.currentToken = null;\n this.currentAttr = { name: '', value: '' };\n this.preprocessor = new Preprocessor(handler);\n this.currentLocation = this.getCurrentLocation(-1);\n }\n //Errors\n _err(code) {\n var _a, _b;\n (_b = (_a = this.handler).onParseError) === null || _b === void 0 ? void 0 : _b.call(_a, this.preprocessor.getError(code));\n }\n // NOTE: `offset` may never run across line boundaries.\n getCurrentLocation(offset) {\n if (!this.options.sourceCodeLocationInfo) {\n return null;\n }\n return {\n startLine: this.preprocessor.line,\n startCol: this.preprocessor.col - offset,\n startOffset: this.preprocessor.offset - offset,\n endLine: -1,\n endCol: -1,\n endOffset: -1,\n };\n }\n _runParsingLoop() {\n if (this.inLoop)\n return;\n this.inLoop = true;\n while (this.active && !this.paused) {\n this.consumedAfterSnapshot = 0;\n const cp = this._consume();\n if (!this._ensureHibernation()) {\n this._callState(cp);\n }\n }\n this.inLoop = false;\n }\n //API\n pause() {\n this.paused = true;\n }\n resume(writeCallback) {\n if (!this.paused) {\n throw new Error('Parser was already resumed');\n }\n this.paused = false;\n // Necessary for synchronous resume.\n if (this.inLoop)\n return;\n this._runParsingLoop();\n if (!this.paused) {\n writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();\n }\n }\n write(chunk, isLastChunk, writeCallback) {\n this.active = true;\n this.preprocessor.write(chunk, isLastChunk);\n this._runParsingLoop();\n if (!this.paused) {\n writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();\n }\n }\n insertHtmlAtCurrentPos(chunk) {\n this.active = true;\n this.preprocessor.insertHtmlAtCurrentPos(chunk);\n this._runParsingLoop();\n }\n //Hibernation\n _ensureHibernation() {\n if (this.preprocessor.endOfChunkHit) {\n this._unconsume(this.consumedAfterSnapshot);\n this.active = false;\n return true;\n }\n return false;\n }\n //Consumption\n _consume() {\n this.consumedAfterSnapshot++;\n return this.preprocessor.advance();\n }\n _unconsume(count) {\n this.consumedAfterSnapshot -= count;\n this.preprocessor.retreat(count);\n }\n _reconsumeInState(state, cp) {\n this.state = state;\n this._callState(cp);\n }\n _advanceBy(count) {\n this.consumedAfterSnapshot += count;\n for (let i = 0; i < count; i++) {\n this.preprocessor.advance();\n }\n }\n _consumeSequenceIfMatch(pattern, caseSensitive) {\n if (this.preprocessor.startsWith(pattern, caseSensitive)) {\n // We will already have consumed one character before calling this method.\n this._advanceBy(pattern.length - 1);\n return true;\n }\n return false;\n }\n //Token creation\n _createStartTagToken() {\n this.currentToken = {\n type: TokenType.START_TAG,\n tagName: '',\n tagID: TAG_ID.UNKNOWN,\n selfClosing: false,\n ackSelfClosing: false,\n attrs: [],\n location: this.getCurrentLocation(1),\n };\n }\n _createEndTagToken() {\n this.currentToken = {\n type: TokenType.END_TAG,\n tagName: '',\n tagID: TAG_ID.UNKNOWN,\n selfClosing: false,\n ackSelfClosing: false,\n attrs: [],\n location: this.getCurrentLocation(2),\n };\n }\n _createCommentToken(offset) {\n this.currentToken = {\n type: TokenType.COMMENT,\n data: '',\n location: this.getCurrentLocation(offset),\n };\n }\n _createDoctypeToken(initialName) {\n this.currentToken = {\n type: TokenType.DOCTYPE,\n name: initialName,\n forceQuirks: false,\n publicId: null,\n systemId: null,\n location: this.currentLocation,\n };\n }\n _createCharacterToken(type, chars) {\n this.currentCharacterToken = {\n type,\n chars,\n location: this.currentLocation,\n };\n }\n //Tag attributes\n _createAttr(attrNameFirstCh) {\n this.currentAttr = {\n name: attrNameFirstCh,\n value: '',\n };\n this.currentLocation = this.getCurrentLocation(0);\n }\n _leaveAttrName() {\n var _a;\n var _b;\n const token = this.currentToken;\n if (getTokenAttr(token, this.currentAttr.name) === null) {\n token.attrs.push(this.currentAttr);\n if (token.location && this.currentLocation) {\n const attrLocations = ((_a = (_b = token.location).attrs) !== null && _a !== void 0 ? _a : (_b.attrs = Object.create(null)));\n attrLocations[this.currentAttr.name] = this.currentLocation;\n // Set end location\n this._leaveAttrValue();\n }\n }\n else {\n this._err(ERR.duplicateAttribute);\n }\n }\n _leaveAttrValue() {\n if (this.currentLocation) {\n this.currentLocation.endLine = this.preprocessor.line;\n this.currentLocation.endCol = this.preprocessor.col;\n this.currentLocation.endOffset = this.preprocessor.offset;\n }\n }\n //Token emission\n prepareToken(ct) {\n this._emitCurrentCharacterToken(ct.location);\n this.currentToken = null;\n if (ct.location) {\n ct.location.endLine = this.preprocessor.line;\n ct.location.endCol = this.preprocessor.col + 1;\n ct.location.endOffset = this.preprocessor.offset + 1;\n }\n this.currentLocation = this.getCurrentLocation(-1);\n }\n emitCurrentTagToken() {\n const ct = this.currentToken;\n this.prepareToken(ct);\n ct.tagID = getTagID(ct.tagName);\n if (ct.type === TokenType.START_TAG) {\n this.lastStartTagName = ct.tagName;\n this.handler.onStartTag(ct);\n }\n else {\n if (ct.attrs.length > 0) {\n this._err(ERR.endTagWithAttributes);\n }\n if (ct.selfClosing) {\n this._err(ERR.endTagWithTrailingSolidus);\n }\n this.handler.onEndTag(ct);\n }\n this.preprocessor.dropParsedChunk();\n }\n emitCurrentComment(ct) {\n this.prepareToken(ct);\n this.handler.onComment(ct);\n this.preprocessor.dropParsedChunk();\n }\n emitCurrentDoctype(ct) {\n this.prepareToken(ct);\n this.handler.onDoctype(ct);\n this.preprocessor.dropParsedChunk();\n }\n _emitCurrentCharacterToken(nextLocation) {\n if (this.currentCharacterToken) {\n //NOTE: if we have a pending character token, make it's end location equal to the\n //current token's start location.\n if (nextLocation && this.currentCharacterToken.location) {\n this.currentCharacterToken.location.endLine = nextLocation.startLine;\n this.currentCharacterToken.location.endCol = nextLocation.startCol;\n this.currentCharacterToken.location.endOffset = nextLocation.startOffset;\n }\n switch (this.currentCharacterToken.type) {\n case TokenType.CHARACTER: {\n this.handler.onCharacter(this.currentCharacterToken);\n break;\n }\n case TokenType.NULL_CHARACTER: {\n this.handler.onNullCharacter(this.currentCharacterToken);\n break;\n }\n case TokenType.WHITESPACE_CHARACTER: {\n this.handler.onWhitespaceCharacter(this.currentCharacterToken);\n break;\n }\n }\n this.currentCharacterToken = null;\n }\n }\n _emitEOFToken() {\n const location = this.getCurrentLocation(0);\n if (location) {\n location.endLine = location.startLine;\n location.endCol = location.startCol;\n location.endOffset = location.startOffset;\n }\n this._emitCurrentCharacterToken(location);\n this.handler.onEof({ type: TokenType.EOF, location });\n this.active = false;\n }\n //Characters emission\n //OPTIMIZATION: specification uses only one type of character tokens (one token per character).\n //This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters.\n //If we have a sequence of characters that belong to the same group, the parser can process it\n //as a single solid character token.\n //So, there are 3 types of character tokens in parse5:\n //1)TokenType.NULL_CHARACTER - \\u0000-character sequences (e.g. '\\u0000\\u0000\\u0000')\n //2)TokenType.WHITESPACE_CHARACTER - any whitespace/new-line character sequences (e.g. '\\n \\r\\t \\f')\n //3)TokenType.CHARACTER - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^')\n _appendCharToCurrentCharacterToken(type, ch) {\n if (this.currentCharacterToken) {\n if (this.currentCharacterToken.type !== type) {\n this.currentLocation = this.getCurrentLocation(0);\n this._emitCurrentCharacterToken(this.currentLocation);\n this.preprocessor.dropParsedChunk();\n }\n else {\n this.currentCharacterToken.chars += ch;\n return;\n }\n }\n this._createCharacterToken(type, ch);\n }\n _emitCodePoint(cp) {\n const type = isWhitespace(cp)\n ? TokenType.WHITESPACE_CHARACTER\n : cp === $.NULL\n ? TokenType.NULL_CHARACTER\n : TokenType.CHARACTER;\n this._appendCharToCurrentCharacterToken(type, String.fromCodePoint(cp));\n }\n //NOTE: used when we emit characters explicitly.\n //This is always for non-whitespace and non-null characters, which allows us to avoid additional checks.\n _emitChars(ch) {\n this._appendCharToCurrentCharacterToken(TokenType.CHARACTER, ch);\n }\n // Character reference helpers\n _matchNamedCharacterReference(cp) {\n let result = null;\n let excess = 0;\n let withoutSemicolon = false;\n for (let i = 0, current = htmlDecodeTree[0]; i >= 0; cp = this._consume()) {\n i = determineBranch(htmlDecodeTree, current, i + 1, cp);\n if (i < 0)\n break;\n excess += 1;\n current = htmlDecodeTree[i];\n const masked = current & BinTrieFlags.VALUE_LENGTH;\n // If the branch is a value, store it and continue\n if (masked) {\n // The mask is the number of bytes of the value, including the current byte.\n const valueLength = (masked >> 14) - 1;\n // Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.\n // See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state\n if (cp !== $.SEMICOLON &&\n this._isCharacterReferenceInAttribute() &&\n isEntityInAttributeInvalidEnd(this.preprocessor.peek(1))) {\n //NOTE: we don't flush all consumed code points here, and instead switch back to the original state after\n //emitting an ampersand. This is fine, as alphanumeric characters won't be parsed differently in attributes.\n result = [$.AMPERSAND];\n // Skip over the value.\n i += valueLength;\n }\n else {\n // If this is a surrogate pair, consume the next two bytes.\n result =\n valueLength === 0\n ? [htmlDecodeTree[i] & ~BinTrieFlags.VALUE_LENGTH]\n : valueLength === 1\n ? [htmlDecodeTree[++i]]\n : [htmlDecodeTree[++i], htmlDecodeTree[++i]];\n excess = 0;\n withoutSemicolon = cp !== $.SEMICOLON;\n }\n if (valueLength === 0) {\n // If the value is zero-length, we're done.\n this._consume();\n break;\n }\n }\n }\n this._unconsume(excess);\n if (withoutSemicolon && !this.preprocessor.endOfChunkHit) {\n this._err(ERR.missingSemicolonAfterCharacterReference);\n }\n // We want to emit the error above on the code point after the entity.\n // We always consume one code point too many in the loop, and we wait to\n // unconsume it until after the error is emitted.\n this._unconsume(1);\n return result;\n }\n _isCharacterReferenceInAttribute() {\n return (this.returnState === State.ATTRIBUTE_VALUE_DOUBLE_QUOTED ||\n this.returnState === State.ATTRIBUTE_VALUE_SINGLE_QUOTED ||\n this.returnState === State.ATTRIBUTE_VALUE_UNQUOTED);\n }\n _flushCodePointConsumedAsCharacterReference(cp) {\n if (this._isCharacterReferenceInAttribute()) {\n this.currentAttr.value += String.fromCodePoint(cp);\n }\n else {\n this._emitCodePoint(cp);\n }\n }\n // Calling states this way turns out to be much faster than any other approach.\n _callState(cp) {\n switch (this.state) {\n case State.DATA: {\n this._stateData(cp);\n break;\n }\n case State.RCDATA: {\n this._stateRcdata(cp);\n break;\n }\n case State.RAWTEXT: {\n this._stateRawtext(cp);\n break;\n }\n case State.SCRIPT_DATA: {\n this._stateScriptData(cp);\n break;\n }\n case State.PLAINTEXT: {\n this._statePlaintext(cp);\n break;\n }\n case State.TAG_OPEN: {\n this._stateTagOpen(cp);\n break;\n }\n case State.END_TAG_OPEN: {\n this._stateEndTagOpen(cp);\n break;\n }\n case State.TAG_NAME: {\n this._stateTagName(cp);\n break;\n }\n case State.RCDATA_LESS_THAN_SIGN: {\n this._stateRcdataLessThanSign(cp);\n break;\n }\n case State.RCDATA_END_TAG_OPEN: {\n this._stateRcdataEndTagOpen(cp);\n break;\n }\n case State.RCDATA_END_TAG_NAME: {\n this._stateRcdataEndTagName(cp);\n break;\n }\n case State.RAWTEXT_LESS_THAN_SIGN: {\n this._stateRawtextLessThanSign(cp);\n break;\n }\n case State.RAWTEXT_END_TAG_OPEN: {\n this._stateRawtextEndTagOpen(cp);\n break;\n }\n case State.RAWTEXT_END_TAG_NAME: {\n this._stateRawtextEndTagName(cp);\n break;\n }\n case State.SCRIPT_DATA_LESS_THAN_SIGN: {\n this._stateScriptDataLessThanSign(cp);\n break;\n }\n case State.SCRIPT_DATA_END_TAG_OPEN: {\n this._stateScriptDataEndTagOpen(cp);\n break;\n }\n case State.SCRIPT_DATA_END_TAG_NAME: {\n this._stateScriptDataEndTagName(cp);\n break;\n }\n case State.SCRIPT_DATA_ESCAPE_START: {\n this._stateScriptDataEscapeStart(cp);\n break;\n }\n case State.SCRIPT_DATA_ESCAPE_START_DASH: {\n this._stateScriptDataEscapeStartDash(cp);\n break;\n }\n case State.SCRIPT_DATA_ESCAPED: {\n this._stateScriptDataEscaped(cp);\n break;\n }\n case State.SCRIPT_DATA_ESCAPED_DASH: {\n this._stateScriptDataEscapedDash(cp);\n break;\n }\n case State.SCRIPT_DATA_ESCAPED_DASH_DASH: {\n this._stateScriptDataEscapedDashDash(cp);\n break;\n }\n case State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {\n this._stateScriptDataEscapedLessThanSign(cp);\n break;\n }\n case State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN: {\n this._stateScriptDataEscapedEndTagOpen(cp);\n break;\n }\n case State.SCRIPT_DATA_ESCAPED_END_TAG_NAME: {\n this._stateScriptDataEscapedEndTagName(cp);\n break;\n }\n case State.SCRIPT_DATA_DOUBLE_ESCAPE_START: {\n this._stateScriptDataDoubleEscapeStart(cp);\n break;\n }\n case State.SCRIPT_DATA_DOUBLE_ESCAPED: {\n this._stateScriptDataDoubleEscaped(cp);\n break;\n }\n case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {\n this._stateScriptDataDoubleEscapedDash(cp);\n break;\n }\n case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {\n this._stateScriptDataDoubleEscapedDashDash(cp);\n break;\n }\n case State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {\n this._stateScriptDataDoubleEscapedLessThanSign(cp);\n break;\n }\n case State.SCRIPT_DATA_DOUBLE_ESCAPE_END: {\n this._stateScriptDataDoubleEscapeEnd(cp);\n break;\n }\n case State.BEFORE_ATTRIBUTE_NAME: {\n this._stateBeforeAttributeName(cp);\n break;\n }\n case State.ATTRIBUTE_NAME: {\n this._stateAttributeName(cp);\n break;\n }\n case State.AFTER_ATTRIBUTE_NAME: {\n this._stateAfterAttributeName(cp);\n break;\n }\n case State.BEFORE_ATTRIBUTE_VALUE: {\n this._stateBeforeAttributeValue(cp);\n break;\n }\n case State.ATTRIBUTE_VALUE_DOUBLE_QUOTED: {\n this._stateAttributeValueDoubleQuoted(cp);\n break;\n }\n case State.ATTRIBUTE_VALUE_SINGLE_QUOTED: {\n this._stateAttributeValueSingleQuoted(cp);\n break;\n }\n case State.ATTRIBUTE_VALUE_UNQUOTED: {\n this._stateAttributeValueUnquoted(cp);\n break;\n }\n case State.AFTER_ATTRIBUTE_VALUE_QUOTED: {\n this._stateAfterAttributeValueQuoted(cp);\n break;\n }\n case State.SELF_CLOSING_START_TAG: {\n this._stateSelfClosingStartTag(cp);\n break;\n }\n case State.BOGUS_COMMENT: {\n this._stateBogusComment(cp);\n break;\n }\n case State.MARKUP_DECLARATION_OPEN: {\n this._stateMarkupDeclarationOpen(cp);\n break;\n }\n case State.COMMENT_START: {\n this._stateCommentStart(cp);\n break;\n }\n case State.COMMENT_START_DASH: {\n this._stateCommentStartDash(cp);\n break;\n }\n case State.COMMENT: {\n this._stateComment(cp);\n break;\n }\n case State.COMMENT_LESS_THAN_SIGN: {\n this._stateCommentLessThanSign(cp);\n break;\n }\n case State.COMMENT_LESS_THAN_SIGN_BANG: {\n this._stateCommentLessThanSignBang(cp);\n break;\n }\n case State.COMMENT_LESS_THAN_SIGN_BANG_DASH: {\n this._stateCommentLessThanSignBangDash(cp);\n break;\n }\n case State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH: {\n this._stateCommentLessThanSignBangDashDash(cp);\n break;\n }\n case State.COMMENT_END_DASH: {\n this._stateCommentEndDash(cp);\n break;\n }\n case State.COMMENT_END: {\n this._stateCommentEnd(cp);\n break;\n }\n case State.COMMENT_END_BANG: {\n this._stateCommentEndBang(cp);\n break;\n }\n case State.DOCTYPE: {\n this._stateDoctype(cp);\n break;\n }\n case State.BEFORE_DOCTYPE_NAME: {\n this._stateBeforeDoctypeName(cp);\n break;\n }\n case State.DOCTYPE_NAME: {\n this._stateDoctypeName(cp);\n break;\n }\n case State.AFTER_DOCTYPE_NAME: {\n this._stateAfterDoctypeName(cp);\n break;\n }\n case State.AFTER_DOCTYPE_PUBLIC_KEYWORD: {\n this._stateAfterDoctypePublicKeyword(cp);\n break;\n }\n case State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {\n this._stateBeforeDoctypePublicIdentifier(cp);\n break;\n }\n case State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {\n this._stateDoctypePublicIdentifierDoubleQuoted(cp);\n break;\n }\n case State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {\n this._stateDoctypePublicIdentifierSingleQuoted(cp);\n break;\n }\n case State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {\n this._stateAfterDoctypePublicIdentifier(cp);\n break;\n }\n case State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {\n this._stateBetweenDoctypePublicAndSystemIdentifiers(cp);\n break;\n }\n case State.AFTER_DOCTYPE_SYSTEM_KEYWORD: {\n this._stateAfterDoctypeSystemKeyword(cp);\n break;\n }\n case State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: {\n this._stateBeforeDoctypeSystemIdentifier(cp);\n break;\n }\n case State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {\n this._stateDoctypeSystemIdentifierDoubleQuoted(cp);\n break;\n }\n case State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {\n this._stateDoctypeSystemIdentifierSingleQuoted(cp);\n break;\n }\n case State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {\n this._stateAfterDoctypeSystemIdentifier(cp);\n break;\n }\n case State.BOGUS_DOCTYPE: {\n this._stateBogusDoctype(cp);\n break;\n }\n case State.CDATA_SECTION: {\n this._stateCdataSection(cp);\n break;\n }\n case State.CDATA_SECTION_BRACKET: {\n this._stateCdataSectionBracket(cp);\n break;\n }\n case State.CDATA_SECTION_END: {\n this._stateCdataSectionEnd(cp);\n break;\n }\n case State.CHARACTER_REFERENCE: {\n this._stateCharacterReference(cp);\n break;\n }\n case State.NAMED_CHARACTER_REFERENCE: {\n this._stateNamedCharacterReference(cp);\n break;\n }\n case State.AMBIGUOUS_AMPERSAND: {\n this._stateAmbiguousAmpersand(cp);\n break;\n }\n case State.NUMERIC_CHARACTER_REFERENCE: {\n this._stateNumericCharacterReference(cp);\n break;\n }\n case State.HEXADEMICAL_CHARACTER_REFERENCE_START: {\n this._stateHexademicalCharacterReferenceStart(cp);\n break;\n }\n case State.HEXADEMICAL_CHARACTER_REFERENCE: {\n this._stateHexademicalCharacterReference(cp);\n break;\n }\n case State.DECIMAL_CHARACTER_REFERENCE: {\n this._stateDecimalCharacterReference(cp);\n break;\n }\n case State.NUMERIC_CHARACTER_REFERENCE_END: {\n this._stateNumericCharacterReferenceEnd(cp);\n break;\n }\n default: {\n throw new Error('Unknown state');\n }\n }\n }\n // State machine\n // Data state\n //------------------------------------------------------------------\n _stateData(cp) {\n switch (cp) {\n case $.LESS_THAN_SIGN: {\n this.state = State.TAG_OPEN;\n break;\n }\n case $.AMPERSAND: {\n this.returnState = State.DATA;\n this.state = State.CHARACTER_REFERENCE;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this._emitCodePoint(cp);\n break;\n }\n case $.EOF: {\n this._emitEOFToken();\n break;\n }\n default: {\n this._emitCodePoint(cp);\n }\n }\n }\n // RCDATA state\n //------------------------------------------------------------------\n _stateRcdata(cp) {\n switch (cp) {\n case $.AMPERSAND: {\n this.returnState = State.RCDATA;\n this.state = State.CHARACTER_REFERENCE;\n break;\n }\n case $.LESS_THAN_SIGN: {\n this.state = State.RCDATA_LESS_THAN_SIGN;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this._emitChars(REPLACEMENT_CHARACTER);\n break;\n }\n case $.EOF: {\n this._emitEOFToken();\n break;\n }\n default: {\n this._emitCodePoint(cp);\n }\n }\n }\n // RAWTEXT state\n //------------------------------------------------------------------\n _stateRawtext(cp) {\n switch (cp) {\n case $.LESS_THAN_SIGN: {\n this.state = State.RAWTEXT_LESS_THAN_SIGN;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this._emitChars(REPLACEMENT_CHARACTER);\n break;\n }\n case $.EOF: {\n this._emitEOFToken();\n break;\n }\n default: {\n this._emitCodePoint(cp);\n }\n }\n }\n // Script data state\n //------------------------------------------------------------------\n _stateScriptData(cp) {\n switch (cp) {\n case $.LESS_THAN_SIGN: {\n this.state = State.SCRIPT_DATA_LESS_THAN_SIGN;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this._emitChars(REPLACEMENT_CHARACTER);\n break;\n }\n case $.EOF: {\n this._emitEOFToken();\n break;\n }\n default: {\n this._emitCodePoint(cp);\n }\n }\n }\n // PLAINTEXT state\n //------------------------------------------------------------------\n _statePlaintext(cp) {\n switch (cp) {\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this._emitChars(REPLACEMENT_CHARACTER);\n break;\n }\n case $.EOF: {\n this._emitEOFToken();\n break;\n }\n default: {\n this._emitCodePoint(cp);\n }\n }\n }\n // Tag open state\n //------------------------------------------------------------------\n _stateTagOpen(cp) {\n if (isAsciiLetter(cp)) {\n this._createStartTagToken();\n this.state = State.TAG_NAME;\n this._stateTagName(cp);\n }\n else\n switch (cp) {\n case $.EXCLAMATION_MARK: {\n this.state = State.MARKUP_DECLARATION_OPEN;\n break;\n }\n case $.SOLIDUS: {\n this.state = State.END_TAG_OPEN;\n break;\n }\n case $.QUESTION_MARK: {\n this._err(ERR.unexpectedQuestionMarkInsteadOfTagName);\n this._createCommentToken(1);\n this.state = State.BOGUS_COMMENT;\n this._stateBogusComment(cp);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofBeforeTagName);\n this._emitChars('<');\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.invalidFirstCharacterOfTagName);\n this._emitChars('<');\n this.state = State.DATA;\n this._stateData(cp);\n }\n }\n }\n // End tag open state\n //------------------------------------------------------------------\n _stateEndTagOpen(cp) {\n if (isAsciiLetter(cp)) {\n this._createEndTagToken();\n this.state = State.TAG_NAME;\n this._stateTagName(cp);\n }\n else\n switch (cp) {\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.missingEndTagName);\n this.state = State.DATA;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofBeforeTagName);\n this._emitChars('');\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this.state = State.SCRIPT_DATA_ESCAPED;\n this._emitChars(REPLACEMENT_CHARACTER);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInScriptHtmlCommentLikeText);\n this._emitEOFToken();\n break;\n }\n default: {\n this.state = State.SCRIPT_DATA_ESCAPED;\n this._emitCodePoint(cp);\n }\n }\n }\n // Script data escaped less-than sign state\n //------------------------------------------------------------------\n _stateScriptDataEscapedLessThanSign(cp) {\n if (cp === $.SOLIDUS) {\n this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN;\n }\n else if (isAsciiLetter(cp)) {\n this._emitChars('<');\n this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_START;\n this._stateScriptDataDoubleEscapeStart(cp);\n }\n else {\n this._emitChars('<');\n this.state = State.SCRIPT_DATA_ESCAPED;\n this._stateScriptDataEscaped(cp);\n }\n }\n // Script data escaped end tag open state\n //------------------------------------------------------------------\n _stateScriptDataEscapedEndTagOpen(cp) {\n if (isAsciiLetter(cp)) {\n this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_NAME;\n this._stateScriptDataEscapedEndTagName(cp);\n }\n else {\n this._emitChars('');\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;\n this._emitChars(REPLACEMENT_CHARACTER);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInScriptHtmlCommentLikeText);\n this._emitEOFToken();\n break;\n }\n default: {\n this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;\n this._emitCodePoint(cp);\n }\n }\n }\n // Script data double escaped less-than sign state\n //------------------------------------------------------------------\n _stateScriptDataDoubleEscapedLessThanSign(cp) {\n if (cp === $.SOLIDUS) {\n this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_END;\n this._emitChars('/');\n }\n else {\n this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;\n this._stateScriptDataDoubleEscaped(cp);\n }\n }\n // Script data double escape end state\n //------------------------------------------------------------------\n _stateScriptDataDoubleEscapeEnd(cp) {\n if (this.preprocessor.startsWith($$.SCRIPT, false) &&\n isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek($$.SCRIPT.length))) {\n this._emitCodePoint(cp);\n for (let i = 0; i < $$.SCRIPT.length; i++) {\n this._emitCodePoint(this._consume());\n }\n this.state = State.SCRIPT_DATA_ESCAPED;\n }\n else if (!this._ensureHibernation()) {\n this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;\n this._stateScriptDataDoubleEscaped(cp);\n }\n }\n // Before attribute name state\n //------------------------------------------------------------------\n _stateBeforeAttributeName(cp) {\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n // Ignore whitespace\n break;\n }\n case $.SOLIDUS:\n case $.GREATER_THAN_SIGN:\n case $.EOF: {\n this.state = State.AFTER_ATTRIBUTE_NAME;\n this._stateAfterAttributeName(cp);\n break;\n }\n case $.EQUALS_SIGN: {\n this._err(ERR.unexpectedEqualsSignBeforeAttributeName);\n this._createAttr('=');\n this.state = State.ATTRIBUTE_NAME;\n break;\n }\n default: {\n this._createAttr('');\n this.state = State.ATTRIBUTE_NAME;\n this._stateAttributeName(cp);\n }\n }\n }\n // Attribute name state\n //------------------------------------------------------------------\n _stateAttributeName(cp) {\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED:\n case $.SOLIDUS:\n case $.GREATER_THAN_SIGN:\n case $.EOF: {\n this._leaveAttrName();\n this.state = State.AFTER_ATTRIBUTE_NAME;\n this._stateAfterAttributeName(cp);\n break;\n }\n case $.EQUALS_SIGN: {\n this._leaveAttrName();\n this.state = State.BEFORE_ATTRIBUTE_VALUE;\n break;\n }\n case $.QUOTATION_MARK:\n case $.APOSTROPHE:\n case $.LESS_THAN_SIGN: {\n this._err(ERR.unexpectedCharacterInAttributeName);\n this.currentAttr.name += String.fromCodePoint(cp);\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this.currentAttr.name += REPLACEMENT_CHARACTER;\n break;\n }\n default: {\n this.currentAttr.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);\n }\n }\n }\n // After attribute name state\n //------------------------------------------------------------------\n _stateAfterAttributeName(cp) {\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n // Ignore whitespace\n break;\n }\n case $.SOLIDUS: {\n this.state = State.SELF_CLOSING_START_TAG;\n break;\n }\n case $.EQUALS_SIGN: {\n this.state = State.BEFORE_ATTRIBUTE_VALUE;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this.state = State.DATA;\n this.emitCurrentTagToken();\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInTag);\n this._emitEOFToken();\n break;\n }\n default: {\n this._createAttr('');\n this.state = State.ATTRIBUTE_NAME;\n this._stateAttributeName(cp);\n }\n }\n }\n // Before attribute value state\n //------------------------------------------------------------------\n _stateBeforeAttributeValue(cp) {\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n // Ignore whitespace\n break;\n }\n case $.QUOTATION_MARK: {\n this.state = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;\n break;\n }\n case $.APOSTROPHE: {\n this.state = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.missingAttributeValue);\n this.state = State.DATA;\n this.emitCurrentTagToken();\n break;\n }\n default: {\n this.state = State.ATTRIBUTE_VALUE_UNQUOTED;\n this._stateAttributeValueUnquoted(cp);\n }\n }\n }\n // Attribute value (double-quoted) state\n //------------------------------------------------------------------\n _stateAttributeValueDoubleQuoted(cp) {\n switch (cp) {\n case $.QUOTATION_MARK: {\n this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;\n break;\n }\n case $.AMPERSAND: {\n this.returnState = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;\n this.state = State.CHARACTER_REFERENCE;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this.currentAttr.value += REPLACEMENT_CHARACTER;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInTag);\n this._emitEOFToken();\n break;\n }\n default: {\n this.currentAttr.value += String.fromCodePoint(cp);\n }\n }\n }\n // Attribute value (single-quoted) state\n //------------------------------------------------------------------\n _stateAttributeValueSingleQuoted(cp) {\n switch (cp) {\n case $.APOSTROPHE: {\n this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;\n break;\n }\n case $.AMPERSAND: {\n this.returnState = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;\n this.state = State.CHARACTER_REFERENCE;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this.currentAttr.value += REPLACEMENT_CHARACTER;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInTag);\n this._emitEOFToken();\n break;\n }\n default: {\n this.currentAttr.value += String.fromCodePoint(cp);\n }\n }\n }\n // Attribute value (unquoted) state\n //------------------------------------------------------------------\n _stateAttributeValueUnquoted(cp) {\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n this._leaveAttrValue();\n this.state = State.BEFORE_ATTRIBUTE_NAME;\n break;\n }\n case $.AMPERSAND: {\n this.returnState = State.ATTRIBUTE_VALUE_UNQUOTED;\n this.state = State.CHARACTER_REFERENCE;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._leaveAttrValue();\n this.state = State.DATA;\n this.emitCurrentTagToken();\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this.currentAttr.value += REPLACEMENT_CHARACTER;\n break;\n }\n case $.QUOTATION_MARK:\n case $.APOSTROPHE:\n case $.LESS_THAN_SIGN:\n case $.EQUALS_SIGN:\n case $.GRAVE_ACCENT: {\n this._err(ERR.unexpectedCharacterInUnquotedAttributeValue);\n this.currentAttr.value += String.fromCodePoint(cp);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInTag);\n this._emitEOFToken();\n break;\n }\n default: {\n this.currentAttr.value += String.fromCodePoint(cp);\n }\n }\n }\n // After attribute value (quoted) state\n //------------------------------------------------------------------\n _stateAfterAttributeValueQuoted(cp) {\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n this._leaveAttrValue();\n this.state = State.BEFORE_ATTRIBUTE_NAME;\n break;\n }\n case $.SOLIDUS: {\n this._leaveAttrValue();\n this.state = State.SELF_CLOSING_START_TAG;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._leaveAttrValue();\n this.state = State.DATA;\n this.emitCurrentTagToken();\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInTag);\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.missingWhitespaceBetweenAttributes);\n this.state = State.BEFORE_ATTRIBUTE_NAME;\n this._stateBeforeAttributeName(cp);\n }\n }\n }\n // Self-closing start tag state\n //------------------------------------------------------------------\n _stateSelfClosingStartTag(cp) {\n switch (cp) {\n case $.GREATER_THAN_SIGN: {\n const token = this.currentToken;\n token.selfClosing = true;\n this.state = State.DATA;\n this.emitCurrentTagToken();\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInTag);\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.unexpectedSolidusInTag);\n this.state = State.BEFORE_ATTRIBUTE_NAME;\n this._stateBeforeAttributeName(cp);\n }\n }\n }\n // Bogus comment state\n //------------------------------------------------------------------\n _stateBogusComment(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.GREATER_THAN_SIGN: {\n this.state = State.DATA;\n this.emitCurrentComment(token);\n break;\n }\n case $.EOF: {\n this.emitCurrentComment(token);\n this._emitEOFToken();\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n token.data += REPLACEMENT_CHARACTER;\n break;\n }\n default: {\n token.data += String.fromCodePoint(cp);\n }\n }\n }\n // Markup declaration open state\n //------------------------------------------------------------------\n _stateMarkupDeclarationOpen(cp) {\n if (this._consumeSequenceIfMatch($$.DASH_DASH, true)) {\n this._createCommentToken($$.DASH_DASH.length + 1);\n this.state = State.COMMENT_START;\n }\n else if (this._consumeSequenceIfMatch($$.DOCTYPE, false)) {\n // NOTE: Doctypes tokens are created without fixed offsets. We keep track of the moment a doctype *might* start here.\n this.currentLocation = this.getCurrentLocation($$.DOCTYPE.length + 1);\n this.state = State.DOCTYPE;\n }\n else if (this._consumeSequenceIfMatch($$.CDATA_START, true)) {\n if (this.inForeignNode) {\n this.state = State.CDATA_SECTION;\n }\n else {\n this._err(ERR.cdataInHtmlContent);\n this._createCommentToken($$.CDATA_START.length + 1);\n this.currentToken.data = '[CDATA[';\n this.state = State.BOGUS_COMMENT;\n }\n }\n //NOTE: Sequence lookups can be abrupted by hibernation. In that case, lookup\n //results are no longer valid and we will need to start over.\n else if (!this._ensureHibernation()) {\n this._err(ERR.incorrectlyOpenedComment);\n this._createCommentToken(2);\n this.state = State.BOGUS_COMMENT;\n this._stateBogusComment(cp);\n }\n }\n // Comment start state\n //------------------------------------------------------------------\n _stateCommentStart(cp) {\n switch (cp) {\n case $.HYPHEN_MINUS: {\n this.state = State.COMMENT_START_DASH;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.abruptClosingOfEmptyComment);\n this.state = State.DATA;\n const token = this.currentToken;\n this.emitCurrentComment(token);\n break;\n }\n default: {\n this.state = State.COMMENT;\n this._stateComment(cp);\n }\n }\n }\n // Comment start dash state\n //------------------------------------------------------------------\n _stateCommentStartDash(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.HYPHEN_MINUS: {\n this.state = State.COMMENT_END;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.abruptClosingOfEmptyComment);\n this.state = State.DATA;\n this.emitCurrentComment(token);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInComment);\n this.emitCurrentComment(token);\n this._emitEOFToken();\n break;\n }\n default: {\n token.data += '-';\n this.state = State.COMMENT;\n this._stateComment(cp);\n }\n }\n }\n // Comment state\n //------------------------------------------------------------------\n _stateComment(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.HYPHEN_MINUS: {\n this.state = State.COMMENT_END_DASH;\n break;\n }\n case $.LESS_THAN_SIGN: {\n token.data += '<';\n this.state = State.COMMENT_LESS_THAN_SIGN;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n token.data += REPLACEMENT_CHARACTER;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInComment);\n this.emitCurrentComment(token);\n this._emitEOFToken();\n break;\n }\n default: {\n token.data += String.fromCodePoint(cp);\n }\n }\n }\n // Comment less-than sign state\n //------------------------------------------------------------------\n _stateCommentLessThanSign(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.EXCLAMATION_MARK: {\n token.data += '!';\n this.state = State.COMMENT_LESS_THAN_SIGN_BANG;\n break;\n }\n case $.LESS_THAN_SIGN: {\n token.data += '<';\n break;\n }\n default: {\n this.state = State.COMMENT;\n this._stateComment(cp);\n }\n }\n }\n // Comment less-than sign bang state\n //------------------------------------------------------------------\n _stateCommentLessThanSignBang(cp) {\n if (cp === $.HYPHEN_MINUS) {\n this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH;\n }\n else {\n this.state = State.COMMENT;\n this._stateComment(cp);\n }\n }\n // Comment less-than sign bang dash state\n //------------------------------------------------------------------\n _stateCommentLessThanSignBangDash(cp) {\n if (cp === $.HYPHEN_MINUS) {\n this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH;\n }\n else {\n this.state = State.COMMENT_END_DASH;\n this._stateCommentEndDash(cp);\n }\n }\n // Comment less-than sign bang dash dash state\n //------------------------------------------------------------------\n _stateCommentLessThanSignBangDashDash(cp) {\n if (cp !== $.GREATER_THAN_SIGN && cp !== $.EOF) {\n this._err(ERR.nestedComment);\n }\n this.state = State.COMMENT_END;\n this._stateCommentEnd(cp);\n }\n // Comment end dash state\n //------------------------------------------------------------------\n _stateCommentEndDash(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.HYPHEN_MINUS: {\n this.state = State.COMMENT_END;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInComment);\n this.emitCurrentComment(token);\n this._emitEOFToken();\n break;\n }\n default: {\n token.data += '-';\n this.state = State.COMMENT;\n this._stateComment(cp);\n }\n }\n }\n // Comment end state\n //------------------------------------------------------------------\n _stateCommentEnd(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.GREATER_THAN_SIGN: {\n this.state = State.DATA;\n this.emitCurrentComment(token);\n break;\n }\n case $.EXCLAMATION_MARK: {\n this.state = State.COMMENT_END_BANG;\n break;\n }\n case $.HYPHEN_MINUS: {\n token.data += '-';\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInComment);\n this.emitCurrentComment(token);\n this._emitEOFToken();\n break;\n }\n default: {\n token.data += '--';\n this.state = State.COMMENT;\n this._stateComment(cp);\n }\n }\n }\n // Comment end bang state\n //------------------------------------------------------------------\n _stateCommentEndBang(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.HYPHEN_MINUS: {\n token.data += '--!';\n this.state = State.COMMENT_END_DASH;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.incorrectlyClosedComment);\n this.state = State.DATA;\n this.emitCurrentComment(token);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInComment);\n this.emitCurrentComment(token);\n this._emitEOFToken();\n break;\n }\n default: {\n token.data += '--!';\n this.state = State.COMMENT;\n this._stateComment(cp);\n }\n }\n }\n // DOCTYPE state\n //------------------------------------------------------------------\n _stateDoctype(cp) {\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n this.state = State.BEFORE_DOCTYPE_NAME;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this.state = State.BEFORE_DOCTYPE_NAME;\n this._stateBeforeDoctypeName(cp);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n this._createDoctypeToken(null);\n const token = this.currentToken;\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.missingWhitespaceBeforeDoctypeName);\n this.state = State.BEFORE_DOCTYPE_NAME;\n this._stateBeforeDoctypeName(cp);\n }\n }\n }\n // Before DOCTYPE name state\n //------------------------------------------------------------------\n _stateBeforeDoctypeName(cp) {\n if (isAsciiUpper(cp)) {\n this._createDoctypeToken(String.fromCharCode(toAsciiLower(cp)));\n this.state = State.DOCTYPE_NAME;\n }\n else\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n // Ignore whitespace\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n this._createDoctypeToken(REPLACEMENT_CHARACTER);\n this.state = State.DOCTYPE_NAME;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.missingDoctypeName);\n this._createDoctypeToken(null);\n const token = this.currentToken;\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this.state = State.DATA;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n this._createDoctypeToken(null);\n const token = this.currentToken;\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n this._createDoctypeToken(String.fromCodePoint(cp));\n this.state = State.DOCTYPE_NAME;\n }\n }\n }\n // DOCTYPE name state\n //------------------------------------------------------------------\n _stateDoctypeName(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n this.state = State.AFTER_DOCTYPE_NAME;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this.state = State.DATA;\n this.emitCurrentDoctype(token);\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n token.name += REPLACEMENT_CHARACTER;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n token.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);\n }\n }\n }\n // After DOCTYPE name state\n //------------------------------------------------------------------\n _stateAfterDoctypeName(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n // Ignore whitespace\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this.state = State.DATA;\n this.emitCurrentDoctype(token);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n if (this._consumeSequenceIfMatch($$.PUBLIC, false)) {\n this.state = State.AFTER_DOCTYPE_PUBLIC_KEYWORD;\n }\n else if (this._consumeSequenceIfMatch($$.SYSTEM, false)) {\n this.state = State.AFTER_DOCTYPE_SYSTEM_KEYWORD;\n }\n //NOTE: sequence lookup can be abrupted by hibernation. In that case lookup\n //results are no longer valid and we will need to start over.\n else if (!this._ensureHibernation()) {\n this._err(ERR.invalidCharacterSequenceAfterDoctypeName);\n token.forceQuirks = true;\n this.state = State.BOGUS_DOCTYPE;\n this._stateBogusDoctype(cp);\n }\n }\n }\n }\n // After DOCTYPE public keyword state\n //------------------------------------------------------------------\n _stateAfterDoctypePublicKeyword(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n this.state = State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;\n break;\n }\n case $.QUOTATION_MARK: {\n this._err(ERR.missingWhitespaceAfterDoctypePublicKeyword);\n token.publicId = '';\n this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;\n break;\n }\n case $.APOSTROPHE: {\n this._err(ERR.missingWhitespaceAfterDoctypePublicKeyword);\n token.publicId = '';\n this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.missingDoctypePublicIdentifier);\n token.forceQuirks = true;\n this.state = State.DATA;\n this.emitCurrentDoctype(token);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);\n token.forceQuirks = true;\n this.state = State.BOGUS_DOCTYPE;\n this._stateBogusDoctype(cp);\n }\n }\n }\n // Before DOCTYPE public identifier state\n //------------------------------------------------------------------\n _stateBeforeDoctypePublicIdentifier(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n // Ignore whitespace\n break;\n }\n case $.QUOTATION_MARK: {\n token.publicId = '';\n this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;\n break;\n }\n case $.APOSTROPHE: {\n token.publicId = '';\n this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.missingDoctypePublicIdentifier);\n token.forceQuirks = true;\n this.state = State.DATA;\n this.emitCurrentDoctype(token);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);\n token.forceQuirks = true;\n this.state = State.BOGUS_DOCTYPE;\n this._stateBogusDoctype(cp);\n }\n }\n }\n // DOCTYPE public identifier (double-quoted) state\n //------------------------------------------------------------------\n _stateDoctypePublicIdentifierDoubleQuoted(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.QUOTATION_MARK: {\n this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n token.publicId += REPLACEMENT_CHARACTER;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.abruptDoctypePublicIdentifier);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this.state = State.DATA;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n token.publicId += String.fromCodePoint(cp);\n }\n }\n }\n // DOCTYPE public identifier (single-quoted) state\n //------------------------------------------------------------------\n _stateDoctypePublicIdentifierSingleQuoted(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.APOSTROPHE: {\n this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n token.publicId += REPLACEMENT_CHARACTER;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.abruptDoctypePublicIdentifier);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this.state = State.DATA;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n token.publicId += String.fromCodePoint(cp);\n }\n }\n }\n // After DOCTYPE public identifier state\n //------------------------------------------------------------------\n _stateAfterDoctypePublicIdentifier(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n this.state = State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this.state = State.DATA;\n this.emitCurrentDoctype(token);\n break;\n }\n case $.QUOTATION_MARK: {\n this._err(ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);\n token.systemId = '';\n this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;\n break;\n }\n case $.APOSTROPHE: {\n this._err(ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);\n token.systemId = '';\n this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);\n token.forceQuirks = true;\n this.state = State.BOGUS_DOCTYPE;\n this._stateBogusDoctype(cp);\n }\n }\n }\n // Between DOCTYPE public and system identifiers state\n //------------------------------------------------------------------\n _stateBetweenDoctypePublicAndSystemIdentifiers(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n // Ignore whitespace\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this.emitCurrentDoctype(token);\n this.state = State.DATA;\n break;\n }\n case $.QUOTATION_MARK: {\n token.systemId = '';\n this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;\n break;\n }\n case $.APOSTROPHE: {\n token.systemId = '';\n this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);\n token.forceQuirks = true;\n this.state = State.BOGUS_DOCTYPE;\n this._stateBogusDoctype(cp);\n }\n }\n }\n // After DOCTYPE system keyword state\n //------------------------------------------------------------------\n _stateAfterDoctypeSystemKeyword(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n this.state = State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;\n break;\n }\n case $.QUOTATION_MARK: {\n this._err(ERR.missingWhitespaceAfterDoctypeSystemKeyword);\n token.systemId = '';\n this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;\n break;\n }\n case $.APOSTROPHE: {\n this._err(ERR.missingWhitespaceAfterDoctypeSystemKeyword);\n token.systemId = '';\n this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.missingDoctypeSystemIdentifier);\n token.forceQuirks = true;\n this.state = State.DATA;\n this.emitCurrentDoctype(token);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);\n token.forceQuirks = true;\n this.state = State.BOGUS_DOCTYPE;\n this._stateBogusDoctype(cp);\n }\n }\n }\n // Before DOCTYPE system identifier state\n //------------------------------------------------------------------\n _stateBeforeDoctypeSystemIdentifier(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n // Ignore whitespace\n break;\n }\n case $.QUOTATION_MARK: {\n token.systemId = '';\n this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;\n break;\n }\n case $.APOSTROPHE: {\n token.systemId = '';\n this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.missingDoctypeSystemIdentifier);\n token.forceQuirks = true;\n this.state = State.DATA;\n this.emitCurrentDoctype(token);\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);\n token.forceQuirks = true;\n this.state = State.BOGUS_DOCTYPE;\n this._stateBogusDoctype(cp);\n }\n }\n }\n // DOCTYPE system identifier (double-quoted) state\n //------------------------------------------------------------------\n _stateDoctypeSystemIdentifierDoubleQuoted(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.QUOTATION_MARK: {\n this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n token.systemId += REPLACEMENT_CHARACTER;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.abruptDoctypeSystemIdentifier);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this.state = State.DATA;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n token.systemId += String.fromCodePoint(cp);\n }\n }\n }\n // DOCTYPE system identifier (single-quoted) state\n //------------------------------------------------------------------\n _stateDoctypeSystemIdentifierSingleQuoted(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.APOSTROPHE: {\n this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n token.systemId += REPLACEMENT_CHARACTER;\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this._err(ERR.abruptDoctypeSystemIdentifier);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this.state = State.DATA;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n token.systemId += String.fromCodePoint(cp);\n }\n }\n }\n // After DOCTYPE system identifier state\n //------------------------------------------------------------------\n _stateAfterDoctypeSystemIdentifier(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.SPACE:\n case $.LINE_FEED:\n case $.TABULATION:\n case $.FORM_FEED: {\n // Ignore whitespace\n break;\n }\n case $.GREATER_THAN_SIGN: {\n this.emitCurrentDoctype(token);\n this.state = State.DATA;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInDoctype);\n token.forceQuirks = true;\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default: {\n this._err(ERR.unexpectedCharacterAfterDoctypeSystemIdentifier);\n this.state = State.BOGUS_DOCTYPE;\n this._stateBogusDoctype(cp);\n }\n }\n }\n // Bogus DOCTYPE state\n //------------------------------------------------------------------\n _stateBogusDoctype(cp) {\n const token = this.currentToken;\n switch (cp) {\n case $.GREATER_THAN_SIGN: {\n this.emitCurrentDoctype(token);\n this.state = State.DATA;\n break;\n }\n case $.NULL: {\n this._err(ERR.unexpectedNullCharacter);\n break;\n }\n case $.EOF: {\n this.emitCurrentDoctype(token);\n this._emitEOFToken();\n break;\n }\n default:\n // Do nothing\n }\n }\n // CDATA section state\n //------------------------------------------------------------------\n _stateCdataSection(cp) {\n switch (cp) {\n case $.RIGHT_SQUARE_BRACKET: {\n this.state = State.CDATA_SECTION_BRACKET;\n break;\n }\n case $.EOF: {\n this._err(ERR.eofInCdata);\n this._emitEOFToken();\n break;\n }\n default: {\n this._emitCodePoint(cp);\n }\n }\n }\n // CDATA section bracket state\n //------------------------------------------------------------------\n _stateCdataSectionBracket(cp) {\n if (cp === $.RIGHT_SQUARE_BRACKET) {\n this.state = State.CDATA_SECTION_END;\n }\n else {\n this._emitChars(']');\n this.state = State.CDATA_SECTION;\n this._stateCdataSection(cp);\n }\n }\n // CDATA section end state\n //------------------------------------------------------------------\n _stateCdataSectionEnd(cp) {\n switch (cp) {\n case $.GREATER_THAN_SIGN: {\n this.state = State.DATA;\n break;\n }\n case $.RIGHT_SQUARE_BRACKET: {\n this._emitChars(']');\n break;\n }\n default: {\n this._emitChars(']]');\n this.state = State.CDATA_SECTION;\n this._stateCdataSection(cp);\n }\n }\n }\n // Character reference state\n //------------------------------------------------------------------\n _stateCharacterReference(cp) {\n if (cp === $.NUMBER_SIGN) {\n this.state = State.NUMERIC_CHARACTER_REFERENCE;\n }\n else if (isAsciiAlphaNumeric(cp)) {\n this.state = State.NAMED_CHARACTER_REFERENCE;\n this._stateNamedCharacterReference(cp);\n }\n else {\n this._flushCodePointConsumedAsCharacterReference($.AMPERSAND);\n this._reconsumeInState(this.returnState, cp);\n }\n }\n // Named character reference state\n //------------------------------------------------------------------\n _stateNamedCharacterReference(cp) {\n const matchResult = this._matchNamedCharacterReference(cp);\n //NOTE: Matching can be abrupted by hibernation. In that case, match\n //results are no longer valid and we will need to start over.\n if (this._ensureHibernation()) {\n // Stay in the state, try again.\n }\n else if (matchResult) {\n for (let i = 0; i < matchResult.length; i++) {\n this._flushCodePointConsumedAsCharacterReference(matchResult[i]);\n }\n this.state = this.returnState;\n }\n else {\n this._flushCodePointConsumedAsCharacterReference($.AMPERSAND);\n this.state = State.AMBIGUOUS_AMPERSAND;\n }\n }\n // Ambiguos ampersand state\n //------------------------------------------------------------------\n _stateAmbiguousAmpersand(cp) {\n if (isAsciiAlphaNumeric(cp)) {\n this._flushCodePointConsumedAsCharacterReference(cp);\n }\n else {\n if (cp === $.SEMICOLON) {\n this._err(ERR.unknownNamedCharacterReference);\n }\n this._reconsumeInState(this.returnState, cp);\n }\n }\n // Numeric character reference state\n //------------------------------------------------------------------\n _stateNumericCharacterReference(cp) {\n this.charRefCode = 0;\n if (cp === $.LATIN_SMALL_X || cp === $.LATIN_CAPITAL_X) {\n this.state = State.HEXADEMICAL_CHARACTER_REFERENCE_START;\n }\n // Inlined decimal character reference start state\n else if (isAsciiDigit(cp)) {\n this.state = State.DECIMAL_CHARACTER_REFERENCE;\n this._stateDecimalCharacterReference(cp);\n }\n else {\n this._err(ERR.absenceOfDigitsInNumericCharacterReference);\n this._flushCodePointConsumedAsCharacterReference($.AMPERSAND);\n this._flushCodePointConsumedAsCharacterReference($.NUMBER_SIGN);\n this._reconsumeInState(this.returnState, cp);\n }\n }\n // Hexademical character reference start state\n //------------------------------------------------------------------\n _stateHexademicalCharacterReferenceStart(cp) {\n if (isAsciiHexDigit(cp)) {\n this.state = State.HEXADEMICAL_CHARACTER_REFERENCE;\n this._stateHexademicalCharacterReference(cp);\n }\n else {\n this._err(ERR.absenceOfDigitsInNumericCharacterReference);\n this._flushCodePointConsumedAsCharacterReference($.AMPERSAND);\n this._flushCodePointConsumedAsCharacterReference($.NUMBER_SIGN);\n this._unconsume(2);\n this.state = this.returnState;\n }\n }\n // Hexademical character reference state\n //------------------------------------------------------------------\n _stateHexademicalCharacterReference(cp) {\n if (isAsciiUpperHexDigit(cp)) {\n this.charRefCode = this.charRefCode * 16 + cp - 0x37;\n }\n else if (isAsciiLowerHexDigit(cp)) {\n this.charRefCode = this.charRefCode * 16 + cp - 0x57;\n }\n else if (isAsciiDigit(cp)) {\n this.charRefCode = this.charRefCode * 16 + cp - 0x30;\n }\n else if (cp === $.SEMICOLON) {\n this.state = State.NUMERIC_CHARACTER_REFERENCE_END;\n }\n else {\n this._err(ERR.missingSemicolonAfterCharacterReference);\n this.state = State.NUMERIC_CHARACTER_REFERENCE_END;\n this._stateNumericCharacterReferenceEnd(cp);\n }\n }\n // Decimal character reference state\n //------------------------------------------------------------------\n _stateDecimalCharacterReference(cp) {\n if (isAsciiDigit(cp)) {\n this.charRefCode = this.charRefCode * 10 + cp - 0x30;\n }\n else if (cp === $.SEMICOLON) {\n this.state = State.NUMERIC_CHARACTER_REFERENCE_END;\n }\n else {\n this._err(ERR.missingSemicolonAfterCharacterReference);\n this.state = State.NUMERIC_CHARACTER_REFERENCE_END;\n this._stateNumericCharacterReferenceEnd(cp);\n }\n }\n // Numeric character reference end state\n //------------------------------------------------------------------\n _stateNumericCharacterReferenceEnd(cp) {\n if (this.charRefCode === $.NULL) {\n this._err(ERR.nullCharacterReference);\n this.charRefCode = $.REPLACEMENT_CHARACTER;\n }\n else if (this.charRefCode > 1114111) {\n this._err(ERR.characterReferenceOutsideUnicodeRange);\n this.charRefCode = $.REPLACEMENT_CHARACTER;\n }\n else if (isSurrogate(this.charRefCode)) {\n this._err(ERR.surrogateCharacterReference);\n this.charRefCode = $.REPLACEMENT_CHARACTER;\n }\n else if (isUndefinedCodePoint(this.charRefCode)) {\n this._err(ERR.noncharacterCharacterReference);\n }\n else if (isControlCodePoint(this.charRefCode) || this.charRefCode === $.CARRIAGE_RETURN) {\n this._err(ERR.controlCharacterReference);\n const replacement = C1_CONTROLS_REFERENCE_REPLACEMENTS.get(this.charRefCode);\n if (replacement !== undefined) {\n this.charRefCode = replacement;\n }\n }\n this._flushCodePointConsumedAsCharacterReference(this.charRefCode);\n this._reconsumeInState(this.returnState, cp);\n }\n}\n//# sourceMappingURL=index.js.map","import { TAG_ID as $, NS, isNumberedHeader } from '../common/html.js';\n//Element utils\nconst IMPLICIT_END_TAG_REQUIRED = new Set([$.DD, $.DT, $.LI, $.OPTGROUP, $.OPTION, $.P, $.RB, $.RP, $.RT, $.RTC]);\nconst IMPLICIT_END_TAG_REQUIRED_THOROUGHLY = new Set([\n ...IMPLICIT_END_TAG_REQUIRED,\n $.CAPTION,\n $.COLGROUP,\n $.TBODY,\n $.TD,\n $.TFOOT,\n $.TH,\n $.THEAD,\n $.TR,\n]);\nconst SCOPING_ELEMENT_NS = new Map([\n [$.APPLET, NS.HTML],\n [$.CAPTION, NS.HTML],\n [$.HTML, NS.HTML],\n [$.MARQUEE, NS.HTML],\n [$.OBJECT, NS.HTML],\n [$.TABLE, NS.HTML],\n [$.TD, NS.HTML],\n [$.TEMPLATE, NS.HTML],\n [$.TH, NS.HTML],\n [$.ANNOTATION_XML, NS.MATHML],\n [$.MI, NS.MATHML],\n [$.MN, NS.MATHML],\n [$.MO, NS.MATHML],\n [$.MS, NS.MATHML],\n [$.MTEXT, NS.MATHML],\n [$.DESC, NS.SVG],\n [$.FOREIGN_OBJECT, NS.SVG],\n [$.TITLE, NS.SVG],\n]);\nconst NAMED_HEADERS = [$.H1, $.H2, $.H3, $.H4, $.H5, $.H6];\nconst TABLE_ROW_CONTEXT = [$.TR, $.TEMPLATE, $.HTML];\nconst TABLE_BODY_CONTEXT = [$.TBODY, $.TFOOT, $.THEAD, $.TEMPLATE, $.HTML];\nconst TABLE_CONTEXT = [$.TABLE, $.TEMPLATE, $.HTML];\nconst TABLE_CELLS = [$.TD, $.TH];\n//Stack of open elements\nexport class OpenElementStack {\n get currentTmplContentOrNode() {\n return this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : this.current;\n }\n constructor(document, treeAdapter, handler) {\n this.treeAdapter = treeAdapter;\n this.handler = handler;\n this.items = [];\n this.tagIDs = [];\n this.stackTop = -1;\n this.tmplCount = 0;\n this.currentTagId = $.UNKNOWN;\n this.current = document;\n }\n //Index of element\n _indexOf(element) {\n return this.items.lastIndexOf(element, this.stackTop);\n }\n //Update current element\n _isInTemplate() {\n return this.currentTagId === $.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML;\n }\n _updateCurrentElement() {\n this.current = this.items[this.stackTop];\n this.currentTagId = this.tagIDs[this.stackTop];\n }\n //Mutations\n push(element, tagID) {\n this.stackTop++;\n this.items[this.stackTop] = element;\n this.current = element;\n this.tagIDs[this.stackTop] = tagID;\n this.currentTagId = tagID;\n if (this._isInTemplate()) {\n this.tmplCount++;\n }\n this.handler.onItemPush(element, tagID, true);\n }\n pop() {\n const popped = this.current;\n if (this.tmplCount > 0 && this._isInTemplate()) {\n this.tmplCount--;\n }\n this.stackTop--;\n this._updateCurrentElement();\n this.handler.onItemPop(popped, true);\n }\n replace(oldElement, newElement) {\n const idx = this._indexOf(oldElement);\n this.items[idx] = newElement;\n if (idx === this.stackTop) {\n this.current = newElement;\n }\n }\n insertAfter(referenceElement, newElement, newElementID) {\n const insertionIdx = this._indexOf(referenceElement) + 1;\n this.items.splice(insertionIdx, 0, newElement);\n this.tagIDs.splice(insertionIdx, 0, newElementID);\n this.stackTop++;\n if (insertionIdx === this.stackTop) {\n this._updateCurrentElement();\n }\n this.handler.onItemPush(this.current, this.currentTagId, insertionIdx === this.stackTop);\n }\n popUntilTagNamePopped(tagName) {\n let targetIdx = this.stackTop + 1;\n do {\n targetIdx = this.tagIDs.lastIndexOf(tagName, targetIdx - 1);\n } while (targetIdx > 0 && this.treeAdapter.getNamespaceURI(this.items[targetIdx]) !== NS.HTML);\n this.shortenToLength(targetIdx < 0 ? 0 : targetIdx);\n }\n shortenToLength(idx) {\n while (this.stackTop >= idx) {\n const popped = this.current;\n if (this.tmplCount > 0 && this._isInTemplate()) {\n this.tmplCount -= 1;\n }\n this.stackTop--;\n this._updateCurrentElement();\n this.handler.onItemPop(popped, this.stackTop < idx);\n }\n }\n popUntilElementPopped(element) {\n const idx = this._indexOf(element);\n this.shortenToLength(idx < 0 ? 0 : idx);\n }\n popUntilPopped(tagNames, targetNS) {\n const idx = this._indexOfTagNames(tagNames, targetNS);\n this.shortenToLength(idx < 0 ? 0 : idx);\n }\n popUntilNumberedHeaderPopped() {\n this.popUntilPopped(NAMED_HEADERS, NS.HTML);\n }\n popUntilTableCellPopped() {\n this.popUntilPopped(TABLE_CELLS, NS.HTML);\n }\n popAllUpToHtmlElement() {\n //NOTE: here we assume that the root element is always first in the open element stack, so\n //we perform this fast stack clean up.\n this.tmplCount = 0;\n this.shortenToLength(1);\n }\n _indexOfTagNames(tagNames, namespace) {\n for (let i = this.stackTop; i >= 0; i--) {\n if (tagNames.includes(this.tagIDs[i]) && this.treeAdapter.getNamespaceURI(this.items[i]) === namespace) {\n return i;\n }\n }\n return -1;\n }\n clearBackTo(tagNames, targetNS) {\n const idx = this._indexOfTagNames(tagNames, targetNS);\n this.shortenToLength(idx + 1);\n }\n clearBackToTableContext() {\n this.clearBackTo(TABLE_CONTEXT, NS.HTML);\n }\n clearBackToTableBodyContext() {\n this.clearBackTo(TABLE_BODY_CONTEXT, NS.HTML);\n }\n clearBackToTableRowContext() {\n this.clearBackTo(TABLE_ROW_CONTEXT, NS.HTML);\n }\n remove(element) {\n const idx = this._indexOf(element);\n if (idx >= 0) {\n if (idx === this.stackTop) {\n this.pop();\n }\n else {\n this.items.splice(idx, 1);\n this.tagIDs.splice(idx, 1);\n this.stackTop--;\n this._updateCurrentElement();\n this.handler.onItemPop(element, false);\n }\n }\n }\n //Search\n tryPeekProperlyNestedBodyElement() {\n //Properly nested element (should be second element in stack).\n return this.stackTop >= 1 && this.tagIDs[1] === $.BODY ? this.items[1] : null;\n }\n contains(element) {\n return this._indexOf(element) > -1;\n }\n getCommonAncestor(element) {\n const elementIdx = this._indexOf(element) - 1;\n return elementIdx >= 0 ? this.items[elementIdx] : null;\n }\n isRootHtmlElementCurrent() {\n return this.stackTop === 0 && this.tagIDs[0] === $.HTML;\n }\n //Element in scope\n hasInScope(tagName) {\n for (let i = this.stackTop; i >= 0; i--) {\n const tn = this.tagIDs[i];\n const ns = this.treeAdapter.getNamespaceURI(this.items[i]);\n if (tn === tagName && ns === NS.HTML) {\n return true;\n }\n if (SCOPING_ELEMENT_NS.get(tn) === ns) {\n return false;\n }\n }\n return true;\n }\n hasNumberedHeaderInScope() {\n for (let i = this.stackTop; i >= 0; i--) {\n const tn = this.tagIDs[i];\n const ns = this.treeAdapter.getNamespaceURI(this.items[i]);\n if (isNumberedHeader(tn) && ns === NS.HTML) {\n return true;\n }\n if (SCOPING_ELEMENT_NS.get(tn) === ns) {\n return false;\n }\n }\n return true;\n }\n hasInListItemScope(tagName) {\n for (let i = this.stackTop; i >= 0; i--) {\n const tn = this.tagIDs[i];\n const ns = this.treeAdapter.getNamespaceURI(this.items[i]);\n if (tn === tagName && ns === NS.HTML) {\n return true;\n }\n if (((tn === $.UL || tn === $.OL) && ns === NS.HTML) || SCOPING_ELEMENT_NS.get(tn) === ns) {\n return false;\n }\n }\n return true;\n }\n hasInButtonScope(tagName) {\n for (let i = this.stackTop; i >= 0; i--) {\n const tn = this.tagIDs[i];\n const ns = this.treeAdapter.getNamespaceURI(this.items[i]);\n if (tn === tagName && ns === NS.HTML) {\n return true;\n }\n if ((tn === $.BUTTON && ns === NS.HTML) || SCOPING_ELEMENT_NS.get(tn) === ns) {\n return false;\n }\n }\n return true;\n }\n hasInTableScope(tagName) {\n for (let i = this.stackTop; i >= 0; i--) {\n const tn = this.tagIDs[i];\n const ns = this.treeAdapter.getNamespaceURI(this.items[i]);\n if (ns !== NS.HTML) {\n continue;\n }\n if (tn === tagName) {\n return true;\n }\n if (tn === $.TABLE || tn === $.TEMPLATE || tn === $.HTML) {\n return false;\n }\n }\n return true;\n }\n hasTableBodyContextInTableScope() {\n for (let i = this.stackTop; i >= 0; i--) {\n const tn = this.tagIDs[i];\n const ns = this.treeAdapter.getNamespaceURI(this.items[i]);\n if (ns !== NS.HTML) {\n continue;\n }\n if (tn === $.TBODY || tn === $.THEAD || tn === $.TFOOT) {\n return true;\n }\n if (tn === $.TABLE || tn === $.HTML) {\n return false;\n }\n }\n return true;\n }\n hasInSelectScope(tagName) {\n for (let i = this.stackTop; i >= 0; i--) {\n const tn = this.tagIDs[i];\n const ns = this.treeAdapter.getNamespaceURI(this.items[i]);\n if (ns !== NS.HTML) {\n continue;\n }\n if (tn === tagName) {\n return true;\n }\n if (tn !== $.OPTION && tn !== $.OPTGROUP) {\n return false;\n }\n }\n return true;\n }\n //Implied end tags\n generateImpliedEndTags() {\n while (IMPLICIT_END_TAG_REQUIRED.has(this.currentTagId)) {\n this.pop();\n }\n }\n generateImpliedEndTagsThoroughly() {\n while (IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) {\n this.pop();\n }\n }\n generateImpliedEndTagsWithExclusion(exclusionId) {\n while (this.currentTagId !== exclusionId && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) {\n this.pop();\n }\n }\n}\n//# sourceMappingURL=open-element-stack.js.map","//Const\nconst NOAH_ARK_CAPACITY = 3;\nexport var EntryType;\n(function (EntryType) {\n EntryType[EntryType[\"Marker\"] = 0] = \"Marker\";\n EntryType[EntryType[\"Element\"] = 1] = \"Element\";\n})(EntryType = EntryType || (EntryType = {}));\nconst MARKER = { type: EntryType.Marker };\n//List of formatting elements\nexport class FormattingElementList {\n constructor(treeAdapter) {\n this.treeAdapter = treeAdapter;\n this.entries = [];\n this.bookmark = null;\n }\n //Noah Ark's condition\n //OPTIMIZATION: at first we try to find possible candidates for exclusion using\n //lightweight heuristics without thorough attributes check.\n _getNoahArkConditionCandidates(newElement, neAttrs) {\n const candidates = [];\n const neAttrsLength = neAttrs.length;\n const neTagName = this.treeAdapter.getTagName(newElement);\n const neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement);\n for (let i = 0; i < this.entries.length; i++) {\n const entry = this.entries[i];\n if (entry.type === EntryType.Marker) {\n break;\n }\n const { element } = entry;\n if (this.treeAdapter.getTagName(element) === neTagName &&\n this.treeAdapter.getNamespaceURI(element) === neNamespaceURI) {\n const elementAttrs = this.treeAdapter.getAttrList(element);\n if (elementAttrs.length === neAttrsLength) {\n candidates.push({ idx: i, attrs: elementAttrs });\n }\n }\n }\n return candidates;\n }\n _ensureNoahArkCondition(newElement) {\n if (this.entries.length < NOAH_ARK_CAPACITY)\n return;\n const neAttrs = this.treeAdapter.getAttrList(newElement);\n const candidates = this._getNoahArkConditionCandidates(newElement, neAttrs);\n if (candidates.length < NOAH_ARK_CAPACITY)\n return;\n //NOTE: build attrs map for the new element, so we can perform fast lookups\n const neAttrsMap = new Map(neAttrs.map((neAttr) => [neAttr.name, neAttr.value]));\n let validCandidates = 0;\n //NOTE: remove bottommost candidates, until Noah's Ark condition will not be met\n for (let i = 0; i < candidates.length; i++) {\n const candidate = candidates[i];\n // We know that `candidate.attrs.length === neAttrs.length`\n if (candidate.attrs.every((cAttr) => neAttrsMap.get(cAttr.name) === cAttr.value)) {\n validCandidates += 1;\n if (validCandidates >= NOAH_ARK_CAPACITY) {\n this.entries.splice(candidate.idx, 1);\n }\n }\n }\n }\n //Mutations\n insertMarker() {\n this.entries.unshift(MARKER);\n }\n pushElement(element, token) {\n this._ensureNoahArkCondition(element);\n this.entries.unshift({\n type: EntryType.Element,\n element,\n token,\n });\n }\n insertElementAfterBookmark(element, token) {\n const bookmarkIdx = this.entries.indexOf(this.bookmark);\n this.entries.splice(bookmarkIdx, 0, {\n type: EntryType.Element,\n element,\n token,\n });\n }\n removeEntry(entry) {\n const entryIndex = this.entries.indexOf(entry);\n if (entryIndex >= 0) {\n this.entries.splice(entryIndex, 1);\n }\n }\n /**\n * Clears the list of formatting elements up to the last marker.\n *\n * @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker\n */\n clearToLastMarker() {\n const markerIdx = this.entries.indexOf(MARKER);\n if (markerIdx >= 0) {\n this.entries.splice(0, markerIdx + 1);\n }\n else {\n this.entries.length = 0;\n }\n }\n //Search\n getElementEntryInScopeWithTagName(tagName) {\n const entry = this.entries.find((entry) => entry.type === EntryType.Marker || this.treeAdapter.getTagName(entry.element) === tagName);\n return entry && entry.type === EntryType.Element ? entry : null;\n }\n getElementEntry(element) {\n return this.entries.find((entry) => entry.type === EntryType.Element && entry.element === element);\n }\n}\n//# sourceMappingURL=formatting-element-list.js.map","import { DOCUMENT_MODE } from '../common/html.js';\nfunction createTextNode(value) {\n return {\n nodeName: '#text',\n value,\n parentNode: null,\n };\n}\nexport const defaultTreeAdapter = {\n //Node construction\n createDocument() {\n return {\n nodeName: '#document',\n mode: DOCUMENT_MODE.NO_QUIRKS,\n childNodes: [],\n };\n },\n createDocumentFragment() {\n return {\n nodeName: '#document-fragment',\n childNodes: [],\n };\n },\n createElement(tagName, namespaceURI, attrs) {\n return {\n nodeName: tagName,\n tagName,\n attrs,\n namespaceURI,\n childNodes: [],\n parentNode: null,\n };\n },\n createCommentNode(data) {\n return {\n nodeName: '#comment',\n data,\n parentNode: null,\n };\n },\n //Tree mutation\n appendChild(parentNode, newNode) {\n parentNode.childNodes.push(newNode);\n newNode.parentNode = parentNode;\n },\n insertBefore(parentNode, newNode, referenceNode) {\n const insertionIdx = parentNode.childNodes.indexOf(referenceNode);\n parentNode.childNodes.splice(insertionIdx, 0, newNode);\n newNode.parentNode = parentNode;\n },\n setTemplateContent(templateElement, contentElement) {\n templateElement.content = contentElement;\n },\n getTemplateContent(templateElement) {\n return templateElement.content;\n },\n setDocumentType(document, name, publicId, systemId) {\n const doctypeNode = document.childNodes.find((node) => node.nodeName === '#documentType');\n if (doctypeNode) {\n doctypeNode.name = name;\n doctypeNode.publicId = publicId;\n doctypeNode.systemId = systemId;\n }\n else {\n const node = {\n nodeName: '#documentType',\n name,\n publicId,\n systemId,\n parentNode: null,\n };\n defaultTreeAdapter.appendChild(document, node);\n }\n },\n setDocumentMode(document, mode) {\n document.mode = mode;\n },\n getDocumentMode(document) {\n return document.mode;\n },\n detachNode(node) {\n if (node.parentNode) {\n const idx = node.parentNode.childNodes.indexOf(node);\n node.parentNode.childNodes.splice(idx, 1);\n node.parentNode = null;\n }\n },\n insertText(parentNode, text) {\n if (parentNode.childNodes.length > 0) {\n const prevNode = parentNode.childNodes[parentNode.childNodes.length - 1];\n if (defaultTreeAdapter.isTextNode(prevNode)) {\n prevNode.value += text;\n return;\n }\n }\n defaultTreeAdapter.appendChild(parentNode, createTextNode(text));\n },\n insertTextBefore(parentNode, text, referenceNode) {\n const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];\n if (prevNode && defaultTreeAdapter.isTextNode(prevNode)) {\n prevNode.value += text;\n }\n else {\n defaultTreeAdapter.insertBefore(parentNode, createTextNode(text), referenceNode);\n }\n },\n adoptAttributes(recipient, attrs) {\n const recipientAttrsMap = new Set(recipient.attrs.map((attr) => attr.name));\n for (let j = 0; j < attrs.length; j++) {\n if (!recipientAttrsMap.has(attrs[j].name)) {\n recipient.attrs.push(attrs[j]);\n }\n }\n },\n //Tree traversing\n getFirstChild(node) {\n return node.childNodes[0];\n },\n getChildNodes(node) {\n return node.childNodes;\n },\n getParentNode(node) {\n return node.parentNode;\n },\n getAttrList(element) {\n return element.attrs;\n },\n //Node data\n getTagName(element) {\n return element.tagName;\n },\n getNamespaceURI(element) {\n return element.namespaceURI;\n },\n getTextNodeContent(textNode) {\n return textNode.value;\n },\n getCommentNodeContent(commentNode) {\n return commentNode.data;\n },\n getDocumentTypeNodeName(doctypeNode) {\n return doctypeNode.name;\n },\n getDocumentTypeNodePublicId(doctypeNode) {\n return doctypeNode.publicId;\n },\n getDocumentTypeNodeSystemId(doctypeNode) {\n return doctypeNode.systemId;\n },\n //Node types\n isTextNode(node) {\n return node.nodeName === '#text';\n },\n isCommentNode(node) {\n return node.nodeName === '#comment';\n },\n isDocumentTypeNode(node) {\n return node.nodeName === '#documentType';\n },\n isElementNode(node) {\n return Object.prototype.hasOwnProperty.call(node, 'tagName');\n },\n // Source code location\n setNodeSourceCodeLocation(node, location) {\n node.sourceCodeLocation = location;\n },\n getNodeSourceCodeLocation(node) {\n return node.sourceCodeLocation;\n },\n updateNodeSourceCodeLocation(node, endLocation) {\n node.sourceCodeLocation = { ...node.sourceCodeLocation, ...endLocation };\n },\n};\n//# sourceMappingURL=default.js.map","import { DOCUMENT_MODE } from './html.js';\n//Const\nconst VALID_DOCTYPE_NAME = 'html';\nconst VALID_SYSTEM_ID = 'about:legacy-compat';\nconst QUIRKS_MODE_SYSTEM_ID = 'http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd';\nconst QUIRKS_MODE_PUBLIC_ID_PREFIXES = [\n '+//silmaril//dtd html pro v0r11 19970101//',\n '-//as//dtd html 3.0 aswedit + extensions//',\n '-//advasoft ltd//dtd html 3.0 aswedit + extensions//',\n '-//ietf//dtd html 2.0 level 1//',\n '-//ietf//dtd html 2.0 level 2//',\n '-//ietf//dtd html 2.0 strict level 1//',\n '-//ietf//dtd html 2.0 strict level 2//',\n '-//ietf//dtd html 2.0 strict//',\n '-//ietf//dtd html 2.0//',\n '-//ietf//dtd html 2.1e//',\n '-//ietf//dtd html 3.0//',\n '-//ietf//dtd html 3.2 final//',\n '-//ietf//dtd html 3.2//',\n '-//ietf//dtd html 3//',\n '-//ietf//dtd html level 0//',\n '-//ietf//dtd html level 1//',\n '-//ietf//dtd html level 2//',\n '-//ietf//dtd html level 3//',\n '-//ietf//dtd html strict level 0//',\n '-//ietf//dtd html strict level 1//',\n '-//ietf//dtd html strict level 2//',\n '-//ietf//dtd html strict level 3//',\n '-//ietf//dtd html strict//',\n '-//ietf//dtd html//',\n '-//metrius//dtd metrius presentational//',\n '-//microsoft//dtd internet explorer 2.0 html strict//',\n '-//microsoft//dtd internet explorer 2.0 html//',\n '-//microsoft//dtd internet explorer 2.0 tables//',\n '-//microsoft//dtd internet explorer 3.0 html strict//',\n '-//microsoft//dtd internet explorer 3.0 html//',\n '-//microsoft//dtd internet explorer 3.0 tables//',\n '-//netscape comm. corp.//dtd html//',\n '-//netscape comm. corp.//dtd strict html//',\n \"-//o'reilly and associates//dtd html 2.0//\",\n \"-//o'reilly and associates//dtd html extended 1.0//\",\n \"-//o'reilly and associates//dtd html extended relaxed 1.0//\",\n '-//sq//dtd html 2.0 hotmetal + extensions//',\n '-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//',\n '-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//',\n '-//spyglass//dtd html 2.0 extended//',\n '-//sun microsystems corp.//dtd hotjava html//',\n '-//sun microsystems corp.//dtd hotjava strict html//',\n '-//w3c//dtd html 3 1995-03-24//',\n '-//w3c//dtd html 3.2 draft//',\n '-//w3c//dtd html 3.2 final//',\n '-//w3c//dtd html 3.2//',\n '-//w3c//dtd html 3.2s draft//',\n '-//w3c//dtd html 4.0 frameset//',\n '-//w3c//dtd html 4.0 transitional//',\n '-//w3c//dtd html experimental 19960712//',\n '-//w3c//dtd html experimental 970421//',\n '-//w3c//dtd w3 html//',\n '-//w3o//dtd w3 html 3.0//',\n '-//webtechs//dtd mozilla html 2.0//',\n '-//webtechs//dtd mozilla html//',\n];\nconst QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES = [\n ...QUIRKS_MODE_PUBLIC_ID_PREFIXES,\n '-//w3c//dtd html 4.01 frameset//',\n '-//w3c//dtd html 4.01 transitional//',\n];\nconst QUIRKS_MODE_PUBLIC_IDS = new Set([\n '-//w3o//dtd w3 html strict 3.0//en//',\n '-/w3c/dtd html 4.0 transitional/en',\n 'html',\n]);\nconst LIMITED_QUIRKS_PUBLIC_ID_PREFIXES = ['-//w3c//dtd xhtml 1.0 frameset//', '-//w3c//dtd xhtml 1.0 transitional//'];\nconst LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES = [\n ...LIMITED_QUIRKS_PUBLIC_ID_PREFIXES,\n '-//w3c//dtd html 4.01 frameset//',\n '-//w3c//dtd html 4.01 transitional//',\n];\n//Utils\nfunction hasPrefix(publicId, prefixes) {\n return prefixes.some((prefix) => publicId.startsWith(prefix));\n}\n//API\nexport function isConforming(token) {\n return (token.name === VALID_DOCTYPE_NAME &&\n token.publicId === null &&\n (token.systemId === null || token.systemId === VALID_SYSTEM_ID));\n}\nexport function getDocumentMode(token) {\n if (token.name !== VALID_DOCTYPE_NAME) {\n return DOCUMENT_MODE.QUIRKS;\n }\n const { systemId } = token;\n if (systemId && systemId.toLowerCase() === QUIRKS_MODE_SYSTEM_ID) {\n return DOCUMENT_MODE.QUIRKS;\n }\n let { publicId } = token;\n if (publicId !== null) {\n publicId = publicId.toLowerCase();\n if (QUIRKS_MODE_PUBLIC_IDS.has(publicId)) {\n return DOCUMENT_MODE.QUIRKS;\n }\n let prefixes = systemId === null ? QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES : QUIRKS_MODE_PUBLIC_ID_PREFIXES;\n if (hasPrefix(publicId, prefixes)) {\n return DOCUMENT_MODE.QUIRKS;\n }\n prefixes =\n systemId === null ? LIMITED_QUIRKS_PUBLIC_ID_PREFIXES : LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES;\n if (hasPrefix(publicId, prefixes)) {\n return DOCUMENT_MODE.LIMITED_QUIRKS;\n }\n }\n return DOCUMENT_MODE.NO_QUIRKS;\n}\n//# sourceMappingURL=doctype.js.map","import { TAG_ID as $, NS, ATTRS, getTagID } from './html.js';\n//MIME types\nconst MIME_TYPES = {\n TEXT_HTML: 'text/html',\n APPLICATION_XML: 'application/xhtml+xml',\n};\n//Attributes\nconst DEFINITION_URL_ATTR = 'definitionurl';\nconst ADJUSTED_DEFINITION_URL_ATTR = 'definitionURL';\nconst SVG_ATTRS_ADJUSTMENT_MAP = new Map([\n 'attributeName',\n 'attributeType',\n 'baseFrequency',\n 'baseProfile',\n 'calcMode',\n 'clipPathUnits',\n 'diffuseConstant',\n 'edgeMode',\n 'filterUnits',\n 'glyphRef',\n 'gradientTransform',\n 'gradientUnits',\n 'kernelMatrix',\n 'kernelUnitLength',\n 'keyPoints',\n 'keySplines',\n 'keyTimes',\n 'lengthAdjust',\n 'limitingConeAngle',\n 'markerHeight',\n 'markerUnits',\n 'markerWidth',\n 'maskContentUnits',\n 'maskUnits',\n 'numOctaves',\n 'pathLength',\n 'patternContentUnits',\n 'patternTransform',\n 'patternUnits',\n 'pointsAtX',\n 'pointsAtY',\n 'pointsAtZ',\n 'preserveAlpha',\n 'preserveAspectRatio',\n 'primitiveUnits',\n 'refX',\n 'refY',\n 'repeatCount',\n 'repeatDur',\n 'requiredExtensions',\n 'requiredFeatures',\n 'specularConstant',\n 'specularExponent',\n 'spreadMethod',\n 'startOffset',\n 'stdDeviation',\n 'stitchTiles',\n 'surfaceScale',\n 'systemLanguage',\n 'tableValues',\n 'targetX',\n 'targetY',\n 'textLength',\n 'viewBox',\n 'viewTarget',\n 'xChannelSelector',\n 'yChannelSelector',\n 'zoomAndPan',\n].map((attr) => [attr.toLowerCase(), attr]));\nconst XML_ATTRS_ADJUSTMENT_MAP = new Map([\n ['xlink:actuate', { prefix: 'xlink', name: 'actuate', namespace: NS.XLINK }],\n ['xlink:arcrole', { prefix: 'xlink', name: 'arcrole', namespace: NS.XLINK }],\n ['xlink:href', { prefix: 'xlink', name: 'href', namespace: NS.XLINK }],\n ['xlink:role', { prefix: 'xlink', name: 'role', namespace: NS.XLINK }],\n ['xlink:show', { prefix: 'xlink', name: 'show', namespace: NS.XLINK }],\n ['xlink:title', { prefix: 'xlink', name: 'title', namespace: NS.XLINK }],\n ['xlink:type', { prefix: 'xlink', name: 'type', namespace: NS.XLINK }],\n ['xml:base', { prefix: 'xml', name: 'base', namespace: NS.XML }],\n ['xml:lang', { prefix: 'xml', name: 'lang', namespace: NS.XML }],\n ['xml:space', { prefix: 'xml', name: 'space', namespace: NS.XML }],\n ['xmlns', { prefix: '', name: 'xmlns', namespace: NS.XMLNS }],\n ['xmlns:xlink', { prefix: 'xmlns', name: 'xlink', namespace: NS.XMLNS }],\n]);\n//SVG tag names adjustment map\nexport const SVG_TAG_NAMES_ADJUSTMENT_MAP = new Map([\n 'altGlyph',\n 'altGlyphDef',\n 'altGlyphItem',\n 'animateColor',\n 'animateMotion',\n 'animateTransform',\n 'clipPath',\n 'feBlend',\n 'feColorMatrix',\n 'feComponentTransfer',\n 'feComposite',\n 'feConvolveMatrix',\n 'feDiffuseLighting',\n 'feDisplacementMap',\n 'feDistantLight',\n 'feFlood',\n 'feFuncA',\n 'feFuncB',\n 'feFuncG',\n 'feFuncR',\n 'feGaussianBlur',\n 'feImage',\n 'feMerge',\n 'feMergeNode',\n 'feMorphology',\n 'feOffset',\n 'fePointLight',\n 'feSpecularLighting',\n 'feSpotLight',\n 'feTile',\n 'feTurbulence',\n 'foreignObject',\n 'glyphRef',\n 'linearGradient',\n 'radialGradient',\n 'textPath',\n].map((tn) => [tn.toLowerCase(), tn]));\n//Tags that causes exit from foreign content\nconst EXITS_FOREIGN_CONTENT = new Set([\n $.B,\n $.BIG,\n $.BLOCKQUOTE,\n $.BODY,\n $.BR,\n $.CENTER,\n $.CODE,\n $.DD,\n $.DIV,\n $.DL,\n $.DT,\n $.EM,\n $.EMBED,\n $.H1,\n $.H2,\n $.H3,\n $.H4,\n $.H5,\n $.H6,\n $.HEAD,\n $.HR,\n $.I,\n $.IMG,\n $.LI,\n $.LISTING,\n $.MENU,\n $.META,\n $.NOBR,\n $.OL,\n $.P,\n $.PRE,\n $.RUBY,\n $.S,\n $.SMALL,\n $.SPAN,\n $.STRONG,\n $.STRIKE,\n $.SUB,\n $.SUP,\n $.TABLE,\n $.TT,\n $.U,\n $.UL,\n $.VAR,\n]);\n//Check exit from foreign content\nexport function causesExit(startTagToken) {\n const tn = startTagToken.tagID;\n const isFontWithAttrs = tn === $.FONT &&\n startTagToken.attrs.some(({ name }) => name === ATTRS.COLOR || name === ATTRS.SIZE || name === ATTRS.FACE);\n return isFontWithAttrs || EXITS_FOREIGN_CONTENT.has(tn);\n}\n//Token adjustments\nexport function adjustTokenMathMLAttrs(token) {\n for (let i = 0; i < token.attrs.length; i++) {\n if (token.attrs[i].name === DEFINITION_URL_ATTR) {\n token.attrs[i].name = ADJUSTED_DEFINITION_URL_ATTR;\n break;\n }\n }\n}\nexport function adjustTokenSVGAttrs(token) {\n for (let i = 0; i < token.attrs.length; i++) {\n const adjustedAttrName = SVG_ATTRS_ADJUSTMENT_MAP.get(token.attrs[i].name);\n if (adjustedAttrName != null) {\n token.attrs[i].name = adjustedAttrName;\n }\n }\n}\nexport function adjustTokenXMLAttrs(token) {\n for (let i = 0; i < token.attrs.length; i++) {\n const adjustedAttrEntry = XML_ATTRS_ADJUSTMENT_MAP.get(token.attrs[i].name);\n if (adjustedAttrEntry) {\n token.attrs[i].prefix = adjustedAttrEntry.prefix;\n token.attrs[i].name = adjustedAttrEntry.name;\n token.attrs[i].namespace = adjustedAttrEntry.namespace;\n }\n }\n}\nexport function adjustTokenSVGTagName(token) {\n const adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP.get(token.tagName);\n if (adjustedTagName != null) {\n token.tagName = adjustedTagName;\n token.tagID = getTagID(token.tagName);\n }\n}\n//Integration points\nfunction isMathMLTextIntegrationPoint(tn, ns) {\n return ns === NS.MATHML && (tn === $.MI || tn === $.MO || tn === $.MN || tn === $.MS || tn === $.MTEXT);\n}\nfunction isHtmlIntegrationPoint(tn, ns, attrs) {\n if (ns === NS.MATHML && tn === $.ANNOTATION_XML) {\n for (let i = 0; i < attrs.length; i++) {\n if (attrs[i].name === ATTRS.ENCODING) {\n const value = attrs[i].value.toLowerCase();\n return value === MIME_TYPES.TEXT_HTML || value === MIME_TYPES.APPLICATION_XML;\n }\n }\n }\n return ns === NS.SVG && (tn === $.FOREIGN_OBJECT || tn === $.DESC || tn === $.TITLE);\n}\nexport function isIntegrationPoint(tn, ns, attrs, foreignNS) {\n return (((!foreignNS || foreignNS === NS.HTML) && isHtmlIntegrationPoint(tn, ns, attrs)) ||\n ((!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns)));\n}\n//# sourceMappingURL=foreign-content.js.map","import { Tokenizer, TokenizerMode } from '../tokenizer/index.js';\nimport { OpenElementStack } from './open-element-stack.js';\nimport { FormattingElementList, EntryType } from './formatting-element-list.js';\nimport { defaultTreeAdapter } from '../tree-adapters/default.js';\nimport * as doctype from '../common/doctype.js';\nimport * as foreignContent from '../common/foreign-content.js';\nimport { ERR } from '../common/error-codes.js';\nimport * as unicode from '../common/unicode.js';\nimport { TAG_ID as $, TAG_NAMES as TN, NS, ATTRS, SPECIAL_ELEMENTS, DOCUMENT_MODE, isNumberedHeader, getTagID, } from '../common/html.js';\nimport { TokenType, getTokenAttr, } from '../common/token.js';\n//Misc constants\nconst HIDDEN_INPUT_TYPE = 'hidden';\n//Adoption agency loops iteration count\nconst AA_OUTER_LOOP_ITER = 8;\nconst AA_INNER_LOOP_ITER = 3;\n//Insertion modes\nvar InsertionMode;\n(function (InsertionMode) {\n InsertionMode[InsertionMode[\"INITIAL\"] = 0] = \"INITIAL\";\n InsertionMode[InsertionMode[\"BEFORE_HTML\"] = 1] = \"BEFORE_HTML\";\n InsertionMode[InsertionMode[\"BEFORE_HEAD\"] = 2] = \"BEFORE_HEAD\";\n InsertionMode[InsertionMode[\"IN_HEAD\"] = 3] = \"IN_HEAD\";\n InsertionMode[InsertionMode[\"IN_HEAD_NO_SCRIPT\"] = 4] = \"IN_HEAD_NO_SCRIPT\";\n InsertionMode[InsertionMode[\"AFTER_HEAD\"] = 5] = \"AFTER_HEAD\";\n InsertionMode[InsertionMode[\"IN_BODY\"] = 6] = \"IN_BODY\";\n InsertionMode[InsertionMode[\"TEXT\"] = 7] = \"TEXT\";\n InsertionMode[InsertionMode[\"IN_TABLE\"] = 8] = \"IN_TABLE\";\n InsertionMode[InsertionMode[\"IN_TABLE_TEXT\"] = 9] = \"IN_TABLE_TEXT\";\n InsertionMode[InsertionMode[\"IN_CAPTION\"] = 10] = \"IN_CAPTION\";\n InsertionMode[InsertionMode[\"IN_COLUMN_GROUP\"] = 11] = \"IN_COLUMN_GROUP\";\n InsertionMode[InsertionMode[\"IN_TABLE_BODY\"] = 12] = \"IN_TABLE_BODY\";\n InsertionMode[InsertionMode[\"IN_ROW\"] = 13] = \"IN_ROW\";\n InsertionMode[InsertionMode[\"IN_CELL\"] = 14] = \"IN_CELL\";\n InsertionMode[InsertionMode[\"IN_SELECT\"] = 15] = \"IN_SELECT\";\n InsertionMode[InsertionMode[\"IN_SELECT_IN_TABLE\"] = 16] = \"IN_SELECT_IN_TABLE\";\n InsertionMode[InsertionMode[\"IN_TEMPLATE\"] = 17] = \"IN_TEMPLATE\";\n InsertionMode[InsertionMode[\"AFTER_BODY\"] = 18] = \"AFTER_BODY\";\n InsertionMode[InsertionMode[\"IN_FRAMESET\"] = 19] = \"IN_FRAMESET\";\n InsertionMode[InsertionMode[\"AFTER_FRAMESET\"] = 20] = \"AFTER_FRAMESET\";\n InsertionMode[InsertionMode[\"AFTER_AFTER_BODY\"] = 21] = \"AFTER_AFTER_BODY\";\n InsertionMode[InsertionMode[\"AFTER_AFTER_FRAMESET\"] = 22] = \"AFTER_AFTER_FRAMESET\";\n})(InsertionMode || (InsertionMode = {}));\nconst BASE_LOC = {\n startLine: -1,\n startCol: -1,\n startOffset: -1,\n endLine: -1,\n endCol: -1,\n endOffset: -1,\n};\nconst TABLE_STRUCTURE_TAGS = new Set([$.TABLE, $.TBODY, $.TFOOT, $.THEAD, $.TR]);\nconst defaultParserOptions = {\n scriptingEnabled: true,\n sourceCodeLocationInfo: false,\n treeAdapter: defaultTreeAdapter,\n onParseError: null,\n};\n//Parser\nexport class Parser {\n constructor(options, document, fragmentContext = null, scriptHandler = null) {\n this.fragmentContext = fragmentContext;\n this.scriptHandler = scriptHandler;\n this.currentToken = null;\n this.stopped = false;\n this.insertionMode = InsertionMode.INITIAL;\n this.originalInsertionMode = InsertionMode.INITIAL;\n this.headElement = null;\n this.formElement = null;\n /** Indicates that the current node is not an element in the HTML namespace */\n this.currentNotInHTML = false;\n /**\n * The template insertion mode stack is maintained from the left.\n * Ie. the topmost element will always have index 0.\n */\n this.tmplInsertionModeStack = [];\n this.pendingCharacterTokens = [];\n this.hasNonWhitespacePendingCharacterToken = false;\n this.framesetOk = true;\n this.skipNextNewLine = false;\n this.fosterParentingEnabled = false;\n this.options = {\n ...defaultParserOptions,\n ...options,\n };\n this.treeAdapter = this.options.treeAdapter;\n this.onParseError = this.options.onParseError;\n // Always enable location info if we report parse errors.\n if (this.onParseError) {\n this.options.sourceCodeLocationInfo = true;\n }\n this.document = document !== null && document !== void 0 ? document : this.treeAdapter.createDocument();\n this.tokenizer = new Tokenizer(this.options, this);\n this.activeFormattingElements = new FormattingElementList(this.treeAdapter);\n this.fragmentContextID = fragmentContext ? getTagID(this.treeAdapter.getTagName(fragmentContext)) : $.UNKNOWN;\n this._setContextModes(fragmentContext !== null && fragmentContext !== void 0 ? fragmentContext : this.document, this.fragmentContextID);\n this.openElements = new OpenElementStack(this.document, this.treeAdapter, this);\n }\n // API\n static parse(html, options) {\n const parser = new this(options);\n parser.tokenizer.write(html, true);\n return parser.document;\n }\n static getFragmentParser(fragmentContext, options) {\n const opts = {\n ...defaultParserOptions,\n ...options,\n };\n //NOTE: use a