import{n as f}from"./micromark-util-sanitize-uri-nvkIJkgW.js";import{p as b,a as x,b as C}from"./unist-util-position-KiAvrw8y.js";import{t as L}from"./trim-lines-D8znQY54.js";import{d as P}from"./mdast-util-definitions-CfSXY7bG.js";import{v as B}from"./unist-util-visit-SwKB2sUE.js";import{g as I}from"./unist-util-generated-CMz5gPdA.js";function A(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function O(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:` `}]}function S(t,e){const n=e.value?e.value+` `:"",r=e.lang?e.lang.match(/^[^ \t]+(?=[ \t]|$)/):null,i={};r&&(i.className=["language-"+r]);let a={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return e.meta&&(a.data={meta:e.meta}),t.patch(e,a),a=t.applyData(e,a),a={type:"element",tagName:"pre",properties:{},children:[a]},t.patch(e,a),a}function R(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function T(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function v(t,e){const n=String(e.identifier).toUpperCase(),r=f(n.toLowerCase()),i=t.footnoteOrder.indexOf(n);let a;i===-1?(t.footnoteOrder.push(n),t.footnoteCounts[n]=1,a=t.footnoteOrder.length):(t.footnoteCounts[n]++,a=i+1);const l=t.footnoteCounts[n],u={type:"element",tagName:"a",properties:{href:"#"+t.clobberPrefix+"fn-"+r,id:t.clobberPrefix+"fnref-"+r+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};t.patch(e,u);const s={type:"element",tagName:"sup",properties:{},children:[u]};return t.patch(e,s),t.applyData(e,s)}function H(t,e){const n=t.footnoteById;let r=1;for(;r in n;)r++;const i=String(r);return n[i]={type:"footnoteDefinition",identifier:i,children:[{type:"paragraph",children:e.children}],position:e.position},v(t,{type:"footnoteReference",identifier:i,position:e.position})}function U(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function F(t,e){if(t.dangerous){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}return null}function w(t,e){const n=e.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return{type:"text",value:"!["+e.alt+r};const i=t.all(e),a=i[0];a&&a.type==="text"?a.value="["+a.value:i.unshift({type:"text",value:"["});const l=i[i.length-1];return l&&l.type==="text"?l.value+=r:i.push({type:"text",value:r}),i}function E(t,e){const n=t.definition(e.identifier);if(!n)return w(t,e);const r={src:f(n.url||""),alt:e.alt};n.title!==null&&n.title!==void 0&&(r.title=n.title);const i={type:"element",tagName:"img",properties:r,children:[]};return t.patch(e,i),t.applyData(e,i)}function q(t,e){const n={src:f(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,r),t.applyData(e,r)}function J(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,r),t.applyData(e,r)}function z(t,e){const n=t.definition(e.identifier);if(!n)return w(t,e);const r={href:f(n.url||"")};n.title!==null&&n.title!==void 0&&(r.title=n.title);const i={type:"element",tagName:"a",properties:r,children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function V(t,e){const n={href:f(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function $(t,e,n){const r=t.all(e),i=n?j(n):D(e),a={},l=[];if(typeof e.checked=="boolean"){const o=r[0];let p;o&&o.type==="element"&&o.tagName==="p"?p=o:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let u=-1;for(;++u1}function G(t,e){const n={},r=t.all(e);let i=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++i0){const l={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},u=b(e.children[1]),s=x(e.children[e.children.length-1]);u.line&&s.line&&(l.position={start:u,end:s}),i.push(l)}const a={type:"element",tagName:"table",properties:{},children:t.wrap(i,!0)};return t.patch(e,a),t.applyData(e,a)}function X(t,e,n){const r=n?n.children:void 0,a=(r?r.indexOf(e):1)===0?"th":"td",l=n&&n.type==="table"?n.align:void 0,u=l?l.length:e.children.length;let s=-1;const c=[];for(;++s{const o=String(c.identifier).toUpperCase();d.call(i,o)||(i[o]=c)}),l;function a(c,o){if(c&&"data"in c&&c.data){const p=c.data;p.hName&&(o.type!=="element"&&(o={type:"element",tagName:"",properties:{},children:[]}),o.tagName=p.hName),o.type==="element"&&p.hProperties&&(o.properties={...o.properties,...p.hProperties}),"children"in o&&o.children&&p.hChildren&&(o.children=p.hChildren)}if(c){const p="type"in c?c:{position:c};I(p)||(o.position={start:b(p),end:x(p)})}return o}function l(c,o,p,h){return Array.isArray(p)&&(h=p,p={}),a(c,{type:"element",tagName:o,properties:p||{},children:h||[]})}function u(c,o){return k(l,c,o)}function s(c){return g(l,c)}}function ne(t,e){t.position&&(e.position=C(t))}function re(t,e){let n=e;if(t&&t.data){const r=t.data.hName,i=t.data.hChildren,a=t.data.hProperties;typeof r=="string"&&(n.type==="element"?n.tagName=r:n={type:"element",tagName:r,properties:{},children:[]}),n.type==="element"&&a&&(n.properties={...n.properties,...a}),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function k(t,e,n){const r=e&&e.type;if(!r)throw new Error("Expected node, got `"+e+"`");return d.call(t.handlers,r)?t.handlers[r](t,e,n):t.passThrough&&t.passThrough.includes(r)?"children"in e?{...e,children:g(t,e)}:e:t.unknownHandler?t.unknownHandler(t,e,n):le(t,e)}function g(t,e){const n=[];if("children"in e){const r=e.children;let i=-1;for(;++i0&&n.push({type:"text",value:` `}),n}function ae(t){const e=[];let n=-1;for(;++n1?"-"+u:""),dataFootnoteBackref:!0,className:["data-footnote-backref"],ariaLabel:t.footnoteBackLabel},children:[{type:"text",value:"↩"}]};u>1&&p.children.push({type:"element",tagName:"sup",children:[{type:"text",value:String(u)}]}),s.length>0&&s.push({type:"text",value:" "}),s.push(p)}const c=i[i.length-1];if(c&&c.type==="element"&&c.tagName==="p"){const p=c.children[c.children.length-1];p&&p.type==="text"?p.value+=" ":c.children.push({type:"text",value:" "}),c.children.push(...s)}else i.push(...s);const o={type:"element",tagName:"li",properties:{id:t.clobberPrefix+"fn-"+l},children:t.wrap(i,!0)};t.patch(r,o),e.push(o)}if(e.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:t.footnoteLabelTagName,properties:{...JSON.parse(JSON.stringify(t.footnoteLabelProperties)),id:"footnote-label"},children:[{type:"text",value:t.footnoteLabel}]},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:t.wrap(e,!0)},{type:"text",value:` `}]}}function he(t,e){const n=te(t,e),r=n.one(t,null),i=ae(n);return i&&r.children.push({type:"text",value:` `},i),Array.isArray(r)?{type:"root",children:r}:r}export{he as t};