n.bottom)&&b==n.bottom-h.bottom>h.top-n.top&&(b=!b);let w=(b?h.top-n.top:n.bottom-h.bottom)-d;if(wm&&t.topv&&(v=b?t.top-p-2-d:t.bottom+d+2);"absolute"==this.position?(l.style.top=v-t.parent.top+"px",l.style.left=m-t.parent.left+"px"):(l.style.top=v+"px",l.style.left=m+"px"),u&&(u.style.left=h.left+(g?O.x:-O.x)-(m+14-7)+"px"),!0!==a.overlap&&s.push({left:m,top:v,right:S,bottom:v+p}),l.classList.toggle("cm-tooltip-above",b),l.classList.toggle("cm-tooltip-below",!b),a.positioned&&a.positioned(t.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 t of this.manager.tooltipViews)t.dom.style.top=Qr}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),Zr=Ts.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:"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"}}}),Ar={x:0,y:0},Tr=E.define({enables:[Xr,Zr]});function Rr(t,e){let i=t.plugin(Xr);if(!i)return null;let n=i.manager.tooltips.indexOf(e);return n<0?null:i.manager.tooltipViews[n]}const Er=E.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function Vr(t,e){let i=t.plugin(Mr),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const Mr=_i.fromClass(class{constructor(t){this.input=t.state.facet(Ur),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(Er);this.top=new Dr(t,!0,e.topContainer),this.bottom=new Dr(t,!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(t){let e=t.state.facet(Er);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Dr(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Dr(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Ur);if(i!=this.input){let e=i.filter((t=>t)),n=[],s=[],r=[],o=[];for(let i of e){let e,a=this.specs.indexOf(i);a<0?(e=i(t.view),o.push(e)):(e=this.panels[a],e.update&&e.update(t)),n.push(e),(e.top?s:r).push(e)}this.specs=e,this.panels=n,this.top.sync(s),this.bottom.sync(r);for(let t of o)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Ts.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class Dr{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));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 t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Wr(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Wr(t)}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 t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function Wr(t){let e=t.nextSibling;return t.remove(),e}const Ur=E.define({enables:Mr});class Yr extends Qt{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Yr.prototype.elementClass="",Yr.prototype.toDOM=void 0,Yr.prototype.mapMode=y.TrackBefore,Yr.prototype.startSide=Yr.prototype.endSide=-1,Yr.prototype.point=!0;const qr=E.define(),Lr={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>_t.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},zr=E.define();function Ir(t){return[jr(),zr.of(Object.assign(Object.assign({},Lr),t))]}const Br=E.define({combine:t=>t.some((t=>t))});function jr(t){let e=[Nr];return t&&!1===t.fixed&&e.push(Br.of(!0)),e}const Nr=_i.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=t.state.facet(zr).map((e=>new Jr(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(Br),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(Br)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=_t.iter(this.view.state.facet(qr),this.view.viewport.from),n=[],s=this.gutters.map((t=>new Hr(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks){let e;if(Array.isArray(t.type)){for(let i of t.type)if(i.type==ii.Text){e=i;break}}else e=t.type==ii.Text?t:void 0;if(e){n.length&&(n=[]),Fr(i,n,t.from);for(let t of s)t.line(this.view,e,n)}}for(let t of s)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(zr),i=t.state.facet(zr),n=t.docChanged||t.heightChanged||t.viewportChanged||!_t.eq(t.startState.facet(qr),t.state.facet(qr),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(n=!0);else{n=!0;let s=[];for(let n of i){let i=e.indexOf(n);i<0?s.push(new Jr(this.view,n)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)this.dom.appendChild(t.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>Ts.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==Wi.LTR?{left:i.dom.offsetWidth}:{right:i.dom.offsetWidth}:null}))});function Gr(t){return Array.isArray(t)?t:[t]}function Fr(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class Hr{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=_t.iter(t.markers,e.from)}line(t,e,i){let n=[];Fr(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let r=this.gutter;if(0==n.length&&!r.config.renderEmptyElements)return;let o=e.top-this.height;if(this.i==r.elements.length){let i=new Kr(t,e.height,o,n);r.elements.push(i),r.dom.appendChild(i.dom)}else r.elements[this.i].update(t,e.height,o,n);this.height=e.bottom,this.i++}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class Jr{constructor(t,e){this.view=t,this.config=e,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 e.domEventHandlers)this.dom.addEventListener(i,(n=>{let s,r=n.target;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let t=r.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=n.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()}));this.markers=Gr(e.markers(t)),e.initialSpacer&&(this.spacer=new Kr(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=Gr(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!_t.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class Kr{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.dom.style.height=(this.height=e)+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),function(t,e){if(t.length!=e.length)return!1;for(let i=0;ikt(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let n=i[t],s=e[t];i[t]=n?(t,e,i)=>n(t,e,i)||s(t,e,i):s}return i}})});class io extends Yr{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function no(t,e){return t.state.facet(eo).formatNumber(e,t.state)}const so=zr.compute([eo],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(to),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new io(no(t,t.state.doc.lineAt(e.from).number)),lineMarkerChange:t=>t.startState.facet(eo)!=t.state.facet(eo),initialSpacer:t=>new io(no(t,ro(t.state.doc.lines))),updateSpacer(t,e){let i=no(e.view,ro(e.view.state.doc.lines));return i==t.number?t:new io(i)},domEventHandlers:t.facet(eo).domEventHandlers})));function ro(t){let e=9;for(;e{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=fo.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}ho.closedBy=new ho({deserialize:t=>t.split(" ")}),ho.openedBy=new ho({deserialize:t=>t.split(" ")}),ho.group=new ho({deserialize:t=>t.split(" ")}),ho.contextHash=new ho({perNode:!0}),ho.lookAhead=new ho({perNode:!0}),ho.mounted=new ho({perNode:!0});class co{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}}const uo=Object.create(null);class fo{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):uo,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new fo(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(ho.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(ho.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}fo.none=new fo("",Object.create(null),0,8);class po{constructor(t){this.types=t;for(let e=0;e=n&&(r.type.isAnonymous||!1!==e(r))){if(r.firstChild())continue;t=!0}for(;t&&i&&!r.type.isAnonymous&&i(r),!r.nextSibling();){if(!r.parent())return;t=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:To(fo.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new bo(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new bo(fo.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=oo,reused:r=[],minRepeatType:o=n.types.length}=t,a=Array.isArray(i)?new wo(i,i.length):i,l=n.types,h=0,c=0;function u(t,e,i,m,b){let{id:w,start:v,end:S,size:y}=a,x=c;for(;y<0;){if(a.next(),-1==y){let e=r[w];return i.push(e),void m.push(v-t)}if(-3==y)return void(h=w);if(-4==y)return void(c=w);throw new RangeError(`Unrecognized record size: ${y}`)}let k,Q,$=l[w],P=v-t;if(S-v<=s&&(Q=O(a.pos-e,b))){let e=new Uint16Array(Q.size-Q.skip),i=a.pos-Q.size,s=e.length;for(;a.pos>i;)s=g(Q.start,e,s);k=new vo(e,S-Q.start,n),P=Q.start-t}else{let t=a.pos-y;a.next();let e=[],i=[],n=w>=o?w:-1,r=0,l=S;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=l-s&&(f(e,i,v,r,a.end,l,n,x),r=e.length,l=a.end),a.next()):u(v,t,e,i,n);if(n>=0&&r>0&&r-1&&r>0){let t=d($);k=To($,e,i,0,e.length,0,S-v,t,t)}else k=p($,e,i,S-v,x-S)}i.push(k),m.push(P)}function d(t){return(e,i,n)=>{let s,r,o=0,a=e.length-1;if(a>=0&&(s=e[a])instanceof bo){if(!a&&s.type==t&&s.length==n)return s;(r=s.prop(ho.lookAhead))&&(o=i[a]+s.length+r)}return p(t,e,i,n,o)}}function f(t,e,i,s,r,o,a,l){let h=[],c=[];for(;t.length>s;)h.push(t.pop()),c.push(e.pop()+i-r);t.push(p(n.types[a],h,c,o-r,l-o)),e.push(r-i)}function p(t,e,i,n,s=0,r){if(h){let t=[ho.contextHash,h];r=r?[t].concat(r):[t]}if(s>25){let t=[ho.lookAhead,s];r=r?[t].concat(r):[t]}return new bo(t,e,i,n,r)}function O(t,e){let i=a.fork(),n=0,r=0,l=0,h=i.end-s,c={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=r,c.skip=l,l+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a=o?4:0,d=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}r=d,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=r,c.skip=l),c.size>4?c:void 0}function g(t,e,i){let{id:n,start:s,end:r,size:l}=a;if(a.next(),l>=0&&n4){let n=a.pos-(l-4);for(;a.pos>n;)i=g(t,e,i)}e[--i]=o,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==l?h=n:-4==l&&(c=n);return i}let m=[],b=[];for(;a.pos>0;)u(t.start||0,t.bufferStart||0,m,b,-1);let w=null!==(e=t.length)&&void 0!==e?e:m.length?b[0]+m[0].length:0;return new bo(l[t.topID],m.reverse(),b.reverse(),w)}(t)}}bo.empty=new bo(fo.none,[],[],0);class wo{constructor(t,e){this.buffer=t,this.index=e}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 wo(this.buffer,this.index)}}class vo{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return fo.none}toString(){let t=[];for(let e=0;e0));a=r[a+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,a=0;o=e&&ie;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function yo(t,e){let i=t.childBefore(e);for(;i;){let e=i.lastChild;if(!e||e.to!=i.to)break;e.type.isError&&e.from==e.to?(t=i,i=e.prevSibling):i=e}return t}function xo(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to0?o.length:-1;t!=l;t+=e){let l=o[t],h=a[t]+r.from;if(So(n,i,h,h+l.length))if(l instanceof vo){if(s&mo.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-h,n);if(o>-1)return new Co(new Po(r,l,t,h),null,o)}else if(s&mo.IncludeAnonymous||!l.type.isAnonymous||Xo(l)){let o;if(!(s&mo.IgnoreMounts)&&l.props&&(o=l.prop(ho.mounted))&&!o.overlay)return new ko(o.tree,h,t,r);let a=new ko(l,h,t,r);return s&mo.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&mo.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)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(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&mo.IgnoreOverlays)&&(n=this._tree.prop(ho.mounted))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t=i:s>i))return new ko(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}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}cursor(t=0){return new _o(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return xo(this,t,e,!1)}resolveInner(t,e=0){return xo(this,t,e,!0)}enterUnfinishedNodesBefore(t){return yo(this,t)}getChild(t,e=null,i=null){let n=Qo(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Qo(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return $o(this,t)}}function Qo(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!s.type.is(i);)if(!s.nextSibling())return r;for(;;){if(null!=n&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return null==n?r:[]}}function $o(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class Po{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class Co{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(t,e,i){this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new Co(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&mo.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new Co(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Co(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new Co(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new _o(this,t)}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let r=i.buffer[this.index+1];t.push(i.slice(n,s,r)),e.push(0)}return new bo(this.type,t,e,this.to-this.from)}resolve(t,e=0){return xo(this,t,e,!1)}resolveInner(t,e=0){return xo(this,t,e,!0)}enterUnfinishedNodesBefore(t){return yo(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=Qo(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Qo(this,t,e,i)}get node(){return this}matchContext(t){return $o(this,t)}}class _o{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof ko)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof ko?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&mo.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&mo.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&mo.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&mo.IncludeAnonymous||t instanceof vo||!t.type.isAnonymous||Xo(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to=0;){for(let r=t;r;r=r._parent)if(r.index==n){if(n==this.index)return r;e=r,i=s+1;break t}n=this.stack[--s]}for(let t=i;t=0;s--){if(s<0)return $o(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function Xo(t){return t.children.some((t=>t instanceof vo||!t.type.isAnonymous||Xo(t)))}const Zo=new WeakMap;function Ao(t,e){if(!t.isAnonymous||e instanceof vo||e.type!=t)return 1;let i=Zo.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof bo)){i=1;break}i+=Ao(t,n)}Zo.set(e,i)}return i}function To(t,e,i,n,s,r,o,a,l){let h=0;for(let i=n;i=c)break;p+=e}if(h==s+1){if(p>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+a);continue}u.push(i[s])}else{let e=n[h-1]+i[h-1].length-f;u.push(To(t,i,n,s,h,f,e,null,l))}d.push(f+a-r)}}(e,i,n,s,0),(a||l)(u,d,o)}class Ro{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof Co?this.setBuffer(t.context.buffer,t.index,e):t instanceof ko&&this.map.set(t.tree,e)}get(t){return t instanceof Co?this.getBuffer(t.context.buffer,t.index):t instanceof ko?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class Eo{constructor(t,e,i,n,s=!1,r=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(r?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new Eo(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,r=t.length?t[0]:null;for(let o=0,a=0,l=0;;o++){let h=o=i)for(;r&&r.from=e.from||c<=e.to||l){let t=Math.max(e.from,a)-l,i=Math.min(e.to,c)-l;e=t>=i?null:new Eo(t,i,e.tree,e.offset+l,o>0,!!h)}if(e&&n.push(e),r.to>c)break;r=snew lo(t.from,t.to))):[new lo(0,0)]:[new lo(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class Mo{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function Do(t){return(e,i,n,s)=>new qo(e,t,i,n,s)}class Wo{constructor(t,e,i,n,s){this.parser=t,this.parse=e,this.overlay=i,this.target=n,this.ranges=s}}class Uo{constructor(t,e,i,n,s,r,o){this.parser=t,this.predicate=e,this.mounts=i,this.index=n,this.start=s,this.target=r,this.prev=o,this.depth=0,this.ranges=[]}}const Yo=new ho({perNode:!0});class qo{constructor(t,e,i,n,s){this.nest=e,this.input=i,this.fragments=n,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let t=this.baseParse.advance();if(!t)return null;if(this.baseParse=null,this.baseTree=t,this.startInner(),null!=this.stoppedAt)for(let t of this.inner)t.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let t=this.baseTree;return null!=this.stoppedAt&&(t=new bo(t.type,t.children,t.positions,t.length,t.propValues.concat([[Yo,this.stoppedAt]]))),t}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[ho.mounted.id]=new co(e,t.overlay,t.parser),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;et.frag.from<=n.from&&t.frag.to>=n.to&&t.mount.overlay));if(t)for(let i of t.mount.overlay){let s=i.from+t.pos,r=i.to+t.pos;s>=n.from&&r<=n.to&&!e.ranges.some((t=>t.froms))&&e.ranges.push({from:s,to:r})}}a=!1}else if(i&&(r=Lo(i.ranges,n.from,n.to)))a=2!=r;else if(!n.type.isAnonymous&&n.fromnew lo(t.from-n.from,t.to-n.from))):null,n.tree,t)),s.overlay?t.length&&(i={ranges:t,depth:0,prev:i}):a=!1}}else e&&(o=e.predicate(n))&&(!0===o&&(o=new lo(n.from,n.to)),o.fromnew lo(t.from-e.start,t.to-e.start))),e.target,t)),e=e.prev}i&&! --i.depth&&(i=i.prev)}}}}function Lo(t,e,i){for(let n of t){if(n.from>=i)break;if(n.to>e)return n.from<=e&&n.to>=i?2:1}return 0}function zo(t,e,i,n,s,r){if(e=e.to);n++);let o=s.children[n],a=o.buffer;s.children[n]=function t(i,n,s,l,h){let c=i;for(;a[c+2]+r<=e.from;)c=a[c+3];let u=[],d=[];zo(o,i,c,u,d,l);let f=a[c+1],p=a[c+2],O=f+r==e.from&&p+r==e.to&&a[c]==e.type.id;return u.push(O?e.toTree():t(c+4,a[c+3],o.set.types[a[c]],f,p-f)),d.push(f-l),zo(o,a[c+3],n,u,d,l),new bo(s,u,d,h)}(0,a.length,fo.none,0,o.length);for(let n=0;n<=i;n++)t.childAfter(e.from)}class Bo{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(mo.IncludeAnonymous|mo.IgnoreMounts)}moveTo(t){let{cursor:e}=this,i=t-this.offset;for(;!this.done&&e.from=t&&e.enter(i,1,mo.IgnoreOverlays|mo.ExcludeBuffers)||e.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(!(e.children.length&&0==e.positions[0]&&e.children[0]instanceof bo))break;e=e.children[0]}return!1}}let jo=class{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=null!==(e=i.tree.prop(Yo))&&void 0!==e?e:i.to,this.inner=new Bo(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=null!==(t=e.tree.prop(Yo))&&void 0!==t?t:e.to,this.inner=new Bo(e.tree,-e.offset)}}findMounts(t,e){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let t=this.inner.cursor.node;t;t=t.parent){let s=null===(i=t.tree)||void 0===i?void 0:i.prop(ho.mounted);if(s&&s.parser==e)for(let e=this.fragI;e=t.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:t.from-i.offset,mount:s})}}}return n}};function No(t,e){let i=null,n=e;for(let s=1,r=0;s=a)break;t.to<=o||(i||(n=i=e.slice()),t.froma&&i.splice(r+1,0,new lo(a,t.to))):t.to>a?i[r--]=new lo(a,t.to):i.splice(r--,1))}}return n}function Go(t,e,i,n){let s=0,r=0,o=!1,a=!1,l=-1e9,h=[];for(;;){let c=s==t.length?1e9:o?t[s].to:t[s].from,u=r==e.length?1e9:a?e[r].to:e[r].from;if(o!=a){let t=Math.max(l,i),e=Math.min(c,u,n);tnew lo(t.from+n,t.to+n))),a,l);for(let e=0,n=a;;e++){let a=e==o.length,h=a?l:o[e].from;if(h>n&&i.push(new Eo(n,h,s.tree,-t,r.from>=n||r.openStart,r.to<=h||r.openEnd)),a)break;n=o[e].to}}else i.push(new Eo(a,l,s.tree,-t,r.from>=t||r.openStart,r.to<=o||r.openEnd))}return i}let Ho=0;class Jo{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=Ho++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new Jo([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new ta;return e=>e.modified.indexOf(t)>-1?e:ta.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let Ko=0;class ta{constructor(){this.instances=[],this.id=Ko++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every(((t,e)=>t==s[e])));var n,s}));if(i)return i;let n=[],s=new Jo(n,t,e);for(let t of e)t.instances.push(s);let r=function(t){let e=[[]];for(let i=0;ie.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of r)n.push(ta.get(e,t));return s}}function ea(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],s=2,r=t;for(let e=0;;){if("..."==r&&e>0&&e+3==t.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){s=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);r=t.slice(e)}let o=i.length-1,a=i[o];if(!a)throw new RangeError("Invalid path: "+t);let l=new na(n,s,o>0?i.slice(0,o):null);e[a]=l.sort(e[a])}}return ia.add(e)}const ia=new ho;class na{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function ra(t,e,i,n=0,s=t.length){let r=new oa(n,Array.isArray(e)?e:[e],i);r.highlightRange(t.cursor(),n,s,"",r.highlighters),r.flush(s)}na.empty=new na([],2,null);class oa{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,s){let{type:r,from:o,to:a}=t;if(o>=i||a<=e)return;r.isTop&&(s=this.highlighters.filter((t=>!t.scope||t.scope(r))));let l=n,h=function(t){let e=t.type.prop(ia);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||na.empty,c=function(t,e){let i=null;for(let n of t){let t=n.style(e);t&&(i=i?i+" "+t:t)}return i}(s,h.tags);if(c&&(l&&(l+=" "),l+=c,1==h.mode&&(n+=(n?" ":"")+c)),this.startSpan(t.from,l),h.opaque)return;let u=t.tree&&t.tree.prop(ho.mounted);if(u&&u.overlay){let r=t.node.enter(u.overlay[0].from+o,1),h=this.highlighters.filter((t=>!t.scope||t.scope(u.tree.type))),c=t.firstChild();for(let d=0,f=o;;d++){let p=d=O)&&t.nextSibling()););if(!p||O>i)break;f=p.to+o,f>e&&(this.highlightRange(r.cursor(),Math.max(e,p.from+o),Math.min(i,f),n,h),this.startSpan(f,l))}c&&t.parent()}else if(t.firstChild()){do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,s),this.startSpan(Math.min(i,t.to),l)}}while(t.nextSibling());t.parent()}}}const aa=Jo.define,la=aa(),ha=aa(),ca=aa(ha),ua=aa(ha),da=aa(),fa=aa(da),pa=aa(da),Oa=aa(),ga=aa(Oa),ma=aa(),ba=aa(),wa=aa(),va=aa(wa),Sa=aa(),ya={comment:la,lineComment:aa(la),blockComment:aa(la),docComment:aa(la),name:ha,variableName:aa(ha),typeName:ca,tagName:aa(ca),propertyName:ua,attributeName:aa(ua),className:aa(ha),labelName:aa(ha),namespace:aa(ha),macroName:aa(ha),literal:da,string:fa,docString:aa(fa),character:aa(fa),attributeValue:aa(fa),number:pa,integer:aa(pa),float:aa(pa),bool:aa(da),regexp:aa(da),escape:aa(da),color:aa(da),url:aa(da),keyword:ma,self:aa(ma),null:aa(ma),atom:aa(ma),unit:aa(ma),modifier:aa(ma),operatorKeyword:aa(ma),controlKeyword:aa(ma),definitionKeyword:aa(ma),moduleKeyword:aa(ma),operator:ba,derefOperator:aa(ba),arithmeticOperator:aa(ba),logicOperator:aa(ba),bitwiseOperator:aa(ba),compareOperator:aa(ba),updateOperator:aa(ba),definitionOperator:aa(ba),typeOperator:aa(ba),controlOperator:aa(ba),punctuation:wa,separator:aa(wa),bracket:va,angleBracket:aa(va),squareBracket:aa(va),paren:aa(va),brace:aa(va),content:Oa,heading:ga,heading1:aa(ga),heading2:aa(ga),heading3:aa(ga),heading4:aa(ga),heading5:aa(ga),heading6:aa(ga),contentSeparator:aa(Oa),list:aa(Oa),quote:aa(Oa),emphasis:aa(Oa),strong:aa(Oa),link:aa(Oa),monospace:aa(Oa),strikethrough:aa(Oa),inserted:aa(),deleted:aa(),changed:aa(),invalid:aa(),meta:Sa,documentMeta:aa(Sa),annotation:aa(Sa),processingInstruction:aa(Sa),definition:Jo.defineModifier(),constant:Jo.defineModifier(),function:Jo.defineModifier(),standard:Jo.defineModifier(),local:Jo.defineModifier(),special:Jo.defineModifier()};var xa;sa([{tag:ya.link,class:"tok-link"},{tag:ya.heading,class:"tok-heading"},{tag:ya.emphasis,class:"tok-emphasis"},{tag:ya.strong,class:"tok-strong"},{tag:ya.keyword,class:"tok-keyword"},{tag:ya.atom,class:"tok-atom"},{tag:ya.bool,class:"tok-bool"},{tag:ya.url,class:"tok-url"},{tag:ya.labelName,class:"tok-labelName"},{tag:ya.inserted,class:"tok-inserted"},{tag:ya.deleted,class:"tok-deleted"},{tag:ya.literal,class:"tok-literal"},{tag:ya.string,class:"tok-string"},{tag:ya.number,class:"tok-number"},{tag:[ya.regexp,ya.escape,ya.special(ya.string)],class:"tok-string2"},{tag:ya.variableName,class:"tok-variableName"},{tag:ya.local(ya.variableName),class:"tok-variableName tok-local"},{tag:ya.definition(ya.variableName),class:"tok-variableName tok-definition"},{tag:ya.special(ya.variableName),class:"tok-variableName2"},{tag:ya.definition(ya.propertyName),class:"tok-propertyName tok-definition"},{tag:ya.typeName,class:"tok-typeName"},{tag:ya.namespace,class:"tok-namespace"},{tag:ya.className,class:"tok-className"},{tag:ya.macroName,class:"tok-macroName"},{tag:ya.propertyName,class:"tok-propertyName"},{tag:ya.operator,class:"tok-operator"},{tag:ya.comment,class:"tok-comment"},{tag:ya.meta,class:"tok-meta"},{tag:ya.invalid,class:"tok-invalid"},{tag:ya.punctuation,class:"tok-punctuation"}]);const ka=new ho;function Qa(t){return E.define({combine:t?e=>e.concat(t):void 0})}const $a=new ho;class Pa{constructor(t,e,i=[],n=""){this.data=t,this.name=n,xt.prototype.hasOwnProperty("tree")||Object.defineProperty(xt.prototype,"tree",{get(){return Xa(this)}}),this.parser=e,this.extension=[Wa.of(this),xt.languageData.of(((t,e,i)=>{let n=Ca(t,e,i),s=n.type.prop(ka);if(!s)return[];let r=t.facet(s),o=n.type.prop($a);if(o){let s=n.resolve(e-n.from,i);for(let e of o)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(r)}}return r}))].concat(i)}isActiveAt(t,e,i=-1){return Ca(t,e,i).type.prop(ka)==this.data}findRegions(t){let e=t.facet(Wa);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(ka)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(ho.mounted);if(s){if(s.tree.prop(ka)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;it.isTop?e:void 0))]}),t.name)}configure(t,e){return new _a(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Xa(t){let e=t.field(Pa.state,!1);return e?e.tree:bo.empty}class Za{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Aa=null;class Ta{constructor(t,e,i=[],n,s,r,o,a){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Ta(t,e,[],bo.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Za(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=bo.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Eo.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Aa;Aa=this;try{return t()}finally{Aa=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Ra(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:r,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,n,s)=>e.push({fromA:t,toA:i,fromB:n,toB:s}))),i=Eo.applyChanges(i,e),n=bo.empty,s=0,r={from:t.mapPos(r.from,-1),to:t.mapPos(r.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);it.from&&(this.fragments=Ra(this.fragments,i,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Vo{createParse(e,i,n){let s=n[0].from,r=n[n.length-1].to;return{parsedPos:s,advance(){let e=Aa;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=r,new bo(fo.none,[],[],r-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return Aa}}function Ra(t,e,i){return Eo.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class Ea{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new Ea(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Ta.create(t.facet(Wa).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Ea(i)}}Pa.state=q.define({create:Ea.init,update(t,e){for(let t of e.effects)if(t.is(Pa.setState))return t.value;return e.startState.facet(Wa)!=e.state.facet(Wa)?Ea.init(e.state):t.apply(e)}});let Va=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Va=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Ma="undefined"!=typeof navigator&&(null===(xa=navigator.scheduling)||void 0===xa?void 0:xa.isInputPending)?()=>navigator.scheduling.isInputPending():null,Da=_i.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Pa.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),t.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Pa.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Va(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEndn+1e3,a=s.context.work((()=>Ma&&Ma()||Date.now()>r),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Pa.setState.of(new Ea(s.context))})),this.chunkBudget>0&&(!a||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>Qi(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Wa=E.define({combine:t=>t.length?t[0]:null,enables:t=>[Pa.state,Da,Ts.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});class Ua{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Ya{constructor(t,e,i,n,s,r=void 0){this.name=t,this.alias=e,this.extensions=i,this.filename=n,this.loadFunc=s,this.support=r,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then((t=>this.support=t),(t=>{throw this.loading=null,t})))}static of(t){let{load:e,support:i}=t;if(!e){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(i)}return new Ya(t.name,(t.alias||[]).concat(t.name).map((t=>t.toLowerCase())),t.extensions||[],t.filename,e,i)}static matchFilename(t,e){for(let i of t)if(i.filename&&i.filename.test(e))return i;let i=/\.([^.]+)$/.exec(e);if(i)for(let e of t)if(e.extensions.indexOf(i[1])>-1)return e;return null}static matchLanguageName(t,e,i=!0){e=e.toLowerCase();for(let i of t)if(i.alias.some((t=>t==e)))return i;if(i)for(let i of t)for(let t of i.alias){let n=e.indexOf(t);if(n>-1&&(t.length>2||!/\w/.test(e[n-1])&&!/\w/.test(e[n+t.length])))return i}return null}}const qa=E.define(),La=E.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some((t=>t!=e[0])))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function za(t){let e=t.facet(La);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Ia(t,e){let i="",n=t.tabSize,s=t.facet(La)[0];if("\t"==s){for(;e>=n;)i+="\t",e-=n;s=" "}for(let t=0;t=i.from&&n<=i.to?s&&n==t?{text:"",from:t}:(e<0?n-1&&(s+=r-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,e=t.length){return Yt(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let t=s(n);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Na=new ho;function Ga(t){let e=t.type.prop(Na);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(ho.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>el(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?Ha:null}function Fa(t,e,i){for(;t;t=t.parent){let n=Ga(t);if(n)return n(Ja.create(i,e,t))}return null}function Ha(){return 0}class Ja extends ja{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.node=i}static create(t,e,i){return new Ja(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let t=this.state.doc.lineAt(this.node.from);for(;;){let e=this.node.resolve(t.from);for(;e.parent&&e.parent.from==e.from;)e=e.parent;if(Ka(e,this.node))break;t=this.state.doc.lineAt(e.from)}return this.lineIndent(t.from)}continue(){let t=this.node.parent;return t?Fa(t,this.pos,this.base):0}}function Ka(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function tl({closing:t,align:e=!0,units:i=1}){return n=>el(n,e,i,t)}function el(t,e,i,n,s){let r=t.textAfter,o=r.match(/^\s*/)[0].length,a=n&&r.slice(o,o+n.length)==n||s==t.pos+o,l=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let s=t.options.simulateBreak,r=t.state.doc.lineAt(i.from),o=null==s||s<=r.from?r.to:Math.min(r.to,s);for(let t=i.to;;){let s=e.childAfter(t);if(!s||s==n)return null;if(!s.type.isSkipped)return s.from{let n=t&&t.test(i.textAfter);return i.baseIndent+(n?0:e*i.unit)}}function nl(){return xt.transactionFilter.of((t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let i=t.newDoc,{head:n}=t.newSelection.main,s=i.lineAt(n);if(n>s.from+200)return t;let r=i.sliceString(s.from,n);if(!e.some((t=>t.test(r))))return t;let{state:o}=t,a=-1,l=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==a)continue;a=e.from;let i=Ba(o,e.from);if(null==i)continue;let n=/^\s*/.exec(e.text)[0],s=Ia(o,i);n!=s&&l.push({from:e.from,to:e.from+n.length,insert:s})}return l.length?[t,{changes:l,sequential:!0}]:t}))}const sl=E.define(),rl=new ho;function ol(t){let e=t.firstChild,i=t.lastChild;return e&&e.toi)continue;if(s&&r.from=e&&n.to>i&&(s=n)}}return s}(t,e,i)}function hl(t,e){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return i>=n?void 0:{from:i,to:n}}const cl=ut.define({map:hl}),ul=ut.define({map:hl}),dl=q.define({create:()=>ni.none,update(t,e){t=t.map(e.changes);for(let i of e.effects)i.is(cl)&&!pl(t,i.value.from,i.value.to)?t=t.update({add:[bl.range(i.value.from,i.value.to)]}):i.is(ul)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));if(e.selection){let i=!1,{head:n}=e.selection.main;t.between(n,n,((t,e)=>{tn&&(i=!0)})),i&&(t=t.update({filterFrom:n,filterTo:n,filter:(t,e)=>e<=n||t>=n}))}return t},provide:t=>Ts.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,((t,e)=>{i.push(t,e)})),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i{(!s||s.from>t)&&(s={from:t,to:e})})),s}function pl(t,e,i){let n=!1;return t.between(e,e,((t,s)=>{t==e&&s==i&&(n=!0)})),n}const Ol={placeholderDOM:null,placeholderText:"…"},gl=E.define({combine:t=>kt(t,Ol)});function ml(t){let e=[dl,Sl];return t&&e.push(gl.of(t)),e}const bl=ni.replace({widget:new class extends ei{toDOM(t){let{state:e}=t,i=e.facet(gl),n=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),n=fl(t.state,i.from,i.to);n&&t.dispatch({effects:ul.of(n)}),e.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(t,n);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",e.phrase("folded code")),s.title=e.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=n,s}}}),wl={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class vl extends Yr{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}const Sl=Ts.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"}});class yl{constructor(t,e){let i;function n(t){let e=It.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,r=e.scope;this.scope=r instanceof Pa?t=>t.prop(ka)==r.data:r?t=>t==r:void 0,this.style=sa(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:s}).style,this.module=i?new It(i):null,this.themeType=e.themeType}static define(t,e){return new yl(t,e||{})}}const xl=E.define(),kl=E.define({combine:t=>t.length?[t[0]]:null});function Ql(t){let e=t.facet(xl);return e.length?e:t.facet(kl)}function $l(t,e){let i,n=[Cl];return t instanceof yl&&(t.module&&n.push(Ts.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(kl.of(t)):i?n.push(xl.computeN([Ts.darkTheme],(e=>e.facet(Ts.darkTheme)==("dark"==i)?[t]:[]))):n.push(xl.of(t)),n}class Pl{constructor(t){this.markCache=Object.create(null),this.tree=Xa(t.state),this.decorations=this.buildDeco(t,Ql(t.state))}update(t){let e=Xa(t.state),i=Ql(t.state),n=i!=Ql(t.startState);e.length{i.add(t,e,this.markCache[n]||(this.markCache[n]=ni.mark({class:n})))}),n,s);return i.finish()}}const Cl=N.high(_i.fromClass(Pl,{decorations:t=>t.decorations})),_l=yl.define([{tag:ya.meta,color:"#404740"},{tag:ya.link,textDecoration:"underline"},{tag:ya.heading,textDecoration:"underline",fontWeight:"bold"},{tag:ya.emphasis,fontStyle:"italic"},{tag:ya.strong,fontWeight:"bold"},{tag:ya.strikethrough,textDecoration:"line-through"},{tag:ya.keyword,color:"#708"},{tag:[ya.atom,ya.bool,ya.url,ya.contentSeparator,ya.labelName],color:"#219"},{tag:[ya.literal,ya.inserted],color:"#164"},{tag:[ya.string,ya.deleted],color:"#a11"},{tag:[ya.regexp,ya.escape,ya.special(ya.string)],color:"#e40"},{tag:ya.definition(ya.variableName),color:"#00f"},{tag:ya.local(ya.variableName),color:"#30a"},{tag:[ya.typeName,ya.namespace],color:"#085"},{tag:ya.className,color:"#167"},{tag:[ya.special(ya.variableName),ya.macroName],color:"#256"},{tag:ya.definition(ya.propertyName),color:"#00c"},{tag:ya.comment,color:"#940"},{tag:ya.invalid,color:"#f00"}]),Xl=Ts.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Zl=1e4,Al="()[]{}",Tl=E.define({combine:t=>kt(t,{afterCursor:!0,brackets:Al,maxScanDistance:Zl,renderMatch:Vl})}),Rl=ni.mark({class:"cm-matchingBracket"}),El=ni.mark({class:"cm-nonmatchingBracket"});function Vl(t){let e=[],i=t.matched?Rl:El;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}const Ml=q.define({create:()=>ni.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let i=[],n=e.state.facet(Tl);for(let t of e.state.selection.ranges){if(!t.empty)continue;let s=Ll(e.state,t.head,-1,n)||t.head>0&&Ll(e.state,t.head-1,1,n)||n.afterCursor&&(Ll(e.state,t.head,1,n)||t.headTs.decorations.from(t)}),Dl=[Ml,Xl];function Wl(t={}){return[Tl.of(t),Dl]}const Ul=new ho;function Yl(t,e,i){let n=t.prop(e<0?ho.openedBy:ho.closedBy);if(n)return n;if(1==t.name.length){let n=i.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[i[n+e]]}return null}function ql(t){let e=t.type.prop(Ul);return e?e(t.node):t}function Ll(t,e,i,n={}){let s=n.maxScanDistance||Zl,r=n.brackets||Al,o=Xa(t),a=o.resolveInner(e,i);for(let n=a;n;n=n.parent){let s=Yl(n.type,i,r);if(s&&n.from0?e>=o.from&&eo.from&&e<=o.to))return zl(t,e,i,n,o,s,r)}}return function(t,e,i,n,s,r,o){let a=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=o.indexOf(a);if(l<0||l%2==0!=i>0)return null;let h={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=r;){let r=c.value;i<0&&(t+=r.length);let a=e+t*i;for(let t=i>0?0:r.length-1,e=i>0?r.length:-1;t!=e;t+=i){let e=o.indexOf(r[t]);if(!(e<0||n.resolveInner(a+t,1).type!=s))if(e%2==0==i>0)u++;else{if(1==u)return{start:h,end:{from:a+t,to:a+t+1},matched:e>>1==l>>1};u--}}i>0&&(t+=r.length)}return c.done?{start:h,matched:!1}:null}(t,e,i,o,a.type,s,r)}function zl(t,e,i,n,s,r,o){let a=n.parent,l={from:s.from,to:s.to},h=0,c=null==a?void 0:a.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do{if(i<0?c.to<=n.from:c.from>=n.to){if(0==h&&r.indexOf(c.type.name)>-1&&c.from=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pose}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPosi?t.toLowerCase():t;return n(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function jl(t){if("object"!=typeof t)return t;let e={};for(let i in t){let n=t[i];e[i]=n instanceof Array?n.slice():n}return e}const Nl=new WeakMap;class Gl extends Pa{constructor(t){let e,i=Qa(t.languageData),n={name:(s=t).name||"",token:s.token,blankLine:s.blankLine||(()=>{}),startState:s.startState||(()=>!0),copyState:s.copyState||jl,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||th};var s;super(i,new class extends Vo{createParse(t,i,n){return new Jl(e,t,i,n)}},[qa.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){let e=fo.define({id:eh.length,name:"Document",props:[ka.add((()=>t))]});return eh.push(e),e}(i),e=this,this.streamParser=n,this.stateAfter=new ho({perNode:!0}),this.tokenTable=t.tokenTable?new rh(n.tokenTable):oh}static define(t){return new Gl(t)}getIndent(t,e){let i,n=Xa(t.state),s=n.resolve(e);for(;s&&s.type!=this.topNode;)s=s.parent;if(!s)return null;let{overrideIndentation:r}=t.options;r&&(i=Nl.get(t.state),null!=i&&i1e4)return null;for(;o=n&&i+e.length<=s&&e.prop(t.stateAfter);if(r)return{state:t.streamParser.copyState(r),pos:i+e.length};for(let r=e.children.length-1;r>=0;r--){let o=e.children[r],a=i+e.positions[r],l=o instanceof bo&&a=e.length)return e;s||e.type!=t.topNode||(s=!0);for(let r=e.children.length-1;r>=0;r--){let o,a=e.positions[r],l=e.children[r];if(ai&&Fl(t,n.tree,0-n.offset,i,r);if(o&&(e=Hl(t,n.tree,i+n.offset,o.pos+n.offset,!1)))return{state:o.state,tree:e}}return{state:t.streamParser.startState(n?za(n):4),tree:bo.empty}}(t,i,r,null==s?void 0:s.state);this.state=o,this.parsedPos=this.chunkStart=r+a.length;for(let t=0;t=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),i=t+e.length;for(let t=this.rangeIndex;;){let n=this.ranges[t].to;if(n>=i)break;if(e=e.slice(0,n-(i-e.length)),t++,t==this.ranges.length)break;let s=this.ranges[t].from,r=this.lineAfter(s);e+=r,i=s+r.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let n=this.ranges[this.rangeIndex].to,s=t+e;if(i>0?n>s:n>=s)break;e+=this.ranges[++this.rangeIndex].from-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to1){e+=s=this.skipGapsTo(e,s,1);let t=this.chunk.length;i+=s=this.skipGapsTo(i,s,-1),n+=this.chunk.length-t}return this.chunk.push(t,e,i,n),s}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:s}=this.lang,r=new Bl(e,t?t.state.tabSize:4,t?za(t.state):2);if(r.eol())s.blankLine(this.state,r.indentUnit);else for(;!r.eol();){let t=Kl(s.token,r,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+r.start,this.parsedPos+r.pos,4,n)),r.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPose.start)return n}throw new Error("Stream parser failed to advance stream.")}const th=Object.create(null),eh=[fo.none],ih=new po(eh),nh=[],sh=Object.create(null);for(let[t,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"]])sh[t]=lh(th,e);class rh{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),sh)}resolve(t){return t?this.table[t]||(this.table[t]=lh(this.extra,t)):0}}const oh=new rh(th);function ah(t,e){nh.indexOf(t)>-1||(nh.push(t),console.warn(e))}function lh(t,e){let i=null;for(let n of e.split(".")){let e=t[n]||ya[n];e?"function"==typeof e?i?i=e(i):ah(n,`Modifier ${n} used at start of tag`):i?ah(n,`Tag ${n} used as modifier`):i=e:ah(n,`Unknown highlighting tag ${n}`)}if(!i)return 0;let n=e.replace(/ /g,"_"),s=fo.define({id:eh.length,name:n,props:[ea({[n]:i})]});return eh.push(s),s.id}function hh(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let s=t(e,i);return!!s&&(n(i.update(s)),!0)}}const ch=hh(gh,0),uh=hh(Oh,0),dh=hh(((t,e)=>Oh(t,e,function(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),s=i.to<=n.to?n:t.doc.lineAt(i.to),r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}(e))),0);function fh(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}const ph=50;function Oh(t,e,i=e.selection.ranges){let n=i.map((t=>fh(e,t.from).block));if(!n.every((t=>t)))return null;let s=i.map(((t,i)=>function(t,{open:e,close:i},n,s){let r,o,a=t.sliceDoc(n-ph,n),l=t.sliceDoc(s,s+ph),h=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(l)[0].length,u=a.length-h;if(a.slice(u-e.length,u)==e&&l.slice(c,c+i.length)==i)return{open:{pos:n-h,margin:h&&1},close:{pos:s+c,margin:c&&1}};s-n<=2*ph?r=o=t.sliceDoc(n,s):(r=t.sliceDoc(n,n+ph),o=t.sliceDoc(s-ph,s));let d=/^\s*/.exec(r)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-i.length;return r.slice(d,d+e.length)==e&&o.slice(p,p+i.length)==i?{open:{pos:n+d+e.length,margin:/\s/.test(r.charAt(d+e.length))?1:0},close:{pos:s-f-i.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(e,n[i],t.from,t.to)));if(2!=t&&!s.every((t=>t)))return{changes:e.changes(i.map(((t,e)=>s[e]?[]:[{from:t.from,insert:n[e].open+" "},{from:t.to,insert:" "+n[e].close}])))};if(1!=t&&s.some((t=>t))){let t=[];for(let e,i=0;is&&(t==r||r>l.from)){s=l.from;let t=/^\s*/.exec(l.text)[0].length,e=t==l.length,i=l.text.slice(t,t+a.length)==a?t:-1;tt.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:e,token:i,indent:s,empty:r,single:o}of n)!o&&r||t.push({from:e.from+s,insert:i+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,1)}}if(1!=t&&n.some((t=>t.comment>=0))){let t=[];for(let{line:e,comment:i,token:s}of n)if(i>=0){let n=e.from+i,r=n+s.length;" "==e.text[r-e.from]&&r++,t.push({from:n,to:r})}return{changes:t}}return null}const mh=lt.define(),bh=lt.define(),wh=E.define(),vh=E.define({combine:t=>kt(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})});const Sh=q.define({create:()=>Dh.empty,update(t,e){let i=e.state.facet(vh),n=e.annotation(mh);if(n){let s=e.docChanged?A.single(function(t){let e=0;return t.iterChangedRanges(((t,i)=>e=i)),e}(e.changes)):void 0,r=Ch.fromTransaction(e,s),o=n.side,a=0==o?t.undone:t.done;return a=r?_h(a,a.length,i.minDepth,r):Th(a,e.startState.selection),new Dh(0==o?n.rest:a,0==o?a:n.rest)}let s=e.annotation(bh);if("full"!=s&&"before"!=s||(t=t.isolate()),!1===e.annotation(dt.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let r=Ch.fromTransaction(e),o=e.annotation(dt.time),a=e.annotation(dt.userEvent);return r?t=t.addChanges(r,o,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,a,i.newGroupDelay)),"full"!=s&&"after"!=s||(t=t.isolate()),t},toJSON:t=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new Dh(t.done.map(Ch.fromJSON),t.undone.map(Ch.fromJSON))});function yh(t={}){return[Sh,vh.of(t),Ts.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?kh:"historyRedo"==t.inputType?Qh:null;return!!i&&(t.preventDefault(),i(e))}})]}function xh(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let s=i.field(Sh,!1);if(!s)return!1;let r=s.pop(t,i,e);return!!r&&(n(r),!0)}}const kh=xh(0,!1),Qh=xh(1,!1),$h=xh(0,!0),Ph=xh(1,!0);class Ch{constructor(t,e,i,n,s){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(t){return new Ch(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map((t=>t.toJSON()))}}static fromJSON(t){return new Ch(t.changes&&k.fromJSON(t.changes),[],t.mapped&&x.fromJSON(t.mapped),t.startSelection&&A.fromJSON(t.startSelection),t.selectionsAfter.map(A.fromJSON))}static fromTransaction(t,e){let i=Zh;for(let e of t.startState.facet(wh)){let n=e(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new Ch(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,Zh)}static selection(t){return new Ch(void 0,Zh,void 0,void 0,t)}}function _h(t,e,i,n){let s=e+1>i+20?e-i-1:0,r=t.slice(s,e);return r.push(n),r}function Xh(t,e){return t.length?e.length?t.concat(e):t:e}const Zh=[],Ah=200;function Th(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-Ah));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),_h(t,t.length-1,1e9,i.setSelAfter(n)))}return[Ch.selection([e])]}function Rh(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function Eh(t,e){if(!t.length)return t;let i=t.length,n=Zh;for(;i;){let s=Vh(t[i-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let e=t.slice(0,i);return e[i-1]=s,e}e=s.mapped,i--,n=s.selectionsAfter}return n.length?[Ch.selection(n)]:Zh}function Vh(t,e,i){let n=Xh(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):Zh,i);if(!t.changes)return Ch.selection(n);let s=t.changes.map(e),r=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(r):r;return new Ch(s,ut.mapEffects(t.effects,e),o,t.startSelection.map(r),n)}const Mh=/^(input\.type|delete)($|\.)/;class Dh{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Dh(this.done,this.undone):this}addChanges(t,e,i,n,s){let r=this.done,o=r[r.length-1];return r=o&&o.changes&&!o.changes.empty&&t.changes&&(!i||Mh.test(i))&&(!o.selectionsAfter.length&&e-this.prevTimei.push(t,e))),e.iterChangedRanges(((t,e,s,r)=>{for(let t=0;t=e&&s<=o&&(n=!0)}})),n}(o.changes,t.changes))||"input.type.compose"==i)?_h(r,r.length-1,n.minDepth,new Ch(t.changes.compose(o.changes),Xh(t.effects,o.effects),o.mapped,o.startSelection,Zh)):_h(r,r.length,n.minDepth,t),new Dh(r,Zh,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Zh;return s.length>0&&e-this.prevTimet.empty!=o.ranges[e].empty)).length)?this:new Dh(Th(this.done,t),this.undone,e,i);var r,o}addMapping(t){return new Dh(Eh(this.done,t),Eh(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=0==t?this.done:this.undone;if(0==n.length)return null;let s=n[n.length-1];if(i&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:mh.of({side:t,rest:Rh(n)}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let i=1==n.length?Zh:n.slice(0,n.length-1);return s.mapped&&(i=Eh(i,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:mh.of({side:t,rest:i}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}Dh.empty=new Dh(Zh,Zh);const Wh=[{key:"Mod-z",run:kh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Qh,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Qh,preventDefault:!0},{key:"Mod-u",run:$h,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Ph,preventDefault:!0}];function Uh(t,e){return A.create(t.ranges.map(e),t.mainIndex)}function Yh(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function qh({state:t,dispatch:e},i){let n=Uh(t.selection,i);return!n.eq(t.selection)&&(e(Yh(t,n)),!0)}function Lh(t,e){return A.cursor(e?t.to:t.from)}function zh(t,e){return qh(t,(i=>i.empty?t.moveByChar(i,e):Lh(i,e)))}function Ih(t){return t.textDirectionAt(t.state.selection.main.head)==Wi.LTR}const Bh=t=>zh(t,!Ih(t)),jh=t=>zh(t,Ih(t));function Nh(t,e){return qh(t,(i=>i.empty?t.moveByGroup(i,e):Lh(i,e)))}function Gh(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Fh(t,e,i){let n,s,r=Xa(t).resolveInner(e.head),o=i?ho.closedBy:ho.openedBy;for(let n=e.head;;){let e=i?r.childAfter(n):r.childBefore(n);if(!e)break;Gh(t,e,o)?r=e:n=i?e.to:e.from}return s=r.type.prop(o)&&(n=i?Ll(t,r.from,1):Ll(t,r.to,-1))&&n.matched?i?n.end.to:n.end.from:i?r.to:r.from,A.cursor(s,i?-1:1)}function Hh(t,e){return qh(t,(i=>{if(!i.empty)return Lh(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)}))}const Jh=t=>Hh(t,!1),Kh=t=>Hh(t,!0);function tc(t){let e,i=t.scrollDOM.clientHeighti.empty?t.moveVertically(i,e,n.height):Lh(i,e)));if(r.eq(s.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(s.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),a=o.top+n.marginTop,l=o.bottom-n.marginBottom;e&&e.top>a&&e.bottomec(t,!1),nc=t=>ec(t,!0);function sc(t,e,i){let n=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,i);if(s.head==e.head&&s.head!=(i?n.to:n.from)&&(s=t.moveToLineBoundary(e,i,!1)),!i&&s.head==n.from&&n.length){let i=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(s=A.cursor(n.from+i))}return s}function rc(t,e){let i=Uh(t.state.selection,(t=>{let i=e(t);return A.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)}));return!i.eq(t.state.selection)&&(t.dispatch(Yh(t.state,i)),!0)}function oc(t,e){return console.log("Select!"),rc(t,(i=>t.moveByCharSelected(i,e)))}const ac=t=>oc(t,!Ih(t)),lc=t=>oc(t,Ih(t));function hc(t,e){return rc(t,(i=>t.moveByGroup(i,e)))}function cc(t,e){return rc(t,(i=>t.moveVertically(i,e)))}const uc=t=>cc(t,!1),dc=t=>cc(t,!0);function fc(t,e){return rc(t,(i=>t.moveVertically(i,e,tc(t).height)))}const pc=t=>fc(t,!1),Oc=t=>fc(t,!0),gc=({state:t,dispatch:e})=>(e(Yh(t,{anchor:0})),!0),mc=({state:t,dispatch:e})=>(e(Yh(t,{anchor:t.doc.length})),!0),bc=({state:t,dispatch:e})=>(e(Yh(t,{anchor:t.selection.main.anchor,head:0})),!0),wc=({state:t,dispatch:e})=>(e(Yh(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function vc(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,s=n.changeByRange((n=>{let{from:s,to:r}=n;if(s==r){let n=e(s);ns&&(i="delete.forward",n=Sc(t,n,!0)),s=Math.min(s,n),r=Math.max(r,n)}else s=Sc(t,s,!1),r=Sc(t,r,!0);return s==r?{range:n}:{changes:{from:s,to:r},range:A.cursor(s)}}));return!s.changes.empty&&(t.dispatch(n.update(s,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?Ts.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function Sc(t,e,i){if(t instanceof Ts)for(let n of t.state.facet(Ts.atomicRanges).map((e=>e(t))))n.between(e,e,((t,n)=>{te&&(e=i?n:t)}));return e}const yc=(t,e)=>vc(t,(i=>{let n,s,{state:r}=t,o=r.doc.lineAt(i);if(!e&&i>o.from&&iyc(t,!1),kc=t=>yc(t,!0),Qc=(t,e)=>vc(t,(i=>{let n=i,{state:s}=t,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let t=null;;){if(n==(e?r.to:r.from)){n==i&&r.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let a=f(r.text,n-r.from,e)+r.from,l=r.text.slice(Math.min(n,a)-r.from,Math.max(n,a)-r.from),h=o(l);if(null!=t&&h!=t)break;" "==l&&n==i||(t=h),n=a}return n})),$c=t=>Qc(t,!1),Pc=t=>vc(t,(e=>{let i=t.lineBlockAt(e).to;return e=s.number){let t=e[e.length-1];t.to=r.to,t.ranges.push(n)}else e.push({from:s.from,to:r.to,ranges:[n]});i=r.number+1}return e}function _c(t,e,i){if(t.readOnly)return!1;let n=[],s=[];for(let e of Cc(t)){if(i?e.to==t.doc.length:0==e.from)continue;let r=t.doc.lineAt(i?e.to+1:e.from-1),o=r.length+1;if(i){n.push({from:e.to,to:r.to},{from:e.from,insert:r.text+t.lineBreak});for(let i of e.ranges)s.push(A.range(Math.min(t.doc.length,i.anchor+o),Math.min(t.doc.length,i.head+o)))}else{n.push({from:r.from,to:e.from},{from:e.to,insert:t.lineBreak+r.text});for(let t of e.ranges)s.push(A.range(t.anchor-o,t.head-o))}}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0,selection:A.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0)}function Xc(t,e,i){if(t.readOnly)return!1;let n=[];for(let e of Cc(t))i?n.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):n.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Zc=Ac(!1);function Ac(e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let s=i.changeByRange((n=>{let{from:s,to:r}=n,o=i.doc.lineAt(s),a=!e&&s==r&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=Xa(t).resolveInner(e),s=n.childBefore(e),r=n.childAfter(e);return s&&r&&s.to<=e&&r.from>=e&&(i=s.type.prop(ho.closedBy))&&i.indexOf(r.name)>-1&&t.doc.lineAt(s.to).from==t.doc.lineAt(r.from).from?{from:s.to,to:r.from}:null}(i,s);e&&(s=r=(r<=o.to?o:i.doc.lineAt(r)).to);let l=new ja(i,{simulateBreak:s,simulateDoubleBreak:!!a}),h=Ba(l,s);for(null==h&&(h=/^\s*/.exec(i.doc.lineAt(s).text)[0].length);ro.from&&s{let s=[];for(let r=n.from;r<=n.to;){let o=t.doc.lineAt(r);o.number>i&&(n.empty||n.to>o.from)&&(e(o,s,n),i=o.number),r=o.to+1}let r=t.changes(s);return{changes:s,range:A.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}}))}const Rc=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(Tc(t,((e,i)=>{i.push({from:e.from,insert:t.facet(La)})})),{userEvent:"input.indent"})),!0),Ec=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(Tc(t,((e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let s=Yt(n,t.tabSize),r=0,o=Ia(t,Math.max(0,s-za(t)));for(;rqh(t,(e=>Fh(t.state,e,!Ih(t)))),shift:t=>rc(t,(e=>Fh(t.state,e,!Ih(t))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>qh(t,(e=>Fh(t.state,e,Ih(t)))),shift:t=>rc(t,(e=>Fh(t.state,e,Ih(t))))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>_c(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>Xc(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>_c(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>Xc(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=A.create([i.main]):i.main.empty||(n=A.create([A.cursor(i.main.head)])),!!n&&(e(Yh(t,n)),!0)}},{key:"Mod-Enter",run:Ac(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=Cc(t).map((({from:e,to:i})=>A.range(e,Math.min(i+1,t.doc.length))));return e(t.update({selection:A.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=Uh(t.selection,(e=>{var i;let n=Xa(t).resolveInner(e.head,1);for(;!(n.from=e.to||n.to>e.to&&n.from<=e.from)&&(null===(i=n.parent)||void 0===i?void 0:i.parent);)n=n.parent;return A.range(n.to,n.from)}));return e(Yh(t,i)),!0},preventDefault:!0},{key:"Mod-[",run:Ec},{key:"Mod-]",run:Rc},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new ja(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),s=Tc(t,((e,s,r)=>{let o=Ba(n,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let a=/^\s*/.exec(e.text)[0],l=Ia(t,o);(a!=l||r.from{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(Cc(e).map((({from:t,to:i})=>(t>0?t--:it.moveVertically(e,!0))).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(t,e,i){let n=!1,s=Uh(t.selection,(e=>{let s=Ll(t,e.head,-1)||Ll(t,e.head,1)||e.head>0&&Ll(t,e.head-1,1)||e.head{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=fh(t.state,i.from);return n.line?ch(t):!!n.block&&dh(t)}},{key:"Alt-A",run:uh}].concat([{key:"ArrowLeft",run:Bh,shift:ac,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Nh(t,!Ih(t)),shift:t=>hc(t,!Ih(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>qh(t,(e=>sc(t,e,!Ih(t)))),shift:t=>rc(t,(e=>sc(t,e,!Ih(t)))),preventDefault:!0},{key:"ArrowRight",run:jh,shift:lc,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Nh(t,Ih(t)),shift:t=>hc(t,Ih(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>qh(t,(e=>sc(t,e,Ih(t)))),shift:t=>rc(t,(e=>sc(t,e,Ih(t)))),preventDefault:!0},{key:"ArrowUp",run:Jh,shift:uc,preventDefault:!0},{mac:"Cmd-ArrowUp",run:gc,shift:bc},{mac:"Ctrl-ArrowUp",run:ic,shift:pc},{key:"ArrowDown",run:Kh,shift:dc,preventDefault:!0},{mac:"Cmd-ArrowDown",run:mc,shift:wc},{mac:"Ctrl-ArrowDown",run:nc,shift:Oc},{key:"PageUp",run:ic,shift:pc},{key:"PageDown",run:nc,shift:Oc},{key:"Home",run:t=>qh(t,(e=>sc(t,e,!1))),shift:t=>rc(t,(e=>sc(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:gc,shift:bc},{key:"End",run:t=>qh(t,(e=>sc(t,e,!0))),shift:t=>rc(t,(e=>sc(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:mc,shift:wc},{key:"Enter",run:Zc},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:xc,shift:xc},{key:"Delete",run:kc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:$c},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>Qc(t,!0)},{mac:"Mod-Backspace",run:t=>vc(t,(e=>{let i=t.lineBlockAt(e).from;return e>i?i:Math.max(0,e-1)}))},{mac:"Mod-Delete",run:Pc}].concat([{key:"Ctrl-b",run:Bh,shift:ac,preventDefault:!0},{key:"Ctrl-f",run:jh,shift:lc},{key:"Ctrl-p",run:Jh,shift:uc},{key:"Ctrl-n",run:Kh,shift:dc},{key:"Ctrl-a",run:t=>qh(t,(e=>A.cursor(t.lineBlockAt(e.head).from,1))),shift:t=>rc(t,(e=>A.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>qh(t,(e=>A.cursor(t.lineBlockAt(e.head).to,-1))),shift:t=>rc(t,(e=>A.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:kc},{key:"Ctrl-h",run:xc},{key:"Ctrl-k",run:Pc},{key:"Ctrl-Alt-h",run:$c},{key:"Ctrl-o",run:({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t.of(["",""])},range:A.cursor(e.from)})));return i(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let i=e.from,n=t.doc.lineAt(i),s=i==n.from?i-1:f(n.text,i-n.from,!1)+n.from,r=i==n.to?i+1:f(n.text,i-n.from,!0)+n.from;return{changes:{from:s,to:r,insert:t.doc.slice(i,r).append(t.doc.slice(s,i))},range:A.cursor(r)}}));return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:nc}].map((t=>({mac:t.key,run:t.run,shift:t.shift}))))),Mc={key:"Tab",run:Rc,shift:Ec};function Dc(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var s=i[n];"string"==typeof s?t.setAttribute(n,s):null!=s&&(t[n]=s)}e++}for(;e