@inkeep/open-knowledge 0.0.0-dev-20260428021930 → 0.0.0-dev-20260428030816

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 (42) hide show
  1. package/dist/cli.mjs +249 -249
  2. package/dist/constants-BFC8WUGR.mjs +2 -0
  3. package/dist/{dist-BWvkug8h.mjs → dist-BVi1kLgS.mjs} +5 -5
  4. package/dist/{dist-Bx5GgBdJ.mjs → dist-DlLqW1l-.mjs} +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/dist/init-CpubW-xy.mjs +1 -0
  7. package/dist/{init-CzZhMVnY.mjs → init-DzmV7EWn.mjs} +2 -2
  8. package/dist/init-Kk_OD9gS.mjs +1 -0
  9. package/dist/{init-C6cjLUFz.mjs → init-lR-iOYyJ.mjs} +3 -3
  10. package/dist/loader-BVRsmTqA.mjs +1 -0
  11. package/dist/{loader-CPc-aW4O.mjs → loader-Dftbh71h.mjs} +2 -2
  12. package/dist/{paths-BpTFy0jY.mjs → paths-9SFXgdez.mjs} +2 -2
  13. package/dist/paths-tkdx_ODM.mjs +1 -0
  14. package/dist/preview-BJIwF_YN.mjs +1 -0
  15. package/dist/{preview-D0LnqCdK.mjs → preview-BWEEPmtf.mjs} +2 -2
  16. package/dist/public/assets/{ActivityModeContent-8j8yoFNR.js → ActivityModeContent-QSE28ToP.js} +1 -1
  17. package/dist/public/assets/{DocumentContext-CRsKuypY.js → DocumentContext-C7zXwLGg.js} +1 -1
  18. package/dist/public/assets/{GraphPanel-nC0tek4D.js → GraphPanel-B9s5n-VJ.js} +1 -1
  19. package/dist/public/assets/McpConsentDialogBody-FBruOF3J.js +1 -0
  20. package/dist/public/assets/{PageListContext-BeAv6YTY.js → PageListContext-DNRRECTw.js} +21 -21
  21. package/dist/public/assets/{SourceEditor-Cr2CUBTn.js → SourceEditor-B5_U1uud.js} +1 -1
  22. package/dist/public/assets/{clipboard-CokCqXWa.js → clipboard-BcHcwwH2.js} +1 -1
  23. package/dist/public/assets/{index-CfjCKbN6.js → index-CfLPPlu0.js} +8 -8
  24. package/dist/public/assets/{toggle-group-ClhkYZ6-.js → toggle-group-akWK7-wE.js} +1 -1
  25. package/dist/public/assets/{tooltip-BAEC-KjA.js → tooltip-nCu_fYrg.js} +1 -1
  26. package/dist/public/index.html +6 -6
  27. package/dist/src-CEe0tBjV.mjs +1 -0
  28. package/dist/start-Bt3IMsVN.mjs +1 -0
  29. package/dist/start-YQGf2koi.mjs +2 -0
  30. package/package.json +1 -1
  31. package/scripts/probe-exec.ts +2 -1
  32. package/scripts/probe-read-document.ts +4 -3
  33. package/dist/constants-DWQfpDRU.mjs +0 -2
  34. package/dist/init-BrdLKYwH.mjs +0 -1
  35. package/dist/init-CLz5m9aU.mjs +0 -1
  36. package/dist/loader-Dv6yC7sh.mjs +0 -1
  37. package/dist/paths-BH3t9_kz.mjs +0 -1
  38. package/dist/preview-S0e7r-4X.mjs +0 -1
  39. package/dist/public/assets/McpConsentDialogBody-CDgbvt5r.js +0 -1
  40. package/dist/src-BeVEUOH4.mjs +0 -1
  41. package/dist/start-BiBFA2tc.mjs +0 -2
  42. package/dist/start-CArB0f_G.mjs +0 -1
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-DlS42TIP.js","./dist-CgLbXgrr.js","./chunk-DECur_0Z.js","./w3c-keyname-CSlwavrd.js","./dist-GlH2KPqY.js","./dist-DeDgmJv2.js","./dist-DR1MrLJC.js","./dist-D2wwoXzm.js","./dist-BqO6NfD-.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./chunk-DECur_0Z.js";import{d as t}from"./propagation-api-Bugyj7xy.js";import{n,r,t as i}from"./compiler-runtime-Y11fyRVL.js";import{l as a}from"./panel-BCRdtBla.js";import{$ as o,D as s,E as c,F as l,G as u,J as d,K as f,N as p,O as m,Q as h,T as g,U as _,V as v,W as y,X as b,Y as x,Z as S,_ as C,g as w,h as T,m as E,q as D,u as O}from"./DocumentContext-CRsKuypY.js";import{L as ee,P as te,U as k,_ as ne,z as re}from"./PageListContext-BeAv6YTY.js";import{_ as ie,a as ae,c as oe,d as se,f as ce,g as le,h as ue,l as de,m as fe,p as pe,s as me,t as he,u as ge,v as _e}from"./clipboard-CokCqXWa.js";import{At as ve,Dt as A,Et as ye,N as j,Nt as M,Pt as N,Q as be,Tt as P,Y as F,Z as I,a as L,bt as R,ft as z,jt as B,lt as xe,q as V,wt as Se}from"./dist-CgLbXgrr.js";var H=e(n(),1),Ce=i(),we=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:d(this.yanchor),yhead:d(this.yhead)}}static fromJSON(t){return new e(f(t.yanchor),f(t.yhead))}},Te=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new _(e)}toYPos(e,t=0){return D(this.ytext,e,t)}fromYPos(e){let t=u(f(e),this.ytext.doc);if(t==null||t.type!==this.ytext)throw Error(`[y-codemirror] The position you want to retrieve was created by a different document`);return{pos:t.index,assoc:t.assoc}}toYRange(e){let t=e.assoc;return new we(this.toYPos(e.anchor,t),this.toYPos(e.head,t))}fromYRange(e){let t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?P.cursor(n.pos,n.assoc):P.range(t.pos,n.pos)}},U=A.define({combine(e){return e[e.length-1]}}),W=R.define(),Ee=class{constructor(e){this.view=e,this.conf=e.state.facet(U),this._observer=(t,n)=>{if(n.origin!==this.conf){let n=t.delta,r=[],i=0;for(let e=0;e<n.length;e++){let t=n[e];t.insert==null?t.delete==null?i+=t.retain:(r.push({from:i,to:i+t.delete,insert:``}),i+=t.delete):r.push({from:i,to:i,insert:t.insert})}e.dispatch({changes:r,annotations:[W.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(W)===this.conf)return;let t=this.conf.ytext;t.doc.transact(()=>{let n=0;e.changes.iterChanges((e,r,i,a,o)=>{let s=o.sliceString(0,o.length,`
2
+ import{r as e}from"./chunk-DECur_0Z.js";import{d as t}from"./propagation-api-Bugyj7xy.js";import{n,r,t as i}from"./compiler-runtime-Y11fyRVL.js";import{l as a}from"./panel-BCRdtBla.js";import{$ as o,D as s,E as c,F as l,G as u,J as d,K as f,N as p,O as m,Q as h,T as g,U as _,V as v,W as y,X as b,Y as x,Z as S,_ as C,g as w,h as T,m as E,q as D,u as O}from"./DocumentContext-C7zXwLGg.js";import{L as ee,P as te,U as k,_ as ne,z as re}from"./PageListContext-DNRRECTw.js";import{_ as ie,a as ae,c as oe,d as se,f as ce,g as le,h as ue,l as de,m as fe,p as pe,s as me,t as he,u as ge,v as _e}from"./clipboard-BcHcwwH2.js";import{At as ve,Dt as A,Et as ye,N as j,Nt as M,Pt as N,Q as be,Tt as P,Y as F,Z as I,a as L,bt as R,ft as z,jt as B,lt as xe,q as V,wt as Se}from"./dist-CgLbXgrr.js";var H=e(n(),1),Ce=i(),we=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:d(this.yanchor),yhead:d(this.yhead)}}static fromJSON(t){return new e(f(t.yanchor),f(t.yhead))}},Te=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new _(e)}toYPos(e,t=0){return D(this.ytext,e,t)}fromYPos(e){let t=u(f(e),this.ytext.doc);if(t==null||t.type!==this.ytext)throw Error(`[y-codemirror] The position you want to retrieve was created by a different document`);return{pos:t.index,assoc:t.assoc}}toYRange(e){let t=e.assoc;return new we(this.toYPos(e.anchor,t),this.toYPos(e.head,t))}fromYRange(e){let t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?P.cursor(n.pos,n.assoc):P.range(t.pos,n.pos)}},U=A.define({combine(e){return e[e.length-1]}}),W=R.define(),Ee=class{constructor(e){this.view=e,this.conf=e.state.facet(U),this._observer=(t,n)=>{if(n.origin!==this.conf){let n=t.delta,r=[],i=0;for(let e=0;e<n.length;e++){let t=n[e];t.insert==null?t.delete==null?i+=t.retain:(r.push({from:i,to:i+t.delete,insert:``}),i+=t.delete):r.push({from:i,to:i,insert:t.insert})}e.dispatch({changes:r,annotations:[W.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(W)===this.conf)return;let t=this.conf.ytext;t.doc.transact(()=>{let n=0;e.changes.iterChanges((e,r,i,a,o)=>{let s=o.sliceString(0,o.length,`
3
3
  `);e!==r&&t.delete(e+n,r-e),s.length>0&&t.insert(e+n,s),n+=s.length-(r-e)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}},De=I.fromClass(Ee),Oe=F.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:`0px 2px 0px 4px`},".cm-ySelectionCaret":{position:`relative`,borderLeft:`1px solid black`,borderRight:`1px solid black`,marginLeft:`-1px`,marginRight:`-1px`,boxSizing:`border-box`,display:`inline`},".cm-ySelectionCaretDot":{borderRadius:`50%`,position:`absolute`,width:`.4em`,height:`.4em`,top:`-.2em`,left:`-.2em`,backgroundColor:`inherit`,transition:`transform .3s ease-in-out`,boxSizing:`border-box`},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:`bottom center`,transform:`scale(0)`},".cm-ySelectionInfo":{position:`absolute`,top:`-1.05em`,left:`-1px`,fontSize:`.75em`,fontFamily:`serif`,fontStyle:`normal`,fontWeight:`normal`,lineHeight:`normal`,userSelect:`none`,color:`white`,paddingLeft:`2px`,paddingRight:`2px`,zIndex:101,transition:`opacity .3s ease-in-out`,backgroundColor:`inherit`,opacity:0,transitionDelay:`0s`,whiteSpace:`nowrap`},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:`0s`}}),ke=R.define(),Ae=class extends be{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return x(`span`,[S(`class`,`cm-ySelectionCaret`),S(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[b(`⁠`),x(`div`,[S(`class`,`cm-ySelectionCaretDot`)]),b(`⁠`),x(`div`,[S(`class`,`cm-ySelectionInfo`)],[b(this.name)]),b(`⁠`)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},je=class{constructor(e){this.conf=e.state.facet(U),this._listener=({added:t,updated:n,removed:r},i,a)=>{t.concat(n).concat(r).findIndex(e=>e!==this.conf.awareness.doc.clientID)>=0&&e.dispatch({annotations:[ke.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=ve.of([])}destroy(){this._awareness.off(`change`,this._listener)}update(e){let t=this.conf.ytext,n=t.doc,r=this.conf.awareness,i=[],a=this.conf.awareness.getLocalState();if(a!=null){let n=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),i=n?e.state.selection.main:null,o=a.cursor==null?null:f(a.cursor.anchor),s=a.cursor==null?null:f(a.cursor.head);if(i!=null){let e=D(t,i.anchor),n=D(t,i.head);(a.cursor==null||!y(o,e)||!y(s,n))&&r.setLocalStateField(`cursor`,{anchor:e,head:n})}else a.cursor!=null&&n&&r.setLocalStateField(`cursor`,null)}r.getStates().forEach((a,s)=>{if(s===r.doc.clientID)return;let c=a.cursor;if(c==null||c.anchor==null||c.head==null)return;let l=u(c.anchor,n),d=u(c.head,n);if(l==null||d==null||l.type!==t||d.type!==t)return;let{color:f=`#30bced`,name:p=`Anonymous`}=a.user||{},m=a.user&&a.user.colorLight||f+`33`,g=o(l.index,d.index),_=h(l.index,d.index),v=e.view.state.doc.lineAt(g),y=e.view.state.doc.lineAt(_);if(v.number===y.number)i.push({from:g,to:_,value:V.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})});else{i.push({from:g,to:v.from+v.length,value:V.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})}),i.push({from:y.from,to:_,value:V.mark({attributes:{style:`background-color: ${m}`},class:`cm-ySelection`})});for(let t=v.number+1;t<y.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:V.line({attributes:{style:`background-color: ${m}`,class:`cm-yLineSelection`}})})}}i.push({from:d.index,to:d.index,value:V.widget({side:d.index-l.index>0?-1:1,block:!1,widget:new Ae(f,p)})})}),this.decorations=V.set(i,!0)}},Me=I.fromClass(je,{decorations:e=>e.decorations}),Ne=class{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}},G=A.define({combine(e){return e[e.length-1]}});R.define();var Pe=class{constructor(e){this.view=e,this.conf=e.state.facet(G),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(U),this._beforeChangeSelection=null,this._mux=v(),this._onStackItemAdded=({stackItem:e,changedParentTypes:t})=>{t.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!e.meta.has(this)&&e.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:t})=>{let n=t.meta.get(this);if(n){let t=this.syncConf.fromYRange(n);e.dispatch(e.state.update({selection:t,effects:[F.scrollIntoView(t)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on(`stack-item-added`,this._onStackItemAdded),this._undoManager.on(`stack-item-popped`,this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){e.selectionSet&&(e.transactions.length===0||e.transactions[0].annotation(W)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off(`stack-item-added`,this._onStackItemAdded),this._undoManager.off(`stack-item-popped`,this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}},Fe=I.fromClass(Pe),Ie=({state:e,dispatch:t})=>e.facet(G).undo()||!0,Le=({state:e,dispatch:t})=>e.facet(G).redo()||!0,Re=(e,t,{undoManager:n=new _(e)}={})=>{let r=new Te(e,t),i=[U.of(r),De];return t&&i.push(Oe,Me),n!==!1&&i.push(G.of(new Ne(n)),Fe,F.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?Ie(t):e.inputType===`historyRedo`?Le(t):!1}})),i},ze=[L.of({name:`javascript`,alias:[`js`,`jsx`],extensions:[`js`,`mjs`,`cjs`,`jsx`],load:async()=>fe({jsx:!0})}),L.of({name:`typescript`,alias:[`ts`,`tsx`],extensions:[`ts`,`mts`,`cts`,`tsx`],load:async()=>fe({typescript:!0,jsx:!0})}),L.of({name:`json`,alias:[`jsonc`],extensions:[`json`,`jsonc`],load:()=>t(()=>import(`./dist-DlS42TIP.js`).then(e=>e.json()),__vite__mapDeps([0,1,2,3,4]),import.meta.url)}),L.of({name:`yaml`,alias:[`yml`],extensions:[`yaml`,`yml`],load:()=>t(()=>import(`./dist-DeDgmJv2.js`).then(e=>e.yaml()),__vite__mapDeps([5,1,2,3,4]),import.meta.url)}),L.of({name:`css`,alias:[`scss`,`less`],extensions:[`css`,`scss`,`less`],load:async()=>ue()}),L.of({name:`html`,alias:[`htm`],extensions:[`html`,`htm`],load:async()=>pe()}),L.of({name:`python`,alias:[`py`],extensions:[`py`,`pyw`],load:()=>t(()=>import(`./dist-DR1MrLJC.js`).then(e=>e.python()),__vite__mapDeps([6,7,1,2,3,4]),import.meta.url)}),L.of({name:`rust`,alias:[`rs`],extensions:[`rs`],load:()=>t(()=>import(`./dist-BqO6NfD-.js`).then(e=>e.rust()),__vite__mapDeps([8,1,2,3,4]),import.meta.url)}),L.of({name:`markdown`,alias:[`md`,`mdx`],extensions:[`md`,`mdx`,`markdown`],load:async()=>se()}),L.of({name:`bash`,alias:[`sh`,`shell`,`zsh`],extensions:[`sh`,`bash`,`zsh`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:n},{shell:r}]=await Promise.all([t(()=>import(`./dist-CgLbXgrr.js`).then(e=>e.m),__vite__mapDeps([1,2,3]),import.meta.url),t(()=>import(`./shell-7yok6dsz.js`),[],import.meta.url)]);return new n(e.define(r))}}),L.of({name:`go`,alias:[`golang`],extensions:[`go`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:n},{go:r}]=await Promise.all([t(()=>import(`./dist-CgLbXgrr.js`).then(e=>e.m),__vite__mapDeps([1,2,3]),import.meta.url),t(()=>import(`./go-DatQmDtN.js`),[],import.meta.url)]);return new n(e.define(r))}})],Be=M.define(),Ve=M.define(),He=V.line({class:`agent-flash`}),Ue=N.define({create(){return V.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Be)){let{from:r,to:i}=n.value,a=[];for(let e=r;e<=i;){let n=t.state.doc.lineAt(e);a.push(He.range(n.from)),e=n.to+1}e=e.update({add:a,sort:!0})}else n.is(Ve)&&(e=V.none);return e},provide:e=>F.decorations.from(e)});function We(e){let t=e.getMap(`agent-flash`);return[Ue,I.define(e=>{let n=0,r=Date.now(),i=null,a=null,o=!1;function s(){let t=e.state.doc.length;t!==0&&(o||(e.dispatch({effects:Be.of({from:0,to:t})}),a&&clearTimeout(a),a=setTimeout(()=>{a=null,!o&&e.dispatch({effects:Ve.of(null)})},ne)))}let c=e=>{if(re(t),!k(t,r))return;r=Date.now();let a=Date.now();if(a-n<500){if(!i){let e=500-(a-n);i=setTimeout(()=>{i=null,n=Date.now(),s()},e)}return}n=a,s()};t.observe(c);let l=()=>{document.visibilityState===`visible`?k(t,r)&&(r=Date.now(),n=Date.now(),s()):r=Date.now()};return document.addEventListener(`visibilitychange`,l),{update(e){},destroy(){o=!0,t.unobserve(c),document.removeEventListener(`visibilitychange`,l),i&&=(clearTimeout(i),null),a&&=(clearTimeout(a),null)}}})]}var K=/\[([^\]\n]*)\]\((<[^>\n]+>|[^)\s\n]+)(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?\)/g,Ge=V.mark({class:`cm-md-internal-link`});function Ke(e,t){return t>0&&e[t-1]===`!`}function qe(e){let t=e[2]??``;return t.startsWith(`<`)&&t.endsWith(`>`)?t.slice(1,-1):t}function Je(e){let t=new B;for(let{from:n,to:r}of e.visibleRanges){let i=e.state.doc.sliceString(n,r);K.lastIndex=0;let a=K.exec(i);for(;a!==null;){let e=Ke(i,a.index)?null:g(qe(a));e&&e.kind!==`external`&&t.add(n+a.index,n+a.index+a[0].length,Ge),a=K.exec(i)}}return t.finish()}var Ye=I.fromClass(class{decorations;constructor(e){this.decorations=Je(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=Je(e.view))}},{decorations:e=>e.decorations}),Xe=F.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);K.lastIndex=0;let i=K.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=Ke(r.text,i.index)?null:g(qe(i));if(t&&t.kind!==`external`)return e.preventDefault(),t.kind===`doc`&&m(e)?(s(t),!0):(c(t),!0)}i=K.exec(r.text)}return!1}}),Ze=F.theme({".cm-md-internal-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-md-internal-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function Qe(){return[Ye,Xe,Ze]}var $e=5e3,q=null,et=0,tt=null,J=new Map;async function nt(){let e=Date.now();return q&&e-et<$e?q:(q=await T(),et=e,tt=st(q),q)}async function rt(e){let t=Date.now(),n=J.get(e);if(n!==void 0&&t-n.time<$e)return n.headings;try{let n=await E(e);return J.set(e,{headings:n,time:t}),n}catch(n){return console.warn(`[wiki-link-source] /api/page-headings fetch failed:`,n),J.set(e,{headings:[],time:t}),[]}}var Y=/\[\[[^\]]*?\]\]/g,it=V.mark({class:`cm-wiki-link`}),at=V.mark({class:`cm-wiki-link cm-wiki-link-broken`});function ot(e){let t=new Set;for(let n of e)t.add(n.docName.toLowerCase()),n.title&&t.add(n.title.toLowerCase());return t}function st(e){let t=ot(e);for(let n of e){let e=n.docName.split(`/`);e.pop();let r=``;for(let n of e)r=r?`${r}/${n}`:n,t.add(r.toLowerCase())}return t}function ct(e){return e.split(/[#|]/)[0].trim().toLowerCase()}function lt(e){let t=new B,n=q?tt:null;for(let{from:r,to:i}of e.visibleRanges){let a=e.state.doc.sliceString(r,i);Y.lastIndex=0;let o=Y.exec(a);for(;o!==null;){let e=it;if(n){let t=ct(o[0].slice(2,-2));t&&!n.has(t)&&(e=at)}t.add(r+o.index,r+o.index+o[0].length,e),o=Y.exec(a)}}return t.finish()}var ut=I.fromClass(class{decorations;cacheWarmAtBuild;constructor(e){this.cacheWarmAtBuild=q!==null,this.decorations=lt(e),this.cacheWarmAtBuild||this.warmCache(e)}update(e){let t=q!==null;(e.docChanged||e.viewportChanged||!this.cacheWarmAtBuild&&t)&&(this.cacheWarmAtBuild=t,this.decorations=lt(e.view))}warmCache(e){nt().then(()=>{try{e.dispatch({})}catch{}}).catch(e=>{console.warn(`[wiki-link-source] warmCache fetch failed:`,e)})}},{decorations:e=>e.decorations}),X=/\[\[([^[\]|#]+?)(?:#([^\]|]+?))?(?:\|([^\]]+?))?\]\]/g,dt=F.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);X.lastIndex=0;let i=X.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=i[1]?.trim(),n=i[2]?.trim()||null;if(t){let r=te(t,n);if(!r)return!1;e.preventDefault(),r.kind===`external`?window.open(r.url,`_blank`,`noopener,noreferrer`):m(e)?s(r):window.location.hash=r.anchor?`#/${r.docName}?anchor=${encodeURIComponent(r.anchor)}`:`#/${r.docName}`}return!0}i=X.exec(r.text)}return!1}});async function ft(e){let t=e.state.doc.sliceString(0,e.pos).match(/\[\[([^\]]*)$/);if(!t)return null;let n=t[1],r=e.pos-n.length,i=n.indexOf(`#`);if(i>0){let e=n.slice(0,i),t=n.slice(i+1),a=r+i+1,o=await rt(e);if(!o.length)return null;let s=w(o,t);return s.length?{from:a,filter:!1,options:s.map(e=>({label:e.text,detail:`H${e.level}`,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.slug+a},selection:{anchor:r+e.slug.length+a.length}})}}))}:null}return{from:r,filter:!1,options:C(await nt().catch(e=>(console.warn(`[wiki-link-source] Failed to fetch pages:`,e),[])),n).map(e=>({label:e.title,detail:e.title===e.docName?void 0:e.docName,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.docName+a},selection:{anchor:r+e.docName.length+a.length}})}}))}}var pt=F.theme({".cm-wiki-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-wiki-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function mt(){return[ut,dt,pt,ce.data.of({autocomplete:ft})]}var ht=V.mark({class:`cm-link-ref-broken`}),gt=/^\s{0,3}\[([^\]]+)\]:\s/,_t=/\[([^\]]*)\]\[([^\]]*)\]/g,vt=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function Z(e,t){let n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i];if(e<a.from)r=i-1;else if(e>=a.to)n=i+1;else return!0}return!1}function yt(e){let t=[];return j(e).iterate({enter(e){if(vt.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Q(e){let t=new Set,n=[],r=e.doc,i=yt(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(Z(n.from,i))continue;let a=gt.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!Z(t.from,i)&&!gt.test(t.text))for(_t.lastIndex=0;;){let e=_t.exec(t.text);if(!e)break;let r=t.from+e.index;if(Z(r,i))continue;let a=e[2]||e[1];n.push({from:r,to:r+e[0].length,label:a.toLowerCase()})}}let a=[];for(let e of n)t.has(e.label)||a.push(ht.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),V.set(a)}var bt=N.define({create(e){return Q(e)},update(e,t){return t.docChanged?Q(t.state):e},provide:e=>F.decorations.from(e)}),xt=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,St=V.mark({class:`cm-del`}),Ct=V.line({class:`cm-table-header`}),wt=V.line({class:`cm-table-row`});function Tt(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Et(e,t){let n=[],r=j(e);for(let{from:i,to:a}of t)r.iterate({from:i,to:a,enter(t){if(t.name===`Strikethrough`){let e=t.from,r=t.to,i=t.node.cursor();if(i.firstChild())do i.name===`StrikethroughMark`&&(i.from===t.from?e=i.to:r=i.from);while(i.nextSibling());return e<r&&n.push(St.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=xt.exec(r.text),a=i?i[1].length:2,o=V.line({class:`cm-list-item`,attributes:{style:`--list-hang: ${a}ch`}});n.push(o.range(r.from));return}if(t.name===`FencedCode`){let r=e.doc.lineAt(t.from),i=e.doc.lineAt(t.to);for(let t=r.number+1;t<i.number;t++){let r=e.doc.line(t),i=Tt(r.text),a=V.line({class:`cm-fenced-code-line`,attributes:{style:`--line-indent: ${i}`}});n.push(a.range(r.from))}return!1}if(t.name===`TableHeader`){let r=e.doc.lineAt(t.from);return n.push(Ct.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(wt.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(wt.range(r.from)),!1}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),V.set(n)}var Dt=class{decorations;constructor(e){this.decorations=Et(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=Et(e.view.state,e.view.visibleRanges))}},Ot=I.fromClass(Dt,{decorations:e=>e.decorations});function kt(){return[Ot,bt]}var At=r(),jt=ge({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),Mt=de({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),Nt=new Se,Pt=new Se;function $(e,t){let n=e.state.doc,r=1;if(n.lines>=1&&n.line(1).text===`---`){for(let e=2;e<=n.lines;e++)if(n.line(e).text===`---`){r=e+1;break}}let i=ee(),a=0;for(let o=r;o<=n.lines;o++){let r=n.line(o);if(!i(r.text)&&/^#{1,6}\s/.test(r.text)){if(a===t.index){e.dispatch({selection:P.cursor(r.from),effects:F.scrollIntoView(r.from,{y:`start`})}),e.focus();return}a++}}}function Ft(e,t){requestAnimationFrame(()=>{let n=e.state.doc,r=Math.min(t.offset,n.length);e.dispatch({selection:P.cursor(r),effects:F.scrollIntoView(r,{y:`center`})}),e.focus()})}function It(e){let t=(0,Ce.c)(29),{docName:n,ytext:r,provider:i,placeholder:o,isSourceModeActive:s}=e,c=(0,H.useRef)(null),u=(0,H.useRef)(null),[d,f]=(0,H.useState)(null);if(d)throw d;let{resolvedTheme:m}=a(),h;t[0]!==s||t[1]!==i.awareness?(h=()=>{let e=i.awareness;if(e)return e.setLocalStateField(`mode`,s?`source`:`wysiwyg`),()=>{e.setLocalStateField(`mode`,`wysiwyg`)}},t[0]=s,t[1]=i.awareness,t[2]=h):h=t[2];let g;t[3]!==s||t[4]!==i?(g=[i,s],t[3]=s,t[4]=i,t[5]=g):g=t[5],(0,H.useEffect)(h,g);let _=(0,H.useRef)(null),v;t[6]!==o||t[7]!==i||t[8]!==m||t[9]!==r?(v=()=>{let e=c.current;if(!e)return;let t=i.configuration.name??``,n,a=Lt;try{n=p({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let t=he({ydoc:i.document,ytext:r}),n=new F({state:ye.create({doc:r.toString(),extensions:[me,xe.of([oe]),se({base:ce,extensions:[le],codeLanguages:ze}),Re(r,i.awareness),We(i.document),mt(),Qe(),kt(),t,Nt.of(m===`dark`?jt:Mt),Pt.of(z(o??``)),F.lineWrapping,F.theme({"&":{height:`100%`}})]}),parent:e}),s=n.contentDOM;return s.addEventListener(`keydown`,a),s.addEventListener(`paste`,a),s.addEventListener(`drop`,a),s.addEventListener(`cut`,a),{view:n,ydoc:i.document,ytext:r,provider:i}}}),_.current=n,u.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),_.current=null,u.current=null,f(t instanceof Error?t:Error(String(t)))}return()=>{let e=_.current;e&&l(e),_.current=null,u.current=null}},t[6]=o,t[7]=i,t[8]=m,t[9]=r,t[10]=v):v=t[10];let y;t[11]!==i||t[12]!==r?(y=[r,i],t[11]=i,t[12]=r,t[13]=y):y=t[13],(0,H.useEffect)(v,y);let b,x;t[14]===m?(b=t[15],x=t[16]):(b=()=>{u.current&&u.current.dispatch({effects:Nt.reconfigure(m===`dark`?jt:Mt)})},x=[m],t[14]=m,t[15]=b,t[16]=x),(0,H.useEffect)(b,x);let S,C;t[17]===o?(S=t[18],C=t[19]):(S=()=>{u.current&&u.current.dispatch({effects:Pt.reconfigure(z(o??``))})},C=[o],t[17]=o,t[18]=S,t[19]=C),(0,H.useEffect)(S,C);let w,T;t[20]!==n||t[21]!==s?(T=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!s)return;let r=u.current;r&&($(r,t),ie(n))};return window.addEventListener(ae,e),()=>window.removeEventListener(ae,e)},w=[n,s],t[20]=n,t[21]=s,t[22]=w,t[23]=T):(w=t[22],T=t[23]),(0,H.useEffect)(T,w);let E,D;t[24]!==n||t[25]!==s?(E=()=>{if(!s)return;let e=u.current;if(!e)return;let t=_e(n);if(t){if(t.kind===`outline`){$(e,t.detail);return}Ft(e,t.detail)}},D=[n,s],t[24]=n,t[25]=s,t[26]=E,t[27]=D):(E=t[26],D=t[27]),(0,H.useEffect)(E,D);let O;return t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,At.jsx)(`div`,{ref:c,className:`source-editor h-full py-3`}),t[28]=O):O=t[28],O}function Lt(){return O()}export{It as SourceEditor};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./chunk-DECur_0Z.js";import{n as t,r as n,t as r}from"./compiler-runtime-Y11fyRVL.js";import{a as i,f as a,i as o,n as s,o as c,r as l,s as u,t as d,u as f}from"./panel-BCRdtBla.js";import{n as p}from"./button-BPXuMr5W.js";import{G as m,n as ee,q as te,rt as ne}from"./DocumentContext-CRsKuypY.js";import{x as re}from"./dialog-CtSN0d2b.js";import{Ft as ie,J as ae,M as oe,Rt as se,W as ce,Y as le,g as ue,n as de,v as fe}from"./PageListContext-BeAv6YTY.js";import{$ as h,A as g,B as _,Bt as v,Ct as y,D as pe,Dt as b,E as x,Et as me,Ft as he,G as S,H as ge,Ht as _e,I as C,It as ve,J as ye,K as be,L as w,Lt as xe,M as Se,N as T,Nt as E,P as Ce,Pt as D,Q as we,Rt as Te,S as Ee,St as De,T as Oe,Tt as O,U as ke,V as Ae,Vt as je,W as Me,Y as k,Z as Ne,_ as Pe,a as Fe,at as Ie,b as Le,bt as Re,c as ze,ct as Be,d as Ve,et as He,f as Ue,g as We,gt as Ge,h as Ke,ht as qe,i as Je,j as Ye,jt as Xe,k as Ze,kt as Qe,l as $e,lt as et,mt as tt,n as nt,nt as rt,o as it,ot as at,p as ot,pt as st,q as A,r as ct,s as lt,st as ut,t as dt,tt as ft,u as pt,ut as mt,v as ht,vt as j,w as gt,x as _t,xt as vt,y as yt,z as bt,zt as xt}from"./dist-CgLbXgrr.js";import{a as St,c as M,i as Ct,n as wt,o as Tt,r as Et,s as Dt,t as Ot}from"./dist-D2wwoXzm.js";import{i as kt,n as N,r as At,t as jt}from"./dist-GlH2KPqY.js";var Mt=e(t(),1),Nt=r(),Pt=new Map;function Ft(e,t){Pt.set(e,t)}function It(e){let t=Pt.get(e)??null;return Pt.delete(e),t}function Lt(e){Pt.delete(e)}var Rt=class e{static create(t,n,r,i,a){return new e(t,n,r,i+(i<<8)+t+(n<<4)|0,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[_.contextHash,r]]}addChild(e,t){e.prop(_.contextHash)!=this.hash&&(e=new S(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new S(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new S(ge.none,e,t,n,this.hashProp)})}},P;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(P||={});var zt=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},Bt=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return Ut(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function Vt(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==P.OrderedList?Xt:Yt)(n,t,!1);return r>0&&(e.type!=P.BulletList||qt(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var Ht={[P.Blockquote](e,t,n){return n.next==62?(n.markers.push(I(P.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(F(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0):!1},[P.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[P.OrderedList]:Vt,[P.BulletList]:Vt,[P.Document](){return!0}};function F(e){return e==32||e==9||e==10||e==13}function Ut(e,t=0){for(;t<e.length&&F(e.charCodeAt(t));)t++;return t}function Wt(e,t,n){for(;t>n&&F(e.charCodeAt(t-1));)t--;return t}function Gt(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function Kt(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function qt(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!F(n))return-1}return n&&e.next==45&&Qt(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(dn.SetextHeading)>-1||r<3?-1:1}function Jt(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function Yt(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||F(e.text.charCodeAt(e.pos+1)))&&(!n||Jt(t,P.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Xt(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!F(e.text.charCodeAt(r+1))||n&&!Jt(t,P.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Zt(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function Qt(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&F(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var $t=/^[ \t]*$/,en=/-->/,tn=/\?>/,nn=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,en],[/^\s*<\?/,tn],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?: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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,$t],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,$t]];function rn(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=nn.length-+!!n;e<t;e++)if(nn[e][0].test(r))return e;return-1}function an(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function on(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==P.CodeText?e[r].to=n:e.push(I(P.CodeText,t,n))}var sn={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(on(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){on(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==P.CodeText?on(o,e.from,e.to):o.push(e);s=[]}on(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&on(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=P.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(P.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Gt(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=Wt(t.text,t.text.length,o),c=[I(P.CodeMark,r,r+a)];o<s&&c.push(I(P.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&on(c,e.lineStart-1,e.lineStart),c.push(I(P.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}else{o=!0,n||(on(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(on(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(P.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Kt(t);return n<0?!1:(e.startContext(P.Blockquote,t.pos),e.addNode(P.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(qt(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(P.HorizontalRule,n),!0},BulletList(e,t){let n=Yt(t,e,!1);if(n<0)return!1;e.block.type!=P.BulletList&&e.startContext(P.BulletList,t.basePos,t.next);let r=an(t,t.pos+1);return e.startContext(P.ListItem,t.basePos,r-t.baseIndent),e.addNode(P.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Xt(t,e,!1);if(n<0)return!1;e.block.type!=P.OrderedList&&e.startContext(P.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=an(t,t.pos+n);return e.startContext(P.ListItem,t.basePos,r-t.baseIndent),e.addNode(P.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Zt(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=Wt(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!F(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(P.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(P.HeaderMark,o-r,a-r);let c=s.finish(P.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=rn(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=nn[n][1],a=[],o=i!=$t;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==en?P.CommentBlock:i==tn?P.ProcessingInstructionBlock:P.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},cn=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
1
+ import{r as e}from"./chunk-DECur_0Z.js";import{n as t,r as n,t as r}from"./compiler-runtime-Y11fyRVL.js";import{a as i,f as a,i as o,n as s,o as c,r as l,s as u,t as d,u as f}from"./panel-BCRdtBla.js";import{n as p}from"./button-BPXuMr5W.js";import{G as m,n as ee,q as te,rt as ne}from"./DocumentContext-C7zXwLGg.js";import{x as re}from"./dialog-CtSN0d2b.js";import{Ft as ie,J as ae,M as oe,Rt as se,W as ce,Y as le,g as ue,n as de,v as fe}from"./PageListContext-DNRRECTw.js";import{$ as h,A as g,B as _,Bt as v,Ct as y,D as pe,Dt as b,E as x,Et as me,Ft as he,G as S,H as ge,Ht as _e,I as C,It as ve,J as ye,K as be,L as w,Lt as xe,M as Se,N as T,Nt as E,P as Ce,Pt as D,Q as we,Rt as Te,S as Ee,St as De,T as Oe,Tt as O,U as ke,V as Ae,Vt as je,W as Me,Y as k,Z as Ne,_ as Pe,a as Fe,at as Ie,b as Le,bt as Re,c as ze,ct as Be,d as Ve,et as He,f as Ue,g as We,gt as Ge,h as Ke,ht as qe,i as Je,j as Ye,jt as Xe,k as Ze,kt as Qe,l as $e,lt as et,mt as tt,n as nt,nt as rt,o as it,ot as at,p as ot,pt as st,q as A,r as ct,s as lt,st as ut,t as dt,tt as ft,u as pt,ut as mt,v as ht,vt as j,w as gt,x as _t,xt as vt,y as yt,z as bt,zt as xt}from"./dist-CgLbXgrr.js";import{a as St,c as M,i as Ct,n as wt,o as Tt,r as Et,s as Dt,t as Ot}from"./dist-D2wwoXzm.js";import{i as kt,n as N,r as At,t as jt}from"./dist-GlH2KPqY.js";var Mt=e(t(),1),Nt=r(),Pt=new Map;function Ft(e,t){Pt.set(e,t)}function It(e){let t=Pt.get(e)??null;return Pt.delete(e),t}function Lt(e){Pt.delete(e)}var Rt=class e{static create(t,n,r,i,a){return new e(t,n,r,i+(i<<8)+t+(n<<4)|0,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[_.contextHash,r]]}addChild(e,t){e.prop(_.contextHash)!=this.hash&&(e=new S(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new S(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new S(ge.none,e,t,n,this.hashProp)})}},P;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(P||={});var zt=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},Bt=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return Ut(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function Vt(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==P.OrderedList?Xt:Yt)(n,t,!1);return r>0&&(e.type!=P.BulletList||qt(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var Ht={[P.Blockquote](e,t,n){return n.next==62?(n.markers.push(I(P.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(F(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0):!1},[P.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[P.OrderedList]:Vt,[P.BulletList]:Vt,[P.Document](){return!0}};function F(e){return e==32||e==9||e==10||e==13}function Ut(e,t=0){for(;t<e.length&&F(e.charCodeAt(t));)t++;return t}function Wt(e,t,n){for(;t>n&&F(e.charCodeAt(t-1));)t--;return t}function Gt(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function Kt(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function qt(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!F(n))return-1}return n&&e.next==45&&Qt(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(dn.SetextHeading)>-1||r<3?-1:1}function Jt(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function Yt(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||F(e.text.charCodeAt(e.pos+1)))&&(!n||Jt(t,P.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Xt(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!F(e.text.charCodeAt(r+1))||n&&!Jt(t,P.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Zt(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function Qt(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&F(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var $t=/^[ \t]*$/,en=/-->/,tn=/\?>/,nn=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,en],[/^\s*<\?/,tn],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?: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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,$t],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,$t]];function rn(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=nn.length-+!!n;e<t;e++)if(nn[e][0].test(r))return e;return-1}function an(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function on(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==P.CodeText?e[r].to=n:e.push(I(P.CodeText,t,n))}var sn={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(on(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){on(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==P.CodeText?on(o,e.from,e.to):o.push(e);s=[]}on(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&on(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=P.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(P.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Gt(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=Wt(t.text,t.text.length,o),c=[I(P.CodeMark,r,r+a)];o<s&&c.push(I(P.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&on(c,e.lineStart-1,e.lineStart),c.push(I(P.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}else{o=!0,n||(on(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(on(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(P.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Kt(t);return n<0?!1:(e.startContext(P.Blockquote,t.pos),e.addNode(P.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(qt(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(P.HorizontalRule,n),!0},BulletList(e,t){let n=Yt(t,e,!1);if(n<0)return!1;e.block.type!=P.BulletList&&e.startContext(P.BulletList,t.basePos,t.next);let r=an(t,t.pos+1);return e.startContext(P.ListItem,t.basePos,r-t.baseIndent),e.addNode(P.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Xt(t,e,!1);if(n<0)return!1;e.block.type!=P.OrderedList&&e.startContext(P.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=an(t,t.pos+n);return e.startContext(P.ListItem,t.basePos,r-t.baseIndent),e.addNode(P.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Zt(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=Wt(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!F(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(P.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(P.HeaderMark,o-r,a-r);let c=s.finish(P.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=rn(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=nn[n][1],a=[],o=i!=$t;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==en?P.CommentBlock:i==tn?P.ProcessingInstructionBlock:P.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},cn=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
2
2
  `+t.scrub(),i=this.advance(r);return i>-1&&i<r.length?this.complete(e,n,i):!1}finish(e,t){return(this.stage==2||this.stage==3)&&Ut(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,n){return e.addLeafElement(t,I(P.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;)if(this.stage==-1)return-1;else if(this.stage==0){if(!this.nextStage(Fn(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(I(P.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(Nn(e,Ut(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=Ut(e,this.pos),n=0;if(t>this.pos){let r=Pn(e,t,this.start);if(r){let t=ln(e,r.to-this.start);t>0&&(this.nextStage(r),n=t)}}return n||=ln(e,this.pos),n>0&&n<e.length?n:-1}else return ln(e,this.pos)}};function ln(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!F(n))return-1}return t}var un=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:Qt(t),i=t.next;if(r<0)return!1;let a=I(P.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,I(i==61?P.SetextHeading1:P.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),a])),!0}finish(){return!1}},dn={LinkReference(e,t){return t.content.charCodeAt(0)==91?new cn(t):null},SetextHeading(){return new un}},fn=[(e,t)=>Zt(t)>=0,(e,t)=>Gt(t)>=0,(e,t)=>Kt(t)>=0,(e,t)=>Yt(t,e,!0)>=0,(e,t)=>Xt(t,e,!0)>=0,(e,t)=>qt(t,e,!0)>=0,(e,t)=>rn(t,e,!0)>=0],pn={text:``,end:0},mn=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new Bt,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=Rt.create(P.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new zn(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let n=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;t<e.markers.length&&(!n||e.markers[t].from<n.end);){let n=e.markers[t++];this.addNode(n.type,n.from,n.to)}if(!n)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;start:for(;;){for(let t of this.parser.blockParsers)if(t){let n=t(this,e);if(n!=0){if(n==1)return null;e.forward();continue start}}break}let t=new zt(this.lineStart+e.pos,e.text.slice(e.pos));for(let e of this.parser.leafBlockParsers)if(e){let n=e(this,t);n&&t.parsers.push(n)}lines:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,t))break lines}for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+=`
3
3
  `+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=Bn(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=pn;if(t.end=e,e>=this.to)t.text=``;else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let e=this.absoluteLineStart,n=this.rangeI;for(;this.ranges[n].to<t.end;){n++;let r=this.ranges[n].from,i=this.lineChunkAt(r);t.end=r+i.length,t.text=t.text.slice(0,this.ranges[n-1].to-e)+i,e=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let t=this.stack[e.depth],n=this.parser.skipContextMarkup[t.type];if(!n)throw Error(`Unhandled block context `+P[t.type]);let r=this.line.markers.length;if(!n(t,this,e)){this.line.markers.length>r&&(t.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),n;if(this.input.lineChunks)n=t==`
4
4
  `?``:t;else{let e=t.indexOf(`