1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5762],{36433:function(t,e,i){let o;i.d(e,{$1:function(){return runScopeHandlers},$f:function(){return tO},AE:function(){return highlightSpecialChars},Eu:function(){return lineNumbers},HQ:function(){return highlightActiveLineGutter},Nm:function(){return j},OO:function(){return logException},S2:function(){return crosshairCursor},SJ:function(){return GutterMarker},Sd:function(){return getPanel},Uw:function(){return drawSelection},W$:function(){return placeholder},ZO:function(){return highlightActiveLine},Zs:function(){return rectangularSelection},bF:function(){return hoverTooltip},gB:function(){return getTooltip},hJ:function(){return t3},l9:function(){return WidgetType},lg:function(){return ViewPlugin},mH:function(){return et},p:function(){return Decoration},qr:function(){return dropCursor},tk:function(){return EditorView},v5:function(){return gutter}});var s,n,r,l=i(86166),h=i(77865),a=i(62063);function getSelection(t){return(11==t.nodeType?t.getSelection?t:t.ownerDocument:t).getSelection()}function contains(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function hasSelection(t,e){if(!e.anchorNode)return!1;try{return contains(t,e.anchorNode)}catch(t){return!1}}function clientRectsFor(t){return 3==t.nodeType?textRange(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function isEquivalentPosition(t,e,i,o){return!!i&&(scanFor(t,e,i,o,-1)||scanFor(t,e,i,o,1))}function domIndex(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function scanFor(t,e,i,o,s){for(;;){if(t==i&&e==o)return!0;if(e==(s<0?0:maxOffset(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=domIndex(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType||1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?maxOffset(t):0}}}function maxOffset(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}let c={left:0,right:0,top:0,bottom:0};function flattenRect(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}let DOMSelectionState=class DOMSelectionState{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){this.set(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}set(t,e,i,o){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=o}};let d=null;function focusPreventScroll(t){if(t.setActive)return t.setActive();if(d)return t.focus(d);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==d?{get preventScroll(){return d={preventScroll:!0},!0}}:void 0),!d){d=!1;for(let t=0;t<e.length;){let i=e[t++],o=e[t++],s=e[t++];i.scrollTop!=o&&(i.scrollTop=o),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function textRange(t,e,i=e){let s=o||(o=document.createRange());return s.setEnd(t,i),s.setStart(t,e),s}function dispatchKey(t,e,i){let o={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",o);s.synthetic=!0,t.dispatchEvent(s);let n=new KeyboardEvent("keyup",o);return n.synthetic=!0,t.dispatchEvent(n),s.defaultPrevented||n.defaultPrevented}function clearAttributes(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}let DOMPos=class DOMPos{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new DOMPos(t.parentNode,domIndex(t),e)}static after(t,e){return new DOMPos(t.parentNode,domIndex(t)+1,e)}};let u=[];let ContentView=class ContentView{constructor(){this.parent=null,this.dom=null,this.dirty=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}coordsAt(t,e){return null}sync(t,e){if(2&this.dirty){let i=this.dom,o=null,s;for(let n of this.children){if(n.dirty){if(!n.dom&&(s=o?o.nextSibling:i.firstChild)){let t=ContentView.get(s);(!t||!t.parent&&t.canReuseDOM(n))&&n.reuseDOM(s)}n.sync(t,e),n.dirty=0}if(s=o?o.nextSibling:i.firstChild,e&&!e.written&&e.node==i&&s!=n.dom&&(e.written=!0),n.dom.parentNode==i)for(;s&&s!=n.dom;)s=rm$1(s);else i.insertBefore(n.dom,s);o=n.dom}for((s=o?o.nextSibling:i.firstChild)&&e&&e.node==i&&(e.written=!0);s;)s=rm$1(s)}else if(1&this.dirty)for(let i of this.children)i.dirty&&(i.sync(t,e),i.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let o=0==maxOffset(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;
10==o&&e.firstChild!=e.lastChild&&(o=t==e.firstChild?-1:1),t=e}i=o<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!ContentView.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let o=this.children[t];if(o.dom==i)return e;e+=o.length+o.breakAfter}}domBoundsAround(t,e,i=0){let o=-1,s=-1,n=-1,r=-1;for(let l=0,h=i,a=i;l<this.children.length;l++){let i=this.children[l],c=h+i.length;if(h<t&&c>e)return i.domBoundsAround(t,e,h);if(c>=t&&-1==o&&(o=l,s=h),h>e&&i.dom.parentNode==this.dom){n=l,r=a;break}a=c,h=c+i.breakAfter}return{from:s,to:r<0?i+this.length:r,startDOM:(o?this.children[o-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:n<this.children.length&&n>=0?this.children[n].dom:null}}markDirty(t=!1){this.dirty|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.dirty|=2),1&e.dirty)return;e.dirty|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,this.dirty&&this.markParentsDirty(!0))}setDOM(t){this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=u){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new ChildCursor(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}merge(t,e,i,o,s,n){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}};function rm$1(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}ContentView.prototype.breakAfter=0;let ChildCursor=class ChildCursor{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}};function replaceRange(t,e,i,o,s,n,r,l,h){let{children:a}=t,c=a.length?a[e]:null,d=n.length?n[n.length-1]:null,u=d?d.breakAfter:r;if(!(e==o&&c&&!r&&!u&&n.length<2&&c.merge(i,s,n.length?d:null,0==i,l,h))){if(o<a.length){let t=a[o];t&&s<t.length?(e==o&&(t=t.split(s),s=0),!u&&d&&t.merge(0,s,d,!0,0,h)?n[n.length-1]=t:(s&&t.merge(0,s,null,!1,0,h),n.push(t))):(null==t?void 0:t.breakAfter)&&(d?d.breakAfter=1:r=1),o++}for(c&&(c.breakAfter=r,i>0&&(!r&&n.length&&c.merge(i,c.length,n[0],!1,l,0)?c.breakAfter=n.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,l,0),e++));e<o&&n.length;)if(a[o-1].become(n[n.length-1]))o--,n.pop(),h=n.length?0:l;else if(a[e].become(n[0]))e++,n.shift(),l=n.length?0:h;else break;!n.length&&e&&o<a.length&&!a[e-1].breakAfter&&a[o].merge(0,0,a[e-1],!1,l,h)&&e--,(e<o||n.length)&&t.replaceChildren(e,o,n)}}function mergeChildrenInto(t,e,i,o,s,n){let r=t.childCursor(),{i:l,off:h}=r.findPos(i,1),{i:a,off:c}=r.findPos(e,-1),d=e-i;for(let t of o)d+=t.length;t.length+=d,replaceRange(t,a,c,l,h,o,0,s,n)}let f="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},p="undefined"!=typeof document?document:{documentElement:{style:{}}},g=/Edge\/(\d+)/.exec(f.userAgent),m=/MSIE \d/.test(f.userAgent),w=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(f.userAgent),v=!!(m||w||g),b=!v&&/gecko\/(\d+)/i.test(f.userAgent),y=!v&&/Chrome\/(\d+)/.exec(f.userAgent),M="webkitFontSmoothing"in p.documentElement.style,x=!v&&/Apple Computer/.test(f.vendor),S=x&&(/Mobile\/\w+/.test(f.userAgent)||f.maxTouchPoints>2);var C={mac:S||/Mac/.test(f.platform),windows:/Win/.test(f.platform),linux:/Linux|X11/.test(f.platform),ie:v,ie_version:m?p.documentMode||6:w?+w[1]:g?+g[1]:0,gecko:b,gecko_version:b?
1+(/Firefox\/(\d+)/.exec(f.userAgent)||[0,0])[1]:0,chrome:!!y,chrome_version:y?+y[1]:0,ios:S,android:/Android\b/.test(f.userAgent),webkit:M,safari:x,webkit_version:M?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=p.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};let TextView=class TextView extends ContentView{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof TextView&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new TextView(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new DOMPos(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return textCoords(this.dom,t,e)}};let MarkView=class MarkView extends ContentView{constructor(t,e=[],i=0){for(let o of(super(),this.mark=t,this.children=e,this.length=i,e))o.setParent(this)}setAttrs(t){if(clearAttributes(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.dirty|=6)}sync(t,e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,o,s,n){return(!i||!!(i instanceof MarkView&&i.mark.eq(this.mark))&&(!t||!(s<=0))&&(!(e<this.length)||!(n<=0)))&&(mergeChildrenInto(this,t,e,i?i.children:[],s-1,n-1),this.markDirty(),!0)}split(t){let e=[],i=0,o=-1,s=0;for(let n of this.children){let r=i+n.length;r>t&&e.push(i<t?n.split(t-i):n),o<0&&i>=t&&(o=s),i=r,s++}let n=this.length-t;return this.length=t,o>-1&&(this.children.length=o,this.markDirty()),new MarkView(this.mark,e,n)}domAtPos(t){return inlineDOMAtPos(this,t)}coordsAt(t,e){return coordsInChildren(this,t,e)}};function textCoords(t,e,i){let o=t.nodeValue.length;e>o&&(e=o);let s=e,n=e,r=0;0==e&&i<0||e==o&&i>=0?!(C.chrome||C.gecko)&&(e?(s--,r=1):n<o&&(n++,r=-1)):i<0?s--:n<o&&n++;let l=textRange(t,s,n).getClientRects();if(!l.length)return c;let h=l[(r?r<0:i>=0)?0:l.length-1];return C.safari&&!r&&0==h.width&&(h=Array.prototype.find.call(l,t=>t.width)||h),r?flattenRect(h,r<0):h||null}let WidgetView=class WidgetView extends ContentView{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}static create(t,e,i){return new(t.customView||WidgetView)(t,e,i)}split(t){let e=WidgetView.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,o,s,n){return(!i||i instanceof WidgetView&&!!this.widget.compare(i.widget)&&(!(t>0)||!(s<=0))&&(!(e<this.length)||!(n<=0)))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t.length==this.length&&t instanceof WidgetView&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.eq(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return l.xv.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,o=this.posAtStart;return i?i.slice(o,o+this.length):l.xv.empty}domAtPos(t){return 0==t?DOMPos.before(this.dom):DOMPos.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.dom.getClientRects(),o=null;if(!i.length)return c;for(let e=t>0?i.length-1:0;o=i[e],t>0?0!=e:e!=i.length-1&&!(o.top<o.bottom);e+=t>0?-1:1);return this.length?o:flattenRect(o,this.side>0)}get isEditable(){return!1}get isWidget(){return!0}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}};let CompositionView=class CompositionView extends WidgetView{domAtPos(t){let{topView:e,text:i}=this.widget;return e?scanCompositionTree(t,0,e,i,(t,e)=>t.domAtPos(e),t=>new DOMPos(i,Math.min(t,i.nodeValue.length))):new DOMPos(i,Math.min(t,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(t,e){let{topView:i,text:o}=this.widget;return i?function posFromDOMInCompositionTree(t,e,i,o){if(i instanceof MarkView){let s=0;for(let n of i.children){let i=contains(n.dom,o);if(contains(n.dom,t))return s+(i?posFromDOMInCompositionTree(t,e,n,o):n.localPosFromDOM(t,e));s+=i?o.nodeValue.length:n.length}}else if(i.dom==o)return Math.min(e,o.nodeValue.length);return i.localPosFromDOM(t,e)}(t,e,i,o):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:o}=this.widget;return i?scanCompositionTree(t,e,i,o,(t,e,i)=>t.coordsAt(e,i),(t,e)=>textCoords(o,t,e)):textCoords(o,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}};function scanCompositionTree(t,e,i,o,s,n){if(i instanceof MarkView){for(let r=i.dom.firstChild;r;r=r.nextSibling){let i=ContentView.get(r);if(!i)return n(t,e);let l=contains(r,o),h=i.length+(l?o.nodeValue.length:0);if(t<h||t==h&&0>=i.getSide())return l?scanCompositionTree(t,e,i,o,s,n):s(i,t,e);t-=h}return s(i,i.length,-1)}return i.dom==o?n(t,e):s(i,t,e)}let WidgetBufferView=class WidgetBufferView extends ContentView{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof WidgetBufferView&&t.side==this.side}split(){return new WidgetBufferView(this.side)}sync(){if(!this.dom){let t=document.createElement("img");
1t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?DOMPos.before(this.dom):DOMPos.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){let e=this.dom.getBoundingClientRect(),i=function(t,e){let i=t.parent,o=i?i.children.indexOf(t):-1;for(;i&&o>=0;)if(e<0?o>0:o<i.children.length){let t=i.children[o+e];if(t instanceof TextView){let i=t.coordsAt(e<0?t.length:0,e);if(i)return i}o+=e}else if(i instanceof MarkView&&i.parent)o=i.parent.children.indexOf(i)+(e<0?0:1),i=i.parent;else{let t=i.dom.lastChild;if(t&&"BR"==t.nodeName)return t.getClientRects()[0];break}}(this,this.side>0?-1:1);return i&&i.top<e.bottom&&i.bottom>e.top?{left:e.left,right:e.right,top:i.top,bottom:i.bottom}:e}get overrideDOMText(){return l.xv.empty}};function inlineDOMAtPos(t,e){let i=t.dom,{children:o}=t,s=0;for(let t=0;s<o.length;s++){let n=o[s],r=t+n.length;if(!(r==t&&0>=n.getSide())){if(e>t&&e<r&&n.dom.parentNode==i)return n.domAtPos(e-t);if(e<=t)break;t=r}}for(let t=s;t>0;t--){let e=o[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<o.length;t++){let e=o[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new DOMPos(i,0)}function coordsInChildren(t,e,i){let o=null,s=-1,n=null,r=-1;!function scan(t,e){for(let i=0,l=0;i<t.children.length&&l<=e;i++){let h=t.children[i],a=l+h.length;a>=e&&(h.children.length?scan(h,e-l):!n&&(a>e||l==a&&h.getSide()>0)?(n=h,r=e-l):(l<e||l==a&&0>h.getSide())&&(o=h,s=e-l)),l=a}}(t,e);let l=(i<0?o:n)||o||n;return l?l.coordsAt(Math.max(0,l==o?s:r),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=clientRectsFor(e);return i[i.length-1]||null}(t)}function combineAttrs(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}function attrsEq(t,e){if(t==e)return!0;if(!t||!e)return!1;let i=Object.keys(t),o=Object.keys(e);if(i.length!=o.length)return!1;for(let s of i)if(-1==o.indexOf(s)||t[s]!==e[s])return!1;return!0}function updateAttrs(t,e,i){let o=null;if(e)for(let s in e)i&&s in i||t.removeAttribute(o=s);if(i)for(let s in i)e&&e[s]==i[s]||t.setAttribute(o=s,i[s]);return!!o}TextView.prototype.children=WidgetView.prototype.children=WidgetBufferView.prototype.children=u;let WidgetType=class WidgetType{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return -1}ignoreEvent(t){return!0}get customView(){return null}destroy(t){}};var k=((s=k||(k={}))[s.Text=0]="Text",s[s.WidgetBefore=1]="WidgetBefore",s[s.WidgetAfter=2]="WidgetAfter",s[s.WidgetRange=3]="WidgetRange",s);let Decoration=class Decoration extends l.uU{constructor(t,e,i,o){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=o}get heightRelevant(){return!1}static mark(t){return new MarkDecoration(t)}static widget(t){let e=t.side||0,i=!!t.block;return e+=i?e>0?3e8:-4e8:e>0?1e8:-1e8,new PointDecoration(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,o;if(t.isBlockGap)i=-5e8,o=4e8;else{let{start:s,end:n}=getInclusive(t,e);i=(s?e?-3e8:-1:5e8)-1,o=(n?e?2e8:1:-6e8)+1}return new PointDecoration(t,i,o,e,t.widget||null,!0)}static line(t){return new LineDecoration(t)}static set(t,e=!1){return l.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}};Decoration.none=l.Xs.empty;let MarkDecoration=class MarkDecoration extends Decoration{constructor(t){let{start:e,end:i}=getInclusive(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){return this==t||t instanceof MarkDecoration&&this.tagName==t.tagName&&this.class==t.class&&attrsEq(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw RangeError("Mark decorations may not be empty");return super.range(t,e)}};MarkDecoration.prototype.point=!1;let LineDecoration=class LineDecoration extends Decoration{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof LineDecoration&&this.spec.class==t.spec.class&&attrsEq(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}};
1LineDecoration.prototype.mapMode=l.gc.TrackBefore,LineDecoration.prototype.point=!0;let PointDecoration=class PointDecoration extends Decoration{constructor(t,e,i,o,s,n){super(e,i,s,t),this.block=o,this.isReplace=n,this.mapMode=o?e<=0?l.gc.TrackBefore:l.gc.TrackAfter:l.gc.TrackDel}get type(){return this.startSide<this.endSide?k.WidgetRange:this.startSide<=0?k.WidgetBefore:k.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}eq(t){var e,i;return t instanceof PointDecoration&&((e=this.widget)==(i=t.widget)||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}};function getInclusive(t,e=!1){let{inclusiveStart:i,inclusiveEnd:o}=t;return null==i&&(i=t.inclusive),null==o&&(o=t.inclusive),{start:null!=i?i:e,end:null!=o?o:e}}function addRange(t,e,i,o=0){let s=i.length-1;s>=0&&i[s]+o>=t?i[s]=Math.max(i[s],e):i.push(t,e)}PointDecoration.prototype.point=!0;let LineView=class LineView extends ContentView{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,o,s,n){if(i){if(!(i instanceof LineView))return!1;this.dom||i.transferDOM(this)}return o&&this.setDeco(i?i.attrs:null),mergeChildrenInto(this,t,e,i?i.children:[],s,n),!0}split(t){let e=new LineView;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:o}=this.childPos(t);o&&(e.append(this.children[i].split(o),0),this.children[i].merge(o,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){attrsEq(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){!function joinInlineInto(t,e,i){let o,{children:s}=t;i>0&&e instanceof MarkView&&s.length&&(o=s[s.length-1])instanceof MarkView&&o.mark.eq(e.mark)?joinInlineInto(o,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=combineAttrs(e,this.attrs||{})),i&&(this.attrs=combineAttrs({class:i},this.attrs||{}))}domAtPos(t){return inlineDOMAtPos(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(clearAttributes(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(updateAttrs(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let o=this.dom.lastChild;for(;o&&ContentView.get(o) instanceof MarkView;)o=o.lastChild;if(!o||!this.length||"BR"!=o.nodeName&&(null===(i=ContentView.get(o))||void 0===i?void 0:i.isEditable)==!1&&(!C.ios||!this.children.some(t=>t instanceof TextView))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t=0,e;for(let i of this.children){if(!(i instanceof TextView)||/[^ -~]/.test(i.text))return null;let o=clientRectsFor(i.dom);
1if(1!=o.length)return null;t+=o[0].width,e=o[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(t,e){let i=coordsInChildren(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(2>Math.abs(e-t.lineHeight)&&t.textHeight<e){let o=(e-t.textHeight)/2;return{top:i.top+o,bottom:i.bottom-o,left:i.left,right:i.left}}}return i}become(t){return!1}get type(){return k.Text}static find(t,e){for(let i=0,o=0;i<t.children.length;i++){let s=t.children[i],n=o+s.length;if(n>=e){if(s instanceof LineView)return s;if(n>e)break}o=n+s.breakAfter}return null}};let BlockWidgetView=class BlockWidgetView extends ContentView{constructor(t,e,i){super(),this.widget=t,this.length=e,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,o,s,n){return(!i||i instanceof BlockWidgetView&&!!this.widget.compare(i.widget)&&(!(t>0)||!(s<=0))&&(!(e<this.length)||!(n<=0)))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?DOMPos.before(this.dom):DOMPos.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new BlockWidgetView(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return u}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):l.xv.empty}domBoundsAround(){return null}become(t){return t instanceof BlockWidgetView&&t.type==this.type&&t.widget.constructor==this.widget.constructor&&(t.widget.eq(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}};let ContentBuilder=class ContentBuilder{constructor(t,e,i,o){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=o,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!t.breakAfter&&!(t instanceof BlockWidgetView&&t.type==k.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new LineView),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(wrapMarks(new WidgetBufferView(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:o}=this.cursor.next(this.skip);if(this.skip=0,o)throw Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let o=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+o)),e),i),this.atCursorPos=!0,this.textOff+=o,t-=o,i=0}}span(t,e,i,o){this.buildText(e-t,i,o),this.pos=e,this.openStart<0&&(this.openStart=o)}point(t,e,i,o,s,n){if(this.disallowBlockEffectsFor[n]&&i instanceof PointDecoration){if(i.block)throw RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof PointDecoration){if(i.block){let{type:t}=i;t!=k.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new BlockWidgetView(i.widget||new NullWidget("div"),r,t))}else{let n=WidgetView.create(i.widget||new NullWidget("span"),r,r?0:i.startSide),l=this.atCursorPos&&!n.isEditable&&s<=o.length&&(t<e||i.startSide>0),h=!n.isEditable&&(t<e||s>o.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||l||(this.pendingBuffer=0),this.flushBuffer(o),l&&(a.append(wrapMarks(new WidgetBufferView(1),o),s),s=o.length+Math.max(0,s-o.length)),a.append(wrapMarks(n,o),s),this.atCursorPos=h,this.pendingBuffer=h?t<e||s>o.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=o.slice())}}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,o,s){let n=new ContentBuilder(t,e,i,s);return n.openEnd=l.Xs.spans(o,e,i,n),n.openStart<0&&(n.openStart=n.openEnd),n.finish(n.openEnd),n}};
1function wrapMarks(t,e){for(let i of e)t=new MarkView(i,[t],t.length);return t}let NullWidget=class NullWidget extends WidgetType{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}};let D=l.r$.define(),T=l.r$.define(),A=l.r$.define(),O=l.r$.define(),V=l.r$.define(),E=l.r$.define(),B=l.r$.define(),R=l.r$.define({combine:t=>t.some(t=>t)}),L=l.r$.define({combine:t=>t.some(t=>t)});let ScrollTarget=class ScrollTarget{constructor(t,e="nearest",i="nearest",o=5,s=5){this.range=t,this.y=e,this.x=i,this.yMargin=o,this.xMargin=s}map(t){return t.empty?this:new ScrollTarget(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}};let P=l.Py.define({map:(t,e)=>t.map(e)});function logException(t,e,i){let o=t.facet(O);o.length?o[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}let H=l.r$.define({combine:t=>!t.length||t[0]}),W=0,N=l.r$.define();let ViewPlugin=class ViewPlugin{constructor(t,e,i,o){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=o(this)}static define(t,e){let{eventHandlers:i,provide:o,decorations:s}=e||{};return new ViewPlugin(W++,t,i,t=>{let e=[N.of(t)];return s&&e.push(z.of(e=>{let i=e.plugin(t);return i?s(i):Decoration.none})),o&&e.push(o(t)),e})}static fromClass(t,e){return ViewPlugin.define(e=>new t(e),e)}};let PluginInstance=class PluginInstance{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(logException(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){logException(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){logException(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}};let F=l.r$.define(),I=l.r$.define(),z=l.r$.define(),G=l.r$.define(),q=l.r$.define(),K=l.r$.define();let ChangedRange=class ChangedRange{constructor(t,e,i,o){this.fromA=t,this.toA=e,this.fromB=i,this.toB=o}join(t){return new ChangedRange(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let o=t[e-1];if(!(o.fromA>i.toA)){if(o.toA<i.fromA)break;i=i.join(o),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let o=0,s=0,n=0,r=0;;o++){let l=o==t.length?null:t[o],h=n-r,a=l?l.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],o=e[s+1],n=Math.max(r,t),l=Math.min(a,o);if(n<=l&&new ChangedRange(n+h,l+h,n,l).addToSet(i),o>a)break;s+=2}if(!l)return i;new ChangedRange(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),n=l.toA,r=l.toB}}};let ViewUpdate=class ViewUpdate{constructor(t,e,i){for(let o of(this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=l.as.empty(this.startState.doc.length),i))this.changes=this.changes.compose(o.changes);let o=[];this.changes.iterChangedRanges((t,e,i,s)=>o.push(new ChangedRange(t,e,i,s))),this.changedRanges=o}static create(t,e,i){return new ViewUpdate(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}};var j=((n=j||(j={}))[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n);let $=j.LTR,X=j.RTL;function dec(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}let _=dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),U=dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Y=Object.create(null),Q=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Y[e]=i,Y[i]=-e}let Z=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;let BidiSpan=class BidiSpan{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?X:$}side(t,e){return this.dir==e==t?this.to:this.from}static find(t,e,i,o){let s=-1;for(let n=0;n<t.length;n++){let r=t[n];if(r.from<=e&&r.to>=e){if(r.level==i)return n;(s<0||(0!=o?o<0?r.from<e:r.to>e:t[s].level>r.level))&&(s=n)}}if(s<0)throw RangeError("Index out of range");return s}};let J=[];function trivialOrder(t){return[new BidiSpan(0,t,0)]}let tt="";let DOMReader=class DOMReader{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(l.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+="ï¿¿"}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let o=t;;){this.findPointBefore(i,o),this.readNode(o);let t=o.nextSibling;if(t==e)break;let s=ContentView.get(o),n=ContentView.get(t);(s&&n?s.breakAfter:(s?s.breakAfter:isBlockElement(o))||isBlockElement(t)&&("BR"!=o.nodeName||o.cmIgnore))&&this.lineBreak(),o=t}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,n=1,r;if(this.lineSeparator?(s=e.indexOf(this.lineSeparator,i),n=this.lineSeparator.length):(r=o.exec(e))&&(s=r.index,n=r[0].length),this.append(e.slice(i,s<0?e.length:s)),s<0)break;if(this.lineBreak(),n>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=n-1);i=s+n}}readNode(t){if(t.cmIgnore)return;let e=ContentView.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+Math.min(e,i.offset))}};function isBlockElement(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.no
1deName)}let DOMPoint=class DOMPoint{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}};let DocView=class DocView extends ContentView{constructor(t){super(),this.view=t,this.compositionDeco=Decoration.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new LineView],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ChangedRange(0,0,0,t.state.doc.length)],0)}get length(){return this.view.state.doc.length}update(t){var e,i,o;let s,n=t.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=Decoration.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=function(t,e){let i=compositionSurroundingNode(t);if(!i)return Decoration.none;let{from:o,to:s,node:n,text:r}=i,l=e.mapPos(o,1),h=Math.max(l,e.mapPos(s,-1)),{state:a}=t,c=3==n.nodeType?n.nodeValue:new DOMReader([],a).readRange(n.firstChild,null).text;if(h-l<c.length){if(a.doc.sliceString(l,Math.min(a.doc.length,l+c.length),"ï¿¿")==c)h=l+c.length;else{if(a.doc.sliceString(Math.max(0,h-c.length),h,"ï¿¿")!=c)return Decoration.none;l=h-c.length}}else if(a.doc.sliceString(l,h,"ï¿¿")!=c)return Decoration.none;let d=ContentView.get(n);return d instanceof CompositionView?d=d.widget.topView:d&&(d.parent=null),Decoration.set(Decoration.replace({widget:new CompositionWidget(n,r,d),inclusive:!0}).range(l,h))}(this.view,t.changes)),(C.ie||C.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=(e=this.decorations,i=this.updateDeco(),o=t.changes,s=new DecorationComparator$1,l.Xs.compare(e,i,o,s),s.changes);return n=ChangedRange.extendWithRanges(n,r),(0!=this.dirty||0!=n.length)&&(this.updateInner(n,t.startState.doc.length),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e);let{observer:i}=this.view;i.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=C.chrome||C.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.dirty=0,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""});let o=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof BlockWidgetView&&t.widget instanceof BlockGapWidget&&o.push(t.dom);i.updateGaps(o)}updateChildren(t,e){let i=this.childCursor(e);for(let e=t.length-1;;e--){let o=e>=0?t[e]:null;if(!o)break;let{fromA:s,toA:n,fromB:r,toB:l}=o,{content:h,breakAtStart:a,openStart:c,openEnd:d}=ContentBuilder.build(this.view.state.doc,r,l,this.decorations,this.dynamicDecorationMap),{i:u,off:f}=i.findPos(n,1),{i:p,off:g}=i.findPos(s,-1);replaceRange(this,p,g,u,f,h,a,c,d)}}updateSelection(t=!1,e=!1){var i;if((t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange(),!(e||this.mayControlSelection()))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,n=this.domAtPos(s.anchor),r=s.empty?n:this.domAtPos(s.head);if(C.gecko&&s.empty&&1==(i=n).node.nodeType&&i.node.firstChild&&(0==i.offset||"false"==i.node.childNodes[i.offset-1].contentEditable)&&(i.offset==i.node.childNodes.length||"false"==i.node.childNodes[i.offset].contentEditable)){let t=document.createTextNode("");this.view.observer.ignore(()=>n.node.insertBefore(t,n.node.childNodes[n.offset]||null)),n=r=new DOMPos(t,0),o=!0}let l=this.view.observer.selectionRange;!o&&l.focusNode&&isEquivalentPosition(n.node,n.offset,l.anchorNode,l.anchorOffset)&&isEquivalentPosition(r.node,r.offset,l.focusNode,l.focusOffset)||(this.view.observer.ignore(()=>{C.android&&C.chrome&&this.dom.contains(l.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(l.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=getSelection(this.view.root);
1if(t){if(s.empty){if(C.gecko){var e,i;let t=(e=n.node,i=n.offset,1!=e.nodeType?0:(i&&"false"==e.childNodes[i-1].contentEditable?1:0)|(i<e.childNodes.length&&"false"==e.childNodes[i].contentEditable?2:0));if(t&&3!=t){let e=nearbyTextNode(n.node,n.offset,1==t?1:-1);e&&(n=new DOMPos(e,1==t?0:e.nodeValue.length))}}t.collapse(n.node,n.offset),null!=s.bidiLevel&&null!=l.cursorBidiLevel&&(l.cursorBidiLevel=s.bidiLevel)}else if(t.extend){t.collapse(n.node,n.offset);try{t.extend(r.node,r.offset)}catch(t){}}else{let e=document.createRange();s.anchor>s.head&&([n,r]=[r,n]),e.setEnd(r.node,r.offset),e.setStart(n.node,n.offset),t.removeAllRanges(),t.addRange(e)}}}),this.view.observer.setSelectionRange(n,r)),this.impreciseAnchor=n.precise?null:new DOMPos(l.anchorNode,l.anchorOffset),this.impreciseHead=r.precise?null:new DOMPos(l.focusNode,l.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=getSelection(t.root),{anchorNode:o,anchorOffset:s}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let n=LineView.find(this,e.head);if(!n)return;let r=n.posAtStart;if(e.head==r||e.head==r+n.length)return;let l=this.coordsAt(e.head,-1),h=this.coordsAt(e.head,1);if(!l||!h||l.bottom>h.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(o,s)}mayControlSelection(){let t=this.view.root.activeElement;return t==this.dom||hasSelection(this.dom,this.view.observer.selectionRange)&&!(t&&this.dom.contains(t))}nearest(t){for(let e=t;e;){let t=ContentView.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof LineView)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){for(let i=this.length,o=this.children.length-1;;o--){let s=this.children[o],n=i-s.breakAfter-s.length;if(t>n||t==n&&s.type!=k.WidgetBefore&&s.type!=k.WidgetAfter&&(!o||2==e||this.children[o-1].breakAfter||this.children[o-1].type==k.WidgetBefore&&e>-2))return s.coordsAt(t-n,e);i=n}}measureVisibleLineHeights(t){let e=[],{from:i,to:o}=t,s=this.view.contentDOM.clientWidth,n=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,l=this.view.textDirection==j.LTR;for(let t=0,h=0;h<this.children.length;h++){let a=this.children[h],c=t+a.length;if(c>o)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),n){let e=a.dom.lastChild,o=e?clientRectsFor(e):[];if(o.length){let e=o[o.length-1],n=l?e.right-i.left:i.right-e.left;n>r&&(r=n,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?j.RTL:j.LTR}measureTextSize(){for(let t of this.children)if(t instanceof LineView){let e=t.measureTextSize();if(e)return e}let t=document.createElement("div"),e,i,o;return t.className="cm-line",t.style.width="99999px",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(t);let s=clientRectsFor(t.firstChild)[0];e=t.getBoundingClientRect().height,i=s?s.width/27:7,o=s?s.height:e,t.remove()}),{lineHeight:e,charWidth:i,textHeight:o}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ChildCursor(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,o=0;;o++){let s=o==e.viewports.length?null:e.viewports[o],n=s?s.from-1:this.length;if(n>i){let o=e.lineBlockAt(n).bottom-e.lineBlockAt(i).top;t.push(Decoration.replace({widget:new BlockGapWidget(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,n))}if(!s)break;i=s.to+1}return Decoration.set(t)}updateDeco(){let t=this.view.state.facet(z).map((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t);for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){let{range:e}=t,i=this.coordsAt(e.head,e.empty?e.assoc:e.head>e.anchor?-1:1),o;if(!i)return;!e.empty&&(o=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,o.left),top:Math.min(i.top,o.top),right:Math.max(i.right,o.right),bottom:Math.max(i.bottom,o.bottom)});let s=0,n=0,r=0,l=0;for(let t of this.view.state.facet(q).map(t=>t(this.view)))if(t){let{left:e,right:i,top:o,bottom:h}=t;null!=e&&(s=Math.max(s,e)),null!=i&&(n=Math.max(n,i)),null!=o&&(r=Math.max(r,o)),null!=h&&(l=Math.max(l,h))}let h={left:i.left-s,top:i.top-r,right:i.right+n,bottom:i.bottom+l};
1!function(t,e,i,o,s,n,r,l){let h=t.ownerDocument,a=h.defaultView||window;for(let c=t;c;)if(1==c.nodeType){let t,d=c==h.body;if(d)t={left:0,right:a.innerWidth,top:0,bottom:a.innerHeight};else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();t={left:e.left,right:e.left+c.clientWidth,top:e.top,bottom:e.top+c.clientHeight}}let u=0,f=0;if("nearest"==s)e.top<t.top?(f=-(t.top-e.top+r),i>0&&e.bottom>t.bottom+f&&(f=e.bottom-t.bottom+f+r)):e.bottom>t.bottom&&(f=e.bottom-t.bottom+r,i<0&&e.top-f<t.top&&(f=-(t.top+f-e.top+r)));else{let o=e.bottom-e.top,n=t.bottom-t.top;f=("center"==s&&o<=n?e.top+o/2-n/2:"start"==s||"center"==s&&i<0?e.top-r:e.bottom-n+r)-t.top}if("nearest"==o?e.left<t.left?(u=-(t.left-e.left+n),i>0&&e.right>t.right+u&&(u=e.right-t.right+u+n)):e.right>t.right&&(u=e.right-t.right+n,i<0&&e.left<t.left+u&&(u=-(t.left+u-e.left+n))):u=("center"==o?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==o==l?e.left-n:e.right-(t.right-t.left)+n)-t.left,u||f){if(d)a.scrollBy(u,f);else{let t=0,i=0;if(f){let t=c.scrollTop;c.scrollTop+=f,i=c.scrollTop-t}if(u){let e=c.scrollLeft;c.scrollLeft+=u,t=c.scrollLeft-e}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&1>Math.abs(t-u)&&(o="nearest"),i&&1>Math.abs(i-f)&&(s="nearest")}}if(d)break;c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,h,e.head<e.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==j.LTR)}};let BlockGapWidget=class BlockGapWidget extends WidgetType{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}};function compositionSurroundingNode(t){let e=t.observer.selectionRange,i=e.focusNode&&nearbyTextNode(e.focusNode,e.focusOffset,0);if(!i)return null;let o=t.docView.nearest(i);if(!o)return null;if(o instanceof LineView){let t=i;for(;t.parentNode!=o.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!ContentView.get(e);)e=e.previousSibling;let s=e?ContentView.get(e).posAtEnd:o.posAtStart;return{from:s,to:s,node:t,text:i}}{for(;;){let{parent:t}=o;if(!t)return null;if(t instanceof LineView)break;o=t}let t=o.posAtStart;return{from:t,to:t+o.length,node:o.dom,text:i}}}let CompositionWidget=class CompositionWidget extends WidgetType{constructor(t,e,i){super(),this.top=t,this.text=e,this.topView=i}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return CompositionView}};function nearbyTextNode(t,e,i){if(i<=0)for(let i=t,o=e;;){if(3==i.nodeType)return i;if(1==i.nodeType&&o>0)o=maxOffset(i=i.childNodes[o-1]);else break}if(i>=0)for(let o=t,s=e;;){if(3==o.nodeType)return o;if(1==o.nodeType&&s<o.childNodes.length&&i>=0)o=o.childNodes[s],s=0;else break}return null}let DecorationComparator$1=class DecorationComparator$1{constructor(){this.changes=[]}compareRange(t,e){addRange(t,e,this.changes)}comparePoint(t,e){addRange(t,e,this.changes)}};function yOverlap(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function upTop(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function upBot(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function domPosInText(t,e,i){let o=t.nodeValue.length,s=-1,n=1e9,r=0;for(let l=0;l<o;l++){let o=textRange(t,l,l+1).getClientRects();for(let h=0;h<o.length;h++){let a=o[h];if(a.top==a.bottom)continue;r||(r=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<n){let i=e>=(a.left+a.right)/2,o=i;if((C.chrome||C.gecko)&&textRange(t,l).getBoundingClientRect().left==a.right&&(o=!i),c<=0)return{node:t,offset:l+(o?1:0)};s=l+(o?1:0),n=c}}}return{node:t,offset:s>-1?s:r>0?t.nodeValue.length:0}}function posAtCoords(t,e,i,o=-1){var s,n;let r=t.contentDOM.getBoundingClientRect(),l=r.top+t.viewState.paddingTop,h,{docHeight:a}=t.viewState,{x:c,y:d}=e,u=d-l;if(u<0)return 0;if(u>a)return t.state.doc.length;for(let e=t.defaultLineHeight/2,s=!1;(h=t.elementAtHeight(u)).type!=k.Text;)for(;!((u=o>0?h.bottom+e:h.top-e)>
1=0)||!(u<=a);){if(s)return i?null:0;s=!0,o=-o}d=l+u;let f=h.from;if(f<t.viewport.from)return 0==t.viewport.from?0:i?null:posAtCoordsImprecise(t,r,h,c,d);if(f>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:posAtCoordsImprecise(t,r,h,c,d);let p=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:p,m=g.elementFromPoint(c,d);m&&!t.contentDOM.contains(m)&&(m=null),!m&&(c=Math.max(r.left+1,Math.min(r.right-1,c)),(m=g.elementFromPoint(c,d))&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable)!=!1){if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,d);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,d);e&&({startContainer:w,startOffset:v}=e,(!t.contentDOM.contains(w)||C.safari&&function(t,e,i){let o;if(3!=t.nodeType||e!=(o=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return textRange(t,o-1,o).getBoundingClientRect().left>i}(w,v,c)||C.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}return i-(1==t.nodeType?t.getBoundingClientRect():textRange(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}(w,v,c))&&(w=void 0))}}if(!w||!t.docView.dom.contains(w)){let e=LineView.find(t.docView,f);if(!e)return u>h.top+h.height/2?h.to:h.from;({node:w,offset:v}=function domPosAtCoords(t,e,i){let o,s,n,r,l,h,a,c,d=!1;for(let p=t.firstChild;p;p=p.nextSibling){let t=clientRectsFor(p);for(let g=0;g<t.length;g++){var u,f;let m=t[g];h&&yOverlap(h,m)&&(m=upTop(upBot(m,h.bottom),h.top));let w=(u=m).left>e?u.left-e:Math.max(0,e-u.right),v=(f=m).top>i?f.top-i:Math.max(0,i-f.bottom);if(0==w&&0==v)return 3==p.nodeType?domPosInText(p,e,i):domPosAtCoords(p,e,i);if(!l||c>v||c==v&&a>w){l=p,h=m,a=w,c=v;let o=v?i<m.top?-1:1:w?e<m.left?-1:1:0;d=!o||(o>0?g<t.length-1:g>0)}0==w?i>m.bottom&&(!n||n.bottom<m.bottom)?(o=p,n=m):i<m.top&&(!r||r.top>m.top)&&(s=p,r=m):n&&yOverlap(n,m)?n=upBot(n,m.bottom):r&&yOverlap(r,m)&&(r=upTop(r,m.top))}}if(n&&n.bottom>=i?(l=o,h=n):r&&r.top<=i&&(l=s,h=r),!l)return{node:t,offset:0};let p=Math.max(h.left,Math.min(h.right,e));if(3==l.nodeType)return domPosInText(l,p,i);if(d&&"false"!=l.contentEditable)return domPosAtCoords(l,p,i);let g=Array.prototype.indexOf.call(t.childNodes,l)+(e>=(h.left+h.right)/2?1:0);return{node:t,offset:g}}(e.dom,c,d))}let b=t.docView.nearest(w);if(!b)return null;if(!b.isWidget||(null===(n=b.dom)||void 0===n?void 0:n.nodeType)!=1)return b.localPosFromDOM(w,v)+b.posAtStart;{let t=b.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?b.posAtStart:b.posAtEnd}}function posAtCoordsImprecise(t,e,i,o,s){let n=Math.round((o-e.left)*t.defaultCharacterWidth);t.lineWrapping&&i.height>1.5*t.defaultLineHeight&&(n+=Math.floor((s-i.top)/t.defaultLineHeight)*t.viewState.heightOracle.lineLength);let r=t.state.sliceDoc(i.from,i.to);return i.from+(0,l.Gz)(r,n,t.state.tabSize)}function moveByChar(t,e,i,o){let s=t.state.doc.lineAt(e.head),n=t.bidiSpans(s),r=t.textDirectionAt(s.from);for(let h=e,a=null;;){let e=function(t,e,i,o,s){var n;let r=o.head-t.from,h=-1;if(0==r){if(!s||!t.length)return null;e[0].level!=i&&(r=e[0].side(!1,i),h=0)}else if(r==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(r=t.side(!0,i),h=e.length-1)}h<0&&(h=BidiSpan.find(e,r,null!==(n=o.bidiLevel)&&void 0!==n?n:-1,o.assoc));let a=e[h];r==a.side(s,i)&&(r=(a=e[h+=s?1:-1]).side(!s,i));let c=s==(a.dir==i),d=(0,l.cp)(t.text,r,c);if(tt=t.text.slice(Math.min(r,d),Math.max(r,d)),d!=a.side(s,i))return l.jT.cursor(d+t.from,c?-1:1,a.level);let u=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return u||a.level==i?u&&u.level<a.level?l.jT.cursor(u.side(!s,i)+t.from,s?1:-1,u.level):l.jT.cursor(d+t.from,s?-1:1,a.level):l.jT.cursor(s?t.to:t.from,s?-1:1,i)}(s,n,r,h,i),c=tt;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;c="\n",s=t.state.doc.line(s.number+(i?1:-1)),n=t.bidiSpans(s),e=l.jT.cursor(i?s.from:s.to)}if(a){if(!a(c))return h}else{if(!o)return e;a=o(c)}h=e}}function skipAtoms(t,e,i){let o=t.state.facet(G).map(e=>e(t));for(;;){let t=!1;for(let s of o)s.between(i.from-1,i.from+1,(o,s,n)=>{i.from>o&&i.from<s&&(i=e.head>i.from?l.jT.cursor(o,1):l.jT.cursor(s,-1),t=!0)});if(!t)return i}}let InputState=class InputState{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.mouseSelection=null;let handleEvent=(e,i)=>{!this.ignoreDuringComposition(i)&&("keydown"==i.type&&this.keydown(t,i)||(this.mustFlushObserver(i)&&t.observer.forceFlush(),this.runCustomHandlers(i.type,t,i)?i.preventDefault():e(t,i)))};for(let e in ts){let i=ts[e];t.contentDOM.addEventListener(e,e=>{eventBelongsToEditor(t,e)&&handleEvent(i,e)},tn[e]),this.registeredEvents.push(e)}t.scrollDOM.addEventListener("mousedown",e=>{if(e.target==t.scrollDOM&&e.clientY>t.contentDOM.getBoundingClientRect().bottom&&(handleEvent(ts.mousedown,e),!e.defaultPrevented&&2==e.button)){let e=t.contentDOM.style.minHeight;t.contentDOM.style.minHeight="100%",setTimeout(()=>t.contentDOM.style.minHeight=e,200)}}),C.chrome&&102==C.chrome_version&&t.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?t.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,t.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=t.hasFocus,C.safari&&t.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t,e){var i;let o;for(let s of(this.customHandlers=[],e))if(o=null===(i=s.update(t).spec)||void 0===i?void 0:i.domEventHandlers)for(let e in this.customHandlers.push({plugin:s.value,handlers:o}),o)0>this.registeredEvents.indexOf(e)&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,i=>{eventBelongsToEditor(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()}))}runCustomHandlers(t,e,i){for(let o of this.customHandlers){let s=o.handlers[t];if(s)try{if(s.call(o.plugin,i,e)||i.defaultPrevented)return!0}catch(t){logException(e.state,t)}}return!1}runScrollHandlers(t,e){for(let i of(this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft,this.customHandlers)){let o=i.handlers.scroll;if(o)try{o.call(i.plugin,e,t)}
1catch(e){logException(t.state,e)}}}keydown(t,e){let i;return this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!!(9==e.keyCode&&Date.now()<this.lastEscPress+2e3)||(C.android&&C.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode)?(t.observer.delayAndroidKey(e.key,e.keyCode),!0):!!(C.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((i=te.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||ti.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey))&&(this.pendingIOSKey=i||e,setTimeout(()=>this.flushIOSKey(t),250),!0))}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,dispatchKey(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(C.safari&&!C.ios&&Date.now()-this.compositionEndedAt<100)&&(this.compositionEndedAt=0,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};let te=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ti="dthko",to=[16,17,18,20,91,92,224,225];function dragScrollSpeed(t){return .7*t+8}let MouseSelection=class MouseSelection{constructor(t,e,i,o){let s,n;this.view=t,this.style=i,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else if(11==i.nodeType)i=i.host;else break;return null}(t.contentDOM);let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(l.yy.allowMultipleSelections)&&((s=t.state.facet(D)).length?s[0](e):C.mac?e.metaKey:e.ctrlKey),this.dragMove=(n=t.state.facet(T)).length?n[0](e):C.mac?!e.altKey:!e.ctrlKey,this.dragging=!!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let o=getSelection(t.root);if(!o||0==o.rangeCount)return!0;let s=o.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)&&1==getClickType(e)&&null}start(t){!1===this.dragging&&(t.preventDefault(),this.select(t))}move(t){var e;if(0==t.buttons)return this.destroy();if(!1!==this.dragging)return;this.select(this.lastEvent=t);let i=0,o=0,s=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight};t.clientX<=s.left?i=-dragScrollSpeed(s.left-t.clientX):t.clientX>=s.right&&(i=dragScrollSpeed(t.clientX-s.right)),t.clientY<=s.top?o=-dragScrollSpeed(s.top-t.clientY):t.clientY>=s.bottom&&(o=dragScrollSpeed(t.clientY-s.bottom)),this.setScrollSpeed(i,o)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}select(t){let e=this.style.get(t,this.extend,this.multiple);(this.mustSelect||!e.eq(this.view.state.selection)||e.main.assoc!=this.view.state.selection.main.assoc)&&this.view.dispatch({selection:e,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}};function eventBelongsToEditor(t,e){if(!e.bubbles)return!0;
1if(e.defaultPrevented)return!1;for(let i=e.target,o;i!=t.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(o=ContentView.get(i))&&o.ignoreEvent(e))return!1;return!0}let ts=Object.create(null),tn=Object.create(null),tr=C.ie&&C.ie_version<15||C.ios&&C.webkit_version<604;function doPaste(t,e){let{state:i}=t,o,s=1,n=i.toText(e),r=n.lines==i.selection.ranges.length;if(null!=td&&i.selection.ranges.every(t=>t.empty)&&td==n.toString()){let t=-1;o=i.changeByRange(o=>{let h=i.doc.lineAt(o.from);if(h.from==t)return{range:o};t=h.from;let a=i.toText((r?n.line(s++).text:e)+i.lineBreak);return{changes:{from:h.from,insert:a},range:l.jT.cursor(o.from+a.length)}})}else o=r?i.changeByRange(t=>{let e=n.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:l.jT.cursor(t.from+e.length)}}):i.replaceSelection(n);t.dispatch(o,{userEvent:"input.paste",scrollIntoView:!0})}function rangeForClick(t,e,i,o){if(1==o)return l.jT.cursor(e,i);if(2==o)return function(t,e,i=1){let o=t.charCategorizer(e),s=t.doc.lineAt(e),n=e-s.from;if(0==s.length)return l.jT.cursor(e);0==n?i=1:n==s.length&&(i=-1);let r=n,h=n;i<0?r=(0,l.cp)(s.text,n,!1):h=(0,l.cp)(s.text,n);let a=o(s.text.slice(r,h));for(;r>0;){let t=(0,l.cp)(s.text,r,!1);if(o(s.text.slice(t,r))!=a)break;r=t}for(;h<s.length;){let t=(0,l.cp)(s.text,h);if(o(s.text.slice(h,t))!=a)break;h=t}return l.jT.range(r+s.from,h+s.from)}(t.state,e,i);{let i=LineView.find(t.docView,e),o=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:o.from,n=i?i.posAtEnd:o.to;return n<t.state.doc.length&&n==o.to&&n++,l.jT.range(s,n)}}ts.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode?t.inputState.lastEscPress=Date.now():0>to.indexOf(e.keyCode)&&(t.inputState.lastEscPress=0)},ts.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},ts.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},tn.touchstart=tn.touchmove={passive:!0},ts.mousedown=(t,e)=>{let i,o,s;if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let n=null;for(let i of t.state.facet(A))if(n=i(t,e))break;if(n||0!=e.button||(i=queryPos(t,e),o=getClickType(e),s=t.state.selection,n={update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,n,r){let h=queryPos(t,e),a=rangeForClick(t,h.pos,h.bias,o);if(i.pos!=h.pos&&!n){let e=rangeForClick(t,i.pos,i.bias,o),s=Math.min(e.from,a.from),n=Math.max(e.to,a.to);a=s<a.from?l.jT.range(s,n):l.jT.range(n,s)}return n?s.replaceRange(s.main.extend(a.from,a.to)):r&&s.ranges.length>1&&s.ranges.some(t=>t.eq(a))?function(t,e){for(let i=0;;i++)if(t.ranges[i].eq(e))return l.jT.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}(s,a):r?s.addRange(a):l.jT.create([a])}}),n){let i=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new MouseSelection(t,e,n,i)),i&&t.observer.ignore(()=>focusPreventScroll(t.contentDOM)),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let insideY=(t,e)=>t>=e.top&&t<=e.bottom,inside=(t,e,i)=>insideY(e,i)&&t>=i.left&&t<=i.right;function queryPos(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:function(t,e,i,o){let s=LineView.find(t.docView,e);if(!s)return 1;let n=e-s.posAtStart;if(0==n)return 1;if(n==s.length)return -1;let r=s.coordsAt(n,-1);if(r&&inside(i,o,r))return -1;let l=s.coordsAt(n,1);return l&&inside(i,o,l)?1:r&&insideY(o,r)?-1:1}(t,i,e.clientX,e.clientY)}}let tl=C.ie&&C.ie_version<=11,th=null,ta=0,tc=0;function getClickType(t){if(!tl)return t.detail;let e=th,i=tc;return th=t,tc=Date.now(),ta=!e||i>Date.now()-400&&2>Math.abs(e.clientX-t.clientX)&&2>Math.abs(e.clientY-t.clientY)?(ta+1)%3:1}function dropText(t,e,i,o){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:n}=t.inputState,r=o&&n&&n.dragging&&n.dragMove?{from:n.dragging.from,to:n.dragging.to}:null,l={from:s,insert:i},h=t.state.changes(r?[r,l]:l);t.focus(),t.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:r?"move.drop":"input.drop"})}ts.dragstart=(t,e)=>{let{selection:{main:i}}=t.state,{mouseSelection:o}=t.inputState;o&&(o.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},ts.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let i=e.dataTransfer.files;if(i&&i.length){e.preventDefault();let o=Array(i.length),s=0,finishFile=()=>{++s==i.length&&dropText(t,e,o.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=finishFile,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(o[t]=e.result),finishFile()},e.readAsText(i[t])}}else dropText(t,e,e.dataTransfer.getData("Text"),!0)},ts.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=tr?null:e.clipboardData;i?(doPaste(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),doPaste(t,i.value)},50)}(t)};let td=null;ts.copy=ts.cut=(t,e)=>{let{text:i,ranges:o,linewise:s}=function(t){let e=[],i=[],o=!1;for(let o of t.selection.ranges)o.empty||(e.push(t.sliceDoc(o.from,o.to)),i.push(o));if(!e.length){let s=-1;for(let{from:o}of t.selection.ranges){let n=t.doc.lineAt(o);n.number>s&&(e.push(n.text),i.push({from:n.from,to:Math.min(t.doc.length,n.to+1)})),s=n.number}o=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:o}}(t.state);if(!i&&!s)return;td=s?i:null;let n=tr?null:e.clipboardData;n?(e.preventDefault(),n.clearData(),n.setData("text/plain",i)):function(t,e){let i=t.dom.parentNode;if(!i)return;let o=i.appendChild(document.createElement("textarea"));o.style.cssText="position: fixed; left: -10000px; top: 10px",o.value=e,o.focus(),o.selectionEnd=e.length,o.selectionStart=0,setTimeout(()=>{o.remove(),t.focus()},50)}(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:o,scrollIntoView:!0,userEvent:"delete.cut"})};let tu=l.q6.define();function focusChangeTransaction(t,e){let i=[];for(let o of t.facet(B)){let s=o(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:tu.of(!0)}):null}function updateForFocusChange(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=focusChangeTransaction(t.state,e);i?t.dispatch(i):t.update([])}},10)}ts.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),updateForFocusChange(t)}
1,ts.blur=t=>{t.observer.clearSelectionRange(),updateForFocusChange(t)},ts.compositionstart=ts.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},ts.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionFirstChange=null,C.chrome&&C.android&&t.observer.flushSoon(),setTimeout(()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])},50)},ts.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},ts.beforeinput=(t,e)=>{var i;let o;if(C.chrome&&C.android&&(o=te.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(o.key,o.keyCode),"Backspace"==o.key||"Delete"==o.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}};let tf=["pre-wrap","normal","pre-line","break-spaces"];let HeightOracle=class HeightOracle{constructor(t){this.lineWrapping=t,this.doc=l.xv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return tf.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let o=t[i];o<0?i++:this.heightSamples[Math.floor(10*o)]||(e=!0,this.heightSamples[Math.floor(10*o)]=!0)}return e}refresh(t,e,i,o,s,n){let r=tf.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=o,this.lineLength=s,l){this.heightSamples={};for(let t=0;t<n.length;t++){let e=n[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return l}};let MeasuredHeights=class MeasuredHeights{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}};let BlockInfo=class BlockInfo{constructor(t,e,i,o,s){this.from=t,this.length=e,this.top=i,this.height=o,this.type=s}get to(){return this.from+this.length}get bottom(){return this.top+this.height}join(t){let e=(Array.isArray(this.type)?this.type:[this]).concat(Array.isArray(t.type)?t.type:[t]);return new BlockInfo(this.from,this.length+t.length,this.top,this.height+t.height,e)}};var tp=((r=tp||(tp={}))[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r);let HeightMap=class HeightMap{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>.001&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return HeightMap.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,o){let s=this,n=i.doc;for(let r=o.length-1;r>=0;r--){let{fromA:l,toA:h,fromB:a,toB:c}=o[r],d=s.lineAt(l,tp.ByPosNoHeight,i.setDoc(e),0,0),u=d.to>=h?d:s.lineAt(h,tp.ByPosNoHeight,i,0,0);for(c+=u.to-h,h=u.to;r>0&&d.from<=o[r-1].toA;)l=o[r-1].fromA,a=o[r-1].fromB,r--,l<d.from&&(d=s.lineAt(l,tp.ByPosNoHeight,i,0,0));a+=d.from-l,l=d.from;let f=NodeBuilder.build(i.setDoc(n),t,a,c);s=s.replace(l,h,f)}return s.updateHeight(i,0)}static empty(){return new HeightMapText(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,o=0,s=0;for(;;)if(e==i){if(o>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,o-=s.size}else if(s>2*o){let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}else break}else if(o<s){let i=t[e++];i&&(o+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let n=0;return null==t[e-1]?(n=1,e--):null==t[e]&&(n=1,i++),new HeightMapBranch(HeightMap.of(t.slice(0,e)),n,HeightMap.of(t.slice(i)))}};HeightMap.prototype.size=1;let HeightMapBlock=class HeightMapBlock extends HeightMap{constructor(t,e,i){super(t,e),this.type=i}blockAt(t,e,i,o){return new BlockInfo(o,this.length,i,this.height,this.type)}lineAt(t,e,i,o,s){return this.blockAt(0,i,o,s)}forEachLine(t,e,i,o,s,n){t<=s+this.length&&e>=s&&n(this.blockAt(0,i,o,s))}updateHeight(t,e=0,i=!1,o){return o&&o.from<=e&&o.more&&this.setHeight(t,o.heights[o.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}};let HeightMapText=class HeightMapText extends HeightMapBlock{constructor(t,e){super(t,e,k.Text),this.collapsed=0,this.widgetHeight=0}replace(t,e,i){let o=i[0];return 1==i.length&&(o instanceof HeightMapText||o instanceof HeightMapGap&&4&o.flags)&&10>Math.abs(this.length-o.length)?(o instanceof HeightMapGap?o=new HeightMapText(o.length,this.height):o.height=this.height,this.outdated||(o.outdated=!1),o):HeightMap.of(i)}updateHeight(t,e=0,i=!1,o){return o&&o.from<=e&&o.more?this.setHeight(t,o.heights[o.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}};let HeightMapGap=class HeightMapGap extends HeightMap{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,o=t.doc.lineAt(e+this.length).number,s=o-i+1,n,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*s);n=e/s,r=(this.height-e)/(this.length-s-1)}else n=this.height/s;return{firstLine:i,lastLine:o,perLine:n,perChar:r}}blockAt(t,e,i,o){let{firstLine:s,lastLine:n,perLine:r,perChar:l}=this.heightMetrics(e,o);if(e.lineWrapping){let s=o+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),n=e.doc.lineAt(s),h=r+n.length*l,a=Math.max(i,t-h/2);return new BlockInfo(n.from,n.length,a,h,k.Text)}{let o=Math.max(0,Math.min(n-s,Math.floor((t-i)/r))),{from:l,length:h}=e.doc.line(s+o);return new BlockInfo(l,h,i+r*o,r,k.Text)}}
vendor: 4,445 bytes, line 1
1lineAt(t,e,i,o,s){if(e==tp.ByHeight)return this.blockAt(t,i,o,s);if(e==tp.ByPosNoHeight){let{from:e,to:o}=i.doc.lineAt(t);return new BlockInfo(e,o-e,0,0,k.Text)}let{firstLine:n,perLine:r,perChar:l}=this.heightMetrics(i,s),h=i.doc.lineAt(t),a=r+h.length*l,c=h.number-n,d=o+r*c+l*(h.from-s-c);return new BlockInfo(h.from,h.length,Math.max(o,Math.min(d,o+this.height-a)),a,k.Text)}forEachLine(t,e,i,o,s,n){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:r,perLine:l,perChar:h}=this.heightMetrics(i,s);for(let a=t,c=o;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-r;c+=l*i+h*(t-s-i)}let o=l+h*e.length;n(new BlockInfo(e.from,e.length,c,o,k.Text)),c+=o,a=e.to+1}}replace(t,e,i){let o=this.length-e;if(o>0){let t=i[i.length-1];t instanceof HeightMapGap?i[i.length-1]=new HeightMapGap(t.length+o):i.push(null,new HeightMapGap(o-1))}if(t>0){let e=i[0];e instanceof HeightMapGap?i[0]=new HeightMapGap(t+e.length):i.unshift(new HeightMapGap(t-1),null)}return HeightMap.of(i)}decomposeLeft(t,e){e.push(new HeightMapGap(t-1),null)}decomposeRight(t,e){e.push(null,new HeightMapGap(this.length-t-1))}updateHeight(t,e=0,i=!1,o){let s=e+this.length;if(o&&o.from<=e+this.length&&o.more){let i=[],n=Math.max(e,o.from),r=-1;for(o.from>e&&i.push(new HeightMapGap(o.from-e-1).updateHeight(t,e));n<=s&&o.more;){let e=t.doc.lineAt(n).length;i.length&&i.push(null);let s=o.heights[o.index++];-1==r?r=s:Math.abs(s-r)>=.001&&(r=-2);let l=new HeightMapText(e,s);l.outdated=!1,i.push(l),n+=e+1}n<=s&&i.push(null,new HeightMapGap(s-n).updateHeight(t,n));let l=HeightMap.of(i);return(r<0||Math.abs(l.height-this.height)>=.001||Math.abs(r-this.heightMetrics(t,e).perLine)>=.001)&&(t.heightChanged=!0),l}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}};let HeightMapBranch=class HeightMapBranch extends HeightMap{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,o){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,o):this.right.blockAt(t,e,s,o+this.left.length+this.break)}lineAt(t,e,i,o,s){let n=o+this.left.height,r=s+this.left.length+this.break,l=e==tp.ByHeight?t<n:t<r,h=l?this.left.lineAt(t,e,i,o,s):this.right.lineAt(t,e,i,n,r);if(this.break||(l?h.to<r:h.from>r))return h;let a=e==tp.ByPosNoHeight?tp.ByPosNoHeight:tp.ByPos;return l?h.join(this.right.lineAt(r,a,i,n,r)):this.left.lineAt(r,a,i,o,s).join(h)}forEachLine(t,e,i,o,s,n){let r=o+this.left.height,l=s+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,o,s,n),e>=l&&this.right.forEachLine(t,e,i,r,l,n);else{let h=this.lineAt(l,tp.ByPos,i,o,s);t<h.from&&this.left.forEachLine(t,h.from-1,i,o,s,n),h.to>=t&&h.from<=e&&n(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,r,l,n)}}replace(t,e,i){let o=this.left.length+this.break;if(e<o)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-o,e-o,i));let s=[];t>0&&this.decomposeLeft(t,s);let n=s.length;for(let t of i)s.push(t);if(t>0&&mergeGaps(s,n-1),e<this.length){let t=s.length;this.decomposeRight(e,s),mergeGaps(s,t)}return HeightMap.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&t>=++i&&e.push(null),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,o=i+this.break;if(t>=o)return this.right.decomposeRight(t-o,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<o&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?HeightMap.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,o){let{left:s,right:n}=this,r=e+s.length+this.break,l=null;return(o&&o.from<=e+s.length&&o.more?l=s=s.updateHeight(t,e,i,o):s.updateHeight(t,e,i),o&&o.from<=r+n.length&&o.more?l=n=n.updateHeight(t,r,i,o):n.updateHeight(t,r,i),l)?this.balanced(s,n):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function mergeGaps(t,e){let i,o;null==t[e]&&(i=t[e-1])instanceof HeightMapGap&&(o=t[e+1])instanceof HeightMapGap&&t.splice(e-1,3,new He
1ightMapGap(i.length+1+o.length))}let NodeBuilder=class NodeBuilder{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof HeightMapText?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new HeightMapText(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let o=i.widget?i.widget.estimatedHeight:0;o<0&&(o=this.oracle.lineHeight);let s=e-t;i.block?this.addBlock(new HeightMapBlock(s,o,i.type)):(s||o>=5)&&this.addLineDeco(o,s)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new HeightMapText(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new HeightMapGap(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof HeightMapText)return t;let e=new HeightMapText(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine(),t.type!=k.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=k.WidgetBefore&&(this.covering=t)}addLineDeco(t,e){let i=this.ensureLine();i.length+=e,i.collapsed+=e,i.widgetHeight=Math.max(i.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof HeightMapText||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new HeightMapText(0,-1));let i=t;for(let t of this.nodes)t instanceof HeightMapText&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,o){let s=new NodeBuilder(i,t);return l.Xs.spans(e,i,o,s,0),s.finish(i)}};let DecorationComparator=class DecorationComparator{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,o){(t<e||i&&i.heightRelevant||o&&o.heightRelevant)&&addRange(t,e,this.changes,5)}};let LineGap=class LineGap{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let o=t[i],s=e[i];if(o.from!=s.from||o.to!=s.to||o.size!=s.size)return!1}return!0}draw(t){return Decoration.replace({widget:new LineGapWidget(this.size,t)}).range(this.from,this.to)}};let LineGapWidget=class LineGapWidget extends WidgetType{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}};let ViewState=class ViewState{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaler=tg,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=j.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(I).some(t=>"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new HeightOracle(e),this.stateDeco=t.facet(z).filter(t=>"function"!=typeof t),this.heightMap=HeightMap.empty().applyChanges(this.stateDeco,l.xv.empty,this.heightOracle.setDoc(t.doc),[new ChangedRange(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Decoration.set(this.lineGaps.map(t=>t.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let o=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>o>=t&&o<=e)){let{from:e,to:i}=this.lineBlockAt(o);t.push(new Viewport(e,i))}}this.viewports=t.sort((t,e)=>t.from-e.from),this.scaler=this.heightMap.height<=7e6?tg:new BigScaler(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEac
1hLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(1==this.scaler.scale?t:scaleBlock(t,this.scaler))})}update(t,e=null){var i,o;let s;this.state=t.state;let n=this.stateDeco;this.stateDeco=this.state.facet(z).filter(t=>"function"!=typeof t);let r=t.changedRanges,h=ChangedRange.extendWithRanges(r,(i=this.stateDeco,o=t?t.changes:l.as.empty(this.state.doc.length),s=new DecorationComparator,l.Xs.compare(n,i,o,s,0),s.changes)),a=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),h),this.heightMap.height!=a&&(t.flags|=2);let c=h.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<c.from||e.range.head>c.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,e));let d=!t.changes.empty||2&t.flags||c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,this.updateForViewport(),d&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(L)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),o=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?j.RTL:j.LTR;let n=this.heightOracle.mustRefreshForWrapping(s),r=e.getBoundingClientRect(),h=n||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let a=0,c=0,d=parseInt(i.paddingTop)||0,u=parseInt(i.paddingBottom)||0;(this.paddingTop!=d||this.paddingBottom!=u)&&(this.paddingTop=d,this.paddingBottom=u,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(o.lineWrapping&&(h=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let f=(this.printing?function(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}:function(t,e){let i=t.getBoundingClientRect(),o=t.ownerDocument,s=o.defaultView||window,n=Math.max(0,i.left),r=Math.min(s.innerWidth,i.right),l=Math.max(0,i.top),h=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=o.body;)if(1==e.nodeType){let i=e,o=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=o.overflow){let o=i.getBoundingClientRect();n=Math.max(n,o.left),r=Math.min(r,o.right),l=Math.max(l,o.top),h=e==t.parentNode?o.bottom:Math.min(h,o.bottom)}e="absolute"==o.position||"fixed"==o.position?i.offsetParent:i.parentNode}else if(11==e.nodeType)e=e.host;else break;return{left:n-i.left,right:Math.max(n,r)-i.left,top:l-(i.top+e),bottom:Math.max(l,h)-(i.top+e)}})(e,this.paddingTop),p=f.top-this.pixelViewport.top,g=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;
1if(m!=this.inView&&(this.inView=m,m&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let w=r.width;if((this.contentDOMWidth!=w||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=r.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),h){let e=t.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(e)&&(n=!0),n||o.lineWrapping&&Math.abs(w-this.contentDOMWidth)>o.charWidth){let{lineHeight:i,charWidth:r,textHeight:l}=t.docView.measureTextSize();(n=i>0&&o.refresh(s,i,r,l,w/r,e))&&(t.docView.minWidth=0,a|=8)}for(let i of(p>0&&g>0?c=Math.max(p,g):p<0&&g<0&&(c=Math.min(p,g)),o.heightChanged=!1,this.viewports)){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(n?HeightMap.empty().applyChanges(this.stateDeco,l.xv.empty,this.heightOracle,[new ChangedRange(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(o,0,n,new MeasuredHeights(i.from,s))}o.heightChanged&&(a|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&a||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(n?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),o=this.heightMap,s=this.heightOracle,{visibleTop:n,visibleBottom:r}=this,l=new Viewport(o.lineAt(n-1e3*i,tp.ByHeight,s,0,0).from,o.lineAt(r+(1-i)*1e3,tp.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),n=o.lineAt(t,tp.ByPos,s,0,0),r;r="center"==e.y?(n.top+n.bottom)/2-i/2:"start"==e.y||"nearest"==e.y&&t<l.from?n.top:n.bottom-i,l=new Viewport(o.lineAt(r-500,tp.ByHeight,s,0,0).from,o.lineAt(r+i+500,tp.ByHeight,s,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),o=e.mapPos(t.to,1);return new Viewport(this.heightMap.lineAt(i,tp.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(o,tp.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:o}=this.heightMap.lineAt(t,tp.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,tp.ByPos,this.heightOracle,0,0),{visibleTop:n,visibleBottom:r}=this;return(0==t||o<=n-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=r+Math.max(10,Math.min(i,250)))&&o>n-2e3&&s<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let o of t)e.touchesRange(o.from,o.to)||i.push(new LineGap(e.mapPos(o.from),e.mapPos(o.to),o.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,o=i?1e4:2e3,s=o>>1,n=o<<1;if(this.defaultTextDirection!=j.LTR&&!i)return[];let r=[],addGap=(o,n,h,a)=>{if(n-o<s)return;let c=this.state.selection.main,d=[c.from];for(let t of(c.empty||d.push(c.to),d))if(t>o&&t<n){addGap(o,t-10,h,a),addGap(t+10,n,h,a);return}let u=function(t,e){for(let i of t)if(e(i))return i}(t,t=>t.from>=h.from&&t.to<=h.to&&Math.abs(t.from-o)<s&&Math.abs(t.to-n)<s&&!d.some(e=>t.from<e&&t.to>e));if(!u){if(n<h.to&&e&&i&&e.visibleRanges.some(t=>t.from<=n&&t.to>=n)){let t=e.moveToLineBoundary(l.jT.cursor(n),!1,!0).head;t>o&&(n=t)}u=new LineGap(o,n,this.gapSize(h,o,n,a))}r.push(u)};for(let t of this.viewportLines){let e,s;if(t.length<n)continue;let r=function(t,e,i){let o=[],s=t,n=0;return l.Xs.spans(i,t,e,{span(){},point(t,e){t>s&&(o.push({from:s,to:t}),n+=t-s),s=e}},20),s<e&&(o.push({from:s,to:e}),n+=e-s),{total:n,ranges:o}}(t.from,t.to,this.stateDeco);if(r.total<n)continue;let h=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,n,l=o/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=h){let e=findFraction(r,h),o=((this.visibleBottom-this.visibleTop)/2+l)/t.height;i=e-o,n=e+o}else i=(this.visibleTop-t.top-l)/t.height,n=(this.visibleBottom-t.top+l)/t.height;e=findPosition(r,i),s=findPosition(r,n)}else{let t,i,n=r.total*this.heightOracle.charWidth,l=o*this.heightOracle.charWidth;if(null!=h){let e=findFraction(r,h),o=((this.pixelViewport.right-this.pixelViewport.left)/2+l)/n;t=e-o,i=e+o}else t=(this.pixelViewport.left-l)/n,i=(this.pixelViewport.right+l)/n;e=findPosition(r,t),s=findPosition(r,i)}e>t.from&&addGap(t.from,e,t,r),s<t.to&&addGap(s,t.to,t,r)}return r}gapSize(t,e,i,o){let s=findFraction(o,i)-findFraction(o,e);return this.heightOracle.lineWrapping?t.height*s:o.total*this.heightOracle.charWidth*s}updateLineGaps(t){LineGap.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Decoration.set(t.map(t=>t.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];l.Xs.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})}
1,point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some((t,i)=>t.from!=e[i].from||t.to!=e[i].to);return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||scaleBlock(this.heightMap.lineAt(t,tp.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(t),tp.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}};let Viewport=class Viewport{constructor(t,e){this.from=t,this.to=e}};function findPosition({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let o=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],n=s-i;if(o<=n)return i+o;o-=n}}function findFraction(t,e){let i=0;for(let{from:o,to:s}of t.ranges){if(e<=s){i+=e-o;break}i+=s-o}return i/t.total}let tg={toDOM:t=>t,fromDOM:t=>t,scale:1};let BigScaler=class BigScaler{constructor(t,e,i){let o=0,s=0,n=0;for(let r of(this.viewports=i.map(({from:i,to:s})=>{let n=e.lineAt(i,tp.ByPos,t,0,0).top,r=e.lineAt(s,tp.ByPos,t,0,0).bottom;return o+=r-n,{from:i,to:s,top:n,bottom:r,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(e.height-o),this.viewports))r.domTop=n+(r.top-s)*this.scale,n=r.domBottom=r.domTop+(r.bottom-r.top),s=r.bottom}toDOM(t){for(let e=0,i=0,o=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return o+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,o=s.domBottom}}fromDOM(t){for(let e=0,i=0,o=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-o)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,o=s.domBottom}}};function scaleBlock(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),o=e.toDOM(t.bottom);return new BlockInfo(t.from,t.length,i,o-i,Array.isArray(t.type)?t.type.map(t=>scaleBlock(t,e)):t.type)}let tm=l.r$.define({combine:t=>t.join(" ")}),tw=l.r$.define({combine:t=>t.indexOf(!0)>-1}),tv=h.V.newName(),tb=h.V.newName(),ty=h.V.newName(),tM={"&light":"."+tb,"&dark":"."+ty};function buildTheme(t,e,i){return new h.V(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!i||!i[e])throw RangeError(`Unsupported selector: ${e}`);return i[e]}):t+" "+e})}let tx=buildTheme("."+tv,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},tM);let DOMChange=class DOMChange{constructor(t,e,i,o){this.typeOver=o,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:n}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||n?[]:function(t){let e=[];
1if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:n}=t.observer.selectionRange;return i&&(e.push(new DOMPoint(i,o)),(s!=i||n!=o)&&e.push(new DOMPoint(s,n))),e}(t),i=new DOMReader(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,o=2==t.length?t[1].pos:i;return i>-1&&o>-1?l.jT.single(i+e,o+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!contains(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),o=n&&n.node==e.anchorNode&&n.offset==e.anchorOffset||!contains(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=l.jT.single(o,i)}}};function applyDOMChange(t,e){let i;let{newSel:o}=e,s=t.state.selection.main;if(e.bounds){let{from:o,to:n}=e.bounds,r=s.from,h=null;(8===t.inputState.lastKeyCode&&t.inputState.lastKeyTime>Date.now()-100||C.android&&e.text.length<n-o)&&(r=s.to,h="end");let a=function(t,e,i,o){let s=Math.min(t.length,e.length),n=0;for(;n<s&&t.charCodeAt(n)==e.charCodeAt(n);)n++;if(n==s&&t.length==e.length)return null;let r=t.length,l=e.length;for(;r>0&&l>0&&t.charCodeAt(r-1)==e.charCodeAt(l-1);)r--,l--;if("end"==o){let t=Math.max(0,n-Math.min(r,l));i-=r+t-n}if(r<n&&t.length<e.length){let t=i<=n&&i>=r?n-i:0;n-=t,l=n+(l-r),r=n}else if(l<n){let t=i<=n&&i>=l?n-i:0;n-=t,r=n+(r-l),l=n}return{from:n,toA:r,toB:l}}(t.state.doc.sliceString(o,n,"ï¿¿"),e.text,r-o,h);a&&(C.chrome&&13==t.inputState.lastKeyCode&&a.toB==a.from+2&&"ï¿¿ï¿¿"==e.text.slice(a.from,a.toB)&&a.toB--,i={from:o+a.from,to:o+a.toA,insert:l.xv.of(e.text.slice(a.from,a.toB).split("ï¿¿"))})}else o&&(!t.hasFocus&&t.state.facet(H)||o.main.eq(s))&&(o=null);if(!i&&!o)return!1;if(!i&&e.typeOver&&!s.empty&&o&&o.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(C.mac||C.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(o&&2==i.insert.length&&(o=l.jT.single(o.main.anchor-1,o.main.head-1)),i={from:s.from,to:s.to,insert:l.xv.of([" "])}):C.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(o&&(o=l.jT.single(o.main.anchor-1,o.main.head-1)),i={from:s.from,to:s.to,insert:l.xv.of([" "])}),i){let e,n=t.state;if(C.ios&&t.inputState.flushIOSKey(t)||C.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&dispatchKey(t.contentDOM,"Enter",13)||i.from==s.from-1&&i.to==s.to&&0==i.insert.length&&dispatchKey(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&dispatchKey(t.contentDOM,"Delete",46)))return!0;let r=i.insert.toString();if(t.state.facet(E).some(e=>e(t,i.from,i.to,r)))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=s.from&&i.to<=s.to&&i.to-i.from>=(s.to-s.from)/3&&(!o||o.main.empty&&o.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let o=s.from<i.from?n.sliceDoc(s.from,i.from):"",r=s.to>i.to?n.sliceDoc(i.to,s.to):"";e=n.replaceSelection(t.state.toText(o+i.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=n.changes(i),h=o&&!n.selection.main.eq(o.main)&&o.main.to<=r.newLength?o.main:void 0;if(n.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=s.to&&i.to>=s.to-10){let o=t.state.sliceDoc(i.from,i.to),a=compositionSurroundingNode(t)||t.state.doc.lineAt(s.head),c=s.to-i.to,d=s.to-s.from;e=n.changeByRange(e=>{if(e.from==s.from&&e.to==s.to)return{changes:r,range:h||e.map(r)};let u=e.to-c,f=u-o.length;if(e.to-e.from!=d||t.state.sliceDoc(f,u)!=o||a&&e.to>=a.from&&e.from<=a.to)return{range:e};let p=n.changes({from:f,to:u,insert:i.insert}),g=e.to-s.to;return{changes:p,range:h?l.jT.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):e.map(p)}})}else e={changes:r,selection:h&&n.selection.replaceRange(h)}}let h="input.type";return t.composing&&(h+=".compose",t.inputState.compositionFirstChange&&(h+=".start",t.inputState.compositionFirstChange=!1)),t.dis
1patch(e,{scrollIntoView:!0,userEvent:h}),!0}if(!o||o.main.eq(s))return!1;{let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:o,scrollIntoView:e,userEvent:i}),!0}}let tS={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},tC=C.ie&&C.ie_version<=11;let DOMObserver=class DOMObserver{constructor(t){this.view=t,this.active=!1,this.selectionRange=new DOMSelectionState,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(C.ie&&C.ie_version<=11||C.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),tC&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM),this.resizeContent=new ResizeObserver(()=>this.view.requestMeasure()),this.resizeContent.observe(t.contentDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runScrollHandlers(this.view,t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){for(let e of(this.gapIntersection.disconnect(),t))this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,o=this.selectionRange;if(i.state.facet(H)?i.root.activeElement!=this.dom:!hasSelection(i.dom,o))return;let s=o.anchorNode&&i.docView.nearest(o.anchorNode);if(s&&s.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(C.ie&&C.ie_version<=11||C.android&&C.chrome)&&!i.state.selection.main.empty&&o.focusNode&&isEquivalentPosition(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=C.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t){let e=null;function read(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",read,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",read,!0),!e)return null;let i=e.startContainer,o=e.startOffset,s=e.endContainer,n=e.endOffset,r=t.docView.domAtPos(t.state.selection.main.anchor);return isEquivalentPosition(r.node,r.offset,s,n)&&([i,o,s,n]=[s,n,i,o]),{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:n}}(this.view)||getSelection(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=hasSelection(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,o=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=o)return!1;for(;;)if(o){if(1!=i.nodeType)return!1;let t=i.childNodes[o-1];"false"==t.contentEditable?o--:o=maxOffset(i=t)}else{if(i==t)return!0;o=domIndex(i),i=i.parentNode}}(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else if(11==i.nodeType)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,tS),tC&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),tC&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;this.delayedAndroidKey||(this.flushingAndroidKey=this.view.win.requestAnimationFrame(()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),!this.flush()&&t.force&&dispatchKey(this.dom,t.ke
1y,t.keyCode))})),this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}processRecords(){let t=this.queue;for(let e of this.observer.takeRecords())t.push(e);t.length&&(this.queue=[]);let e=-1,i=-1,o=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(o=!0),-1==e?{from:e,to:i}=t:(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:o}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),o=this.selectionChanged&&hasSelection(this.dom,this.selectionRange);return t<0&&!o?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new DOMChange(this.view,t,e,i))}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return!1;let i=this.view.state,o=applyDOMChange(this.view,e);return this.view.state==i&&this.view.update([]),o}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.dirty|=4),"childList"==t.type){let i=findChild(e,t.previousSibling||t.target.previousSibling,-1),o=findChild(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:o?e.posBefore(o):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i,o;for(let s of(this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),null===(o=this.resizeContent)||void 0===o||o.disconnect(),this.scrollTargets))s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}};function findChild(t,e,i){for(;e;){let o=ContentView.get(e);if(o&&o.parent==t)return o;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}let EditorView=class EditorView{constructor(t={}){for(let e of(this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: fixed; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new ViewState(t.state||l.yy.create(t)),this.plugins=this.state.facet(N).map(t=>new PluginInstance(t)),this.plugins))e.update(this);this.observer=new DOMObserver(this),this.inputState=new InputState(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new DocView(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}
1dispatch(...t){this._dispatch(1==t.length&&t[0]instanceof l.YW?t[0]:this.state.update(...t))}update(t){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,o,s=this.state;for(let e of t){if(e.startState!=s)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed){this.viewState.state=s;return}let n=this.hasFocus,r=0,h=null;t.some(t=>t.annotation(tu))?(this.inputState.notifiedFocused=n,r=1):n==this.inputState.notifiedFocused||(this.inputState.notifiedFocused=n,(h=focusChangeTransaction(s,n))||(r=1));let a=this.observer.delayedAndroidKey,c=null;if(a?(this.observer.clearDelayedAndroidKey(),((c=this.observer.readChange())&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(l.yy.phrases)!=this.state.facet(l.yy.phrases))return this.setState(s);o=ViewUpdate.create(this,s,t),o.flags|=r;let d=this.viewState.scrollTarget;try{for(let e of(this.updateState=2,t)){if(d&&(d=d.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;d=new ScrollTarget(t.empty?t:l.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(P)&&(d=t.value)}this.viewState.update(o,d),this.bidiCache=CachedOrder.update(this.bidiCache,o.changes),o.empty||(this.updatePlugins(o),this.inputState.update(o)),e=this.docView.update(o),this.state.facet(K)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(o.startState.facet(tm)!=o.state.facet(tm)&&(this.viewState.mustMeasureContent=!0),(e||i||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!o.empty)for(let t of this.state.facet(V))t(o);(h||c)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),c&&!applyDOMChange(this,c)&&a.force&&dispatchKey(this.contentDOM,a.key,a.keyCode)})}setState(t){if(0!=this.updateState)throw Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);for(let e of(this.viewState=new ViewState(t),this.plugins=t.facet(N).map(t=>new PluginInstance(t)),this.pluginMap.clear(),this.plugins))e.update(this);this.docView=new DocView(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(N),i=t.state.facet(N);if(e!=i){let o=[];for(let s of i){let i=e.indexOf(s);if(i<0)o.push(new PluginInstance(s));else{let e=this.plugins[i];e.mustUpdate=t,o.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=o,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,{scrollHeight:i,scrollTop:o,clientHeight:s}=this.scrollDOM,n=o>i-s-4?i:o;try{for(let t=0;;t++){this.updateState=1;let i=this.viewport,o=this.viewState.lineBlockAtHeight(n),s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let r=[];4&s||([this.measureRequests,r]=[r,this.measureRequests]);let l=r.map(t=>{try{return t.read(this)}catch(t){return logException(this.state,t),tD}}),h=ViewUpdate.create(this,this.state,[]),a=!1,c=!1;h.flags|=s,e?e.flags|=s:e=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),a=this.docView.update(h));for(let t=0;t<r.length;t++)if(l[t]!=tD)try{let e=r[t];e.write&&e.write(l[t],this)}catch(t){logException(this.state,t)}if(this.viewState.editorHeight){if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,c=!0;else{let t=this.viewState.lineBlockAt(o.from).top-o.top;(t>1||t<-1)&&(this.scrollDOM.scrollTop+=t,c=!0)}}if(a&&this.docView.updateSelection(!0),this.viewport.from==i.from&&this.viewport.to==i.to&&!c&&0==this.measureRequests.length)break}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(V))t(e)}get themeClasses(){return tv+" "+(this.state.facet(tw)?ty:tb)+" "+this.state.facet(tm)}updateAttrs(){let t=attrsFromFacet(this,F,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(H)?"true":"false",class:"cm-content",style:`${C.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),attrsFromFacet(this,I,e);let i=this.observer.ignore(()=>{let i=updateAttrs(this.contentDOM,this.contentAttrs,e),o=updateAttrs(this.dom,this.editorAttrs,t);return i||o});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)t.is(EditorView.announce)&&(e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value)}mountStyles(){this.styleModules=this.state.facet(K),h.V.mount(this.root,this.styleModules.concat(tx).reverse())}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t&&!(this.measureRequests.indexOf(t)>
1-1)){if(null!=t.key){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find(e=>e.spec==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return skipAtoms(this,t,moveByChar(this,t,e,i))}moveByGroup(t,e){return skipAtoms(this,t,moveByChar(this,t,e,e=>{var i;let o,s;return i=t.head,s=(o=this.state.charCategorizer(i))(e),t=>{let e=o(t);return s==l.D0.Space&&(s=e),s==e}}))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,o){let s=t.state.doc.lineAt(e.head),n=o&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(n){let e=t.dom.getBoundingClientRect(),o=t.textDirectionAt(s.from),r=t.posAtCoords({x:i==(o==j.LTR)?e.right-1:e.left+1,y:(n.top+n.bottom)/2});if(null!=r)return l.jT.cursor(r,i?-1:1)}let r=LineView.find(t.docView,e.head),h=r?i?r.posAtEnd:r.posAtStart:i?s.to:s.from;return l.jT.cursor(h,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return skipAtoms(this,t,function(t,e,i,o){let s=e.head,n=i?1:-1;if(s==(i?t.state.doc.length:0))return l.jT.cursor(s,e.assoc);let r=e.goalColumn,h,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(s),d=t.documentTop;if(c)null==r&&(r=c.left-a.left),h=n<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(s);null==r&&(r=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),h=(n<0?e.top:e.bottom)+d}let u=a.left+r,f=null!=o?o:t.defaultLineHeight>>1;for(let i=0;;i+=10){let o=h+(f+i)*n,c=posAtCoords(t,{x:u,y:o},!1,n);if(o<a.top||o>a.bottom||(n<0?c<s:c>s))return l.jT.cursor(c,e.assoc,void 0,r)}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),posAtCoords(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let o=this.state.doc.lineAt(t),s=this.bidiSpans(o);return flattenRect(i,s[BidiSpan.find(s,t-o.from,-1,e)].dir==j.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(R)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>tk)return trivialOrder(t.length);let e=this.textDirectionAt(t.from);for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e)return i.order;let i=function(t,e){let i=t.length,o=e==$?1:2,s=e==$?2:1;if(!t||1==o&&!Z.test(t))return trivialOrder(i);for(let e=0,s=o,r=o;e<i;e++){var n;let i=(n=t.charCodeAt(e))<=247?_[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?U[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8203?256:64336<=n&&n<=65023?4:8204==n?256:1;512==i?i=s:8==i&&4==r&&(i=16),J[e]=4==i?2:i,7&i&&(r=i),s=i}for(let t=0,e=o,s=o;t<i;t++){let o=J[t];if(128==o)t<i-1&&e==J[t+1]&&24&e?o=J[t]=e:J[t]=256;else if(64==o){let o=t+1;for(;o<i&&64==J[o];)o++;let n=t&&8==e||o<i&&8==J[o]?1==s?1:8:256;for(let e=t;e<o;e++)J[e]=n;t=o-1}else 8==o&&1==s&&(J[t]=1);e=o,7&o&&(s=o)}for(let e=0,n=0,r=0,l,h,a;e<i;e++)if(h=Y[l=t.charCodeAt(e)]){if(h<0){for(let t=n-3;t>=0;t-=3)if(Q[t+1]==-h){let i=Q[t+2],r=2&i?o:4&i?1&i?s:o:0;r&&(J[e]=J[Q[t]]=r),n=t;break}}else if(189==Q.length)break;else Q[n++]=e,Q[n++]=l,Q[n++]=r}else if(2==(a=J[e])||1==a){let t=a==o;r=t?0:1;for(let e=n-3;e>=0;e-=3){let i=Q[e+2];if(2&i)break;if(t)Q[e+2]|=2;else{if(4&i)break;Q[e+2]|=4}}}for(let t=0;t<i;t++)if(256==J[t]){let e=t+1;for(;e<i&&256==J[e];)e++;let s=(t?J[t-1]:o)==1,n=s==((e<i?J[e]:o)==1)?s?1:2:o;for(let i=t;i<e;i++)J[i]=n;t=e-1}let r=[];if(1==o)for(let t=0;t<i;){let e=t,o=1!=J[t++];for(;t<i&&o==(1!=J[t]);)t++;if(o)for(let i=t;i>e;){let t=i,o=2!=J[--i];for(;i>
1e&&o==(2!=J[i-1]);)i--;r.push(new BidiSpan(i,t,o?2:1))}else r.push(new BidiSpan(e,t,0))}else for(let t=0;t<i;){let e=t,o=2==J[t++];for(;t<i&&o==(2==J[t]);)t++;r.push(new BidiSpan(e,t,o?1:2))}return r}(t.text,e);return this.bidiCache.push(new CachedOrder(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||C.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{focusPreventScroll(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return P.of(new ScrollTarget("number"==typeof t?l.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return ViewPlugin.define(()=>({}),{eventHandlers:t})}static theme(t,e){let i=h.V.newName(),o=[tm.of(i),K.of(buildTheme(`.${i}`,t))];return e&&e.dark&&o.push(tw.of(!0)),o}static baseTheme(t){return l.Wl.lowest(K.of(buildTheme("."+tv,t,tM)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),o=i&&ContentView.get(i)||ContentView.get(t);return(null===(e=null==o?void 0:o.rootView)||void 0===e?void 0:e.view)||null}};EditorView.styleModule=K,EditorView.inputHandler=E,EditorView.focusChangeEffect=B,EditorView.perLineTextDirection=R,EditorView.exceptionSink=O,EditorView.updateListener=V,EditorView.editable=H,EditorView.mouseSelectionStyle=A,EditorView.dragMovesSelection=T,EditorView.clickAddsSelectionRange=D,EditorView.decorations=z,EditorView.atomicRanges=G,EditorView.scrollMargins=q,EditorView.darkTheme=tw,EditorView.contentAttributes=I,EditorView.editorAttributes=F,EditorView.lineWrapping=EditorView.contentAttributes.of({class:"cm-lineWrapping"}),EditorView.announce=l.Py.define();let tk=4096,tD={};let CachedOrder=class CachedOrder{constructor(t,e,i,o){this.from=t,this.to=e,this.dir=i,this.order=o}static update(t,e){if(e.empty)return t;let i=[],o=t.length?t[t.length-1].dir:j.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let n=t[s];n.dir!=o||e.touchesRange(n.from,n.to)||i.push(new CachedOrder(e.mapPos(n.from,1),e.mapPos(n.to,-1),n.dir,n.order))}return i}};function attrsFromFacet(t,e,i){for(let o=t.state.facet(e),s=o.length-1;s>=0;s--){let e=o[s],n="function"==typeof e?e(t):e;n&&combineAttrs(n,i)}return i}let tT=C.mac?"mac":C.windows?"win":C.linux?"linux":"key";function modifiers(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}let tA=l.Wl.default(EditorView.domEventHandlers({keydown:(t,e)=>runHandlers(getKeymap(e.state),t,e,"editor")})),tO=l.r$.define({enables:tA}),tV=new WeakMap;function getKeymap(t){let e=t.facet(tO),i=tV.get(e);return i||tV.set(e,i=function(t,e=tT){let i=Object.create(null),o=Object.create(null),checkPrefix=(t,e)=>{let i=o[t];if(null==i)o[t]=e;else if(i!=e)throw Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},add=(t,o,s,n)=>{var r,l;let h=i[t]||(i[t]=Object.create(null)),a=o.split(/ (?!$)/).map(t=>(function(t,e){let i,o,s,n;let r=t.split(/-(?!$)/),l=r[r.length-1];"Space"==l&&(l=" ");for(let t=0;t<r.length-1;++t){let l=r[t];if(/^(cmd|meta|m)$/i.test(l))n=!0;else if(/^a(lt)?$/i.test(l))i=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))"mac"==e?n=!0:o=!0;else throw Error("Unrecognized modifier name: "+l)}return i&&(l="Alt-"+l),o&&(l="Ctrl-"+l),n&&(l="Meta-"+l),s&&(l="Shift-"+l),l})(t,e));for(let e=1;e<a.length;e++){let i=a.slice(0,e).join(" ");checkPrefix(i,!0),h[i]||(h[i]={preventDefault:!0,run:[e=>{let o=tE={view:e,prefix:i,scope:t};return setTimeout(()=>{tE==o&&(tE=null)},4e3),!0}]})}let c=a.join(" ");checkPrefix(c,!1);let d=h[c]||(h[c]={preventDefault:!1,run:(null===(l=null===(r=h._any)||void 0===r?void 0:r.run)||void 0===l?void 0:l.slice())||[]});s&&d.run.push(s),n&&(d.preventDefault=!0)};for(let o of t){let t=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));for(let e in t._any||(t._any={preventDefault:!1,run:[]}),t)t[e].run.push(o.any)}let s=o[e]||o.key;if(s)for(let e of t)add(e,s,o.run,o.preventDefault),o.shift&&add(e,"Shift-"+s,o.shift,o.preventDefault)}return i}(e.reduce((t,e)=>t.concat(e),[]))),i}function runScopeHandlers(t,e,i){return runHandlers(getKeymap(t.state),e,t,i)}let tE=null;function runHandlers(t,e,i,o){let s=(0,a.YG)(e),n=(0,l.gm)(s,0),r=(0,l.nZ)(n)==s.length&&" "!=s,h="",c=!1;tE&&tE.view==i&&tE.scope==o&&(h=tE.prefix+" ",(c=0>to.indexOf(e.keyCode))&&(tE=null));let d=new Set,runFor=t=>{if(t){for(let o of t.run)if(!d.has(o)&&(d.add(o),o(i,e)))return!0;t.preventDefault&&(c=!0)}return!1},u=t[o],f,p;if(u){if(runFor(u[h+modifiers(s,e,!r)]))return!0;
1if(r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(C.windows&&e.ctrlKey&&e.altKey)&&(f=a.ue[e.keyCode])&&f!=s){if(runFor(u[h+modifiers(f,e,!0)])||e.shiftKey&&(p=a.uY[e.keyCode])!=s&&p!=f&&runFor(u[h+modifiers(p,e,!1)]))return!0}else if(r&&e.shiftKey&&runFor(u[h+modifiers(s,e,!0)]))return!0;if(runFor(u._any))return!0}return c}let RectangleMarker=class RectangleMarker{constructor(t,e,i,o,s){this.className=t,this.left=e,this.top=i,this.width=o,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(!i.empty)return function(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let o=Math.max(i.from,t.viewport.from),s=Math.min(i.to,t.viewport.to),n=t.textDirection==j.LTR,r=t.contentDOM,l=r.getBoundingClientRect(),h=getBase(t),a=r.querySelector(".cm-line"),c=a&&window.getComputedStyle(a),d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),f=blockAt(t,o),p=blockAt(t,s),g=f.type==k.Text?f:null,m=p.type==k.Text?p:null;if(t.lineWrapping&&(g&&(g=wrappedLine(t,o,g)),m&&(m=wrappedLine(t,s,m))),g&&m&&g.from==m.from)return pieces(drawForLine(i.from,i.to,g));{let e=g?drawForLine(i.from,null,g):drawForWidget(f,!1),o=m?drawForLine(null,i.to,m):drawForWidget(p,!0),s=[];return(g||f).to<(m||p).from-1?s.push(piece(d,e.bottom,u,o.top)):e.bottom<o.top&&t.elementAtHeight((e.bottom+o.top)/2).type==k.Text&&(e.bottom=o.top=(e.bottom+o.top)/2),pieces(e).concat(s).concat(pieces(o))}function piece(t,i,o,s){return new RectangleMarker(e,t-h.left,i-h.top-.01,o-t,s-i+.01)}function pieces({top:t,bottom:e,horizontal:i}){let o=[];for(let s=0;s<i.length;s+=2)o.push(piece(i[s],t,i[s+1],e));return o}function drawForLine(e,i,o){let s=1e9,r=-1e9,l=[];function addSpan(e,i,h,a,c){let f=t.coordsAtPos(e,e==o.to?-2:2),p=t.coordsAtPos(h,h==o.from?2:-2);s=Math.min(f.top,p.top,s),r=Math.max(f.bottom,p.bottom,r),c==j.LTR?l.push(n&&i?d:f.left,n&&a?u:p.right):l.push(!n&&a?d:p.left,!n&&i?u:f.right)}let h=null!=e?e:o.from,a=null!=i?i:o.to;for(let o of t.visibleRanges)if(o.to>h&&o.from<a)for(let s=Math.max(o.from,h),n=Math.min(o.to,a);;){let o=t.state.doc.lineAt(s);for(let r of t.bidiSpans(o)){let t=r.from+o.from,l=r.to+o.from;if(t>=n)break;l>s&&addSpan(Math.max(t,s),null==e&&t<=h,Math.min(l,n),null==i&&l>=a,r.dir)}if((s=o.to+1)>=n)break}return 0==l.length&&addSpan(h,null==e,a,null==i,t.textDirection),{top:s,bottom:r,horizontal:l}}function drawForWidget(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i);{let o=t.coordsAtPos(i.head,i.assoc||1);if(!o)return[];let s=getBase(t);return[new RectangleMarker(e,o.left-s.left,o.top-s.top,null,o.bottom-o.top)]}}};function getBase(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==j.LTR?e.left:e.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function wrappedLine(t,e,i){let o=l.jT.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(o,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(o,!0,!0).from),type:k.Text}}function blockAt(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type)){for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==k.Text))return t}return i}let LayerView=class LayerView{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(tB)!=t.state.facet(tB)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&t.view.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(tB);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}draw(t){if(t.length!=this.drawn.length||t.some((t,e)=>{var i;return i=this.drawn[e],!(t.constructor==i.constructor&&t.eq(i))})){let e=this.dom.firstChild,i=0;for(let o of t)o.update&&e&&o.constructor&&this.drawn[i].constructor&&o.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(o.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}};let tB=l.r$.define();function layer(t){return[ViewPlugin.define(e=>new LayerView(e,t)),tB.of(t)]}let tR=!C.ios,tL=l.r$.define({combine:t=>(0,l.BO)(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function drawSelection(t={}){return[tL.of(t),tP,tH,tN,L.of(!0)]}function configChanged(t){return t.startState.facet(tL)!=t.state.facet(tL)}let tP=layer({above:!0,markers(t){let{state:e}=t,i=e.facet(tL),o=[];for(let s of e.selection.ranges){let n=s==e.selection.main;if(s.empty?!n||tR:i.drawRangeCursor){let e=n?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:l.jT.cursor(s.head,s.head>
1s.anchor?-1:1);for(let s of RectangleMarker.forRange(t,e,i))o.push(s)}}return o},update(t,e){t.transactions.some(t=>t.selection)&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=configChanged(t);return i&&setBlinkRate(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){setBlinkRate(e.state,t)},class:"cm-cursorLayer"});function setBlinkRate(t,e){e.style.animationDuration=t.facet(tL).cursorBlinkRate+"ms"}let tH=layer({above:!1,markers:t=>t.state.selection.ranges.map(e=>e.empty?[]:RectangleMarker.forRange(t,"cm-selectionBackground",e)).reduce((t,e)=>t.concat(e)),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||configChanged(t),class:"cm-selectionLayer"}),tW={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};tR&&(tW[".cm-line"].caretColor="transparent !important");let tN=l.Wl.highest(EditorView.theme(tW)),tF=l.Py.define({map:(t,e)=>null==t?null:e.mapPos(t)}),tI=l.QQ.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce((t,e)=>e.is(tF)?e.value:t,t))}),tz=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let i=t.state.field(tI);null==i?null!=this.cursor&&(null===(e=this.cursor)||void 0===e||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(tI)!=i||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let t=this.view.state.field(tI),e=null!=t&&this.view.coordsAtPos(t);if(!e)return null;let i=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-i.left+this.view.scrollDOM.scrollLeft,top:e.top-i.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}drawCursor(t){this.cursor&&(t?(this.cursor.style.left=t.left+"px",this.cursor.style.top=t.top+"px",this.cursor.style.height=t.height+"px"):this.cursor.style.left="-100000px")}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(tI)!=t&&this.view.dispatch({effects:tF.of(t)})}},{eventHandlers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function dropCursor(){return[tI,tz]}function iterMatches(t,e,i,o,s){e.lastIndex=0;for(let n=t.iterRange(i,o),r=i,l;!n.next().done;r+=n.value.length)if(!n.lineBreak)for(;l=e.exec(n.value);)s(r+l.index,l)}let MatchDecorator=class MatchDecorator{constructor(t){let{regexp:e,decoration:i,decorate:o,boundary:s,maxLength:n=1e3}=t;if(!e.global)throw RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,o)this.addMatch=(t,e,i,s)=>o(s,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,o,s)=>{let n=i(t,e,o);n&&s(o,o+t[0].length,n)};else if(i)this.addMatch=(t,e,o,s)=>s(o,o+t[0].length,i);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=n}createDeco(t){let e=new l.f_,i=e.add.bind(e);for(let{from:e,to:o}of function(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let o=[];for(let{from:s,to:n}of i)s=Math.max(t.state.doc.lineAt(s).from,s-e),n=Math.min(t.state.doc.lineAt(n).to,n+e),o.length&&o[o.length-1].to>=s?o[o.length-1].to=n:o.push({from:s,to:n});return o}(t,this.maxLength))iterMatches(t.state.doc,this.regexp,e,o,(e,o)=>this.addMatch(o,t,e,i));return e.finish()}updateDeco(t,e){let i=1e9,o=-1;return(t.docChanged&&t.changes.iterChanges((e,s,n,r)=>{r>t.view.viewport.from&&n<t.view.viewport.to&&(i=Math.min(n,i),o=Math.max(r,o))}),t.viewportChanged||o-i>1e3)?this.createDeco(t.view):o>-1?this.updateRange(t.view,e.map(t.changes),i,o):e}updateRange(t,e,i,o){for(let s of t.visibleRanges){let n=Math.max(s.from,i),r=Math.min(s.to,o);if(r>n){let i=t.state.doc.lineAt(n),o=i.to<r?t.state.doc.lineAt(r):i,l=Math.max(s.from,i.from),h=Math.min(s.to,o.to);if(this.boundary){for(;n>i.from;n--)if(this.boundary.test(i.text[n-1-i.from])){l=n;break}for(;r<o.to;r++)if(this.boundary.test(o.text[r-o.from])){h=r;break}}
1let a=[],c,add=(t,e,i)=>a.push(i.range(t,e));if(i==o)for(this.regexp.lastIndex=l-i.from;(c=this.regexp.exec(i.text))&&c.index<h-i.from;)this.addMatch(c,t,c.index+i.from,add);else iterMatches(t.state.doc,this.regexp,l,h,(e,i)=>this.addMatch(i,t,e,add));e=e.update({filterFrom:l,filterTo:h,filter:(t,e)=>t<l||e>h,add:a})}}return e}};let tG=null!=/x/.unicode?"gu":"g",tq=RegExp("[\x00-\b\n-\x1f\x7f-\x9f\xadØâââ\u2028\u2029ââ®â¦â§â©\uFEFF-]",tG),tK={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},tj=null,t$=l.r$.define({combine(t){let e=(0,l.BO)(t,{render:null,specialChars:tq,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==tj&&"undefined"!=typeof document&&document.body){let e=document.body.style;tj=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)!=null}return tj||!1}())&&(e.specialChars=RegExp(" |"+e.specialChars.source,tG)),e.addSpecialChars&&(e.specialChars=RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,tG)),e}});function highlightSpecialChars(t={}){return[t$.of(t),tX||(tX=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.decorations=Decoration.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(t$)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new MatchDecorator({regexp:t.specialChars,decoration:(e,i,o)=>{let{doc:s}=i.state,n=(0,l.gm)(e[0],0);if(9==n){let t=s.lineAt(o),e=i.state.tabSize,n=(0,l.IS)(t.text,e,o-t.from);return Decoration.replace({widget:new TabWidget((e-n%e)*this.view.defaultCharacterWidth)})}return this.decorationCache[n]||(this.decorationCache[n]=Decoration.replace({widget:new SpecialCharWidget(t,n)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(t$);t.startState.facet(t$)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]}let tX=null;let SpecialCharWidget=class SpecialCharWidget extends WidgetType{constructor(t,e){super(),this.options=t,this.co
1de=e}eq(t){return t.code==this.code}toDOM(t){var e;let i=(e=this.code)>=32?"â¢":10==e?"â¤":String.fromCharCode(9216+e),o=t.state.phrase("Control character")+" "+(tK[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,o,i);if(s)return s;let n=document.createElement("span");return n.textContent=i,n.title=o,n.setAttribute("aria-label",o),n.className="cm-specialChar",n}ignoreEvent(){return!1}};let TabWidget=class TabWidget extends WidgetType{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}};function highlightActiveLine(){return tU}let t_=Decoration.line({class:"cm-activeLine"}),tU=ViewPlugin.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let o of t.state.selection.ranges){let s=t.lineBlockAt(o.head);s.from>e&&(i.push(t_.range(s.from)),e=s.from)}return Decoration.set(i)}},{decorations:t=>t.decorations});let Placeholder=class Placeholder extends WidgetType{constructor(t){super(),this.content=t}toDOM(){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):this.content),"string"==typeof this.content?t.setAttribute("aria-label","placeholder "+this.content):t.setAttribute("aria-hidden","true"),t}ignoreEvent(){return!1}};function placeholder(t){return ViewPlugin.fromClass(class{constructor(e){this.view=e,this.placeholder=Decoration.set([Decoration.widget({widget:new Placeholder(t),side:1}).range(0)])}get decorations(){return this.view.state.doc.length?Decoration.none:this.placeholder}},{decorations:t=>t.decorations})}function getPos(t,e){var i;let o,s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(s),r=s-n.from,h=r>2e3?-1:r==n.length?(i=e.clientX,(o=t.coordsAtPos(t.viewport.from))?Math.round(Math.abs((o.left-i)/t.defaultCharacterWidth)):-1):(0,l.IS)(n.text,t.state.tabSize,s-n.from);return{line:n.number,col:h,off:r}}function rectangularSelection(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return EditorView.mouseSelectionStyle.of((t,i)=>{let o,s;return e(i)?(o=getPos(t,i),s=t.state.selection,o?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(o.line).from),i=t.state.doc.lineAt(e);o={line:i.number,col:o.col,off:Math.min(o.off,i.length)},s=s.map(t.changes)}},get(e,i,n){let r=getPos(t,e);if(!r)return s;let h=function(t,e,i){let o=Math.min(e.line,i.line),s=Math.max(e.line,i.line),n=[];if(e.off>2e3||i.off>2e3||e.col<0||i.col<0){let r=Math.min(e.off,i.off),h=Math.max(e.off,i.off);for(let e=o;e<=s;e++){let i=t.doc.line(e);i.length<=h&&n.push(l.jT.range(i.from+r,i.to+h))}}else{let r=Math.min(e.col,i.col),h=Math.max(e.col,i.col);for(let e=o;e<=s;e++){let i=t.doc.line(e),o=(0,l.Gz)(i.text,r,t.tabSize,!0);if(o<0)n.push(l.jT.cursor(i.to));else{let e=(0,l.Gz)(i.text,h,t.tabSize);n.push(l.jT.range(i.from+o,i.from+e))}}}return n}(t.state,o,r);return h.length?n?l.jT.create(h.concat(s.ranges)):l.jT.create(h):s}}:null):null})}let tY={Alt:[18,t=>t.altKey],Control:[17,t=>t.ctrlKey],Shift:[16,t=>t.shiftKey],Meta:[91,t=>t.metaKey]},tQ={style:"cursor: crosshair"};function crosshairCursor(t={}){let[e,i]=tY[t.key||"Alt"],o=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventHandlers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)},mousemove(t){this.set(i(t))}}});return[o,EditorView.contentAttributes.of(t=>{var e;return(null===(e=t.plugin(o))||void 0===e?void 0:e.isDown)?tQ:null})]}let tZ="-10000px";let TooltipViewManager=class TooltipViewManager{constructor(t,e,i){this.facet=e,this.createTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t),this.tooltipViews=this.tooltips.map(i)}update(t){var e;let i=t.state.facet(this.facet),o=i.filter(t=>t);if(i===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let s=[];for(let e=0;e<o.length;e++){let i=o[e],n=-1;
1if(i){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==i.create&&(n=t)}if(n<0)s[e]=this.createTooltipView(i);else{let i=s[e]=this.tooltipViews[n];i.update&&i.update(t)}}}for(let t of this.tooltipViews)0>s.indexOf(t)&&(t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t));return this.input=i,this.tooltips=o,this.tooltipViews=s,!0}};function windowSpace(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}let tJ=l.r$.define({combine:t=>{var e,i,o;return{position:C.ios?"absolute":(null===(e=t.find(t=>t.position))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find(t=>t.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(o=t.find(t=>t.tooltipSpace))||void 0===o?void 0:o.tooltipSpace)||windowSpace}}}),t0=new WeakMap,t1=ViewPlugin.fromClass(class{constructor(t){this.view=t,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(tJ);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new TooltipViewManager(t,t3,t=>this.createTooltip(t)),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver)for(let t of(this.intersectionObserver.disconnect(),this.manager.tooltipViews))this.intersectionObserver.observe(t.dom)}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t);e&&this.observeIntersection();let i=e||t.geometryChanged,o=t.state.facet(tJ);if(o.position!=this.position){for(let t of(this.position=o.position,this.manager.tooltipViews))t.dom.style.position=this.position;i=!0}if(o.parent!=this.parent){for(let t of(this.parent&&this.container.remove(),this.parent=o.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t){let e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=tZ,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;for(let e of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);null===(e=this.intersectionObserver)||void 0===e||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect();return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(({dom:t})=>t.getBoundingClientRect()),space:this.view.state.facet(tJ).tooltipSpace(this.view)}}writeMeasure(t){var e;let{editor:i,space:o}=t,s=[];for(let n=0;n<this.manager.tooltips.length;n++){let r=this.manager.tooltips[n],l=this.manager.tooltipViews[n],{dom:h}=l,a=t.pos[n],c=t.size[n];if(!a||a.bottom<=Math.max(i.top,o.top)||a.top>=Math.min(i.bottom,o.bottom)||a.right<Math.max(i.left,o.left)-.1||a.left>Math.min(i.right,o.right)+.1){h.style.top=tZ;continue}let d=r.arrow?l.dom.querySelector(".cm-tooltip-arrow"):null,u=d?7:0,f=c.right-c.left,p=null!==(e=t0.get(l))&&void 0!==e?e:c.bottom-c.top,g=l.offset||t8,m=this.view.textDirection==j.LTR,w=c.width>o.right-o.left?m?o.left:o.right-c.width:m?Math.min(a.left-(d?14:0)+g.x,o.right-f):Math.max(o.left,a.left-f+(d?14:0)-g.x),v=!!r.above;!r.strictSide&&(v?a.top-(c.bottom-c.top)-g.y<o.top:a.bottom+(c.bottom-c.top)+g.y>o.bottom)&&v==o.bottom-a.bottom>a.top-o.top&&(v=!v);let b=(v?a.top-o.top:o.bottom-a.bottom)-u;if(b<p&&!1!==l.resize){if(b<this.view.defaultLineHeight){h.style.top=tZ;continue}t0.set(l,p),h.style.height=(p=b)+"px"}else h.style.height&&(h.style.height="");let y=v?a.top-p-u-g.y:a.bottom+u+g.y,M=w+f;if(!0!==l.overlap)for(let t of s)t.left<M&&t.right>w&&t.top<y+p&&t.bottom>y&&(y=v?t.top-p-2-u:t.bottom+u+2);"absolute"==this.position?(h.style.top=y-t.parent.top+"px",h.style.left=w-t.parent.left+"px"):(h.style.top=y+"px",h.style.left=w+"px"),d&&(d.style.left=`${a.left+(m?g.x:-g.x)-(w+14-7)}px`),!0!==l.overlap&&s.push({left:w,top:y,right:M,bottom:y+p}),h.classList.toggle("cm-tooltip-above",v),h.classList.toggle("cm-tooltip-below",!v),l.positioned&&l.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&
1(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=tZ}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),t2=EditorView.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"}}}),t8={x:0,y:0},t3=l.r$.define({enables:[t1,t2]}),t9=l.r$.define();let HoverTooltipHost=class HoverTooltipHost{constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new TooltipViewManager(t,t9,t=>this.createHostedView(t))}static create(t){return new HoverTooltipHost(t)}createHostedView(t){let e=t.create(this.view);return e.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(e.dom),this.mounted&&e.mount&&e.mount(this.view),e}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}};let t5=t3.compute([t9],t=>{let e=t.facet(t9).filter(t=>t);return 0===e.length?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.filter(t=>null!=t.end).map(t=>t.end)),create:HoverTooltipHost.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});let HoverPlugin=class HoverPlugin{constructor(t,e,i,o,s){this.view=t,this.source=e,this.field=i,this.setHover=o,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.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)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{lastMove:t}=this,e=this.view.contentDOM.contains(t.target)?this.view.posAtCoords(t):null;if(null==e)return;let i=this.view.coordsAtPos(e);if(null==i||t.y<i.top||t.y>i.bottom||t.x<i.left-this.view.defaultCharacterWidth||t.x>i.right+this.view.defaultCharacterWidth)return;let o=this.view.bidiSpans(this.view.state.doc.lineAt(e)).find(t=>t.from<=e&&t.to>=e),s=o&&o.dir==j.RTL?-1:1,n=this.source(this.view,e,t.x<i.left?-s:s);if(null==n?void 0:n.then){let t=this.pending={pos:e};n.then(e=>{this.pending==t&&(this.pending=null,e&&this.view.dispatch({effects:this.setHover.of(e)}))},t=>logException(this.view.state,t,"hover tooltip"))}else n&&this.view.dispatch({effects:this.setHover.of(n)})}mousemove(t){var e;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let i=this.active;if(i&&!isInTooltip(this.lastMove.target)||this.pending){let{pos:o}=i||this.pending,s=null!==(e=null==i?void 0:i.end)&&void 0!==e?e:o;(o==s?this.view.posAtCoords(this.lastMove)!=o:!function(t,e,i,o,s,n){let r=document.createRange(),l=t.domAtPos(e),h=t.domAtPos(i);r.setEnd(h.node,h.offset),r.setStart(l.node,l.offset);let a=r.getClientRects();r.detach();for(let t=0;t<a.length;t++){let e=a[t];
1if(6>=Math.max(e.top-s,s-e.bottom,e.left-o,o-e.right))return!0}return!1}(this.view,o,s,t.clientX,t.clientY,0))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&!isInTooltip(t.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}};function isInTooltip(t){for(let e=t;e;e=e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip"))return!0;return!1}function hoverTooltip(t,e={}){let i=l.Py.define(),o=l.QQ.define({create:()=>null,update(t,o){if(t&&(e.hideOnChange&&(o.docChanged||o.selection)||e.hideOn&&e.hideOn(o,t)))return null;if(t&&o.docChanged){let e=o.changes.mapPos(t.pos,-1,l.gc.TrackDel);if(null==e)return null;let i=Object.assign(Object.create(null),t);i.pos=e,null!=t.end&&(i.end=o.changes.mapPos(t.end)),t=i}for(let e of o.effects)e.is(i)&&(t=e.value),e.is(t4)&&(t=null);return t},provide:t=>t9.from(t)});return[o,ViewPlugin.define(s=>new HoverPlugin(s,t,o,i,e.hoverTime||300)),t5]}function getTooltip(t,e){let i=t.plugin(t1);if(!i)return null;let o=i.manager.tooltips.indexOf(e);return o<0?null:i.manager.tooltipViews[o]}let t4=l.Py.define(),t6=l.r$.define({combine(t){let e,i;for(let o of t)e=e||o.topContainer,i=i||o.bottomContainer;return{topContainer:e,bottomContainer:i}}});function getPanel(t,e){let i=t.plugin(t7),o=i?i.specs.indexOf(e):-1;return o>-1?i.panels[o]:null}let t7=ViewPlugin.fromClass(class{constructor(t){this.input=t.state.facet(et),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet(t6);for(let i of(this.top=new PanelGroup(t,!0,e.topContainer),this.bottom=new PanelGroup(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top)),this.panels))i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(t){let e=t.state.facet(t6);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new PanelGroup(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new PanelGroup(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(et);if(i!=this.input){let e=i.filter(t=>t),o=[],s=[],n=[],r=[];for(let i of e){let e=this.specs.indexOf(i),l;e<0?(l=i(t.view),r.push(l)):(l=this.panels[e]).update&&l.update(t),o.push(l),(l.top?s:n).push(l)}for(let t of(this.specs=e,this.panels=o,this.top.sync(s),this.bottom.sync(n),r))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=>EditorView.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});let PanelGroup=class PanelGroup{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&&0>t.indexOf(e)&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length){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 t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=rm(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=rm(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);
1for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}};function rm(t){let e=t.nextSibling;return t.remove(),e}let et=l.r$.define({enables:t7});let GutterMarker=class GutterMarker extends l.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}};GutterMarker.prototype.elementClass="",GutterMarker.prototype.toDOM=void 0,GutterMarker.prototype.mapMode=l.gc.TrackBefore,GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1,GutterMarker.prototype.point=!0;let ee=l.r$.define(),ei={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>l.Xs.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},eo=l.r$.define();function gutter(t){return[gutters(),eo.of(Object.assign(Object.assign({},ei),t))]}let es=l.r$.define({combine:t=>t.some(t=>t)});function gutters(t){let e=[en];return t&&!1===t.fixed&&e.push(es.of(!0)),e}let en=ViewPlugin.fromClass(class{constructor(t){for(let e of(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(eo).map(e=>new SingleGutterView(t,e)),this.gutters))this.dom.appendChild(e.dom);this.fixed=!t.state.facet(es),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,o=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(o<(i.to-i.from)*.8)}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(es)!=!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=l.Xs.iter(this.view.state.facet(ee),this.view.viewport.from),o=[],s=this.gutters.map(t=>new UpdateContext(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==k.Text){e=i;break}}else e=t.type==k.Text?t:void 0;if(e)for(let n of(o.length&&(o=[]),advanceCursor(i,o,t.from),s))n.line(this.view,e,o)}for(let t of s)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(eo),i=t.state.facet(eo),o=t.docChanged||t.heightChanged||t.viewportChanged||!l.Xs.eq(t.startState.facet(ee),t.state.facet(ee),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(o=!0);else{o=!0;let s=[];for(let o of i){let i=e.indexOf(o);i<0?s.push(new SingleGutterView(this.view,o)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),0>s.indexOf(t)&&t.destroy();for(let t of s)this.dom.appendChild(t.dom);this.gutters=s}return o}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>EditorView.scrollMargins.of(e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==j.LTR?{left:i.dom.offsetWidth}:{right:i.dom.offsetWidth}:null})});function asArray(t){return Array.isArray(t)?t:[t]}function advanceCursor(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}let UpdateContext=class UpdateContext{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=l.Xs.iter(t.markers,e.from)}line(t,e,i){let o=[];advanceCursor(this.cursor,o,e.from),i.length&&(o=o.concat(i));let s=this.gutter.config.lineMarker(t,e,o);s&&o.unshift(s);let n=this.gutter;if(0==o.length&&!n.config.renderEmptyElements)return;let r=e.top-this.height;if(this.i==n.elements.length){let i=new GutterElement(t,e.height,r,o);n.elements.push(i),n.dom.appendChild(i.dom)}else n.elements[this.i].update(t,e.height,r,o);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()}}};let SingleGutterView=class SingleGutterView{constructor(t,e){for(let i in this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="
1cm-gutter"+(this.config.class?" "+this.config.class:""),e.domEventHandlers)this.dom.addEventListener(i,o=>{let s=o.target,n;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let t=s.getBoundingClientRect();n=(t.top+t.bottom)/2}else n=o.clientY;let r=t.lineBlockAtHeight(n-t.documentTop);e.domEventHandlers[i](t,r,o)&&o.preventDefault()});this.markers=asArray(e.markers(t)),e.initialSpacer&&(this.spacer=new GutterElement(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=asArray(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!l.Xs.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}};let GutterElement=class GutterElement{constructor(t,e,i,o){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,o)}update(t,e,i,o){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;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}(this.markers,o)&&this.setMarkers(t,o)}setMarkers(t,e){let i="cm-gutterElement",o=this.dom.firstChild;for(let s=0,n=0;;){let r=n,l=s<e.length?e[s++]:null,h=!1;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let t=n;t<this.markers.length;t++)if(this.markers[t].compare(l)){r=t,h=!0;break}}else r=this.markers.length;for(;n<r;){let t=this.markers[n++];if(t.toDOM){t.destroy(o);let e=o.nextSibling;o.remove(),o=e}}if(!l)break;l.toDOM&&(h?o=o.nextSibling:this.dom.insertBefore(l.toDOM(t),o)),h&&n++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}};let er=l.r$.define(),el=l.r$.define({combine:t=>(0,l.BO)(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let o=i[t],s=e[t];i[t]=o?(t,e,i)=>o(t,e,i)||s(t,e,i):s}return i}})});let NumberMarker=class NumberMarker extends GutterMarker{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}};function formatNumber(t,e){return t.state.facet(el).formatNumber(e,t.state)}let eh=eo.compute([el],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(er),lineMarker:(t,e,i)=>i.some(t=>t.toDOM)?null:new NumberMarker(formatNumber(t,t.state.doc.lineAt(e.from).number)),lineMarkerChange:t=>t.startState.facet(el)!=t.state.facet(el),initialSpacer:t=>new NumberMarker(formatNumber(t,maxLineNumber(t.state.doc.lines))),updateSpacer(t,e){let i=formatNumber(e.view,maxLineNumber(e.view.state.doc.lines));return i==t.number?t:new NumberMarker(i)},domEventHandlers:t.facet(el).domEventHandlers}));function lineNumbers(t={}){return[el.of(t),gutters(),eh]}function maxLineNumber(t){let e=9;for(;e<t;)e=10*e+9;return e}let ea=new class extends GutterMarker{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},ec=ee.compute(["selection"],t=>{let e=[],i=-1;for(let o of t.selection.ranges){let s=t.doc.lineAt(o.head).from;s>i&&(i=s,e.push(ea.range(s)))}return l.Xs.of(e)});function highlightActiveLineGutter(){return ec}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.