import{f as g}from"./vendor-micromark-factory-space-BM4zcA-B.js";import{m as O,f as R,j as P}from"./vendor-micromark-util-character-Cn8n62xE.js";class N{constructor(){this.map=[]}add(n,i,r){x(this,n,i,r)}consume(n){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let i=this.map.length;const r=[];for(;i>0;)i-=1,r.push(n.slice(this.map[i][0]+this.map[i][1]),this.map[i][2]),n.length=this.map[i][0];r.push(n.slice()),n.length=0;let a=r.pop();for(;a;){for(const l of a)n.push(l);a=r.pop()}this.map.length=0}}function x(t,n,i,r){let a=0;if(!(i===0&&r.length===0)){for(;a-1;){const M=r.events[o][1].type;if(M==="lineEnding"||M==="linePrefix")o--;else break}const S=o>-1?r.events[o][1].type:null,z=S==="tableHead"||S==="tableRow"?H:h;return z===H&&r.parser.lazy[r.now().line]?i(e):z(e)}function h(e){return t.enter("tableHead"),t.enter("tableRow"),D(e)}function D(e){return e===124||(u=!0,l+=1),p(e)}function p(e){return e===null?i(e):O(e)?l>1?(l=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(e),t.exit("lineEnding"),f):i(e):R(e)?g(t,p,"whitespace")(e):(l+=1,u&&(u=!1,a+=1),e===124?(t.enter("tableCellDivider"),t.consume(e),t.exit("tableCellDivider"),u=!0,p):(t.enter("data"),b(e)))}function b(e){return e===null||e===124||P(e)?(t.exit("data"),p(e)):(t.consume(e),e===92?m:b)}function m(e){return e===92||e===124?(t.consume(e),b):b(e)}function f(e){return r.interrupt=!1,r.parser.lazy[r.now().line]?i(e):(t.enter("tableDelimiterRow"),u=!1,R(e)?g(t,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(e):s(e))}function s(e){return e===45||e===58?A(e):e===124?(u=!0,t.enter("tableCellDivider"),t.consume(e),t.exit("tableCellDivider"),T):d(e)}function T(e){return R(e)?g(t,A,"whitespace")(e):A(e)}function A(e){return e===58?(l+=1,u=!0,t.enter("tableDelimiterMarker"),t.consume(e),t.exit("tableDelimiterMarker"),E):e===45?(l+=1,E(e)):e===null||O(e)?C(e):d(e)}function E(e){return e===45?(t.enter("tableDelimiterFiller"),B(e)):d(e)}function B(e){return e===45?(t.consume(e),B):e===58?(u=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(e),t.exit("tableDelimiterMarker"),F):(t.exit("tableDelimiterFiller"),F(e))}function F(e){return R(e)?g(t,C,"whitespace")(e):C(e)}function C(e){return e===124?s(e):e===null||O(e)?!u||a!==l?d(e):(t.exit("tableDelimiterRow"),t.exit("tableHead"),n(e)):d(e)}function d(e){return i(e)}function H(e){return t.enter("tableRow"),k(e)}function k(e){return e===124?(t.enter("tableCellDivider"),t.consume(e),t.exit("tableCellDivider"),k):e===null||O(e)?(t.exit("tableRow"),n(e)):R(e)?g(t,k,"whitespace")(e):(t.enter("data"),j(e))}function j(e){return e===null||e===124||P(e)?(t.exit("data"),k(e)):(t.consume(e),e===92?L:j)}function L(e){return e===92||e===124?(t.consume(e),j):j(e)}}function q(t,n){let i=-1,r=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],w=!1,h=0,D,p,b;const m=new N;for(;++ii[2]+1){const s=i[2]+1,T=i[3]-i[2]-1;t.add(s,T,[])}}t.add(i[3]+1,0,[["exit",b,n]])}return a!==void 0&&(l.end=Object.assign({},y(n.events,a)),t.add(a,0,[["exit",l,n]]),l=void 0),l}function I(t,n,i,r,a){const l=[],u=y(n.events,i);a&&(a.end=Object.assign({},u),l.push(["exit",a,n])),r.end=Object.assign({},u),l.push(["exit",r,n]),t.add(i+1,0,l)}function y(t,n){const i=t[n],r=i[0]==="enter"?"start":"end";return i[1][r]}export{Q as g};