@limetech/lime-elements 40.20.0 → 40.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/limel-chart.cjs.entry.js +29 -18
  3. package/dist/cjs/limel-markdown.cjs.entry.js +2 -2
  4. package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +1 -1
  5. package/dist/cjs/{markdown-exporter-BWS2EBxq.js → markdown-exporter-CGNfjGr9.js} +80 -897
  6. package/dist/cjs/{markdown-parser-toAp9-Eq.js → markdown-parser-C14XF_G3.js} +994 -38
  7. package/dist/collection/components/chart/chart.css +20 -5
  8. package/dist/collection/components/chart/chart.js +3 -0
  9. package/dist/collection/components/chart/options.js +12 -16
  10. package/dist/collection/components/chart/theme.js +13 -1
  11. package/dist/esm/limel-chart.entry.js +29 -18
  12. package/dist/esm/limel-markdown.entry.js +2 -2
  13. package/dist/esm/limel-prosemirror-adapter.entry.js +1 -1
  14. package/dist/esm/{markdown-exporter-B2vFxSLw.js → markdown-exporter-DcFcD699.js} +80 -897
  15. package/dist/esm/{markdown-parser-Cw8iW5R9.js → markdown-parser-8aHA9IYo.js} +991 -33
  16. package/dist/lime-elements/lime-elements.esm.js +1 -1
  17. package/dist/lime-elements/{p-8514480b.entry.js → p-0887e0df.entry.js} +2 -2
  18. package/dist/lime-elements/{p-1d9bc526.entry.js → p-9edd79a8.entry.js} +1 -1
  19. package/dist/lime-elements/p-C9gctvIB.js +1 -0
  20. package/dist/lime-elements/{p-c2f993cc.entry.js → p-a891f3e8.entry.js} +1 -1
  21. package/dist/lime-elements/p-kiQd8Ntf.js +7 -0
  22. package/dist/types/components/chart/theme.d.ts +2 -2
  23. package/package.json +3 -3
  24. package/dist/lime-elements/p-Bd37Vplf.js +0 -7
  25. package/dist/lime-elements/p-CvHpvp0f.js +0 -1
@@ -1 +0,0 @@
1
- import{z as t,w as n,y as e,A as r,i as o,C as i,g as c,v as a,E as s,S as u,h as l,u as f}from"./p-CbPYnlF-.js";import{a as d,b as p,h,c as m,f as g,d as b,e as y,i as v,j as k,k as w,p as x,l as C,n as S,t as B,r as A,o as E}from"./p-Bd37Vplf.js";import"./p-B85MJLTf.js";const F={}.hasOwnProperty;function L(t,n){let e,r=-1;if(n.extensions)for(;++r<n.extensions.length;)L(t,n.extensions[r]);for(e in n)if(F.call(n,e))switch(e){case"extensions":break;case"unsafe":case"join":o=t[e],(i=n[e])&&o.push(...i);break;case"handlers":M(t[e],n[e]);break;default:t.options[e]=n[e]}var o,i;return t}function M(t,n){n&&Object.assign(t,n)}function z(t){if(60!==t.charCodeAt(0))return;const n=t.charCodeAt(1);if(33===n){const n=t.charCodeAt(2);return 45===n?2:91===n?5:d(n)?4:void 0}if(63===n)return 3;const e=47===n,r=e?2:1;let o=r,i=t.charCodeAt(o);if(!d(i))return;for(;45===i||p(i);)i=t.charCodeAt(++o);const c=t.slice(r,o).toLowerCase();return!e&&47!==i&&h.includes(c)?1:m.includes(c)?6:7}const T=[function(t,n,e,r){if("code"===n.type&&g(n,r)&&("list"===t.type||t.type===n.type&&g(t,r)))return!1;if("spread"in e&&"boolean"==typeof e.spread){if("paragraph"===t.type&&(t.type===n.type||"definition"===n.type||"heading"===n.type&&b(n,r)))return;if("html"===t.type){const n=z(t.value);if(void 0===n||6===n||7===n)return 1}if("paragraph"===t.type&&"html"===n.type){const t=z(n.value);if(void 0===t||7===t)return 1}return e.spread?1:0}}],j=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],I=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\r",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\r",after:"\\r",inConstruct:"phrasing"},{character:"\n",before:"\\n",inConstruct:"phrasing"},{character:"\n",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:j},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:j},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:j},{atBreak:!0,character:"+",after:"(?:[ \t\r\n])"},{atBreak:!0,character:"-",after:"(?:[ \t\r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \t\r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:j},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:j},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:j},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:j},{atBreak:!0,character:"~"},{character:"<",inConstruct:"autolink"},{character:">",inConstruct:"autolink"},{character:"",inConstruct:"autolink"}];let N=-1;for(;++N<33;)I.push({character:String.fromCharCode(N),inConstruct:"autolink"});function R(t){return t.label||!t.identifier?t.label||"":y(t.identifier)}function q(t){if(!t._compiled){const n=(t.atBreak?"[\\r\\n][\\t ]*":"")+(t.before?"(?:"+t.before+")":"");t._compiled=new RegExp((t.beforeNode?"^":n?"("+n+")":"")+(/[$()*+.?[\\\]^{|}]/.test(t.character)?"\\":"")+t.character+(t.afterNode?"$":t.after?"(?:"+t.after+")":""),t.unicode?"gu":"g")}return t._compiled}function G(t){const n=t.codePointAt(0);return void 0===n?"":String.fromCodePoint(n)}function _(t){const n=t.codePointAt(t.length-2);return t.slice(void 0!==n&&n>65535?-2:-1)}function $(t,n,e){const r=v(t),o=v(n);return void 0===r?void 0===o?"_"===e?{inside:!0,outside:!0}:{inside:!1,outside:!1}:1===o?{inside:!0,outside:!0}:{inside:!1,outside:!0}:1===r?void 0===o?{inside:!1,outside:!1}:1===o?{inside:!0,outside:!0}:{inside:!1,outside:!1}:void 0===o?{inside:!1,outside:!1}:1===o?{inside:!0,outside:!1}:{inside:!1,outside:!1}}const P=new Map([["*",!1],["_",!0]]);function U(t,n,e){const r=new Set;for(const o of t){const t=e.get(o);if(t&&o.attention&&n.some((t=>t.attention===o.attention)))for(const n of t.tokens)r.add(n.attention)}const o=[];for(const n of t)n.attention&&r.delete(n.attention)&&o.push(n.attention);return o.reverse(),o}function Z(t,n,e){const r=[],o=new Map,i=new Map;let c=0;for(;c<t.length;){if(!t[c].attention){c++;continue}const a=t[c].value.charAt(0),s=P.get(a);let u=c+1;for(;u<t.length&&t[u].attention&&t[u].value.charAt(0)===a;)u++;const l=c?t[c-1].value:n,f=v(l.charCodeAt(l.length-1)),d=v((u<t.length?t[u].value:e).charCodeAt(0)),p=!d||2===d&&Boolean(f),h=!f||2===f&&Boolean(d),m={tokens:t.slice(c,u),markers:[],start:0,end:0,open:s?p&&(Boolean(f)||!h):p,close:s?h&&(Boolean(d)||!p):h,split:void 0!==s};for(const t of m.tokens){o.set(t,[...m.tokens]),i.set(t,m);let n=t.value.length;for(;n--;)m.markers.push(t)}m.end=m.markers.length,r.push(m),c=u}for(function(t,n){let e=0;for(;e<t.length;){const r=t[e],o=r.tokens[0].value.charAt(0),i=r.end-r.start;let c=r.close&&i?e:0;for(;c--;){const e=t[c],a=e.end-e.start;if(e.tokens[0].value.charAt(0)===o&&e.open&&a&&(r.split?!((e.close||r.open)&&i%3)||(a+i)%3:a===e.markers.length&&a===i)){const t=r.split?a>1&&i>1?2:1:i,o=e.markers.slice(e.end-t,e.end),c=r.markers.slice(r.start,r.start+t),s=o[0],u=c[0];if(s===o[t-1]&&s.value.length===t&&u===c[t-1]&&u.value.length===t&&s.attention===u.attention)n.delete(s),n.delete(u);else{const t=[...new Set([...o,...c])];for(const e of t){const r=n.get(e);r&&r.push(...t)}}e.end-=t,r.start+=t;break}}-1!==c&&r.start!==r.end||e++}}(r,o),c=-1;++c<t.length;){const n=o.get(t[c]);if(n)return{attention:U(t,n,i),index:c}}}function O(t,n,e){return Y(J(t,n,e),e.before,e.after)}function Q(t,n){const e=t[n?0:t.length-1];if(!e||e.attention)return;const r=n?G(e.value):_(e.value),o=w(r.codePointAt(0));e.value=n?o+e.value.slice(r.length):e.value.slice(0,e.value.length-r.length)+o}function D(t,n,e,r,o){for(const i of e.attention){const c=n.get(i)||i.sequences[0];for(const a of i.sequences){if(a===c)continue;const s=new Map(n);s.set(i,a);const u=V(t,s,r,o),l=Z(u,r,o);if(!l||l.index>e.index)return{chosen:s,mistake:l,tokens:u}}}}function H(t,n,e){if(0===n.length)throw new Error("Cannot serialize `"+t+"` as attention without markers, expected one or more markers");if(0===e.length)throw new Error("Cannot serialize `"+t+"` as attention without sizes, expected one or more sizes");for(const n of e)if(!Number.isSafeInteger(n)||n<1)throw new Error("Cannot serialize `"+t+"` as attention with `"+n+"` as size, expected positive integer");const r=[];for(const o of n){if(1!==o.length)throw new Error("Cannot serialize `"+t+"` as attention with `"+o+"` as marker, expected a single ascii character");if(!k(o.charCodeAt(0)))throw new Error("Cannot serialize `"+t+"` as attention with `"+o+"` as marker, expected ascii punctuation");for(const t of e)r.push(o.repeat(t))}return r}function J(t,n,e){const r=n.indexStack,o=t.children||[],i=[];let c=-1,a=e.before;r.push(-1);let s=n.createTracker(e);for(;++c<o.length;){const u=o[c];let l;if(r[r.length-1]=c,c+1<o.length){let e=n.handle.handlers[o[c+1].type];e&&e.peek&&(e=e.peek),l=e?G(e(o[c+1],t,n,{before:"",after:"",...s.current()})):""}else l=e.after;const f=i[i.length-1];"string"!=typeof f||"\r"!==a&&"\n"!==a||"html"!==u.type||7===z(u.value)||(i[i.length-1]=f.replace(/(\r?\n|\r)$/," "),a=" ",s=n.createTracker(e),s.move(Y(i,e.before,e.after)));const d=n.handle.handlers[u.type];if(d&&d.attention){const{construct:t,markers:e,sizes:r}=d.attention(u,n),o=H(u.type,e,r),c=o[0],l=n.enter(t);s.move(c);const f=J(u,n,{...s.current(),before:c,after:c});s.move(Y(f,c,c)),s.move(c),l(),i.push({children:f,sequences:o}),a=c.charAt(c.length-1)}else{const e=n.handle(u,t,n,{...s.current(),after:l,before:a});if(!e)continue;s.move(e),i.push(e),a=_(e)}}return r.pop(),i}function V(t,n,e,r){const o=[];let i,c=_(e),a=-1;for(;++a<t.length;){const e=t[a];if("string"==typeof e){const t={value:e,attention:void 0};i&&i===G(e)&&Q([t],!0),i=void 0,o.push(t),t.value&&(c=_(t.value));continue}const s=n.get(e)||e.sequences[0],u=s.charAt(0),l=t[a+1],f=c,d=G(void 0===l?r:"string"==typeof l?l:n.get(l)||l.sequences[0]),p=V(e.children,n,s,s),h=p.length>0?p[0].value:"",m=$(f.charCodeAt(f.length-1),h.charCodeAt(0),u);m.inside&&Q(p,!0);const g=p.length>0?_(p[p.length-1].value):"",b=$(d.charCodeAt(0),g.charCodeAt(g.length-1),u);b.inside&&Q(p,!1),m.outside&&"\n"!==f&&"\r"!==f&&Q(o,!1),b.outside&&(i=d),o.push({value:s,attention:e},...p,{value:s,attention:e}),c=s.charAt(s.length-1)}return o}function Y(t,n,e){let r=new Map;const o=V(t,r,n,e);let i=o,c=Z(i,n,e);for(;c;){const a=D(t,r,c,n,e);if(!a){i=o;break}r=a.chosen,i=a.tokens,c=a.mistake}let a="";for(const t of i)a+=t.value;return a}function K(t,n,e,r){let o=r.join.length;for(;o--;){const i=r.join[o](t,n,e,r);if(!0===i||1===i)break;if("number"==typeof i)return"\n".repeat(1+i);if(!1===i)return"\n\n\x3c!----\x3e\n\n"}return"\n\n"}const W=/\r?\n|\r/g;function X(t,n){const e=[];let r,o=0,i=0;for(;r=W.exec(t);)c(t.slice(o,r.index)),e.push(r[0]),o=r.index+r[0].length,i++;return c(t.slice(o)),e.join("");function c(t){e.push(n(t,i,!t))}}const tt={}.hasOwnProperty;function nt(t,n){return!t||!!n&&("string"==typeof t?t===n.type:t.includes(n.type))}function et(t,n){return t-n}function rt(t,n){const e=/\\(?=[!-/:-@[-`{-~])/g,r=[],o=[],i=t+n;let c,a=-1,s=0;for(;c=e.exec(i);)r.push(c.index);for(;++a<r.length;)s!==r[a]&&o.push(t.slice(s,r[a])),o.push("\\"),s=r[a];return o.push(t.slice(s)),o.join("")}function ot(t){const n=t||{},e=n.now||{};let r=n.lineShift||0,o=e.line||1,i=e.column||1;return{move:function(t){const n=t||"",e=n.split(/\r?\n|\r/g),c=e[e.length-1];return o+=e.length-1,i=1===e.length?i+c.length:1+c.length+r,n},current:function(){return{now:{line:o,column:i},lineShift:r}},shift:function(t){r+=t}}}function it(n,e){const r=e||{},o={associationId:R,bulletCurrent:void 0,bulletLastUsed:void 0,containerPhrasing:ut,containerFlow:lt,createTracker:ot,compilePattern:q,enter:function(t){return o.stack.push(t),function(){o.stack.pop()}},handlers:{...C},handle:void 0,indentLines:X,indexStack:[],join:[...T],options:{},safe:ft,stack:[],unsafe:[...I]};L(o,r),o.options.tightDefinitions&&o.join.push(st),o.handle=t("type",{invalid:ct,unknown:at,handlers:o.handlers});let i=o.handle(S(n)?{type:"root",children:[n]}:n,void 0,o,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0});return i&&10!==i.charCodeAt(i.length-1)&&13!==i.charCodeAt(i.length-1)&&(i+="\n"),i}function ct(t){throw new Error("Cannot handle value `"+t+"`, expected node")}function at(t){throw new Error("Cannot handle unknown node `"+t.type+"`")}function st(t,n){if("definition"===t.type&&t.type===n.type)return 0}function ut(t,n){return O(t,this,n)}function lt(t,n){return function(t,n,e){const r=n.indexStack,o=t.children||[],i=n.createTracker(e),c=[];let a=-1;for(r.push(-1);++a<o.length;){const e=o[a];r[r.length-1]=a,c.push(i.move(n.handle(e,t,n,{before:"\n",after:"\n",...i.current()}))),"list"!==e.type&&(n.bulletLastUsed=void 0),a<o.length-1&&c.push(i.move(K(e,o[a+1],t,n)))}return r.pop(),c.join("")}(t,this,n)}function ft(t,n){return function(t,n,e){const r=(e.before||"")+(n||"")+(e.after||""),o=[],i=[],c={},a=t.stack.includes("autolink"),s=e.before?e.before.length:0,u=r.length-(e.after?e.after.length:0);let l=-1;for(;++l<t.unsafe.length;){const n=t.unsafe[l];if(!x(t.stack,n)||!nt(n.beforeNode,e.beforeNode)||!nt(n.afterNode,e.afterNode))continue;const i=t.compilePattern(n),a=n.beforeNode?s:0,f=r.slice(a,n.afterNode?u:void 0);let d;for(;d=i.exec(f);){const t="before"in n||Boolean(n.atBreak),e="after"in n,r=a+d.index+(t?d[1].length:0);tt.call(c,r)?(c[r].before&&!t&&(c[r].before=!1),c[r].after&&!e&&(c[r].after=!1)):(o.push(r),c[r]={before:t,after:e})}}o.sort(et);let f=s;for(l=-1;++l<o.length;){const t=o[l];if(!(t<f||t>=u)){if("_"===r.charAt(t)&&t>0&&void 0===v(r.charCodeAt(t-1))&&!tt.call(c,t-1)&&(t-1!==s||!/[*_]/.test(r.charAt(s-1)))){let n=t+1;for(;n<u&&"_"===r.charAt(n);)n++;const e=n-t-1;if(o[l+e]===n-1&&n<r.length&&void 0===v(r.charCodeAt(n))&&!tt.call(c,n)&&(n!==u-1||!/[*_]/.test(r.charAt(u)))){l+=e;continue}}if(!(t+1<u&&o[l+1]===t+1&&c[t].after&&!c[t+1].before&&!c[t+1].after||o[l-1]===t-1&&c[t].before&&!c[t-1].before&&!c[t-1].after)){if(f!==t){const n=r.slice(f,t);i.push(a?n:rt(n,"\\"))}f=t,a?(i.push("%"+r.charCodeAt(t).toString(16).toUpperCase().padStart(2,"0")),f++):!/[!-/:-@[-`{-~]/.test(r.charAt(t))||e.encode&&e.encode.includes(r.charAt(t))?(i.push(w(r.charCodeAt(t))),f++):i.push("\\")}}}const d=r.slice(f,u);return i.push(a?d:rt(d,e.after)),i.join("")}(this,t,n)}function dt(t,o){const i=function(t,o){switch(t.nodeType){case 1:return function(t,o){const i=t.namespaceURI,c=i===n.svg?e:r,a=i===n.html?t.tagName.toLowerCase():t.tagName,s=i===n.html&&"template"===a?t.content:t,u=t.getAttributeNames(),l={};let f=-1;for(;++f<u.length;)l[u[f]]=t.getAttribute(u[f])||"";return c(a,l,ht(s,o))}(t,o);case 3:return function(t){return{type:"text",value:t.nodeValue||""}}(t);case 8:return function(t){return{type:"comment",value:t.nodeValue||""}}(t);case 9:case 11:return pt(t,o);case 10:return{type:"doctype"};default:return}}(t,o);return i&&o.afterTransform&&o.afterTransform(t,i),i}function pt(t,n){return{type:"root",children:ht(t,n)}}function ht(t,n){const e=t.childNodes,r=[];let o=-1;for(;++o<e.length;){const t=dt(e[o],n);void 0!==t&&r.push(t)}return r}const mt=function(t,n,e,r,o){const i=gt(n);return!!vt(t)&&i.call(o,t,e,r)},gt=function(t){if(null==t)return yt;if("string"==typeof t)return function(t){return bt((function(n){return n.tagName===t}))}(t);if("object"==typeof t)return function(t){const n=[];let e=-1;for(;++e<t.length;)n[e]=gt(t[e]);return bt((function(...t){let e=-1;for(;++e<n.length;)if(n[e].apply(this,t))return!0;return!1}))}(t);if("function"==typeof t)return bt(t);throw new Error("Expected function, string, or array as `test`")};function bt(t){return function(n,e,r){return Boolean(vt(n)&&t.call(this,n,"number"==typeof e?e:void 0,r||void 0))}}function yt(t){return Boolean(t&&"object"==typeof t&&"type"in t&&"element"===t.type&&"tagName"in t&&"string"==typeof t.tagName)}function vt(t){return null!==t&&"object"==typeof t&&"type"in t&&"tagName"in t}const kt=gt((function(t){return"audio"===t.tagName||"canvas"===t.tagName||"embed"===t.tagName||"iframe"===t.tagName||"img"===t.tagName||"math"===t.tagName||"object"===t.tagName||"picture"===t.tagName||"svg"===t.tagName||"video"===t.tagName})),wt=["address","article","aside","blockquote","body","br","caption","center","col","colgroup","dd","dialog","dir","div","dl","dt","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","legend","li","li","listing","main","menu","nav","ol","optgroup","option","p","plaintext","pre","section","summary","table","tbody","td","td","tfoot","th","th","thead","tr","ul","wbr","xmp"],xt=["button","input","select","textarea"],Ct=["area","base","basefont","dialog","datalist","head","link","meta","noembed","noframes","param","rp","script","source","style","template","track","title"],St={},Bt=o(["comment","doctype"]);function At(t,n){if("children"in t){const e={...n};return("root"===t.type||Mt(t))&&(e.before=!0,e.after=!0),e.whitespace=function(t,n){if("tagName"in t&&t.properties)switch(t.tagName){case"listing":case"plaintext":case"script":case"style":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return t.properties.wrap?"pre-wrap":"pre";case"td":case"th":return t.properties.noWrap?"nowrap":n.whitespace;case"textarea":return"pre-wrap"}return n.whitespace}(t,n),function(t,n){let e=n.before;const r=n.after,o=t.children;let i=o.length,c=-1;for(;++c<i;){const t=At(o[c],{...n,after:Et(o,c,r),before:e});t.remove?(o.splice(c,1),c--,i--):t.ignore||(e=t.stripAtStart),Lt(o[c])&&(e=!1)}return{ignore:!1,stripAtStart:Boolean(e||r),remove:!1}}(t,e)}if("text"===t.type){if("normal"===n.whitespace)return function(t,n){const e=n.collapse(t.value),r={ignore:!1,stripAtStart:!1,remove:!1};let o=0,i=e.length;return n.before&&Tt(e.charAt(0))&&o++,o!==i&&Tt(e.charAt(i-1))&&(n.after?i--:r.stripAtStart=!0),o===i?r.remove=!0:t.value=e.slice(o,i),r}(t,n);"nowrap"===n.whitespace&&(t.value=n.collapse(t.value))}return{ignore:Bt(t),stripAtStart:!1,remove:!1}}function Et(t,n,e){for(;++n<t.length;){const e=t[n];let r=Ft(e);if(void 0===r&&"children"in e&&!zt(e)&&(r=Et(e.children,-1)),"boolean"==typeof r)return r}return e}function Ft(t){if("element"===t.type){if(Lt(t))return!1;if(Mt(t))return!0}else if("text"===t.type){if(!i(t))return!1}else if(!Bt(t))return!1}function Lt(t){return kt(t)||mt(t,xt)}function Mt(t){return mt(t,wt)}function zt(t){return Boolean("element"===t.type&&t.properties.hidden)||Bt(t)||mt(t,Ct)}function Tt(t){return" "===t||"\n"===t}function jt(t){const n=/\r?\n|\r/.exec(t);return n?n[0]:" "}function It(){return" "}function Nt(t){return function(n){!function(t,n){var e;At(t,{collapse:(e=(n||St).newlines?jt:It,function(t){return String(t).replace(/[\t\n\v\f\r ]+/g,e)}),whitespace:"normal"})}(n,t)}}const Rt=function(t,n,e){const r=o(e);if(!t||!t.type||!t.children)throw new Error("Expected parent node");if("number"==typeof n){if(n<0||n===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if((n=t.children.indexOf(n))<0)throw new Error("Expected child node or index");for(;++n<t.children.length;)if(r(t.children[n],n,t))return t.children[n]},qt=/\n/g,Gt=/[\t ]+/g,_t=gt("br"),$t=gt((function(t){return"td"===t.tagName||"th"===t.tagName})),Pt=gt("p"),Ut=gt("tr"),Zt=gt(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",function(t){return Boolean((t.properties||{}).hidden)},function(t){return"dialog"===t.tagName&&!(t.properties||{}).open}]),Ot=gt(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function Qt(t){const n="children"in t?t.children:[],e=Ot(t),r=Vt(t,{whitespace:{}.whitespace||"normal"}),o=[];"text"!==t.type&&"comment"!==t.type||o.push(...Ht(t,{breakBefore:!0,breakAfter:!0}));let i=-1;for(;++i<n.length;)o.push(...Dt(n[i],t,{whitespace:r,breakBefore:i?void 0:e,breakAfter:i<n.length-1?_t(n[i+1]):e}));const c=[];let a;for(i=-1;++i<o.length;){const t=o[i];"number"==typeof t?void 0!==a&&t>a&&(a=t):t&&(void 0!==a&&a>-1&&c.push("\n".repeat(a)||" "),a=-1,c.push(t))}return c.join("")}function Dt(t,n,e){return"element"===t.type?function(t,n,e){const r=Vt(t,e),o=t.children||[];let i,c,a=-1,s=[];if(Zt(t))return s;for(_t(t)||Ut(t)&&Rt(n,t,Ut)?c="\n":Pt(t)?(i=2,c=2):Ot(t)&&(i=1,c=1);++a<o.length;)s=s.concat(Dt(o[a],t,{whitespace:r,breakBefore:a?void 0:i,breakAfter:a<o.length-1?_t(o[a+1]):c}));return $t(t)&&Rt(n,t,$t)&&s.push("\t"),i&&s.unshift(i),c&&s.push(c),s}(t,n,e):"text"===t.type?"normal"===e.whitespace?Ht(t,e):function(t){return[String(t.value)]}(t):[]}function Ht(t,n){const e=String(t.value),r=[],o=[];let i=0;for(;i<=e.length;){qt.lastIndex=i;const t=qt.exec(e),o=t&&"index"in t?t.index:e.length;r.push(Jt(e.slice(i,o).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),0!==i||n.breakBefore,o!==e.length||n.breakAfter)),i=o+1}let c,a=-1;for(;++a<r.length;)8203===r[a].charCodeAt(r[a].length-1)||a<r.length-1&&8203===r[a+1].charCodeAt(0)?(o.push(r[a]),c=void 0):r[a]?("number"==typeof c&&o.push(c),o.push(r[a]),c=0):0!==a&&a!==r.length-1||o.push(0);return o}function Jt(t,n,e){const r=[];let o,i=0;for(;i<t.length;){Gt.lastIndex=i;const e=Gt.exec(t);o=e?e.index:t.length,i||o||!e||n||r.push(""),i!==o&&r.push(t.slice(i,o)),i=e?o+e[0].length:o}return i===o||e||r.push(""),r.join(" ")}function Vt(t,n){if("element"===t.type){const e=t.properties||{};switch(t.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return e.wrap?"pre-wrap":"pre";case"td":case"th":return e.noWrap?"nowrap":n.whitespace;case"textarea":return"pre-wrap"}}return n.whitespace}function Yt(t){const n=String(t);let e=n.length;for(;e>0;){const t=n.codePointAt(e-1);if(void 0===t||10!==t&&13!==t)break;e--}return n.slice(0,e)}function Kt(t,n){const e=n.children;let r,o,i=-1;if("pre"===n.tagName)for(;++i<e.length;){const t=e[i];if("element"===t.type&&"code"===t.tagName&&t.properties&&t.properties.className&&Array.isArray(t.properties.className)){r=t.properties.className;break}}if(r)for(i=-1;++i<r.length;)if("language-"===String(r[i]).slice(0,9)){o=String(r[i]).slice(9);break}const c={type:"code",lang:o||null,meta:null,value:Yt(Qt(n))};return t.patch(n,c),c}function Wt(t,n){const e={type:"delete",children:t.all(n)};return t.patch(n,e),e}function Xt(t){let n=-1;if(t.length>1)for(;++n<t.length;)if(t[n].spread)return!0;return!1}function tn(t,n){const e=t.all({type:"root",children:n}),r=t.toSpecificContent(e,nn);return 0===r.length?[]:1===r.length?r[0].children:[{type:"list",ordered:!1,start:null,spread:Xt(r),children:r}]}function nn(){return{type:"listItem",spread:!1,checked:null,children:[]}}function en(t,n){const e={type:"emphasis",children:t.all(n)};return t.patch(n,e),e}function rn(t){let n=0,e=t.length;for(;n<e&&"break"===t[n].type;)n++;for(;e>n&&"break"===t[e-1].type;)e--;return 0===n&&e===t.length?t:t.slice(n,e)}function on(t,n){const e={type:"heading",depth:Number(n.tagName.charAt(1))||1,children:rn(t.all(n))};return t.patch(n,e),e}function cn(t,n){const e=n.properties||{},r={type:"image",url:t.resolve(String(e.src||"")||null),title:e.title?String(e.title):null,alt:e.alt?String(e.alt):""};return t.patch(n,r),r}function an(t,n){const e={type:"inlineCode",value:Qt(n)};return t.patch(n,e),e}function sn(t,n){const e=[],r=[],o=n||t.properties||{},i=un(t),c=Math.min(Number.parseInt(String(o.size),10),0)||(o.multiple?4:1);let a=-1;for(;++a<i.length;){const t=i[a];t&&t.properties&&t.properties.selected&&e.push(t)}const s=e.length>0?e:i,u=Math.min(s.length,c);for(a=-1;++a<u;){const t=s[a],n=t.properties||{},e=Qt(t),o=e||String(n.label||""),i=String(n.value||"")||e;r.push([i,o===i?void 0:o])}return r}function un(t){const n=[];let e=-1;for(;++e<t.children.length;){const r=t.children[e];"children"in r&&Array.isArray(r.children)&&n.push(...un(r)),"element"!==r.type||"option"!==r.tagName||r.properties&&r.properties.disabled||n.push(r)}return n}const ln={}.hasOwnProperty,fn=new Set(["pingback","prefetch","stylesheet"]),dn=gt(["a","abbr","area","b","bdi","bdo","br","button","cite","code","data","datalist","del","dfn","em","i","input","ins","kbd","keygen","label","map","mark","meter","noscript","output","progress","q","ruby","s","samp","script","select","small","span","strong","sub","sup","template","textarea","time","u","var","wbr"]),pn=gt("meta");function hn(t){return Boolean("text"===t.type||dn(t)||kt(t)||function(t){if("element"!==t.type||"link"!==t.tagName)return!1;if(t.properties.itemProp)return!0;const n=t.properties.rel;let e=-1;if(!Array.isArray(n)||0===n.length)return!1;for(;++e<n.length;)if(!fn.has(String(n[e])))return!1;return!0}(t)||pn(t)&&function(t,n){const e="element"===t.type&&ln.call(t.properties,n)&&t.properties[n];return null!=e&&!1!==e}(t,"itemProp"))}function mn(t,n){const{rest:e,checkbox:r}=bn(n),o=r?Boolean(r.properties.checked):null,i={type:"listItem",spread:gn(e),checked:o,children:t.toFlow(t.all(e))};return t.patch(n,i),i}function gn(t){let n=-1,e=!1;for(;++n<t.children.length;){const r=t.children[n];if("element"===r.type){if(hn(r))continue;if("p"===r.tagName||e||gn(r))return!0;e=!0}}return!1}function bn(t){const n=t.children[0];if(n&&"element"===n.type&&"input"===n.tagName&&n.properties&&("checkbox"===n.properties.type||"radio"===n.properties.type))return{checkbox:n,rest:{...t,children:t.children.slice(1)}};if(n&&"element"===n.type&&"p"===n.tagName){const{checkbox:e,rest:r}=bn(n);if(e)return{checkbox:e,rest:{...t,children:[r,...t.children.slice(1)]}}}return{checkbox:void 0,rest:t}}function yn(t,n){const e="ol"===n.tagName,r=t.toSpecificContent(t.all(n),vn);let o=null;e&&(o=n.properties&&n.properties.start?Number.parseInt(String(n.properties.start),10):1);const i={type:"list",ordered:e,start:o,spread:Xt(r),children:r};return t.patch(n,i),i}function vn(){return{type:"listItem",spread:!1,checked:null,children:[]}}function kn(t){let n=-1;for(;++n<t.length;){const e=t[n];if(!Sn(e)||"children"in e&&kn(e.children))return!0}return!1}function wn(t){return Cn(t,(function(t){return t.every((function(t){return"text"===t.type&&i(t.value)}))?[]:[{type:"paragraph",children:rn(t)}]}),(function(t){return t}))}function xn(t){return Cn(t.children,(function(n){const e=Bn(t);return e.children=n,[e]}),(function(n){if("children"in n&&"children"in t){const e=Bn(t),r=Bn(n);return e.children=n.children,r.children.push(e),r}return{...n}}))}function Cn(t,n,e){const r=function(t){const n=[];let e=-1;for(;++e<t.length;){const r=t[e];"delete"!==r.type&&"link"!==r.type||!kn(r.children)?n.push(r):n.push(...xn(r))}return n}(t),o=[];let i=[],c=-1;for(;++c<r.length;){const t=r[c];Sn(t)?i.push(t):(i.length>0&&(o.push(...n(i)),i=[]),o.push(e(t)))}return i.length>0&&(o.push(...n(i)),i=[]),o}function Sn(t){const n=t.data&&t.data.hName;return n?hn({type:"element",tagName:n,properties:{},children:[]}):S(t)}function Bn(t){return c({...t,children:[]})}function An(t,n){const e=n.properties||{},r="video"===n.tagName?String(e.poster||""):"";let o=String(e.src||""),i=-1,c=!1,u=t.all(n);if(a({type:"root",children:u},(function(t){if("link"===t.type)return c=!0,s})),c||kn(u))return u;for(;!o&&++i<n.children.length;){const t=n.children[i];"element"===t.type&&"source"===t.tagName&&t.properties&&(o=String(t.properties.src||""))}if(r){const e={type:"image",title:null,url:t.resolve(r),alt:B(u)};t.patch(n,e),u=[e]}const l=u,f={type:"link",title:e.title?String(e.title):null,url:t.resolve(o),children:l};return t.patch(n,f),f}function En(t,n){const e=rn(t.all(n));if(e.length>0){const r={type:"paragraph",children:e};return t.patch(n,r),r}}const Fn=['"'];function Ln(t,n){const e={type:"strong",children:t.all(n)};return t.patch(n,e),e}function Mn(t,n){const e={type:"tableCell",children:t.all(n)};if(t.patch(n,e),n.properties){const t=n.properties.rowSpan,r=n.properties.colSpan;if(t||r){const n=e.data||(e.data={});t&&(n.hastUtilToMdastTemporaryRowSpan=t),r&&(n.hastUtilToMdastTemporaryColSpan=r)}}return e}function zn(){return{type:"tableCell",children:[]}}function Tn(){return{type:"tableCell",children:[]}}function jn(){return{type:"tableRow",children:[]}}const In={comment:function(t,n){const e={type:"html",value:"\x3c!--"+n.value+"--\x3e"};return t.patch(n,e),e},doctype:Gn,root:function(t,n){let e=t.all(n);(t.options.document||kn(e))&&(e=wn(e));const r={type:"root",children:e};return t.patch(n,r),r},text:function(t,n){const e={type:"text",value:n.value};return t.patch(n,e),e}},Nn={applet:Gn,area:Gn,basefont:Gn,bgsound:Gn,caption:Gn,col:Gn,colgroup:Gn,command:Gn,content:Gn,datalist:Gn,dialog:Gn,element:Gn,embed:Gn,frame:Gn,frameset:Gn,isindex:Gn,keygen:Gn,link:Gn,math:Gn,menu:Gn,menuitem:Gn,meta:Gn,nextid:Gn,noembed:Gn,noframes:Gn,optgroup:Gn,option:Gn,param:Gn,script:Gn,shadow:Gn,source:Gn,spacer:Gn,style:Gn,svg:Gn,template:Gn,title:Gn,track:Gn,abbr:Rn,acronym:Rn,bdi:Rn,bdo:Rn,big:Rn,blink:Rn,button:Rn,canvas:Rn,cite:Rn,data:Rn,details:Rn,dfn:Rn,font:Rn,ins:Rn,label:Rn,map:Rn,marquee:Rn,meter:Rn,nobr:Rn,noscript:Rn,object:Rn,output:Rn,progress:Rn,rb:Rn,rbc:Rn,rp:Rn,rt:Rn,rtc:Rn,ruby:Rn,slot:Rn,small:Rn,span:Rn,sup:Rn,sub:Rn,tbody:Rn,tfoot:Rn,thead:Rn,time:Rn,address:qn,article:qn,aside:qn,body:qn,center:qn,div:qn,fieldset:qn,figcaption:qn,figure:qn,form:qn,footer:qn,header:qn,hgroup:qn,html:qn,legend:qn,main:qn,multicol:qn,nav:qn,picture:qn,section:qn,a:function(t,n){const e=n.properties||{},r=t.all(n),o={type:"link",url:t.resolve(String(e.href||"")||null),title:e.title?String(e.title):null,children:r};return t.patch(n,o),o},audio:An,b:Ln,base:function(t,n){t.baseFound||(t.frozenBaseUrl=String(n.properties&&n.properties.href||"")||void 0,t.baseFound=!0)},blockquote:function(t,n){const e={type:"blockquote",children:t.toFlow(t.all(n))};return t.patch(n,e),e},br:function(t,n){const e={type:"break"};return t.patch(n,e),e},code:an,dir:yn,dl:function(t,n){const e=[],r=[];let o=-1;for(;++o<n.children.length;){const t=n.children[o];"element"===t.type&&"div"===t.tagName?e.push(...t.children):e.push(t)}let i={definitions:[],titles:[]};for(o=-1;++o<e.length;){const t=e[o];if("element"===t.type&&"dt"===t.tagName){const n=e[o-1];n&&"element"===n.type&&"dd"===n.tagName&&(r.push(i),i={definitions:[],titles:[]}),i.titles.push(t)}else i.definitions.push(t)}r.push(i),o=-1;const c=[];for(;++o<r.length;){const n=[...tn(t,r[o].titles),...tn(t,r[o].definitions)];n.length>0&&c.push({type:"listItem",spread:n.length>1,checked:null,children:n})}if(c.length>0){const e={type:"list",ordered:!1,start:null,spread:Xt(c),children:c};return t.patch(n,e),e}},dt:mn,dd:mn,del:Wt,em:en,h1:on,h2:on,h3:on,h4:on,h5:on,h6:on,hr:function(t,n){const e={type:"thematicBreak"};return t.patch(n,e),e},i:en,iframe:function(t,n){const e=n.properties||{},r=String(e.src||""),o=String(e.title||"");if(r&&o){const e={type:"link",title:null,url:t.resolve(r),children:[{type:"text",value:o}]};return t.patch(n,e),e}},img:cn,image:cn,input:function(t,n){const e=n.properties||{},r=String(e.value||e.placeholder||"");if(e.disabled||"hidden"===e.type||"file"===e.type)return;if("checkbox"===e.type||"radio"===e.type){const r={type:"text",value:e.checked?t.options.checked||"[x]":t.options.unchecked||"[ ]"};return t.patch(n,r),r}if("image"===e.type){const o=e.alt||r;if(o){const r={type:"image",url:t.resolve(String(e.src||"")||null),title:String(e.title||"")||null,alt:String(o)};return t.patch(n,r),r}return}let o=[];if(r)o=[[r,void 0]];else if("button"!==e.type&&"file"!==e.type&&"password"!==e.type&&"reset"!==e.type&&"submit"!==e.type&&e.list){const n=String(e.list),r=t.elementById.get(n);r&&"datalist"===r.tagName&&(o=sn(r,e))}if(0===o.length)return;if("password"===e.type&&(o[0]=["•".repeat(o[0][0].length),void 0]),"email"===e.type||"url"===e.type){const n=[];let r=-1;for(;++r<o.length;){const i=t.resolve(o[r][0]);n.push({type:"link",title:null,url:"email"===e.type?"mailto:"+i:i,children:[{type:"text",value:o[r][1]||i}]}),r!==o.length-1&&n.push({type:"text",value:", "})}return n}const i=[];let c=-1;for(;++c<o.length;)i.push(o[c][1]?o[c][1]+" ("+o[c][0]+")":o[c][0]);const a={type:"text",value:i.join(", ")};return t.patch(n,a),a},kbd:an,li:mn,listing:Kt,mark:en,ol:yn,p:En,plaintext:Kt,pre:Kt,q:function(t,n){const e=t.options.quotes||Fn;t.qNesting++;const r=t.all(n);t.qNesting--;const o=e[t.qNesting%e.length],i=r[0],c=r[r.length-1],a=o.charAt(0),s=o.length>1?o.charAt(1):o;return i&&"text"===i.type?i.value=a+i.value:r.unshift({type:"text",value:a}),c&&"text"===c.type?c.value+=s:r.push({type:"text",value:s}),r},s:Wt,samp:an,select:function(t,n){const e=sn(n);let r=-1;const o=[];for(;++r<e.length;){const t=e[r];o.push(t[1]?t[1]+" ("+t[0]+")":t[0])}if(o.length>0){const e={type:"text",value:o.join(", ")};return t.patch(n,e),e}},strike:Wt,strong:Ln,summary:En,table:function(t,n){if(t.inTable){const e={type:"text",value:Qt(n)};return t.patch(n,e),e}t.inTable=!0;const{align:e,headless:r}=function(t){const n={align:[null],headless:!0};let e=0,r=0;return a(t,(function(o){if("element"===o.type){if("table"===o.tagName&&t!==o)return u;if("th"!==o.tagName&&"td"!==o.tagName||!o.properties)"thead"===o.tagName?n.headless=!1:"tr"===o.tagName&&(e++,r=0);else{if(!n.align[r]){const t=String(o.properties.align||"")||null;"center"!==t&&"left"!==t&&"right"!==t&&null!==t||(n.align[r]=t)}n.headless&&e<2&&"th"===o.tagName&&(n.headless=!1),r++}}})),n}(n),o=t.toSpecificContent(t.all(n),jn);r&&o.unshift({type:"tableRow",children:[]});let i=-1;for(;++i<o.length;){const n=o[i],e=t.toSpecificContent(n.children,Tn);n.children=e}let c=1;for(i=-1;++i<o.length;){const t=o[i].children;let n=-1;for(;++n<t.length;){const e=t[n];if(e.data){const t=e.data,r=Number.parseInt(String(t.hastUtilToMdastTemporaryColSpan),10)||1,c=Number.parseInt(String(t.hastUtilToMdastTemporaryRowSpan),10)||1;if(r>1||c>1){let t=i-1;for(;++t<i+c;){let e=n-1;for(;++e<n+r&&o[t];){const r=[];t===i&&e===n||r.push({type:"tableCell",children:[]}),o[t].children.splice(e,0,...r)}}}"hastUtilToMdastTemporaryColSpan"in e.data&&delete e.data.hastUtilToMdastTemporaryColSpan,"hastUtilToMdastTemporaryRowSpan"in e.data&&delete e.data.hastUtilToMdastTemporaryRowSpan,0===Object.keys(e.data).length&&delete e.data}}t.length>c&&(c=t.length)}for(i=-1;++i<o.length;){const t=o[i].children;let n=t.length-1;for(;++n<c;)t.push({type:"tableCell",children:[]})}let s=e.length-1;for(;++s<c;)e.push(null);t.inTable=!1;const l={type:"table",align:e,children:o};return t.patch(n,l),l},td:Mn,textarea:function(t,n){const e={type:"text",value:Qt(n)};return t.patch(n,e),e},th:Mn,tr:function(t,n){const e={type:"tableRow",children:t.toSpecificContent(t.all(n),zn)};return t.patch(n,e),e},tt:an,u:en,ul:yn,var:an,video:An,wbr:function(t,n){const e={type:"text",value:"​"};return t.patch(n,e),e},xmp:Kt};function Rn(t,n){return t.all(n)}function qn(t,n){return t.toFlow(t.all(n))}function Gn(){}const _n={}.hasOwnProperty;function $n(t){const n=t.children||[],e=[];let r=-1;for(;++r<n.length;){const o=this.one(n[r],t);Array.isArray(o)?e.push(...o):o&&e.push(o)}return e}function Pn(t,n){if("element"===t.type){if(t.properties&&"ignore"===t.properties.dataMdast)return;if(_n.call(this.handlers,t.tagName))return this.handlers[t.tagName](this,t,n)||void 0}else if(_n.call(this.nodeHandlers,t.type))return this.nodeHandlers[t.type](this,t,n)||void 0;if("value"in t&&"string"==typeof t.value){const n={type:"text",value:t.value};return this.patch(t,n),n}if("children"in t)return this.all(t)}function Un(t,n){t.position&&(n.position=l(t))}function Zn(t){const n=this.frozenBaseUrl;return null==t?"":n?String(new URL(t,n)):t}function On(t){return wn(t)}function Qn(t,n){const e=n(),r=[];let o=[],i=-1;for(;++i<t.length;){const n=t[i];c(n)?(o.length>0&&(n.children.unshift(...o),o=[]),r.push(n)):o.push(n)}if(o.length>0){let t=r[r.length-1];t||(t=n(),r.push(t)),t.children.push(...o),o=[]}return r;function c(t){return t.type===e.type}}const Dn={};function Hn(t,n){const e=c(t),r=n||Dn,o=Nt({newlines:!0===r.newlines}),i=function(t){return{all:$n,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...Nn,...t.handlers},inTable:!1,nodeHandlers:{...In,...t.nodeHandlers},one:Pn,options:t,patch:Un,qNesting:0,resolve:Zn,toFlow:On,toSpecificContent:Qn}}(r);let s;o(e),a(e,(function(t){if(t&&"element"===t.type&&t.properties){const n=String(t.properties.id||"")||void 0;n&&!i.elementById.has(n)&&i.elementById.set(n,t)}}));const u=i.one(e,void 0);return s=u?Array.isArray(u)?{type:"root",children:u}:u:{type:"root",children:[]},a(s,(function(t,n,e){if("text"===t.type&&void 0!==n&&e){const r=e.children[n-1];if(r&&r.type===t.type)return r.value+=t.value,e.children.splice(n,1),r.position&&t.position&&(r.position.end=t.position.end),n-1;if(t.value=t.value.replace(/[\t ]*(\r?\n|\r)[\t ]*/,"$1"),!e||"heading"!==e.type&&"paragraph"!==e.type&&"root"!==e.type||(n||(t.value=t.value.replace(/^[\t ]+/,"")),n===e.children.length-1&&(t.value=t.value.replace(/[\t ]+$/,""))),!t.value)return e.children.splice(n,1),n}})),s}const Jn={document:!0};function Vn(t,n){return t&&"run"in t?async function(e,r){const o=Hn(e,{...Jn,...n});await t.run(o,r)}:function(n){return Hn(n,{...Jn,...t})}}function Yn(t){const n=this;n.compiler=function(e){return it(e,{...n.data("settings"),...t,extensions:n.data("toMarkdownExtensions")||[]})}}async function Kn(t,n){const e=new Set(n.map((t=>t.tagName)).filter(re)),r=new Map,o=function(t,n){return dt(t,n||{})||{type:"root",children:[]}}(t,{afterTransform:(t,n)=>{var o;"element"===n.type&&(function(t){const n=t.properties.dataSrc;"img"===t.tagName&&!t.properties.src&&n&&(t.properties.src=n)}(n),"a"===(o=n).tagName&&void 0!==o.properties.dataFootnoteBackref&&(o.properties.dataMdast="ignore"),t instanceof Element&&e.has(t.localName)&&r.set(n,t))}});await async function(t){await Promise.all([...t].map((async([t,n])=>{try{const e=await n.toMarkdown();t.properties.dataMarkdownDescription=e,t.children=[{type:"text",value:e}]}catch(t){console.error("Failed to describe element as markdown",t)}})))}(r);const i={sup:te,section:ne};for(const t of e)i[t]=Wn;const c=f().use(Vn,{handlers:i}).use(A).use(Yn,{bullet:"-",handlers:{break:Xn}}),a=await c.run({type:"root",children:o.children});return c.stringify(a).trimEnd()}const Wn=(t,n)=>{const e=n.properties.dataMarkdownDescription;return"string"==typeof e?function(t){const{children:n}=f().use(E).use(A).parse(t);return 1===n.length&&"paragraph"===n[0].type?n[0].children:n}(e):t.all(n)},Xn=(...t)=>{const n=C.break(...t);return"\\\n"===n?" \n":n},te=(t,n)=>{const e=n.children.find((t=>ee(t,"a")&&void 0!==t.properties.dataFootnoteRef));if(!e)return Nn.sup(t,n);const r=e.children.map((t=>"text"===t.type?t.value:"")).join("");return{type:"footnoteReference",identifier:r,label:r}},ne=(t,n)=>{if(void 0===n.properties.dataFootnotes)return Nn.section(t,n);const e=n.children.find((t=>ee(t,"ol"))),r=null==e?void 0:e.children.filter((t=>ee(t,"li")));return(null!=r?r:[]).map(((n,e)=>{const r=String(e+1);return{type:"footnoteDefinition",identifier:r,label:r,children:t.toFlow(t.all(n))}}))};function ee(t,n){return"element"===t.type&&t.tagName===n}function re(t){var n;const e=null===(n=customElements.get(t))||void 0===n?void 0:n.prototype;return"function"==typeof(null==e?void 0:e.toMarkdown)}export{Kn as exportMarkdown}