v&&D.topP&&(P=x?D.top-g-2-m:D.bottom+m+2);if(this.position=="absolute"?(c.style.top=(P-i.parent.top)/s+"px",c.style.left=(v-i.parent.left)/r+"px"):(c.style.top=P/s+"px",c.style.left=v/r+"px"),d){let D=f.left+(y?O.x:-O.x)-(v+14-7);d.style.left=D/r+"px"}h.overlap!==!0&&o.push({left:v,top:P,right:C,bottom:P+g}),c.classList.toggle("cm-tooltip-above",x),c.classList.toggle("cm-tooltip-below",!x),h.positioned&&h.positioned(i.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 i of this.manager.tooltipViews)i.dom.style.top=Hn}},{eventObservers:{scroll(){this.maybeMeasure()}}}),zb=E.baseTheme({".cm-tooltip":{zIndex:100,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:`${7*2}px`,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"}}}),Ub={x:0,y:0},gr=A.define({enables:[kh,zb]}),ao=A.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])}),lo=class i{static create(e){return new i(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new oo(e,ao,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}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 n of this.manager.tooltipViews){let r=n[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")}},Fb=gr.compute([ao],i=>{let e=i.facet(ao);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:lo.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),ph=class{constructor(e,t,n,r,s){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=s,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 l=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),h=l&&l.dir==H.RTL?-1:1;s=t.x{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>we(e.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(kh),t=e?e.manager.tooltips.findIndex(n=>n.create==lo.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;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:s}=this;if(r.length&&s&&!Hb(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,a=(n=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!Gb(this.view,o,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:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.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)}},Ns=4;function Hb(i,e){let t=i.getBoundingClientRect();return e.clientX>=t.left-Ns&&e.clientX<=t.right+Ns&&e.clientY>=t.top-Ns&&e.clientY<=t.bottom+Ns}function Gb(i,e,t,n,r,s){let o=i.scrollDOM.getBoundingClientRect(),a=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.rightr||Math.min(o.bottom,a)=e&&l<=t}function vp(i,e={}){let t=_.define(),n=te.define({create(){return[]},update(r,s){if(r.length&&(e.hideOnChange&&(s.docChanged||s.selection)?r=[]:e.hideOn&&(r=r.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let a of r){let l=s.changes.mapPos(a.pos,-1,ge.TrackDel);if(l!=null){let h=Object.assign(Object.create(null),a);h.pos=l,h.end!=null&&(h.end=s.changes.mapPos(h.end)),o.push(h)}}r=o}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(Yb)&&(r=[]);return r},provide:r=>ao.from(r)});return[n,re.define(r=>new ph(r,i,n,t,e.hoverTime||300)),Fb]}function Sh(i,e){let t=i.plugin(kh);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}var Yb=_.define();var ad=A.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Pi(i,e){let t=i.plugin(xp),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}var xp=re.fromClass(class{constructor(i){this.input=i.state.facet(Ti),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(ad);this.top=new sn(i,!0,e.topContainer),this.bottom=new sn(i,!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(i){let e=i.state.facet(ad);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new sn(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new sn(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Ti);if(t!=this.input){let n=t.filter(l=>l),r=[],s=[],o=[],a=[];for(let l of n){let h=this.specs.indexOf(l),c;h<0?(c=l(i.view),a.push(c)):(c=this.panels[h],c.update&&c.update(i)),r.push(c),(c.top?s:o).push(c)}this.specs=n,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>E.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),sn=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,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=ld(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=ld(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 ld(i){let e=i.nextSibling;return i.remove(),e}var Ti=A.define({enables:xp}),ze=class extends at{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};ze.prototype.elementClass="";ze.prototype.toDOM=void 0;ze.prototype.mapMode=ge.TrackBefore;ze.prototype.startSide=ze.prototype.endSide=-1;ze.prototype.point=!0;var Gs=A.define(),Zb={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>j.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},sr=A.define();function Th(i){return[kp(),sr.of(Object.assign(Object.assign({},Zb),i))]}var mh=A.define({combine:i=>i.some(e=>e)});function kp(i){let e=[Jb];return i&&i.fixed===!1&&e.push(mh.of(!0)),e}var Jb=re.fromClass(class{constructor(i){this.view=i,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(sr).map(e=>new ho(i,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!i.state.facet(mh),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}i.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(mh)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&this.dom.remove();let t=j.iter(this.view.state.facet(Gs),this.view.viewport.from),n=[],r=this.gutters.map(s=>new Oh(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==_e.Text&&o){gh(t,n,a.from);for(let l of r)l.line(this.view,a,n);o=!1}else if(a.widget)for(let l of r)l.widget(this.view,a)}else if(s.type==_e.Text){gh(t,n,s.from);for(let o of r)o.line(this.view,s,n)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();i&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(i){let e=i.startState.facet(sr),t=i.state.facet(sr),n=i.docChanged||i.heightChanged||i.viewportChanged||!j.eq(i.startState.facet(Gs),i.state.facet(Gs),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(i)&&(n=!0);else{n=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new ho(this.view,s)):(this.gutters[o].update(i),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove()}},{provide:i=>E.scrollMargins.of(e=>{let t=e.plugin(i);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==H.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function hd(i){return Array.isArray(i)?i:[i]}function gh(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}var Oh=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=j.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let a=new co(e,o,s,n);r.elements.push(a),r.dom.appendChild(a.dom)}else r.elements[this.i].update(e,o,s,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];gh(this.cursor,r,t.from),n.length&&(r=r.concat(n));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t);n&&this.addElement(e,t,[n])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},ho=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 n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=r.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,a,r)&&r.preventDefault()});this.markers=hd(t.markers(e)),t.initialSpacer&&(this.spacer=new co(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=hd(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 n=e.view.viewport;return!j.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},co=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),Kb(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let a=o,l=ss(a,l,h)||o(a,l,h):o}return n}})}}),or=class extends ze{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Rl(i,e){return i.state.facet(on).formatNumber(e,i.state)}var tw=sr.compute([on],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(ew)},lineMarker(e,t,n){return n.some(r=>r.toDOM)?null:new or(Rl(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(on)!=e.state.facet(on),initialSpacer(e){return new or(Rl(e,cd(e.state.doc.lines)))},updateSpacer(e,t){let n=Rl(t.view,cd(t.view.state.doc.lines));return n==e.number?e:new or(n)},domEventHandlers:i.facet(on).domEventHandlers}));function Sp(i={}){return[on.of(i),kp(),tw]}function cd(i){let e=9;for(;e{let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.head).from;r>t&&(t=r,e.push(iw.range(r)))}return j.of(e)});function Tp(){return nw}var rw=0,Or=class{constructor(e,t){this.from=e,this.to=t}},$=class{constructor(e={}){this.id=rw++,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=Pe.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};$.closedBy=new $({deserialize:i=>i.split(" ")});$.openedBy=new $({deserialize:i=>i.split(" ")});$.group=new $({deserialize:i=>i.split(" ")});$.isolate=new $({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});$.contextHash=new $({perNode:!0});$.lookAhead=new $({perNode:!0});$.mounted=new $({perNode:!0});var ln=class{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[$.mounted.id]}},sw=Object.create(null),Pe=class i{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):sw,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new i(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[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 n in e)for(let r of n.split(" "))t[r]=e[n];return n=>{for(let r=n.prop($.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}};Pe.none=new Pe("",Object.create(null),0,8);var yr=class i{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|oe.IncludeAnonymous);;){let h=!1;if(l.from<=s&&l.to>=r&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;h=!0}for(;h&&n&&(a||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;h=!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:Mh(Pe.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new i(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new i(Pe.none,t,n,r)))}static build(e){return aw(e)}};le.empty=new le(Pe.none,[],[],0);var Ph=class i{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 i(this.buffer,this.index)}},ei=class i{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Pe.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function br(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?a.length:-1;e!=h;e+=t){let c=a[e],f=l[e]+o.from;if(Ep(r,n,f,f+c.length)){if(c instanceof ei){if(s&oe.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,n-f,r);if(u>-1)return new Ci(new Rh(o,c,e,f),null,u)}else if(s&oe.IncludeAnonymous||!c.type.isAnonymous||Qh(c)){let u;if(!(s&oe.IgnoreMounts)&&(u=ln.get(c))&&!u.overlay)return new i(u.tree,f,e,o);let d=new i(c,f,e,o);return s&oe.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?c.children.length-1:0,t,n,r)}}}if(s&oe.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<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)}enter(e,t,n=0){let r;if(!(n&oe.IgnoreOverlays)&&(r=ln.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:a}of r.overlay)if((t>0?o<=s:o=s:a>s))return new i(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}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 Cp(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function Ch(i,e,t=e.length-1){for(let n=i.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}var Rh=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Ci=class i extends mo{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(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new i(this.context,this,s)}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,n=0){if(n&oe.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new i(this.context,this,s)}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 i(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 i(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new le(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Ap(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;st.from||o.to=e){let a=new nt(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(br(a,e,t,!1))}}return r?Ap(r):n}var wr=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 nt)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.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 nt?(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,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}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&oe.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&oe.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&oe.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 r=n<0?0:this.stack[n]+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<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<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,n,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let a=n._tree.children[s];if(this.mode&oe.IncludeAnonymous||a instanceof ei||!a.type.isAnonymous||Qh(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 o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r=0;s--){if(s<0)return Ch(this.node,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function Qh(i){return i.children.some(e=>e instanceof ei||!e.type.isAnonymous||Qh(e))}function aw(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=n.types.length}=i,a=Array.isArray(t)?new Ph(t,t.length):t,l=n.types,h=0,c=0;function f(w,P,C,D,B,V){let{id:X,start:q,end:G,size:I}=a,ie=c;for(;I<0;)if(a.next(),I==-1){let pe=s[X];C.push(pe),D.push(q-w);return}else if(I==-3){h=X;return}else if(I==-4){c=X;return}else throw new RangeError(`Unrecognized record size: ${I}`);let De=l[X],$e,We,Ye=q-w;if(G-q<=r&&(We=g(a.pos-P,B))){let pe=new Uint16Array(We.size-We.skip),Ze=a.pos-We.size,dt=pe.length;for(;a.pos>Ze;)dt=O(We.start,pe,dt);$e=new ei(pe,G-We.start,n),Ye=We.start-w}else{let pe=a.pos-I;a.next();let Ze=[],dt=[],hi=X>=o?X:-1,qi=0,Hr=G;for(;a.pos>pe;)hi>=0&&a.id==hi&&a.size>=0?(a.end<=Hr-r&&(m(Ze,dt,q,qi,a.end,Hr,hi,ie),qi=Ze.length,Hr=a.end),a.next()):V>2500?u(q,pe,Ze,dt):f(q,pe,Ze,dt,hi,V+1);if(hi>=0&&qi>0&&qi-1&&qi>0){let of=d(De);$e=Mh(De,Ze,dt,0,Ze.length,0,G-q,of,of)}else $e=p(De,Ze,dt,G-q,ie-G)}C.push($e),D.push(Ye)}function u(w,P,C,D){let B=[],V=0,X=-1;for(;a.pos>P;){let{id:q,start:G,end:I,size:ie}=a;if(ie>4)a.next();else{if(X>-1&&G=0;I-=3)q[ie++]=B[I],q[ie++]=B[I+1]-G,q[ie++]=B[I+2]-G,q[ie++]=ie;C.push(new ei(q,B[2]-G,n)),D.push(G-w)}}function d(w){return(P,C,D)=>{let B=0,V=P.length-1,X,q;if(V>=0&&(X=P[V])instanceof le){if(!V&&X.type==w&&X.length==D)return X;(q=X.prop($.lookAhead))&&(B=C[V]+X.length+q)}return p(w,P,C,D,B)}}function m(w,P,C,D,B,V,X,q){let G=[],I=[];for(;w.length>D;)G.push(w.pop()),I.push(P.pop()+C-B);w.push(p(n.types[X],G,I,V-B,q-V)),P.push(B-C)}function p(w,P,C,D,B=0,V){if(h){let X=[$.contextHash,h];V=V?[X].concat(V):[X]}if(B>25){let X=[$.lookAhead,B];V=V?[X].concat(V):[X]}return new le(w,P,C,D,V)}function g(w,P){let C=a.fork(),D=0,B=0,V=0,X=C.end-r,q={size:0,start:0,skip:0};e:for(let G=C.pos-w;C.pos>G;){let I=C.size;if(C.id==P&&I>=0){q.size=D,q.start=B,q.skip=V,V+=4,D+=4,C.next();continue}let ie=C.pos-I;if(I<0||ie=o?4:0,$e=C.start;for(C.next();C.pos>ie;){if(C.size<0)if(C.size==-3)De+=4;else break e;else C.id>=o&&(De+=4);C.next()}B=$e,D+=I,V+=De}return(P<0||D==w)&&(q.size=D,q.start=B,q.skip=V),q.size>4?q:void 0}function O(w,P,C){let{id:D,start:B,end:V,size:X}=a;if(a.next(),X>=0&&D4){let G=a.pos-(X-4);for(;a.pos>G;)C=O(w,P,C)}P[--C]=q,P[--C]=V-w,P[--C]=B-w,P[--C]=D}else X==-3?h=D:X==-4&&(c=D);return C}let y=[],v=[];for(;a.pos>0;)f(i.start||0,i.bufferStart||0,y,v,-1,0);let x=(e=i.length)!==null&&e!==void 0?e:y.length?v[0]+y[0].length:0;return new le(l[i.topID],y.reverse(),v.reverse(),x)}var Rp=new WeakMap;function po(i,e){if(!i.isAnonymous||e instanceof ei||e.type!=i)return 1;let t=Rp.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof le)){t=1;break}t+=po(i,n)}Rp.set(e,t)}return t}function Mh(i,e,t,n,r,s,o,a,l){let h=0;for(let m=n;m=c)break;P+=C}if(v==x+1){if(P>c){let C=m[x];d(C.children,C.positions,0,C.children.length,p[x]+y);continue}f.push(m[x])}else{let C=p[v-1]+m[v-1].length-w;f.push(Mh(i,m,p,x,v,w,C,null,l))}u.push(w+y-s)}}return d(e,t,n,r,0),(a||l)(f,u,o)}var go=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 Ci?this.setBuffer(e.context.buffer,e.index,t):e instanceof nt&&this.map.set(e.tree,t)}get(e){return e instanceof Ci?this.getBuffer(e.context.buffer,e.index):e instanceof nt?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)}},Ri=class i{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new i(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,h=0;;a++){let c=a=n)for(;o&&o.from=u.from||f<=u.to||h){let d=Math.max(u.from,l)-h,m=Math.min(u.to,f)-h;u=d>=m?null:new i(d,m,u.tree,u.offset+h,a>0,!!c)}if(u&&r.push(u),o.to>f)break;o=snew Or(r.from,r.to)):[new Or(0,0)]:[new Or(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}},Ah=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)}};var pT=new $({perNode:!0});var lw=0,Tt=class i{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=lw++}static define(e){if(e?.base)throw new Error("Can not derive from a modified tag");let t=new i([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new wo;return t=>t.modified.indexOf(e)>-1?t:wo.get(t.base||t,t.modified.concat(e).sort((n,r)=>n.id-r.id))}},hw=0,wo=class i{constructor(){this.instances=[],this.id=hw++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(a=>a.base==e&&cw(t,a.modified));if(n)return n;let r=[],s=new Tt(r,e,t);for(let a of t)a.instances.push(s);let o=fw(t);for(let a of e.set)if(!a.modified.length)for(let l of o)r.push(i.get(a,l));return s}};function cw(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function fw(i){let e=[[]];for(let t=0;tn.length-t.length)}function fn(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,a=r;for(let f=0;;){if(a=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let d=r[f++];if(f==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);a=r.slice(f)}let l=s.length-1,h=s[l];if(!h)throw new RangeError("Invalid path: "+r);let c=new cn(n,o,l>0?s.slice(0,l):null);e[h]=c.sort(e[h])}}return _p.add(e)}var _p=new $,cn=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{let o=r;for(let a of s)for(let l of a.set){let h=t[l.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}function uw(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function Vh(i,e,t,n=0,r=i.length){let s=new Dh(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}function Lh(i,e,t,n,r,s=0,o=i.length){let a=s;function l(h,c){if(!(h<=a)){for(let f=i.slice(a,h),u=0;;){let d=f.indexOf(`
-`,u),m=d<0?f.length:d;if(m>u&&n(f.slice(u,m),c),d<0)break;r(),u=d+1}a=h}}Vh(e,t,(h,c,f)=>{l(h,""),l(c,f)},s,o),l(o,"")}var Dh=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,s){let{type:o,from:a,to:l}=e;if(a>=n||l<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=r,c=dw(e)||cn.empty,f=uw(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,a),h),c.opaque)return;let u=e.tree&&e.tree.prop($.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+a,1),m=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),p=e.firstChild();for(let g=0,O=a;;g++){let y=g=v||!e.nextSibling())););if(!y||v>n)break;O=y.to+a,O>t&&(this.highlightRange(d.cursor(),Math.max(t,y.from+a),Math.min(n,O),"",m),this.startSpan(Math.min(n,O),h))}p&&e.parent()}else if(e.firstChild()){u&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),h)}while(e.nextSibling());e.parent()}}};function dw(i){let e=i.type.prop(_p);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}var R=Tt.define,Oo=R(),ti=R(),Qp=R(ti),Mp=R(ti),ii=R(),yo=R(ii),_h=R(ii),St=R(),Ei=R(St),xt=R(),kt=R(),$h=R(),vr=R($h),bo=R(),b={comment:Oo,lineComment:R(Oo),blockComment:R(Oo),docComment:R(Oo),name:ti,variableName:R(ti),typeName:Qp,tagName:R(Qp),propertyName:Mp,attributeName:R(Mp),className:R(ti),labelName:R(ti),namespace:R(ti),macroName:R(ti),literal:ii,string:yo,docString:R(yo),character:R(yo),attributeValue:R(yo),number:_h,integer:R(_h),float:R(_h),bool:R(ii),regexp:R(ii),escape:R(ii),color:R(ii),url:R(ii),keyword:xt,self:R(xt),null:R(xt),atom:R(xt),unit:R(xt),modifier:R(xt),operatorKeyword:R(xt),controlKeyword:R(xt),definitionKeyword:R(xt),moduleKeyword:R(xt),operator:kt,derefOperator:R(kt),arithmeticOperator:R(kt),logicOperator:R(kt),bitwiseOperator:R(kt),compareOperator:R(kt),updateOperator:R(kt),definitionOperator:R(kt),typeOperator:R(kt),controlOperator:R(kt),punctuation:$h,separator:R($h),bracket:vr,angleBracket:R(vr),squareBracket:R(vr),paren:R(vr),brace:R(vr),content:St,heading:Ei,heading1:R(Ei),heading2:R(Ei),heading3:R(Ei),heading4:R(Ei),heading5:R(Ei),heading6:R(Ei),contentSeparator:R(St),list:R(St),quote:R(St),emphasis:R(St),strong:R(St),link:R(St),monospace:R(St),strikethrough:R(St),inserted:R(),deleted:R(),changed:R(),invalid:R(),meta:bo,documentMeta:R(bo),annotation:R(bo),processingInstruction:R(bo),definition:Tt.defineModifier(),constant:Tt.defineModifier(),function:Tt.defineModifier(),standard:Tt.defineModifier(),local:Tt.defineModifier(),special:Tt.defineModifier()},OT=xr([{tag:b.link,class:"tok-link"},{tag:b.heading,class:"tok-heading"},{tag:b.emphasis,class:"tok-emphasis"},{tag:b.strong,class:"tok-strong"},{tag:b.keyword,class:"tok-keyword"},{tag:b.atom,class:"tok-atom"},{tag:b.bool,class:"tok-bool"},{tag:b.url,class:"tok-url"},{tag:b.labelName,class:"tok-labelName"},{tag:b.inserted,class:"tok-inserted"},{tag:b.deleted,class:"tok-deleted"},{tag:b.literal,class:"tok-literal"},{tag:b.string,class:"tok-string"},{tag:b.number,class:"tok-number"},{tag:[b.regexp,b.escape,b.special(b.string)],class:"tok-string2"},{tag:b.variableName,class:"tok-variableName"},{tag:b.local(b.variableName),class:"tok-variableName tok-local"},{tag:b.definition(b.variableName),class:"tok-variableName tok-definition"},{tag:b.special(b.variableName),class:"tok-variableName2"},{tag:b.definition(b.propertyName),class:"tok-propertyName tok-definition"},{tag:b.typeName,class:"tok-typeName"},{tag:b.namespace,class:"tok-namespace"},{tag:b.className,class:"tok-className"},{tag:b.macroName,class:"tok-macroName"},{tag:b.propertyName,class:"tok-propertyName"},{tag:b.operator,class:"tok-operator"},{tag:b.comment,class:"tok-comment"},{tag:b.meta,class:"tok-meta"},{tag:b.invalid,class:"tok-invalid"},{tag:b.punctuation,class:"tok-punctuation"}]);var qh,un=new $;function pw(i){return A.define({combine:i?e=>e.concat(i):void 0})}var mw=new $,Ue=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,N.prototype.hasOwnProperty("tree")||Object.defineProperty(N.prototype,"tree",{get(){return he(this)}}),this.parser=t,this.extension=[ni.of(this),N.languageData.of((s,o,a)=>{let l=Dp(s,o,a),h=l.type.prop(un);if(!h)return[];let c=s.facet(h),f=l.type.prop(mw);if(f){let u=l.resolve(o-l.from,a);for(let d of f)if(d.test(u,s)){let m=s.facet(d.facet);return d.type=="replace"?m:m.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return Dp(e,t,n).type.prop(un)==this.data}findRegions(e){let t=e.facet(ni);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(un)==this.data){n.push({from:o,to:o+s.length});return}let a=s.prop($.mounted);if(a){if(a.tree.prop(un)==this.data){if(a.overlay)for(let l of a.overlay)n.push({from:l.from+o,to:l.to+o});else n.push({from:o,to:o+s.length});return}else if(a.overlay){let l=n.length;if(r(a.tree,a.overlay[0].from+o),n.length>l)return}}for(let l=0;ln.isTop?t:void 0)]}),e.name)}configure(e,t){return new i(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function he(i){let e=i.field(Ue.state,!1);return e?e.tree:le.empty}var Ih=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 n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},kr=null,Nh=class i{constructor(e,t,n=[],r,s,o,a,l){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new i(e,t,[],le.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Ih(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=le.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;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(Ri.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=kr;kr=this;try{return e()}finally{kr=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=$p(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((h,c,f,u)=>l.push({fromA:h,toA:c,fromB:f,toB:u})),n=Ri.applyChanges(n,l),r=le.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);ce.from&&(this.fragments=$p(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends hn{createParse(t,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let l=kr;if(l){for(let h of r)l.tempSkipped.push(h);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new le(Pe.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return kr}};function $p(i,e,t){return Ri.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}var Tr=class i{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new i(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Nh.create(e.facet(ni).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new i(n)}};Ue.state=te.define({create:Tr.init,update(i,e){for(let t of e.effects)if(t.is(Ue.setState))return t.value;return e.startState.facet(ni)!=e.state.facet(ni)?Tr.init(e.state):i.apply(e)}});var Xp=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Xp=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Bh=typeof navigator<"u"&&(!((qh=navigator.scheduling)===null||qh===void 0)&&qh.isInputPending)?()=>navigator.scheduling.isInputPending():null,gw=re.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Ue.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Ue.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Xp(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,l=s.context.work(()=>Bh&&Bh()||Date.now()>o,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ue.setState.of(new Tr(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>we(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ni=A.define({combine(i){return i.length?i[0]:null},enables:i=>[Ue.state,gw,E.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]}),pn=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var Ow=A.define(),mn=A.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Pr(i){let e=i.facet(mn);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function gn(i,e){let t="",n=i.tabSize,r=i.facet(mn)[0];if(r==" "){for(;e>=n;)t+=" ",e-=n;r=" "}for(let s=0;s=e?yw(i,t,e):null}var Ai=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Pr(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return $t(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Cr=new $;function yw(i,e,t){let n=e.resolveStack(t),r=n.node.enterUnfinishedNodesBefore(t);if(r!=n.node){let s=[];for(let o=r;o!=n.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return Wp(n,i,t)}function Wp(i,e,t){for(let n=i;n;n=n.next){let r=ww(n.node);if(r)return r(jh.create(e,t,n))}return 0}function bw(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function ww(i){let e=i.type.prop(Cr);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop($.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>Ip(o,!0,1,void 0,s&&!bw(o)?r.from:void 0)}return i.parent==null?vw:null}function vw(){return 0}var jh=class i extends Ai{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new i(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(xw(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Wp(this.context.next,this.base,this.pos)}};function xw(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function kw(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==n)return null;if(!l.type.isSkipped)return l.fromIp(n,e,t,i)}function Ip(i,e,t,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==i.pos+o,l=e?kw(i):null;return l?a?i.column(l.from):i.column(l.to):i.baseIndent+(a?0:i.unit*t)}var Sw=200;function Np(){return N.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,r=t.lineAt(n);if(n>r.from+Sw)return i;let s=t.sliceString(r.from,n);if(!e.some(h=>h.test(s)))return i;let{state:o}=i,a=-1,l=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==a)continue;a=c.from;let f=So(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=gn(o,f);u!=d&&l.push({from:c.from,to:c.from+u.length,insert:d})}return l.length?[i,{changes:l,sequential:!0}]:i})}var Tw=A.define(),Rr=new $;function To(i){let e=i.firstChild,t=i.lastChild;return e&&e.tot)continue;if(s&&a.from=e&&h.to>t&&(s=h)}}return s}function Cw(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function vo(i,e,t){for(let n of i.facet(Tw)){let r=n(i,e,t);if(r)return r}return Pw(i,e,t)}function jp(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}var Po=_.define({map:jp}),Er=_.define({map:jp});function zp(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}var Qi=te.define({create(){return M.none},update(i,e){i=i.map(e.changes);for(let t of e.effects)if(t.is(Po)&&!Rw(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(Yh),r=n?M.replace({widget:new zh(n(e.state,t.value))}):Vp;i=i.update({add:[r.range(t.value.from,t.value.to)]})}else t.is(Er)&&(i=i.update({filter:(n,r)=>t.value.from!=n||t.value.to!=r,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:n}=e.selection.main;i.between(n,n,(r,s)=>{rn&&(t=!0)}),t&&(i=i.update({filterFrom:n,filterTo:n,filter:(r,s)=>s<=n||r>=n}))}return i},provide:i=>E.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,r)=>{t.push(n,r)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{(!r||r.from>s)&&(r={from:s,to:o})}),r}function Rw(i,e,t){let n=!1;return i.between(e,e,(r,s)=>{r==e&&s==t&&(n=!0)}),n}function Up(i,e){return i.field(Qi,!1)?e:e.concat(_.appendConfig.of(Gp()))}var Ew=i=>{for(let e of zp(i)){let t=vo(i.state,e.from,e.to);if(t)return i.dispatch({effects:Up(i.state,[Po.of(t),Fp(i,t)])}),!0}return!1},Aw=i=>{if(!i.state.field(Qi,!1))return!1;let e=[];for(let t of zp(i)){let n=xo(i.state,t.from,t.to);n&&e.push(Er.of(n),Fp(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function Fp(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,r=i.state.doc.lineAt(e.to).number;return E.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${r}.`)}var Qw=i=>{let{state:e}=i,t=[];for(let n=0;n{let e=i.state.field(Qi,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,r)=>{t.push(Er.of({from:n,to:r}))}),i.dispatch({effects:t}),!0};var Hp=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Ew},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Aw},{key:"Ctrl-Alt-[",run:Qw},{key:"Ctrl-Alt-]",run:Mw}],_w={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},Yh=A.define({combine(i){return Te(i,_w)}});function Gp(i){let e=[Qi,$w];return i&&e.push(Yh.of(i)),e}function Yp(i,e){let{state:t}=i,n=t.facet(Yh),r=o=>{let a=i.lineBlockAt(i.posAtDOM(o.target)),l=xo(i.state,a.from,a.to);l&&i.dispatch({effects:Er.of(l)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,r,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}var Vp=M.replace({widget:new class extends Be{toDOM(i){return Yp(i,null)}}}),zh=class extends Be{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Yp(e,this.value)}},Dw={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},Sr=class extends ze{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}};function Zp(i={}){let e=Object.assign(Object.assign({},Dw),i),t=new Sr(e,!0),n=new Sr(e,!1),r=re.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(ni)!=o.state.facet(ni)||o.startState.field(Qi,!1)!=o.state.field(Qi,!1)||he(o.startState)!=he(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new lt;for(let l of o.viewportLineBlocks){let h=xo(o.state,l.from,l.to)?n:vo(o.state,l.from,l.to)?t:null;h&&a.add(l.from,l.from,h)}return a.finish()}}),{domEventHandlers:s}=e;return[r,Th({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(r))===null||a===void 0?void 0:a.markers)||j.empty},initialSpacer(){return new Sr(e,!1)},domEventHandlers:Object.assign(Object.assign({},s),{click:(o,a,l)=>{if(s.click&&s.click(o,a,l))return!0;let h=xo(o.state,a.from,a.to);if(h)return o.dispatch({effects:Er.of(h)}),!0;let c=vo(o.state,a.from,a.to);return c?(o.dispatch({effects:Po.of(c)}),!0):!1}})}),Gp()]}var $w=E.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),ko=class i{constructor(e,t){this.specs=e;let n;function r(a){let l=et.newName();return(n||(n=Object.create(null)))["."+l]=a,l}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof Ue?a=>a.prop(un)==o.data:o?a=>a==o:void 0,this.style=xr(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=n?new et(n):null,this.themeType=t.themeType}static define(e,t){return new i(e,t||{})}},Uh=A.define(),Jp=A.define({combine(i){return i.length?[i[0]]:null}});function Xh(i){let e=i.facet(Uh);return e.length?e:i.facet(Jp)}function Ar(i,e){let t=[Vw],n;return i instanceof ko&&(i.module&&t.push(E.styleModule.of(i.module)),n=i.themeType),e?.fallback?t.push(Jp.of(i)):n?t.push(Uh.computeN([E.darkTheme],r=>r.facet(E.darkTheme)==(n=="dark")?[i]:[])):t.push(Uh.of(i)),t}var Fh=class{constructor(e){this.markCache=Object.create(null),this.tree=he(e.state),this.decorations=this.buildDeco(e,Xh(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=he(e.state),n=Xh(e.state),r=n!=Xh(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return M.none;let n=new lt;for(let{from:r,to:s}of e.visibleRanges)Vh(this.tree,t,(o,a,l)=>{n.add(o,a,this.markCache[l]||(this.markCache[l]=M.mark({class:l})))},r,s);return n.finish()}},Vw=Qe.high(re.fromClass(Fh,{decorations:i=>i.decorations})),Kp=ko.define([{tag:b.meta,color:"#404740"},{tag:b.link,textDecoration:"underline"},{tag:b.heading,textDecoration:"underline",fontWeight:"bold"},{tag:b.emphasis,fontStyle:"italic"},{tag:b.strong,fontWeight:"bold"},{tag:b.strikethrough,textDecoration:"line-through"},{tag:b.keyword,color:"#708"},{tag:[b.atom,b.bool,b.url,b.contentSeparator,b.labelName],color:"#219"},{tag:[b.literal,b.inserted],color:"#164"},{tag:[b.string,b.deleted],color:"#a11"},{tag:[b.regexp,b.escape,b.special(b.string)],color:"#e40"},{tag:b.definition(b.variableName),color:"#00f"},{tag:b.local(b.variableName),color:"#30a"},{tag:[b.typeName,b.namespace],color:"#085"},{tag:b.className,color:"#167"},{tag:[b.special(b.variableName),b.macroName],color:"#256"},{tag:b.definition(b.propertyName),color:"#00c"},{tag:b.comment,color:"#940"},{tag:b.invalid,color:"#f00"}]),Lw=E.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),em=1e4,tm="()[]{}",im=A.define({combine(i){return Te(i,{afterCursor:!0,brackets:tm,maxScanDistance:em,renderMatch:Xw})}}),qw=M.mark({class:"cm-matchingBracket"}),Bw=M.mark({class:"cm-nonmatchingBracket"});function Xw(i){let e=[],t=i.matched?qw:Bw;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}var Ww=te.define({create(){return M.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(im);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=ct(e.state,r.head,-1,n)||r.head>0&&ct(e.state,r.head-1,1,n)||n.afterCursor&&(ct(e.state,r.head,1,n)||r.headE.decorations.from(i)}),Iw=[Ww,Lw];function nm(i={}){return[im.of(i),Iw]}var Nw=new $;function Hh(i,e,t){let n=i.prop(e<0?$.openedBy:$.closedBy);if(n)return n;if(i.name.length==1){let r=t.indexOf(i.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function Gh(i){let e=i.type.prop(Nw);return e?e(i.node):i}function ct(i,e,t,n={}){let r=n.maxScanDistance||em,s=n.brackets||tm,o=he(i),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let h=Hh(l.type,t,s);if(h&&l.from0?e>=c.from&&ec.from&&e<=c.to))return jw(i,e,t,l,c,h,s)}}return zw(i,e,t,o,a.type,r,s)}function jw(i,e,t,n,r,s,o){let a=n.parent,l={from:r.from,to:r.to},h=0,c=a?.cursor();if(c&&(t<0?c.childBefore(n.from):c.childAfter(n.to)))do if(t<0?c.to<=n.from:c.from>=n.to){if(h==0&&s.indexOf(c.type.name)>-1&&c.from0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=i.doc.iterRange(e,t>0?i.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=s;){let d=c.value;t<0&&(u+=d.length);let m=e+u*t;for(let p=t>0?0:d.length-1,g=t>0?d.length:-1;p!=g;p+=t){let O=o.indexOf(d[p]);if(!(O<0||n.resolveInner(m+p,1).type!=r))if(O%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:m+p,to:m+p+1},matched:O>>1==l>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}var Uw=Object.create(null),Lp=[Pe.none];var qp=[],Bp=Object.create(null),Fw=Object.create(null);for(let[i,e]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"]])Fw[i]=Hw(Uw,e);function Wh(i,e){qp.indexOf(i)>-1||(qp.push(i),console.warn(e))}function Hw(i,e){let t=[];for(let a of e.split(" ")){let l=[];for(let h of a.split(".")){let c=i[h]||b[h];c?typeof c=="function"?l.length?l=l.map(c):Wh(h,`Modifier ${h} used at start of tag`):l.length?Wh(h,`Tag ${h} used as modifier`):l=Array.isArray(c)?c:[c]:Wh(h,`Unknown highlighting tag ${h}`)}for(let h of l)t.push(h)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+t.map(a=>a.id),s=Bp[r];if(s)return s.id;let o=Bp[r]=Pe.define({id:Lp.length,name:n,props:[fn({[n]:t})]});return Lp.push(o),o.id}var TT={rtl:M.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:H.RTL}),ltr:M.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:H.LTR}),auto:M.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var Gw=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=nc(i.state,t.from);return n.line?Yw(i):n.block?Jw(i):!1};function ic(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=i(e,t);return r?(n(t.update(r)),!0):!1}}var Yw=ic(tv,0);var Zw=ic(fm,0);var Jw=ic((i,e)=>fm(i,e,ev(e)),0);function nc(i,e){let t=i.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var Qr=50;function Kw(i,{open:e,close:t},n,r){let s=i.sliceDoc(n-Qr,n),o=i.sliceDoc(r,r+Qr),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,h=s.length-a;if(s.slice(h-e.length,h)==e&&o.slice(l,l+t.length)==t)return{open:{pos:n-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let c,f;r-n<=2*Qr?c=f=i.sliceDoc(n,r):(c=i.sliceDoc(n,n+Qr),f=i.sliceDoc(r-Qr,r));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,m=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(m,m+t.length)==t?{open:{pos:n+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(f.charAt(m-1))?1:0}}:null}function ev(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),r=t.to<=n.to?n:i.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=r.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return e}function fm(i,e,t=e.selection.ranges){let n=t.map(s=>nc(e,s.from).block);if(!n.every(s=>s))return null;let r=t.map((s,o)=>Kw(e,n[o],s.from,s.to));if(i!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:n[o].open+" "},{from:s.to,insert:" "+n[o].close}]))};if(i!=1&&r.some(s=>s)){let s=[];for(let o=0,a;or&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,m=f.text.slice(u,u+h.length)==h?u:-1;u