@agimon-ai/doompi-web 0.0.1-alpha.5 → 0.0.1-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/web/assets/{CodeEditorView-LG_3Cg99.js → CodeEditorView-CJoceEgU.js} +3 -3
  2. package/dist/web/assets/{CodeEditorView-LG_3Cg99.js.map → CodeEditorView-CJoceEgU.js.map} +1 -1
  3. package/dist/web/assets/{dist-QnaykjN5.js → dist--0dFFjHK.js} +2 -2
  4. package/dist/web/assets/{dist-QnaykjN5.js.map → dist--0dFFjHK.js.map} +1 -1
  5. package/dist/web/assets/{dist-D1W3-wtH.js → dist-BEjTM7TM.js} +2 -2
  6. package/dist/web/assets/{dist-D1W3-wtH.js.map → dist-BEjTM7TM.js.map} +1 -1
  7. package/dist/web/assets/{dist-DTXlEibW.js → dist-Cc1jhITG.js} +2 -2
  8. package/dist/web/assets/{dist-DTXlEibW.js.map → dist-Cc1jhITG.js.map} +1 -1
  9. package/dist/web/assets/{dist-CxM2xdE9.js → dist-Cr0kQueR.js} +2 -2
  10. package/dist/web/assets/{dist-CxM2xdE9.js.map → dist-Cr0kQueR.js.map} +1 -1
  11. package/dist/web/assets/{dist-DI-m0tCl.js → dist-Dh1ufhC2.js} +2 -2
  12. package/dist/web/assets/{dist-DI-m0tCl.js.map → dist-Dh1ufhC2.js.map} +1 -1
  13. package/dist/web/assets/{dist-Bietfciw.js → dist-Dnjnn2hl.js} +1 -1
  14. package/dist/web/assets/{dist-DOR6BHb3.js → dist-DsQNQF8G.js} +2 -2
  15. package/dist/web/assets/{dist-DOR6BHb3.js.map → dist-DsQNQF8G.js.map} +1 -1
  16. package/dist/web/assets/{dist-cVWn89LE.js → dist-KD1Mlgxp.js} +2 -2
  17. package/dist/web/assets/{dist-cVWn89LE.js.map → dist-KD1Mlgxp.js.map} +1 -1
  18. package/dist/web/assets/{dist-E_ycctz6.js → dist-a_TARmvK.js} +2 -2
  19. package/dist/web/assets/{dist-E_ycctz6.js.map → dist-a_TARmvK.js.map} +1 -1
  20. package/dist/web/assets/{dist-Dl2n08ak.js → dist-h0LM1rYV.js} +2 -2
  21. package/dist/web/assets/{dist-Dl2n08ak.js.map → dist-h0LM1rYV.js.map} +1 -1
  22. package/dist/web/assets/index-Dur2Nvah.js +101 -0
  23. package/dist/web/assets/index-Dur2Nvah.js.map +1 -0
  24. package/dist/web/index.html +1 -1
  25. package/package.json +4 -4
  26. package/src/web/features/session/Composer.tsx +13 -2
  27. package/src/web/features/session/QueueSheet.tsx +17 -0
  28. package/src/web/features/session/Timeline.tsx +24 -10
  29. package/src/web/lib/protocolTimeline.ts +2 -2
  30. package/src/web/lib/sessionModel.ts +28 -4
  31. package/src/web/stores/sessionStore.ts +29 -0
  32. package/dist/web/assets/index-DoAxBglp.js +0 -101
  33. package/dist/web/assets/index-DoAxBglp.js.map +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-DTXlEibW.js","assets/rolldown-runtime-hePW80VL.js","assets/dist-D1W3-wtH.js","assets/dist-E_ycctz6.js","assets/dist-DI-m0tCl.js","assets/dist-cVWn89LE.js","assets/dist-CxM2xdE9.js","assets/dist-Dl2n08ak.js","assets/dist-QnaykjN5.js","assets/dist-DOR6BHb3.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from"./index-DoAxBglp.js";var a={cjs:`javascript`,js:`javascript`,mjs:`javascript`,jsx:`jsx`,cts:`typescript`,mts:`typescript`,ts:`typescript`,tsx:`tsx`,json:`json`,jsonc:`json`,markdown:`markdown`,md:`markdown`,htm:`html`,html:`html`,xhtml:`html`,css:`css`,py:`python`,pyi:`python`,yaml:`yaml`,yml:`yaml`,bash:`shell`,sh:`shell`,zsh:`shell`,toml:`toml`},o={".bashrc":`shell`,".zshrc":`shell`,containerfile:`dockerfile`,dockerfile:`dockerfile`};function s(e){return(e.split(`/`).at(-1)??``).toLowerCase()}function c(e){let t=s(e),n=o[t];if(n!==void 0)return n;let r=t.lastIndexOf(`.`);if(!(r<1))return a[t.slice(r+1)]}async function l(e){let[{StreamLanguage:t},n]=await Promise.all([i(()=>import(`./dist-Bietfciw.js`),[]),e()]);return t.define(n)}async function u(e){switch(e){case`javascript`:return(await i(async()=>{let{javascript:e}=await import(`./dist-DTXlEibW.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]))).javascript();case`jsx`:return(await i(async()=>{let{javascript:e}=await import(`./dist-DTXlEibW.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]))).javascript({jsx:!0});case`typescript`:return(await i(async()=>{let{javascript:e}=await import(`./dist-DTXlEibW.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]))).javascript({typescript:!0});case`tsx`:return(await i(async()=>{let{javascript:e}=await import(`./dist-DTXlEibW.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]))).javascript({jsx:!0,typescript:!0});case`json`:return(await i(async()=>{let{json:e}=await import(`./dist-DI-m0tCl.js`);return{json:e}},__vite__mapDeps([4,2]))).json();case`markdown`:return(await i(async()=>{let{markdown:e}=await import(`./dist-cVWn89LE.js`);return{markdown:e}},__vite__mapDeps([5,3,6,2,7,1,0]))).markdown();case`html`:return(await i(async()=>{let{html:e}=await import(`./dist-CxM2xdE9.js`);return{html:e}},__vite__mapDeps([6,2,7,1,0,3]))).html();case`css`:return(await i(async()=>{let{css:e}=await import(`./dist-Dl2n08ak.js`).then(e=>e.r);return{css:e}},__vite__mapDeps([7,1,2]))).css();case`python`:return(await i(async()=>{let{python:e}=await import(`./dist-QnaykjN5.js`);return{python:e}},__vite__mapDeps([8,2,3]))).python();case`yaml`:return(await i(async()=>{let{yaml:e}=await import(`./dist-DOR6BHb3.js`);return{yaml:e}},__vite__mapDeps([9,2]))).yaml();case`shell`:return l(async()=>(await i(async()=>{let{shell:e}=await import(`./shell-DwuoZtxw.js`);return{shell:e}},[])).shell);case`toml`:return l(async()=>(await i(async()=>{let{toml:e}=await import(`./toml-BPTmHmyx.js`);return{toml:e}},[])).toml);case`dockerfile`:return l(async()=>(await i(async()=>{let{dockerFile:e}=await import(`./dockerfile-BDePf5PZ.js`);return{dockerFile:e}},[])).dockerFile)}}var d=e(t(),1),f=n(),p=1024,m=0,h=class{constructor(e,t){this.from=e,this.to=t}},g=class{constructor(e={}){this.id=m++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=v.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};g.closedBy=new g({deserialize:e=>e.split(` `)}),g.openedBy=new g({deserialize:e=>e.split(` `)}),g.group=new g({deserialize:e=>e.split(` `)}),g.isolate=new g({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),g.contextHash=new g({perNode:!0}),g.lookAhead=new g({perNode:!0}),g.mounted=new g({perNode:!0});var _=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[g.mounted.id]}},ee=Object.create(null),v=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):ee,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(g.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(g.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};v.none=new v(``,Object.create(null),0,8);var te=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new v(e.name,r,e.id,e.flags):e)}return new e(n)}},ne=new WeakMap,y=new WeakMap,b;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(b||={});var x=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=_.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new he(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new he(ne.get(this)||this.topNode);return r.moveTo(e,t),ne.set(this,r._tree),r}get topNode(){return new S(this,0,0,null)}resolve(e,t=0){let n=oe(ne.get(this)||this.topNode,e,t,!1);return ne.set(this,n),n}resolveInner(e,t=0){let n=oe(y.get(this)||this.topNode,e,t,!0);return y.set(this,n),n}resolveStack(e,t=0){return me(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&b.IncludeAnonymous)>0;for(let e=this.cursor(a|b.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:be(v.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(v.none,t,n,r)))}static build(e){return _e(e)}};x.empty=new x(v.none,[],[],0);var re=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},ie=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return v.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(ae(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function ae(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function oe(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof S&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:b.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof S&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var se=class{cursor(e=0){return new he(this,e)}getChild(e,t=null,n=null){let r=ce(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return ce(this,e,t,n)}resolve(e,t=0){return oe(this,e,t,!1)}resolveInner(e,t=0){return oe(this,e,t,!0)}matchContext(e){return le(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},S=class e extends se{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&b.EnterBracketed&&l instanceof x&&(d=_.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!ae(i,r,u,u+l.length))){if(l instanceof ie){if(a&b.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new de(new ue(o,l,t,u),null,e)}else if(a&b.IncludeAnonymous||!l.type.isAnonymous||ge(l)){let s;if(!(a&b.IgnoreMounts)&&(s=_.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&b.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&b.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&b.IgnoreOverlays)&&(i=_.get(this._tree))&&i.overlay){let a=t-this.from,o=r&b.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function ce(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function le(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var ue=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},de=class e extends se{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&b.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new x(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function fe(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof S&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new pe(i,n)}var pe=class{constructor(e,t){this.heads=e,this.node=t}get next(){return fe(this.heads)}};function me(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof S?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=_.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new S(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(oe(o,t,n,!1))}}return i?fe(i):r}var he=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~b.EnterBracketed,e instanceof S)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof S?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&b.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&b.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&b.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&b.IncludeAnonymous||e instanceof ie||!e.type.isAnonymous||ge(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new de(this.buffer,t,this.stack[e]);return this.bufferNode=new de(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return le(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return le(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function ge(e){return e.children.some(e=>e instanceof ie||!e.type.isAnonymous||ge(e))}function _e(e){let{buffer:t,nodeSet:n,maxBufferLength:r=p,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new re(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,p,g,v,te){let{id:ne,start:y,end:b,size:x}=o,re=l,ae=c;if(x<0){if(o.next(),x==-1){let t=i[ne];p.push(t),g.push(y-e);return}if(x==-3){c=ne;return}if(x==-4){l=ne;return}throw RangeError(`Unrecognized record size: ${x}`)}let oe=s[ne],se,S,ce=y-e;if(b-y<=r&&(S=_(o.pos-t,v))){let t=new Uint16Array(S.size-S.skip),r=o.pos-S.size,i=t.length;for(;o.pos>r;)i=ee(S.start,t,i);se=new ie(t,b-S.start,n),ce=S.start-e}else{let e=o.pos-x;o.next();let t=[],n=[],i=ne>=a?ne:-1,s=0,c=b;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(m(t,n,y,s,o.end,c,i,re,ae),s=t.length,c=o.end),o.next()):te>2500?d(y,e,t,n):u(y,e,t,n,i,te+1);if(i>=0&&s>0&&s<t.length&&m(t,n,y,s,y,c,i,re,ae),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(oe,ae);se=be(oe,t,n,0,t.length,0,b-y,e,e)}else se=h(oe,t,n,b-y,re-b,ae)}p.push(se),g.push(ce)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new ie(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof x){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(g.lookAhead))&&(a=r[o]+s.length+c)}return h(e,n,r,i,a,t)}}function m(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(h(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function h(e,t,n,r,i,a,o){if(a){let e=[g.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[g.lookAhead,i];o=o?[e].concat(o):[e]}return new x(e,t,n,r,o)}function _(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function ee(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=ee(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let v=[],te=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,v,te,-1,0);let ne=e.length??(v.length?te[0]+v[0].length:0);return new x(s[e.topID],v.reverse(),te.reverse(),ne)}var ve=new WeakMap;function ye(e,t){if(!e.isAnonymous||t instanceof ie||t.type!=e)return 1;let n=ve.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof x)){n=1;break}n+=ye(e,r)}ve.set(t,n)}return n}function be(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=ye(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=ye(e,t[s]);for(s++;s<i;s++){let n=ye(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(be(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var xe=class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof de?this.setBuffer(e.context.buffer,e.index,t):e instanceof S&&this.map.set(e.tree,t)}get(e){return e instanceof de?this.getBuffer(e.context.buffer,e.index):e instanceof S?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},Se=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},Ce=class{startParse(e,t,n){return typeof e==`string`&&(e=new we(e)),n=n?n.length?n.map(e=>new h(e.from,e.to)):[new h(0,0)]:[new h(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},we=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function Te(e){return(t,n,r,i)=>new Ae(t,e,n,r,i)}var Ee=class{constructor(e,t,n,r,i,a){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=i,this.from=a}};function De(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var Oe=class{constructor(e,t,n,r,i,a,o,s){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=i,this.bracketed=a,this.target=o,this.prev=s,this.depth=0,this.ranges=[]}},ke=new g({perNode:!0}),Ae=class{constructor(e,t,n,r,i){this.nest=t,this.input=n,this.fragments=r,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return this.stoppedAt!=null&&(e=new x(e.type,e.children,e.positions,e.length,e.propValues.concat([[ke,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[g.mounted.id]=new _(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new Fe(this.fragments),t=null,n=null,r=new he(new S(this.baseTree,this.ranges[0].from,0,null),b.IncludeAnonymous|b.IgnoreMounts);scan:for(let i,a;;){let o=!0,s;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)o=!1;else if(e.hasNode(r)){if(t){let e=t.mounts.find(e=>e.frag.from<=r.from&&e.frag.to>=r.to&&e.mount.overlay);if(e)for(let n of e.mount.overlay){let i=n.from+e.pos,a=n.to+e.pos;i>=r.from&&a<=r.to&&!t.ranges.some(e=>e.from<a&&e.to>i)&&t.ranges.push({from:i,to:a})}}o=!1}else if(n&&(a=je(n.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(i=this.nest(r,this.input))&&(r.from<r.to||!i.overlay)){r.tree||(Ne(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new Oe(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=Ie(this.ranges,i.overlay||(r.from<r.to?[new h(r.from,r.to)]:[]));e.length&&De(e),(e.length||!i.overlay)&&this.inner.push(new Ee(i.parser,e.length?i.parser.startParse(this.input,Re(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new h(e.from-r.from,e.to-r.from)):null,!!i.bracketed,r.tree,e.length?e[0].from:r.from)),i.overlay?e.length&&(n={ranges:e,depth:0,prev:n}):o=!1}}else if(t&&(s=t.predicate(r))&&(s===!0&&(s=new h(r.from,r.to)),s.from<s.to)){let e=t.ranges.length-1;e>=0&&t.ranges[e].to==s.from?t.ranges[e]={from:t.ranges[e].from,to:s.to}:t.ranges.push(s)}if(o&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break scan;if(t&&!--t.depth){let e=Ie(this.ranges,t.ranges);e.length&&(De(e),this.inner.splice(t.index,0,new Ee(t.parser,t.parser.startParse(this.input,Re(t.mounts,e),e),t.ranges.map(e=>new h(e.from-t.start,e.to-t.start)),t.bracketed,t.target,e[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}};function je(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function Me(e,t,n,r,i,a){if(t<n){let o=e.buffer[t+1];r.push(e.slice(t,n,o)),i.push(o-a)}}function Ne(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,a=i.children.indexOf(r),o=i.children[a],s=o.buffer,c=[a];function l(e,r,i,a,u,d){let f=n[d],p=[],m=[];Me(o,e,f,p,m,a);let h=s[f+1],g=s[f+2];c.push(p.length);let _=d?l(f+4,s[f+3],o.set.types[s[f]],h,g-h,d-1):t.toTree();return p.push(_),m.push(h-a),Me(o,s[f+3],r,p,m,a),new x(i,p,m,u)}i.children[a]=l(0,s.length,v.none,0,o.length,n.length-1);for(let t of c){let n=e.tree.children[t],r=e.tree.positions[t];e.yield(new S(n,r+e.from,t,e._tree))}}var Pe=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(b.IncludeAnonymous|b.IgnoreMounts)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)if(!(t.to>=e&&t.enter(n,1,b.IgnoreOverlays|b.ExcludeBuffers))){if(t.to<=e)t.next(!1)||(this.done=!0);else break}}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof x)t=t.children[0];else break}return!1}},Fe=class{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=t.tree.prop(ke)??t.to,this.inner=new Pe(t.tree,-t.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=e.tree.prop(ke)??e.to,this.inner=new Pe(e.tree,-e.offset)}}findMounts(e,t){let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=e.tree?.prop(g.mounted);if(r&&r.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let i=this.fragments[t];if(i.from>=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}};function Ie(e,t){let n=null,r=t;for(let i=1,a=0;i<e.length;i++){let o=e[i-1].to,s=e[i].from;for(;a<r.length;a++){let e=r[a];if(e.from>=s)break;e.to<=o||(n||(r=n=t.slice()),e.from<o?(n[a]=new h(e.from,o),e.to>s&&n.splice(a+1,0,new h(s,e.to))):e.to>s?n[a--]=new h(s,e.to):n.splice(a--,1))}}return r}function Le(e,t,n,r){let i=0,a=0,o=!1,s=!1,c=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,d=a==t.length?1e9:s?t[a].to:t[a].from;if(o!=s){let e=Math.max(c,n),t=Math.min(u,d,r);e<t&&l.push(new h(e,t))}if(c=Math.min(u,d),c==1e9)break;u==c&&(o?(o=!1,i++):o=!0),d==c&&(s?(s=!1,a++):s=!0)}return l}function Re(e,t){let n=[];for(let{pos:r,mount:i,frag:a}of e){let e=r+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length,s=Math.max(a.from,e),c=Math.min(a.to,o);if(i.overlay){let o=Le(t,i.overlay.map(e=>new h(e.from+r,e.to+r)),s,c);for(let t=0,r=s;;t++){let s=t==o.length,l=s?c:o[t].from;if(l>r&&n.push(new Se(r,l,i.tree,-e,a.from>=r||a.openStart,a.to<=l||a.openEnd)),s)break;r=o[t].to}}else n.push(new Se(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var ze=0,Be=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=ze++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new He(e);return e=>e.modified.indexOf(t)>-1?e:He.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},Ve=0,He=class e{constructor(e){this.name=e,this.instances=[],this.id=Ve++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&Ue(n,e.modified));if(r)return r;let i=[],a=new Be(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=We(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function Ue(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function We(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function Ge(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new qe(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Ke.add(t)}var Ke=new g({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new qe(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),qe=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};qe.empty=new qe([],2,null);function Je(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function Ye(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function Xe(e,t,n,r=0,i=e.length){let a=new Ze(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Ze=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=Qe(e)||qe.empty,u=Ye(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(g.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function Qe(e){let t=e.type.prop(Ke);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var C=Be.define,$e=C(),et=C(),tt=C(et),nt=C(et),rt=C(),it=C(rt),at=C(rt),ot=C(),st=C(ot),ct=C(),lt=C(),ut=C(),dt=C(ut),ft=C(),w={comment:$e,lineComment:C($e),blockComment:C($e),docComment:C($e),name:et,variableName:C(et),typeName:tt,tagName:C(tt),propertyName:nt,attributeName:C(nt),className:C(et),labelName:C(et),namespace:C(et),macroName:C(et),literal:rt,string:it,docString:C(it),character:C(it),attributeValue:C(it),number:at,integer:C(at),float:C(at),bool:C(rt),regexp:C(rt),escape:C(rt),color:C(rt),url:C(rt),keyword:ct,self:C(ct),null:C(ct),atom:C(ct),unit:C(ct),modifier:C(ct),operatorKeyword:C(ct),controlKeyword:C(ct),definitionKeyword:C(ct),moduleKeyword:C(ct),operator:lt,derefOperator:C(lt),arithmeticOperator:C(lt),logicOperator:C(lt),bitwiseOperator:C(lt),compareOperator:C(lt),updateOperator:C(lt),definitionOperator:C(lt),typeOperator:C(lt),controlOperator:C(lt),punctuation:ut,separator:C(ut),bracket:dt,angleBracket:C(dt),squareBracket:C(dt),paren:C(dt),brace:C(dt),content:ot,heading:st,heading1:C(st),heading2:C(st),heading3:C(st),heading4:C(st),heading5:C(st),heading6:C(st),contentSeparator:C(ot),list:C(ot),quote:C(ot),emphasis:C(ot),strong:C(ot),link:C(ot),monospace:C(ot),strikethrough:C(ot),inserted:C(),deleted:C(),changed:C(),invalid:C(),meta:ft,documentMeta:C(ft),annotation:C(ft),processingInstruction:C(ft),definition:Be.defineModifier(`definition`),constant:Be.defineModifier(`constant`),function:Be.defineModifier(`function`),standard:Be.defineModifier(`standard`),local:Be.defineModifier(`local`),special:Be.defineModifier(`special`)};for(let e in w){let t=w[e];t instanceof Be&&(t.name=e)}Je([{tag:w.link,class:`tok-link`},{tag:w.heading,class:`tok-heading`},{tag:w.emphasis,class:`tok-emphasis`},{tag:w.strong,class:`tok-strong`},{tag:w.keyword,class:`tok-keyword`},{tag:w.atom,class:`tok-atom`},{tag:w.bool,class:`tok-bool`},{tag:w.url,class:`tok-url`},{tag:w.labelName,class:`tok-labelName`},{tag:w.inserted,class:`tok-inserted`},{tag:w.deleted,class:`tok-deleted`},{tag:w.literal,class:`tok-literal`},{tag:w.string,class:`tok-string`},{tag:w.number,class:`tok-number`},{tag:[w.regexp,w.escape,w.special(w.string)],class:`tok-string2`},{tag:w.variableName,class:`tok-variableName`},{tag:w.local(w.variableName),class:`tok-variableName tok-local`},{tag:w.definition(w.variableName),class:`tok-variableName tok-definition`},{tag:w.special(w.variableName),class:`tok-variableName2`},{tag:w.definition(w.propertyName),class:`tok-propertyName tok-definition`},{tag:w.typeName,class:`tok-typeName`},{tag:w.namespace,class:`tok-namespace`},{tag:w.className,class:`tok-className`},{tag:w.macroName,class:`tok-macroName`},{tag:w.propertyName,class:`tok-propertyName`},{tag:w.operator,class:`tok-operator`},{tag:w.comment,class:`tok-comment`},{tag:w.meta,class:`tok-meta`},{tag:w.invalid,class:`tok-invalid`},{tag:w.punctuation,class:`tok-punctuation`}]);var pt=[],mt=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?mt:pt).push(n+=e[t])})();function ht(e){if(e<768)return!1;for(let t=0,n=pt.length;;){let r=t+n>>1;if(e<pt[r])n=r;else if(e>=mt[r])t=r+1;else return!0;if(t==n)return!1}}function gt(e){return e>=127462&&e<=127487}var _t=8205;function vt(e,t,n=!0,r=!0){return(n?yt:bt)(e,t,r)}function yt(e,t,n){if(t==e.length)return t;t&&St(e.charCodeAt(t))&&Ct(e.charCodeAt(t-1))&&t--;let r=xt(e,t);for(t+=wt(r);t<e.length;){let i=xt(e,t);if(r==_t||i==_t||n&&ht(i))t+=wt(i),r=i;else if(gt(i)){let n=0,r=t-2;for(;r>=0&&gt(xt(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function bt(e,t,n){for(;t>1;){let r=yt(e,t-2,n);if(r<t)return r;t--}return 0}function xt(e,t){let n=e.charCodeAt(t);if(!Ct(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return St(r)?(n-55296<<10)+(r-56320)+65536:n}function St(e){return e>=56320&&e<57344}function Ct(e){return e>=55296&&e<56320}function wt(e){return e<65536?1:2}var T=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Pt(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Et.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Pt(this,e,t);let n=[];return this.decompose(e,t,n,0),Et.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new At(this),i=new At(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new At(this,e)}iterRange(e,t=this.length){return new jt(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Mt(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new Tt(t):Et.from(Tt.split(t,[]))}},Tt=class e extends T{constructor(e,t=Dt(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new Nt(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(kt(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=Ot(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=Pt(this,t,n);let i=Ot(this.text,Ot(r.text,kt(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):Et.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-Cc1jhITG.js","assets/rolldown-runtime-hePW80VL.js","assets/dist-BEjTM7TM.js","assets/dist-a_TARmvK.js","assets/dist-Dh1ufhC2.js","assets/dist-KD1Mlgxp.js","assets/dist-Cr0kQueR.js","assets/dist-h0LM1rYV.js","assets/dist--0dFFjHK.js","assets/dist-DsQNQF8G.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from"./index-Dur2Nvah.js";var a={cjs:`javascript`,js:`javascript`,mjs:`javascript`,jsx:`jsx`,cts:`typescript`,mts:`typescript`,ts:`typescript`,tsx:`tsx`,json:`json`,jsonc:`json`,markdown:`markdown`,md:`markdown`,htm:`html`,html:`html`,xhtml:`html`,css:`css`,py:`python`,pyi:`python`,yaml:`yaml`,yml:`yaml`,bash:`shell`,sh:`shell`,zsh:`shell`,toml:`toml`},o={".bashrc":`shell`,".zshrc":`shell`,containerfile:`dockerfile`,dockerfile:`dockerfile`};function s(e){return(e.split(`/`).at(-1)??``).toLowerCase()}function c(e){let t=s(e),n=o[t];if(n!==void 0)return n;let r=t.lastIndexOf(`.`);if(!(r<1))return a[t.slice(r+1)]}async function l(e){let[{StreamLanguage:t},n]=await Promise.all([i(()=>import(`./dist-Dnjnn2hl.js`),[]),e()]);return t.define(n)}async function u(e){switch(e){case`javascript`:return(await i(async()=>{let{javascript:e}=await import(`./dist-Cc1jhITG.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]))).javascript();case`jsx`:return(await i(async()=>{let{javascript:e}=await import(`./dist-Cc1jhITG.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]))).javascript({jsx:!0});case`typescript`:return(await i(async()=>{let{javascript:e}=await import(`./dist-Cc1jhITG.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]))).javascript({typescript:!0});case`tsx`:return(await i(async()=>{let{javascript:e}=await import(`./dist-Cc1jhITG.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]))).javascript({jsx:!0,typescript:!0});case`json`:return(await i(async()=>{let{json:e}=await import(`./dist-Dh1ufhC2.js`);return{json:e}},__vite__mapDeps([4,2]))).json();case`markdown`:return(await i(async()=>{let{markdown:e}=await import(`./dist-KD1Mlgxp.js`);return{markdown:e}},__vite__mapDeps([5,3,6,2,7,1,0]))).markdown();case`html`:return(await i(async()=>{let{html:e}=await import(`./dist-Cr0kQueR.js`);return{html:e}},__vite__mapDeps([6,2,7,1,0,3]))).html();case`css`:return(await i(async()=>{let{css:e}=await import(`./dist-h0LM1rYV.js`).then(e=>e.r);return{css:e}},__vite__mapDeps([7,1,2]))).css();case`python`:return(await i(async()=>{let{python:e}=await import(`./dist--0dFFjHK.js`);return{python:e}},__vite__mapDeps([8,2,3]))).python();case`yaml`:return(await i(async()=>{let{yaml:e}=await import(`./dist-DsQNQF8G.js`);return{yaml:e}},__vite__mapDeps([9,2]))).yaml();case`shell`:return l(async()=>(await i(async()=>{let{shell:e}=await import(`./shell-DwuoZtxw.js`);return{shell:e}},[])).shell);case`toml`:return l(async()=>(await i(async()=>{let{toml:e}=await import(`./toml-BPTmHmyx.js`);return{toml:e}},[])).toml);case`dockerfile`:return l(async()=>(await i(async()=>{let{dockerFile:e}=await import(`./dockerfile-BDePf5PZ.js`);return{dockerFile:e}},[])).dockerFile)}}var d=e(t(),1),f=n(),p=1024,m=0,h=class{constructor(e,t){this.from=e,this.to=t}},g=class{constructor(e={}){this.id=m++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=v.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};g.closedBy=new g({deserialize:e=>e.split(` `)}),g.openedBy=new g({deserialize:e=>e.split(` `)}),g.group=new g({deserialize:e=>e.split(` `)}),g.isolate=new g({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),g.contextHash=new g({perNode:!0}),g.lookAhead=new g({perNode:!0}),g.mounted=new g({perNode:!0});var _=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[g.mounted.id]}},ee=Object.create(null),v=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):ee,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(g.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(g.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};v.none=new v(``,Object.create(null),0,8);var te=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new v(e.name,r,e.id,e.flags):e)}return new e(n)}},ne=new WeakMap,y=new WeakMap,b;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(b||={});var x=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=_.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new he(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new he(ne.get(this)||this.topNode);return r.moveTo(e,t),ne.set(this,r._tree),r}get topNode(){return new S(this,0,0,null)}resolve(e,t=0){let n=oe(ne.get(this)||this.topNode,e,t,!1);return ne.set(this,n),n}resolveInner(e,t=0){let n=oe(y.get(this)||this.topNode,e,t,!0);return y.set(this,n),n}resolveStack(e,t=0){return me(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&b.IncludeAnonymous)>0;for(let e=this.cursor(a|b.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:be(v.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(v.none,t,n,r)))}static build(e){return _e(e)}};x.empty=new x(v.none,[],[],0);var re=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},ie=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return v.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(ae(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function ae(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function oe(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof S&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:b.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof S&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var se=class{cursor(e=0){return new he(this,e)}getChild(e,t=null,n=null){let r=ce(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return ce(this,e,t,n)}resolve(e,t=0){return oe(this,e,t,!1)}resolveInner(e,t=0){return oe(this,e,t,!0)}matchContext(e){return le(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},S=class e extends se{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&b.EnterBracketed&&l instanceof x&&(d=_.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!ae(i,r,u,u+l.length))){if(l instanceof ie){if(a&b.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new de(new ue(o,l,t,u),null,e)}else if(a&b.IncludeAnonymous||!l.type.isAnonymous||ge(l)){let s;if(!(a&b.IgnoreMounts)&&(s=_.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&b.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&b.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&b.IgnoreOverlays)&&(i=_.get(this._tree))&&i.overlay){let a=t-this.from,o=r&b.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function ce(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function le(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var ue=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},de=class e extends se{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&b.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new x(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function fe(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof S&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new pe(i,n)}var pe=class{constructor(e,t){this.heads=e,this.node=t}get next(){return fe(this.heads)}};function me(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof S?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=_.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new S(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(oe(o,t,n,!1))}}return i?fe(i):r}var he=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~b.EnterBracketed,e instanceof S)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof S?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&b.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&b.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&b.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&b.IncludeAnonymous||e instanceof ie||!e.type.isAnonymous||ge(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new de(this.buffer,t,this.stack[e]);return this.bufferNode=new de(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return le(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return le(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function ge(e){return e.children.some(e=>e instanceof ie||!e.type.isAnonymous||ge(e))}function _e(e){let{buffer:t,nodeSet:n,maxBufferLength:r=p,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new re(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,p,g,v,te){let{id:ne,start:y,end:b,size:x}=o,re=l,ae=c;if(x<0){if(o.next(),x==-1){let t=i[ne];p.push(t),g.push(y-e);return}if(x==-3){c=ne;return}if(x==-4){l=ne;return}throw RangeError(`Unrecognized record size: ${x}`)}let oe=s[ne],se,S,ce=y-e;if(b-y<=r&&(S=_(o.pos-t,v))){let t=new Uint16Array(S.size-S.skip),r=o.pos-S.size,i=t.length;for(;o.pos>r;)i=ee(S.start,t,i);se=new ie(t,b-S.start,n),ce=S.start-e}else{let e=o.pos-x;o.next();let t=[],n=[],i=ne>=a?ne:-1,s=0,c=b;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(m(t,n,y,s,o.end,c,i,re,ae),s=t.length,c=o.end),o.next()):te>2500?d(y,e,t,n):u(y,e,t,n,i,te+1);if(i>=0&&s>0&&s<t.length&&m(t,n,y,s,y,c,i,re,ae),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(oe,ae);se=be(oe,t,n,0,t.length,0,b-y,e,e)}else se=h(oe,t,n,b-y,re-b,ae)}p.push(se),g.push(ce)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new ie(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof x){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(g.lookAhead))&&(a=r[o]+s.length+c)}return h(e,n,r,i,a,t)}}function m(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(h(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function h(e,t,n,r,i,a,o){if(a){let e=[g.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[g.lookAhead,i];o=o?[e].concat(o):[e]}return new x(e,t,n,r,o)}function _(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function ee(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=ee(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let v=[],te=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,v,te,-1,0);let ne=e.length??(v.length?te[0]+v[0].length:0);return new x(s[e.topID],v.reverse(),te.reverse(),ne)}var ve=new WeakMap;function ye(e,t){if(!e.isAnonymous||t instanceof ie||t.type!=e)return 1;let n=ve.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof x)){n=1;break}n+=ye(e,r)}ve.set(t,n)}return n}function be(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=ye(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=ye(e,t[s]);for(s++;s<i;s++){let n=ye(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(be(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var xe=class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof de?this.setBuffer(e.context.buffer,e.index,t):e instanceof S&&this.map.set(e.tree,t)}get(e){return e instanceof de?this.getBuffer(e.context.buffer,e.index):e instanceof S?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},Se=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},Ce=class{startParse(e,t,n){return typeof e==`string`&&(e=new we(e)),n=n?n.length?n.map(e=>new h(e.from,e.to)):[new h(0,0)]:[new h(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},we=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function Te(e){return(t,n,r,i)=>new Ae(t,e,n,r,i)}var Ee=class{constructor(e,t,n,r,i,a){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=i,this.from=a}};function De(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var Oe=class{constructor(e,t,n,r,i,a,o,s){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=i,this.bracketed=a,this.target=o,this.prev=s,this.depth=0,this.ranges=[]}},ke=new g({perNode:!0}),Ae=class{constructor(e,t,n,r,i){this.nest=t,this.input=n,this.fragments=r,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return this.stoppedAt!=null&&(e=new x(e.type,e.children,e.positions,e.length,e.propValues.concat([[ke,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[g.mounted.id]=new _(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new Fe(this.fragments),t=null,n=null,r=new he(new S(this.baseTree,this.ranges[0].from,0,null),b.IncludeAnonymous|b.IgnoreMounts);scan:for(let i,a;;){let o=!0,s;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)o=!1;else if(e.hasNode(r)){if(t){let e=t.mounts.find(e=>e.frag.from<=r.from&&e.frag.to>=r.to&&e.mount.overlay);if(e)for(let n of e.mount.overlay){let i=n.from+e.pos,a=n.to+e.pos;i>=r.from&&a<=r.to&&!t.ranges.some(e=>e.from<a&&e.to>i)&&t.ranges.push({from:i,to:a})}}o=!1}else if(n&&(a=je(n.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(i=this.nest(r,this.input))&&(r.from<r.to||!i.overlay)){r.tree||(Ne(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new Oe(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=Ie(this.ranges,i.overlay||(r.from<r.to?[new h(r.from,r.to)]:[]));e.length&&De(e),(e.length||!i.overlay)&&this.inner.push(new Ee(i.parser,e.length?i.parser.startParse(this.input,Re(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new h(e.from-r.from,e.to-r.from)):null,!!i.bracketed,r.tree,e.length?e[0].from:r.from)),i.overlay?e.length&&(n={ranges:e,depth:0,prev:n}):o=!1}}else if(t&&(s=t.predicate(r))&&(s===!0&&(s=new h(r.from,r.to)),s.from<s.to)){let e=t.ranges.length-1;e>=0&&t.ranges[e].to==s.from?t.ranges[e]={from:t.ranges[e].from,to:s.to}:t.ranges.push(s)}if(o&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break scan;if(t&&!--t.depth){let e=Ie(this.ranges,t.ranges);e.length&&(De(e),this.inner.splice(t.index,0,new Ee(t.parser,t.parser.startParse(this.input,Re(t.mounts,e),e),t.ranges.map(e=>new h(e.from-t.start,e.to-t.start)),t.bracketed,t.target,e[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}};function je(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function Me(e,t,n,r,i,a){if(t<n){let o=e.buffer[t+1];r.push(e.slice(t,n,o)),i.push(o-a)}}function Ne(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,a=i.children.indexOf(r),o=i.children[a],s=o.buffer,c=[a];function l(e,r,i,a,u,d){let f=n[d],p=[],m=[];Me(o,e,f,p,m,a);let h=s[f+1],g=s[f+2];c.push(p.length);let _=d?l(f+4,s[f+3],o.set.types[s[f]],h,g-h,d-1):t.toTree();return p.push(_),m.push(h-a),Me(o,s[f+3],r,p,m,a),new x(i,p,m,u)}i.children[a]=l(0,s.length,v.none,0,o.length,n.length-1);for(let t of c){let n=e.tree.children[t],r=e.tree.positions[t];e.yield(new S(n,r+e.from,t,e._tree))}}var Pe=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(b.IncludeAnonymous|b.IgnoreMounts)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)if(!(t.to>=e&&t.enter(n,1,b.IgnoreOverlays|b.ExcludeBuffers))){if(t.to<=e)t.next(!1)||(this.done=!0);else break}}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof x)t=t.children[0];else break}return!1}},Fe=class{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=t.tree.prop(ke)??t.to,this.inner=new Pe(t.tree,-t.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=e.tree.prop(ke)??e.to,this.inner=new Pe(e.tree,-e.offset)}}findMounts(e,t){let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=e.tree?.prop(g.mounted);if(r&&r.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let i=this.fragments[t];if(i.from>=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}};function Ie(e,t){let n=null,r=t;for(let i=1,a=0;i<e.length;i++){let o=e[i-1].to,s=e[i].from;for(;a<r.length;a++){let e=r[a];if(e.from>=s)break;e.to<=o||(n||(r=n=t.slice()),e.from<o?(n[a]=new h(e.from,o),e.to>s&&n.splice(a+1,0,new h(s,e.to))):e.to>s?n[a--]=new h(s,e.to):n.splice(a--,1))}}return r}function Le(e,t,n,r){let i=0,a=0,o=!1,s=!1,c=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,d=a==t.length?1e9:s?t[a].to:t[a].from;if(o!=s){let e=Math.max(c,n),t=Math.min(u,d,r);e<t&&l.push(new h(e,t))}if(c=Math.min(u,d),c==1e9)break;u==c&&(o?(o=!1,i++):o=!0),d==c&&(s?(s=!1,a++):s=!0)}return l}function Re(e,t){let n=[];for(let{pos:r,mount:i,frag:a}of e){let e=r+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length,s=Math.max(a.from,e),c=Math.min(a.to,o);if(i.overlay){let o=Le(t,i.overlay.map(e=>new h(e.from+r,e.to+r)),s,c);for(let t=0,r=s;;t++){let s=t==o.length,l=s?c:o[t].from;if(l>r&&n.push(new Se(r,l,i.tree,-e,a.from>=r||a.openStart,a.to<=l||a.openEnd)),s)break;r=o[t].to}}else n.push(new Se(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var ze=0,Be=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=ze++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new He(e);return e=>e.modified.indexOf(t)>-1?e:He.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},Ve=0,He=class e{constructor(e){this.name=e,this.instances=[],this.id=Ve++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&Ue(n,e.modified));if(r)return r;let i=[],a=new Be(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=We(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function Ue(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function We(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function Ge(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new qe(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Ke.add(t)}var Ke=new g({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new qe(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),qe=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};qe.empty=new qe([],2,null);function Je(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function Ye(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function Xe(e,t,n,r=0,i=e.length){let a=new Ze(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Ze=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=Qe(e)||qe.empty,u=Ye(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(g.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function Qe(e){let t=e.type.prop(Ke);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var C=Be.define,$e=C(),et=C(),tt=C(et),nt=C(et),rt=C(),it=C(rt),at=C(rt),ot=C(),st=C(ot),ct=C(),lt=C(),ut=C(),dt=C(ut),ft=C(),w={comment:$e,lineComment:C($e),blockComment:C($e),docComment:C($e),name:et,variableName:C(et),typeName:tt,tagName:C(tt),propertyName:nt,attributeName:C(nt),className:C(et),labelName:C(et),namespace:C(et),macroName:C(et),literal:rt,string:it,docString:C(it),character:C(it),attributeValue:C(it),number:at,integer:C(at),float:C(at),bool:C(rt),regexp:C(rt),escape:C(rt),color:C(rt),url:C(rt),keyword:ct,self:C(ct),null:C(ct),atom:C(ct),unit:C(ct),modifier:C(ct),operatorKeyword:C(ct),controlKeyword:C(ct),definitionKeyword:C(ct),moduleKeyword:C(ct),operator:lt,derefOperator:C(lt),arithmeticOperator:C(lt),logicOperator:C(lt),bitwiseOperator:C(lt),compareOperator:C(lt),updateOperator:C(lt),definitionOperator:C(lt),typeOperator:C(lt),controlOperator:C(lt),punctuation:ut,separator:C(ut),bracket:dt,angleBracket:C(dt),squareBracket:C(dt),paren:C(dt),brace:C(dt),content:ot,heading:st,heading1:C(st),heading2:C(st),heading3:C(st),heading4:C(st),heading5:C(st),heading6:C(st),contentSeparator:C(ot),list:C(ot),quote:C(ot),emphasis:C(ot),strong:C(ot),link:C(ot),monospace:C(ot),strikethrough:C(ot),inserted:C(),deleted:C(),changed:C(),invalid:C(),meta:ft,documentMeta:C(ft),annotation:C(ft),processingInstruction:C(ft),definition:Be.defineModifier(`definition`),constant:Be.defineModifier(`constant`),function:Be.defineModifier(`function`),standard:Be.defineModifier(`standard`),local:Be.defineModifier(`local`),special:Be.defineModifier(`special`)};for(let e in w){let t=w[e];t instanceof Be&&(t.name=e)}Je([{tag:w.link,class:`tok-link`},{tag:w.heading,class:`tok-heading`},{tag:w.emphasis,class:`tok-emphasis`},{tag:w.strong,class:`tok-strong`},{tag:w.keyword,class:`tok-keyword`},{tag:w.atom,class:`tok-atom`},{tag:w.bool,class:`tok-bool`},{tag:w.url,class:`tok-url`},{tag:w.labelName,class:`tok-labelName`},{tag:w.inserted,class:`tok-inserted`},{tag:w.deleted,class:`tok-deleted`},{tag:w.literal,class:`tok-literal`},{tag:w.string,class:`tok-string`},{tag:w.number,class:`tok-number`},{tag:[w.regexp,w.escape,w.special(w.string)],class:`tok-string2`},{tag:w.variableName,class:`tok-variableName`},{tag:w.local(w.variableName),class:`tok-variableName tok-local`},{tag:w.definition(w.variableName),class:`tok-variableName tok-definition`},{tag:w.special(w.variableName),class:`tok-variableName2`},{tag:w.definition(w.propertyName),class:`tok-propertyName tok-definition`},{tag:w.typeName,class:`tok-typeName`},{tag:w.namespace,class:`tok-namespace`},{tag:w.className,class:`tok-className`},{tag:w.macroName,class:`tok-macroName`},{tag:w.propertyName,class:`tok-propertyName`},{tag:w.operator,class:`tok-operator`},{tag:w.comment,class:`tok-comment`},{tag:w.meta,class:`tok-meta`},{tag:w.invalid,class:`tok-invalid`},{tag:w.punctuation,class:`tok-punctuation`}]);var pt=[],mt=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?mt:pt).push(n+=e[t])})();function ht(e){if(e<768)return!1;for(let t=0,n=pt.length;;){let r=t+n>>1;if(e<pt[r])n=r;else if(e>=mt[r])t=r+1;else return!0;if(t==n)return!1}}function gt(e){return e>=127462&&e<=127487}var _t=8205;function vt(e,t,n=!0,r=!0){return(n?yt:bt)(e,t,r)}function yt(e,t,n){if(t==e.length)return t;t&&St(e.charCodeAt(t))&&Ct(e.charCodeAt(t-1))&&t--;let r=xt(e,t);for(t+=wt(r);t<e.length;){let i=xt(e,t);if(r==_t||i==_t||n&&ht(i))t+=wt(i),r=i;else if(gt(i)){let n=0,r=t-2;for(;r>=0&&gt(xt(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function bt(e,t,n){for(;t>1;){let r=yt(e,t-2,n);if(r<t)return r;t--}return 0}function xt(e,t){let n=e.charCodeAt(t);if(!Ct(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return St(r)?(n-55296<<10)+(r-56320)+65536:n}function St(e){return e>=56320&&e<57344}function Ct(e){return e>=55296&&e<56320}function wt(e){return e<65536?1:2}var T=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Pt(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Et.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Pt(this,e,t);let n=[];return this.decompose(e,t,n,0),Et.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new At(this),i=new At(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new At(this,e)}iterRange(e,t=this.length){return new jt(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Mt(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new Tt(t):Et.from(Tt.split(t,[]))}},Tt=class e extends T{constructor(e,t=Dt(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new Nt(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(kt(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=Ot(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=Pt(this,t,n);let i=Ot(this.text,Ot(r.text,kt(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):Et.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
3
3
  `){[e,t]=Pt(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},Et=class e extends T{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=Pt(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
4
4
  `){[e,t]=Pt(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new Tt(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof Tt&&c&&(n=u[u.length-1])instanceof Tt&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new Tt(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};T.empty=new Tt([``],0);function Dt(e){let t=-1;for(let n of e)t+=n.length+1;return t}function Ot(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function kt(e,t,n){return Ot(e,[``],t,n)}var At=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof Tt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof Tt?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
5
5
  `,this;e--}else if(r instanceof Tt){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof Tt?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},jt=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new At(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},Mt=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(T.prototype[Symbol.iterator]=function(){return this.iter()},At.prototype[Symbol.iterator]=jt.prototype[Symbol.iterator]=Mt.prototype[Symbol.iterator]=function(){return this});var Nt=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function Pt(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function E(e,t,n=!0,r=!0){return vt(e,t,n,r)}function Ft(e){return e>=56320&&e<57344}function It(e){return e>=55296&&e<56320}function Lt(e,t){let n=e.charCodeAt(t);if(!It(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Ft(r)?(n-55296<<10)+(r-56320)+65536:n}function Rt(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function zt(e){return e<65536?1:2}var Bt=/\r\n?|\n/,D=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(D||={}),Vt=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){Wt(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:Kt(this,e)}mapDesc(e,t=!1){return e.empty?this:Gt(this,e,t)}mapPos(e,t=-1,n=D.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=D.Simple&&c>=e&&(n==D.TrackDel&&r<e&&c>e||n==D.TrackBefore&&r<e||n==D.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},Ht=class e extends Vt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return Wt(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return Gt(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(T.empty);r.push(a?t.slice(i,i+a):T.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:Kt(this,e,!0)}map(e,t=!1){return e.empty?this:Gt(this,e,t,!0)}iterChanges(e,t=!1){Wt(this,e,t)}get desc(){return Vt.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new qt(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);O(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;O(n,e,t),t>0&&Ut(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);O(n,e,-1),O(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:Vt.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&O(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?T.of(l.split(r||Bt)):l:T.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&O(i,e-o,-1),O(i,s-e,d),Ut(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(T.empty);r[e]=T.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function O(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function Ut(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(T.empty);e.push(n)}}function Wt(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=T.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function Gt(e,t,n,r=!1){let i=[],a=r?[]:null,o=new qt(e),s=new qt(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);O(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(O(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(O(i,0,o.ins),a&&Ut(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;O(i,t,e<o.i?o.ins:0),a&&e<o.i&&Ut(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?Ht.createSet(i,a):Vt.create(i);else throw Error(`Mismatched change set lengths`)}function Kt(e,t,n=!1){let r=[],i=n?[]:null,a=new qt(e),o=new qt(t);for(let e=!1;;)if(a.done&&o.done)return i?Ht.createSet(r,i):Vt.create(r);else if(a.ins==0)O(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)O(r,0,o.ins,e),i&&Ut(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;O(r,t,n,e),i&&n&&Ut(i,r,o.text)}else o.ins==-1?(O(r,a.off?0:a.len,t,e),i&&Ut(i,r,a.textBit(t))):(O(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&Ut(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var qt=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?T.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?T.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Jt=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return k.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return k.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return k.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},k=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>Jt.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return Jt.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,i){let a=r==null?7:Math.min(6,r);return!i&&e!=t&&(i=t<e?1:-1),i&&(a|=i<0?8:16),t<e?Jt.create(t,e,a|32,n):Jt.create(e,t,a,n)}static undirectionalRange(e,t){return Jt.create(e,t,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function Yt(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var Xt=0,A=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Xt++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Zt),!!t.static,t.enables)}of(e){return new Qt([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Qt(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Qt(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Zt(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var Qt=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Xt++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||en(e,c)){let r=t(e);if(a?!$t(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=mn(o,c);if(this.dependencies.every(t=>t instanceof A?o.facet(t)===e.facet(t):t instanceof rn?o.field(t,!1)==e.field(t,!1):!0)||(a?$t(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function $t(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function en(e,t){let n=!1;for(let r of t)pn(e,r)&1&&(n=!0);return n}function tn(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=mn(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)pn(e,t);return e.values[o]=s(e),1},update(e,n){if(!en(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=en(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Zt(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var nn=A.define({static:!0}),rn=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(Xt++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(nn).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(nn),i=n.facet(nn),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,nn.of({field:this,create:e})]}get extension(){return this}},an={lowest:4,low:3,default:2,high:1,highest:0};function on(e){return t=>new cn(t,e)}var sn={highest:on(an.highest),high:on(an.high),default:on(an.default),low:on(an.low),lowest:on(an.lowest)},cn=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},ln=class e{of(e){return new un(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},un=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},dn=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of fn(t,n,o))e instanceof rn?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,Zt(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>tn(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function fn(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof un&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof un){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof cn)a(e.inner,e.prec);else if(e instanceof rn)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof Qt)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,an.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,an.default),r.reduce((e,t)=>e.concat(t))}function pn(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function mn(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var hn=A.define(),gn=A.define({combine:e=>e.some(e=>e),static:!0}),_n=A.define({combine:e=>e.length?e[0]:void 0,static:!0}),vn=A.define(),yn=A.define(),bn=A.define(),xn=A.define({combine:e=>e.length?e[0]:!1}),Sn=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Cn}},Cn=class{of(e){return new Sn(this,e)}},wn=class{constructor(e){this.map=e}of(e){return new j(this,e)}},j=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new wn(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};j.reconfigure=j.define(),j.appendConfig=j.define();var M=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Yt(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};M.time=Sn.define(),M.userEvent=Sn.define(),M.addToHistory=Sn.define(),M.remote=Sn.define();function Tn(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function En(e,t,n){let r,i,a;return n?(r=t.changes,i=Ht.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:j.mapEffects(e.effects,r).concat(j.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Dn(e,t,n){let r=t.selection,i=Mn(t.annotations);return t.userEvent&&(i=i.concat(M.userEvent.of(t.userEvent))),{changes:t.changes instanceof Ht?t.changes:Ht.of(t.changes||[],n,e.facet(_n)),selection:r&&(r instanceof k?r:k.single(r.anchor,r.head)),effects:Mn(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function On(e,t,n){let r=Dn(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=En(r,Dn(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=M.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return An(n?kn(i):i)}function kn(e){let t=e.startState,n=!0;for(let r of t.facet(vn)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:Tn(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=Ht.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=M.create(t,r,e.selection&&e.selection.map(i),j.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(yn);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof M?i:Array.isArray(i)&&i.length==1&&i[0]instanceof M?i[0]:On(t,Mn(i),!1)}return e}function An(e){let t=e.startState,n=t.facet(bn),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=En(r,Dn(t,a,e.changes.newLength),!0))}return r==e?e:M.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var jn=[];function Mn(e){return e==null?jn:Array.isArray(e)?e:[e]}var N=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(N||={}),Nn=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Pn;try{Pn=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function Fn(e){if(Pn)return Pn.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>`€`&&(n.toUpperCase()!=n.toLowerCase()||Nn.test(n)))return!0}return!1}function In(e){return t=>{if(!/\S/.test(t))return N.Space;if(Fn(t))return N.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return N.Word;return N.Other}}var P=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)pn(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return pn(this,n),mn(this,n)}update(...e){return On(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(ln.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(j.reconfigure)?(n=null,r=e.value):e.is(j.appendConfig)&&(n=null,r=Mn(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=dn.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(gn)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:k.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=Mn(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=j.mapEffects(a,c).concat(j.mapEffects(Mn(o.effects),l))}return{changes:r,selection:k.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof Ht?t:Ht.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return T.of(t.split(this.facet(e.lineSeparator)||Bt))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(pn(this,t),mn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof rn&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:k.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=dn.resolve(t.extensions||[],new Map),r=t.doc instanceof T?t.doc:T.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||Bt)),i=t.selection?t.selection instanceof k?t.selection:k.single(t.selection.anchor,t.selection.head):k.single(0);return Yt(i,r.length),n.staticFacet(gn)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
@@ -12,4 +12,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from
12
12
  `&&(t=``);else{let e=t.indexOf(`
13
13
  `);e>-1&&(t=t.slice(0,e))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let e=this.rangeIndex;;){let r=this.ranges[e].to;if(r>=n||(t=t.slice(0,r-(n-t.length)),e++,e==this.ranges.length))break;let i=this.ranges[e].from,a=this.lineAfter(i);t+=a,n=i+a.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,i=e+t;if(n>0?r>i:r>=i)break;let a=this.ranges[++this.rangeIndex].from;t+=a-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r){let i=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let e=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,i+=this.chunk.length-e}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&a>=0&&this.chunk[a]==e&&this.chunk[a+2]==t?this.chunk[a+2]=n:this.chunk.push(e,t,n,i),r}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:i}=this.lang,a=new Ed(t,e?e.state.tabSize:4,e?eu(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=Fd(i.token,a,this.state);if(e&&(r=this.emitToken(this.lang.tokenTable.resolve(e),this.parsedPos+a.start,this.parsedPos+a.pos,r)),a.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=x.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Rd,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new x(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new x(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Fd(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let r=e(t,n);if(t.pos>t.start)return r}throw Error(`Stream parser failed to advance stream.`)}var Id=Object.create(null),Ld=[v.none],Rd=new te(Ld),zd=[],Bd=Object.create(null),Vd=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])Vd[e]=Gd(Id,t);var Hd=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Vd)}resolve(e){return e?this.table[e]||(this.table[e]=Gd(this.extra,e)):0}},Ud=new Hd(Id);function Wd(e,t){zd.indexOf(e)>-1||(zd.push(e),console.warn(t))}function Gd(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||w[n];r?typeof r==`function`?t.length?t=t.map(r):Wd(n,`Modifier ${n} used at start of tag`):t.length?Wd(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Wd(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=Bd[i];if(a)return a.id;let o=Bd[i]=v.define({id:Ld.length,name:r,props:[Ge({[r]:n})]});return Ld.push(o),o.id}function Kd(e,t){let n=v.define({id:Ld.length,name:`Document`,props:[Ml.add(()=>e),au.add(()=>e=>t.getIndent(e))],top:!0});return Ld.push(n),n}function qd(e){return e.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(e)}function Jd(e){for(let t=e.iter();!t.next().done;)if(qd(t.value))return!0;return!1}function Yd(e){let t=!1;return e.iterChanges((e,n,r,i,a)=>{!t&&Jd(a)&&(t=!0)}),t}var Xd=A.define({combine:e=>e.some(e=>e)});function Zd(e={}){let t=[Qd];return e.alwaysIsolate&&t.push(Xd.of(!0)),t}var Qd=W.fromClass(class{constructor(e){this.always=e.state.facet(Xd)||e.textDirection!=H.LTR||e.state.facet(J.perLineTextDirection),this.hasRTL=!this.always&&Jd(e.state.doc),this.tree=X(e.state),this.decorations=this.always||this.hasRTL?$d(e,this.tree,this.always):V.none}update(e){let t=e.state.facet(Xd)||e.view.textDirection!=H.LTR||e.state.facet(J.perLineTextDirection);if(!t&&!this.hasRTL&&Yd(e.changes)&&(this.hasRTL=!0),!t&&!this.hasRTL)return;let n=X(e.state);(t!=this.always||n!=this.tree||e.docChanged||e.viewportChanged)&&(this.tree=n,this.always=t,this.decorations=$d(e.view,n,t))}},{provide:e=>{function t(t){return t.plugin(e)?.decorations??V.none}return[J.outerDecorations.of(t),sn.lowest(J.bidiIsolatedRanges.of(t))]}});function $d(e,t,n){let r=new Wn,i=e.visibleRanges;n||(i=ef(i,e.state.doc));for(let{from:e,to:n}of i)t.iterate({enter:e=>{let t=e.type.prop(g.isolate);t&&r.add(e.from,e.to,tf[t])},from:e,to:n});return r.finish()}function ef(e,t){let n=t.iter(),r=0,i=[],a=null;for(let{from:t,to:o}of e)if(!(a&&a.to>t&&(t=a.to,t>=o)))for(r+n.value.length<t&&(n.next(t-(r+n.value.length)),r=t);;){let e=r,t=r+n.value.length;if(!n.lineBreak&&qd(n.value)&&(a&&a.to>e-10?a.to=Math.min(o,t):i.push(a={from:e,to:Math.min(o,t)})),t>=o)break;r=t,n.next()}return i}var tf={rtl:V.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`rtl`},bidiIsolate:H.RTL}),ltr:V.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`ltr`},bidiIsolate:H.LTR}),auto:V.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`auto`},bidiIsolate:null})},nf={"&":{color:`var(--doom-text)`,backgroundColor:`var(--doom-deep)`,fontSize:`12px`,height:`100%`},".cm-scroller":{fontFamily:`var(--doom-font-mono)`,lineHeight:`1.5`},".cm-content":{caretColor:`var(--doom-blue)`,padding:`8px 0`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--doom-blue)`,borderLeftWidth:`2px`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`var(--doom-selected)`},".cm-gutters":{backgroundColor:`var(--doom-deep)`,color:`var(--doom-faint)`,borderRight:`1px solid var(--doom-border-soft)`},".cm-activeLine":{backgroundColor:`var(--doom-panel)`},".cm-activeLineGutter":{backgroundColor:`var(--doom-panel)`,color:`var(--doom-dim)`},".cm-foldPlaceholder":{backgroundColor:`var(--doom-panel)`,border:`1px solid var(--doom-border)`,color:`var(--doom-dim)`},".cm-searchMatch":{backgroundColor:`var(--doom-tint-yellow)`,outline:`1px solid var(--doom-edge-yellow)`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`var(--doom-tint-orange)`},".cm-selectionMatch":{backgroundColor:`var(--doom-tint-blue)`},".cm-matchingBracket, &.cm-focused .cm-matchingBracket":{backgroundColor:`var(--doom-tint-green)`,outline:`1px solid var(--doom-edge-green)`},".cm-nonmatchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`var(--doom-tint-red)`},".cm-panels":{backgroundColor:`var(--doom-panel)`,color:`var(--doom-text)`,fontSize:`11px`},".cm-panels.cm-panels-bottom":{borderTop:`1px solid var(--doom-border)`},".cm-panels.cm-panels-top":{borderBottom:`1px solid var(--doom-border)`},".cm-panel input, .cm-panel button, .cm-panel select":{backgroundColor:`var(--doom-deep)`,color:`var(--doom-text)`,border:`1px solid var(--doom-border)`,borderRadius:`2px`,fontFamily:`var(--doom-font-mono)`,fontSize:`11px`},".cm-tooltip":{backgroundColor:`var(--doom-panel)`,border:`1px solid var(--doom-border)`,color:`var(--doom-text)`}},Z={comment:{color:`var(--doom-faint)`,fontStyle:`italic`},keyword:{color:`var(--doom-magenta)`},constant:{color:`var(--doom-violet)`},literal:{color:`var(--doom-orange)`},string:{color:`var(--doom-green)`},regexp:{color:`var(--doom-teal)`},operator:{color:`var(--doom-blue)`},punctuation:{color:`var(--doom-dim)`},variable:{color:`var(--doom-text)`},property:{color:`var(--doom-cyan)`},callable:{color:`var(--doom-blue)`},type:{color:`var(--doom-yellow)`},tag:{color:`var(--doom-red)`},attribute:{color:`var(--doom-yellow)`},meta:{color:`var(--doom-faint)`},heading:{color:`var(--doom-hi)`,fontWeight:`bold`},link:{color:`var(--doom-cyan)`,textDecoration:`underline`},emphasis:{fontStyle:`italic`},strong:{fontWeight:`bold`},strikethrough:{textDecoration:`line-through`},invalid:{color:`var(--doom-red)`}},rf=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=lf(e.state,n.from);return r.line?of(e):r.block?cf(e):!1};function af(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var of=af(mf,0),sf=af(pf,0),cf=af((e,t)=>pf(e,t,ff(t)),0);function lf(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var uf=50;function df(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-uf,r),o=e.sliceDoc(i,i+uf),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+uf),d=e.sliceDoc(i-uf,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function ff(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function pf(e,t,n=t.selection.ranges){let r=n.map(e=>lf(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>df(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function mf(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=lf(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var hf=Sn.define(),gf=Sn.define(),_f=A.define(),vf=A.define({combine(e){return Ln(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),yf=rn.define({create(){return Rf.empty},update(e,t){let n=t.state.facet(vf),r=t.annotation(hf);if(r){let i=Ef.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?Df(o,o.length,n.minDepth,i):Nf(o,t.startState.selection),new Rf(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(gf);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(M.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=Ef.fromTransaction(t),o=t.annotation(M.time),s=t.annotation(M.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Rf(e.done.map(Ef.fromJSON),e.undone.map(Ef.fromJSON))}});function bf(e={}){return[yf,vf.of(e),J.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Sf:e.inputType==`historyRedo`?Cf:null;return n?(e.preventDefault(),n(t)):!1}})]}function xf(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(yf,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Sf=xf(0,!1),Cf=xf(1,!1),wf=xf(0,!0),Tf=xf(1,!0),Ef=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&Ht.fromJSON(t.changes),[],t.mapped&&Vt.fromJSON(t.mapped),t.startSelection&&k.fromJSON(t.startSelection),t.selectionsAfter.map(k.fromJSON))}static fromTransaction(t,n){let r=jf;for(let e of t.startState.facet(_f)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,jf)}static selection(t){return new e(void 0,jf,void 0,void 0,t)}};function Df(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Of(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function kf(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function Af(e,t){return e.length?t.length?e.concat(t):e:t}var jf=[],Mf=200;function Nf(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Mf));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Df(e,e.length-1,1e9,n.setSelAfter(r)))}return[Ef.selection([t])]}function Pf(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Ff(e,t){if(!e.length)return e;let n=e.length,r=jf;for(;n;){let i=If(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[Ef.selection(r)]:jf}function If(e,t,n){let r=Af(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):jf,n);if(!e.changes)return Ef.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new Ef(i,j.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Lf=/^(input\.type|delete)($|\.)/,Rf=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Lf.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Of(s.changes,t.changes))||r==`input.type.compose`)?Df(o,o.length-1,i.minDepth,new Ef(t.changes.compose(s.changes),Af(j.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,jf)):Df(o,o.length,i.minDepth,t),new e(o,jf,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:jf;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&kf(a[a.length-1],t)?this:new e(Nf(this.done,t),this.undone,n,r)}addMapping(t){return new e(Ff(this.done,t),Ff(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:hf.of({side:e,rest:Pf(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?jf:r.slice(0,r.length-1);return i.mapped&&(n=Ff(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:hf.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};Rf.empty=new Rf(jf,jf);var zf=[{key:`Mod-z`,run:Sf,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:Cf,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:Cf,preventDefault:!0},{key:`Mod-u`,run:wf,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Tf,preventDefault:!0}];function Bf(e,t){return k.create(e.ranges.map(t),e.mainIndex)}function Vf(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function Hf({state:e,dispatch:t},n){let r=Bf(e.selection,n);return!r.eq(e.selection,!0)&&(t(Vf(e,r)),!0)}function Uf(e,t){return k.cursor(t?e.to:e.from)}function Wf(e,t){return Hf(e,n=>n.empty?e.moveByChar(n,t):Uf(n,t))}function Q(e){return e.textDirectionAt(e.state.selection.main.head)==H.LTR}var Gf=e=>Wf(e,!Q(e)),Kf=e=>Wf(e,Q(e));function qf(e,t){return Hf(e,n=>n.empty?e.moveByGroup(n,t):Uf(n,t))}var Jf=e=>qf(e,!Q(e)),Yf=e=>qf(e,Q(e));typeof Intl<`u`&&Intl.Segmenter;function Xf(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Zf(e,t,n){let r=X(e).resolveInner(t.head),i=n?g.closedBy:g.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Xf(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?Sd(e,r.from,1):Sd(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,k.cursor(s,n?-1:1)}var Qf=e=>Hf(e,t=>Zf(e.state,t,!Q(e))),$f=e=>Hf(e,t=>Zf(e.state,t,Q(e)));function ep(e,t){return Hf(e,n=>{if(!n.empty)return Uf(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var tp=e=>ep(e,!1),np=e=>ep(e,!0);function rp(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(J.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function ip(e,t){let n=rp(e),{state:r}=e,i=Bf(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Uf(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=J.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(Vf(r,i),{effects:a}),!0}var ap=e=>ip(e,!1),op=e=>ip(e,!0);function sp(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=k.cursor(r.from+n))}return i}var cp=e=>Hf(e,t=>sp(e,t,!0)),lp=e=>Hf(e,t=>sp(e,t,!1)),up=e=>Hf(e,t=>sp(e,t,!Q(e))),dp=e=>Hf(e,t=>sp(e,t,Q(e))),fp=e=>Hf(e,t=>k.cursor(e.lineBlockAt(t.head).from,1)),pp=e=>Hf(e,t=>k.cursor(e.lineBlockAt(t.head).to,-1));function mp(e,t,n){let r=!1,i=Bf(e.selection,t=>{let i=Sd(e,t.head,-1)||Sd(e,t.head,1)||t.head>0&&Sd(e,t.head-1,1)||t.head<e.doc.length&&Sd(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?k.range(t.anchor,a):k.cursor(a)});return r?(t(Vf(e,i)),!0):!1}var hp=({state:e,dispatch:t})=>mp(e,t,!1);function gp(e,t,n){let r=Bf(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=k.range(e.head,e.anchor));let r=n(e);return k.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(Vf(e.state,r)),!0)}function _p(e,t){return gp(e,t,n=>e.moveByChar(n,t))}var vp=e=>_p(e,!Q(e)),yp=e=>_p(e,Q(e));function bp(e,t){return gp(e,t,n=>e.moveByGroup(n,t))}var xp=e=>bp(e,!Q(e)),Sp=e=>bp(e,Q(e)),Cp=e=>{let t=!Q(e);return gp(e,t,n=>Zf(e.state,n,t))},wp=e=>{let t=Q(e);return gp(e,t,n=>Zf(e.state,n,t))};function Tp(e,t){return gp(e,t,n=>e.moveVertically(n,t))}var Ep=e=>Tp(e,!1),Dp=e=>Tp(e,!0);function Op(e,t){return gp(e,t,n=>e.moveVertically(n,t,rp(e).height))}var kp=e=>Op(e,!1),Ap=e=>Op(e,!0),jp=e=>gp(e,!0,t=>sp(e,t,!0)),Mp=e=>gp(e,!1,t=>sp(e,t,!1)),Np=e=>{let t=!Q(e);return gp(e,t,n=>sp(e,n,t))},Pp=e=>{let t=Q(e);return gp(e,t,n=>sp(e,n,t))},Fp=e=>gp(e,!1,t=>k.cursor(e.lineBlockAt(t.head).from)),Ip=e=>gp(e,!0,t=>k.cursor(e.lineBlockAt(t.head).to)),Lp=({state:e,dispatch:t})=>(t(Vf(e,{anchor:0})),!0),Rp=({state:e,dispatch:t})=>(t(Vf(e,{anchor:e.doc.length})),!0),zp=({state:e,dispatch:t})=>(t(Vf(e,{anchor:e.selection.main.anchor,head:0})),!0),Bp=({state:e,dispatch:t})=>(t(Vf(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Vp=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Hp=({state:e,dispatch:t})=>{let n=sm(e).map(({from:t,to:n})=>k.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:k.create(n),userEvent:`select`})),!0},Up=({state:e,dispatch:t})=>{let n=Bf(e.selection,t=>{let n=X(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return k.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(Vf(e,n)),!0)};function Wp(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(Vf(n,k.create(i,i.length-1))),!0)}var Gp=e=>Wp(e,!1),Kp=e=>Wp(e,!0),qp=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=k.create([n.main]):n.main.empty||(r=k.create([k.cursor(n.main.head)])),r?(t(Vf(e,r)),!0):!1};function Jp(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Yp(e,o,!1)):o>i&&(n=`delete.forward`,o=Yp(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Yp(e,i,!1),a=Yp(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:k.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?J.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Yp(e,t,n){if(e instanceof J)for(let r of e.state.facet(J.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var Xp=(e,t,n)=>Jp(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=tr(s,a.tabSize)%eu(a)||eu(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=E(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=E(o.text,c-o.from,!1,!1)+o.from);return c}),Zp=e=>Xp(e,!1,!0),Qp=e=>Xp(e,!0,!1),$p=(e,t)=>Jp(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=E(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),em=e=>$p(e,!1),tm=e=>$p(e,!0),nm=e=>Jp(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),rm=e=>Jp(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),im=e=>Jp(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),am=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:T.of([``,``])},range:k.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},om=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:E(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:E(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:k.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function sm(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function cm(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of sm(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(k.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(k.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:k.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var lm=({state:e,dispatch:t})=>cm(e,t,!1),um=({state:e,dispatch:t})=>cm(e,t,!0);function dm(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of sm(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var fm=({state:e,dispatch:t})=>dm(e,t,!1),pm=({state:e,dispatch:t})=>dm(e,t,!0),mm=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(sm(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=Bf(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function hm(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=X(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(g.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var gm=vm(!1),_m=vm(!0);function vm(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&hm(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new iu(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=nu(s,r);for(c??=tr(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,tu(t,c)];return o&&l.push(tu(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:T.of(l)},range:k.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function ym(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:k.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var bm=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new iu(e,{overrideIndentation:e=>n[e]??-1}),i=ym(e,(t,i,a)=>{let o=nu(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=tu(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},xm=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(ym(e,(t,n)=>{n.push({from:t.from,insert:e.facet($l)})}),{userEvent:`input.indent`})),!0),Sm=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(ym(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=tr(r,e.tabSize),a=0,o=tu(e,Math.max(0,i-eu(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Cm=e=>(e.setTabFocusMode(),!0),wm=[{key:`Ctrl-b`,run:Gf,shift:vp,preventDefault:!0},{key:`Ctrl-f`,run:Kf,shift:yp},{key:`Ctrl-p`,run:tp,shift:Ep},{key:`Ctrl-n`,run:np,shift:Dp},{key:`Ctrl-a`,run:fp,shift:Fp},{key:`Ctrl-e`,run:pp,shift:Ip},{key:`Ctrl-d`,run:Qp},{key:`Ctrl-h`,run:Zp},{key:`Ctrl-k`,run:nm},{key:`Ctrl-Alt-h`,run:em},{key:`Ctrl-o`,run:am},{key:`Ctrl-t`,run:om},{key:`Ctrl-v`,run:op}],Tm=[{key:`ArrowLeft`,run:Gf,shift:vp,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Jf,shift:xp,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:up,shift:Np,preventDefault:!0},{key:`ArrowRight`,run:Kf,shift:yp,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Yf,shift:Sp,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:dp,shift:Pp,preventDefault:!0},{key:`ArrowUp`,run:tp,shift:Ep,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Lp,shift:zp},{mac:`Ctrl-ArrowUp`,run:ap,shift:kp},{key:`ArrowDown`,run:np,shift:Dp,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Rp,shift:Bp},{mac:`Ctrl-ArrowDown`,run:op,shift:Ap},{key:`PageUp`,run:ap,shift:kp},{key:`PageDown`,run:op,shift:Ap},{key:`Home`,run:lp,shift:Mp,preventDefault:!0},{key:`Mod-Home`,run:Lp,shift:zp},{key:`End`,run:cp,shift:jp,preventDefault:!0},{key:`Mod-End`,run:Rp,shift:Bp},{key:`Enter`,run:gm,shift:gm},{key:`Mod-a`,run:Vp},{key:`Backspace`,run:Zp,shift:Zp,preventDefault:!0},{key:`Delete`,run:Qp,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:em,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:tm,preventDefault:!0},{mac:`Mod-Backspace`,run:rm,preventDefault:!0},{mac:`Mod-Delete`,run:im,preventDefault:!0}].concat(wm.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Em=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Qf,shift:Cp},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:$f,shift:wp},{key:`Alt-ArrowUp`,run:lm},{key:`Shift-Alt-ArrowUp`,run:fm},{key:`Alt-ArrowDown`,run:um},{key:`Shift-Alt-ArrowDown`,run:pm},{key:`Mod-Alt-ArrowUp`,run:Gp},{key:`Mod-Alt-ArrowDown`,run:Kp},{key:`Escape`,run:qp},{key:`Mod-Enter`,run:_m},{key:`Alt-l`,mac:`Ctrl-l`,run:Hp},{key:`Mod-i`,run:Up,preventDefault:!0},{key:`Mod-[`,run:Sm},{key:`Mod-]`,run:xm},{key:`Mod-Alt-\\`,run:bm},{key:`Shift-Mod-k`,run:mm},{key:`Shift-Mod-\\`,run:hp},{key:`Mod-/`,run:rf},{key:`Alt-A`,mac:`Ctrl-A`,run:sf},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Cm}].concat(Tm),Dm={key:`Tab`,run:xm,shift:Sm},Om=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,km=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(Om(e)):Om,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Lt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Rt(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=zt(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(km.prototype[Symbol.iterator]=function(){return this});var Am={from:-1,to:-1,match:/.*/.exec(``),precise:!0},jm=`gm`+(/x/.unicode==null?``:`u`),Mm=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=Am,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Fm(e,t,n,r,i);this.re=new RegExp(t,jm+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=Lm(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Lm(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Nm=new WeakMap,Pm=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Nm.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Nm.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Nm.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Fm=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Am,this.matchPos=Lm(e,r),this.re=new RegExp(t,jm+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Pm.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=Lm(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Pm.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Mm.prototype[Symbol.iterator]=Fm.prototype[Symbol.iterator]=function(){return this});function Im(e){try{return new RegExp(e,jm),!0}catch{return!1}}function Lm(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Rm=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=tl(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=k.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,J.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},zm={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Bm=A.define({combine(e){return Ln(e,zm,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Vm(e){let t=[qm,Km];return e&&t.push(Bm.of(e)),t}var Hm=V.mark({class:`cm-selectionMatch`}),Um=V.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Wm(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=N.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=N.Word)}function Gm(e,t,n,r){return e(t.sliceDoc(n,n+1))==N.Word&&e(t.sliceDoc(r-1,r))==N.Word}var Km=W.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Bm),{state:n}=e,r=n.selection;if(r.ranges.length>1)return V.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return V.none;let e=n.wordAt(i.head);if(!e)return V.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return V.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Wm(o,n,i.from,i.to)&&Gm(o,n,i.from,i.to)))return V.none}else if(a=n.sliceDoc(i.from,i.to),!a)return V.none}let s=[];for(let r of e.visibleRanges){let e=new km(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Wm(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Um.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Hm.range(r,a)),s.length>t.maxMatches))return V.none}}return V.set(s)}},{decorations:e=>e.decorations}),qm=J.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Jm=({state:e,dispatch:t})=>{let{selection:n}=e,r=k.create(n.ranges.map(t=>e.wordAt(t.head)||k.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function Ym(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new km(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new km(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Xm=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Jm({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Ym(e,r);return i?(t(e.update({selection:e.selection.addRange(k.range(i.from,i.to),!1),effects:J.scrollIntoView(i.to)})),!0):!1},Zm=A.define({combine(e){return Ln(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Mh(e),scrollToMatch:e=>J.scrollIntoView(e)})}});function Qm(e){return e?[Zm.of(e),Lh]:Lh}var $m=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Im(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
14
14
  `: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 uh(this):new ih(this)}getCursor(e,t=0,n){let r=e.doc?e:P.create({doc:e});return n??=r.doc.length,this.regexp?oh(this,r,t,n):nh(this,r,t,n)}},eh=class{constructor(e){this.spec=e}};function th(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 nh(e,t,n,r){let i;return e.wholeWord&&(i=rh(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=th(e.test,t,i)),new km(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function rh(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(sh(i,n-a))!=N.Word||t(ch(i,n-a))!=N.Word)&&(t(ch(i,r-a))!=N.Word||t(sh(i,r-a))!=N.Word))}var ih=class extends eh{constructor(e){super(e)}nextMatch(e,t,n){let r=nh(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=nh(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=nh(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=nh(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=nh(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 ah(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function oh(e,t,n,r){let i;return e.wholeWord&&(i=lh(t.charCategorizer(t.selection.main.head))),e.test&&(i=ah(e.test,t,i)),new Mm(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function sh(e,t){return e.slice(E(e,t,!1),t)}function ch(e,t){return e.slice(t,E(e,t))}function lh(e){return(t,n,r)=>!r[0].length||(e(sh(r.input,r.index))!=N.Word||e(ch(r.input,r.index))!=N.Word)&&(e(ch(r.input,r.index+r[0].length))!=N.Word||e(sh(r.input,r.index+r[0].length))!=N.Word)}var uh=class extends eh{nextMatch(e,t,n){let r=oh(this.spec,e,n,e.doc.length).next();return r.done&&(r=oh(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=oh(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=oh(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=oh(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)}},dh=j.define(),fh=j.define(),ph=rn.define({create(e){return new mh(Eh(e).create(),null)},update(e,t){for(let n of t.effects)n.is(dh)?e=new mh(n.value.create(),e.panel):n.is(fh)&&(e=new mh(e.query,n.value?Th:null));return e},provide:e=>el.from(e,e=>e.panel)}),mh=class{constructor(e,t){this.query=e,this.panel=t}},hh=V.mark({class:`cm-searchMatch`}),gh=V.mark({class:`cm-searchMatch cm-searchMatch-selected`}),_h=W.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(ph))}update(e){let t=e.state.field(ph);(t!=e.startState.field(ph)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return V.none;let{view:n}=this,r=new Wn;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?gh:hh)})}return r.finish()}},{decorations:e=>e.decorations});function vh(e){return t=>{let n=t.state.field(ph,!1);return n&&n.query.spec.valid?e(t,n):kh(t)}}var yh=vh((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=k.single(r.from,r.to),a=e.state.facet(Zm);return e.dispatch({selection:i,effects:[Fh(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),Oh(e),!0}),bh=vh((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=k.single(i.from,i.to),o=e.state.facet(Zm);return e.dispatch({selection:a,effects:[Fh(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),Oh(e),!0}),xh=vh((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:k.create(n.map(e=>k.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Sh=({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 km(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(k.range(t.value.from,t.value.to))}return t(e.update({selection:k.create(a,o),userEvent:`select.search.matches`})),!0},Ch=vh((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.precise?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(J.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=k.single(o.from,o.to).map(d),u.push(Fh(e,o)),u.push(n.facet(Zm).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),wh=vh((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:J.announce.of(r),userEvent:`input.replace.all`}),!0});function Th(e){return e.state.facet(Zm).createPanel(e)}function Eh(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(Zm);return new $m({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 Dh(e){let t=Xc(e,Th);return t&&t.dom.querySelector(`[main-field]`)}function Oh(e){let t=Dh(e);t&&t==e.root.activeElement&&t.select()}var kh=e=>{let t=e.state.field(ph,!1);if(t&&t.panel){let n=Dh(e);if(n&&n!=e.root.activeElement){let r=Eh(e.state,t.query.spec);r.valid&&e.dispatch({effects:dh.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[fh.of(!0),t?dh.of(Eh(e.state,t.query.spec)):j.appendConfig.of(Lh)]});return!0},Ah=e=>{let t=e.state.field(ph,!1);if(!t||!t.panel)return!1;let n=Xc(e,Th);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:fh.of(!1)}),!0},jh=[{key:`Mod-f`,run:kh,scope:`editor search-panel`},{key:`F3`,run:yh,shift:bh,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:yh,shift:bh,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Ah,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Sh},{key:`Mod-Alt-g`,run:Rm},{key:`Mod-d`,run:Xm,preventDefault:!0}],Mh=class{constructor(e){this.view=e;let t=this.query=e.state.field(ph).query.spec;this.commit=this.commit.bind(this),this.searchField=L(`input`,{value:t.search,placeholder:$(e,`Find`),"aria-label":$(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=L(`input`,{value:t.replace,placeholder:$(e,`Replace`),"aria-label":$(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=L(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=L(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=L(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return L(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=L(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>yh(e),[$(e,`next`)]),n(`prev`,()=>bh(e),[$(e,`previous`)]),n(`select`,()=>xh(e),[$(e,`all`)]),L(`label`,null,[this.caseField,$(e,`match case`)]),L(`label`,null,[this.reField,$(e,`regexp`)]),L(`label`,null,[this.wordField,$(e,`by word`)]),...e.state.readOnly?[]:[L(`br`),this.replaceField,n(`replace`,()=>Ch(e),[$(e,`replace`)]),n(`replaceAll`,()=>wh(e),[$(e,`replace all`)])],L(`button`,{name:`close`,onclick:()=>Ah(e),"aria-label":$(e,`close`),type:`button`},[`×`])])}commit(){let e=new $m({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:dh.of(e)}))}keydown(e){vc(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?bh:yh)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Ch(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(dh)&&!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(Zm).top}};function $(e,t){return e.state.phrase(t)}var Nh=30,Ph=/[\s\.,:;?!]/;function Fh(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-Nh),o=Math.min(i,n+Nh),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Nh;e++)if(!Ph.test(s[e+1])&&Ph.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Nh;e--)if(!Ph.test(s[e-1])&&Ph.test(s[e])){s=s.slice(0,e);break}}return J.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Ih=J.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`}}),Lh=[ph,sn.low(_h),Ih],Rh=J.theme(nf),zh=ed.define([{tag:w.comment,...Z.comment},{tag:w.keyword,...Z.keyword},{tag:[w.atom,w.bool,w.null,w.self],...Z.constant},{tag:w.number,...Z.literal},{tag:[w.string,w.special(w.string),w.character],...Z.string},{tag:w.regexp,...Z.regexp},{tag:w.operator,...Z.operator},{tag:w.punctuation,...Z.punctuation},{tag:w.variableName,...Z.variable},{tag:w.propertyName,...Z.property},{tag:[w.function(w.variableName),w.function(w.propertyName)],...Z.callable},{tag:[w.typeName,w.className,w.namespace],...Z.type},{tag:w.tagName,...Z.tag},{tag:w.attributeName,...Z.attribute},{tag:[w.meta,w.processingInstruction],...Z.meta},{tag:w.heading,...Z.heading},{tag:[w.link,w.url],...Z.link},{tag:w.emphasis,...Z.emphasis},{tag:w.strong,...Z.strong},{tag:w.strikethrough,...Z.strikethrough},{tag:w.invalid,...Z.invalid}]),Bh=[Dl(),jl(),Qu(),Bc(),Nc(),Jc(),yu(),vd(),bf(),Qm({top:!0}),Vm(),hc.of([...Em,...zf,...jh,...Uu,Dm]),id(zh),Rh];function Vh({value:e,path:t,readOnly:n=!1,lineWrapping:i=!0,className:a,onChange:o,onSelect:s,"data-testid":l}){let p=(0,d.useRef)(null),m=(0,d.useRef)(null),h=(0,d.useRef)({onChange:o,onSelect:s}),g=(0,d.useRef)({language:new ln,readOnly:new ln,wrapping:new ln});return(0,d.useEffect)(()=>{h.current={onChange:o,onSelect:s}}),(0,d.useEffect)(()=>{let t=p.current;if(t===null)return;let{language:n,readOnly:r,wrapping:i}=g.current,a=new J({parent:t,state:P.create({doc:e,extensions:[...Bh,n.of([]),r.of([]),i.of([]),J.updateListener.of(e=>{if(e.docChanged&&h.current.onChange?.(e.state.doc.toString()),!e.selectionSet&&!e.docChanged)return;let t=h.current.onSelect;if(t===void 0)return;let n=e.state.selection.main;t({text:e.state.sliceDoc(n.from,n.to),startLine:e.state.doc.lineAt(n.from).number,endLine:e.state.doc.lineAt(n.to).number})})]})});return m.current=a,()=>{a.destroy(),m.current=null}},[]),(0,d.useEffect)(()=>{let t=m.current;t!==null&&t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},[e]),(0,d.useEffect)(()=>{m.current?.dispatch({effects:g.current.readOnly.reconfigure([P.readOnly.of(n),J.editable.of(!n)])})},[n]),(0,d.useEffect)(()=>{m.current?.dispatch({effects:g.current.wrapping.reconfigure(i?J.lineWrapping:[])})},[i]),(0,d.useEffect)(()=>{let e=t===void 0?void 0:c(t),{language:n}=g.current;if(e===void 0){m.current?.dispatch({effects:n.reconfigure([])});return}let r=!1;return u(e).then(e=>{r||m.current?.dispatch({effects:n.reconfigure(e)})}).catch(()=>{r||m.current?.dispatch({effects:n.reconfigure([])})}),()=>{r=!0}},[t]),(0,f.jsx)(`div`,{ref:p,"data-testid":l,className:r(`min-h-0 overflow-hidden`,a)})}export{Lu as $,Au as A,Ql as B,Iu as C,Vh as CodeEditorView,te as Ct,Uu as D,x as Dt,Su as E,Ce as Et,nu as F,Sd as G,$l as H,ad as I,Bl as J,Pl as K,au as L,Mu as M,zl as N,xu as O,Te as Ot,eu as P,Bu as Q,yu as R,zu as S,g as St,Qu as T,xe as Tt,Yl as U,tu as V,Ml as W,Rl as X,X as Y,Hu as Z,cd as _,Be as _t,Y as a,Sn as at,Ll as b,p as bt,Ul as c,A as ct,du as d,Rn as dt,Ou as et,Zd as f,j as ft,_u as g,tr as gt,Ku as h,M as ht,Il as i,hc as it,Tu as j,bu as k,Ad as l,D as lt,yd as m,T as mt,ed as n,J as nt,Zl as o,k as ot,vd as p,rn as pt,id as q,iu as r,Nr as rt,Xl as s,P as st,Vl as t,V as tt,Ed as u,sn as ut,Nl as v,Ge as vt,Du as w,v as wt,gu as x,b as xt,mu as y,w as yt,ru as z};
15
- //# sourceMappingURL=CodeEditorView-LG_3Cg99.js.map
15
+ //# sourceMappingURL=CodeEditorView-CJoceEgU.js.map