@inkeep/open-knowledge 0.0.0-dev-20260425212030 → 0.0.0-dev-20260426174941
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.
- package/dist/THIRD_PARTY_NOTICES.md +5423 -0
- package/dist/cli.mjs +4 -4
- package/dist/constants-PF4sn_jZ.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-fnfrY0dl.mjs → init-BMCljmwm.mjs} +2 -2
- package/dist/{init-D-GOVq98.mjs → init-BuaWX5H3.mjs} +3 -3
- package/dist/init-C8byYxDo.mjs +1 -0
- package/dist/init-_yiWlR63.mjs +1 -0
- package/dist/{loader-BRo8pPHW.mjs → loader-CLLp9lGO.mjs} +2 -2
- package/dist/loader-Ds0A_tan.mjs +1 -0
- package/dist/{paths-C50UJWlj.mjs → paths-B5kWDyFj.mjs} +2 -2
- package/dist/paths-BVo_Owap.mjs +1 -0
- package/dist/{preview-SjLLXOnK.mjs → preview-OhPPhA34.mjs} +2 -2
- package/dist/preview-WpG0-sgj.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-DgzyXqn2.js → ActivityModeContent-D0IBEocY.js} +1 -1
- package/dist/public/assets/DocumentContext-JchuLhmY.js +5 -0
- package/dist/public/assets/{GraphPanel-D8k5I70O.js → GraphPanel-Cbdtn-PM.js} +1 -1
- package/dist/public/assets/McpConsentDialogBody-OUzp0vNz.js +1 -0
- package/dist/public/assets/{PageListContext-BMPOeSCn.js → PageListContext-B5VjPPMf.js} +59 -59
- package/dist/public/assets/{SourceEditor-Buo7XU1f.js → SourceEditor-2A0A15_U.js} +1 -1
- package/dist/public/assets/{clipboard-Cww2W4TE.js → clipboard-DpYzM0tN.js} +2 -2
- package/dist/public/assets/index-DYVEcGnt.js +1838 -0
- package/dist/public/assets/index-UjCvBlfb.css +1 -0
- package/dist/public/assets/{toggle-group-DHcz1Spj.js → toggle-group-Cga3MGFU.js} +1 -1
- package/dist/public/assets/tooltip-bZXi-Vss.js +1 -0
- package/dist/public/index.html +7 -7
- package/dist/src-J3PaPJrI.mjs +1 -0
- package/dist/{start-BUOymW9g.mjs → start-Dp0EtwvR.mjs} +2 -2
- package/dist/start-EQNzm5Jw.mjs +1 -0
- package/package.json +4 -3
- package/dist/constants-BEMZSQ6j.mjs +0 -2
- package/dist/init-BL9p0u-R.mjs +0 -1
- package/dist/init-BShshEHA.mjs +0 -1
- package/dist/loader-Svyk0Msf.mjs +0 -1
- package/dist/paths-E6OWBb8u.mjs +0 -1
- package/dist/preview-CptgYPKk.mjs +0 -1
- package/dist/public/assets/DocumentContext-sx4y_fGB.js +0 -5
- package/dist/public/assets/McpConsentDialogBody-BLYVcOqD.js +0 -1
- package/dist/public/assets/index-C91q9hh3.js +0 -27
- package/dist/public/assets/index-DLJBF2zC.css +0 -1
- package/dist/public/assets/tooltip-Be1xrEel.js +0 -1
- package/dist/src-DCj04215.mjs +0 -1
- package/dist/start-Dpsr1iNE.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-rtdrPcLu.js";import{B as o,D as s,E as c,G as l,H as u,J as d,K as f,M as p,O as m,P as h,Q as g,T as _,U 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-
|
|
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-rtdrPcLu.js";import{B as o,D as s,E as c,G as l,H as u,J as d,K as f,M as p,O as m,P as h,Q as g,T as _,U 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-JchuLhmY.js";import{M as ee,P as te,R as k,k as ne,p as re}from"./PageListContext-B5VjPPMf.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-DpYzM0tN.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(l(t.yanchor),l(t.yhead))}},Te=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new u(e)}toYPos(e,t=0){return f(this.ytext,e,t)}fromYPos(e){let t=y(l(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 d(`span`,[b(`class`,`cm-ySelectionCaret`),b(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[x(``),d(`div`,[b(`class`,`cm-ySelectionCaretDot`)]),x(``),d(`div`,[b(`class`,`cm-ySelectionInfo`)],[x(this.name)]),x(``)])}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:l(a.cursor.anchor),s=a.cursor==null?null:l(a.cursor.head);if(i!=null){let e=f(t,i.anchor),n=f(t,i.head);(a.cursor==null||!v(o,e)||!v(s,n))&&r.setLocalStateField(`cursor`,{anchor:e,head:n})}else a.cursor!=null&&n&&r.setLocalStateField(`cursor`,null)}r.getStates().forEach((a,o)=>{if(o===r.doc.clientID)return;let s=a.cursor;if(s==null||s.anchor==null||s.head==null)return;let c=y(s.anchor,n),l=y(s.head,n);if(c==null||l==null||c.type!==t||l.type!==t)return;let{color:u=`#30bced`,name:d=`Anonymous`}=a.user||{},f=a.user&&a.user.colorLight||u+`33`,p=g(c.index,l.index),m=S(c.index,l.index),h=e.view.state.doc.lineAt(p),_=e.view.state.doc.lineAt(m);if(h.number===_.number)i.push({from:p,to:m,value:V.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});else{i.push({from:p,to:h.from+h.length,value:V.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})}),i.push({from:_.from,to:m,value:V.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});for(let t=h.number+1;t<_.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:V.line({attributes:{style:`background-color: ${f}`,class:`cm-yLineSelection`}})})}}i.push({from:l.index,to:l.index,value:V.widget({side:l.index-c.index>0?-1:1,block:!1,widget:new Ae(u,d)})})}),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=o(),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 u(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)})},re)))}let c=e=>{if(te(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:_(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:_(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=ne(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),l=(0,H.useRef)(null),[u,d]=(0,H.useState)(null);if(u)throw u;let{resolvedTheme:f}=a(),m;t[0]!==s||t[1]!==i.awareness?(m=()=>{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]=m):m=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)(m,g);let _=(0,H.useRef)(null),v;t[6]!==o||t[7]!==i||t[8]!==f||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(f===`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,l.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),_.current=null,l.current=null,d(t instanceof Error?t:Error(String(t)))}return()=>{let e=_.current;e&&h(e),_.current=null,l.current=null}},t[6]=o,t[7]=i,t[8]=f,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]===f?(b=t[15],x=t[16]):(b=()=>{l.current&&l.current.dispatch({effects:Nt.reconfigure(f===`dark`?jt:Mt)})},x=[f],t[14]=f,t[15]=b,t[16]=x),(0,H.useEffect)(b,x);let S,C;t[17]===o?(S=t[18],C=t[19]):(S=()=>{l.current&&l.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=l.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=l.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-rtdrPcLu.js";import{n as p}from"./button-B1XQHQcX.js";import{K as m,W as ee,n as te,nt as ne}from"./DocumentContext-sx4y_fGB.js";import{C as re}from"./dialog-xzAlDsHy.js";import{D as ie,Ft as ae,Mt as oe,U as se,W as ce,f as h,m as le,n as ue,z as de}from"./PageListContext-BMPOeSCn.js";import{$ as g,A as _,B as v,Bt as y,Ct as b,D as fe,Dt as pe,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=[[v.contextHash,r]]}addChild(e,t){e.prop(v.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-rtdrPcLu.js";import{n as p}from"./button-B1XQHQcX.js";import{K as m,W as ee,n as te,nt as ne}from"./DocumentContext-JchuLhmY.js";import{C as re}from"./dialog-xzAlDsHy.js";import{At as ie,D as ae,Dt as oe,U as se,W as ce,f as h,m as le,n as ue,z as de}from"./PageListContext-B5VjPPMf.js";import{$ as g,A as _,B as v,Bt as y,Ct as b,D as fe,Dt as pe,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=[[v.contextHash,r]]}addChild(e,t){e.prop(v.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(`
|
|
@@ -29,4 +29,4 @@ import{r as e}from"./chunk-DECur_0Z.js";import{n as t,r as n,t as r}from"./compi
|
|
|
29
29
|
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new zu(this):new Nu(this)}getCursor(e,t=0,n){let r=e.doc?e:me.create({doc:e});return n??=r.doc.length,this.regexp?Fu(this,r,t,n):ju(this,r,t,n)}},ku=class{constructor(e){this.spec=e}};function Au(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function ju(e,t,n,r){let i;return e.wholeWord&&(i=Mu(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Au(e.test,t,i)),new au(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Mu(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(Iu(i,n-a))!=b.Word||t(Lu(i,n-a))!=b.Word)&&(t(Lu(i,r-a))!=b.Word||t(Iu(i,r-a))!=b.Word))}var Nu=class extends ku{constructor(e){super(e)}nextMatch(e,t,n){let r=ju(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=ju(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=ju(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=ju(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=ju(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Pu(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function Fu(e,t,n,r){let i;return e.wholeWord&&(i=Ru(t.charCategorizer(t.selection.main.head))),e.test&&(i=Pu(e.test,t,i)),new cu(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function Iu(e,t){return e.slice(je(e,t,!1),t)}function Lu(e,t){return e.slice(t,je(e,t))}function Ru(e){return(t,n,r)=>!r[0].length||(e(Iu(r.input,r.index))!=b.Word||e(Lu(r.input,r.index))!=b.Word)&&(e(Lu(r.input,r.index+r[0].length))!=b.Word||e(Iu(r.input,r.index+r[0].length))!=b.Word)}var zu=class extends ku{nextMatch(e,t,n){let r=Fu(this.spec,e,n,e.doc.length).next();return r.done&&(r=Fu(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=Fu(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=Fu(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=Fu(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},Bu=E.define(),Vu=E.define(),Hu=D.define({create(e){return new Uu(td(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Bu)?e=new Uu(n.value.create(),e.panel):n.is(Vu)&&(e=new Uu(e.query,n.value?ed:null));return e},provide:e=>Ge.from(e,e=>e.panel)}),Uu=class{constructor(e,t){this.query=e,this.panel=t}},Wu=A.mark({class:`cm-searchMatch`}),Gu=A.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Ku=Ne.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Hu))}update(e){let t=e.state.field(Hu);(t!=e.startState.field(Hu)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return A.none;let{view:n}=this,r=new Xe;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Gu:Wu)})}return r.finish()}},{decorations:e=>e.decorations});function qu(e){return t=>{let n=t.state.field(Hu,!1);return n&&n.query.spec.valid?e(t,n):id(t)}}var Ju=qu((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=O.single(r.from,r.to),a=e.state.facet(Du);return e.dispatch({selection:i,effects:[ud(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),rd(e),!0}),Yu=qu((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=O.single(i.from,i.to),o=e.state.facet(Du);return e.dispatch({selection:a,effects:[ud(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),rd(e),!0}),Xu=qu((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:O.create(n.map(e=>O.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Zu=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new au(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(O.range(t.value.from,t.value.to))}return t(e.update({selection:O.create(a,o),userEvent:`select.search.matches`})),!0},Qu=qu((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(k.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=O.single(o.from,o.to).map(d),u.push(ud(e,o)),u.push(n.facet(Du).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),$u=qu((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:k.announce.of(r),userEvent:`input.replace.all`}),!0});function ed(e){return e.state.facet(Du).createPanel(e)}function td(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(Du);return new Ou({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function nd(e){let t=rt(e,ed);return t&&t.dom.querySelector(`[main-field]`)}function rd(e){let t=nd(e);t&&t==e.root.activeElement&&t.select()}var id=e=>{let t=e.state.field(Hu,!1);if(t&&t.panel){let n=nd(e);if(n&&n!=e.root.activeElement){let r=td(e.state,t.query.spec);r.valid&&e.dispatch({effects:Bu.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Vu.of(!0),t?Bu.of(td(e.state,t.query.spec)):E.appendConfig.of(fd)]});return!0},ad=e=>{let t=e.state.field(Hu,!1);if(!t||!t.panel)return!1;let n=rt(e,ed);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Vu.of(!1)}),!0},od=[{key:`Mod-f`,run:id,scope:`editor search-panel`},{key:`F3`,run:Ju,shift:Yu,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:Ju,shift:Yu,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:ad,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Zu},{key:`Mod-Alt-g`,run:mu},{key:`Mod-d`,run:Eu,preventDefault:!0}],sd=class{constructor(e){this.view=e;let t=this.query=e.state.field(Hu).query.spec;this.commit=this.commit.bind(this),this.searchField=j(`input`,{value:t.search,placeholder:q(e,`Find`),"aria-label":q(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=j(`input`,{value:t.replace,placeholder:q(e,`Replace`),"aria-label":q(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=j(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=j(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=j(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return j(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=j(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>Ju(e),[q(e,`next`)]),n(`prev`,()=>Yu(e),[q(e,`previous`)]),n(`select`,()=>Xu(e),[q(e,`all`)]),j(`label`,null,[this.caseField,q(e,`match case`)]),j(`label`,null,[this.reField,q(e,`regexp`)]),j(`label`,null,[this.wordField,q(e,`by word`)]),...e.state.readOnly?[]:[j(`br`),this.replaceField,n(`replace`,()=>Qu(e),[q(e,`replace`)]),n(`replaceAll`,()=>$u(e),[q(e,`replace all`)])],j(`button`,{name:`close`,onclick:()=>ad(e),"aria-label":q(e,`close`),type:`button`},[`×`])])}commit(){let e=new Ou({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Bu.of(e)}))}keydown(e){tt(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Yu:Ju)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Qu(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Bu)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Du).top}};function q(e,t){return e.state.phrase(t)}var cd=30,ld=/[\s\.,:;?!]/;function ud(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-cd),o=Math.min(i,n+cd),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<cd;e++)if(!ld.test(s[e+1])&&ld.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-cd;e--)if(!ld.test(s[e-1])&&ld.test(s[e])){s=s.slice(0,e);break}}return k.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var dd=k.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),fd=[Hu,Qe.low(Ku),dd],pd=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},md=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Dd).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Xe,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Rd(s);if(i)o.add(n,n,A.widget({widget:new jd(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,A.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,hd(f))}};function hd(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new pd(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new pd(r.from,n,r.diagnostic)}),r}function gd(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Dd).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(vd))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function _d(e,t){return e.field(J,!1)?t:t.concat(E.appendConfig.of(zd))}var vd=E.define(),yd=E.define(),bd=E.define(),J=D.define({create(){return new md(A.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=hd(n,e.selected.diagnostic,i)||hd(n,null,i)}!n.size&&i&&t.state.facet(Dd).autoPanel&&(i=null),e=new md(n,i,r)}for(let n of t.effects)if(n.is(vd)){let r=t.state.facet(Dd).autoPanel?n.value.length?Nd.open:null:e.panel;e=md.init(n.value,r,t.state)}else n.is(yd)?e=new md(e.diagnostics,n.value?Nd.open:null,e.selected):n.is(bd)&&(e=new md(e.diagnostics,e.panel,n.value));return e},provide:e=>[Ge.from(e,e=>e.panel),k.decorations.from(e,e=>e.diagnostics)]}),xd=A.mark({class:`cm-lintRange cm-lintRange-active`});function Sd(e,t,n){let{diagnostics:r}=e.state.field(J),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Dd).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:Cd(e,i)}}}:null}function Cd(e,t){return j(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Ad(e,t,!1)))}var wd=e=>{let t=e.state.field(J,!1);(!t||!t.panel)&&e.dispatch({effects:_d(e.state,[yd.of(!0)])});let n=rt(e,Nd.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},Td=e=>{let t=e.state.field(J,!1);return!t||!t.panel?!1:(e.dispatch({effects:yd.of(!1)}),!0)},Ed=[{key:`Mod-Shift-m`,run:wd,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(J,!1);if(!t)return!1;let n=e.state.selection.main,r=hd(t.diagnostics,null,n.to+1);return!r&&(r=hd(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Dd=pe.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...xt(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Od,tooltipFilter:Od,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Od(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function kd(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Ad(e,t,n){let r=n?kd(t.actions):[];return j(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},j(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=hd(e.state.field(J).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),j(`u`,s.slice(c,c+1)),s.slice(c+1)];return j(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&j(`div`,{class:`cm-diagnosticSource`},t.source))}var jd=class extends we{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return j(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Md=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Ad(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Nd=class e{constructor(e){this.view=e,this.items=[],this.list=j(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Td(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=kd(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=hd(this.view.state.field(J).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=j(`div`,{class:`cm-panel-lint`},this.list,j(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>Td(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(J).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(J),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new Md(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Md(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=hd(this.view.state.field(J).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:bd.of(t)})}static open(t){return new e(t)}};function Pd(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Fd(e){return Pd(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Id=k.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Fd(`#d11`)},".cm-lintRange-warning":{backgroundImage:Fd(`orange`)},".cm-lintRange-info":{backgroundImage:Fd(`#999`)},".cm-lintRange-hint":{backgroundImage:Fd(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Ld(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Rd(e){let t=`hint`,n=1;for(let r of e){let e=Ld(r.severity);e>n&&(n=e,t=r.severity)}return t}var zd=[J,k.decorations.compute([J],e=>{let{selected:t,panel:n}=e.field(J);return!t||!n||t.from==t.to?A.none:A.set([xd.range(t.from,t.to)])}),Be(Sd,{hideOn:gd}),Id],Bd=[mt(),at(),ut(),ec(),We(),He(),ft(),me.allowMultipleSelections.of(!0),Oe(),Se(Ve,{fallback:!0}),ze(),Et(),wt(),st(),g(),Ie(),_u(),et.of([...Ct,...nu,...od,...vc,...ht,...Tt,...Ed])];ut(),ec(),He(),Se(Ve,{fallback:!0}),et.of([...nu,...vc]);function Vd(e,t){let n=(0,Nt.c)(4),r=t===void 0?!1:t,[i,a]=(0,Mt.useState)(void 0),o=(0,Mt.useRef)(null),s,c;return n[0]!==r||n[1]!==e?(s=()=>{if(r||e.length===0){a(void 0);return}let t=function(){let t=window.innerHeight/2,n,r;for(let i of e){let e=document.getElementById(i);if(!e)continue;let a=e.getBoundingClientRect().top;a<0?n=i:r===void 0&&a<t&&(r=i)}a(r??n??e[0])},n=function(){o.current===null&&(o.current=requestAnimationFrame(()=>{o.current=null,t()}))};return document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),t(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}},c=[e,r],n[0]=r,n[1]=e,n[2]=s,n[3]=c):(s=n[2],c=n[3]),(0,Mt.useEffect)(s,c),i}var Y=n(),Hd=300;async function Ud(e){let t=await fetch(`/api/page-headings?docName=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Server error: ${t.status} ${t.statusText}`);let n=await t.json();if(!n.ok)throw Error(n.error??`Failed to load headings`);return n.headings??[]}var Wd=32,Gd=6,Kd=6,qd=8;function Jd(e){return(e-1)*qd+.5}function Yd(e){if(e.length===0)return``;let t=[];for(let n=0;n<e.length;n++){let r=Jd(e[n].level),i=n*Wd+Gd,a=n*Wd+Wd-Kd;t.push(`${n===0?`M`:`L`}${r} ${i}`),t.push(`L${r} ${a}`)}return t.join(` `)}var Xd=`open-knowledge:outline-nav`;function Zd(e){let t=(0,Nt.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Y.jsx)(ne,{name:`outline-panel`,children:(0,Y.jsx)(Qd,{...e})}),t[0]=e,t[1]=n),n}function Qd(e){let t=(0,Nt.c)(54),{docName:n,isSourceMode:r,className:m}=e,ee=m===void 0?``:m,{pages:ne,loading:re}=ue(),ie=a(),{activeProvider:ae,activeDocName:oe}=te(),se,ce;t[0]===n?(se=t[1],ce=t[2]):(se=[`page-headings`,n],ce=()=>Ud(n),t[0]=n,t[1]=se,t[2]=ce);let h;t[3]!==n||t[4]!==re||t[5]!==ne?(h=!re&&ne.has(n),t[3]=n,t[4]=re,t[5]=ne,t[6]=h):h=t[6];let le;t[7]!==se||t[8]!==ce||t[9]!==h?(le={queryKey:se,queryFn:ce,enabled:h,staleTime:1/0},t[7]=se,t[8]=ce,t[9]=h,t[10]=le):le=t[10];let{data:de,isLoading:g,error:_}=f(le),v;t[11]===de?v=t[12]:(v=de===void 0?[]:de,t[11]=de,t[12]=v);let y=v,b,fe;t[13]!==oe||t[14]!==ae||t[15]!==n||t[16]!==ie?(b=()=>{if(!ae||oe!==n)return;let e=ae.document,t=null,r=()=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,ie.invalidateQueries({queryKey:[`page-headings`,n]})},Hd)};return e.on(`update`,r),()=>{e.off(`update`,r),t!==null&&clearTimeout(t)}},fe=[ae,oe,n,ie],t[13]=oe,t[14]=ae,t[15]=n,t[16]=ie,t[17]=b,t[18]=fe):(b=t[17],fe=t[18]),(0,Mt.useEffect)(b,fe);let pe;t[19]===y?pe=t[20]:(pe=y.map(ef),t[19]=y,t[20]=pe);let x=Vd(pe,r),me;t[21]!==x||t[22]!==y?(me=x?y.findIndex(e=>e.slug===x):-1,t[21]=x,t[22]=y,t[23]=me):me=t[23];let he=me,S;t[24]!==n||t[25]!==r?(S=function(e,t){let i={index:e,slug:t,mode:r?`source`:`wysiwyg`};i.mode===`source`&&Ft(n,{kind:`outline`,detail:i}),window.dispatchEvent(new CustomEvent(Xd,{detail:i}))},t[24]=n,t[25]=r,t[26]=S):S=t[26];let ge=S,_e=(y.reduce($d,1)-1)*qd+1,C=y.length*Wd,ve;t[27]===y?ve=t[28]:(ve=Yd(y),t[27]=y,t[28]=ve);let ye=ve,be=ye?`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${_e} ${C}"><path d="${ye}" stroke="black" stroke-width="2" fill="none" /></svg>`)}")`:void 0,w=he>=0?he*Wd+Gd:0,xe=he>=0?Wd-Gd-Kd:0,Se;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Y.jsx)(u,{children:`Outline`}),t[29]=Se):Se=t[29];let T;t[30]!==y.length||t[31]!==g?(T=!g&&(0,Y.jsx)(l,{children:y.length}),t[30]=y.length,t[31]=g,t[32]=T):T=t[32];let E;t[33]===T?E=t[34]:(E=(0,Y.jsxs)(c,{children:[Se,T]}),t[33]=T,t[34]=E);let Ce;t[35]!==x||t[36]!==_||t[37]!==ge||t[38]!==y||t[39]!==g||t[40]!==ye||t[41]!==be||t[42]!==C||t[43]!==_e||t[44]!==xe||t[45]!==w?(Ce=_?(0,Y.jsx)(i,{className:`px-2`,children:_ instanceof Error?_.message:`Failed to load headings`}):y.length===0&&!g?(0,Y.jsx)(o,{className:`px-2`,children:`No headings yet.`}):(0,Y.jsxs)(`nav`,{"aria-label":`Document outline`,className:`relative`,children:[(0,Y.jsx)(`svg`,{width:_e,height:C,className:`pointer-events-none absolute left-0 top-0`,"aria-hidden":`true`,children:(0,Y.jsx)(`path`,{d:ye,fill:`none`,strokeWidth:`1`,style:{stroke:`var(--border)`}})}),be&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute left-0 top-0`,style:{width:_e,height:C,maskImage:be,WebkitMaskImage:be},children:(0,Y.jsx)(`div`,{className:`w-full motion-safe:[transition:transform_0.25s_var(--ease-out-strong),height_0.1s_var(--ease-out-strong)]`,style:{transform:`translateY(${w}px)`,height:xe,backgroundColor:`var(--primary)`}})}),y.map((e,t)=>{let n=e.slug===x;return(0,Y.jsx)(`button`,{type:`button`,"aria-current":n?`location`:void 0,onClick:()=>ge(t,e.slug),className:p(`w-full cursor-pointer truncate py-1.5 pe-2 text-left text-sm transition-colors`,n?`font-medium text-primary`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${(e.level-1)*qd+16}px`},title:e.text,children:e.text},t)})]}),t[35]=x,t[36]=_,t[37]=ge,t[38]=y,t[39]=g,t[40]=ye,t[41]=be,t[42]=C,t[43]=_e,t[44]=xe,t[45]=w,t[46]=Ce):Ce=t[46];let D;t[47]!==g||t[48]!==Ce?(D=(0,Y.jsx)(s,{className:`px-3 py-2`,"aria-busy":g,children:Ce}),t[47]=g,t[48]=Ce,t[49]=D):D=t[49];let we;return t[50]!==ee||t[51]!==E||t[52]!==D?(we=(0,Y.jsxs)(d,{className:ee,children:[E,D]}),t[50]=ee,t[51]=E,t[52]=D,t[53]=we):we=t[53],we}function $d(e,t){return Math.max(e,t.level)}function ef(e){return e.slug}function tf(e){if(!e)return`plaintext`;if(e.types.includes(`vscode-editor-data`))return`vscode`;if(e.types.includes(`text/x-gfm`))return`gfm`;let t=e.getData(`text/html`);return t?/data-pm-slice/i.test(t)?`pm-origin`:/docs-internal-guid-/i.test(t)?`gdocs`:/xmlns:o="urn:schemas-microsoft-com:office/i.test(t)||/<meta[^>]*Generator[^>]*Microsoft Word/i.test(t)?`word`:/class="gmail_|class='gmail_/i.test(t)?`gmail`:/notionvc:/i.test(t)?`notion`:/Cocoa HTML Writer/i.test(t)?`apple`:/c-message_kit__|c-message__|c-compose/i.test(t)?`slack`:/google-sheets-html-origin/i.test(t)?`gsheets`:/data-hovercard-type=/i.test(t)?`github`:`generic`:`plaintext`}var nf=250,rf=100;function X(e,t){let n=performance.now()-e;n<(t.op===`paste`?nf:rf)||console.warn(JSON.stringify({event:`clipboard-slow-op`,op:t.op,view:t.view,elapsedMs:Math.round(n),branch:t.branch,source:t.source,...t.htmlBytes==null?{}:{htmlBytes:t.htmlBytes}}))}function Z(e){console.warn(JSON.stringify({event:`clipboard-source-detected`,view:e.view,source:e.source,branch:e.branch}))}function Q(e){console.warn(JSON.stringify({event:`clipboard-html-conversion-failed`,view:e.view,stage:e.stage,source:e.source,...e.branch==null?{}:{branch:e.branch},reason:e.reason,...e.errorClass==null?{}:{errorClass:e.errorClass},...e.htmlBytes==null?{}:{htmlBytes:e.htmlBytes}}))}function af(e){console.warn(JSON.stringify({event:`clipboard-serialize-failed`,view:e.view,kind:e.kind,reason:e.reason}))}function of(e){console.warn(JSON.stringify({event:`clipboard-chunked-insert-failed`,view:e.view,chunksCompleted:e.chunksCompleted,totalChunks:e.totalChunks,bytesWritten:e.bytesWritten,bytesRemaining:e.bytesRemaining,reason:e.reason}))}function $(e){if(e instanceof le)return`HtmlPayloadTooLargeError`;if(e instanceof h)return`ChunkedInsertError`;if(e instanceof Error&&e.name&&e.name!==`Error`)return e.name}var sf=/^```/m,cf=/^#{1,6} /m,lf=/^[-*+] /m,uf=/^\d+[.)] /m,df=/\[[^\]\n]+\]\([^)\n]+\)/,ff=/^\|.*\|$/m,pf=/^\|?\s*(:?-+:?)(\s*\|\s*:?-+:?)+\s*\|?$/m,mf=/\$\$[\s\S]+?\$\$/;function hf(e){if(!e)return!1;let t=0;sf.test(e)&&t++,cf.test(e)&&t++,lf.test(e)&&t++,uf.test(e)&&t++,df.test(e)&&t++,ff.test(e)&&pf.test(e)&&t++,mf.test(e)&&t++;let n=e.split(`
|
|
30
30
|
`).length,r=Math.min(3,Math.floor(n/5));return t>=Math.max(1,r)}var gf=3e3,_f=new Map;function vf(e,t=`Pasted as plain text — some formatting could not be converted.`){let n=Date.now();return n-(_f.get(e)??0)<gf?!1:(_f.set(e,n),re.error(t),!0)}var yf=!1,bf=!1;function xf(e){yf=e.shiftKey}function Sf(e){(e.key===`Shift`||!e.shiftKey)&&(yf=!1)}function Cf(){yf=!1}function wf(){bf||typeof window>`u`||(window.addEventListener(`keydown`,xf,!0),window.addEventListener(`keyup`,Sf,!0),window.addEventListener(`blur`,Cf,!0),bf=!0)}function Tf(){wf()}function Ef(){return wf(),yf}function Df(e){return Ef()?!0:e.shiftKey===!0}function Of(e){return(t,n)=>{let r=n.clipboardData;if(!r||r.types.length===0)return!1;let i=performance.now(),a=tf(r),o=r.getData(`text/plain`),s=r.getData(`text/html`);if(Df(n))return o&&Af(t,o),Z({view:`wysiwyg`,branch:`shift`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`shift`,source:a}),!0;if(kf(t))return o&&Af(t,o),Z({view:`wysiwyg`,branch:`codeblock`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`codeblock`,source:a}),!0;let c=r.getData(`vscode-editor-data`);if(c&&o&&Mf(t,c,o,a))return Z({view:`wysiwyg`,branch:`A`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`A`,source:a}),!0;let l=r.getData(`text/x-gfm`);return l&&Nf(t,l,e,`B`,a)?(Z({view:`wysiwyg`,branch:`B`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`B`,source:a}),!0):s&&/data-pm-slice/i.test(s)?(Z({view:`wysiwyg`,branch:`C`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`C`,source:a}),!1):o&&s&&hf(o)&&Nf(t,o,e,`B`,a)?(Z({view:`wysiwyg`,branch:`B`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`B`,source:a}),!0):s&&Pf(t,s,e,a)?(Z({view:`wysiwyg`,branch:`D`,source:a}),X(i,{op:`paste`,view:`wysiwyg`,branch:`D`,source:a,htmlBytes:s.length}),!0):o?hf(o)&&Nf(t,o,e,`E`,`markdown-text`)?(Z({view:`wysiwyg`,branch:`E`,source:`markdown-text`}),X(i,{op:`paste`,view:`wysiwyg`,branch:`E`,source:`markdown-text`}),!0):(Af(t,o),Z({view:`wysiwyg`,branch:`E`,source:`plaintext`}),X(i,{op:`paste`,view:`wysiwyg`,branch:`E`,source:`plaintext`}),!0):!1}}function kf(e){let{$from:t}=e.state.selection;for(let e=t.depth;e>=0;e--)if(t.node(e).type.name===`codeBlock`)return!0;return!1}function Af(e,t){let{schema:n,tr:r}=e.state;t&&e.dispatch(r.replaceSelectionWith(n.text(t)).scrollIntoView())}var jf=/^[A-Za-z0-9_+-]+$/;function Mf(e,t,n,r){try{let r=JSON.parse(t),i=typeof r.mode==`string`?r.mode:``,a=jf.test(i)?i:``,o=e.state.schema.nodes.codeBlock;if(!o)return!1;let s=o.create({language:a},n?e.state.schema.text(n):null);return e.dispatch(e.state.tr.replaceSelectionWith(s).scrollIntoView()),!0}catch(e){return Q({view:`wysiwyg`,stage:`branchA`,source:r,branch:`A`,reason:e?.message??`unknown`,errorClass:$(e)}),!1}}function Nf(e,t,n,r,i){let a;try{a=n.mdManager.parse(t)}catch(e){return Q({view:`wysiwyg`,stage:`mdManagerParse`,source:i,branch:r,reason:e?.message??`unknown`,errorClass:$(e)}),!1}return Ff(e,a,i,r)}function Pf(e,t,n,r){let i;try{i=de(t)}catch(e){return Q({view:`wysiwyg`,stage:`htmlToMdast`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),vf(`wysiwyg`),!1}let a;try{a=ce(i)}catch(e){return Q({view:`wysiwyg`,stage:`mdastToMarkdown`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),vf(`wysiwyg`),!1}let o;try{o=n.mdManager.parse(a)}catch(e){return Q({view:`wysiwyg`,stage:`mdManagerParse`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),vf(`wysiwyg`),!1}return Ff(e,o,r,`D`,t.length)}function Ff(e,t,n,r,i){try{let n=e.state.schema.nodeFromJSON(t);return e.dispatch(e.state.tr.replaceSelection(n.slice(0,n.content.size)).scrollIntoView()),!0}catch(e){return Q({view:`wysiwyg`,stage:`applyJsonSlice`,source:n,branch:r,reason:e?.message??`unknown`,errorClass:$(e),...i==null?{}:{htmlBytes:i}}),!1}}function If(e){return(t,n)=>{try{return zf(t,n.state.schema,e.mdManager)}catch(e){return console.warn(`[clipboard] text serialize fell through — PM default textBetween`,e),t.content.textBetween(0,t.content.size,`
|
|
31
31
|
|
|
32
|
-
`)}}}var Lf=class extends oe{mdManager;constructor(e){super({},{}),this.mdManager=e}serializeFragment(e,t,n){try{let t=e.firstChild?.type.schema;if(!t)return n??document.createDocumentFragment();let r=Hf(Bf(e,t,this.mdManager));if(n){for(let e of Array.from(r.childNodes))n.appendChild(e);return n}return r}catch(e){return console.warn(`[clipboard] HTML serialize fell through — PM default DOMSerializer`,e),n??document.createDocumentFragment()}}};function Rf(e){return new Lf(e.mdManager)}function zf(e,t,n){return n.serialize(Vf(e,t))}function Bf(e,t,n){return se(zf(new
|
|
32
|
+
`)}}}var Lf=class extends oe{mdManager;constructor(e){super({},{}),this.mdManager=e}serializeFragment(e,t,n){try{let t=e.firstChild?.type.schema;if(!t)return n??document.createDocumentFragment();let r=Hf(Bf(e,t,this.mdManager));if(n){for(let e of Array.from(r.childNodes))n.appendChild(e);return n}return r}catch(e){return console.warn(`[clipboard] HTML serialize fell through — PM default DOMSerializer`,e),n??document.createDocumentFragment()}}};function Rf(e){return new Lf(e.mdManager)}function zf(e,t,n){return n.serialize(Vf(e,t))}function Bf(e,t,n){return se(zf(new ie(e,0,0),t,n))}function Vf(e,t){let n=t.topNodeType.createAndFill(null,e.content);if(!n){let e=t.topNodeType.createAndFill();if(!e)throw Error(`[clipboard] schema cannot fill topNodeType`);return e.toJSON()}return n.toJSON()}function Hf(e){let t=new DOMParser().parseFromString(e,`text/html`),n=document.createDocumentFragment();for(let e of Array.from(t.body.childNodes))n.appendChild(e);return n}function Uf(e){return Tf(),k.domEventHandlers({copy:(e,t)=>Wf(e,t,`copy`),cut:(e,t)=>Wf(e,t,`cut`),paste:(t,n)=>Gf(t,n,e)})}function Wf(e,t,n){let{from:r,to:i}=t.state.selection.main;if(r===i)return e.preventDefault(),!0;let a=e.clipboardData;if(!a)return!1;let o=performance.now();try{let s=t.state.sliceDoc(r,i);a.setData(`text/plain`,s);try{a.setData(`text/html`,se(s))}catch(e){af({view:`source`,kind:`html`,reason:e?.message??`unknown`})}return e.preventDefault(),n===`cut`&&t.dispatch({changes:{from:r,to:i,insert:``}}),X(o,{op:n,view:`source`,branch:`serialize`,source:`local`}),!0}catch(e){return af({view:`source`,kind:`text`,reason:e?.message??`unknown`}),!1}}function Gf(e,t,n){let r=e.clipboardData;if(!r||r.types.length===0)return!1;let i=performance.now(),a=tf(r),o=r.getData(`text/plain`),s=r.getData(`text/html`);if(Df(e))return Z({view:`source`,branch:`shift`,source:a}),X(i,{op:`paste`,view:`source`,branch:`shift`,source:a}),!1;let c=r.getData(`vscode-editor-data`);return c&&o&&qf(t,c,o,a)?(e.preventDefault(),Z({view:`source`,branch:`A`,source:a}),X(i,{op:`paste`,view:`source`,branch:`A`,source:a}),!0):s&&/data-pm-slice/i.test(s)?(Z({view:`source`,branch:`C`,source:a}),X(i,{op:`paste`,view:`source`,branch:`C`,source:a}),!1):s&&Jf(t,s,n,a)?(e.preventDefault(),Z({view:`source`,branch:`D`,source:a}),X(i,{op:`paste`,view:`source`,branch:`D`,source:a,htmlBytes:s.length}),!0):(Z({view:`source`,branch:`E`,source:a}),X(i,{op:`paste`,view:`source`,branch:`E`,source:a}),!1)}var Kf=/^[A-Za-z0-9_+-]+$/;function qf(e,t,n,r){try{let r=JSON.parse(t),i=typeof r.mode==`string`?r.mode:``,a=`\`\`\`${Kf.test(i)?i:``}\n${n}\n\`\`\`\n`,{from:o,to:s}=e.state.selection.main;return e.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}}),!0}catch(e){return Q({view:`source`,stage:`branchA`,source:r,branch:`A`,reason:e?.message??`unknown`,errorClass:$(e)}),!1}}function Jf(e,t,n,r){let i;try{i=de(t)}catch(e){return Q({view:`source`,stage:`htmlToMdast`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),!1}let a;try{a=ce(i)}catch(e){return Q({view:`source`,stage:`mdastToMarkdown`,source:r,branch:`D`,reason:e?.message??`unknown`,errorClass:$(e),htmlBytes:t.length}),!1}let{from:o,to:s}=e.state.selection.main;if(!(a.length>500*1024))return e.dispatch({changes:{from:o,to:s,insert:a},selection:{anchor:o+a.length}}),!0;let c=o===s?``:e.state.sliceDoc(o,s);o!==s&&e.dispatch({changes:{from:o,to:s,insert:``}});let l=o,u=m(n.ytext,l);return ae(n.ydoc,n.ytext,l,a,{resolveOffset:e=>{let t=ee(u,n.ydoc);return t==null?e:t.index+(e-l)}}).catch(i=>{Yf({view:e,source:r,html:t,restoreText:c,anchorIndex:l,anchorRelPos:u,ydoc:n.ydoc,err:i})}),!0}function Yf(e){let{view:t,source:n,html:r,restoreText:i,anchorIndex:a,anchorRelPos:o,ydoc:s,err:c}=e;if(c instanceof h&&c.bytesWritten>0){let e=o&&s?ee(o,s)?.index??a:a,n=Math.min(e+c.bytesWritten,t.state.doc.length);try{t.dispatch({changes:{from:e,to:n,insert:i}})}catch(e){console.warn(`[clipboard] partial-chunk rollback dispatch failed`,e)}}else if(i.length>0)try{t.dispatch({changes:{from:a,to:a,insert:i}})}catch(e){console.warn(`[clipboard] selection-restore dispatch failed`,e)}if(c instanceof h){of({view:`source`,chunksCompleted:c.chunksCompleted,totalChunks:c.totalChunks,bytesWritten:c.bytesWritten,bytesRemaining:c.bytesRemaining,reason:c.message}),re.error(`Paste was incomplete — ${c.chunksCompleted} of ${c.totalChunks} chunks landed. Your selection has been restored.`);return}Q({view:`source`,stage:`chunkedYTextInsert`,source:n,branch:`D`,reason:c?.message??`unknown`,errorClass:$(c),htmlBytes:r.length}),re.error(`Paste failed. Your selection has been restored.`)}export{Lt as _,Xd as a,ru as c,ws as d,us as f,cr as g,ya as h,Of as i,Ls as l,xo as m,Rf as n,Zd as o,Qo as p,If as r,Bd as s,Uf as t,Ps as u,It as v,Ft as y};
|