"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[13614],{87359:(t,e,i)=>{let s;i.d(e,{$f:()=>iy,AE:()=>iF,Eu:()=>sp,Nm:()=>tg,OO:()=>tI,SJ:()=>i7,ZO:()=>iq,gB:()=>i8,hJ:()=>i0,l9:()=>to,lg:()=>t$,p:()=>tr,tk:()=>id});var o=i(89501),n=i(327),r=i(96048);function l(t){return(11==t.nodeType?t.getSelection?t:t.ownerDocument:t).getSelection()}function h(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function a(t,e){if(!e.anchorNode)return!1;try{return h(t,e.anchorNode)}catch(t){return!1}}function c(t){return 3==t.nodeType?S(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function d(t,e,i,s){return!!i&&(p(t,e,i,s,-1)||p(t,e,i,s,1))}function u(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function f(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function p(t,e,i,s,o){for(;;){if(t==i&&e==s)return!0;if(e==(o<0?0:g(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=u(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType||1==(t=t.childNodes[e+(o<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=o<0?g(t):0}}}function g(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function m(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function w(t,e){let i=e.width/t.offsetWidth,s=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||1>Math.abs(e.width-t.offsetWidth))&&(i=1),(s>.995&&s<1.005||!isFinite(s)||1>Math.abs(e.height-t.offsetHeight))&&(s=1),{scaleX:i,scaleY:s}}class v{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){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?g(e):0),i,Math.min(t.focusOffset,i?g(i):0))}set(t,e,i,s){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=s}}let b=null;function y(t){if(t.setActive)return t.setActive();if(b)return t.focus(b);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==b?{get preventScroll(){return b={preventScroll:!0},!0}}:void 0),!b){b=!1;for(let t=0;tMath.max(1,t.scrollHeight-t.clientHeight-4)}function C(t,e){for(let i=t,s=e;;){if(3==i.nodeType&&s>0)return{node:i,offset:s};if(1==i.nodeType&&s>0){if("false"==i.contentEditable)return null;s=g(i=i.childNodes[s-1])}else{if(!i.parentNode||f(i))return null;s=u(i),i=i.parentNode}}}function A(t,e){for(let i=t,s=e;;){if(3==i.nodeType&&se)return i.domBoundsAround(t,e,h);if(c>=t&&-1==s&&(s=l,o=h),h>e&&i.dom.parentNode==this.dom){n=l,r=a;break}a=c,h=c+i.breakAfter}return{from:o,to:r<0?i+this.length:r,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:n=0?this.children[n].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=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=O){this.markDirty();for(let s=t;si.indexOf(t)&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;tthis.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 B(t,e,i,s,o,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==s&&c&&!r&&!u&&n.length<2&&c.merge(i,o,n.length?d:null,0==i,l,h))){if(s0&&(!r&&n.length&&c.merge(i,c.length,n[0],!1,l,0)?c.breakAfter=n.shift().breakAfter:(i2);var $={mac:j||/Mac/.test(V.platform),windows:/Win/.test(V.platform),linux:/Linux|X11/.test(V.platform),ie:F,ie_version:H?P.documentMode||6:W?+W[1]:N?+N[1]:0,gecko:z,gecko_version:z?+(/Firefox\/(\d+)/.exec(V.userAgent)||[0,0])[1]:0,chrome:!!I,chrome_version:I?+I[1]:0,ios:j,android:/Android\b/.test(V.userAgent),webkit:K,safari:q,webkit_version:K?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=P.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class X extends T{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!(8&this.flags)&&(!i||i instanceof X&&!(this.length-(e-t)+i.length>256)&&!(8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new X(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new D(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 function(t,e,i){let s=t.nodeValue.length;e>s&&(e=s);let o=e,n=e,r=0;0==e&&i<0||e==s&&i>=0?!($.chrome||$.gecko)&&(e?(o--,r=1):n=0)?0:l.length-1];return $.safari&&!r&&0==h.width&&(h=Array.prototype.find.call(l,t=>t.width)||h),r?m(h,r<0):h||null}(this.dom,t,e)}}class G extends T{constructor(t,e=[],i=0){for(let s of(super(),this.mark=t,this.children=e,this.length=i,e))s.setParent(this)}setAttrs(t){if(M(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}canReuseDOM(t){return super.canReuseDOM(t)&&!((this.flags|t.flags)&8)}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,s,o,n){return(!i||!!(i instanceof G&&i.mark.eq(this.mark))&&(!t||!(o<=0))&&(!(et&&e.push(i=t&&(s=o),i=r,o++}let n=this.length-t;return this.length=t,s>-1&&(this.children.length=s,this.markDirty()),new G(this.mark,e,n)}domAtPos(t){return U(this,t)}coordsAt(t,e){return Q(this,t,e)}}class _ extends T{static create(t,e,i){return new _(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=_.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.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,s,o,n){return(!i||i instanceof _&&!!this.widget.compare(i.widget)&&(!(t>0)||!(o<=0))&&(!(e0)?D.before(this.dom):D.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let n=this.side?this.side<0:t>0;for(let e=n?s.length-1:0;o=s[e],t>0?0!=e:e!=s.length-1&&!(o.top0?D.before(this.dom):D.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return o.xv.empty}get isHidden(){return!0}}function U(t,e){let i=t.dom,{children:s}=t,o=0;for(let t=0;o=n.getSide())){if(e>t&&e0;t--){let e=s[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=o;t=l&&(c.children.length?t(c,l-a):(!n||n.isHidden&&i>0)&&(d>l||a==d&&c.getSide()>0)?(n=c,r=l-a):(ac.getSide()&&!c.isHidden)&&(s=c,o=l-a)),a=d}}(t,e);let l=(i<0?s:n)||s||n;return l?l.coordsAt(Math.max(0,l==s?o:r),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=c(e);return i[i.length-1]||null}(t)}function J(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}X.prototype.children=_.prototype.children=Y.prototype.children=O;let Z=Object.create(null);function tt(t,e,i){if(t==e)return!0;t||(t=Z),e||(e=Z);let s=Object.keys(t),o=Object.keys(e);if(s.length-(i&&s.indexOf(i)>-1?1:0)!=o.length-(i&&o.indexOf(i)>-1?1:0))return!1;for(let n of s)if(n!=i&&(-1==o.indexOf(n)||t[n]!==e[n]))return!1;return!0}function te(t,e,i){let s=!1;if(e)for(let o in e)i&&o in i||(s=!0,"style"==o?t.style.cssText="":t.removeAttribute(o));if(i)for(let o in i)e&&e[o]==i[o]||(s=!0,"style"==o?t.style.cssText=i[o]:t.setAttribute(o,i[o]));return s}class ti extends T{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,s,o,n){if(i){if(!(i instanceof ti))return!1;this.dom||i.transferDOM(this)}return s&&this.setDeco(i?i.attrs:null),L(this,t,e,i?i.children.slice():[],o,n),!0}split(t){let e=new ti;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:s}=this.childPos(t);s&&(e.append(this.children[i].split(s),0),this.children[i].merge(s,this.children[i].length,null,!1,0,0),i++);for(let t=i;t0&&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){tt(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){!function t(e,i,s){let o,{children:n}=e;s>0&&i instanceof G&&n.length&&(o=n[n.length-1])instanceof G&&o.mark.eq(i.mark)?t(o,i.children[0],s-1):(n.push(i),i.setParent(e)),e.length+=i.length}(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=J(e,this.attrs||{})),i&&(this.attrs=J({class:i},this.attrs||{}))}domAtPos(t){return U(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(M(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&&(te(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let s=this.dom.lastChild;for(;s&&T.get(s) instanceof G;)s=s.lastChild;if(!s||!this.length||"BR"!=s.nodeName&&(null===(i=T.get(s))||void 0===i?void 0:i.isEditable)==!1&&(!$.ios||!this.children.some(t=>t instanceof X))){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 X)||/[^ -~]/.test(i.text))return null;let s=c(i.dom);if(1!=s.length)return null;t+=s[0].width,e=s[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(t,e){let i=Q(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){if(o instanceof ti)return o;if(n>e)break}s=n+o.breakAfter}return null}}class ts extends T{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,s,o,n){return(!i||i instanceof ts&&!!this.widget.compare(i.widget)&&(!(t>0)||!(o<=0))&&(!(e0)}}class to{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}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var tn=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(tn||(tn={}));class tr extends o.uU{constructor(t,e,i,s){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(t){return new tl(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new ta(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,s;if(t.isBlockGap)i=-5e8,s=4e8;else{let{start:o,end:n}=tc(t,e);i=(o?e?-3e8:-1:5e8)-1,s=(n?e?2e8:1:-6e8)+1}return new ta(t,i,s,e,t.widget||null,!0)}static line(t){return new th(t)}static set(t,e=!1){return o.Xs.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}tr.none=o.Xs.empty;class tl extends tr{constructor(t){let{start:e,end:i}=tc(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){var e,i;return this==t||t instanceof tl&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&tt(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw RangeError("Mark decorations may not be empty");return super.range(t,e)}}tl.prototype.point=!1;class th extends tr{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof th&&this.spec.class==t.spec.class&&tt(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)}}th.prototype.mapMode=o.gc.TrackBefore,th.prototype.point=!0;class ta extends tr{constructor(t,e,i,s,n,r){super(e,i,n,t),this.block=s,this.isReplace=r,this.mapMode=s?e<=0?o.gc.TrackBefore:o.gc.TrackAfter:o.gc.TrackDel}get type(){return this.startSide!=this.endSide?tn.WidgetRange:this.startSide<=0?tn.WidgetBefore:tn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){var e,i;return t instanceof ta&&((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 tc(t,e=!1){let{inclusiveStart:i,inclusiveEnd:s}=t;return null==i&&(i=t.inclusive),null==s&&(s=t.inclusive),{start:null!=i?i:e,end:null!=s?s:e}}function td(t,e,i,s=0){let o=i.length-1;o>=0&&i[o]+s>=t?i[o]=Math.max(i[o],e):i.push(t,e)}ta.prototype.point=!0;class tu{constructor(t,e,i,s){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=s,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 ts&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new ti),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(tf(new Y(-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()||t&&this.content.length&&this.content[this.content.length-1]instanceof ts||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:s}=this.cursor.next(this.skip);if(this.skip=0,s)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 s=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(tf(new X(this.text.slice(this.textOff,this.textOff+s)),e),i),this.atCursorPos=!0,this.textOff+=s,t-=s,i=0}}span(t,e,i,s){this.buildText(e-t,i,s),this.pos=e,this.openStart<0&&(this.openStart=s)}point(t,e,i,s,o,n){if(this.disallowBlockEffectsFor[n]&&i instanceof ta){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 ta){if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new ts(i.widget||tp.block,r,i));else{let n=_.create(i.widget||tp.inline,r,r?0:i.startSide),l=this.atCursorPos&&!n.isEditable&&o<=s.length&&(t0),h=!n.isEditable&&(ts.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||l||n.isEditable||(this.pendingBuffer=0),this.flushBuffer(s),l&&(a.append(tf(new Y(1),s),o),o=s.length+Math.max(0,o-s.length)),a.append(tf(n,s),o),this.atCursorPos=h,this.pendingBuffer=h?ts.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.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=o)}static build(t,e,i,s,n){let r=new tu(t,e,i,n);return r.openEnd=o.Xs.spans(s,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function tf(t,e){for(let i of e)t=new G(i,[t],t.length);return t}class tp extends to{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}get isHidden(){return!0}}tp.inline=new tp("span"),tp.block=new tp("div");var tg=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(tg||(tg={}));let tm=tg.LTR,tw=tg.RTL;function tv(t){let e=[];for(let i=0;i=e){if(r.level==i)return n;(o<0||(0!=s?s<0?r.frome:t[o].level>r.level))&&(o=n)}}if(o<0)throw RangeError("Index out of range");return o}}let tA=[];function tD(t){return[new tC(0,t,0)]}let tO="",tT=o.r$.define(),tE=o.r$.define(),tR=o.r$.define(),tB=o.r$.define(),tL=o.r$.define(),tV=o.r$.define(),tP=o.r$.define(),tN=o.r$.define({combine:t=>t.some(t=>t)}),tH=o.r$.define({combine:t=>t.some(t=>t)}),tW=o.r$.define();class tF{constructor(t,e="nearest",i="nearest",s=5,o=5,n=!1){this.range=t,this.y=e,this.x=i,this.yMargin=s,this.xMargin=o,this.isSnapshot=n}map(t){return t.empty?this:new tF(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new tF(o.jT.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}let tz=o.Py.define({map:(t,e)=>t.map(e)});function tI(t,e,i){let s=t.facet(tB);s.length?s[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}let tK=o.r$.define({combine:t=>!t.length||t[0]}),tq=0,tj=o.r$.define();class t${constructor(t,e,i,s,o){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=s,this.extension=o(this)}static define(t,e){let{eventHandlers:i,eventObservers:s,provide:o,decorations:n}=e||{};return new t$(tq++,t,i,s,t=>{let e=[tj.of(t)];return n&&e.push(tY.of(e=>{let i=e.plugin(t);return i?n(i):tr.none})),o&&e.push(o(t)),e})}static fromClass(t,e){return t$.define(e=>new t(e),e)}}class tX{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(tI(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){tI(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){tI(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}let tG=o.r$.define(),t_=o.r$.define(),tY=o.r$.define(),tU=o.r$.define(),tQ=o.r$.define(),tJ=o.r$.define();function tZ(t,e){let i=t.state.facet(tJ);if(!i.length)return i;let s=i.map(e=>e instanceof Function?e(t):e),n=[];return o.Xs.spans(s,e.from,e.to,{point(){},span(t,i,s,o){let r=t-e.from,l=i-e.from,h=n;for(let t=s.length-1;t>=0;t--,o--){let i=s[t].spec.bidiIsolate,n;if(null==i&&(i=function(t,e,i){for(let s=e;s0&&h.length&&(n=h[h.length-1]).to==r&&n.direction==i)n.to=l,h=n.inner;else{let t={from:r,to:l,direction:i,inner:[]};h.push(t),h=t.inner}}}}),n}let t0=o.r$.define();function t1(t){let e=0,i=0,s=0,o=0;for(let n of t.state.facet(t0)){let r=n(t);r&&(null!=r.left&&(e=Math.max(e,r.left)),null!=r.right&&(i=Math.max(i,r.right)),null!=r.top&&(s=Math.max(s,r.top)),null!=r.bottom&&(o=Math.max(o,r.bottom)))}return{left:e,right:i,top:s,bottom:o}}let t2=o.r$.define();class t8{constructor(t,e,i,s){this.fromA=t,this.toA=e,this.fromB=i,this.toB=s}join(t){return new t8(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 s=t[e-1];if(!(s.fromA>i.toA)){if(s.toAa)break;o+=2}if(!l)return i;new t8(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),n=l.toA,r=l.toB}}}class t3{constructor(t,e,i){for(let s of(this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=o.as.empty(this.startState.doc.length),i))this.changes=this.changes.compose(s.changes);let s=[];this.changes.iterChangedRanges((t,e,i,o)=>s.push(new t8(t,e,i,o))),this.changedRanges=s}static create(t,e,i){return new t3(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}}class t9 extends T{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.lastCompositionAfterCursor=!1,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 ti],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new t8(0,0,0,t.state.doc.length)],0,null)}update(t){var e,i,s,n,r,l;let h,a;let c=t.changedRanges;this.minWidth>0&&c.length&&(c.every(({fromA:t,toA:e})=>ethis.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let d=-1;!(this.view.inputState.composing>=0)||((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?d=this.domChanged.newSel.head:(i=t.changes,s=this.hasComposition,h=!1,s&&i.iterChangedRanges((t,e)=>{ts.from&&(h=!0)}),h||t.selectionSet||(d=t.state.selection.main.head)));let u=d>-1?function(t,e,i){let s=t4(t,i);if(!s)return null;let{node:o,from:n,to:r}=s,l=o.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(s.from,s.to)!=l)return null;let h=e.invertedDesc,a=new t8(h.mapPos(n),h.mapPos(r),n,r),c=[];for(let e=o.parentNode;;e=e.parentNode){let i=T.get(e);if(i instanceof G)c.push({node:e,deco:i.mark});else{if(i instanceof ti||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:a,text:o,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new tl({inclusive:!0,attributes:function(t){let e=Object.create(null);for(let i=0;i{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=$.chrome||$.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||s.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(t=>t.flags&=-9);let o=[];if(this.view.viewport.from||this.view.viewport.to=0?s[t]:null;if(!e)break;let{fromA:n,toA:r,fromB:l,toB:h}=e,a,c,d,u;if(i&&i.range.fromBl){let t=tu.build(this.view.state.doc,l,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=tu.build(this.view.state.doc,i.range.toB,h,this.decorations,this.dynamicDecorationMap);c=t.breakAtStart,d=t.openStart,u=e.openEnd;let s=this.compositionView(i);e.breakAtStart?s.breakAfter=1:e.content.length&&s.merge(s.length,s.length,e.content[0],!1,e.openStart,0)&&(s.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&s.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),a=t.content.concat(s).concat(e.content)}else({content:a,breakAtStart:c,openStart:d,openEnd:u}=tu.build(this.view.state.doc,l,h,this.decorations,this.dynamicDecorationMap));let{i:f,off:p}=o.findPos(r,1),{i:g,off:m}=o.findPos(n,-1);B(this,g,m,f,p,a,c,d,u)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new X(t.text.nodeValue);for(let{deco:i}of(e.flags|=8,t.marks))e=new G(i,[e],e.length);let i=new ti;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some(t=>7&t.flags)?1:0),this.markedForComposition.add(e);let i=T.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),s=this.children[i.i];e(t.line,s);for(let o=t.marks.length-1;o>=-1;o--)i=s.childPos(i.off,1),s=s.children[i.i],e(o>=0?t.marks[o].node:t.text,s)}updateSelection(t=!1,e=!1){var i;(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let s=this.view.root.activeElement,o=s==this.dom,n=!o&&a(this.dom,this.view.observer.selectionRange)&&!(s&&this.dom.contains(s));if(!(o||e||n))return;let r=this.forceSelection;this.forceSelection=!1;let h=this.view.state.selection.main,c=this.moveToLine(this.domAtPos(h.anchor)),u=h.empty?c:this.moveToLine(this.domAtPos(h.head));if($.gecko&&h.empty&&!this.hasComposition&&1==(i=c).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(()=>c.node.insertBefore(t,c.node.childNodes[c.offset]||null)),c=u=new D(t,0),r=!0}let f=this.view.observer.selectionRange;!r&&f.focusNode&&(d(c.node,c.offset,f.anchorNode,f.anchorOffset)&&d(u.node,u.offset,f.focusNode,f.focusOffset)||this.suppressWidgetCursorChange(f,h))||(this.view.observer.ignore(()=>{$.android&&$.chrome&&this.dom.contains(f.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}(f.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=l(this.view.root);if(t){if(h.empty){if($.gecko){var e,i;let t=(e=c.node,i=c.offset,1!=e.nodeType?0:(i&&"false"==e.childNodes[i-1].contentEditable?1:0)|(ih.head&&([c,u]=[u,c]),e.setEnd(u.node,u.offset),e.setStart(c.node,c.offset),t.removeAllRanges(),t.addRange(e)}}n&&this.view.root.activeElement==this.dom&&(this.dom.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(c,u)),this.impreciseAnchor=c.precise?null:new D(f.anchorNode,f.anchorOffset),this.impreciseHead=u.precise?null:new D(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&d(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=l(t.root),{anchorNode:s,anchorOffset:o}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let n=ti.find(this,e.head);if(!n)return;let r=n.posAtStart;if(e.head==r||e.head==r+n.length)return;let h=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!h||!a||h.bottom>a.top)return;let c=this.domAtPos(e.head+e.assoc);i.collapse(c.node,c.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let d=t.observer.selectionRange;t.docView.posFromDOM(d.anchorNode,d.anchorOffset)!=e.from&&i.collapse(s,o)}moveToLine(t){let e=this.dom,i;if(t.node!=e)return t;for(let s=t.offset;!i&&s=0;s--){let t=T.get(e.childNodes[s]);t instanceof ti&&(i=t.domAtPos(t.length))}return i?new D(i.node,i.offset,!0):t}nearest(t){for(let e=t;e;){let t=T.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=0;n--){let r=this.children[n],l=o-r.breakAfter,h=l-r.length;if(lt||r.covers(1))&&(!i||r instanceof ti&&!(i instanceof ti&&e>=0))&&(i=r,s=h),o=h}return i?i.coordsAt(t-s,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),s=this.children[e];if(!(s instanceof ti))return null;for(;s.children.length;){let{i:t,off:e}=s.childPos(i,1);for(;;t++){if(t==s.children.length)return null;if((s=s.children[t]).length)break}i=e}if(!(s instanceof X))return null;let n=(0,o.cp)(s.text,i);if(n==i)return null;let r=S(s.dom,i,n).getClientRects();for(let t=0;tMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,l=this.view.textDirection==tg.LTR;for(let t=0,h=0;hs)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),n){let e=a.dom.lastChild,s=e?c(e):[];if(s.length){let e=s[s.length-1],n=l?e.right-i.left:i.right-e.left;n>r&&(r=n,this.minWidth=o,this.minWidthFrom=t,this.minWidthTo=d)}}}t=d+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?tg.RTL:tg.LTR}measureTextSize(){for(let t of this.children)if(t instanceof ti){let e=t.measureTextSize();if(e)return e}let t=document.createElement("div"),e,i,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(t);let o=c(t.firstChild)[0];e=t.getBoundingClientRect().height,i=o?o.width/27:7,s=o?o.height:e,t.remove()}),{lineHeight:e,charWidth:i,textHeight:s}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new R(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,s=0;;s++){let o=s==e.viewports.length?null:e.viewports[s],n=o?o.from-1:this.length;if(n>i){let s=(e.lineBlockAt(n).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(tr.replace({widget:new t5(s),block:!0,inclusive:!0,isBlockGap:!0}).range(i,n))}if(!o)break;i=o.to+1}return tr.set(t)}updateDeco(){let t=0,e=this.view.state.facet(tY).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),i=!1,s=this.view.state.facet(tU).map((t,e)=>{let s="function"==typeof t;return s&&(i=!0),s?t(this.view):t});for(s.length&&(this.dynamicDecorationMap[t++]=i,e.push(o.Xs.join(s))),this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];te.anchor?-1:1),s;if(!i)return;!e.empty&&(s=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let o=t1(this.view),n={left:i.left-o.left,top:i.top-o.top,right:i.right+o.right,bottom:i.bottom+o.bottom},{offsetWidth:r,offsetHeight:l}=this.view.scrollDOM;!function(t,e,i,s,o,n,r,l){let h=t.ownerDocument,a=h.defaultView||window;for(let c=t,d=!1;c&&!d;)if(1==c.nodeType){let t,u=c==h.body,f=1,p=1;if(u)t=function(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(d=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:f,scaleY:p}=w(c,e)),t={left:e.left,right:e.left+c.clientWidth*f,top:e.top,bottom:e.top+c.clientHeight*p}}let g=0,m=0;if("nearest"==o)e.top0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+r)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+r,i<0&&e.top-m0&&e.right>t.right+g&&(g=e.right-t.right+g+n)):e.right>t.right&&(g=e.right-t.right+n,i<0&&e.leftMath.abs(t-g)&&(s="nearest"),i&&1>Math.abs(i-m)&&(o="nearest")}}if(u)break;c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,n,e.heade.top+1}function et(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function ei(t,e,i){let s=t.nodeValue.length,o=-1,n=1e9,r=0;for(let l=0;li?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c=(a.left+a.right)/2,s=i;if(($.chrome||$.gecko)&&S(t,l).getBoundingClientRect().left==a.right&&(s=!i),c<=0)return{node:t,offset:l+(s?1:0)};o=l+(s?1:0),n=c}}}return{node:t,offset:o>-1?o:r>0?t.nodeValue.length:0}}function es(t,e,i,s=-1){var o,n;let r=t.contentDOM.getBoundingClientRect(),l=r.top+t.viewState.paddingTop,h,{docHeight:a}=t.viewState,{x:d,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,o=!1;(h=t.elementAtHeight(f)).type!=tn.Text;)for(;!((f=s>0?h.bottom+e:h.top-e)>=0)||!(f<=a);){if(o)return i?null:0;o=!0,s=-s}u=l+f;let p=h.from;if(pt.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:eo(t,r,h,d,u);let g=t.dom.ownerDocument,m=t.root.elementFromPoint?t.root:g,w=m.elementFromPoint(d,u);w&&!t.contentDOM.contains(w)&&(w=null),!w&&(d=Math.max(r.left+1,Math.min(r.right-1,d)),(w=m.elementFromPoint(d,u))&&!t.contentDOM.contains(w)&&(w=null));let v,b=-1;if(w&&(null===(o=t.docView.nearest(w))||void 0===o?void 0:o.isEditable)!=!1){if(g.caretPositionFromPoint){let t=g.caretPositionFromPoint(d,u);t&&({offsetNode:v,offset:b}=t)}else if(g.caretRangeFromPoint){let e=g.caretRangeFromPoint(d,u);e&&({startContainer:v,startOffset:b}=e,(!t.contentDOM.contains(v)||$.safari&&function(t,e,i){let s;if(3!=t.nodeType||e!=(s=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return S(t,s-1,s).getBoundingClientRect().left>i}(v,b,d)||$.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():S(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}(v,b,d))&&(v=void 0))}}if(!v||!t.docView.dom.contains(v)){let e=ti.find(t.docView,p);if(!e)return f>h.top+h.height/2?h.to:h.from;({node:v,offset:b}=function t(e,i,s){let o,n,r,l,h,a,d,u,f=!1;for(let m=e.firstChild;m;m=m.nextSibling){let e=c(m);for(let c=0;ci?p.left-i:Math.max(0,i-p.right),b=(g=w).top>s?g.top-s:Math.max(0,s-g.bottom);if(0==v&&0==b)return 3==m.nodeType?ei(m,i,s):t(m,i,s);if(!h||u>b||u==b&&d>v){h=m,a=w,d=v,u=b;let t=b?s0?c0)}0==v?s>w.bottom&&(!r||r.bottomw.top)&&(n=m,l=w):r&&t7(r,w)?r=ee(r,w.bottom):l&&t7(l,w)&&(l=et(l,w.top))}}if(r&&r.bottom>=s?(h=o,a=r):l&&l.top<=s&&(h=n,a=l),!h)return{node:e,offset:0};let m=Math.max(a.left,Math.min(a.right,i));if(3==h.nodeType)return ei(h,m,s);if(f&&"false"!=h.contentEditable)return t(h,m,s);let w=Array.prototype.indexOf.call(e.childNodes,h)+(i>=(a.left+a.right)/2?1:0);return{node:e,offset:w}}(e.dom,d,u))}let y=t.docView.nearest(v);if(!y)return null;if(!y.isWidget||(null===(n=y.dom)||void 0===n?void 0:n.nodeType)!=1)return y.localPosFromDOM(v,b)+y.posAtStart;{let t=y.dom.getBoundingClientRect();return e.y1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((n-i.top-(t.defaultLineHeight-e)*.5)/e)*t.viewState.heightOracle.lineLength}let l=t.state.sliceDoc(i.from,i.to);return i.from+(0,o.Gz)(l,r,t.state.tabSize)}function en(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==tn.Text))return t}return i}function er(t,e,i,s){let n=t.state.doc.lineAt(e.head),r=t.bidiSpans(n),l=t.textDirectionAt(n.from);for(let h=e,a=null;;){let e=function(t,e,i,s,n){var r;let l=s.head-t.from,h=tC.find(e,l,null!==(r=s.bidiLevel)&&void 0!==r?r:-1,s.assoc),a=e[h],c=a.side(n,i);if(l==c){let t=h+=n?1:-1;if(t<0||t>=e.length)return null;l=(a=e[h=t]).side(!n,i),c=a.side(n,i)}let d=(0,o.cp)(t.text,l,a.forward(n,i));(da.to)&&(d=c),tO=t.text.slice(Math.min(l,d),Math.max(l,d));let u=h==(n?e.length-1:0)?null:e[h+(n?1:-1)];return u&&d==c&&u.level+(n?0:1){if(e>t&&ee(t)),i.from,e.head>i.from?-1:1);return s==i.from?i:o.jT.cursor(s,snull),$.gecko&&function(t){eV.has(t)||(eV.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}(t.contentDOM.ownerDocument)}handleEvent(t){!(!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i=e.target,s;i!=t.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(s=T.get(i))&&s.ignoreEvent(e))return!1;return!0}(this.view,t)||this.ignoreDuringComposition(t))&&("keydown"==t.type&&this.keydown(t)||this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=function(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec;if(t&&t.domEventHandlers)for(let s in t.domEventHandlers){let o=t.domEventHandlers[s];o&&i(s).handlers.push(ec(e.value,o))}if(t&&t.domEventObservers)for(let s in t.domEventObservers){let o=t.domEventObservers[s];o&&i(s).observers.push(ec(e.value,o))}}for(let t in em)i(t).handlers.push(em[t]);for(let t in ew)i(t).observers.push(ew[t]);return e}(t),i=this.handlers,s=this.view.contentDOM;for(let t in e)if("scroll"!=t){let o=!e[t].handlers.length,n=i[t];n&&!n.handlers.length!=o&&(s.removeEventListener(t,this.handleEvent),n=null),n||s.addEventListener(t,this.handleEvent,{passive:o})}for(let t in i)"scroll"==t||e[t]||s.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){let e;return this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),!!(9==t.keyCode&&Date.now()ef.indexOf(t.keyCode)&&(this.view.inputState.lastEscPress=0),$.android&&$.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))?(this.view.observer.delayAndroidKey(t.key,t.keyCode),!0):$.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((e=ed.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||eu.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(229!=t.keyCode&&this.view.observer.forceFlush(),!1))}flushIOSKey(t){let e=this.pendingIOSKey;return!(!e||"Enter"==e.key&&t&&t.from0||!!($.safari&&!$.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function ec(t,e){return(i,s)=>{try{return e.call(t,s,i)}catch(t){tI(i.state,t)}}}let ed=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],eu="dthko",ef=[16,17,18,20,91,92,224,225];function ep(t){return .7*Math.max(0,t)+8}class eg{constructor(t,e,i,s){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=s,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),this.atoms=t.state.facet(tQ).map(e=>e(t));let n=t.contentDOM.ownerDocument;n.addEventListener("mousemove",this.move=this.move.bind(this)),n.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(o.yy.allowMultipleSelections)&&function(t,e){let i=t.state.facet(tT);return i.length?i[0](e):$.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let s=l(t.root);if(!s||0==s.rangeCount)return!0;let o=s.getRangeAt(0).getClientRects();for(let t=0;t=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)&&1==eO(e)&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&10>Math.max(Math.abs((i=this.startEvent).clientX-t.clientX),Math.abs(i.clientY-t.clientY)))return;this.select(this.lastEvent=t);let s=0,o=0,n=(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},r=t1(this.view);t.clientX-r.left<=n.left+6?s=-ep(n.left-t.clientX):t.clientX+r.right>=n.right-6&&(s=ep(t.clientX-n.right)),t.clientY-r.top<=n.top+6?o=-ep(n.top-t.clientY):t.clientY+r.bottom>=n.bottom-6&&(o=ep(t.clientY-n.bottom)),this.setScrollSpeed(s,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=this.view.inputState.draggedContent=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)}skipAtoms(t){let e=null;for(let i=0;ithis.select(this.lastEvent),20)}}let em=Object.create(null),ew=Object.create(null),ev=$.ie&&$.ie_version<15||$.ios&&$.webkit_version<604;function eb(t,e){let{state:i}=t,s,n=1,r=i.toText(e),l=r.lines==i.selection.ranges.length;if(null!=eE&&i.selection.ranges.every(t=>t.empty)&&eE==r.toString()){let t=-1;s=i.changeByRange(s=>{let h=i.doc.lineAt(s.from);if(h.from==t)return{range:s};t=h.from;let a=i.toText((l?r.line(n++).text:e)+i.lineBreak);return{changes:{from:h.from,insert:a},range:o.jT.cursor(s.from+a.length)}})}else s=l?i.changeByRange(t=>{let e=r.line(n++);return{changes:{from:t.from,to:t.to,insert:e.text},range:o.jT.cursor(t.from+e.length)}}):i.replaceSelection(r);t.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}function ey(t,e,i,s){if(1==s)return o.jT.cursor(e,i);if(2==s)return function(t,e,i=1){let s=t.charCategorizer(e),n=t.doc.lineAt(e),r=e-n.from;if(0==n.length)return o.jT.cursor(e);0==r?i=1:r==n.length&&(i=-1);let l=r,h=r;i<0?l=(0,o.cp)(n.text,r,!1):h=(0,o.cp)(n.text,r);let a=s(n.text.slice(l,h));for(;l>0;){let t=(0,o.cp)(n.text,l,!1);if(s(n.text.slice(t,l))!=a)break;l=t}for(;h{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},em.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now()),!1),ew.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},ew.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},em.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let s of t.state.facet(tR))if(i=s(t,e))break;if(i||0!=e.button||(i=function(t,e){let i=eM(t,e),s=eO(e),n=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),n=n.map(t.changes))},get(e,r,l){let h=eM(t,e),a,c=ey(t,h.pos,h.bias,s);if(i.pos!=h.pos&&!r){let e=ey(t,i.pos,i.bias,s),n=Math.min(e.from,c.from),r=Math.max(e.to,c.to);c=n1&&(a=function(t,e){for(let i=0;i=e)return o.jT.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(n,h.pos))?a:l?n.addRange(c):o.jT.create([c])}}}(t,e)),i){let s=!t.hasFocus;t.inputState.startMouseSelection(new eg(t,e,i,s)),s&&t.observer.ignore(()=>y(t.contentDOM));let o=t.inputState.mouseSelection;if(o)return o.start(e),!1===o.dragging}return!1};let eS=(t,e)=>t>=e.top&&t<=e.bottom,ex=(t,e,i)=>eS(e,i)&&t>=i.left&&t<=i.right;function eM(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:function(t,e,i,s){let o=ti.find(t.docView,e);if(!o)return 1;let n=e-o.posAtStart;if(0==n)return 1;if(n==o.length)return -1;let r=o.coordsAt(n,-1);if(r&&ex(i,s,r))return -1;let l=o.coordsAt(n,1);return l&&ex(i,s,l)?1:r&&eS(s,r)?-1:1}(t,i,e.clientX,e.clientY)}}let ek=$.ie&&$.ie_version<=11,eC=null,eA=0,eD=0;function eO(t){if(!ek)return t.detail;let e=eC,i=eD;return eC=t,eD=Date.now(),eA=!e||i>Date.now()-400&&2>Math.abs(e.clientX-t.clientX)&&2>Math.abs(e.clientY-t.clientY)?(eA+1)%3:1}function eT(t,e,i,s){let o;if(!i)return;let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,l=s&&r&&((o=t.state.facet(tE)).length?o[0](e):$.mac?!e.altKey:!e.ctrlKey)?{from:r.from,to:r.to}:null,h={from:n,insert:i},a=t.state.changes(l?[l,h]:h);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:l?"move.drop":"input.drop"}),t.inputState.draggedContent=null}em.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let s=t.docView.nearest(e.target);if(s&&s.isWidget){let t=s.posAtStart,e=t+s.length;(t>=i.to||e<=i.from)&&(i=o.jT.range(t,e))}}let{inputState:s}=t;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},em.dragend=t=>(t.inputState.draggedContent=null,!1),em.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let s=Array(i.length),o=0,n=()=>{++o==i.length&&eT(t,e,s.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(s[t]=e.result),n()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return eT(t,e,i,!0),!0}return!1},em.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=ev?null:e.clipboardData;return i?(eb(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(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(),eb(t,i.value)},50)}(t),!1)};let eE=null;em.copy=em.cut=(t,e)=>{let{text:i,ranges:s,linewise:o}=function(t){let e=[],i=[],s=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),i.push(s));if(!e.length){let o=-1;for(let{from:s}of t.selection.ranges){let n=t.doc.lineAt(s);n.number>o&&(e.push(n.text),i.push({from:n.from,to:Math.min(t.doc.length,n.to+1)})),o=n.number}s=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:s}}(t.state);if(!i&&!o)return!1;eE=o?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let n=ev?null:e.clipboardData;return n?(n.clearData(),n.setData("text/plain",i),!0):(!function(t,e){let i=t.dom.parentNode;if(!i)return;let s=i.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=e,s.focus(),s.selectionEnd=e.length,s.selectionStart=0,setTimeout(()=>{s.remove(),t.focus()},50)}(t,i),!1)};let eR=o.q6.define();function eB(t,e){let i=[];for(let s of t.facet(tP)){let o=s(t,e);o&&i.push(o)}return i?t.update({effects:i,annotations:eR.of(!0)}):null}function eL(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=eB(t.state,e);i?t.dispatch(i):t.update([])}},10)}ew.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),eL(t)},ew.blur=t=>{t.observer.clearSelectionRange(),eL(t)},ew.compositionstart=ew.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},ew.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,$.chrome&&$.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50)},ew.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},em.beforeinput=(t,e)=>{var i;let s;if($.chrome&&$.android&&(s=ed.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.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)}return $.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),$.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>ew.compositionend(t,e),20),!1};let eV=new Set,eP=["pre-wrap","normal","pre-line","break-spaces"];class eN{constructor(t){this.lineWrapping=t,this.doc=o.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 eP.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=s,this.lineLength=o,l){this.heightSamples={};for(let t=0;t0}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 ez.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,s){let o=this,n=i.doc;for(let r=s.length-1;r>=0;r--){let{fromA:l,toA:h,fromB:a,toB:c}=s[r],d=o.lineAt(l,eF.ByPosNoHeight,i.setDoc(e),0,0),u=d.to>=h?d:o.lineAt(h,eF.ByPosNoHeight,i,0,0);for(c+=u.to-h,h=u.to;r>0&&d.from<=s[r-1].toA;)l=s[r-1].fromA,a=s[r-1].fromB,r--,l2*o){let o=t[e-1];o.break?t.splice(--e,1,o.left,null,o.right):t.splice(--e,1,o.left,o.right),i+=1+o.break,s-=o.size}else if(o>2*s){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,o-=e.size}else break}else if(s=o&&n(this.blockAt(0,i,s,o))}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more&&this.setHeight(t,s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class eK extends eI{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,s){return new eW(s,this.length,i,this.height,this.breaks)}replace(t,e,i){let s=i[0];return 1==i.length&&(s instanceof eK||s instanceof eq&&4&s.flags)&&10>Math.abs(this.length-s.length)?(s instanceof eq?s=new eK(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):ez.of(i)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more?this.setHeight(t,s.heights[s.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class eq extends ez{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,o=s-i+1,n,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*o);n=e/o,this.length>o+1&&(r=(this.height-e)/(this.length-o-1))}else n=this.height/o;return{firstLine:i,lastLine:s,perLine:n,perChar:r}}blockAt(t,e,i,s){let{firstLine:o,lastLine:n,perLine:r,perChar:l}=this.heightMetrics(e,s);if(e.lineWrapping){let o=s+(t0){let t=i[i.length-1];t instanceof eq?i[i.length-1]=new eq(t.length+s):i.push(null,new eq(s-1))}if(t>0){let e=i[0];e instanceof eq?i[0]=new eq(t+e.length):i.unshift(new eq(t-1),null)}return ez.of(i)}decomposeLeft(t,e){e.push(new eq(t-1),null)}decomposeRight(t,e){e.push(null,new eq(this.length-t-1))}updateHeight(t,e=0,i=!1,s){let o=e+this.length;if(s&&s.from<=e+this.length&&s.more){let i=[],n=Math.max(e,s.from),r=-1;for(s.from>e&&i.push(new eq(s.from-e-1).updateHeight(t,e));n<=o&&s.more;){let e=t.doc.lineAt(n).length;i.length&&i.push(null);let o=s.heights[s.index++];-1==r?r=o:Math.abs(o-r)>=.001&&(r=-2);let l=new eK(e,o);l.outdated=!1,i.push(l),n+=e+1}n<=o&&i.push(null,new eq(o-n).updateHeight(t,n));let l=ez.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})`}}class ej extends ez{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,s){let o=i+this.left.height;return tr))return h;let a=e==eF.ByPosNoHeight?eF.ByPosNoHeight:eF.ByPos;return l?h.join(this.right.lineAt(r,a,i,n,r)):this.left.lineAt(r,a,i,s,o).join(h)}forEachLine(t,e,i,s,o,n){let r=s+this.left.height,l=o+this.left.length+this.break;if(this.break)t=l&&this.right.forEachLine(t,e,i,r,l,n);else{let h=this.lineAt(l,eF.ByPos,i,s,o);t=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 s=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-s,e-s,i));let o=[];t>0&&this.decomposeLeft(t,o);let n=o.length;for(let t of i)o.push(t);if(t>0&&e$(o,n-1),e=++i&&e.push(null),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,s=i+this.break;if(t>=s)return this.right.decomposeRight(t-s,e);t2*e.size||e.size>2*t.size?ez.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,s){let{left:o,right:n}=this,r=e+o.length+this.break,l=null;return(s&&s.from<=e+o.length&&s.more?l=o=o.updateHeight(t,e,i,s):o.updateHeight(t,e,i),s&&s.from<=r+n.length&&s.more?l=n=n.updateHeight(t,r,i,s):n.updateHeight(t,r,i),l)?this.balanced(o,n):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function e$(t,e){let i,s;null==t[e]&&(i=t[e-1])instanceof eq&&(s=t[e+1])instanceof eq&&t.splice(e-1,3,new eq(i.length+1+s.length))}class eX{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 eK?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new eK(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=5)&&this.addLineDeco(s,o,n)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTot&&this.nodes.push(new eK(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new eq(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 eK)return t;let e=new eK(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,t),s.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof eK||this.isCovered?(this.writtenTo"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new eN(e),this.stateDeco=t.facet(tY).filter(t=>"function"!=typeof t),this.heightMap=ez.empty().applyChanges(this.stateDeco,o.xv.empty,this.heightOracle.setDoc(t.doc),[new t8(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=tr.set(this.lineGaps.map(t=>t.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let s=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>s>=t&&s<=e)){let{from:e,to:i}=this.lineBlockAt(s);t.push(new eQ(e,i))}}this.viewports=t.sort((t,e)=>t.from-e.from),this.scaler=this.heightMap.height<=7e6?e0:new e1(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(1==this.scaler.scale?t:e2(t,this.scaler))})}update(t,e=null){var i,s;let n;this.state=t.state;let r=this.stateDeco;this.stateDeco=this.state.facet(tY).filter(t=>"function"!=typeof t);let l=t.changedRanges,h=t8.extendWithRanges(l,(i=this.stateDeco,s=t?t.changes:o.as.empty(this.state.doc.length),n=new eG,o.Xs.compare(r,i,s,n,0),n.changes)),a=this.heightMap.height,c=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),h),this.heightMap.height!=a&&(t.flags|=2),c?(this.scrollAnchorPos=t.changes.mapPos(c.from,-1),this.scrollAnchorHeight=c.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let d=h.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.headd.to)||!this.viewportIsAppropriate(d))&&(d=this.getViewport(0,e));let u=!t.changes.empty||2&t.flags||d.from!=this.viewport.from||d.to!=this.viewport.to;this.viewport=d,this.updateForViewport(),u&&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(tH)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,n=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?tg.RTL:tg.LTR;let r=this.heightOracle.mustRefreshForWrapping(n),l=e.getBoundingClientRect(),h=r||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let a=0,c=0;if(l.width&&l.height){let{scaleX:t,scaleY:i}=w(e,l);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,a|=8,r=h=!0)}let d=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=d||this.paddingBottom!=u)&&(this.paddingTop=d,this.paddingBottom=u,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(s.lineWrapping&&(h=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let f=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=f&&(this.scrollAnchorHeight=-1,this.scrollTop=f),this.scrolledToBottom=k(t.scrollDOM);let p=(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(),s=t.ownerDocument,o=s.defaultView||window,n=Math.max(0,i.left),r=Math.min(o.innerWidth,i.right),l=Math.max(0,i.top),h=Math.min(o.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=s.body;)if(1==e.nodeType){let i=e,s=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=s.overflow){let s=i.getBoundingClientRect();n=Math.max(n,s.left),r=Math.min(r,s.right),l=Math.max(l,s.top),h=e==t.parentNode?s.bottom:Math.min(h,s.bottom)}e="absolute"==s.position||"fixed"==s.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),g=p.top-this.pixelViewport.top,m=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let b=l.width;if((this.contentDOMWidth!=b||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),h){let e=t.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(e)&&(r=!0),r||s.lineWrapping&&Math.abs(b-this.contentDOMWidth)>s.charWidth){let{lineHeight:i,charWidth:o,textHeight:l}=t.docView.measureTextSize();(r=i>0&&s.refresh(n,i,o,l,b/o,e))&&(t.docView.minWidth=0,a|=8)}for(let i of(g>0&&m>0?c=Math.max(g,m):g<0&&m<0&&(c=Math.min(g,m)),s.heightChanged=!1,this.viewports)){let n=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(r?ez.empty().applyChanges(this.stateDeco,o.xv.empty,this.heightOracle,[new t8(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(s,0,r,new eH(i.from,n))}s.heightChanged&&(a|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return y&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&a||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(r?[]: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)),s=this.heightMap,o=this.heightOracle,{visibleTop:n,visibleBottom:r}=this,l=new eQ(s.lineAt(n-1e3*i,eF.ByHeight,o,0,0).from,s.lineAt(r+(1-i)*1e3,eF.ByHeight,o,0,0).to);if(e){let{head:t}=e.range;if(tl.to){let i=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),n=s.lineAt(t,eF.ByPos,o,0,0),r;r="center"==e.y?(n.top+n.bottom)/2-i/2:"start"==e.y||"nearest"==e.y&&t=r+Math.max(10,Math.min(i,250)))&&s>n-2e3&&o>1,r=s<<1;if(this.defaultTextDirection!=tg.LTR&&!i)return[];let l=[],h=(s,r,a,c)=>{if(r-ss&&tt.from>=a.from&&t.to<=a.to&&Math.abs(t.from-s)t.frome));if(!f){if(rt.from<=r&&t.to>=r)){let t=e.moveToLineBoundary(o.jT.cursor(r),!1,!0).head;t>s&&(r=t)}f=new e_(s,r,this.gapSize(a,s,r,c))}l.push(f)};for(let t of this.viewportLines){let e,n;if(t.lengthn&&(s.push({from:n,to:t}),r+=t-n),n=e}},20),nt.from&&h(t.from,e,t,l),nt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];o.Xs.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},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)||e2(this.heightMap.lineAt(t,eF.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return e2(this.heightMap.lineAt(this.scaler.fromDOM(t),eF.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return e2(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}}class eQ{constructor(t,e){this.from=t,this.to=e}}function eJ({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let s=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:o}=e[t],n=o-i;if(s<=n)return i+s;s-=n}}function eZ(t,e){let i=0;for(let{from:s,to:o}of t.ranges){if(e<=o){i+=e-s;break}i+=o-s}return i/t.total}let e0={toDOM:t=>t,fromDOM:t=>t,scale:1};class e1{constructor(t,e,i){let s=0,o=0,n=0;for(let r of(this.viewports=i.map(({from:i,to:o})=>{let n=e.lineAt(i,eF.ByPos,t,0,0).top,r=e.lineAt(o,eF.ByPos,t,0,0).bottom;return s+=r-n,{from:i,to:o,top:n,bottom:r,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(e.height-s),this.viewports))r.domTop=n+(r.top-o)*this.scale,n=r.domBottom=r.domTop+(r.bottom-r.top),o=r.bottom}toDOM(t){for(let e=0,i=0,s=0;;e++){let o=ee2(t,e)):t._content)}let e8=o.r$.define({combine:t=>t.join(" ")}),e3=o.r$.define({combine:t=>t.indexOf(!0)>-1}),e9=n.V.newName(),e5=n.V.newName(),e4=n.V.newName(),e6={"&light":"."+e5,"&dark":"."+e4};function e7(t,e,i){return new n.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 it=e7("."+e9,{"&":{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",minHeight:"100%",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-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&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",insetInlineStart: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,\')',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"}},e6);class ie{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(o.yy.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+="￿"}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let s=t;;){this.findPointBefore(i,s);let t=this.text.length;this.readNode(s);let o=s.nextSibling;if(o==e)break;let n=T.get(s),r=T.get(o);(n&&r?n.breakAfter:(n?n.breakAfter:f(s))||f(o)&&("BR"!=s.nodeName||s.cmIgnore)&&this.text.length>t)&&this.lineBreak(),s=o}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,s=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,n=1,r;if(this.lineSeparator?(o=e.indexOf(this.lineSeparator,i),n=this.lineSeparator.length):(r=s.exec(e))&&(o=r.index,n=r[0].length),this.append(e.slice(i,o<0?e.length:o)),o<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=o+n}}readNode(t){if(t.cmIgnore)return;let e=T.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+(!function(t,e,i){for(;;){if(!e||i-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=n||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:n}=t.observer.selectionRange;return i&&(e.push(new ii(i,s)),(o!=i||n!=s)&&e.push(new ii(o,n))),e}(t),i=new ie(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,s=2==t.length?t[1].pos:i;return i>-1&&s>-1?o.jT.single(i+e,s+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=n&&n.node==e.focusNode&&n.offset==e.focusOffset||!h(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),s=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!h(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),l=t.viewport;if(($.ios||$.chrome)&&t.state.selection.main.empty&&i!=s&&(l.from>0||l.toDate.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:l}=e.bounds,h=n.from,a=null;(8===r||$.android&&e.text.length0&&l>0&&t.charCodeAt(r-1)==e.charCodeAt(l-1);)r--,l--;if("end"==s){let t=Math.max(0,n-Math.min(r,l));i-=r+t-n}if(r=r?n-i:0;n-=t,l=n+(l-r),r=n}else if(l=l?n-i:0;n-=t,r=n+(r-l),l=n}return{from:n,toA:r,toB:l}}(t.state.doc.sliceString(s,l,"￿"),e.text,h-s,a);c&&($.chrome&&13==r&&c.toB==c.from+2&&"￿￿"==e.text.slice(c.from,c.toB)&&c.toB--,i={from:s+c.from,to:s+c.toA,insert:o.xv.of(e.text.slice(c.from,c.toB).split("￿"))})}else s&&(!t.hasFocus&&t.state.facet(tK)||s.main.eq(n))&&(s=null);if(!i&&!s)return!1;if(!i&&e.typeOver&&!n.empty&&s&&s.main.empty?i={from:n.from,to:n.to,insert:t.state.doc.slice(n.from,n.to)}:i&&i.from>=n.from&&i.to<=n.to&&(i.from!=n.from||i.to!=n.to)&&n.to-n.from-(i.to-i.from)<=4?i={from:n.from,to:n.to,insert:t.state.doc.slice(n.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,n.to))}:($.mac||$.android)&&i&&i.from==i.to&&i.from==n.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(s&&2==i.insert.length&&(s=o.jT.single(s.main.anchor-1,s.main.head-1)),i={from:n.from,to:n.to,insert:o.xv.of([" "])}):$.chrome&&i&&i.from==i.to&&i.from==n.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(s&&(s=o.jT.single(s.main.anchor-1,s.main.head-1)),i={from:n.from,to:n.to,insert:o.xv.of([" "])}),i){let e;if($.ios&&t.inputState.flushIOSKey(i)||$.android&&(i.to==n.to&&(i.from==n.from||i.from==n.from-1&&" "==t.state.sliceDoc(i.from,n.from))&&1==i.insert.length&&2==i.insert.lines&&x(t.contentDOM,"Enter",13)||(i.from==n.from-1&&i.to==n.to&&0==i.insert.length||8==r&&i.insert.lengthn.head)&&x(t.contentDOM,"Backspace",8)||i.from==n.from&&i.to==n.to+1&&0==i.insert.length&&x(t.contentDOM,"Delete",46)))return!0;let l=i.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let h=()=>e||(e=function(t,e,i){let s,n=t.state,r=n.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=r.frome.to?n.sliceDoc(e.to,r.to):"";s=n.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let l=n.changes(e),h=i&&i.main.to<=l.newLength?i.main:void 0;if(n.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let a=t.state.sliceDoc(e.from,e.to),c,d=i&&t4(t,i.main.head);if(d){let t=e.insert.length-(e.to-e.from);c={from:d.from,to:d.to-t}}else c=t.state.doc.lineAt(r.head);let u=r.to-e.to,f=r.to-r.from;s=n.changeByRange(i=>{if(i.from==r.from&&i.to==r.to)return{changes:l,range:h||i.map(l)};let s=i.to-u,d=s-a.length;if(i.to-i.from!=f||t.state.sliceDoc(d,s)!=a||i.to>=c.from&&i.from<=c.to)return{range:i};let p=n.changes({from:d,to:s,insert:e.insert}),g=i.to-r.to;return{changes:p,range:h?o.jT.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):i.map(p)}})}else s={changes:l,selection:h&&n.selection.replaceRange(h)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),n.update(s,{userEvent:l,scrollIntoView:!0})}(t,i,s));return t.state.facet(tV).some(e=>e(t,i.from,i.to,l,h))||t.dispatch(h()),!0}if(!s||s.main.eq(n))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:s,scrollIntoView:e,userEvent:i}),!0}}let ir={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},il=$.ie&&$.ie_version<=11;class ih{constructor(t){this.view=t,this.active=!1,this.selectionRange=new v,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.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);($.ie&&$.ie_version<=11||$.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()}),il&&(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),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate){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")))},{threshold:[0,.001]}),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.runHandlers("scroll",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(t){("change"!=t.type||t.matches)&&(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,s=this.selectionRange;if(i.state.facet(tK)?i.root.activeElement!=this.dom:!a(i.dom,s))return;let o=s.anchorNode&&i.docView.nearest(s.anchorNode);if(o&&o.ignoreEvent(t)){e||(this.selectionChanged=!1);return}($.ie&&$.ie_version<=11||$.android&&$.chrome)&&!i.state.selection.main.empty&&s.focusNode&&d(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=l(t.root);if(!e)return!1;let i=$.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,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return ic(t,i)}let i=null;function s(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",s,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",s,!0),i?ic(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let s=a(this.dom,i);return s&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&x(this.dom,t.key,t.keyCode))})),this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,s=!1;for(let o of t){let t=this.readMutation(o);t&&(t.typeOver&&(s=!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:s}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),s=this.selectionChanged&&a(this.dom,this.selectionRange);if(t<0&&!s)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new is(this.view,t,e,i);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,s=io(this.view,e);return this.view.state==i&&this.view.update([]),s}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.flags|=4),"childList"==t.type){let i=ia(e,t.previousSibling||t.target.previousSibling,-1),s=ia(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:s?e.posBefore(s):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),this.printQuery?this.printQuery.addEventListener("change",this.onPrint):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),this.printQuery?this.printQuery.removeEventListener("change",this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i;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(),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 ia(t,e,i){for(;e;){let s=T.get(e);if(s&&s.parent==t)return s;let o=e.parentNode;e=o!=t.dom?o:i>0?e.nextSibling:e.previousSibling}return null}function ic(t,e){let i=e.startContainer,s=e.startOffset,o=e.endContainer,n=e.endOffset,r=t.docView.domAtPos(t.state.selection.main.anchor);return d(r.node,r.offset,o,n)&&([i,s,o,n]=[o,n,i,s]),{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:n}}class id{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}constructor(t={}){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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:e}=t;for(let i of(this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach(t=>e(t,this)))||(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 eU(t.state||o.yy.create(t)),t.scrollTo&&t.scrollTo.is(tz)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(tj).map(t=>new tX(t)),this.plugins))i.update(this);this.observer=new ih(this),this.inputState=new ea(this),this.inputState.ensureHandlers(this.plugins),this.docView=new t9(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=1==t.length&&t[0]instanceof o.YW?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}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,s,n=this.state;for(let e of t){if(e.startState!=n)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=e.state}if(this.destroyed){this.viewState.state=n;return}let r=this.hasFocus,l=0,h=null;t.some(t=>t.annotation(eR))?(this.inputState.notifiedFocused=r,l=1):r==this.inputState.notifiedFocused||(this.inputState.notifiedFocused=r,(h=eB(n,r))||(l=1));let a=this.observer.delayedAndroidKey,c=null;if(a?(this.observer.clearDelayedAndroidKey(),((c=this.observer.readChange())&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(c=null)):this.observer.clear(),n.facet(o.yy.phrases)!=this.state.facet(o.yy.phrases))return this.setState(n);s=t3.create(this,n,t),s.flags|=l;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 tF(t.empty?t:o.jT.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(tz)&&(d=t.value.clip(this.state))}this.viewState.update(s,d),this.bidiCache=ig.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),e=this.docView.update(s),this.state.facet(t2)!=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(s.startState.facet(e8)!=s.state.facet(e8)&&(this.viewState.mustMeasureContent=!0),(e||i||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!s.empty)for(let t of this.state.facet(tL))try{t(s)}catch(t){tI(this.state,t,"update listener")}(h||c)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),c&&!io(this,c)&&a.force&&x(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 eU(t),this.plugins=t.facet(tj).map(t=>new tX(t)),this.pluginMap.clear(),this.plugins))e.update(this);this.docView.destroy(),this.docView=new t9(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(tj),i=t.state.facet(tj);if(e!=i){let s=[];for(let o of i){let i=e.indexOf(o);if(i<0)s.push(new tX(o));else{let e=this.plugins[i];e.mustUpdate=t,s.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,s=i.scrollTop*this.scaleY,{scrollAnchorPos:o,scrollAnchorHeight:n}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(n=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(n<0){if(k(i))o=-1,n=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(s);o=t.from,n=t.top}}this.updateState=1;let r=this.viewState.measure(this);if(!r&&!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 l=[];4&r||([this.measureRequests,l]=[l,this.measureRequests]);let h=l.map(t=>{try{return t.read(this)}catch(t){return tI(this.state,t),ip}}),a=t3.create(this,this.state,[]),c=!1;a.flags|=r,e?e.flags|=r:e=a,this.updateState=2,!a.empty&&(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),(c=this.docView.update(a))&&this.docViewUpdate());for(let t=0;t1||t<-1){s+=t,i.scrollTop=s/this.scaleY,n=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(tL))t(e)}get themeClasses(){return e9+" "+(this.state.facet(e3)?e4:e5)+" "+this.state.facet(e8)}updateAttrs(){let t=im(this,tG,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(tK)?"true":"false",class:"cm-content",style:`${$.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),im(this,t_,e);let i=this.observer.ignore(()=>{let i=te(this.contentDOM,this.contentAttrs,e),s=te(this.dom,this.editorAttrs,t);return i||s});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(id.announce)&&(e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value)}mountStyles(){this.styleModules=this.state.facet(t2);let t=this.state.facet(id.cspNonce);n.V.mount(this.root,this.styleModules.concat(it).reverse(),t?{nonce:t}:void 0)}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)){if(null!=t.key){for(let e=0;ee.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}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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 eh(this,t,er(this,t,e,i))}moveByGroup(t,e){return eh(this,t,er(this,t,e,e=>{var i;let s,n;return i=t.head,n=(s=this.state.charCategorizer(i))(e),t=>{let e=s(t);return n==o.D0.Space&&(n=e),n==e}}))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from),n=i[e?i.length-1:0];return o.jT.cursor(n.side(e,s)+t.from,n.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,s){let n=en(t,e.head),r=s&&n.type==tn.Text&&(t.lineWrapping||n.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),s=t.textDirectionAt(n.from),l=t.posAtCoords({x:i==(s==tg.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=l)return o.jT.cursor(l,i?-1:1)}return o.jT.cursor(i?n.to:n.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return eh(this,t,function(t,e,i,s){let n=e.head,r=i?1:-1;if(n==(i?t.state.doc.length:0))return o.jT.cursor(n,e.assoc);let l=e.goalColumn,h,a=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(n,e.assoc||-1),d=t.documentTop;if(c)null==l&&(l=c.left-a.left),h=r<0?c.top:c.bottom;else{let e=t.viewState.lineBlockAt(n);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(n-e.from))),h=(r<0?e.top:e.bottom)+d}let u=a.left+l,f=null!=s?s:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=h+(f+e)*r,s=es(t,{x:u,y:i},!1,r);if(ia.bottom||(r<0?sn)){let e=t.docView.coordsForChar(s),n=!e||i0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}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(tN)||tthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>iu)return tD(t.length);let e=this.textDirectionAt(t.from),i;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==e&&(s.fresh||function t(e,i){if(e.length!=i.length)return!1;for(let s=0;stA.length;)tA[tA.length]=256;let s=[],o=e==tm?0:1;return function t(e,i,s,o,n,r,l){let h=i%2?2:1;(function(t,e,i,s,o){for(let n=0;n<=s.length;n++){let r=n?s[n-1].to:e,l=n=0;t-=3)if(tx[t+1]==-s){let i=tx[t+2],s=2&i?o:4&i?1&i?n:o:0;s&&(tA[e]=tA[tx[t]]=s),l=t;break}}else if(189==tx.length)break;else tx[l++]=e,tx[l++]=i,tx[l++]=h}else if(2==(r=tA[e])||1==r){let t=r==o;h=t?0:1;for(let e=l-3;e>=0;e-=3){let i=tx[e+2];if(2&i)break;if(t)tx[e+2]|=2;else{if(4&i)break;tx[e+2]|=4}}}}}(e,n,r,o,h),function(t,e,i,s){for(let o=0,n=s;o<=i.length;o++){let r=o?i[o-1].to:t,l=oh;)e==n&&(e=i[--s].from,n=s?i[s-1].to:t),tA[--e]=c;h=r}else n=r,h++}}}(n,r,o,h),function e(i,s,o,n,r,l,h){let a=n%2?2:1;if(n%2==r%2)for(let c=s,d=0;cc&&h.push(new tC(c,e.from,p)),t(i,e.direction==tm!=!(p%2)?n+1:n,r,e.inner,e.from,e.to,h),c=e.to),g=e.to}else if(g==o||(s?tA[g]!=a:tA[g]==a))break;else g++;f?e(i,c,g,n+1,r,f,h):cs;){let o=!0,u=!1;if(!d||c>l[d-1].to){let t=tA[c-1];t!=a&&(o=!1,u=16==t)}let f=o||1!=a?null:[],p=o?n:n+1,g=c;t:for(;;)if(d&&g==l[d-1].to){if(u)break;let e=l[--d];if(!o)for(let t=e.from,i=d;;){if(t==s)break t;if(i&&l[i-1].to==t)t=l[--i].from;else if(tA[t-1]==a)break t;else break}f?f.push(e):(e.toDate.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{y(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.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return tz.of(new tF("number"==typeof t?o.jT.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return tz.of(new tF(o.jT.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return t$.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return t$.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=n.V.newName(),s=[e8.of(i),t2.of(e7(`.${i}`,t))];return e&&e.dark&&s.push(e3.of(!0)),s}static baseTheme(t){return o.Wl.lowest(t2.of(e7("."+e9,t,e6)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&T.get(i)||T.get(t);return(null===(e=null==s?void 0:s.rootView)||void 0===e?void 0:e.view)||null}}id.styleModule=t2,id.inputHandler=tV,id.scrollHandler=tW,id.focusChangeEffect=tP,id.perLineTextDirection=tN,id.exceptionSink=tB,id.updateListener=tL,id.editable=tK,id.mouseSelectionStyle=tR,id.dragMovesSelection=tE,id.clickAddsSelectionRange=tT,id.decorations=tY,id.outerDecorations=tU,id.atomicRanges=tQ,id.bidiIsolatedRanges=tJ,id.scrollMargins=t0,id.darkTheme=e3,id.cspNonce=o.r$.define({combine:t=>t.length?t[0]:""}),id.contentAttributes=t_,id.editorAttributes=tG,id.lineWrapping=id.contentAttributes.of({class:"cm-lineWrapping"}),id.announce=o.Py.define();let iu=4096,ip={};class ig{constructor(t,e,i,s,o,n){this.from=t,this.to=e,this.dir=i,this.isolates=s,this.fresh=o,this.order=n}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let i=[],s=t.length?t[t.length-1].dir:tg.LTR;for(let o=Math.max(0,t.length-10);o=0;o--){let e=s[o],n="function"==typeof e?e(t):e;n&&J(n,i)}return i}let iw=$.mac?"mac":$.windows?"win":$.linux?"linux":"key";function iv(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 ib=o.Wl.default(id.domEventHandlers({keydown:(t,e)=>(function(t,e,i,s){let n=(0,r.YG)(e),l=(0,o.gm)(n,0),h=(0,o.nZ)(l)==n.length&&" "!=n,a="",c=!1,d=!1,u=!1;ix&&ix.view==i&&ix.scope==s&&(a=ix.prefix+" ",0>ef.indexOf(e.keyCode)&&(d=!0,ix=null));let f=new Set,p=t=>{if(t){for(let s of t.run)if(!f.has(s)&&(f.add(s),s(i,e)))return t.stopPropagation&&(u=!0),!0;t.preventDefault&&(t.stopPropagation&&(u=!0),d=!0)}return!1},g=t[s],m,w;return g&&(p(g[a+iv(n,e,!h)])?c=!0:h&&(e.altKey||e.metaKey||e.ctrlKey)&&!($.windows&&e.ctrlKey&&e.altKey)&&(m=r.ue[e.keyCode])&&m!=n?p(g[a+iv(m,e,!0)])?c=!0:e.shiftKey&&(w=r.uY[e.keyCode])!=n&&w!=m&&p(g[a+iv(w,e,!1)])&&(c=!0):h&&e.shiftKey&&p(g[a+iv(n,e,!0)])&&(c=!0),!c&&p(g._any)&&(c=!0)),d&&(c=!0),c&&u&&e.stopPropagation(),c})(function(t){let e=t.facet(iy),i=iS.get(e);return i||iS.set(e,i=function(t,e=iw){let i=Object.create(null),s=Object.create(null),o=(t,e)=>{let i=s[t];if(null==i)s[t]=e;else if(i!=e)throw Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},n=(t,s,n,r,l)=>{var h,a;let c=i[t]||(i[t]=Object.create(null)),d=s.split(/ (?!$)/).map(t=>(function(t,e){let i,s,o,n;let r=t.split(/-(?!$)/),l=r[r.length-1];"Space"==l&&(l=" ");for(let t=0;t{let s=ix={view:e,prefix:i,scope:t};return setTimeout(()=>{ix==s&&(ix=null)},4e3),!0}]})}let u=d.join(" ");o(u,!1);let f=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(null===(a=null===(h=c._any)||void 0===h?void 0:h.run)||void 0===a?void 0:a.slice())||[]});n&&f.run.push(n),r&&(f.preventDefault=!0),l&&(f.stopPropagation=!0)};for(let s of t){let t=s.scope?s.scope.split(" "):["editor"];if(s.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,stopPropagation:!1,run:[]}),t)t[e].run.push(s.any)}let o=s[e]||s.key;if(o)for(let e of t)n(e,o,s.run,s.preventDefault,s.stopPropagation),s.shift&&n(e,"Shift-"+o,s.shift,s.preventDefault,s.stopPropagation)}return i}(e.reduce((t,e)=>t.concat(e),[]))),i}(e.state),t,e,"editor")})),iy=o.r$.define({enables:ib}),iS=new WeakMap,ix=null;class iM{constructor(t,e,i,s,o){this.className=t,this.left=e,this.top=i,this.width=s,this.height=o}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 s=Math.max(i.from,t.viewport.from),o=Math.min(i.to,t.viewport.to),n=t.textDirection==tg.LTR,r=t.contentDOM,l=r.getBoundingClientRect(),h=ik(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=en(t,s),p=en(t,o),g=f.type==tn.Text?f:null,m=p.type==tn.Text?p:null;if(g&&(t.lineWrapping||f.widgetLineBreaks)&&(g=iC(t,s,g)),m&&(t.lineWrapping||p.widgetLineBreaks)&&(m=iC(t,o,m)),g&&m&&g.from==m.from)return v(b(i.from,i.to,g));{let e=g?b(i.from,null,g):y(f,!1),s=m?b(null,i.to,m):y(p,!0),o=[];return(g||f).to<(m||p).from-(g&&m?1:0)||f.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2a&&s.from=n)break;l>o&&h(Math.max(t,o),null==e&&t<=a,Math.min(l,n),null==i&&l>=c,r.dir)}if((o=s.to+1)>=n)break}return 0==l.length&&h(a,null==e,c,null==i,t.textDirection),{top:o,bottom:r,horizontal:l}}function y(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i);{let s=t.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let o=ik(t);return[new iM(e,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}}}function ik(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==tg.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function iC(t,e,i){let s=o.jT.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(s,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(s,!0,!0).from),type:tn.Text}}class iA{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,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.scale(),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(iD)!=t.state.facet(iD)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){!1!==this.layer.updateOnDocViewUpdate&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(iD);for(;e{var i;return i=this.drawn[e],!(t.constructor==i.constructor&&t.eq(i))})){let e=this.dom.firstChild,i=0;for(let s of t)s.update&&e&&s.constructor&&this.drawn[i].constructor&&s.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(s.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 iD=o.r$.define(),iO=!$.ios,iT=o.r$.define({combine:t=>(0,o.BO)(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}),iE={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};iO&&(iE[".cm-line"].caretColor="transparent !important",iE[".cm-content"]={caretColor:"transparent !important"});let iR=o.Py.define({map:(t,e)=>null==t?null:e.mapPos(t)});function iB(t,e,i,s,o){e.lastIndex=0;for(let n=t.iterRange(i,s),r=i,l;!n.next().done;r+=n.value.length)if(!n.lineBreak)for(;l=e.exec(n.value);)o(r+l.index,l)}class iL{constructor(t){let{regexp:e,decoration:i,decorate:s,boundary:o,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,s)this.addMatch=(t,e,i,o)=>s(o,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,s,o)=>{let n=i(t,e,s);n&&o(s,s+t[0].length,n)};else if(i)this.addMatch=(t,e,s,o)=>o(s,s+t[0].length,i);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=o,this.maxLength=n}createDeco(t){let e=new o.f_,i=e.add.bind(e);for(let{from:e,to:s}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 s=[];for(let{from:o,to:n}of i)o=Math.max(t.state.doc.lineAt(o).from,o-e),n=Math.min(t.state.doc.lineAt(n).to,n+e),s.length&&s[s.length-1].to>=o?s[s.length-1].to=n:s.push({from:o,to:n});return s}(t,this.maxLength))iB(t.state.doc,this.regexp,e,s,(e,s)=>this.addMatch(s,t,e,i));return e.finish()}updateDeco(t,e){let i=1e9,s=-1;return(t.docChanged&&t.changes.iterChanges((e,o,n,r)=>{r>t.view.viewport.from&&n1e3)?this.createDeco(t.view):s>-1?this.updateRange(t.view,e.map(t.changes),i,s):e}updateRange(t,e,i,s){for(let o of t.visibleRanges){let n=Math.max(o.from,i),r=Math.min(o.to,s);if(r>n){let i=t.state.doc.lineAt(n),s=i.toi.from;n--)if(this.boundary.test(i.text[n-1-i.from])){l=n;break}for(;ra.push(i.range(t,e));if(i==s)for(this.regexp.lastIndex=l-i.from;(c=this.regexp.exec(i.text))&&c.indexthis.addMatch(i,t,e,d));e=e.update({filterFrom:l,filterTo:h,filter:(t,e)=>th,add:a})}}return e}}let iV=null!=/x/.unicode?"gu":"g",iP=RegExp("[\0-\b\n-\x1f\x7f-\x9f\xad؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]",iV),iN={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"},iH=null,iW=o.r$.define({combine(t){let e=(0,o.BO)(t,{render:null,specialChars:iP,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==iH&&"undefined"!=typeof document&&document.body){let e=document.body.style;iH=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)!=null}return iH||!1}())&&(e.specialChars=RegExp(" |"+e.specialChars.source,iV)),e.addSpecialChars&&(e.specialChars=RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,iV)),e}});function iF(t={}){return[iW.of(t),iz||(iz=t$.fromClass(class{constructor(t){this.view=t,this.decorations=tr.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(iW)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new iL({regexp:t.specialChars,decoration:(e,i,s)=>{let{doc:n}=i.state,r=(0,o.gm)(e[0],0);if(9==r){let t=n.lineAt(s),e=i.state.tabSize,r=(0,o.IS)(t.text,e,s-t.from);return tr.replace({widget:new iK((e-r%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=tr.replace({widget:new iI(t,r)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(iW);t.startState.facet(iW)!=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 iz=null;class iI extends to{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){var e;let i=(e=this.code)>=32?"•":10==e?"␤":String.fromCharCode(9216+e),s=t.state.phrase("Control character")+" "+(iN[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,s,i);if(o)return o;let n=document.createElement("span");return n.textContent=i,n.title=s,n.setAttribute("aria-label",s),n.className="cm-specialChar",n}ignoreEvent(){return!1}}class iK extends to{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 iq(){return i$}let ij=tr.line({class:"cm-activeLine"}),i$=t$.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 s of t.state.selection.ranges){let o=t.lineBlockAt(s.head);o.from>e&&(i.push(ij.range(o.from)),e=o.from)}return tr.set(i)}},{decorations:t=>t.decorations}),iX="-10000px";class iG{constructor(t,e,i,s){this.facet=e,this.createTooltipView=i,this.removeTooltipView=s,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t);let o=null;this.tooltipViews=this.tooltips.map(t=>o=i(t,o))}update(t,e){var i;let s=t.state.facet(this.facet),o=s.filter(t=>t);if(s===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let n=[],r=e?[]:null;for(let i=0;in.indexOf(t)&&(this.removeTooltipView(t),null===(i=t.destroy)||void 0===i||i.call(t));return e&&(r.forEach((t,i)=>e[i]=t),e.length=r.length),this.input=s,this.tooltips=o,this.tooltipViews=n,!0}}function i_(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}let iY=o.r$.define({combine:t=>{var e,i,s;return{position:$.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===(s=t.find(t=>t.tooltipSpace))||void 0===s?void 0:s.tooltipSpace)||i_}}}),iU=new WeakMap,iQ=t$.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(iY);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.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new iG(t,i0,(t,e)=>this.createTooltip(t,e),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),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,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,s=t.state.facet(iY);if(s.position!=this.position&&!this.madeAbsolute){for(let t of(this.position=s.position,this.manager.tooltipViews))t.dom.style.position=this.position;i=!0}if(s.parent!=this.parent){for(let t of(this.parent&&this.container.remove(),this.parent=s.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,e){let i=t.create(this.view),s=e?e.dom:null;if(i.dom.classList.add("cm-tooltip"),t.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",i.dom.appendChild(t)}return i.dom.style.position=this.position,i.dom.style.top=iX,i.dom.style.left="0px",this.container.insertBefore(i.dom,s),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var t,e,i;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);this.parent&&this.container.remove(),null===(e=this.resizeObserver)||void 0===e||e.disconnect(),null===(i=this.intersectionObserver)||void 0===i||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect(),e=1,i=1,s=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if($.gecko)s=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==iX&&"0px"==t.style.left){let e=t.getBoundingClientRect();s=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(s||"absolute"==this.position){if(this.parent){let t=this.parent.getBoundingClientRect();t.width&&t.height&&(e=t.width/this.parent.offsetWidth,i=t.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:i}=this.view.viewState)}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(iY).tooltipSpace(this.view),scaleX:e,scaleY:i,makeAbsolute:s}}writeMeasure(t){var e;if(t.makeAbsolute)for(let t of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))t.dom.style.position="absolute";let{editor:i,space:s,scaleX:o,scaleY:n}=t,r=[];for(let l=0;l=Math.min(i.bottom,s.bottom)||d.rightMath.min(i.right,s.right)+.1){c.style.top=iX;continue}let f=h.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,g=u.right-u.left,m=null!==(e=iU.get(a))&&void 0!==e?e:u.bottom-u.top,w=a.offset||iZ,v=this.view.textDirection==tg.LTR,b=u.width>s.right-s.left?v?s.left:s.right-u.width:v?Math.min(d.left-(f?14:0)+w.x,s.right-g):Math.max(s.left,d.left-g+(f?14:0)-w.x),y=this.above[l];!h.strictSide&&(y?d.top-(u.bottom-u.top)-w.ys.bottom)&&y==s.bottom-d.bottom>d.top-s.top&&(y=this.above[l]=!y);let S=(y?d.top-s.top:s.bottom-d.bottom)-p;if(Sb&&t.topx&&(x=y?t.top-m-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(x-t.parent.top)/n+"px",c.style.left=(b-t.parent.left)/o+"px"):(c.style.top=x/n+"px",c.style.left=b/o+"px"),f){let t=d.left+(v?w.x:-w.x)-(b+14-7);f.style.left=t/o+"px"}!0!==a.overlap&&r.push({left:b,top:x,right:M,bottom:x+m}),c.classList.toggle("cm-tooltip-above",y),c.classList.toggle("cm-tooltip-below",!y),a.positioned&&a.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=iX}},{eventObservers:{scroll(){this.maybeMeasure()}}}),iJ=id.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"}}}),iZ={x:0,y:0},i0=o.r$.define({enables:[iQ,iJ]}),i1=o.r$.define({combine:t=>t.reduce((t,e)=>t.concat(e),[])});class i2{static create(t){return new i2(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new iG(t,i1,(t,e)=>this.createHostedView(t,e),t=>t.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}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)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let s=i[t];if(void 0!==s){if(void 0===e)e=s;else if(e!==s)return}}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}function i8(t,e){let i=t.plugin(iQ);if(!i)return null;let s=i.manager.tooltips.indexOf(e);return s<0?null:i.manager.tooltipViews[s]}let i3=o.r$.define({combine(t){let e,i;for(let s of t)e=e||s.topContainer,i=i||s.bottomContainer;return{topContainer:e,bottomContainer:i}}}),i9=t$.fromClass(class{constructor(t){this.input=t.state.facet(i6),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet(i3);for(let i of(this.top=new i5(t,!0,e.topContainer),this.bottom=new i5(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(i3);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new i5(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new i5(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(i6);if(i!=this.input){let e=i.filter(t=>t),s=[],o=[],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),s.push(l),(l.top?o:n).push(l)}for(let t of(this.specs=e,this.panels=s,this.top.sync(o),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=>id.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class i5{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=i4(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=i4(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function i4(t){let e=t.nextSibling;return t.remove(),e}let i6=o.r$.define({enables:i9});class i7 extends o.uU{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}i7.prototype.elementClass="",i7.prototype.toDOM=void 0,i7.prototype.mapMode=o.gc.TrackBefore,i7.prototype.startSide=i7.prototype.endSide=-1,i7.prototype.point=!0;let st=o.r$.define(),se=o.r$.define(),si=o.r$.define({combine:t=>t.some(t=>t)}),ss=t$.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/this.view.scaleY+"px",this.gutters=t.state.facet(se).map(e=>new sl(t,e)),this.gutters))this.dom.appendChild(e.dom);this.fixed=!t.state.facet(si),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,s=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(s<(i.to-i.from)*.8)}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(si)!=!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=o.Xs.iter(this.view.state.facet(st),this.view.viewport.from),s=[],n=this.gutters.map(t=>new sr(t,this.view.viewport,-this.view.documentPadding.top));for(let t of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(t.type)){let e=!0;for(let o of t.type)if(o.type==tn.Text&&e){for(let t of(sn(i,s,o.from),n))t.line(this.view,o,s);e=!1}else if(o.widget)for(let t of n)t.widget(this.view,o)}else if(t.type==tn.Text)for(let e of(sn(i,s,t.from),n))e.line(this.view,t,s);else if(t.widget)for(let e of n)e.widget(this.view,t);for(let t of n)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(se),i=t.state.facet(se),s=t.docChanged||t.heightChanged||t.viewportChanged||!o.Xs.eq(t.startState.facet(st),t.state.facet(st),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(s=!0);else{s=!0;let o=[];for(let s of i){let i=e.indexOf(s);i<0?o.push(new sl(this.view,s)):(this.gutters[i].update(t),o.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),0>o.indexOf(t)&&t.destroy();for(let t of o)this.dom.appendChild(t.dom);this.gutters=o}return s}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>id.scrollMargins.of(e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==tg.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null})});function so(t){return Array.isArray(t)?t:[t]}function sn(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class sr{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=o.Xs.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:s}=this,o=(e.top-this.height)/t.scaleY,n=e.height/t.scaleY;if(this.i==s.elements.length){let e=new sh(t,n,o,i);s.elements.push(e),s.dom.appendChild(e.dom)}else s.elements[this.i].update(t,n,o,i);this.height=e.bottom,this.i++}line(t,e,i){let s=[];sn(this.cursor,s,e.from),i.length&&(s=s.concat(i));let o=this.gutter.config.lineMarker(t,e,s);o&&s.unshift(o);let n=this.gutter;(0!=s.length||n.config.renderEmptyElements)&&this.addElement(t,e,s)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e);i&&this.addElement(t,e,[i])}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class sl{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="cm-gutter"+(this.config.class?" "+this.config.class:""),e.domEventHandlers)this.dom.addEventListener(i,s=>{let o=s.target,n;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let t=o.getBoundingClientRect();n=(t.top+t.bottom)/2}else n=s.clientY;let r=t.lineBlockAtHeight(n-t.documentTop);e.domEventHandlers[i](t,r,s)&&s.preventDefault()});this.markers=so(e.markers(t)),e.initialSpacer&&(this.spacer=new sh(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=so(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!o.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()}}class sh{constructor(t,e,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,s)}update(t,e,i,s){this.height!=e&&(this.height=e,this.dom.style.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(0,o.BO)(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let s=i[t],o=e[t];i[t]=s?(t,e,i)=>s(t,e,i)||o(t,e,i):o}return i}})});class sd extends i7{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function su(t,e){return t.state.facet(sc).formatNumber(e,t.state)}let sf=se.compute([sc],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(sa),lineMarker:(t,e,i)=>i.some(t=>t.toDOM)?null:new sd(su(t,t.state.doc.lineAt(e.from).number)),widgetMarker:()=>null,lineMarkerChange:t=>t.startState.facet(sc)!=t.state.facet(sc),initialSpacer:t=>new sd(su(t,sg(t.state.doc.lines))),updateSpacer(t,e){let i=su(e.view,sg(e.view.state.doc.lines));return i==t.number?t:new sd(i)},domEventHandlers:t.facet(sc).domEventHandlers}));function sp(t={}){let e;return[sc.of(t),e=[ss],sf]}function sg(t){let e=9;for(;e