i.bottom)&&T==i.bottom-h.bottom>h.top-i.top&&(T=this.above[a]=!T);let S=(T?h.top-i.top:i.bottom-h.bottom)-u;if(SX&&j.topx&&(x=T?j.top-p-2-u:j.bottom+u+2);if(this.position=="absolute"?(c.style.top=(x-O.parent.top)/n+"px",gf(c,(X-O.parent.left)/r)):(c.style.top=x/n+"px",gf(c,X/r)),Q){let j=h.left+(g?m.x:-m.x)-(X+14-7);Q.style.left=j/r+"px"}l.overlap!==!0&&s.push({left:X,top:x,right:w,bottom:x+p}),c.classList.toggle("cm-tooltip-above",T),c.classList.toggle("cm-tooltip-below",!T),l.positioned&&l.positioned(O.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let O of this.manager.tooltipViews)O.dom.style.top=Yi}},{eventObservers:{scroll(){this.maybeMeasure()}}});function gf(O,e){let t=parseInt(O.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(O.style.left=e+"px")}var RS=b.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),_S={x:0,y:0},Hi=Y.define({enables:[ao,RS]}),yn=Y.define({combine:O=>O.reduce((e,t)=>e.concat(t),[])}),bn=class O{static create(e){return new O(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Tn(e,yn,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},VS=Hi.compute([yn],O=>{let e=O.facet(yn);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:bn.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Fa=class{constructor(e,t,i,r,n){this.view=e,this.source=t,this.field=i,this.setHover=r,this.hoverTime=n,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),l=o&&o.dir==ee.RTL?-1:1;n=t.x{this.pending==a&&(this.pending=null,o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])}))},o=>Te(e.state,o,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let e=this.view.plugin(ao),t=e?e.manager.tooltips.findIndex(i=>i.create==bn.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:n}=this;if(r.length&&n&&!qS(n.dom,e)||this.pending){let{pos:s}=r[0]||this.pending,a=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:s;(s==a?this.view.posAtCoords(this.lastMove)!=s:!zS(this.view,s,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},nn=4;function qS(O,e){let{left:t,right:i,top:r,bottom:n}=O.getBoundingClientRect(),s;if(s=O.querySelector(".cm-tooltip-arrow")){let a=s.getBoundingClientRect();r=Math.min(a.top,r),n=Math.max(a.bottom,n)}return e.clientX>=t-nn&&e.clientX<=i+nn&&e.clientY>=r-nn&&e.clientY<=n+nn}function zS(O,e,t,i,r,n){let s=O.scrollDOM.getBoundingClientRect(),a=O.documentTop+O.documentPadding.top+O.contentHeight;if(s.left>i||s.rightr||Math.min(s.bottom,a)=e&&o<=t}function Zd(O,e={}){let t=V.define(),i=he.define({create(){return[]},update(r,n){if(r.length&&(e.hideOnChange&&(n.docChanged||n.selection)?r=[]:e.hideOn&&(r=r.filter(s=>!e.hideOn(n,s))),n.docChanged)){let s=[];for(let a of r){let o=n.changes.mapPos(a.pos,-1,pe.TrackDel);if(o!=null){let l=Object.assign(Object.create(null),a);l.pos=o,l.end!=null&&(l.end=n.changes.mapPos(l.end)),s.push(l)}}r=s}for(let s of n.effects)s.is(t)&&(r=s.value),s.is(WS)&&(r=[]);return r},provide:r=>yn.from(r)});return{active:i,extension:[i,fe.define(r=>new Fa(r,O,i,t,e.hoverTime||300)),VS]}}function oo(O,e){let t=O.plugin(ao);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}var WS=V.define();var Pf=Y.define({combine(O){let e,t;for(let i of O)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function SO(O,e){let t=O.plugin(Rd),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}var Rd=fe.fromClass(class{constructor(O){this.input=O.state.facet(PO),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(O));let e=O.state.facet(Pf);this.top=new KO(O,!0,e.topContainer),this.bottom=new KO(O,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(O){let e=O.state.facet(Pf);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new KO(O.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new KO(O.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=O.state.facet(PO);if(t!=this.input){let i=t.filter(o=>o),r=[],n=[],s=[],a=[];for(let o of i){let l=this.specs.indexOf(o),c;l<0?(c=o(O.view),a.push(c)):(c=this.panels[l],c.update&&c.update(O)),r.push(c),(c.top?n:s).push(c)}this.specs=i,this.panels=r,this.top.sync(n),this.bottom.sync(s);for(let o of a)o.dom.classList.add("cm-panel"),o.mount&&o.mount()}else for(let i of this.panels)i.update&&i.update(O)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:O=>b.scrollMargins.of(e=>{let t=e.plugin(O);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),KO=class{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Sf(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Sf(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function Sf(O){let e=O.nextSibling;return O.remove(),e}var PO=Y.define({enables:Rd});var Be=class extends ot{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Be.prototype.elementClass="";Be.prototype.toDOM=void 0;Be.prototype.mapMode=pe.TrackBefore;Be.prototype.startSide=Be.prototype.endSide=-1;Be.prototype.point=!0;var fn=Y.define(),US=Y.define(),jS={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>F.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},ji=Y.define();function lo(O){return[_d(),ji.of({...jS,...O})]}var Ha=Y.define({combine:O=>O.some(e=>e)});function _d(O){let e=[CS];return O&&O.fixed===!1&&e.push(Ha.of(!0)),e}var CS=fe.fromClass(class{constructor(O){this.view=O,this.domAfter=null,this.prevViewport=O.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=O.state.facet(ji).map(e=>new xn(O,e)),this.fixed=!O.state.facet(Ha);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),O.scrollDOM.insertBefore(this.dom,O.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(O){if(this.updateGutters(O)){let e=this.prevViewport,t=O.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(O.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Ha)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=O.view.viewport}syncGutters(O){let e=this.dom.nextSibling;O&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=F.iter(this.view.state.facet(fn),this.view.viewport.from),i=[],r=this.gutters.map(n=>new Ja(n,this.view.viewport,-this.view.documentPadding.top));for(let n of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(n.type)){let s=!0;for(let a of n.type)if(a.type==Re.Text&&s){Ka(t,i,a.from);for(let o of r)o.line(this.view,a,i);s=!1}else if(a.widget)for(let o of r)o.widget(this.view,a)}else if(n.type==Re.Text){Ka(t,i,n.from);for(let s of r)s.line(this.view,n,i)}else if(n.widget)for(let s of r)s.widget(this.view,n);for(let n of r)n.finish();O&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(O){let e=O.startState.facet(ji),t=O.state.facet(ji),i=O.docChanged||O.heightChanged||O.viewportChanged||!F.eq(O.startState.facet(fn),O.state.facet(fn),O.view.viewport.from,O.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(O)&&(i=!0);else{i=!0;let r=[];for(let n of t){let s=e.indexOf(n);s<0?r.push(new xn(this.view,n)):(this.gutters[s].update(O),r.push(this.gutters[s]))}for(let n of this.gutters)n.dom.remove(),r.indexOf(n)<0&&n.destroy();for(let n of r)n.config.side=="after"?this.getDOMAfter().appendChild(n.dom):this.dom.appendChild(n.dom);this.gutters=r}return i}destroy(){for(let O of this.gutters)O.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:O=>b.scrollMargins.of(e=>{let t=e.plugin(O);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==ee.LTR?{left:i,right:r}:{right:i,left:r}})});function Xf(O){return Array.isArray(O)?O:[O]}function Ka(O,e,t){for(;O.value&&O.from<=t;)O.from==t&&e.push(O.value),O.next()}var Ja=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=F.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,n=(t.top-this.height)/e.scaleY,s=t.height/e.scaleY;if(this.i==r.elements.length){let a=new wn(e,s,n,i);r.elements.push(a),r.dom.appendChild(a.dom)}else r.elements[this.i].update(e,s,n,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Ka(this.cursor,r,t.from),i.length&&(r=r.concat(i));let n=this.gutter.config.lineMarker(e,t,r);n&&r.unshift(n);let s=this.gutter;r.length==0&&!s.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),r=i?[i]:null;for(let n of e.state.facet(US)){let s=n(e,t.widget,t);s&&(r||(r=[])).push(s)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},xn=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let n=r.target,s;if(n!=this.dom&&this.dom.contains(n)){for(;n.parentNode!=this.dom;)n=n.parentNode;let o=n.getBoundingClientRect();s=(o.top+o.bottom)/2}else s=r.clientY;let a=e.lineBlockAtHeight(s-e.documentTop);t.domEventHandlers[i](e,a,r)&&r.preventDefault()});this.markers=Xf(t.markers(e)),t.initialSpacer&&(this.spacer=new wn(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Xf(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!F.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},wn=class{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),GS(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let n=0,s=0;;){let a=s,o=nn(a,o,l)||s(a,o,l):s}return i}})}}),Ci=class extends Be{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function fa(O,e){return O.state.facet(JO).formatNumber(e,O.state)}var LS=ji.compute([JO],O=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(ES)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new Ci(fa(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let r of e.state.facet(AS)){let n=r(e,t,i);if(n)return n}return null},lineMarkerChange:e=>e.startState.facet(JO)!=e.state.facet(JO),initialSpacer(e){return new Ci(fa(e,Tf(e.state.doc.lines)))},updateSpacer(e,t){let i=fa(t.view,Tf(t.view.state.doc.lines));return i==e.number?e:new Ci(i)},domEventHandlers:O.facet(JO).domEventHandlers,side:"before"}));function Vd(O={}){return[JO.of(O),_d(),LS]}function Tf(O){let e=9;for(;e{let e=[],t=-1;for(let i of O.selection.ranges){let r=O.doc.lineAt(i.head).from;r>t&&(t=r,e.push(MS.range(r)))}return F.of(e)});function qd(){return DS}var IS=0,Ue=class{constructor(e,t){this.from=e,this.to=t}},_=class{constructor(e={}){this.id=IS++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=de.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};_.closedBy=new _({deserialize:O=>O.split(" ")});_.openedBy=new _({deserialize:O=>O.split(" ")});_.group=new _({deserialize:O=>O.split(" ")});_.isolate=new _({deserialize:O=>{if(O&&O!="rtl"&&O!="ltr"&&O!="auto")throw new RangeError("Invalid value for isolate: "+O);return O||"auto"}});_.contextHash=new _({perNode:!0});_.lookAhead=new _({perNode:!0});_.mounted=new _({perNode:!0});var XO=class{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[_.mounted.id]}},BS=Object.create(null),de=class O{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):BS,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new O(e.name||"",t,e.id,i);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(r)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}}return r}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(_.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(_.group),n=-1;n<(r?r.length:0);n++){let s=t[n<0?i.name:r[n]];if(s)return s}}}};de.none=new de("",Object.create(null),0,8);var Ht=class O{constructor(e){this.types=e;for(let t=0;t0;for(let o=this.cursor(s|A.IncludeAnonymous);;){let l=!1;if(o.from<=n&&o.to>=r&&(!a&&o.type.isAnonymous||t(o)!==!1)){if(o.firstChild())continue;l=!0}for(;l&&i&&(a||!o.type.isAnonymous)&&i(o),!o.nextSibling();){if(!o.parent())return;l=!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(e={}){return this.children.length<=8?this:So(de.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new O(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new O(de.none,t,i,r)))}static build(e){return FS(e)}};D.empty=new D(de.none,[],[],0);var co=class O{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 O(this.buffer,this.index)}},Kt=class O{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return de.none}toString(){let e=[];for(let t=0;t0));o=s[o+3]);return a}slice(e,t,i){let r=this.buffer,n=new Uint16Array(t-e),s=0;for(let a=e,o=0;a=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Ki(O,e,t,i){for(var r;O.from==O.to||(t<1?O.from>=e:O.from>e)||(t>-1?O.to<=e:O.to0?a.length:-1;e!=l;e+=t){let c=a[e],h=o[e]+s.from;if(Ad(r,i,h,h+c.length)){if(c instanceof Kt){if(n&A.ExcludeBuffers)continue;let f=c.findChild(0,c.buffer.length,t,i-h,r);if(f>-1)return new TO(new fo(s,c,e,h),null,f)}else if(n&A.IncludeAnonymous||!c.type.isAnonymous||Po(c)){let f;if(!(n&A.IgnoreMounts)&&(f=XO.get(c))&&!f.overlay)return new O(f.tree,h,e,s);let Q=new O(c,h,e,s);return n&A.IncludeAnonymous||!Q.type.isAnonymous?Q:Q.nextChild(t<0?c.children.length-1:0,t,i,r)}}}if(n&A.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+t:e=t<0?-1:s._parent._tree.children.length,s=s._parent,!s))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)}enter(e,t,i=0){let r;if(!(i&A.IgnoreOverlays)&&(r=XO.get(this._tree))&&r.overlay){let n=e-this.from;for(let{from:s,to:a}of r.overlay)if((t>0?s<=n:s=n:a>n))return new O(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}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 Wd(O,e,t,i){let r=O.cursor(),n=[];if(!r.firstChild())return n;if(t!=null){for(let s=!1;!s;)if(s=r.type.is(t),!r.nextSibling())return n}for(;;){if(i!=null&&r.type.is(i))return n;if(r.type.is(e)&&n.push(r.node),!r.nextSibling())return i==null?n:[]}}function ho(O,e,t=e.length-1){for(let i=O;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var fo=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},TO=class O extends Vn{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,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return n<0?null:new O(this.context,this,n)}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)}enter(e,t,i=0){if(i&A.ExcludeBuffers)return null;let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return n<0?null:new O(this.context,this,n)}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:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new O(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new O(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,n=i.buffer[this.index+3];if(n>r){let s=i.buffer[this.index+1];e.push(i.slice(r,n,s)),t.push(0)}return new D(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Ld(O){if(!O.length)return null;let e=0,t=O[0];for(let n=1;nt.from||s.to=e){let a=new je(s.tree,s.overlay[0].from+n.from,-1,n);(r||(r=[i])).push(Ki(a,e,t,!1))}}return r?Ld(r):i}var Oi=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof je)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.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:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof je?(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,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,n=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return n<0?!1:(this.stack.push(this.index),this.yieldBuf(n))}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,i=this.mode){return this.buffer?i&A.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&A.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&A.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,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let n=t+e,s=e<0?-1:i._tree.children.length;n!=s;n+=e){let a=i._tree.children[n];if(this.mode&A.IncludeAnonymous||a instanceof Kt||!a.type.isAnonymous||Po(a))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=0;){for(let s=e;s;s=s._parent)if(s.index==r){if(r==this.index)return s;t=s,i=n+1;break e}r=this.stack[--n]}for(let r=i;r=0;n--){if(n<0)return ho(this._tree,e,r);let s=i[t.buffer[this.stack[n]]];if(!s.isAnonymous){if(e[r]&&e[r]!=s.name)return!1;r--}}return!0}};function Po(O){return O.children.some(e=>e instanceof Kt||!e.type.isAnonymous||Po(e))}function FS(O){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:n=[],minRepeatType:s=i.types.length}=O,a=Array.isArray(t)?new co(t,t.length):t,o=i.types,l=0,c=0;function h(S,x,w,j,E,ie){let{id:C,start:q,end:H,size:I}=a,ae=c,ke=l;for(;I<0;)if(a.next(),I==-1){let vt=n[C];w.push(vt),j.push(q-S);return}else if(I==-3){l=C;return}else if(I==-4){c=C;return}else throw new RangeError(`Unrecognized record size: ${I}`);let Ae=o[C],Qt,Pe,et=q-S;if(H-q<=r&&(Pe=p(a.pos-x,E))){let vt=new Uint16Array(Pe.size-Pe.skip),tt=a.pos-Pe.size,ut=vt.length;for(;a.pos>tt;)ut=m(Pe.start,vt,ut);Qt=new Kt(vt,H-Pe.start,i),et=Pe.start-S}else{let vt=a.pos-I;a.next();let tt=[],ut=[],hO=C>=s?C:-1,GO=0,Wr=H;for(;a.pos>vt;)hO>=0&&a.id==hO&&a.size>=0?(a.end<=Wr-r&&(u(tt,ut,q,GO,a.end,Wr,hO,ae,ke),GO=tt.length,Wr=a.end),a.next()):ie>2500?f(q,vt,tt,ut):h(q,vt,tt,ut,hO,ie+1);if(hO>=0&&GO>0&&GO-1&&GO>0){let sh=Q(Ae,ke);Qt=So(Ae,tt,ut,0,tt.length,0,H-q,sh,sh)}else Qt=$(Ae,tt,ut,H-q,ae-H,ke)}w.push(Qt),j.push(et)}function f(S,x,w,j){let E=[],ie=0,C=-1;for(;a.pos>x;){let{id:q,start:H,end:I,size:ae}=a;if(ae>4)a.next();else{if(C>-1&&H=0;I-=3)q[ae++]=E[I],q[ae++]=E[I+1]-H,q[ae++]=E[I+2]-H,q[ae++]=ae;w.push(new Kt(q,E[2]-H,i)),j.push(H-S)}}function Q(S,x){return(w,j,E)=>{let ie=0,C=w.length-1,q,H;if(C>=0&&(q=w[C])instanceof D){if(!C&&q.type==S&&q.length==E)return q;(H=q.prop(_.lookAhead))&&(ie=j[C]+q.length+H)}return $(S,w,j,E,ie,x)}}function u(S,x,w,j,E,ie,C,q,H){let I=[],ae=[];for(;S.length>j;)I.push(S.pop()),ae.push(x.pop()+w-E);S.push($(i.types[C],I,ae,ie-E,q-ie,H)),x.push(E-w)}function $(S,x,w,j,E,ie,C){if(ie){let q=[_.contextHash,ie];C=C?[q].concat(C):[q]}if(E>25){let q=[_.lookAhead,E];C=C?[q].concat(C):[q]}return new D(S,x,w,j,C)}function p(S,x){let w=a.fork(),j=0,E=0,ie=0,C=w.end-r,q={size:0,start:0,skip:0};e:for(let H=w.pos-S;w.pos>H;){let I=w.size;if(w.id==x&&I>=0){q.size=j,q.start=E,q.skip=ie,ie+=4,j+=4,w.next();continue}let ae=w.pos-I;if(I<0||ae=s?4:0,Ae=w.start;for(w.next();w.pos>ae;){if(w.size<0)if(w.size==-3)ke+=4;else break e;else w.id>=s&&(ke+=4);w.next()}E=Ae,j+=I,ie+=ke}return(x<0||j==S)&&(q.size=j,q.start=E,q.skip=ie),q.size>4?q:void 0}function m(S,x,w){let{id:j,start:E,end:ie,size:C}=a;if(a.next(),C>=0&&j4){let H=a.pos-(C-4);for(;a.pos>H;)w=m(S,x,w)}x[--w]=q,x[--w]=ie-S,x[--w]=E-S,x[--w]=j}else C==-3?l=j:C==-4&&(c=j);return w}let g=[],X=[];for(;a.pos>0;)h(O.start||0,O.bufferStart||0,g,X,-1,0);let T=(e=O.length)!==null&&e!==void 0?e:g.length?X[0]+g[0].length:0;return new D(o[O.topID],g.reverse(),X.reverse(),T)}var Ud=new WeakMap;function _n(O,e){if(!O.isAnonymous||e instanceof Kt||e.type!=O)return 1;let t=Ud.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=O||!(i instanceof D)){t=1;break}t+=_n(O,i)}Ud.set(e,t)}return t}function So(O,e,t,i,r,n,s,a,o){let l=0;for(let u=i;u=c)break;x+=w}if(X==T+1){if(x>c){let w=u[T];Q(w.children,w.positions,0,w.children.length,$[T]+g);continue}h.push(u[T])}else{let w=$[X-1]+u[X-1].length-S;h.push(So(O,u,$,T,X,S,w,null,o))}f.push(S+g-n)}}return Q(e,t,i,r,0),(a||o)(h,f,s)}var Tt=class{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof TO?this.setBuffer(e.context.buffer,e.index,t):e instanceof je&&this.map.set(e.tree,t)}get(e){return e instanceof TO?this.getBuffer(e.context.buffer,e.index):e instanceof je?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)}},Vt=class O{constructor(e,t,i,r,n=!1,s=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(n?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new O(0,e.length,e,0,!1,i)];for(let n of t)n.to>e.length&&r.push(n);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],n=1,s=e.length?e[0]:null;for(let a=0,o=0,l=0;;a++){let c=a=i)for(;s&&s.from=f.from||h<=f.to||l){let Q=Math.max(f.from,o)-l,u=Math.min(f.to,h)-l;f=Q>=u?null:new O(Q,u,f.tree,f.offset+l,a>0,!!c)}if(f&&r.push(f),s.to>h)break;s=nnew Ue(r.from,r.to)):[new Ue(0,0)]:[new Ue(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let n=r.advance();if(n)return n}}},uo=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 yO(O){return(e,t,i,r)=>new mo(e,O,t,i,r)}var qn=class{constructor(e,t,i,r,n){this.parser=e,this.parse=t,this.overlay=i,this.target=r,this.from=n}};function jd(O){if(!O.length||O.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(O))}var $o=class{constructor(e,t,i,r,n,s,a){this.parser=e,this.predicate=t,this.mounts=i,this.index=r,this.start=n,this.target=s,this.prev=a,this.depth=0,this.ranges=[]}},po=new _({perNode:!0}),mo=class{constructor(e,t,i,r,n){this.nest=t,this.input=i,this.fragments=r,this.ranges=n,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new D(i.type,i.children,i.positions,i.length,i.propValues.concat([[po,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[_.mounted.id]=new XO(t,e.overlay,e.parser),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t=this.stoppedAt)a=!1;else if(e.hasNode(r)){if(t){let l=t.mounts.find(c=>c.frag.from<=r.from&&c.frag.to>=r.to&&c.mount.overlay);if(l)for(let c of l.mount.overlay){let h=c.from+l.pos,f=c.to+l.pos;h>=r.from&&f<=r.to&&!t.ranges.some(Q=>Q.fromh)&&t.ranges.push({from:h,to:f})}}a=!1}else if(i&&(s=HS(i.ranges,r.from,r.to)))a=s!=2;else if(!r.type.isAnonymous&&(n=this.nest(r,this.input))&&(r.fromnew Ue(h.from-r.from,h.to-r.from)):null,r.tree,c.length?c[0].from:r.from)),n.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):a=!1}}else if(t&&(o=t.predicate(r))&&(o===!0&&(o=new Ue(r.from,r.to)),o.from=0&&t.ranges[l].to==o.from?t.ranges[l]={from:t.ranges[l].from,to:o.to}:t.ranges.push(o)}if(a&&r.firstChild())t&&t.depth++,i&&i.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(t&&!--t.depth){let l=Gd(this.ranges,t.ranges);l.length&&(jd(l),this.inner.splice(t.index,0,new qn(t.parser,t.parser.startParse(this.input,Ed(t.mounts,l),l),t.ranges.map(c=>new Ue(c.from-t.start,c.to-t.start)),t.target,l[0].from))),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}};function HS(O,e,t){for(let i of O){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function Cd(O,e,t,i,r,n){if(e=e&&t.enter(i,1,A.IgnoreOverlays|A.ExcludeBuffers)||t.next(!1)||(this.done=!0)}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 D)t=t.children[0];else break}return!1}},go=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(t=i.tree.prop(po))!==null&&t!==void 0?t:i.to,this.inner=new zn(i.tree,-i.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(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(po))!==null&&e!==void 0?e:t.to,this.inner=new zn(t.tree,-t.offset)}}findMounts(e,t){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let n=this.inner.cursor.node;n;n=n.parent){let s=(i=n.tree)===null||i===void 0?void 0:i.prop(_.mounted);if(s&&s.parser==t)for(let a=this.fragI;a=n.to)break;o.tree==this.curFrag.tree&&r.push({frag:o,pos:n.from-o.offset,mount:s})}}}return r}};function Gd(O,e){let t=null,i=e;for(let r=1,n=0;r=a)break;o.to<=s||(t||(i=t=e.slice()),o.froma&&t.splice(n+1,0,new Ue(a,o.to))):o.to>a?t[n--]=new Ue(a,o.to):t.splice(n--,1))}}return i}function JS(O,e,t,i){let r=0,n=0,s=!1,a=!1,o=-1e9,l=[];for(;;){let c=r==O.length?1e9:s?O[r].to:O[r].from,h=n==e.length?1e9:a?e[n].to:e[n].from;if(s!=a){let f=Math.max(o,t),Q=Math.min(c,h,i);fnew Ue(f.from+i,f.to+i)),h=JS(e,c,o,l);for(let f=0,Q=o;;f++){let u=f==h.length,$=u?l:h[f].from;if($>Q&&t.push(new Vt(Q,$,r.tree,-s,n.from>=Q||n.openStart,n.to<=$||n.openEnd)),u)break;Q=h[f].to}}else t.push(new Vt(o,l,r.tree,-s,n.from>=s||n.openStart,n.to<=a||n.openEnd))}return t}var eX=0,Ne=class O{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=eX++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof O&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new O(i,[],null,[]);if(r.set.push(r),t)for(let n of t.set)r.set.push(n);return r}static defineModifier(e){let t=new Cn(e);return i=>i.modified.indexOf(t)>-1?i:Cn.get(i.base||i,i.modified.concat(t).sort((r,n)=>r.id-n.id))}},tX=0,Cn=class O{constructor(e){this.name=e,this.instances=[],this.id=tX++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(a=>a.base==e&&OX(t,a.modified));if(i)return i;let r=[],n=new Ne(e.name,r,e,t);for(let a of t)a.instances.push(n);let s=iX(t);for(let a of e.set)if(!a.modified.length)for(let o of s)r.push(O.get(a,o));return n}};function OX(O,e){return O.length==e.length&&O.every((t,i)=>t==e[i])}function iX(O){let e=[[]];for(let t=0;ti.length-t.length)}function N(O){let e=Object.create(null);for(let t in O){let i=O[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let n=[],s=2,a=r;for(let h=0;;){if(a=="..."&&h>0&&h+3==r.length){s=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+r);if(n.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),h+=f[0].length,h==r.length)break;let Q=r[h++];if(h==r.length&&Q=="!"){s=0;break}if(Q!="/")throw new RangeError("Invalid path: "+r);a=r.slice(h)}let o=n.length-1,l=n[o];if(!l)throw new RangeError("Invalid path: "+r);let c=new ii(i,s,o>0?n.slice(0,o):null);e[l]=c.sort(e[l])}}return Id.add(e)}var Id=new _,ii=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let s=r;for(let a of n)for(let o of a.set){let l=t[o.id];if(l){s=s?s+" "+l:l;break}}return s},scope:i}}function rX(O,e){let t=null;for(let i of O){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function Bd(O,e,t,i=0,r=O.length){let n=new To(i,Array.isArray(e)?e:[e],t);n.highlightRange(O.cursor(),i,r,"",n.highlighters),n.flush(r)}var To=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,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,i,r,n){let{type:s,from:a,to:o}=e;if(a>=i||o<=t)return;s.isTop&&(n=this.highlighters.filter(Q=>!Q.scope||Q.scope(s)));let l=r,c=nX(e)||ii.empty,h=rX(n,c.tags);if(h&&(l&&(l+=" "),l+=h,c.mode==1&&(r+=(r?" ":"")+h)),this.startSpan(Math.max(t,a),l),c.opaque)return;let f=e.tree&&e.tree.prop(_.mounted);if(f&&f.overlay){let Q=e.node.enter(f.overlay[0].from+a,1),u=this.highlighters.filter(p=>!p.scope||p.scope(f.tree.type)),$=e.firstChild();for(let p=0,m=a;;p++){let g=p=X||!e.nextSibling())););if(!g||X>i)break;m=g.to+a,m>t&&(this.highlightRange(Q.cursor(),Math.max(t,g.from+a),Math.min(i,m),"",u),this.startSpan(Math.min(i,m),l))}$&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,n),this.startSpan(Math.min(i,e.to),l)}while(e.nextSibling());e.parent()}}};function nX(O){let e=O.type.prop(Id);for(;e&&e.context&&!O.matchContext(e.context);)e=e.next;return e||null}var k=Ne.define,Wn=k(),eO=k(),Md=k(eO),Dd=k(eO),tO=k(),Un=k(tO),Xo=k(tO),xt=k(),bO=k(xt),yt=k(),bt=k(),yo=k(),Ji=k(yo),jn=k(),d={comment:Wn,lineComment:k(Wn),blockComment:k(Wn),docComment:k(Wn),name:eO,variableName:k(eO),typeName:Md,tagName:k(Md),propertyName:Dd,attributeName:k(Dd),className:k(eO),labelName:k(eO),namespace:k(eO),macroName:k(eO),literal:tO,string:Un,docString:k(Un),character:k(Un),attributeValue:k(Un),number:Xo,integer:k(Xo),float:k(Xo),bool:k(tO),regexp:k(tO),escape:k(tO),color:k(tO),url:k(tO),keyword:yt,self:k(yt),null:k(yt),atom:k(yt),unit:k(yt),modifier:k(yt),operatorKeyword:k(yt),controlKeyword:k(yt),definitionKeyword:k(yt),moduleKeyword:k(yt),operator:bt,derefOperator:k(bt),arithmeticOperator:k(bt),logicOperator:k(bt),bitwiseOperator:k(bt),compareOperator:k(bt),updateOperator:k(bt),definitionOperator:k(bt),typeOperator:k(bt),controlOperator:k(bt),punctuation:yo,separator:k(yo),bracket:Ji,angleBracket:k(Ji),squareBracket:k(Ji),paren:k(Ji),brace:k(Ji),content:xt,heading:bO,heading1:k(bO),heading2:k(bO),heading3:k(bO),heading4:k(bO),heading5:k(bO),heading6:k(bO),contentSeparator:k(xt),list:k(xt),quote:k(xt),emphasis:k(xt),strong:k(xt),link:k(xt),monospace:k(xt),strikethrough:k(xt),inserted:k(),deleted:k(),changed:k(),invalid:k(),meta:jn,documentMeta:k(jn),annotation:k(jn),processingInstruction:k(jn),definition:Ne.defineModifier("definition"),constant:Ne.defineModifier("constant"),function:Ne.defineModifier("function"),standard:Ne.defineModifier("standard"),local:Ne.defineModifier("local"),special:Ne.defineModifier("special")};for(let O in d){let e=d[O];e instanceof Ne&&(e.name=O)}var IZ=bo([{tag:d.link,class:"tok-link"},{tag:d.heading,class:"tok-heading"},{tag:d.emphasis,class:"tok-emphasis"},{tag:d.strong,class:"tok-strong"},{tag:d.keyword,class:"tok-keyword"},{tag:d.atom,class:"tok-atom"},{tag:d.bool,class:"tok-bool"},{tag:d.url,class:"tok-url"},{tag:d.labelName,class:"tok-labelName"},{tag:d.inserted,class:"tok-inserted"},{tag:d.deleted,class:"tok-deleted"},{tag:d.literal,class:"tok-literal"},{tag:d.string,class:"tok-string"},{tag:d.number,class:"tok-number"},{tag:[d.regexp,d.escape,d.special(d.string)],class:"tok-string2"},{tag:d.variableName,class:"tok-variableName"},{tag:d.local(d.variableName),class:"tok-variableName tok-local"},{tag:d.definition(d.variableName),class:"tok-variableName tok-definition"},{tag:d.special(d.variableName),class:"tok-variableName2"},{tag:d.definition(d.propertyName),class:"tok-propertyName tok-definition"},{tag:d.typeName,class:"tok-typeName"},{tag:d.namespace,class:"tok-namespace"},{tag:d.className,class:"tok-className"},{tag:d.macroName,class:"tok-macroName"},{tag:d.propertyName,class:"tok-propertyName"},{tag:d.operator,class:"tok-operator"},{tag:d.comment,class:"tok-comment"},{tag:d.meta,class:"tok-meta"},{tag:d.invalid,class:"tok-invalid"},{tag:d.punctuation,class:"tok-punctuation"}]);var xo,OO=new _;function nr(O){return Y.define({combine:O?e=>e.concat(O):void 0})}var An=new _,_e=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,M.prototype.hasOwnProperty("tree")||Object.defineProperty(M.prototype,"tree",{get(){return W(this)}}),this.parser=t,this.extension=[iO.of(this),M.languageData.of((n,s,a)=>{let o=Nd(n,s,a),l=o.type.prop(OO);if(!l)return[];let c=n.facet(l),h=o.type.prop(An);if(h){let f=o.resolve(s-o.from,a);for(let Q of h)if(Q.test(f,n)){let u=n.facet(Q.facet);return Q.type=="replace"?u:u.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return Nd(e,t,i).type.prop(OO)==this.data}findRegions(e){let t=e.facet(iO);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(n,s)=>{if(n.prop(OO)==this.data){i.push({from:s,to:s+n.length});return}let a=n.prop(_.mounted);if(a){if(a.tree.prop(OO)==this.data){if(a.overlay)for(let o of a.overlay)i.push({from:o.from+s,to:o.to+s});else i.push({from:s,to:s+n.length});return}else if(a.overlay){let o=i.length;if(r(a.tree,a.overlay[0].from+s),i.length>o)return}}for(let o=0;oi.isTop?t:void 0)]}),e.name)}configure(e,t){return new O(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function W(O){let e=O.field(_e.state,!1);return e?e.tree:D.empty}var vo=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},er=null,Or=class O{constructor(e,t,i=[],r,n,s,a,o){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=n,this.viewport=s,this.skipped=a,this.scheduleOn=o,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new O(e,t,[],D.empty,0,i,[],null)}startParse(){return this.parser.startParse(new vo(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=D.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Vt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=er;er=this;try{return e()}finally{er=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Fd(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:n,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let o=[];if(e.iterChangedRanges((l,c,h,f)=>o.push({fromA:l,toA:c,fromB:h,toB:f})),i=Vt.applyChanges(i,o),r=D.empty,n=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let l of this.skipped){let c=e.mapPos(l.from,1),h=e.mapPos(l.to,-1);c