satis 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +11 -0
- data/.gitignore +15 -0
- data/.nvmrc +1 -0
- data/.rubocop.yml +18 -0
- data/Gemfile +27 -0
- data/Procfile +2 -0
- data/TODO.md +26 -0
- data/app/assets/images/satis/.keep +0 -0
- data/bin/importmap +4 -0
- data/bin/rails +14 -0
- data/lib/satis/version.rb +1 -1
- data/package.json +9 -0
- data/satis.gemspec +39 -0
- data/vendor/javascript/@codemirror--autocomplete.js +2 -0
- data/vendor/javascript/@codemirror--commands.js +2 -0
- data/vendor/javascript/@codemirror--lang-css.js +2 -0
- data/vendor/javascript/@codemirror--lang-html.js +2 -0
- data/vendor/javascript/@codemirror--lang-javascript.js +2 -0
- data/vendor/javascript/@codemirror--lang-json.js +2 -0
- data/vendor/javascript/@codemirror--lang-liquid.js +2 -0
- data/vendor/javascript/@codemirror--lang-markdown.js +2 -0
- data/vendor/javascript/@codemirror--lang-yaml.js +2 -0
- data/vendor/javascript/@codemirror--language.js +2 -0
- data/vendor/javascript/@codemirror--lint.js +2 -0
- data/vendor/javascript/@codemirror--search.js +2 -0
- data/vendor/javascript/@codemirror--state.js +2 -0
- data/vendor/javascript/@codemirror--view.js +2 -0
- data/vendor/javascript/@lezer--common.js +2 -0
- data/vendor/javascript/@lezer--css.js +2 -0
- data/vendor/javascript/@lezer--highlight.js +2 -0
- data/vendor/javascript/@lezer--html.js +2 -0
- data/vendor/javascript/@lezer--javascript.js +2 -0
- data/vendor/javascript/@lezer--json.js +2 -0
- data/vendor/javascript/@lezer--lr.js +2 -0
- data/vendor/javascript/@lezer--markdown.js +2 -0
- data/vendor/javascript/@lezer--yaml.js +2 -0
- data/vendor/javascript/@rails--actiontext.js +2 -0
- data/vendor/javascript/codemirror.js +2 -0
- data/vendor/javascript/crelt.js +2 -0
- data/vendor/javascript/data.min.js +7 -0
- data/vendor/javascript/intl-tel-input-utils.js +520 -0
- data/vendor/javascript/intl-tel-input.js +1782 -0
- data/vendor/javascript/leaflet.js +6 -0
- data/vendor/javascript/popper.js.js +1805 -0
- data/vendor/javascript/sortablejs.js +134 -0
- data/vendor/javascript/style-mod.js +2 -0
- data/vendor/javascript/tippy.js.js +2 -0
- data/vendor/javascript/trix.js +2 -0
- data/vendor/javascript/w3c-keyname.js +2 -0
- data/yarn.lock +821 -0
- metadata +51 -2
@@ -0,0 +1,2 @@
|
|
1
|
+
import{Text as t,RangeValue as e,RangeSet as i,MapMode as s,findClusterBreak as o,EditorSelection as n,Facet as r,StateEffect as l,ChangeSet as a,findColumn as h,CharCategory as c,EditorState as d,Annotation as u,Transaction as f,Prec as p,codePointAt as g,codePointSize as m,combineConfig as w,StateField as v,RangeSetBuilder as b,countColumn as y}from"@codemirror/state";import{StyleModule as S}from"style-mod";import{keyName as M,base as x,shift as C}from"w3c-keyname";function getSelection(t){let e;e=t.nodeType==11?t.getSelection?t:t.ownerDocument:t;return e.getSelection()}function contains(t,e){return!!e&&(t==e||t.contains(e.nodeType!=1?e.parentNode:e))}function deepActiveElement(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function hasSelection(t,e){if(!e.anchorNode)return false;try{return contains(t,e.anchorNode)}catch(t){return false}}function clientRectsFor(t){return t.nodeType==3?textRange(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function isEquivalentPosition(t,e,i,s){return!!i&&(scanFor(t,e,i,s,-1)||scanFor(t,e,i,s,1))}function domIndex(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}}function scanFor(t,e,i,s,o){for(;;){if(t==i&&e==s)return true;if(e==(o<0?0:maxOffset(t))){if(t.nodeName=="DIV")return false;let i=t.parentNode;if(!i||i.nodeType!=1)return false;e=domIndex(t)+(o<0?0:1);t=i}else{if(t.nodeType!=1)return false;t=t.childNodes[e+(o<0?-1:0)];if(t.nodeType==1&&t.contentEditable=="false")return false;e=o<0?maxOffset(t):0}}}function maxOffset(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function flattenRect(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function windowRect(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function getScale(t,e){let i=e.width/t.offsetWidth;let s=e.height/t.offsetHeight;(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1);(s>.995&&s<1.005||!isFinite(s)||Math.abs(e.height-t.offsetHeight)<1)&&(s=1);return{scaleX:i,scaleY:s}}function scrollRectIntoView(t,e,i,s,o,n,r,l){let a=t.ownerDocument,h=a.defaultView||window;for(let c=t,d=false;c&&!d;)if(c.nodeType==1){let t,u=c==a.body;let f=1,p=1;if(u)t=windowRect(h);else{/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(d=true);if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:f,scaleY:p}=getScale(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(o=="nearest"){if(e.top<t.top){m=-(t.top-e.top+r);i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+r)}else if(e.bottom>t.bottom){m=e.bottom-t.bottom+r;i<0&&e.top-m<t.top&&(m=-(t.top+m-e.top+r))}}else{let s=e.bottom-e.top,n=t.bottom-t.top;let l=o=="center"&&s<=n?e.top+s/2-n/2:o=="start"||o=="center"&&i<0?e.top-r:e.bottom-n+r;m=l-t.top}if(s=="nearest"){if(e.left<t.left){g=-(t.left-e.left+n);i>0&&e.right>t.right+g&&(g=e.right-t.right+g+n)}else if(e.right>t.right){g=e.right-t.right+n;i<0&&e.left<t.left+g&&(g=-(t.left+g-e.left+n))}}else{let i=s=="center"?e.left+(e.right-e.left)/2-(t.right-t.left)/2:s=="start"==l?e.left-n:e.right-(t.right-t.left)+n;g=i-t.left}if(g||m)if(u)h.scrollBy(g,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/p;i=(c.scrollTop-t)*p}if(g){let e=c.scrollLeft;c.scrollLeft+=g/f;t=(c.scrollLeft-e)*f}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i};t&&Math.abs(t-g)<1&&(s="nearest");i&&Math.abs(i-m)<1&&(o="nearest")}if(u)break;c=c.assignedSlot||c.parentNode}else{if(c.nodeType!=11)break;c=c.host}}function scrollableParent(t){let e=t.ownerDocument;for(let i=t.parentNode;i;){if(i==e.body)break;if(i.nodeType==1){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(i.nodeType!=11)break;i=i.host}}return null}class DOMSelectionState{constructor(){this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?maxOffset(e):0),i,Math.min(t.focusOffset,i?maxOffset(i):0))}set(t,e,i,s){this.anchorNode=t;this.anchorOffset=e;this.focusNode=i;this.focusOffset=s}}let k=null;function focusPreventScroll(t){if(t.setActive)return t.setActive();if(k)return t.focus(k);let e=[];for(let i=t;i;i=i.parentNode){e.push(i,i.scrollTop,i.scrollLeft);if(i==i.ownerDocument)break}t.focus(k==null?{get preventScroll(){k={preventScroll:true};return true}}:void 0);if(!k){k=false;for(let t=0;t<e.length;){let i=e[t++],s=e[t++],o=e[t++];i.scrollTop!=s&&(i.scrollTop=s);i.scrollLeft!=o&&(i.scrollLeft=o)}}}let A;function textRange(t,e,i=e){let s=A||(A=document.createRange());s.setEnd(t,i);s.setStart(t,e);return s}function dispatchKey(t,e,i){let s={key:e,code:e,keyCode:i,which:i,cancelable:true};let o=new KeyboardEvent("keydown",s);o.synthetic=true;t.dispatchEvent(o);let n=new KeyboardEvent("keyup",s);n.synthetic=true;t.dispatchEvent(n);return o.defaultPrevented||n.defaultPrevented}function getRoot(t){while(t){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function clearAttributes(t){while(t.attributes.length)t.removeAttributeNode(t.attributes[0])}function atElementStart(t,e){let i=e.focusNode,s=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=s)return false;s=Math.min(s,maxOffset(i));for(;;)if(s){if(i.nodeType!=1)return false;let t=i.childNodes[s-1];if(t.contentEditable=="false")s--;else{i=t;s=maxOffset(i)}}else{if(i==t)return true;s=domIndex(i);i=i.parentNode}}function isScrolledToBottom(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}class DOMPos{constructor(t,e,i=true){this.node=t;this.offset=e;this.precise=i}static before(t,e){return new DOMPos(t.parentNode,domIndex(t),e)}static after(t,e){return new DOMPos(t.parentNode,domIndex(t)+1,e)}}const D=[];class ContentView{constructor(){this.parent=null;this.dom=null;this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(this.flags&2){let i=this.dom;let s,o=null;for(let n of this.children){if(n.flags&7){if(!n.dom&&(s=o?o.nextSibling:i.firstChild)){let t=ContentView.get(s);(!t||!t.parent&&t.canReuseDOM(n))&&n.reuseDOM(s)}n.sync(t,e);n.flags&=-8}s=o?o.nextSibling:i.firstChild;e&&!e.written&&e.node==i&&s!=n.dom&&(e.written=true);if(n.dom.parentNode==i)while(s&&s!=n.dom)s=rm$1(s);else i.insertBefore(n.dom,s);o=n.dom}s=o?o.nextSibling:i.firstChild;s&&e&&e.node==i&&(e.written=true);while(s)s=rm$1(s)}else if(this.flags&1)for(let i of this.children)if(i.flags&7){i.sync(t,e);i.flags&=-8}}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let s=maxOffset(t)==0?0:e==0?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;s==0&&e.firstChild!=e.lastChild&&(s=t==e.firstChild?-1:1);t=e}i=s<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;while(i&&!ContentView.get(i))i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let s=this.children[t];if(s.dom==i)return e;e+=s.length+s.breakAfter}}domBoundsAround(t,e,i=0){let s=-1,o=-1,n=-1,r=-1;for(let l=0,a=i,h=i;l<this.children.length;l++){let i=this.children[l],c=a+i.length;if(a<t&&c>e)return i.domBoundsAround(t,e,a);if(c>=t&&s==-1){s=l;o=a}if(a>e&&i.dom.parentNode==this.dom){n=l;r=h;break}h=c;a=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<this.children.length&&n>=0?this.children[n].dom:null}}markDirty(t=false){this.flags|=2;this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){t&&(e.flags|=2);if(e.flags&1)return;e.flags|=1;t=false}}setParent(t){if(this.parent!=t){this.parent=t;this.flags&7&&this.markParentsDirty(true)}}setDOM(t){if(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=D){this.markDirty();for(let s=t;s<e;s++){let t=this.children[s];t.parent==this&&i.indexOf(t)<0&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return false}ignoreEvent(t){return false}childCursor(t=this.length){return new ChildCursor(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+(t=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return true}get isWidget(){return false}get isHidden(){return false}merge(t,e,i,s,o,n){return false}become(t){return false}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}ContentView.prototype.breakAfter=0;function rm$1(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class ChildCursor{constructor(t,e,i){this.children=t;this.pos=e;this.i=i;this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||this.i==0||this.children[this.i-1].breakAfter)){this.off=t-this.pos;return this}let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function replaceRange(t,e,i,s,o,n,r,l,a){let{children:h}=t;let c=h.length?h[e]:null;let d=n.length?n[n.length-1]:null;let u=d?d.breakAfter:r;if(!(e==s&&c&&!r&&!u&&n.length<2&&c.merge(i,o,n.length?d:null,i==0,l,a))){if(s<h.length){let t=h[s];if(t&&(o<t.length||t.breakAfter&&(d===null||d===void 0?void 0:d.breakAfter))){if(e==s){t=t.split(o);o=0}if(!u&&d&&t.merge(0,o,d,true,0,a))n[n.length-1]=t;else{(o||t.children.length&&!t.children[0].length)&&t.merge(0,o,null,false,0,a);n.push(t)}}else(t===null||t===void 0?void 0:t.breakAfter)&&(d?d.breakAfter=1:r=1);s++}if(c){c.breakAfter=r;if(i>0){!r&&n.length&&c.merge(i,c.length,n[0],false,l,0)?c.breakAfter=n.shift().breakAfter:(i<c.length||c.children.length&&c.children[c.children.length-1].length==0)&&c.merge(i,c.length,null,false,l,0);e++}}while(e<s&&n.length)if(h[s-1].become(n[n.length-1])){s--;n.pop();a=n.length?0:l}else{if(!h[e].become(n[0]))break;e++;n.shift();l=n.length?0:a}!n.length&&e&&s<h.length&&!h[e-1].breakAfter&&h[s].merge(0,0,h[e-1],false,l,a)&&e--;(e<s||n.length)&&t.replaceChildren(e,s,n)}}function mergeChildrenInto(t,e,i,s,o,n){let r=t.childCursor();let{i:l,off:a}=r.findPos(i,1);let{i:h,off:c}=r.findPos(e,-1);let d=e-i;for(let t of s)d+=t.length;t.length+=d;replaceRange(t,h,c,l,a,s,0,o,n)}let T=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""};let O=typeof document!="undefined"?document:{documentElement:{style:{}}};const R=/Edge\/(\d+)/.exec(T.userAgent);const V=/MSIE \d/.test(T.userAgent);const B=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(T.userAgent);const E=!!(V||B||R);const P=!E&&/gecko\/(\d+)/i.test(T.userAgent);const L=!E&&/Chrome\/(\d+)/.exec(T.userAgent);const H="webkitFontSmoothing"in O.documentElement.style;const N=!E&&/Apple Computer/.test(T.vendor);const W=N&&(/Mobile\/\w+/.test(T.userAgent)||T.maxTouchPoints>2);var F={mac:W||/Mac/.test(T.platform),windows:/Win/.test(T.platform),linux:/Linux|X11/.test(T.platform),ie:E,ie_version:V?O.documentMode||6:B?+B[1]:R?+R[1]:0,gecko:P,gecko_version:P?+(/Firefox\/(\d+)/.exec(T.userAgent)||[0,0])[1]:0,chrome:!!L,chrome_version:L?+L[1]:0,ios:W,android:/Android\b/.test(T.userAgent),webkit:H,safari:N,webkit_version:H?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:O.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const I=256;class TextView extends ContentView{constructor(t){super();this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM();if(this.dom.nodeValue!=this.text){e&&e.node==this.dom&&(e.written=true);this.dom.nodeValue=this.text}}reuseDOM(t){t.nodeType==3&&this.createDOM(t)}merge(t,e,i){if(this.flags&8||i&&(!(i instanceof TextView)||this.length-(e-t)+i.length>I||i.flags&8))return false;this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e);this.markDirty();return true}split(t){let e=new TextView(this.text.slice(t));this.text=this.text.slice(0,t);this.markDirty();e.flags|=this.flags&8;return e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new DOMPos(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return textCoords(this.dom,t,e)}}class MarkView extends ContentView{constructor(t,e=[],i=0){super();this.mark=t;this.children=e;this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){clearAttributes(t);this.mark.class&&(t.className=this.mark.class);if(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)&&!(8&(this.flags|t.flags))}reuseDOM(t){if(t.nodeName==this.mark.tagName.toUpperCase()){this.setDOM(t);this.flags|=6}}sync(t,e){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));super.sync(t,e)}merge(t,e,i,s,o,n){if(i&&(!(i instanceof MarkView&&i.mark.eq(this.mark))||t&&o<=0||e<this.length&&n<=0))return false;mergeChildrenInto(this,t,e,i?i.children.slice():[],o-1,n-1);this.markDirty();return true}split(t){let e=[],i=0,s=-1,o=0;for(let n of this.children){let r=i+n.length;r>t&&e.push(i<t?n.split(t-i):n);s<0&&i>=t&&(s=o);i=r;o++}let n=this.length-t;this.length=t;if(s>-1){this.children.length=s;this.markDirty()}return new MarkView(this.mark,e,n)}domAtPos(t){return inlineDOMAtPos(this,t)}coordsAt(t,e){return coordsInChildren(this,t,e)}}function textCoords(t,e,i){let s=t.nodeValue.length;e>s&&(e=s);let o=e,n=e,r=0;if(e==0&&i<0||e==s&&i>=0){if(!(F.chrome||F.gecko))if(e){o--;r=1}else if(n<s){n++;r=-1}}else i<0?o--:n<s&&n++;let l=textRange(t,o,n).getClientRects();if(!l.length)return null;let a=l[(r?r<0:i>=0)?0:l.length-1];F.safari&&!r&&a.width==0&&(a=Array.prototype.find.call(l,(t=>t.width))||a);return r?flattenRect(a,r<0):a||null}class WidgetView extends ContentView{static create(t,e,i){return new WidgetView(t,e,i)}constructor(t,e,i){super();this.widget=t;this.length=e;this.side=i;this.prevWidget=null}split(t){let e=WidgetView.create(this.widget,this.length-t,this.side);this.length-=t;return e}sync(t){if(!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){if(i&&(!(i instanceof WidgetView)||!this.widget.compare(i.widget)||t>0&&o<=0||e<this.length&&n<=0))return false;this.length=t+(i?i.length:0)+(this.length-e);return true}become(t){if(t instanceof WidgetView&&t.side==this.side&&this.widget.constructor==t.widget.constructor){this.widget.compare(t.widget)||this.markDirty(true);this.dom&&!this.prevWidget&&(this.prevWidget=this.widget);this.widget=t.widget;this.length=t.length;return true}return false}ignoreMutation(){return true}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(this.length==0)return t.empty;let e=this;while(e.parent)e=e.parent;let{view:i}=e,s=i&&i.state.doc,o=this.posAtStart;return s?s.slice(o,o+this.length):t.empty}domAtPos(t){return(this.length?t==0:this.side>0)?DOMPos.before(this.dom):DOMPos.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;;e+=n?-1:1){o=s[e];if(t>0?e==0:e==s.length-1||o.top<o.bottom)break}return flattenRect(o,!n)}get isEditable(){return false}get isWidget(){return true}get isHidden(){return this.widget.isHidden}destroy(){super.destroy();this.dom&&this.widget.destroy(this.dom)}}class WidgetBufferView extends ContentView{constructor(t){super();this.side=t}get length(){return 0}merge(){return false}become(t){return t instanceof WidgetBufferView&&t.side==this.side}split(){return new WidgetBufferView(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer";t.setAttribute("aria-hidden","true");this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?DOMPos.before(this.dom):DOMPos.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return t.empty}get isHidden(){return true}}TextView.prototype.children=WidgetView.prototype.children=WidgetBufferView.prototype.children=D;function inlineDOMAtPos(t,e){let i=t.dom,{children:s}=t,o=0;for(let t=0;o<s.length;o++){let n=s[o],r=t+n.length;if(!(r==t&&n.getSide()<=0)){if(e>t&&e<r&&n.dom.parentNode==i)return n.domAtPos(e-t);if(e<=t)break;t=r}}for(let t=o;t>0;t--){let e=s[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=o;t<s.length;t++){let e=s[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new DOMPos(i,0)}function joinInlineInto(t,e,i){let s,{children:o}=t;if(i>0&&e instanceof MarkView&&o.length&&(s=o[o.length-1])instanceof MarkView&&s.mark.eq(e.mark))joinInlineInto(s,e.children[0],i-1);else{o.push(e);e.setParent(t)}t.length+=e.length}function coordsInChildren(t,e,i){let s=null,o=-1,n=null,r=-1;function scan(t,e){for(let l=0,a=0;l<t.children.length&&a<=e;l++){let h=t.children[l],c=a+h.length;if(c>=e)if(h.children.length)scan(h,e-a);else if((!n||n.isHidden&&i>0)&&(c>e||a==c&&h.getSide()>0)){n=h;r=e-a}else if(a<e||a==c&&h.getSide()<0&&!h.isHidden){s=h;o=e-a}a=c}}scan(t,e);let l=(i<0?s:n)||s||n;return l?l.coordsAt(Math.max(0,l==s?o:r),i):fallbackRect(t)}function fallbackRect(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=clientRectsFor(e);return i[i.length-1]||null}function combineAttrs(t,e){for(let i in t)i=="class"&&e.class?e.class+=" "+t.class:i=="style"&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}const z=Object.create(null);function attrsEq(t,e,i){if(t==e)return true;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 false;for(let n of s)if(n!=i&&(o.indexOf(n)==-1||t[n]!==e[n]))return false;return true}function updateAttrs(t,e,i){let s=false;if(e)for(let o in e)if(!(i&&o in i)){s=true;o=="style"?t.style.cssText="":t.removeAttribute(o)}if(i)for(let o in i)if(!(e&&e[o]==i[o])){s=true;o=="style"?t.style.cssText=i[o]:t.setAttribute(o,i[o])}return s}function getAttrs(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let s=t.attributes[i];e[s.name]=s.value}return e}class LineView extends ContentView{constructor(){super(...arguments);this.children=[];this.length=0;this.prevAttrs=void 0;this.attrs=null;this.breakAfter=0}merge(t,e,i,s,o,n){if(i){if(!(i instanceof LineView))return false;this.dom||i.transferDOM(this)}s&&this.setDeco(i?i.attrs:null);mergeChildrenInto(this,t,e,i?i.children.slice():[],o,n);return true}split(t){let e=new LineView;e.breakAfter=this.breakAfter;if(this.length==0)return e;let{i:i,off:s}=this.childPos(t);if(s){e.append(this.children[i].split(s),0);this.children[i].merge(s,this.children[i].length,null,false,0,0);i++}for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);while(i>0&&this.children[i-1].length==0)this.children[--i].destroy();this.children.length=i;this.markDirty();this.length=t;return e}transferDOM(t){if(this.dom){this.markDirty();t.setDOM(this.dom);t.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs;this.prevAttrs=void 0;this.dom=null}}setDeco(t){if(!attrsEq(this.attrs,t)){if(this.dom){this.prevAttrs=this.attrs;this.markDirty()}this.attrs=t}}append(t,e){joinInlineInto(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=combineAttrs(e,this.attrs||{}));i&&(this.attrs=combineAttrs({class:i},this.attrs||{}))}domAtPos(t){return inlineDOMAtPos(this,t)}reuseDOM(t){if(t.nodeName=="DIV"){this.setDOM(t);this.flags|=6}}sync(t,e){var i;if(this.dom){if(this.flags&4){clearAttributes(this.dom);this.dom.className="cm-line";this.prevAttrs=this.attrs?null:void 0}}else{this.setDOM(document.createElement("div"));this.dom.className="cm-line";this.prevAttrs=this.attrs?null:void 0}if(this.prevAttrs!==void 0){updateAttrs(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;while(s&&ContentView.get(s)instanceof MarkView)s=s.lastChild;if(!s||!this.length||s.nodeName!="BR"&&((i=ContentView.get(s))===null||i===void 0?void 0:i.isEditable)==false&&(!F.ios||!this.children.some((t=>t instanceof TextView)))){let t=document.createElement("BR");t.cmIgnore=true;this.dom.appendChild(t)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof TextView)||/[^ -~]/.test(i.text))return null;let s=clientRectsFor(i.dom);if(s.length!=1)return null;e+=s[0].width;t=s[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=coordsInChildren(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let s=(e-t.textHeight)/2;return{top:i.top+s,bottom:i.bottom-s,left:i.left,right:i.left}}}return i}become(t){return false}covers(){return true}static find(t,e){for(let i=0,s=0;i<t.children.length;i++){let o=t.children[i],n=s+o.length;if(n>=e){if(o instanceof LineView)return o;if(n>e)break}s=n+o.breakAfter}return null}}class BlockWidgetView extends ContentView{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){if(i&&(!(i instanceof BlockWidgetView)||!this.widget.compare(i.widget)||t>0&&o<=0||e<this.length&&n<=0))return false;this.length=t+(i?i.length:0)+(this.length-e);return true}domAtPos(t){return t==0?DOMPos.before(this.dom):DOMPos.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new BlockWidgetView(this.widget,e,this.deco);i.breakAfter=this.breakAfter;return i}get children(){return D}sync(t){if(!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")}}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):t.empty}domBoundsAround(){return null}become(t){if(t instanceof BlockWidgetView&&t.widget.constructor==this.widget.constructor){t.widget.compare(this.widget)||this.markDirty(true);this.dom&&!this.prevWidget&&(this.prevWidget=this.widget);this.widget=t.widget;this.length=t.length;this.deco=t.deco;this.breakAfter=t.breakAfter;return true}return false}ignoreMutation(){return true}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return false}get isWidget(){return true}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy();this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class WidgetType{eq(t){return false}updateDOM(t,e){return false}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return true}coordsAt(t,e,i){return null}get isHidden(){return false}get editable(){return false}destroy(t){}}var G=function(t){t[t.Text=0]="Text";t[t.WidgetBefore=1]="WidgetBefore";t[t.WidgetAfter=2]="WidgetAfter";t[t.WidgetRange=3]="WidgetRange";return t}(G||(G={}));class Decoration extends e{constructor(t,e,i,s){super();this.startSide=t;this.endSide=e;this.widget=i;this.spec=s}get heightRelevant(){return false}static mark(t){return new MarkDecoration(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8;return new PointDecoration(t,e,e,i,t.widget||null,false)}static replace(t){let e,i,s=!!t.block;if(t.isBlockGap){e=-5e8;i=4e8}else{let{start:o,end:n}=getInclusive(t,s);e=(o?s?-3e8:-1:5e8)-1;i=1+(n?s?2e8:1:-6e8)}return new PointDecoration(t,e,i,s,t.widget||null,true)}static line(t){return new LineDecoration(t)}static set(t,e=false){return i.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Decoration.none=i.empty;class MarkDecoration extends Decoration{constructor(t){let{start:e,end:i}=getInclusive(t);super(e?-1:5e8,i?1:-6e8,null,t);this.tagName=t.tagName||"span";this.class=t.class||"";this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof MarkDecoration&&this.tagName==t.tagName&&(this.class||((e=this.attrs)===null||e===void 0?void 0:e.class))==(t.class||((i=t.attrs)===null||i===void 0?void 0:i.class))&&attrsEq(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}MarkDecoration.prototype.point=false;class LineDecoration extends Decoration{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof LineDecoration&&this.spec.class==t.spec.class&&attrsEq(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}LineDecoration.prototype.mapMode=s.TrackBefore;LineDecoration.prototype.point=true;class PointDecoration extends Decoration{constructor(t,e,i,o,n,r){super(e,i,n,t);this.block=o;this.isReplace=r;this.mapMode=o?e<=0?s.TrackBefore:s.TrackAfter:s.TrackDel}get type(){return this.startSide!=this.endSide?G.WidgetRange:this.startSide<=0?G.WidgetBefore:G.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof PointDecoration&&widgetsEq(this.widget,t.widget)&&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 new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}PointDecoration.prototype.point=true;function getInclusive(t,e=false){let{inclusiveStart:i,inclusiveEnd:s}=t;i==null&&(i=t.inclusive);s==null&&(s=t.inclusive);return{start:i!==null&&i!==void 0?i:e,end:s!==null&&s!==void 0?s:e}}function widgetsEq(t,e){return t==e||!!(t&&e&&t.compare(e))}function addRange(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)}class ContentBuilder{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=true;this.openStart=-1;this.openEnd=-1;this.text="";this.textOff=0;this.cursor=t.iter();this.skip=e}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof BlockWidgetView&&t.deco.endSide<0)}getLine(){if(!this.curLine){this.content.push(this.curLine=new LineView);this.atCursorPos=true}return this.curLine}flushBuffer(t=this.bufferMarks){if(this.pendingBuffer){this.curLine.append(wrapMarks(new WidgetBufferView(-1),t),t.length);this.pendingBuffer=0}}addBlockWidget(t){this.flushBuffer();this.curLine=null;this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0;this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof BlockWidgetView||this.getLine()}buildText(t,e,i){while(t>0){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:s}=this.cursor.next(this.skip);this.skip=0;if(s)throw new 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=true;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(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+s)),e),i);this.atCursorPos=true;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 PointDecoration){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof PointDecoration)if(i.block){i.startSide>0&&!this.posCovered()&&this.getLine();this.addBlockWidget(new BlockWidgetView(i.widget||new NullWidget("div"),r,i))}else{let n=WidgetView.create(i.widget||new NullWidget("span"),r,r?0:i.startSide);let l=this.atCursorPos&&!n.isEditable&&o<=s.length&&(t<e||i.startSide>0);let a=!n.isEditable&&(t<e||o>s.length||i.startSide<=0);let h=this.getLine();this.pendingBuffer!=2||l||n.isEditable||(this.pendingBuffer=0);this.flushBuffer(s);if(l){h.append(wrapMarks(new WidgetBufferView(1),s),o);o=s.length+Math.max(0,o-s.length)}h.append(wrapMarks(n,s),o);this.atCursorPos=a;this.pendingBuffer=a?t<e||o>s.length?1:2:0;this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);if(r){if(this.textOff+r<=this.text.length)this.textOff+=r;else{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,s,o,n){let r=new ContentBuilder(t,e,s,n);r.openEnd=i.spans(o,e,s,r);r.openStart<0&&(r.openStart=r.openEnd);r.finish(r.openEnd);return r}}function wrapMarks(t,e){for(let i of e)t=new MarkView(i,[t],t.length);return t}class NullWidget extends WidgetType{constructor(t){super();this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return true}}var q=function(t){t[t.LTR=0]="LTR";t[t.RTL=1]="RTL";return t}(q||(q={}));const K=q.LTR,Y=q.RTL;function dec(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const X=dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");const j=dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");const _=Object.create(null),U=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);_[e]=i;_[i]=-e}function charType(t){return t<=247?X[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?j[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const $=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class BidiSpan{get dir(){return this.level%2?Y:K}constructor(t,e,i){this.from=t;this.to=e;this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,s){let o=-1;for(let n=0;n<t.length;n++){let r=t[n];if(r.from<=e&&r.to>=e){if(r.level==i)return n;(o<0||(s!=0?s<0?r.from<e:r.to>e:t[o].level>r.level))&&(o=n)}}if(o<0)throw new RangeError("Index out of range");return o}}function isolatesEq(t,e){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++){let s=t[i],o=e[i];if(s.from!=o.from||s.to!=o.to||s.direction!=o.direction||!isolatesEq(s.inner,o.inner))return false}return true}const Q=[];function computeCharTypes(t,e,i,s,o){for(let n=0;n<=s.length;n++){let r=n?s[n-1].to:e,l=n<s.length?s[n].from:i;let a=n?256:o;for(let e=r,i=a,s=a;e<l;e++){let o=charType(t.charCodeAt(e));o==512?o=i:o==8&&s==4&&(o=16);Q[e]=o==4?2:o;o&7&&(s=o);i=o}for(let t=r,e=a,s=a;t<l;t++){let o=Q[t];if(o==128)t<l-1&&e==Q[t+1]&&e&24?o=Q[t]=e:Q[t]=256;else if(o==64){let o=t+1;while(o<l&&Q[o]==64)o++;let n=t&&e==8||o<i&&Q[o]==8?s==1?1:8:256;for(let e=t;e<o;e++)Q[e]=n;t=o-1}else o==8&&s==1&&(Q[t]=1);e=o;o&7&&(s=o)}}}function processBracketPairs(t,e,i,s,o){let n=o==1?2:1;for(let r=0,l=0,a=0;r<=s.length;r++){let h=r?s[r-1].to:e,c=r<s.length?s[r].from:i;for(let e,i,s,r=h;r<c;r++)if(i=_[e=t.charCodeAt(r)])if(i<0){for(let t=l-3;t>=0;t-=3)if(U[t+1]==-i){let e=U[t+2];let i=e&2?o:e&4?e&1?n:o:0;i&&(Q[r]=Q[U[t]]=i);l=t;break}}else{if(U.length==189)break;U[l++]=r;U[l++]=e;U[l++]=a}else if((s=Q[r])==2||s==1){let t=s==o;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=U[e+2];if(i&2)break;if(t)U[e+2]|=2;else{if(i&4)break;U[e+2]|=4}}}}}function processNeutrals(t,e,i,s){for(let o=0,n=s;o<=i.length;o++){let r=o?i[o-1].to:t,l=o<i.length?i[o].from:e;for(let a=r;a<l;){let r=Q[a];if(r==256){let r=a+1;for(;;)if(r==l){if(o==i.length)break;r=i[o++].to;l=o<i.length?i[o].from:e}else{if(Q[r]!=256)break;r++}let h=n==1;let c=(r<e?Q[r]:s)==1;let d=h==c?h?1:2:s;for(let e=r,s=o,n=s?i[s-1].to:t;e>a;){if(e==n){e=i[--s].from;n=s?i[s-1].to:t}Q[--e]=d}a=r}else{n=r;a++}}}}function emitSpans(t,e,i,s,o,n,r){let l=s%2?2:1;if(s%2==o%2)for(let a=e,h=0;a<i;){let e=true,c=false;if(h==n.length||a<n[h].from){let t=Q[a];if(t!=l){e=false;c=t==16}}let d=e||l!=1?null:[];let u=e?s:s+1;let f=a;t:for(;;)if(h<n.length&&f==n[h].from){if(c)break t;let p=n[h];if(!e)for(let t=p.to,e=h+1;;){if(t==i)break t;if(!(e<n.length&&n[e].from==t)){if(Q[t]==l)break t;break}t=n[e++].to}h++;if(d)d.push(p);else{p.from>a&&r.push(new BidiSpan(a,p.from,u));let e=p.direction==K!=!(u%2);computeSectionOrder(t,e?s+1:s,o,p.inner,p.from,p.to,r);a=p.to}f=p.to}else{if(f==i||(e?Q[f]!=l:Q[f]==l))break;f++}d?emitSpans(t,a,f,s+1,o,d,r):a<f&&r.push(new BidiSpan(a,f,u));a=f}else for(let a=i,h=n.length;a>e;){let i=true,c=false;if(!h||a>n[h-1].to){let t=Q[a-1];if(t!=l){i=false;c=t==16}}let d=i||l!=1?null:[];let u=i?s:s+1;let f=a;t:for(;;)if(h&&f==n[h-1].to){if(c)break t;let p=n[--h];if(!i)for(let t=p.from,i=h;;){if(t==e)break t;if(!i||n[i-1].to!=t){if(Q[t-1]==l)break t;break}t=n[--i].from}if(d)d.push(p);else{p.to<a&&r.push(new BidiSpan(p.to,a,u));let e=p.direction==K!=!(u%2);computeSectionOrder(t,e?s+1:s,o,p.inner,p.from,p.to,r);a=p.from}f=p.from}else{if(f==e||(i?Q[f-1]!=l:Q[f-1]==l))break;f--}d?emitSpans(t,f,a,s+1,o,d,r):f<a&&r.push(new BidiSpan(f,a,u));a=f}}function computeSectionOrder(t,e,i,s,o,n,r){let l=e%2?2:1;computeCharTypes(t,o,n,s,l);processBracketPairs(t,o,n,s,l);processNeutrals(o,n,s,l);emitSpans(t,o,n,e,i,s,r)}function computeOrder(t,e,i){if(!t)return[new BidiSpan(0,0,e==Y?1:0)];if(e==K&&!i.length&&!$.test(t))return trivialOrder(t.length);if(i.length)while(t.length>Q.length)Q[Q.length]=256;let s=[],o=e==K?0:1;computeSectionOrder(t,o,o,i,0,t.length,s);return s}function trivialOrder(t){return[new BidiSpan(0,t,0)]}let J="";function moveVisually(t,e,i,s,r){var l;let a=s.head-t.from;let h=BidiSpan.find(e,a,(l=s.bidiLevel)!==null&&l!==void 0?l:-1,s.assoc);let c=e[h],d=c.side(r,i);if(a==d){let t=h+=r?1:-1;if(t<0||t>=e.length)return null;c=e[h=t];a=c.side(!r,i);d=c.side(r,i)}let u=o(t.text,a,c.forward(r,i));(u<c.from||u>c.to)&&(u=d);J=t.text.slice(Math.min(a,u),Math.max(a,u));let f=h==(r?e.length-1:0)?null:e[h+(r?1:-1)];return f&&u==d&&f.level+(r?0:1)<c.level?n.cursor(f.side(!r,i)+t.from,f.forward(r,i)?1:-1,f.level):n.cursor(u+t.from,c.forward(r,i)?-1:1,c.level)}function autoDirection(t,e,i){for(let s=e;s<i;s++){let e=charType(t.charCodeAt(s));if(e==1)return K;if(e==2||e==4)return Y}return K}const Z=r.define();const tt=r.define();const et=r.define();const it=r.define();const st=r.define();const ot=r.define();const nt=r.define();const rt=r.define({combine:t=>t.some((t=>t))});const lt=r.define({combine:t=>t.some((t=>t))});class ScrollTarget{constructor(t,e="nearest",i="nearest",s=5,o=5,n=false){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 ScrollTarget(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 ScrollTarget(n.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const at=l.define({map:(t,e)=>t.map(e)});function logException(t,e,i){let s=t.facet(it);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)}const ht=r.define({combine:t=>!t.length||t[0]});let ct=0;const dt=r.define();class ViewPlugin{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){const{eventHandlers:i,eventObservers:s,provide:o,decorations:n}=e||{};return new ViewPlugin(ct++,t,i,s,(t=>{let e=[dt.of(t)];n&&e.push(pt.of((e=>{let i=e.plugin(t);return i?n(i):Decoration.none})));o&&e.push(o(t));return e}))}static fromClass(t,e){return ViewPlugin.define((e=>new t(e)),e)}}class PluginInstance{constructor(t){this.spec=t;this.mustUpdate=null;this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;this.mustUpdate=null;if(this.value.update)try{this.value.update(t)}catch(e){logException(t.state,e,"CodeMirror plugin crashed");if(this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){logException(t.state,e,"CodeMirror plugin crashed");this.deactivate()}return this}destroy(t){var e;if((e=this.value)===null||e===void 0?void 0:e.destroy)try{this.value.destroy()}catch(e){logException(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ut=r.define();const ft=r.define();const pt=r.define();const gt=r.define();const mt=r.define();const wt=r.define();function getIsolatedRanges(t,e){let s=t.state.facet(wt);if(!s.length)return s;let o=s.map((e=>e instanceof Function?e(t):e));let n=[];i.spans(o,e.from,e.to,{point(){},span(t,i,s,o){let r=t-e.from,l=i-e.from;let a=n;for(let t=s.length-1;t>=0;t--,o--){let i,n=s[t].spec.bidiIsolate;n==null&&(n=autoDirection(e.text,r,l));if(o>0&&a.length&&(i=a[a.length-1]).to==r&&i.direction==n){i.to=l;a=i.inner}else{let t={from:r,to:l,direction:n,inner:[]};a.push(t);a=t.inner}}}});return n}const vt=r.define();function getScrollMargins(t){let e=0,i=0,s=0,o=0;for(let n of t.state.facet(vt)){let r=n(t);if(r){r.left!=null&&(e=Math.max(e,r.left));r.right!=null&&(i=Math.max(i,r.right));r.top!=null&&(s=Math.max(s,r.top));r.bottom!=null&&(o=Math.max(o,r.bottom))}}return{left:e,right:i,top:s,bottom:o}}const bt=r.define();class ChangedRange{constructor(t,e,i,s){this.fromA=t;this.toA=e;this.fromB=i;this.toB=s}join(t){return new ChangedRange(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let s=t[e-1];if(!(s.fromA>i.toA)){if(s.toA<i.fromA)break;i=i.join(s);t.splice(e-1,1)}}t.splice(e,0,i);return t}static extendWithRanges(t,e){if(e.length==0)return t;let i=[];for(let s=0,o=0,n=0,r=0;;s++){let l=s==t.length?null:t[s],a=n-r;let h=l?l.fromB:1e9;while(o<e.length&&e[o]<h){let t=e[o],s=e[o+1];let n=Math.max(r,t),l=Math.min(h,s);n<=l&&new ChangedRange(n+a,l+a,n,l).addToSet(i);if(s>h)break;o+=2}if(!l)return i;new ChangedRange(l.fromA,l.toA,l.fromB,l.toB).addToSet(i);n=l.toA;r=l.toB}}}class ViewUpdate{constructor(t,e,i){this.view=t;this.state=e;this.transactions=i;this.flags=0;this.startState=t.state;this.changes=a.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let s=[];this.changes.iterChangedRanges(((t,e,i,o)=>s.push(new ChangedRange(t,e,i,o))));this.changedRanges=s}static create(t,e,i){return new ViewUpdate(t,e,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return this.flags==0&&this.transactions.length==0}}class DocView extends ContentView{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.minWidth=0;this.minWidthFrom=0;this.minWidthTo=0;this.impreciseAnchor=null;this.impreciseHead=null;this.forceSelection=false;this.lastUpdate=Date.now();this.setDOM(t.contentDOM);this.children=[new LineView];this.children[0].setParent(this);this.updateDeco();this.updateInner([new ChangedRange(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;if(this.minWidth>0&&i.length)if(i.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo))){this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1);this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)}else this.minWidth=this.minWidthFrom=this.minWidthTo=0;let s=-1;this.view.inputState.composing>=0&&(((e=this.domChanged)===null||e===void 0?void 0:e.newSel)?s=this.domChanged.newSel.head:touchesComposition(t.changes,this.hasComposition)||t.selectionSet||(s=t.state.selection.main.head));let o=s>-1?findCompositionRange(this.view,t.changes,s):null;this.domChanged=null;if(this.hasComposition){this.markedForComposition.clear();let{from:e,to:s}=this.hasComposition;i=new ChangedRange(e,s,t.changes.mapPos(e,-1),t.changes.mapPos(s,1)).addToSet(i.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null;(F.ie||F.chrome)&&!o&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=true);let n=this.decorations,r=this.updateDeco();let l=findChangedDeco(n,r,t.changes);i=ChangedRange.extendWithRanges(i,l);if(this.flags&7||i.length!=0){this.updateInner(i,t.startState.doc.length,o);t.transactions.length&&(this.lastUpdate=Date.now());return true}return false}updateInner(t,e,i){this.view.viewState.mustMeasureContent=true;this.updateChildren(t,e,i);let{observer:s}=this.view;s.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px";this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=F.chrome||F.ios?{node:s.selectionRange.focusNode,written:false}:void 0;this.sync(this.view,t);this.flags&=-8;t&&(t.written||s.selectionRange.focusNode!=t.node)&&(this.forceSelection=true);this.dom.style.height=""}));this.markedForComposition.forEach((t=>t.flags&=-9));let o=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof BlockWidgetView&&t.widget instanceof BlockGapWidget&&o.push(t.dom);s.updateGaps(o)}updateChildren(t,e,i){let s=i?i.range.addToSet(t.slice()):t;let o=this.childCursor(e);for(let t=s.length-1;;t--){let e=t>=0?s[t]:null;if(!e)break;let n,r,l,a,{fromA:h,toA:c,fromB:d,toB:u}=e;if(i&&i.range.fromB<u&&i.range.toB>d){let t=ContentBuilder.build(this.view.state.doc,d,i.range.fromB,this.decorations,this.dynamicDecorationMap);let e=ContentBuilder.build(this.view.state.doc,i.range.toB,u,this.decorations,this.dynamicDecorationMap);r=t.breakAtStart;l=t.openStart;a=e.openEnd;let s=this.compositionView(i);if(e.breakAtStart)s.breakAfter=1;else if(e.content.length&&s.merge(s.length,s.length,e.content[0],false,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],true,0,t.openEnd)&&t.content.pop();n=t.content.concat(s).concat(e.content)}else({content:n,breakAtStart:r,openStart:l,openEnd:a}=ContentBuilder.build(this.view.state.doc,d,u,this.decorations,this.dynamicDecorationMap));let{i:f,off:p}=o.findPos(c,1);let{i:g,off:m}=o.findPos(h,-1);replaceRange(this,g,m,f,p,n,r,l,a)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new TextView(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new MarkView(i,[e],e.length);let i=new LineView;i.append(e,0);return i}fixCompositionDOM(t){let fix=(t,e)=>{e.flags|=8|(e.children.some((t=>t.flags&7))?1:0);this.markedForComposition.add(e);let i=ContentView.get(t);i&&i!=e&&(i.dom=null);e.setDOM(t)};let e=this.childPos(t.range.fromB,1);let i=this.children[e.i];fix(t.line,i);for(let s=t.marks.length-1;s>=-1;s--){e=i.childPos(e.off,1);i=i.children[e.i];fix(s>=0?t.marks[s].node:t.text,i)}}updateSelection(t=false,e=false){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,s=i==this.dom;let o=!s&&hasSelection(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(s||e||o))return;let n=this.forceSelection;this.forceSelection=false;let r=this.view.state.selection.main;let l=this.moveToLine(this.domAtPos(r.anchor));let a=r.empty?l:this.moveToLine(this.domAtPos(r.head));if(F.gecko&&r.empty&&!this.hasComposition&&betweenUneditable(l)){let t=document.createTextNode("");this.view.observer.ignore((()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null)));l=a=new DOMPos(t,0);n=true}let h=this.view.observer.selectionRange;if(n||!h.focusNode||(!isEquivalentPosition(l.node,l.offset,h.anchorNode,h.anchorOffset)||!isEquivalentPosition(a.node,a.offset,h.focusNode,h.focusOffset))&&!this.suppressWidgetCursorChange(h,r)){this.view.observer.ignore((()=>{if(F.android&&F.chrome&&this.dom.contains(h.focusNode)&&inUneditable(h.focusNode,this.dom)){this.dom.blur();this.dom.focus({preventScroll:true})}let t=getSelection(this.view.root);if(t)if(r.empty){if(F.gecko){let t=nextToUneditable(l.node,l.offset);if(t&&t!=3){let e=nearbyTextNode(l.node,l.offset,t==1?1:-1);e&&(l=new DOMPos(e.node,e.offset))}}t.collapse(l.node,l.offset);r.bidiLevel!=null&&t.caretBidiLevel!==void 0&&(t.caretBidiLevel=r.bidiLevel)}else if(t.extend){t.collapse(l.node,l.offset);try{t.extend(a.node,a.offset)}catch(t){}}else{let e=document.createRange();r.anchor>r.head&&([l,a]=[a,l]);e.setEnd(a.node,a.offset);e.setStart(l.node,l.offset);t.removeAllRanges();t.addRange(e)}else;if(o&&this.view.root.activeElement==this.dom){this.dom.blur();i&&i.focus()}}));this.view.observer.setSelectionRange(l,a)}this.impreciseAnchor=l.precise?null:new DOMPos(h.anchorNode,h.anchorOffset);this.impreciseHead=a.precise?null:new DOMPos(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&isEquivalentPosition(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;let i=getSelection(t.root);let{anchorNode:s,anchorOffset:o}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let n=LineView.find(this,e.head);if(!n)return;let r=n.posAtStart;if(e.head==r||e.head==r+n.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(e.head+e.assoc);i.collapse(h.node,h.offset);i.modify("move",e.assoc<0?"forward":"backward","lineboundary");t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(s,o)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let s=t.offset;!e&&s<i.childNodes.length;s++){let t=ContentView.get(i.childNodes[s]);t instanceof LineView&&(e=t.domAtPos(0))}for(let s=t.offset-1;!e&&s>=0;s--){let t=ContentView.get(i.childNodes[s]);t instanceof LineView&&(e=t.domAtPos(t.length))}return e?new DOMPos(e.node,e.offset,true):t}nearest(t){for(let e=t;e;){let t=ContentView.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof LineView)break;e++;i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,s=0;for(let o=this.length,n=this.children.length-1;n>=0;n--){let r=this.children[n],l=o-r.breakAfter,a=l-r.length;if(l<t)break;if(a<=t&&(a<t||r.covers(-1))&&(l>t||r.covers(1))&&(!i||r instanceof LineView&&!(i instanceof LineView&&e>=0))){i=r;s=a}o=a}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 LineView))return null;while(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 TextView))return null;let n=o(s.text,i);if(n==i)return null;let r=textRange(s.dom,i,n).getClientRects();for(let t=0;t<r.length;t++){let e=r[t];if(t==r.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:s}=t;let o=this.view.contentDOM.clientWidth;let n=o>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1;let r=-1,l=this.view.textDirection==q.LTR;for(let t=0,a=0;a<this.children.length;a++){let h=this.children[a],c=t+h.length;if(c>s)break;if(t>=i){let i=h.dom.getBoundingClientRect();e.push(i.height);if(n){let e=h.dom.lastChild;let s=e?clientRectsFor(e):[];if(s.length){let e=s[s.length-1];let n=l?e.right-i.left:i.right-e.left;if(n>r){r=n;this.minWidth=o;this.minWidthFrom=t;this.minWidthTo=c}}}}t=c+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return getComputedStyle(this.children[e].dom).direction=="rtl"?q.RTL:q.LTR}measureTextSize(){for(let t of this.children)if(t instanceof LineView){let e=t.measureTextSize();if(e)return e}let t,e,i,s=document.createElement("div");s.className="cm-line";s.style.width="99999px";s.style.position="absolute";s.textContent="abc def ghi jkl mno pqr stu";this.view.observer.ignore((()=>{this.dom.appendChild(s);let o=clientRectsFor(s.firstChild)[0];t=s.getBoundingClientRect().height;e=o?o.width/27:7;i=o?o.height:t;s.remove()}));return{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;e&&(t-=this.children[--e].length);return new ChildCursor(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];let 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(Decoration.replace({widget:new BlockGapWidget(s),block:true,inclusive:true,isBlockGap:true}).range(i,n))}if(!o)break;i=o.to+1}return Decoration.set(t)}updateDeco(){let t=this.view.state.facet(pt).map(((t,e)=>{let i=this.dynamicDecorationMap[e]=typeof t=="function";return i?t(this.view):t}));let e=false,s=this.view.state.facet(gt).map(((t,i)=>{let s=typeof t=="function";s&&(e=true);return s?t(this.view):t}));if(s.length){this.dynamicDecorationMap[t.length]=e;t.push(i.join(s))}for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=false;return this.decorations=[...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=e.top-t.yMargin;this.view.scrollDOM.scrollLeft=t.xMargin;return}let{range:e}=t;let i,s=this.coordsAt(e.head,e.empty?e.assoc:e.head>e.anchor?-1:1);if(!s)return;!e.empty&&(i=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(s={left:Math.min(s.left,i.left),top:Math.min(s.top,i.top),right:Math.max(s.right,i.right),bottom:Math.max(s.bottom,i.bottom)});let o=getScrollMargins(this.view);let n={left:s.left-o.left,top:s.top-o.top,right:s.right+o.right,bottom:s.bottom+o.bottom};let{offsetWidth:r,offsetHeight:l}=this.view.scrollDOM;scrollRectIntoView(this.view.scrollDOM,n,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,r),-r),Math.max(Math.min(t.yMargin,l),-l),this.view.textDirection==q.LTR)}}function betweenUneditable(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}class BlockGapWidget extends WidgetType{constructor(t){super();this.height=t}toDOM(){let t=document.createElement("div");t.className="cm-gap";this.updateDOM(t);return t}eq(t){return t.height==this.height}updateDOM(t){t.style.height=this.height+"px";return true}get editable(){return true}get estimatedHeight(){return this.height}ignoreEvent(){return false}}function findCompositionNode(t,e){let i=t.observer.selectionRange;let s=i.focusNode&&nearbyTextNode(i.focusNode,i.focusOffset,0);if(!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function findCompositionRange(t,e,i){let s=findCompositionNode(t,i);if(!s)return null;let{node:o,from:n,to:r}=s,l=o.nodeValue;if(/[\n\r]/.test(l))return null;if(t.state.doc.sliceString(s.from,s.to)!=l)return null;let a=e.invertedDesc;let h=new ChangedRange(a.mapPos(n),a.mapPos(r),n,r);let c=[];for(let e=o.parentNode;;e=e.parentNode){let i=ContentView.get(e);if(i instanceof MarkView)c.push({node:e,deco:i.mark});else{if(i instanceof LineView||e.nodeName=="DIV"&&e.parentNode==t.contentDOM)return{range:h,text:o,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new MarkDecoration({inclusive:true,attributes:getAttrs(e),tagName:e.tagName.toLowerCase()})})}}}function nearbyTextNode(t,e,i){if(i<=0)for(let i=t,s=e;;){if(i.nodeType==3)return{node:i,offset:s};if(!(i.nodeType==1&&s>0))break;i=i.childNodes[s-1];s=maxOffset(i)}if(i>=0)for(let s=t,o=e;;){if(s.nodeType==3)return{node:s,offset:o};if(!(s.nodeType==1&&o<s.childNodes.length&&i>=0))break;s=s.childNodes[o];o=0}return null}function nextToUneditable(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e<t.childNodes.length&&t.childNodes[e].contentEditable=="false"?2:0)}let yt=class DecorationComparator{constructor(){this.changes=[]}compareRange(t,e){addRange(t,e,this.changes)}comparePoint(t,e){addRange(t,e,this.changes)}};function findChangedDeco(t,e,s){let o=new yt;i.compare(t,e,s,o);return o.changes}function inUneditable(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(i.nodeType==1&&i.contentEditable=="false")return true;return false}function touchesComposition(t,e){let i=false;e&&t.iterChangedRanges(((t,s)=>{t<e.to&&s>e.from&&(i=true)}));return i}function groupAt(t,e,i=1){let s=t.charCategorizer(e);let r=t.doc.lineAt(e),l=e-r.from;if(r.length==0)return n.cursor(e);l==0?i=1:l==r.length&&(i=-1);let a=l,h=l;i<0?a=o(r.text,l,false):h=o(r.text,l);let c=s(r.text.slice(a,h));while(a>0){let t=o(r.text,a,false);if(s(r.text.slice(t,a))!=c)break;a=t}while(h<r.length){let t=o(r.text,h);if(s(r.text.slice(h,t))!=c)break;h=t}return n.range(a+r.from,h+r.from)}function getdx(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function getdy(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function yOverlap(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function upTop(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function upBot(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function domPosAtCoords(t,e,i){let s,o,n,r,l=false;let a,h,c,d;for(let u=t.firstChild;u;u=u.nextSibling){let t=clientRectsFor(u);for(let f=0;f<t.length;f++){let p=t[f];o&&yOverlap(o,p)&&(p=upTop(upBot(p,o.bottom),o.top));let g=getdx(e,p),m=getdy(i,p);if(g==0&&m==0)return u.nodeType==3?domPosInText(u,e,i):domPosAtCoords(u,e,i);if(!s||r>m||r==m&&n>g){s=u;o=p;n=g;r=m;let a=m?i<p.top?-1:1:g?e<p.left?-1:1:0;l=!a||(a>0?f<t.length-1:f>0)}if(g==0){if(i>p.bottom&&(!c||c.bottom<p.bottom)){a=u;c=p}else if(i<p.top&&(!d||d.top>p.top)){h=u;d=p}}else c&&yOverlap(c,p)?c=upBot(c,p.bottom):d&&yOverlap(d,p)&&(d=upTop(d,p.top))}}if(c&&c.bottom>=i){s=a;o=c}else if(d&&d.top<=i){s=h;o=d}if(!s)return{node:t,offset:0};let u=Math.max(o.left,Math.min(o.right,e));if(s.nodeType==3)return domPosInText(s,u,i);if(l&&s.contentEditable!="false")return domPosAtCoords(s,u,i);let f=Array.prototype.indexOf.call(t.childNodes,s)+(e>=(o.left+o.right)/2?1:0);return{node:t,offset:f}}function domPosInText(t,e,i){let s=t.nodeValue.length;let o=-1,n=1e9,r=0;for(let l=0;l<s;l++){let s=textRange(t,l,l+1).getClientRects();for(let a=0;a<s.length;a++){let h=s[a];if(h.top==h.bottom)continue;r||(r=e-h.left);let c=(h.top>i?h.top-i:i-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<n){let i=e>=(h.left+h.right)/2,s=i;if(F.chrome||F.gecko){let e=textRange(t,l).getBoundingClientRect();e.left==h.right&&(s=!i)}if(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 posAtCoords(t,e,i,s=-1){var o,n;let r=t.contentDOM.getBoundingClientRect(),l=r.top+t.viewState.paddingTop;let a,{docHeight:h}=t.viewState;let{x:c,y:d}=e,u=d-l;if(u<0)return 0;if(u>h)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,o=false;;){a=t.elementAtHeight(u);if(a.type==G.Text)break;for(;;){u=s>0?a.bottom+e:a.top-e;if(u>=0&&u<=h)break;if(o)return i?null:0;o=true;s=-s}}d=l+u;let f=a.from;if(f<t.viewport.from)return t.viewport.from==0?0:i?null:posAtCoordsImprecise(t,r,a,c,d);if(f>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:posAtCoordsImprecise(t,r,a,c,d);let p=t.dom.ownerDocument;let g=t.root.elementFromPoint?t.root:p;let m=g.elementFromPoint(c,d);m&&!t.contentDOM.contains(m)&&(m=null);if(!m){c=Math.max(r.left+1,Math.min(r.right-1,c));m=g.elementFromPoint(c,d);m&&!t.contentDOM.contains(m)&&(m=null)}let w,v=-1;if(m&&((o=t.docView.nearest(m))===null||o===void 0?void 0:o.isEditable)!=false)if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,d);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,d);if(e){({startContainer:w,startOffset:v}=e);(!t.contentDOM.contains(w)||F.safari&&isSuspiciousSafariCaretResult(w,v,c)||F.chrome&&isSuspiciousChromeCaretResult(w,v,c))&&(w=void 0)}}if(!w||!t.docView.dom.contains(w)){let e=LineView.find(t.docView,f);if(!e)return u>a.top+a.height/2?a.to:a.from;({node:w,offset:v}=domPosAtCoords(e.dom,c,d))}let b=t.docView.nearest(w);if(!b)return null;if(b.isWidget&&((n=b.dom)===null||n===void 0?void 0:n.nodeType)==1){let t=b.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?b.posAtStart:b.posAtEnd}return b.localPosFromDOM(w,v)+b.posAtStart}function posAtCoordsImprecise(t,e,i,s,o){let n=Math.round((s-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>t.defaultLineHeight*1.5){let e=t.viewState.heightOracle.textHeight;let s=Math.floor((o-i.top-.5*(t.defaultLineHeight-e))/e);n+=s*t.viewState.heightOracle.lineLength}let r=t.state.sliceDoc(i.from,i.to);return i.from+h(r,n,t.state.tabSize)}function isSuspiciousSafariCaretResult(t,e,i){let s;if(t.nodeType!=3||e!=(s=t.nodeValue.length))return false;for(let e=t.nextSibling;e;e=e.nextSibling)if(e.nodeType!=1||e.nodeName!="BR")return false;return textRange(t,s-1,s).getBoundingClientRect().left>i}function isSuspiciousChromeCaretResult(t,e,i){if(e!=0)return false;for(let e=t;;){let t=e.parentNode;if(!t||t.nodeType!=1||t.firstChild!=e)return false;if(t.classList.contains("cm-line"))break;e=t}let s=t.nodeType==1?t.getBoundingClientRect():textRange(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-s.left>5}function blockAt(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==G.Text))return t;return i}function moveToLineBoundary(t,e,i,s){let o=blockAt(t,e.head);let r=s&&o.type==G.Text&&(t.lineWrapping||o.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>o.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect();let s=t.textDirectionAt(o.from);let l=t.posAtCoords({x:i==(s==q.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(l!=null)return n.cursor(l,i?-1:1)}return n.cursor(i?o.to:o.from,i?-1:1)}function moveByChar(t,e,i,s){let o=t.state.doc.lineAt(e.head),n=t.bidiSpans(o);let r=t.textDirectionAt(o.from);for(let l=e,a=null;;){let e=moveVisually(o,n,r,l,i),h=J;if(!e){if(o.number==(i?t.state.doc.lines:1))return l;h="\n";o=t.state.doc.line(o.number+(i?1:-1));n=t.bidiSpans(o);e=t.visualLineSide(o,!i)}if(a){if(!a(h))return l}else{if(!s)return e;a=s(h)}l=e}}function byGroup(t,e,i){let s=t.state.charCategorizer(e);let o=s(i);return t=>{let e=s(t);o==c.Space&&(o=e);return o==e}}function moveVertically(t,e,i,s){let o=e.head,r=i?1:-1;if(o==(i?t.state.doc.length:0))return n.cursor(o,e.assoc);let l,a=e.goalColumn;let h=t.contentDOM.getBoundingClientRect();let c=t.coordsAtPos(o,e.assoc||-1),d=t.documentTop;if(c){a==null&&(a=c.left-h.left);l=r<0?c.top:c.bottom}else{let e=t.viewState.lineBlockAt(o);a==null&&(a=Math.min(h.right-h.left,t.defaultCharacterWidth*(o-e.from)));l=(r<0?e.top:e.bottom)+d}let u=h.left+a;let f=s!==null&&s!==void 0?s:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=l+(f+e)*r;let s=posAtCoords(t,{x:u,y:i},false,r);if(i<h.top||i>h.bottom||(r<0?s<o:s>o)){let e=t.docView.coordsForChar(s);let o=!e||i<e.top?-1:1;return n.cursor(s,o,void 0,a)}}}function skipAtomicRanges(t,e,i){for(;;){let s=0;for(let o of t)o.between(e-1,e+1,((t,o,n)=>{if(e>t&&e<o){let n=s||i||(e-t<o-e?-1:1);e=n<0?t:o;s=n}}));if(!s)return e}}function skipAtoms(t,e,i){let s=skipAtomicRanges(t.state.facet(mt).map((e=>e(t))),i.from,e.head>i.from?-1:1);return s==i.from?i:n.cursor(s,s<i.from?1:-1)}class InputState{setSelectionOrigin(t){this.lastSelectionOrigin=t;this.lastSelectionTime=Date.now()}constructor(t){this.view=t;this.lastKeyCode=0;this.lastKeyTime=0;this.lastTouchTime=0;this.lastFocusTime=0;this.lastScrollTop=0;this.lastScrollLeft=0;this.pendingIOSKey=void 0;this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastEscPress=0;this.lastContextMenu=0;this.scrollHandlers=[];this.handlers=Object.create(null);this.composing=-1;this.compositionFirstChange=null;this.compositionEndedAt=0;this.compositionPendingKey=false;this.compositionPendingChange=false;this.mouseSelection=null;this.draggedContent=null;this.handleEvent=this.handleEvent.bind(this);this.notifiedFocused=t.hasFocus;F.safari&&t.contentDOM.addEventListener("input",(()=>null));F.gecko&&firefoxCopyCutHack(t.contentDOM.ownerDocument)}handleEvent(t){eventBelongsToEditor(this.view,t)&&!this.ignoreDuringComposition(t)&&(t.type=="keydown"&&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=computeHandlers(t),i=this.handlers,s=this.view.contentDOM;for(let t in e)if(t!="scroll"){let o=!e[t].handlers.length;let n=i[t];if(n&&o!=!n.handlers.length){s.removeEventListener(t,this.handleEvent);n=null}n||s.addEventListener(t,this.handleEvent,{passive:o})}for(let t in i)t=="scroll"||e[t]||s.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){this.lastKeyCode=t.keyCode;this.lastKeyTime=Date.now();if(t.keyCode==9&&Date.now()<this.lastEscPress+2e3)return true;t.keyCode!=27&&xt.indexOf(t.keyCode)<0&&(this.view.inputState.lastEscPress=0);if(F.android&&F.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8)){this.view.observer.delayAndroidKey(t.key,t.keyCode);return true}let e;if(F.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((e=St.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||Mt.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)){this.pendingIOSKey=e||t;setTimeout((()=>this.flushIOSKey()),250);return true}t.keyCode!=229&&this.view.observer.forceFlush();return false}flushIOSKey(){let t=this.pendingIOSKey;if(!t)return false;this.pendingIOSKey=void 0;return dispatchKey(this.view.contentDOM,t.key,t.keyCode)}ignoreDuringComposition(t){if(!/^key/.test(t.type))return false;if(this.composing>0)return true;if(F.safari&&!F.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100){this.compositionPendingKey=false;return true}return false}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 bindHandler(t,e){return(i,s)=>{try{return e.call(t,s,i)}catch(t){logException(i.state,t)}}}function computeHandlers(t){let e=Object.create(null);function record(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec;if(t&&t.domEventHandlers)for(let i in t.domEventHandlers){let s=t.domEventHandlers[i];s&&record(i).handlers.push(bindHandler(e.value,s))}if(t&&t.domEventObservers)for(let i in t.domEventObservers){let s=t.domEventObservers[i];s&&record(i).observers.push(bindHandler(e.value,s))}}for(let t in kt)record(t).handlers.push(kt[t]);for(let t in At)record(t).observers.push(At[t]);return e}const St=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}];const Mt="dthko";const xt=[16,17,18,20,91,92,224,225];const Ct=6;function dragScrollSpeed(t){return Math.max(0,t)*.7+8}function dist(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class MouseSelection{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=scrollableParent(t.contentDOM);this.atoms=t.state.facet(mt).map((e=>e(t)));let o=t.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this));o.addEventListener("mouseup",this.up=this.up.bind(this));this.extend=e.shiftKey;this.multiple=t.state.facet(d.allowMultipleSelections)&&addsSelectionRange(t,e);this.dragging=!(!isInPrimarySelection(t,e)||getClickType(e)!=1)&&null}start(t){this.dragging===false&&this.select(t)}move(t){var e;if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&dist(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let i=0,s=0;let o=((e=this.scrollParent)===null||e===void 0?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight};let n=getScrollMargins(this.view);t.clientX-n.left<=o.left+Ct?i=-dragScrollSpeed(o.left-t.clientX):t.clientX+n.right>=o.right-Ct&&(i=dragScrollSpeed(t.clientX-o.right));t.clientY-n.top<=o.top+Ct?s=-dragScrollSpeed(o.top-t.clientY):t.clientY+n.bottom>=o.bottom-Ct&&(s=dragScrollSpeed(t.clientY-o.bottom));this.setScrollSpeed(i,s)}up(t){this.dragging==null&&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};if(t||e)this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50));else if(this.scrolling>-1){clearInterval(this.scrolling);this.scrolling=-1}}scroll(){if(this.scrollParent){this.scrollParent.scrollLeft+=this.scrollSpeed.x;this.scrollParent.scrollTop+=this.scrollSpeed.y}else this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y);this.dragging===false&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let s=t.ranges[i],o=null;if(s.empty){let t=skipAtomicRanges(this.atoms,s.from,0);t!=s.from&&(o=n.cursor(t,-1))}else{let t=skipAtomicRanges(this.atoms,s.from,-1);let e=skipAtomicRanges(this.atoms,s.to,1);t==s.from&&e==s.to||(o=n.range(s.from==s.anchor?t:e,s.from==s.head?t:e))}if(o){e||(e=t.ranges.slice());e[i]=o}}return e?n.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,this.dragging===false)||this.view.dispatch({selection:i,userEvent:"select.pointer"});this.mustSelect=false}update(t){this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function addsSelectionRange(t,e){let i=t.state.facet(Z);return i.length?i[0](e):F.mac?e.metaKey:e.ctrlKey}function dragMovesSelection(t,e){let i=t.state.facet(tt);return i.length?i[0](e):F.mac?!e.altKey:!e.ctrlKey}function isInPrimarySelection(t,e){let{main:i}=t.state.selection;if(i.empty)return false;let s=getSelection(t.root);if(!s||s.rangeCount==0)return true;let o=s.getRangeAt(0).getClientRects();for(let t=0;t<o.length;t++){let i=o[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return true}return false}function eventBelongsToEditor(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let i,s=e.target;s!=t.contentDOM;s=s.parentNode)if(!s||s.nodeType==11||(i=ContentView.get(s))&&i.ignoreEvent(e))return false;return true}const kt=Object.create(null);const At=Object.create(null);const Dt=F.ie&&F.ie_version<15||F.ios&&F.webkit_version<604;function capturePaste(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px";i.focus();setTimeout((()=>{t.focus();i.remove();doPaste(t,i.value)}),50)}function doPaste(t,e){let i,{state:s}=t,o=1,r=s.toText(e);let l=r.lines==s.selection.ranges.length;let a=Bt!=null&&s.selection.ranges.every((t=>t.empty))&&Bt==r.toString();if(a){let t=-1;i=s.changeByRange((i=>{let a=s.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let h=s.toText((l?r.line(o++).text:e)+s.lineBreak);return{changes:{from:a.from,insert:h},range:n.cursor(i.from+h.length)}}))}else i=l?s.changeByRange((t=>{let e=r.line(o++);return{changes:{from:t.from,to:t.to,insert:e.text},range:n.cursor(t.from+e.length)}})):s.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:true})}At.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop;t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};kt.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select");e.keyCode==27&&(t.inputState.lastEscPress=Date.now());return false};At.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now();t.inputState.setSelectionOrigin("select.pointer")};At.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};kt.mousedown=(t,e)=>{t.observer.flush();if(t.inputState.lastTouchTime>Date.now()-2e3)return false;let i=null;for(let s of t.state.facet(et)){i=s(t,e);if(i)break}i||e.button!=0||(i=basicMouseSelection(t,e));if(i){let s=!t.hasFocus;t.inputState.startMouseSelection(new MouseSelection(t,e,i,s));s&&t.observer.ignore((()=>focusPreventScroll(t.contentDOM)));let o=t.inputState.mouseSelection;if(o){o.start(e);return o.dragging===false}}return false};function rangeForClick(t,e,i,s){if(s==1)return n.cursor(e,i);if(s==2)return groupAt(t.state,e,i);{let i=LineView.find(t.docView,e),s=t.state.doc.lineAt(i?i.posAtEnd:e);let o=i?i.posAtStart:s.from,r=i?i.posAtEnd:s.to;r<t.state.doc.length&&r==s.to&&r++;return n.range(o,r)}}let insideY=(t,e)=>t>=e.top&&t<=e.bottom;let inside=(t,e,i)=>insideY(e,i)&&t>=i.left&&t<=i.right;function findPositionSide(t,e,i,s){let o=LineView.find(t.docView,e);if(!o)return 1;let n=e-o.posAtStart;if(n==0)return 1;if(n==o.length)return-1;let r=o.coordsAt(n,-1);if(r&&inside(i,s,r))return-1;let l=o.coordsAt(n,1);return l&&inside(i,s,l)?1:r&&insideY(s,r)?-1:1}function queryPos(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},false);return{pos:i,bias:findPositionSide(t,i,e.clientX,e.clientY)}}const Tt=F.ie&&F.ie_version<=11;let Ot=null,Rt=0,Vt=0;function getClickType(t){if(!Tt)return t.detail;let e=Ot,i=Vt;Ot=t;Vt=Date.now();return Rt=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Rt+1)%3:1}function basicMouseSelection(t,e){let i=queryPos(t,e),s=getClickType(e);let o=t.state.selection;return{update(t){if(t.docChanged){i.pos=t.changes.mapPos(i.pos);o=o.map(t.changes)}},get(e,r,l){let a,h=queryPos(t,e);let c=rangeForClick(t,h.pos,h.bias,s);if(i.pos!=h.pos&&!r){let e=rangeForClick(t,i.pos,i.bias,s);let o=Math.min(e.from,c.from),r=Math.max(e.to,c.to);c=o<c.from?n.range(o,r):n.range(r,o)}return r?o.replaceRange(o.main.extend(c.from,c.to)):l&&s==1&&o.ranges.length>1&&(a=removeRangeAround(o,h.pos))?a:l?o.addRange(c):n.create([c])}}}function removeRangeAround(t,e){for(let i=0;i<t.ranges.length;i++){let{from:s,to:o}=t.ranges[i];if(s<=e&&o>=e)return n.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}kt.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=n.range(t,e))}}let{inputState:s}=t;s.mouseSelection&&(s.mouseSelection.dragging=true);s.draggedContent=i;if(e.dataTransfer){e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to));e.dataTransfer.effectAllowed="copyMove"}return false};kt.dragend=t=>{t.inputState.draggedContent=null;return false};function dropText(t,e,i,s){if(!i)return;let o=t.posAtCoords({x:e.clientX,y:e.clientY},false);let{draggedContent:n}=t.inputState;let r=s&&n&&dragMovesSelection(t,e)?{from:n.from,to:n.to}:null;let l={from:o,insert:i};let a=t.state.changes(r?[r,l]:l);t.focus();t.dispatch({changes:a,selection:{anchor:a.mapPos(o,-1),head:a.mapPos(o,1)},userEvent:r?"move.drop":"input.drop"});t.inputState.draggedContent=null}kt.drop=(t,e)=>{if(!e.dataTransfer)return false;if(t.state.readOnly)return true;let i=e.dataTransfer.files;if(i&&i.length){let s=Array(i.length),o=0;let finishFile=()=>{++o==i.length&&dropText(t,e,s.filter((t=>t!=null)).join(t.state.lineBreak),false)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=finishFile;e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(s[t]=e.result);finishFile()};e.readAsText(i[t])}return true}{let i=e.dataTransfer.getData("Text");if(i){dropText(t,e,i,true);return true}}return false};kt.paste=(t,e)=>{if(t.state.readOnly)return true;t.observer.flush();let i=Dt?null:e.clipboardData;if(i){doPaste(t,i.getData("text/plain")||i.getData("text/uri-text"));return true}capturePaste(t);return false};function captureCopy(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)}function copiedRange(t){let e=[],i=[],s=false;for(let s of t.selection.ranges)if(!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);if(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=true}return{text:e.join(t.lineBreak),ranges:i,linewise:s}}let Bt=null;kt.copy=kt.cut=(t,e)=>{let{text:i,ranges:s,linewise:o}=copiedRange(t.state);if(!i&&!o)return false;Bt=o?i:null;e.type!="cut"||t.state.readOnly||t.dispatch({changes:s,scrollIntoView:true,userEvent:"delete.cut"});let n=Dt?null:e.clipboardData;if(n){n.clearData();n.setData("text/plain",i);return true}captureCopy(t,i);return false};const Et=u.define();function focusChangeTransaction(t,e){let i=[];for(let s of t.facet(nt)){let o=s(t,e);o&&i.push(o)}return i?t.update({effects:i,annotations:Et.of(true)}):null}function updateForFocusChange(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=focusChangeTransaction(t.state,e);i?t.dispatch(i):t.update([])}}),10)}At.focus=t=>{t.inputState.lastFocusTime=Date.now();if(!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)){t.scrollDOM.scrollTop=t.inputState.lastScrollTop;t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft}updateForFocusChange(t)};At.blur=t=>{t.observer.clearSelectionRange();updateForFocusChange(t)};At.compositionstart=At.compositionupdate=t=>{t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=true);t.inputState.composing<0&&(t.inputState.composing=0)};At.compositionend=t=>{t.inputState.composing=-1;t.inputState.compositionEndedAt=Date.now();t.inputState.compositionPendingKey=true;t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0;t.inputState.compositionFirstChange=null;F.chrome&&F.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)};At.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};kt.beforeinput=(t,e)=>{var i;let s;if(F.chrome&&F.android&&(s=St.find((t=>t.inputType==e.inputType)))){t.observer.delayAndroidKey(s.key,s.keyCode);if(s.key=="Backspace"||s.key=="Delete"){let e=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout((()=>{var i;if((((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0)>e+10&&t.hasFocus){t.contentDOM.blur();t.focus()}}),100)}}return false};const Pt=new Set;function firefoxCopyCutHack(t){if(!Pt.has(t)){Pt.add(t);t.addEventListener("copy",(()=>{}));t.addEventListener("cut",(()=>{}))}}const Lt=["pre-wrap","normal","pre-line","break-spaces"];class HeightOracle{constructor(e){this.lineWrapping=e;this.doc=t.empty;this.heightSamples={};this.lineHeight=14;this.charWidth=7;this.textHeight=14;this.lineLength=30;this.heightChanged=false}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength)));return this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;let e=1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5)));return e*this.lineHeight}setDoc(t){this.doc=t;return this}mustRefreshForWrapping(t){return Lt.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=false;for(let i=0;i<t.length;i++){let s=t[i];if(s<0)i++;else if(!this.heightSamples[Math.floor(s*10)]){e=true;this.heightSamples[Math.floor(s*10)]=true}}return e}refresh(t,e,i,s,o,n){let r=Lt.indexOf(t)>-1;let l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;this.lineWrapping=r;this.lineHeight=e;this.charWidth=i;this.textHeight=s;this.lineLength=o;if(l){this.heightSamples={};for(let t=0;t<n.length;t++){let e=n[t];e<0?t++:this.heightSamples[Math.floor(e*10)]=true}}return l}}class MeasuredHeights{constructor(t,e){this.from=t;this.heights=e;this.index=0}get more(){return this.index<this.heights.length}}class BlockInfo{constructor(t,e,i,s,o){this.from=t;this.length=e;this.top=i;this.height=s;this._content=o}get type(){return typeof this._content=="number"?G.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof PointDecoration?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new BlockInfo(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var Ht=function(t){t[t.ByPos=0]="ByPos";t[t.ByHeight=1]="ByHeight";t[t.ByPosNoHeight=2]="ByPosNoHeight";return t}(Ht||(Ht={}));const Nt=.001;class HeightMap{constructor(t,e,i=2){this.length=t;this.height=e;this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t,e){if(this.height!=e){Math.abs(this.height-e)>Nt&&(t.heightChanged=true);this.height=e}}replace(t,e,i){return HeightMap.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,s){let o=this,n=i.doc;for(let r=s.length-1;r>=0;r--){let{fromA:l,toA:a,fromB:h,toB:c}=s[r];let d=o.lineAt(l,Ht.ByPosNoHeight,i.setDoc(e),0,0);let u=d.to>=a?d:o.lineAt(a,Ht.ByPosNoHeight,i,0,0);c+=u.to-a;a=u.to;while(r>0&&d.from<=s[r-1].toA){l=s[r-1].fromA;h=s[r-1].fromB;r--;l<d.from&&(d=o.lineAt(l,Ht.ByPosNoHeight,i,0,0))}h+=d.from-l;l=d.from;let f=NodeBuilder.build(i.setDoc(n),t,h,c);o=o.replace(l,a,f)}return o.updateHeight(i,0)}static empty(){return new HeightMapText(0,0)}static of(t){if(t.length==1)return t[0];let e=0,i=t.length,s=0,o=0;for(;;)if(e==i)if(s>o*2){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>s*2))break;{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 if(s<o){let i=t[e++];i&&(s+=i.size)}else{let e=t[--i];e&&(o+=e.size)}let n=0;if(t[e-1]==null){n=1;e--}else if(t[e]==null){n=1;i++}return new HeightMapBranch(HeightMap.of(t.slice(0,e)),n,HeightMap.of(t.slice(i)))}}HeightMap.prototype.size=1;class HeightMapBlock extends HeightMap{constructor(t,e,i){super(t,e);this.deco=i}blockAt(t,e,i,s){return new BlockInfo(s,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,s,o){return this.blockAt(0,i,s,o)}forEachLine(t,e,i,s,o,n){t<=o+this.length&&e>=o&&n(this.blockAt(0,i,s,o))}updateHeight(t,e=0,i=false,s){s&&s.from<=e&&s.more&&this.setHeight(t,s.heights[s.index++]);this.outdated=false;return this}toString(){return`block(${this.length})`}}class HeightMapText extends HeightMapBlock{constructor(t,e){super(t,e,null);this.collapsed=0;this.widgetHeight=0;this.breaks=0}blockAt(t,e,i,s){return new BlockInfo(s,this.length,i,this.height,this.breaks)}replace(t,e,i){let s=i[0];if(i.length==1&&(s instanceof HeightMapText||s instanceof HeightMapGap&&s.flags&4)&&Math.abs(this.length-s.length)<10){s instanceof HeightMapGap?s=new HeightMapText(s.length,this.height):s.height=this.height;this.outdated||(s.outdated=false);return s}return HeightMap.of(i)}updateHeight(t,e=0,i=false,s){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=false;return this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class HeightMapGap extends HeightMap{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number;let o=s-i+1;let 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+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length);let n=e.doc.lineAt(o),a=r+n.length*l;let h=Math.max(i,t-a/2);return new BlockInfo(n.from,n.length,h,a,0)}{let s=Math.max(0,Math.min(n-o,Math.floor((t-i)/r)));let{from:l,length:a}=e.doc.line(o+s);return new BlockInfo(l,a,i+r*s,r,0)}}lineAt(t,e,i,s,o){if(e==Ht.ByHeight)return this.blockAt(t,i,s,o);if(e==Ht.ByPosNoHeight){let{from:e,to:s}=i.doc.lineAt(t);return new BlockInfo(e,s-e,0,0,0)}let{firstLine:n,perLine:r,perChar:l}=this.heightMetrics(i,o);let a=i.doc.lineAt(t),h=r+a.length*l;let c=a.number-n;let d=s+r*c+l*(a.from-o-c);return new BlockInfo(a.from,a.length,Math.max(s,Math.min(d,s+this.height-h)),h,0)}forEachLine(t,e,i,s,o,n){t=Math.max(t,o);e=Math.min(e,o+this.length);let{firstLine:r,perLine:l,perChar:a}=this.heightMetrics(i,o);for(let h=t,c=s;h<=e;){let e=i.doc.lineAt(h);if(h==t){let i=e.number-r;c+=l*i+a*(t-o-i)}let s=l+a*e.length;n(new BlockInfo(e.from,e.length,c,s,0));c+=s;h=e.to+1}}replace(t,e,i){let s=this.length-e;if(s>0){let t=i[i.length-1];t instanceof HeightMapGap?i[i.length-1]=new HeightMapGap(t.length+s):i.push(null,new HeightMapGap(s-1))}if(t>0){let e=i[0];e instanceof HeightMapGap?i[0]=new HeightMapGap(t+e.length):i.unshift(new HeightMapGap(t-1),null)}return HeightMap.of(i)}decomposeLeft(t,e){e.push(new HeightMapGap(t-1),null)}decomposeRight(t,e){e.push(null,new HeightMapGap(this.length-t-1))}updateHeight(t,e=0,i=false,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;s.from>e&&i.push(new HeightMapGap(s.from-e-1).updateHeight(t,e));while(n<=o&&s.more){let e=t.doc.lineAt(n).length;i.length&&i.push(null);let o=s.heights[s.index++];r==-1?r=o:Math.abs(o-r)>=Nt&&(r=-2);let l=new HeightMapText(e,o);l.outdated=false;i.push(l);n+=e+1}n<=o&&i.push(null,new HeightMapGap(o-n).updateHeight(t,n));let l=HeightMap.of(i);(r<0||Math.abs(l.height-this.height)>=Nt||Math.abs(r-this.heightMetrics(t,e).perLine)>=Nt)&&(t.heightChanged=true);return l}if(i||this.outdated){this.setHeight(t,t.heightForGap(e,e+this.length));this.outdated=false}return this}toString(){return`gap(${this.length})`}}class HeightMapBranch extends HeightMap{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0));this.left=t;this.right=i;this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,e,i,s){let o=i+this.left.height;return t<o?this.left.blockAt(t,e,i,s):this.right.blockAt(t,e,o,s+this.left.length+this.break)}lineAt(t,e,i,s,o){let n=s+this.left.height,r=o+this.left.length+this.break;let l=e==Ht.ByHeight?t<n:t<r;let a=l?this.left.lineAt(t,e,i,s,o):this.right.lineAt(t,e,i,n,r);if(this.break||(l?a.to<r:a.from>r))return a;let h=e==Ht.ByPosNoHeight?Ht.ByPosNoHeight:Ht.ByPos;return l?a.join(this.right.lineAt(r,h,i,n,r)):this.left.lineAt(r,h,i,s,o).join(a)}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.left.forEachLine(t,e,i,s,o,n);e>=l&&this.right.forEachLine(t,e,i,r,l,n)}else{let a=this.lineAt(l,Ht.ByPos,i,s,o);t<a.from&&this.left.forEachLine(t,a.from-1,i,s,o,n);a.to>=t&&a.from<=e&&n(a);e>a.to&&this.right.forEachLine(a.to+1,e,i,r,l,n)}}replace(t,e,i){let s=this.left.length+this.break;if(e<s)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-s,e-s,i));let o=[];t>0&&this.decomposeLeft(t,o);let n=o.length;for(let t of i)o.push(t);t>0&&mergeGaps(o,n-1);if(e<this.length){let t=o.length;this.decomposeRight(e,o);mergeGaps(o,t)}return HeightMap.of(o)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left);if(this.break){i++;t>=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);t<i&&this.left.decomposeRight(t,e);this.break&&t<s&&e.push(null);e.push(this.right)}balanced(t,e){if(t.size>2*e.size||e.size>2*t.size)return HeightMap.of(this.break?[t,null,e]:[t,e]);this.left=t;this.right=e;this.height=t.height+e.height;this.outdated=t.outdated||e.outdated;this.size=t.size+e.size;this.length=t.length+this.break+e.length;return this}updateHeight(t,e=0,i=false,s){let{left:o,right:n}=this,r=e+o.length+this.break,l=null;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);if(l)return this.balanced(o,n);this.height=this.left.height+this.right.height;this.outdated=false;return this}toString(){return this.left+(this.break?" ":"-")+this.right}}function mergeGaps(t,e){let i,s;t[e]==null&&(i=t[e-1])instanceof HeightMapGap&&(s=t[e+1])instanceof HeightMapGap&&t.splice(e-1,3,new HeightMapGap(i.length+1+s.length))}const Wt=5;class NodeBuilder{constructor(t,e){this.pos=t;this.oracle=e;this.nodes=[];this.lineStart=-1;this.lineEnd=-1;this.covering=null;this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof HeightMapText?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new HeightMapText(t-this.pos,-1));this.writtenTo=t;if(e>t){this.nodes.push(null);this.writtenTo++;this.lineStart=-1}}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let s=i.widget?i.widget.estimatedHeight:0;let o=i.widget?i.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let n=e-t;i.block?this.addBlock(new HeightMapBlock(n,s,i)):(n||o||s>=Wt)&&this.addLineDeco(s,o,n)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t;this.lineEnd=e;if(this.writtenTo<t){(this.writtenTo<t-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1));this.nodes.push(null)}this.pos>t&&this.nodes.push(new HeightMapText(this.pos-t,-1));this.writtenTo=this.pos}blankContent(t,e){let i=new HeightMapGap(e-t);this.oracle.doc.lineAt(t).to==e&&(i.flags|=4);return i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof HeightMapText)return t;let e=new HeightMapText(0,-1);this.nodes.push(e);return 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=this.nodes.length==0?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof HeightMapText||this.isCovered?(this.writtenTo<this.pos||e==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new HeightMapText(0,-1));let i=t;for(let t of this.nodes){t instanceof HeightMapText&&t.updateHeight(this.oracle,i);i+=t?t.length:1}return this.nodes}static build(t,e,s,o){let n=new NodeBuilder(s,t);i.spans(e,s,o,n,0);return n.finish(s)}}function heightRelevantDecoChanges(t,e,s){let o=new DecorationComparator;i.compare(t,e,s,o,0);return o.changes}class DecorationComparator{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,s){(t<e||i&&i.heightRelevant||s&&s.heightRelevant)&&addRange(t,e,this.changes,5)}}function visiblePixelRange(t,e){let i=t.getBoundingClientRect();let s=t.ownerDocument,o=s.defaultView||window;let n=Math.max(0,i.left),r=Math.min(o.innerWidth,i.right);let l=Math.max(0,i.top),a=Math.min(o.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=s.body;)if(e.nodeType==1){let i=e;let s=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&s.overflow!="visible"){let s=i.getBoundingClientRect();n=Math.max(n,s.left);r=Math.min(r,s.right);l=Math.max(l,s.top);a=e==t.parentNode?s.bottom:Math.min(a,s.bottom)}e=s.position=="absolute"||s.position=="fixed"?i.offsetParent:i.parentNode}else{if(e.nodeType!=11)break;e=e.host}return{left:n-i.left,right:Math.max(n,r)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function fullPixelRange(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class LineGap{constructor(t,e,i){this.from=t;this.to=e;this.size=i}static same(t,e){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++){let s=t[i],o=e[i];if(s.from!=o.from||s.to!=o.to||s.size!=o.size)return false}return true}draw(t,e){return Decoration.replace({widget:new LineGapWidget(this.size*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class LineGapWidget extends WidgetType{constructor(t,e){super();this.size=t;this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");if(this.vertical)t.style.height=this.size+"px";else{t.style.width=this.size+"px";t.style.height="2px";t.style.display="inline-block"}return t}get estimatedHeight(){return this.vertical?this.size:-1}}class ViewState{constructor(e){this.state=e;this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0};this.inView=true;this.paddingTop=0;this.paddingBottom=0;this.contentDOMWidth=0;this.contentDOMHeight=0;this.editorHeight=0;this.editorWidth=0;this.scrollTop=0;this.scrolledToBottom=true;this.scaleX=1;this.scaleY=1;this.scrollAnchorPos=0;this.scrollAnchorHeight=-1;this.scaler=Ft;this.scrollTarget=null;this.printing=false;this.mustMeasureContent=true;this.defaultTextDirection=q.LTR;this.visibleRanges=[];this.mustEnforceCursorAssoc=false;let i=e.facet(ft).some((t=>typeof t!="function"&&t.class=="cm-lineWrapping"));this.heightOracle=new HeightOracle(i);this.stateDeco=e.facet(pt).filter((t=>typeof t!="function"));this.heightMap=HeightMap.empty().applyChanges(this.stateDeco,t.empty,this.heightOracle.setDoc(e.doc),[new ChangedRange(0,0,0,e.doc.length)]);this.viewport=this.getViewport(0,null);this.updateViewportLines();this.updateForViewport();this.lineGaps=this.ensureLineGaps([]);this.lineGapDeco=Decoration.set(this.lineGaps.map((t=>t.draw(this,false))));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 Viewport(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from));this.scaler=this.heightMap.height<=7e6?Ft:new BigScaler(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(this.scaler.scale==1?t:scaleBlock(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(pt).filter((t=>typeof t!="function"));let s=t.changedRanges;let o=ChangedRange.extendWithRanges(s,heightRelevantDecoChanges(i,this.stateDeco,t?t.changes:a.empty(this.state.doc.length)));let n=this.heightMap.height;let r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),o);this.heightMap.height!=n&&(t.flags|=2);if(r){this.scrollAnchorPos=t.changes.mapPos(r.from,-1);this.scrollAnchorHeight=r.top}else{this.scrollAnchorPos=-1;this.scrollAnchorHeight=this.heightMap.height}let l=o.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let h=!t.changes.empty||t.flags&2||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l;this.updateForViewport();h&&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(lt)&&(this.mustEnforceCursorAssoc=true)}measure(e){let i=e.contentDOM,s=window.getComputedStyle(i);let o=this.heightOracle;let n=s.whiteSpace;this.defaultTextDirection=s.direction=="rtl"?q.RTL:q.LTR;let r=this.heightOracle.mustRefreshForWrapping(n);let l=i.getBoundingClientRect();let a=r||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height;this.mustMeasureContent=false;let h=0,c=0;if(l.width&&l.height){let{scaleX:t,scaleY:e}=getScale(i,l);if(this.scaleX!=t||this.scaleY!=e){this.scaleX=t;this.scaleY=e;h|=8;r=a=true}}let d=(parseInt(s.paddingTop)||0)*this.scaleY;let u=(parseInt(s.paddingBottom)||0)*this.scaleY;if(this.paddingTop!=d||this.paddingBottom!=u){this.paddingTop=d;this.paddingBottom=u;h|=10}if(this.editorWidth!=e.scrollDOM.clientWidth){o.lineWrapping&&(a=true);this.editorWidth=e.scrollDOM.clientWidth;h|=8}let f=e.scrollDOM.scrollTop*this.scaleY;if(this.scrollTop!=f){this.scrollAnchorHeight=-1;this.scrollTop=f}this.scrolledToBottom=isScrolledToBottom(e.scrollDOM);let p=(this.printing?fullPixelRange:visiblePixelRange)(i,this.paddingTop);let g=p.top-this.pixelViewport.top,m=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView){this.inView=w;w&&(a=true)}if(!this.inView&&!this.scrollTarget)return 0;let v=l.width;if(this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight){this.contentDOMWidth=l.width;this.editorHeight=e.scrollDOM.clientHeight;h|=8}if(a){let i=e.docView.measureVisibleLineHeights(this.viewport);o.mustRefreshForHeights(i)&&(r=true);if(r||o.lineWrapping&&Math.abs(v-this.contentDOMWidth)>o.charWidth){let{lineHeight:t,charWidth:s,textHeight:l}=e.docView.measureTextSize();r=t>0&&o.refresh(n,t,s,l,v/s,i);if(r){e.docView.minWidth=0;h|=8}}g>0&&m>0?c=Math.max(g,m):g<0&&m<0&&(c=Math.min(g,m));o.heightChanged=false;for(let s of this.viewports){let n=s.from==this.viewport.from?i:e.docView.measureVisibleLineHeights(s);this.heightMap=(r?HeightMap.empty().applyChanges(this.stateDeco,t.empty,this.heightOracle,[new ChangedRange(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,r,new MeasuredHeights(s.from,n))}o.heightChanged&&(h|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);b&&(this.viewport=this.getViewport(c,this.scrollTarget));this.updateForViewport();(h&2||b)&&this.updateViewportLines();(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(r?[]:this.lineGaps,e));h|=this.computeVisibleRanges();if(this.mustEnforceCursorAssoc){this.mustEnforceCursorAssoc=false;e.docView.enforceCursorAssoc()}return h}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));let s=this.heightMap,o=this.heightOracle;let{visibleTop:n,visibleBottom:r}=this;let l=new Viewport(s.lineAt(n-i*1e3,Ht.ByHeight,o,0,0).from,s.lineAt(r+1e3*(1-i),Ht.ByHeight,o,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top);let n,r=s.lineAt(t,Ht.ByPos,o,0,0);n=e.y=="center"?(r.top+r.bottom)/2-i/2:e.y=="start"||e.y=="nearest"&&t<l.from?r.top:r.bottom-i;l=new Viewport(s.lineAt(n-500,Ht.ByHeight,o,0,0).from,s.lineAt(n+i+500,Ht.ByHeight,o,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),s=e.mapPos(t.to,1);return new Viewport(this.heightMap.lineAt(i,Ht.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,Ht.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return true;let{top:s}=this.heightMap.lineAt(t,Ht.ByPos,this.heightOracle,0,0);let{bottom:o}=this.heightMap.lineAt(e,Ht.ByPos,this.heightOracle,0,0);let{visibleTop:n,visibleBottom:r}=this;return(t==0||s<=n-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||o>=r+Math.max(10,Math.min(i,250)))&&s>n-2e3&&o<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let s of t)e.touchesRange(s.from,s.to)||i.push(new LineGap(e.mapPos(s.from),e.mapPos(s.to),s.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping;let s=i?1e4:2e3,o=s>>1,r=s<<1;if(this.defaultTextDirection!=q.LTR&&!i)return[];let l=[];let addGap=(s,r,a,h)=>{if(r-s<o)return;let c=this.state.selection.main,d=[c.from];c.empty||d.push(c.to);for(let t of d)if(t>s&&t<r){addGap(s,t-10,a,h);addGap(t+10,r,a,h);return}let u=find(t,(t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-s)<o&&Math.abs(t.to-r)<o&&!d.some((e=>t.from<e&&t.to>e))));if(!u){if(r<a.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(n.cursor(r),false,true).head;t>s&&(r=t)}u=new LineGap(s,r,this.gapSize(a,s,r,h))}l.push(u)};for(let t of this.viewportLines){if(t.length<r)continue;let e=lineStructure(t.from,t.to,this.stateDeco);if(e.total<r)continue;let o=this.scrollTarget?this.scrollTarget.range.head:null;let n,l;if(i){let i=s/this.heightOracle.lineLength*this.heightOracle.lineHeight;let r,a;if(o!=null){let s=findFraction(e,o);let n=((this.visibleBottom-this.visibleTop)/2+i)/t.height;r=s-n;a=s+n}else{r=(this.visibleTop-t.top-i)/t.height;a=(this.visibleBottom-t.top+i)/t.height}n=findPosition(e,r);l=findPosition(e,a)}else{let t=e.total*this.heightOracle.charWidth;let i=s*this.heightOracle.charWidth;let r,a;if(o!=null){let s=findFraction(e,o);let n=((this.pixelViewport.right-this.pixelViewport.left)/2+i)/t;r=s-n;a=s+n}else{r=(this.pixelViewport.left-i)/t;a=(this.pixelViewport.right+i)/t}n=findPosition(e,r);l=findPosition(e,a)}n>t.from&&addGap(t.from,n,t,e);l<t.to&&addGap(l,t.to,t,e)}return l}gapSize(t,e,i,s){let o=findFraction(s,i)-findFraction(s,e);return this.heightOracle.lineWrapping?t.height*o:s.total*this.heightOracle.charWidth*o}updateLineGaps(t){if(!LineGap.same(t,this.lineGaps)){this.lineGaps=t;this.lineGapDeco=Decoration.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping))))}}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];i.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let s=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));this.visibleRanges=e;return s?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||scaleBlock(this.heightMap.lineAt(t,Ht.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(t),Ht.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 scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Viewport{constructor(t,e){this.from=t;this.to=e}}function lineStructure(t,e,s){let o=[],n=t,r=0;i.spans(s,t,e,{span(){},point(t,e){if(t>n){o.push({from:n,to:t});r+=t-n}n=e}},20);if(n<e){o.push({from:n,to:e});r+=e-n}return{total:r,ranges:o}}function findPosition({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 findFraction(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}function find(t,e){for(let i of t)if(e(i))return i}const Ft={toDOM(t){return t},fromDOM(t){return t},scale:1};class BigScaler{constructor(t,e,i){let s=0,o=0,n=0;this.viewports=i.map((({from:i,to:o})=>{let n=e.lineAt(i,Ht.ByPos,t,0,0).top;let r=e.lineAt(o,Ht.ByPos,t,0,0).bottom;s+=r-n;return{from:i,to:o,top:n,bottom:r,domTop:0,domBottom:0}}));this.scale=(7e6-s)/(e.height-s);for(let t of this.viewports){t.domTop=n+(t.top-o)*this.scale;n=t.domBottom=t.domTop+(t.bottom-t.top);o=t.bottom}}toDOM(t){for(let e=0,i=0,s=0;;e++){let o=e<this.viewports.length?this.viewports[e]:null;if(!o||t<o.top)return s+(t-i)*this.scale;if(t<=o.bottom)return o.domTop+(t-o.top);i=o.bottom;s=o.domBottom}}fromDOM(t){for(let e=0,i=0,s=0;;e++){let o=e<this.viewports.length?this.viewports[e]:null;if(!o||t<o.domTop)return i+(t-s)/this.scale;if(t<=o.domBottom)return o.top+(t-o.domTop);i=o.bottom;s=o.domBottom}}}function scaleBlock(t,e){if(e.scale==1)return t;let i=e.toDOM(t.top),s=e.toDOM(t.bottom);return new BlockInfo(t.from,t.length,i,s-i,Array.isArray(t._content)?t._content.map((t=>scaleBlock(t,e))):t._content)}const It=r.define({combine:t=>t.join(" ")});const zt=r.define({combine:t=>t.indexOf(true)>-1});const Gt=S.newName(),qt=S.newName(),Kt=S.newName();const Yt={"&light":"."+qt,"&dark":"."+Kt};function buildTheme(t,e,i){return new S(e,{finish(e){return/&/.test(e)?e.replace(/&\w*/,(e=>{if(e=="&")return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e}})}const Xt=buildTheme("."+Gt,{"&":{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,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Yt);const jt="";class DOMReader{constructor(t,e){this.points=t;this.text="";this.lineSeparator=e.facet(d.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=jt}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=ContentView.get(s),r=ContentView.get(o);(n&&r?n.breakAfter:(n?n.breakAfter:isBlockElement(s))||isBlockElement(o)&&(s.nodeName!="BR"||s.cmIgnore)&&this.text.length>t)&&this.lineBreak();s=o}this.findPointBefore(i,e);return 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,n=-1,r=1;if(this.lineSeparator){n=e.indexOf(this.lineSeparator,i);r=this.lineSeparator.length}else if(o=s.exec(e)){n=o.index;r=o[0].length}this.append(e.slice(i,n<0?e.length:n));if(n<0)break;this.lineBreak();if(r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=n+r}}readNode(t){if(t.cmIgnore)return;let e=ContentView.get(t);let i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&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)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(isAtEnd(t,i.node,i.offset)?e:0))}}function isAtEnd(t,e,i){for(;;){if(!e||i<maxOffset(e))return false;if(e==t)return true;i=domIndex(e)+1;e=e.parentNode}}function isBlockElement(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class DOMPoint{constructor(t,e){this.node=t;this.offset=e;this.pos=-1}}class DOMChange{constructor(t,e,i,s){this.typeOver=s;this.bounds=null;this.text="";let{impreciseHead:o,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=o||r?[]:selectionPoints(t);let i=new DOMReader(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM);this.text=i.text;this.newSel=selectionFromPoints(e,this.bounds.from)}else{let e=t.observer.selectionRange;let i=o&&o.node==e.focusNode&&o.offset==e.focusOffset||!contains(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset);let s=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!contains(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);let l=t.viewport;if((F.ios||F.chrome)&&t.state.selection.main.empty&&i!=s&&(l.from>0||l.to<t.state.doc.length)){let e=Math.min(i,s),o=Math.max(i,s);let n=l.from-e,r=l.to-o;if((n==0||n==1||e==0)&&(r==0||r==-1||o==t.state.doc.length)){i=0;s=t.state.doc.length}}this.newSel=n.single(s,i)}}}function applyDOMChange(e,i){let s;let{newSel:o}=i,r=e.state.selection.main;let l=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(i.bounds){let{from:o,to:n}=i.bounds;let a=r.from,h=null;if(l===8||F.android&&i.text.length<n-o){a=r.to;h="end"}let c=findDiff(e.state.doc.sliceString(o,n,jt),i.text,a-o,h);if(c){F.chrome&&l==13&&c.toB==c.from+2&&i.text.slice(c.from,c.toB)==jt+jt&&c.toB--;s={from:o+c.from,to:o+c.toA,insert:t.of(i.text.slice(c.from,c.toB).split(jt))}}}else o&&(!e.hasFocus&&e.state.facet(ht)||o.main.eq(r))&&(o=null);if(!s&&!o)return false;if(!s&&i.typeOver&&!r.empty&&o&&o.main.empty)s={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)};else if(s&&s.from>=r.from&&s.to<=r.to&&(s.from!=r.from||s.to!=r.to)&&r.to-r.from-(s.to-s.from)<=4)s={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,s.from).append(s.insert).append(e.state.doc.slice(s.to,r.to))};else if((F.mac||F.android)&&s&&s.from==s.to&&s.from==r.head-1&&/^\. ?$/.test(s.insert.toString())&&e.contentDOM.getAttribute("autocorrect")=="off"){o&&s.insert.length==2&&(o=n.single(o.main.anchor-1,o.main.head-1));s={from:r.from,to:r.to,insert:t.of([" "])}}else if(F.chrome&&s&&s.from==s.to&&s.from==r.head&&s.insert.toString()=="\n "&&e.lineWrapping){o&&(o=n.single(o.main.anchor-1,o.main.head-1));s={from:r.from,to:r.to,insert:t.of([" "])}}if(s){if(F.ios&&e.inputState.flushIOSKey())return true;if(F.android&&(s.from==r.from&&s.to==r.to&&s.insert.length==1&&s.insert.lines==2&&dispatchKey(e.contentDOM,"Enter",13)||(s.from==r.from-1&&s.to==r.to&&s.insert.length==0||l==8&&s.insert.length<s.to-s.from&&s.to>r.head)&&dispatchKey(e.contentDOM,"Backspace",8)||s.from==r.from&&s.to==r.to+1&&s.insert.length==0&&dispatchKey(e.contentDOM,"Delete",46)))return true;let t=s.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let i;let defaultInsert=()=>i||(i=applyDefaultInsert(e,s,o));e.state.facet(ot).some((i=>i(e,s.from,s.to,t,defaultInsert)))||e.dispatch(defaultInsert());return true}if(o&&!o.main.eq(r)){let t=false,i="select";if(e.inputState.lastSelectionTime>Date.now()-50){e.inputState.lastSelectionOrigin=="select"&&(t=true);i=e.inputState.lastSelectionOrigin}e.dispatch({selection:o,scrollIntoView:t,userEvent:i});return true}return false}function applyDefaultInsert(t,e,i){let s,o=t.state,r=o.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.from<e.from?o.sliceDoc(r.from,e.from):"";let n=r.to>e.to?o.sliceDoc(e.to,r.to):"";s=o.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+n))}else{let l=o.changes(e);let a=i&&i.main.to<=l.newLength?i.main:void 0;if(o.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let h=t.state.sliceDoc(e.from,e.to);let c,d=i&&findCompositionNode(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=o.changeByRange((i=>{if(i.from==r.from&&i.to==r.to)return{changes:l,range:a||i.map(l)};let s=i.to-u,d=s-h.length;if(i.to-i.from!=f||t.state.sliceDoc(d,s)!=h||i.to>=c.from&&i.from<=c.to)return{range:i};let p=o.changes({from:d,to:s,insert:e.insert}),g=i.to-r.to;return{changes:p,range:a?n.range(Math.max(0,a.anchor+g),Math.max(0,a.head+g)):i.map(p)}}))}else s={changes:l,selection:a&&o.selection.replaceRange(a)}}let l="input.type";if(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50){t.inputState.compositionPendingChange=false;l+=".compose";if(t.inputState.compositionFirstChange){l+=".start";t.inputState.compositionFirstChange=false}}return o.update(s,{userEvent:l,scrollIntoView:true})}function findDiff(t,e,i,s){let o=Math.min(t.length,e.length);let n=0;while(n<o&&t.charCodeAt(n)==e.charCodeAt(n))n++;if(n==o&&t.length==e.length)return null;let r=t.length,l=e.length;while(r>0&&l>0&&t.charCodeAt(r-1)==e.charCodeAt(l-1)){r--;l--}if(s=="end"){let t=Math.max(0,n-Math.min(r,l));i-=r+t-n}if(r<n&&t.length<e.length){let t=i<=n&&i>=r?n-i:0;n-=t;l=n+(l-r);r=n}else if(l<n){let t=i<=n&&i>=l?n-i:0;n-=t;r=n+(r-l);l=n}return{from:n,toA:r,toB:l}}function selectionPoints(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:n}=t.observer.selectionRange;if(i){e.push(new DOMPoint(i,s));o==i&&n==s||e.push(new DOMPoint(o,n))}return e}function selectionFromPoints(t,e){if(t.length==0)return null;let i=t[0].pos,s=t.length==2?t[1].pos:i;return i>-1&&s>-1?n.single(i+e,s+e):null}const _t={childList:true,characterData:true,subtree:true,attributes:true,characterDataOldValue:true};const Ut=F.ie&&F.ie_version<=11;class DOMObserver{constructor(t){this.view=t;this.active=false;this.selectionRange=new DOMSelectionState;this.selectionChanged=false;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=false;this.gapIntersection=null;this.gaps=[];this.parentCheck=-1;this.dom=t.contentDOM;this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(F.ie&&F.ie_version<=11||F.ios&&t.composing)&&e.some((t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()}));Ut&&(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);if(typeof ResizeObserver=="function"){this.resizeScroll=new ResizeObserver((()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}));this.resizeScroll.observe(t.scrollDOM)}this.addWindowListeners(this.win=t.win);this.start();if(typeof IntersectionObserver=="function"){this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3));if(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(false);this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1;this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=true;this.view.measure();setTimeout((()=>{this.view.viewState.printing=false;this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of 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(ht)?i.root.activeElement!=this.dom:!hasSelection(i.dom,s))return;let o=s.anchorNode&&i.docView.nearest(s.anchorNode);o&&o.ignoreEvent(t)?e||(this.selectionChanged=false):(F.ie&&F.ie_version<=11||F.android&&F.chrome)&&!i.state.selection.main.empty&&s.focusNode&&isEquivalentPosition(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(false)}readSelectionRange(){let{view:t}=this;let e=F.safari&&t.root.nodeType==11&&deepActiveElement(this.dom.ownerDocument)==this.dom&&safariSelectionRangeHack(this.view)||getSelection(t.root);if(!e||this.selectionRange.eq(e))return false;let i=hasSelection(this.dom,e);if(i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&atElementStart(this.dom,e)){this.view.inputState.lastFocusTime=0;t.docView.updateSelection();return false}this.selectionRange.setRange(e);i&&(this.selectionChanged=true);return true}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset);this.selectionChanged=false}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(i.nodeType==1){!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t));e&&e.push(i);i=i.assignedSlot||i.parentNode}else{if(i.nodeType!=11)break;i=i.host}t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t));if(e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{this.stop();return t()}finally{this.start();this.clear()}}start(){if(!this.active){this.observer.observe(this.dom,_t);Ut&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.active=true}}stop(){if(this.active){this.active=false;this.observer.disconnect();Ut&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData)}}clear(){this.processRecords();this.queue.length=0;this.selectionChanged=false}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let flush=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey();this.view.inputState.lastKeyCode=t.keyCode;this.view.inputState.lastKeyTime=Date.now();let e=this.flush();!e&&t.force&&dispatchKey(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(flush)}this.delayedAndroidKey&&t!="Enter"||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!((i=this.delayedAndroidKey)===null||i===void 0?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey);this.delayedAndroidKey=null;this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1;this.flush()})))}forceFlush(){if(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=false;for(let o of t){let t=this.readMutation(o);if(t){t.typeOver&&(s=true);if(e==-1)({from:e,to:i}=t);else{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();let s=this.selectionChanged&&hasSelection(this.dom,this.selectionRange);if(t<0&&!s)return null;t>-1&&(this.lastChange=Date.now());this.view.inputState.lastFocusTime=0;this.selectionChanged=false;let o=new DOMChange(this.view,t,e,i);this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null};return o}flush(t=true){if(this.delayedFlush>=0||this.delayedAndroidKey)return false;t&&this.readSelectionRange();let e=this.readChange();if(!e){this.view.requestMeasure();return false}let i=this.view.state;let s=applyDOMChange(this.view,e);this.view.state==i&&this.view.update([]);return s}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;e.markDirty(t.type=="attributes");t.type=="attributes"&&(e.flags|=4);if(t.type=="childList"){let i=findChild(e,t.previousSibling||t.target.previousSibling,-1);let s=findChild(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:s?e.posBefore(s):e.posAtEnd,typeOver:false}}return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){if(t!=this.win){this.removeWindowListeners(this.win);this.win=t;this.addWindowListeners(this.win)}}addWindowListeners(t){t.addEventListener("resize",this.onResize);t.addEventListener("beforeprint",this.onPrint);t.addEventListener("scroll",this.onScroll);t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll);t.removeEventListener("resize",this.onResize);t.removeEventListener("beforeprint",this.onPrint);t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i;this.stop();(t=this.intersection)===null||t===void 0?void 0:t.disconnect();(e=this.gapIntersection)===null||e===void 0?void 0:e.disconnect();(i=this.resizeScroll)===null||i===void 0?void 0:i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win);clearTimeout(this.parentCheck);clearTimeout(this.resizeTimeout);this.win.cancelAnimationFrame(this.delayedFlush);this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function findChild(t,e,i){while(e){let s=ContentView.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 safariSelectionRangeHack(t){let e=null;function read(t){t.preventDefault();t.stopImmediatePropagation();e=t.getTargetRanges()[0]}t.contentDOM.addEventListener("beforeinput",read,true);t.dom.ownerDocument.execCommand("indent");t.contentDOM.removeEventListener("beforeinput",read,true);if(!e)return null;let i=e.startContainer,s=e.startOffset;let o=e.endContainer,n=e.endOffset;let r=t.docView.domAtPos(t.state.selection.main.anchor);isEquivalentPosition(r.node,r.offset,o,n)&&([i,s,o,n]=[o,n,i,s]);return{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:n}}class EditorView{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=false;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;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||getRoot(t.parent)||document;this.viewState=new ViewState(t.state||d.create(t));t.scrollTo&&t.scrollTo.is(at)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state));this.plugins=this.state.facet(dt).map((t=>new PluginInstance(t)));for(let t of this.plugins)t.update(this);this.observer=new DOMObserver(this);this.inputState=new InputState(this);this.inputState.ensureHandlers(this.plugins);this.docView=new DocView(this);this.mountStyles();this.updateAttrs();this.updateState=0;this.requestMeasure()}dispatch(...t){let e=t.length==1&&t[0]instanceof f?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=false,s=false;let o=this.state;for(let e of t){if(e.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=e.state}if(this.destroyed){this.viewState.state=o;return}let r=this.hasFocus,l=0,a=null;if(t.some((t=>t.annotation(Et)))){this.inputState.notifiedFocused=r;l=1}else if(r!=this.inputState.notifiedFocused){this.inputState.notifiedFocused=r;a=focusChangeTransaction(o,r);a||(l=1)}let h=this.observer.delayedAndroidKey,c=null;if(h){this.observer.clearDelayedAndroidKey();c=this.observer.readChange();(c&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(c=null)}else this.observer.clear();if(o.facet(d.phrases)!=this.state.facet(d.phrases))return this.setState(o);e=ViewUpdate.create(this,o,t);e.flags|=l;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){u&&(u=u.map(e.changes));if(e.scrollIntoView){let{main:t}=e.state.selection;u=new ScrollTarget(t.empty?t:n.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(at)&&(u=t.value.clip(this.state))}this.viewState.update(e,u);this.bidiCache=CachedOrder.update(this.bidiCache,e.changes);if(!e.empty){this.updatePlugins(e);this.inputState.update(e)}i=this.docView.update(e);this.state.facet(bt)!=this.styleModules&&this.mountStyles();s=this.updateAttrs();this.showAnnouncements(t);this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}e.startState.facet(It)!=e.state.facet(It)&&(this.viewState.mustMeasureContent=true);(i||s||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure();if(!e.empty)for(let t of this.state.facet(st))try{t(e)}catch(t){logException(this.state,t,"update listener")}(a||c)&&Promise.resolve().then((()=>{a&&this.state==a.startState&&this.dispatch(a);c&&!applyDOMChange(this,c)&&h.force&&dispatchKey(this.contentDOM,h.key,h.keyCode)}))}setState(t){if(this.updateState!=0)throw new 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);this.viewState=new ViewState(t);this.plugins=t.facet(dt).map((t=>new PluginInstance(t)));this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy();this.docView=new DocView(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(dt),i=t.state.facet(dt);if(e!=i){let s=[];for(let o of i){let i=e.indexOf(o);if(i<0)s.push(new PluginInstance(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<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}measure(t=true){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled);if(this.observer.delayedAndroidKey){this.measureScheduled=-1;this.requestMeasure();return}this.measureScheduled=0;t&&this.observer.forceFlush();let e=null;let i=this.scrollDOM,s=i.scrollTop*this.scaleY;let{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(isScrolledToBottom(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&&this.viewState.scrollTarget==null)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];r&4||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((t=>{try{return t.read(this)}catch(t){logException(this.state,t);return Qt}}));let h=ViewUpdate.create(this,this.state,[]),c=false;h.flags|=r;e?e.flags|=r:e=h;this.updateState=2;if(!h.empty){this.updatePlugins(h);this.inputState.update(h);this.updateAttrs();c=this.docView.update(h)}for(let t=0;t<l.length;t++)if(a[t]!=Qt)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){logException(this.state,t)}c&&this.docView.updateSelection(true);if(!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget);this.viewState.scrollTarget=null;n=-1;continue}{let t=o<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(o).top;let e=t-n;if(e>1||e<-1){s+=e;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(st))t(e)}get themeClasses(){return Gt+" "+(this.state.facet(zt)?Kt:qt)+" "+this.state.facet(It)}updateAttrs(){let t=attrsFromFacet(this,ut,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses});let e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ht)?"true":"false",class:"cm-content",style:`${F.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true");attrsFromFacet(this,ft,e);let i=this.observer.ignore((()=>{let i=updateAttrs(this.contentDOM,this.contentAttrs,e);let s=updateAttrs(this.dom,this.editorAttrs,t);return i||s}));this.editorAttrs=t;this.contentAttrs=e;return i}showAnnouncements(t){let e=true;for(let i of t)for(let t of i.effects)if(t.is(EditorView.announce)){e&&(this.announceDOM.textContent="");e=false;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(bt);let t=this.state.facet(EditorView.cspNonce);S.mount(this.root,this.styleModules.concat(Xt).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(false)}requestMeasure(t){this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure())));if(t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);(e===void 0||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null);return 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){this.readMeasured();return this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){this.readMeasured();return this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return skipAtoms(this,t,moveByChar(this,t,e,i))}moveByGroup(t,e){return skipAtoms(this,t,moveByChar(this,t,e,(e=>byGroup(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from);let o=i[e?i.length-1:0];return n.cursor(o.side(e,s)+t.from,o.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=true){return moveToLineBoundary(this,t,e,i)}moveVertically(t,e,i){return skipAtoms(this,t,moveVertically(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=true){this.readMeasured();return posAtCoords(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(t),o=this.bidiSpans(s);let n=o[BidiSpan.find(o,t-s.from,-1,e)];return flattenRect(i,n.dir==q.LTR==e>0)}coordsForChar(t){this.readMeasured();return 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){let e=this.state.facet(rt);if(!e||t<this.viewport.from||t>this.viewport.to)return this.textDirection;this.readMeasured();return this.docView.textDirectionAt(t)}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>$t)return trivialOrder(t.length);let e,i=this.textDirectionAt(t.from);for(let s of this.bidiCache)if(s.from==t.from&&s.dir==i&&(s.fresh||isolatesEq(s.isolates,e=getIsolatedRanges(this,t))))return s.order;e||(e=getIsolatedRanges(this,t));let s=computeOrder(t.text,i,e);this.bidiCache.push(new CachedOrder(t.from,t.to,i,e,true,s));return s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||F.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{focusPreventScroll(this.contentDOM);this.docView.updateSelection()}))}setRoot(t){if(this._root!=t){this._root=t;this.observer.setWindow((t.nodeType==9?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=true}static scrollIntoView(t,e={}){return at.of(new ScrollTarget(typeof t=="number"?n.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM;let i=this.viewState.scrollAnchorAt(t);return at.of(new ScrollTarget(n.cursor(i.from),"start","start",i.top-t,e,true))}static domEventHandlers(t){return ViewPlugin.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return ViewPlugin.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=S.newName();let s=[It.of(i),bt.of(buildTheme(`.${i}`,t))];e&&e.dark&&s.push(zt.of(true));return s}static baseTheme(t){return p.lowest(bt.of(buildTheme("."+Gt,t,Yt)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content");let s=i&&ContentView.get(i)||ContentView.get(t);return((e=s===null||s===void 0?void 0:s.rootView)===null||e===void 0?void 0:e.view)||null}}EditorView.styleModule=bt;EditorView.inputHandler=ot;EditorView.focusChangeEffect=nt;EditorView.perLineTextDirection=rt;EditorView.exceptionSink=it;EditorView.updateListener=st;EditorView.editable=ht;EditorView.mouseSelectionStyle=et;EditorView.dragMovesSelection=tt;EditorView.clickAddsSelectionRange=Z;EditorView.decorations=pt;EditorView.outerDecorations=gt;EditorView.atomicRanges=mt;EditorView.bidiIsolatedRanges=wt;EditorView.scrollMargins=vt;EditorView.darkTheme=zt;EditorView.cspNonce=r.define({combine:t=>t.length?t[0]:""});EditorView.contentAttributes=ft;EditorView.editorAttributes=ut;EditorView.lineWrapping=EditorView.contentAttributes.of({class:"cm-lineWrapping"});EditorView.announce=l.define();const $t=4096;const Qt={};class CachedOrder{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:q.LTR;for(let o=Math.max(0,t.length-10);o<t.length;o++){let n=t[o];n.dir!=s||e.touchesRange(n.from,n.to)||i.push(new CachedOrder(e.mapPos(n.from,1),e.mapPos(n.to,-1),n.dir,n.isolates,false,n.order))}return i}}function attrsFromFacet(t,e,i){for(let s=t.state.facet(e),o=s.length-1;o>=0;o--){let e=s[o],n=typeof e=="function"?e(t):e;n&&combineAttrs(n,i)}return i}const Jt=F.mac?"mac":F.windows?"win":F.linux?"linux":"key";function normalizeKeyName(t,e){const i=t.split(/-(?!$)/);let s=i[i.length-1];s=="Space"&&(s=" ");let o,n,r,l;for(let t=0;t<i.length-1;++t){const s=i[t];if(/^(cmd|meta|m)$/i.test(s))l=true;else if(/^a(lt)?$/i.test(s))o=true;else if(/^(c|ctrl|control)$/i.test(s))n=true;else if(/^s(hift)?$/i.test(s))r=true;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);e=="mac"?l=true:n=true}}o&&(s="Alt-"+s);n&&(s="Ctrl-"+s);l&&(s="Meta-"+s);r&&(s="Shift-"+s);return s}function modifiers(t,e,i){e.altKey&&(t="Alt-"+t);e.ctrlKey&&(t="Ctrl-"+t);e.metaKey&&(t="Meta-"+t);i!==false&&e.shiftKey&&(t="Shift-"+t);return t}const Zt=p.default(EditorView.domEventHandlers({keydown(t,e){return runHandlers(getKeymap(e.state),t,e,"editor")}}));const te=r.define({enables:Zt});const ee=new WeakMap;function getKeymap(t){let e=t.facet(te);let i=ee.get(e);i||ee.set(e,i=buildKeymap(e.reduce(((t,e)=>t.concat(e)),[])));return i}function runScopeHandlers(t,e,i){return runHandlers(getKeymap(t.state),e,t,i)}let ie=null;const se=4e3;function buildKeymap(t,e=Jt){let i=Object.create(null);let s=Object.create(null);let checkPrefix=(t,e)=>{let i=s[t];if(i==null)s[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")};let add=(t,s,o,n,r)=>{var l,a;let h=i[t]||(i[t]=Object.create(null));let c=s.split(/ (?!$)/).map((t=>normalizeKeyName(t,e)));for(let e=1;e<c.length;e++){let i=c.slice(0,e).join(" ");checkPrefix(i,true);h[i]||(h[i]={preventDefault:true,stopPropagation:false,run:[e=>{let s=ie={view:e,prefix:i,scope:t};setTimeout((()=>{ie==s&&(ie=null)}),se);return true}]})}let d=c.join(" ");checkPrefix(d,false);let u=h[d]||(h[d]={preventDefault:false,stopPropagation:false,run:((a=(l=h._any)===null||l===void 0?void 0:l.run)===null||a===void 0?void 0:a.slice())||[]});o&&u.run.push(o);n&&(u.preventDefault=true);r&&(u.stopPropagation=true)};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));t._any||(t._any={preventDefault:false,stopPropagation:false,run:[]});for(let e in t)t[e].run.push(s.any)}let o=s[e]||s.key;if(o)for(let e of t){add(e,o,s.run,s.preventDefault,s.stopPropagation);s.shift&&add(e,"Shift-"+o,s.shift,s.preventDefault,s.stopPropagation)}}return i}function runHandlers(t,e,i,s){let o=M(e);let n=g(o,0),r=m(n)==o.length&&o!=" ";let l="",a=false,h=false,c=false;if(ie&&ie.view==i&&ie.scope==s){l=ie.prefix+" ";if(xt.indexOf(e.keyCode)<0){h=true;ie=null}}let d=new Set;let runFor=t=>{if(t){for(let s of t.run)if(!d.has(s)){d.add(s);if(s(i,e)){t.stopPropagation&&(c=true);return true}}if(t.preventDefault){t.stopPropagation&&(c=true);h=true}}return false};let u,f,p=t[s];if(p){runFor(p[l+modifiers(o,e,!r)])?a=true:r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(F.windows&&e.ctrlKey&&e.altKey)&&(u=x[e.keyCode])&&u!=o?(runFor(p[l+modifiers(u,e,true)])||e.shiftKey&&(f=C[e.keyCode])!=o&&f!=u&&runFor(p[l+modifiers(f,e,false)]))&&(a=true):r&&e.shiftKey&&runFor(p[l+modifiers(o,e,true)])&&(a=true);!a&&runFor(p._any)&&(a=true)}h&&(a=true);a&&c&&e.stopPropagation();return a}class RectangleMarker{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");t.className=this.className;this.adjust(t);return t}update(t,e){if(e.className!=this.className)return false;this.adjust(t);return true}adjust(t){t.style.left=this.left+"px";t.style.top=this.top+"px";this.width!=null&&(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){let s=t.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let o=getBase(t);return[new RectangleMarker(e,s.left-o.left,s.top-o.top,null,s.bottom-s.top)]}return rectanglesForRange(t,e,i)}}function getBase(t){let e=t.scrollDOM.getBoundingClientRect();let i=t.textDirection==q.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX;return{left:i-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function wrappedLine(t,e,i){let s=n.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(s,false,true).from),to:Math.min(i.to,t.moveToLineBoundary(s,true,true).from),type:G.Text}}function rectanglesForRange(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);let n=t.textDirection==q.LTR;let r=t.contentDOM,l=r.getBoundingClientRect(),a=getBase(t);let h=r.querySelector(".cm-line"),c=h&&window.getComputedStyle(h);let d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0);let u=l.right-(c?parseInt(c.paddingRight):0);let f=blockAt(t,s),p=blockAt(t,o);let g=f.type==G.Text?f:null;let m=p.type==G.Text?p:null;g&&(t.lineWrapping||f.widgetLineBreaks)&&(g=wrappedLine(t,s,g));m&&(t.lineWrapping||p.widgetLineBreaks)&&(m=wrappedLine(t,o,m));if(g&&m&&g.from==m.from)return pieces(drawForLine(i.from,i.to,g));{let e=g?drawForLine(i.from,null,g):drawForWidget(f,false);let s=m?drawForLine(null,i.to,m):drawForWidget(p,true);let o=[];(g||f).to<(m||p).from-(g&&m?1:0)||f.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<s.top?o.push(piece(d,e.bottom,u,s.top)):e.bottom<s.top&&t.elementAtHeight((e.bottom+s.top)/2).type==G.Text&&(e.bottom=s.top=(e.bottom+s.top)/2);return pieces(e).concat(o).concat(pieces(s))}function piece(t,i,s,o){return new RectangleMarker(e,t-a.left,i-a.top-.01,s-t,o-i+.01)}function pieces({top:t,bottom:e,horizontal:i}){let s=[];for(let o=0;o<i.length;o+=2)s.push(piece(i[o],t,i[o+1],e));return s}function drawForLine(e,i,s){let o=1e9,r=-1e9,l=[];function addSpan(e,i,a,h,c){let f=t.coordsAtPos(e,e==s.to?-2:2);let p=t.coordsAtPos(a,a==s.from?2:-2);if(f&&p){o=Math.min(f.top,p.top,o);r=Math.max(f.bottom,p.bottom,r);c==q.LTR?l.push(n&&i?d:f.left,n&&h?u:p.right):l.push(!n&&h?d:p.left,!n&&i?u:f.right)}}let a=e!==null&&e!==void 0?e:s.from,h=i!==null&&i!==void 0?i:s.to;for(let s of t.visibleRanges)if(s.to>a&&s.from<h)for(let o=Math.max(s.from,a),n=Math.min(s.to,h);;){let s=t.state.doc.lineAt(o);for(let r of t.bidiSpans(s)){let t=r.from+s.from,l=r.to+s.from;if(t>=n)break;l>o&&addSpan(Math.max(t,o),e==null&&t<=a,Math.min(l,n),i==null&&l>=h,r.dir)}o=s.to+1;if(o>=n)break}l.length==0&&addSpan(a,e==null,h,i==null,t.textDirection);return{top:o,bottom:r,horizontal:l}}function drawForWidget(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}function sameMarker(t,e){return t.constructor==e.constructor&&t.eq(e)}class LayerView{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(oe)!=t.state.facet(oe)&&this.setOrder(t.state);if(this.layer.update(t,this.dom)||t.geometryChanged){this.scale();t.view.requestMeasure(this.measureReq)}}setOrder(t){let e=0,i=t.facet(oe);while(e<i.length&&i[e]!=this.layer)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;if(t!=this.scaleX||e!=this.scaleY){this.scaleX=t;this.scaleY=e;this.dom.style.transform=`scale(${1/t}, ${1/e})`}}draw(t){if(t.length!=this.drawn.length||t.some(((t,e)=>!sameMarker(t,this.drawn[e])))){let e=this.dom.firstChild,i=0;for(let s of t)if(s.update&&e&&s.constructor&&this.drawn[i].constructor&&s.update(e,this.drawn[i])){e=e.nextSibling;i++}else this.dom.insertBefore(s.draw(),e);while(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()}}const oe=r.define();function layer(t){return[ViewPlugin.define((e=>new LayerView(e,t))),oe.of(t)]}const ne=!F.ios;const re=r.define({combine(t){return w(t,{cursorBlinkRate:1200,drawRangeCursor:true},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});function drawSelection(t={}){return[re.of(t),le,ae,ce,lt.of(true)]}function getDrawSelectionConfig(t){return t.facet(re)}function configChanged(t){return t.startState.facet(re)!=t.state.facet(re)}const le=layer({above:true,markers(t){let{state:e}=t,i=e.facet(re);let s=[];for(let o of e.selection.ranges){let r=o==e.selection.main;if(o.empty?!r||ne:i.drawRangeCursor){let e=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary";let i=o.empty?o:n.cursor(o.head,o.head>o.anchor?-1:1);for(let o of RectangleMarker.forRange(t,e,i))s.push(o)}}return s},update(t,e){t.transactions.some((t=>t.selection))&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let i=configChanged(t);i&&setBlinkRate(t.state,e);return t.docChanged||t.selectionSet||i},mount(t,e){setBlinkRate(e.state,t)},class:"cm-cursorLayer"});function setBlinkRate(t,e){e.style.animationDuration=t.facet(re).cursorBlinkRate+"ms"}const ae=layer({above:false,markers(t){return t.state.selection.ranges.map((e=>e.empty?[]:RectangleMarker.forRange(t,"cm-selectionBackground",e))).reduce(((t,e)=>t.concat(e)))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||configChanged(t)},class:"cm-selectionLayer"});const he={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};if(ne){he[".cm-line"].caretColor="transparent !important";he[".cm-content"]={caretColor:"transparent !important"}}const ce=p.highest(EditorView.theme(he));const de=l.define({map(t,e){return t==null?null:e.mapPos(t)}});const ue=v.define({create(){return null},update(t,e){t!=null&&(t=e.changes.mapPos(t));return e.effects.reduce(((t,e)=>e.is(de)?e.value:t),t)}});const fe=ViewPlugin.fromClass(class{constructor(t){this.view=t;this.cursor=null;this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let i=t.state.field(ue);if(i==null){if(this.cursor!=null){(e=this.cursor)===null||e===void 0?void 0:e.remove();this.cursor=null}}else{if(!this.cursor){this.cursor=this.view.scrollDOM.appendChild(document.createElement("div"));this.cursor.className="cm-dropCursor"}(t.startState.field(ue)!=i||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq)}}readPos(){let{view:t}=this;let e=t.state.field(ue);let i=e!=null&&t.coordsAtPos(e);if(!i)return null;let s=t.scrollDOM.getBoundingClientRect();return{left:i.left-s.left+t.scrollDOM.scrollLeft*t.scaleX,top:i.top-s.top+t.scrollDOM.scrollTop*t.scaleY,height:i.bottom-i.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:i}=this.view;if(t){this.cursor.style.left=t.left/e+"px";this.cursor.style.top=t.top/i+"px";this.cursor.style.height=t.height/i+"px"}else this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(ue)!=t&&this.view.dispatch({effects:de.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function dropCursor(){return[ue,fe]}function iterMatches(t,e,i,s,o){e.lastIndex=0;for(let n,r=t.iterRange(i,s),l=i;!r.next().done;l+=r.value.length)if(!r.lineBreak)while(n=e.exec(r.value))o(l+n.index,n)}function matchRanges(t,e){let i=t.visibleRanges;if(i.length==1&&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}class MatchDecorator{constructor(t){const{regexp:e,decoration:i,decorate:s,boundary:o,maxLength:n=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=e;if(s)this.addMatch=(t,e,i,o)=>s(o,i,i+t[0].length,t,e);else if(typeof i=="function")this.addMatch=(t,e,s,o)=>{let n=i(t,e,s);n&&o(s,s+t[0].length,n)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,s,o)=>o(s,s+t[0].length,i)}this.boundary=o;this.maxLength=n}createDeco(t){let e=new b,i=e.add.bind(e);for(let{from:e,to:s}of matchRanges(t,this.maxLength))iterMatches(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;t.docChanged&&t.changes.iterChanges(((e,o,n,r)=>{if(r>t.view.viewport.from&&n<t.view.viewport.to){i=Math.min(n,i);s=Math.max(r,s)}}));return t.viewportChanged||s-i>1e3?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.to<r?t.state.doc.lineAt(r):i;let l=Math.max(o.from,i.from),a=Math.min(o.to,s.to);if(this.boundary){for(;n>i.from;n--)if(this.boundary.test(i.text[n-1-i.from])){l=n;break}for(;r<s.to;r++)if(this.boundary.test(s.text[r-s.from])){a=r;break}}let h,c=[];let add=(t,e,i)=>c.push(i.range(t,e));if(i==s){this.regexp.lastIndex=l-i.from;while((h=this.regexp.exec(i.text))&&h.index<a-i.from)this.addMatch(h,t,h.index+i.from,add)}else iterMatches(t.state.doc,this.regexp,l,a,((e,i)=>this.addMatch(i,t,e,add)));e=e.update({filterFrom:l,filterTo:a,filter:(t,e)=>t<l||e>a,add:c})}}return e}}const pe=/x/.unicode!=null?"gu":"g";const ge=new RegExp("[\0-\b\n--\u2028\u2029\ufeff-]",pe);const me={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"};let we=null;function supportsTabSize(){var t;if(we==null&&typeof document!="undefined"&&document.body){let e=document.body.style;we=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return we||false}const ve=r.define({combine(t){let e=w(t,{render:null,specialChars:ge,addSpecialChars:null});(e.replaceTabs=!supportsTabSize())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,pe));e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,pe));return e}});function highlightSpecialChars(t={}){return[ve.of(t),specialCharPlugin()]}let be=null;function specialCharPlugin(){return be||(be=ViewPlugin.fromClass(class{constructor(t){this.view=t;this.decorations=Decoration.none;this.decorationCache=Object.create(null);this.decorator=this.makeDecorator(t.state.facet(ve));this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new MatchDecorator({regexp:t.specialChars,decoration:(e,i,s)=>{let{doc:o}=i.state;let n=g(e[0],0);if(n==9){let t=o.lineAt(s);let e=i.state.tabSize,n=y(t.text,e,s-t.from);return Decoration.replace({widget:new TabWidget((e-n%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[n]||(this.decorationCache[n]=Decoration.replace({widget:new SpecialCharWidget(t,n)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(ve);if(t.startState.facet(ve)!=e){this.decorator=this.makeDecorator(e);this.decorations=this.decorator.createDeco(t.view)}else this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const ye="•";function placeholder$1(t){return t>=32?ye:t==10?"":String.fromCharCode(9216+t)}class SpecialCharWidget extends WidgetType{constructor(t,e){super();this.options=t;this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=placeholder$1(this.code);let i=t.state.phrase("Control character")+" "+(me[this.code]||"0x"+this.code.toString(16));let s=this.options.render&&this.options.render(this.code,i,e);if(s)return s;let o=document.createElement("span");o.textContent=e;o.title=i;o.setAttribute("aria-label",i);o.className="cm-specialChar";return o}ignoreEvent(){return false}}class TabWidget extends WidgetType{constructor(t){super();this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");t.textContent="\t";t.className="cm-tab";t.style.width=this.width+"px";return t}ignoreEvent(){return false}}const Se=ViewPlugin.fromClass(class{constructor(){this.height=1e3;this.attrs={style:"padding-bottom: 1000px"}}update(t){let{view:e}=t;let i=e.viewState.editorHeight*e.scaleY-e.defaultLineHeight-e.documentPadding.top-.5;if(i>=0&&i!=this.height){this.height=i;this.attrs={style:`padding-bottom: ${i}px`}}}});function scrollPastEnd(){return[Se,ft.of((t=>{var e;return((e=t.plugin(Se))===null||e===void 0?void 0:e.attrs)||null}))]}function highlightActiveLine(){return xe}const Me=Decoration.line({class:"cm-activeLine"});const xe=ViewPlugin.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let s of t.state.selection.ranges){let o=t.lineBlockAt(s.head);if(o.from>e){i.push(Me.range(o.from));e=o.from}}return Decoration.set(i)}},{decorations:t=>t.decorations});class Placeholder extends WidgetType{constructor(t){super();this.content=t}toDOM(){let t=document.createElement("span");t.className="cm-placeholder";t.style.pointerEvents="none";t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content);typeof this.content=="string"?t.setAttribute("aria-label","placeholder "+this.content):t.setAttribute("aria-hidden","true");return t}coordsAt(t){let e=t.firstChild?clientRectsFor(t.firstChild):[];if(!e.length)return null;let i=window.getComputedStyle(t.parentNode);let s=flattenRect(e[0],i.direction!="rtl");let o=parseInt(i.lineHeight);return s.bottom-s.top>o*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+o}:s}ignoreEvent(){return false}}function placeholder(t){return ViewPlugin.fromClass(class{constructor(e){this.view=e;this.placeholder=t?Decoration.set([Decoration.widget({widget:new Placeholder(t),side:1}).range(0)]):Decoration.none}get decorations(){return this.view.state.doc.length?Decoration.none:this.placeholder}},{decorations:t=>t.decorations})}const Ce=2e3;function rectangleFor(t,e,i){let s=Math.min(e.line,i.line),o=Math.max(e.line,i.line);let r=[];if(e.off>Ce||i.off>Ce||e.col<0||i.col<0){let l=Math.min(e.off,i.off),a=Math.max(e.off,i.off);for(let e=s;e<=o;e++){let i=t.doc.line(e);i.length<=a&&r.push(n.range(i.from+l,i.to+a))}}else{let l=Math.min(e.col,i.col),a=Math.max(e.col,i.col);for(let e=s;e<=o;e++){let i=t.doc.line(e);let s=h(i.text,l,t.tabSize,true);if(s<0)r.push(n.cursor(i.to));else{let e=h(i.text,a,t.tabSize);r.push(n.range(i.from+s,i.from+e))}}}return r}function absoluteColumn(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}function getPos(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},false);let s=t.state.doc.lineAt(i),o=i-s.from;let n=o>Ce?-1:o==s.length?absoluteColumn(t,e.clientX):y(s.text,t.state.tabSize,i-s.from);return{line:s.number,col:n,off:o}}function rectangleSelectionStyle(t,e){let i=getPos(t,e),s=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from);let o=t.state.doc.lineAt(e);i={line:o.number,col:i.col,off:Math.min(i.off,o.length)};s=s.map(t.changes)}},get(e,o,r){let l=getPos(t,e);if(!l)return s;let a=rectangleFor(t.state,i,l);return a.length?r?n.create(a.concat(s.ranges)):n.create(a):s}}:null}function rectangularSelection(t){let e=(t===null||t===void 0?void 0:t.eventFilter)||(t=>t.altKey&&t.button==0);return EditorView.mouseSelectionStyle.of(((t,i)=>e(i)?rectangleSelectionStyle(t,i):null))}const ke={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]};const Ae={style:"cursor: crosshair"};function crosshairCursor(t={}){let[e,i]=ke[t.key||"Alt"];let s=ViewPlugin.fromClass(class{constructor(t){this.view=t;this.isDown=false}set(t){if(this.isDown!=t){this.isDown=t;this.view.update([])}}},{eventObservers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(false)},mousemove(t){this.set(i(t))}}});return[s,EditorView.contentAttributes.of((t=>{var e;return((e=t.plugin(s))===null||e===void 0?void 0:e.isDown)?Ae:null}))]}const De="-10000px";class TooltipViewManager{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);let o=s.filter((t=>t));if(s===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return false}let n=[],r=e?[]:null;for(let i=0;i<o.length;i++){let s=o[i],l=-1;if(s){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==s.create&&(l=t)}if(l<0){n[i]=this.createTooltipView(s,i?n[i-1]:null);r&&(r[i]=!!s.above)}else{let s=n[i]=this.tooltipViews[l];r&&(r[i]=e[l]);s.update&&s.update(t)}}}for(let t of this.tooltipViews)if(n.indexOf(t)<0){this.removeTooltipView(t);(i=t.destroy)===null||i===void 0?void 0:i.call(t)}if(e){r.forEach(((t,i)=>e[i]=t));e.length=r.length}this.input=s;this.tooltips=o;this.tooltipViews=n;return true}}function tooltips(t={}){return Te.of(t)}function windowSpace(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const Te=r.define({combine:t=>{var e,i,s;return{position:F.ios?"absolute":((e=t.find((t=>t.position)))===null||e===void 0?void 0:e.position)||"fixed",parent:((i=t.find((t=>t.parent)))===null||i===void 0?void 0:i.parent)||null,tooltipSpace:((s=t.find((t=>t.tooltipSpace)))===null||s===void 0?void 0:s.tooltipSpace)||windowSpace}}});const Oe=new WeakMap;const Re=ViewPlugin.fromClass(class{constructor(t){this.view=t;this.above=[];this.inView=true;this.madeAbsolute=false;this.lastTransaction=0;this.measureTimeout=-1;let e=t.state.facet(Te);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=typeof ResizeObserver=="function"?new ResizeObserver((()=>this.measureSoon())):null;this.manager=new TooltipViewManager(t,Ee,((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=typeof IntersectionObserver=="function"?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(){if(this.parent){this.container=document.createElement("div");this.container.style.position="relative";this.container.className=this.view.themeClasses;this.parent.appendChild(this.container)}else this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of 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;let s=t.state.facet(Te);if(s.position!=this.position&&!this.madeAbsolute){this.position=s.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=true}if(s.parent!=this.parent){this.parent&&this.container.remove();this.parent=s.parent;this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);i=true}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);let s=e?e.dom:null;i.dom.classList.add("cm-tooltip");if(t.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow";i.dom.insertBefore(t,s)}i.dom.style.position=this.position;i.dom.style.top=De;i.dom.style.left="0px";this.container.insertBefore(i.dom,s);i.mount&&i.mount(this.view);this.resizeObserver&&this.resizeObserver.observe(i.dom);return i}destroy(){var t,e,i;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews){e.dom.remove();(t=e.destroy)===null||t===void 0?void 0:t.call(e)}this.parent&&this.container.remove();(e=this.resizeObserver)===null||e===void 0?void 0:e.disconnect();(i=this.intersectionObserver)===null||i===void 0?void 0:i.disconnect();clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect();let e=1,i=1,s=false;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(F.gecko)s=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==De&&t.style.left=="0px"){let e=t.getBoundingClientRect();s=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(s||this.position=="absolute")if(this.parent){let t=this.parent.getBoundingClientRect();if(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(Te).tooltipSpace(this.view),scaleX:e,scaleY:i,makeAbsolute:s}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=true;this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{editor:i,space:s,scaleX:o,scaleY:n}=t;let r=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h;let d=t.pos[l],u=t.size[l];if(!d||d.bottom<=Math.max(i.top,s.top)||d.top>=Math.min(i.bottom,s.bottom)||d.right<Math.max(i.left,s.left)-.1||d.left>Math.min(i.right,s.right)+.1){c.style.top=De;continue}let f=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null;let p=f?7:0;let g=u.right-u.left,m=(e=Oe.get(h))!==null&&e!==void 0?e:u.bottom-u.top;let w=h.offset||Be,v=this.view.textDirection==q.LTR;let 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);let y=this.above[l];!a.strictSide&&(y?d.top-(u.bottom-u.top)-w.y<s.top:d.bottom+(u.bottom-u.top)+w.y>s.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(S<m&&h.resize!==false){if(S<this.view.defaultLineHeight){c.style.top=De;continue}Oe.set(h,m);c.style.height=(m=S)/n+"px"}else c.style.height&&(c.style.height="");let M=y?d.top-m-p-w.y:d.bottom+p+w.y;let x=b+g;if(h.overlap!==true)for(let t of r)t.left<x&&t.right>b&&t.top<M+m&&t.bottom>M&&(M=y?t.top-m-2-p:t.bottom+p+2);if(this.position=="absolute"){c.style.top=(M-t.parent.top)/n+"px";c.style.left=(b-t.parent.left)/o+"px"}else{c.style.top=M/n+"px";c.style.left=b/o+"px"}if(f){let t=d.left+(v?w.x:-w.x)-(b+14-7);f.style.left=t/o+"px"}h.overlap!==true&&r.push({left:b,top:M,right:x,bottom:M+m});c.classList.toggle("cm-tooltip-above",y);c.classList.toggle("cm-tooltip-below",!y);h.positioned&&h.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length){this.view.inView&&this.view.requestMeasure(this.measureReq);if(this.inView!=this.view.inView){this.inView=this.view.inView;if(!this.inView)for(let t of this.manager.tooltipViews)t.dom.style.top=De}}}},{eventObservers:{scroll(){this.maybeMeasure()}}});const Ve=EditorView.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});const Be={x:0,y:0};const Ee=r.define({enables:[Re,Ve]});const Pe=r.define({combine:t=>t.reduce(((t,e)=>t.concat(e)),[])});class HoverTooltipHost{static create(t){return new HoverTooltipHost(t)}constructor(t){this.view=t;this.mounted=false;this.dom=document.createElement("div");this.dom.classList.add("cm-tooltip-hover");this.manager=new TooltipViewManager(t,Pe,((t,e)=>this.createHostedView(t,e)),(t=>t.dom.remove()))}createHostedView(t,e){let i=t.create(this.view);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);return i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=true}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)(t=e.destroy)===null||t===void 0?void 0:t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let s=i[t];if(s!==void 0)if(e===void 0)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")}}const Le=Ee.compute([Pe],(t=>{let e=t.facet(Pe);return e.length===0?null:{pos:Math.min(...e.map((t=>t.pos))),end:Math.max(...e.map((t=>{var e;return(e=t.end)!==null&&e!==void 0?e:t.pos}))),create:HoverTooltipHost.create,above:e[0].above,arrow:e.some((t=>t.arrow))}}));class HoverPlugin{constructor(t,e,i,s,o){this.view=t;this.source=e;this.field=i;this.setHover=s;this.hoverTime=o;this.hoverTimeout=-1;this.restartTimeout=-1;this.pending=null;this.lastMove={x:0,y:0,target:t.dom,time:0};this.checkHover=this.checkHover.bind(this);t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this));t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){if(this.pending){this.pending=null;clearTimeout(this.restartTimeout);this.restartTimeout=setTimeout((()=>this.startHover()),20)}}get active(){return this.view.state.field(this.field)}checkHover(){this.hoverTimeout=-1;if(this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this;let i=t.docView.nearest(e.target);if(!i)return;let s,o=1;if(i instanceof WidgetView)s=i.posAtStart;else{s=t.posAtCoords(e);if(s==null)return;let i=t.coordsAtPos(s);if(!i||e.y<i.top||e.y>i.bottom||e.x<i.left-t.defaultCharacterWidth||e.x>i.right+t.defaultCharacterWidth)return;let n=t.bidiSpans(t.state.doc.lineAt(s)).find((t=>t.from<=s&&t.to>=s));let r=n&&n.dir==q.RTL?-1:1;o=e.x<i.left?-r:r}let n=this.source(t,s,o);if(n===null||n===void 0?void 0:n.then){let e=this.pending={pos:s};n.then((i=>{if(this.pending==e){this.pending=null;!i||Array.isArray(i)&&!i.length||t.dispatch({effects:this.setHover.of(Array.isArray(i)?i:[i])})}}),(e=>logException(t.state,e,"hover tooltip")))}else!n||Array.isArray(n)&&!n.length||t.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])})}get tooltip(){let t=this.view.plugin(Re);let e=t?t.manager.tooltips.findIndex((t=>t.create==HoverTooltipHost.create)):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()};this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:o}=this;if(s.length&&o&&!isInTooltip(o.dom,t)||this.pending){let{pos:o}=s[0]||this.pending,n=(i=(e=s[0])===null||e===void 0?void 0:e.end)!==null&&i!==void 0?i:o;if(o==n?this.view.posAtCoords(this.lastMove)!=o:!isOverRange(this.view,o,n,t.clientX,t.clientY)){this.view.dispatch({effects:this.setHover.of([])});this.pending=null}}}mouseleave(t){clearTimeout(this.hoverTimeout);this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:e}=this;let i=e&&e.dom.contains(t.relatedTarget);i?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let watch=e=>{t.removeEventListener("mouseleave",watch);this.active.length&&!this.view.dom.contains(e.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",watch)}destroy(){clearTimeout(this.hoverTimeout);this.view.dom.removeEventListener("mouseleave",this.mouseleave);this.view.dom.removeEventListener("mousemove",this.mousemove)}}const He=4;function isInTooltip(t,e){let i=t.getBoundingClientRect();return e.clientX>=i.left-He&&e.clientX<=i.right+He&&e.clientY>=i.top-He&&e.clientY<=i.bottom+He}function isOverRange(t,e,i,s,o,n){let r=t.scrollDOM.getBoundingClientRect();let l=t.documentTop+t.documentPadding.top+t.contentHeight;if(r.left>s||r.right<s||r.top>o||Math.min(r.bottom,l)<o)return false;let a=t.posAtCoords({x:s,y:o},false);return a>=e&&a<=i}function hoverTooltip(t,e={}){let i=l.define();let o=v.define({create(){return[]},update(t,o){if(t.length){e.hideOnChange&&(o.docChanged||o.selection)?t=[]:e.hideOn&&(t=t.filter((t=>!e.hideOn(o,t))));if(o.docChanged){let e=[];for(let i of t){let t=o.changes.mapPos(i.pos,-1,s.TrackDel);if(t!=null){let s=Object.assign(Object.create(null),i);s.pos=t;s.end!=null&&(s.end=o.changes.mapPos(s.end));e.push(s)}}t=e}}for(let e of o.effects){e.is(i)&&(t=e.value);e.is(Ne)&&(t=[])}return t},provide:t=>Pe.from(t)});return[o,ViewPlugin.define((s=>new HoverPlugin(s,t,o,i,e.hoverTime||300))),Le]}function getTooltip(t,e){let i=t.plugin(Re);if(!i)return null;let s=i.manager.tooltips.indexOf(e);return s<0?null:i.manager.tooltipViews[s]}function hasHoverTooltips(t){return t.facet(Pe).some((t=>t))}const Ne=l.define();const We=Ne.of(null);function repositionTooltips(t){let e=t.plugin(Re);e&&e.maybeMeasure()}const Fe=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}}});function panels(t){return t?[Fe.of(t)]:[]}function getPanel(t,e){let i=t.plugin(Ie);let s=i?i.specs.indexOf(e):-1;return s>-1?i.panels[s]:null}const Ie=ViewPlugin.fromClass(class{constructor(t){this.input=t.state.facet(ze);this.specs=this.input.filter((t=>t));this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(Fe);this.top=new PanelGroup(t,true,e.topContainer);this.bottom=new PanelGroup(t,false,e.bottomContainer);this.top.sync(this.panels.filter((t=>t.top)));this.bottom.sync(this.panels.filter((t=>!t.top)));for(let t of this.panels){t.dom.classList.add("cm-panel");t.mount&&t.mount()}}update(t){let e=t.state.facet(Fe);if(this.top.container!=e.topContainer){this.top.sync([]);this.top=new PanelGroup(t.view,true,e.topContainer)}if(this.bottom.container!=e.bottomContainer){this.bottom.sync([]);this.bottom=new PanelGroup(t.view,false,e.bottomContainer)}this.top.syncClasses();this.bottom.syncClasses();let i=t.state.facet(ze);if(i!=this.input){let e=i.filter((t=>t));let s=[],o=[],n=[],r=[];for(let i of e){let e,l=this.specs.indexOf(i);if(l<0){e=i(t.view);r.push(e)}else{e=this.panels[l];e.update&&e.update(t)}s.push(e);(e.top?o:n).push(e)}this.specs=e;this.panels=s;this.top.sync(o);this.bottom.sync(n);for(let t of r){t.dom.classList.add("cm-panel");t.mount&&t.mount()}}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]);this.bottom.sync([])}},{provide:t=>EditorView.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class PanelGroup{constructor(t,e,i){this.view=t;this.top=e;this.container=i;this.dom=void 0;this.classes="";this.panels=[];this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t;this.syncDOM()}syncDOM(){if(this.panels.length==0){if(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){while(t!=e.dom)t=rm(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);while(t)t=rm(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function rm(t){let e=t.nextSibling;t.remove();return e}const ze=r.define({enables:Ie});class GutterMarker extends e{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return false}destroy(t){}}GutterMarker.prototype.elementClass="";GutterMarker.prototype.toDOM=void 0;GutterMarker.prototype.mapMode=s.TrackBefore;GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1;GutterMarker.prototype.point=true;const Ge=r.define();const qe={class:"",renderEmptyElements:false,elementStyle:"",markers:()=>i.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}};const Ke=r.define();function gutter(t){return[gutters(),Ke.of(Object.assign(Object.assign({},qe),t))]}const Ye=r.define({combine:t=>t.some((t=>t))});function gutters(t){let e=[Xe];t&&t.fixed===false&&e.push(Ye.of(true));return e}const Xe=ViewPlugin.fromClass(class{constructor(t){this.view=t;this.prevViewport=t.viewport;this.dom=document.createElement("div");this.dom.className="cm-gutters";this.dom.setAttribute("aria-hidden","true");this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px";this.gutters=t.state.facet(Ke).map((e=>new SingleGutterView(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(Ye);this.fixed&&(this.dom.style.position="sticky");this.syncGutters(false);t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport;let s=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(s<.8*(i.to-i.from))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px");if(this.view.state.facet(Ye)!=!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 s=i.iter(this.view.state.facet(Ge),this.view.viewport.from);let o=[];let n=this.gutters.map((t=>new UpdateContext(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks){o.length&&(o=[]);if(Array.isArray(t.type)){let e=true;for(let i of t.type)if(i.type==G.Text&&e){advanceCursor(s,o,i.from);for(let t of n)t.line(this.view,i,o);e=false}else if(i.widget)for(let t of n)t.widget(this.view,i)}else if(t.type==G.Text){advanceCursor(s,o,t.from);for(let e of n)e.line(this.view,t,o)}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(Ke),s=t.state.facet(Ke);let o=t.docChanged||t.heightChanged||t.viewportChanged||!i.eq(t.startState.facet(Ge),t.state.facet(Ge),t.view.viewport.from,t.view.viewport.to);if(e==s)for(let e of this.gutters)e.update(t)&&(o=true);else{o=true;let i=[];for(let o of s){let s=e.indexOf(o);if(s<0)i.push(new SingleGutterView(this.view,o));else{this.gutters[s].update(t);i.push(this.gutters[s])}}for(let t of this.gutters){t.dom.remove();i.indexOf(t)<0&&t.destroy()}for(let t of i)this.dom.appendChild(t.dom);this.gutters=i}return o}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>EditorView.scrollMargins.of((e=>{let i=e.plugin(t);return i&&i.gutters.length!=0&&i.fixed?e.textDirection==q.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null}))});function asArray(t){return Array.isArray(t)?t:[t]}function advanceCursor(t,e,i){while(t.value&&t.from<=i){t.from==i&&e.push(t.value);t.next()}}class UpdateContext{constructor(t,e,s){this.gutter=t;this.height=s;this.i=0;this.cursor=i.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 GutterElement(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=[];advanceCursor(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;(s.length!=0||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;while(t.elements.length>this.i){let e=t.elements.pop();t.dom.removeChild(e.dom);e.destroy()}}}class SingleGutterView{constructor(t,e){this.view=t;this.config=e;this.elements=[];this.spacer=null;this.dom=document.createElement("div");this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,(s=>{let o,n=s.target;if(n!=this.dom&&this.dom.contains(n)){while(n.parentNode!=this.dom)n=n.parentNode;let t=n.getBoundingClientRect();o=(t.top+t.bottom)/2}else o=s.clientY;let r=t.lineBlockAtHeight(o-t.documentTop);e.domEventHandlers[i](t,r,s)&&s.preventDefault()}));this.markers=asArray(e.markers(t));if(e.initialSpacer){this.spacer=new GutterElement(t,0,0,[e.initialSpacer(t)]);this.dom.appendChild(this.spacer.dom);this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none"}}update(t){let e=this.markers;this.markers=asArray(this.config.markers(t.view));if(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 s=t.view.viewport;return!i.eq(this.markers,e,s.from,s.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class GutterElement{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){if(this.height!=e){this.height=e;this.dom.style.height=e+"px"}this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":"");sameMarkers(this.markers,s)||this.setMarkers(t,s)}setMarkers(t,e){let i="cm-gutterElement",s=this.dom.firstChild;for(let o=0,n=0;;){let r=n,l=o<e.length?e[o++]:null,a=false;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let t=n;t<this.markers.length;t++)if(this.markers[t].compare(l)){r=t;a=true;break}}else r=this.markers.length;while(n<r){let t=this.markers[n++];if(t.toDOM){t.destroy(s);let e=s.nextSibling;s.remove();s=e}}if(!l)break;l.toDOM&&(a?s=s.nextSibling:this.dom.insertBefore(l.toDOM(t),s));a&&n++}this.dom.className=i;this.markers=e}destroy(){this.setMarkers(null,[])}}function sameMarkers(t,e){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return false;return true}const je=r.define();const _e=r.define({combine(t){return w(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 NumberMarker extends GutterMarker{constructor(t){super();this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function formatNumber(t,e){return t.state.facet(_e).formatNumber(e,t.state)}const Ue=Ke.compute([_e],(t=>({class:"cm-lineNumbers",renderEmptyElements:false,markers(t){return t.state.facet(je)},lineMarker(t,e,i){return i.some((t=>t.toDOM))?null:new NumberMarker(formatNumber(t,t.state.doc.lineAt(e.from).number))},widgetMarker:()=>null,lineMarkerChange:t=>t.startState.facet(_e)!=t.state.facet(_e),initialSpacer(t){return new NumberMarker(formatNumber(t,maxLineNumber(t.state.doc.lines)))},updateSpacer(t,e){let i=formatNumber(e.view,maxLineNumber(e.view.state.doc.lines));return i==t.number?t:new NumberMarker(i)},domEventHandlers:t.facet(_e).domEventHandlers})));function lineNumbers(t={}){return[_e.of(t),gutters(),Ue]}function maxLineNumber(t){let e=9;while(e<t)e=e*10+9;return e}const $e=new class extends GutterMarker{constructor(){super(...arguments);this.elementClass="cm-activeLineGutter"}};const Qe=Ge.compute(["selection"],(t=>{let e=[],s=-1;for(let i of t.selection.ranges){let o=t.doc.lineAt(i.head).from;if(o>s){s=o;e.push($e.range(o))}}return i.of(e)}));function highlightActiveLineGutter(){return Qe}const Je=new Map;function getWhitespaceDeco(t){let e=Je.get(t);e||Je.set(t,e=Decoration.mark({attributes:t==="\t"?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":t.replace(/ /g,"·")}}));return e}function matcher(t){return ViewPlugin.define((e=>({decorations:t.createDeco(e),update(e){this.decorations=t.updateDeco(e,this.decorations)}})),{decorations:t=>t.decorations})}const Ze=matcher(new MatchDecorator({regexp:/\t| +/g,decoration:t=>getWhitespaceDeco(t[0]),boundary:/\S/}));function highlightWhitespace(){return Ze}const ti=matcher(new MatchDecorator({regexp:/\s+$/g,decoration:Decoration.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function highlightTrailingWhitespace(){return ti}const ei={HeightMap:HeightMap,HeightOracle:HeightOracle,MeasuredHeights:MeasuredHeights,QueryType:Ht,ChangedRange:ChangedRange,computeOrder:computeOrder,moveVisually:moveVisually};export{BidiSpan,BlockInfo,G as BlockType,Decoration,q as Direction,EditorView,GutterMarker,MatchDecorator,RectangleMarker,ViewPlugin,ViewUpdate,WidgetType,ei as __test,We as closeHoverTooltips,crosshairCursor,drawSelection,dropCursor,getDrawSelectionConfig,getPanel,getTooltip,gutter,Ge as gutterLineClass,gutters,hasHoverTooltips,highlightActiveLine,highlightActiveLineGutter,highlightSpecialChars,highlightTrailingWhitespace,highlightWhitespace,hoverTooltip,te as keymap,layer,je as lineNumberMarkers,lineNumbers,logException,panels,placeholder,rectangularSelection,repositionTooltips,runScopeHandlers,scrollPastEnd,ze as showPanel,Ee as showTooltip,tooltips};
|
2
|
+
|
@@ -0,0 +1,2 @@
|
|
1
|
+
const e=1024;let t=0;class Range{constructor(e,t){this.from=e;this.to=t}}class NodeProp{constructor(e={}){this.id=t++;this.perNode=!!e.perNode;this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");typeof e!="function"&&(e=NodeType.match(e));return t=>{let r=e(t);return r===void 0?null:[this,r]}}}NodeProp.closedBy=new NodeProp({deserialize:e=>e.split(" ")});NodeProp.openedBy=new NodeProp({deserialize:e=>e.split(" ")});NodeProp.group=new NodeProp({deserialize:e=>e.split(" ")});NodeProp.isolate=new NodeProp({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});NodeProp.contextHash=new NodeProp({perNode:true});NodeProp.lookAhead=new NodeProp({perNode:true});NodeProp.mounted=new NodeProp({perNode:true});class MountedTree{constructor(e,t,r){this.tree=e;this.overlay=t;this.parser=r}static get(e){return e&&e.props&&e.props[NodeProp.mounted.id]}}const r=Object.create(null);class NodeType{constructor(e,t,r,n=0){this.name=e;this.props=t;this.id=r;this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):r;let n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0);let i=new NodeType(e.name||"",t,e.id,n);if(e.props)for(let r of e.props){Array.isArray(r)||(r=r(i));if(r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return true;let t=this.prop(NodeProp.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let n of r.split(" "))t[n]=e[r];return e=>{for(let r=e.prop(NodeProp.group),n=-1;n<(r?r.length:0);n++){let i=t[n<0?e.name:r[n]];if(i)return i}}}}NodeType.none=new NodeType("",Object.create(null),0,8);class NodeSet{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let r of this.types){let n=null;for(let t of e){let e=t(r);if(e){n||(n=Object.assign({},r.props));n[e[0].id]=e[1]}}t.push(n?new NodeType(r.name,n,r.id,r.flags):r)}return new NodeSet(t)}}const n=new WeakMap,i=new WeakMap;var s;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers";e[e.IncludeAnonymous=2]="IncludeAnonymous";e[e.IgnoreMounts=4]="IgnoreMounts";e[e.IgnoreOverlays=8]="IgnoreOverlays"})(s||(s={}));class Tree{constructor(e,t,r,n,i){this.type=e;this.children=t;this.positions=r;this.length=n;this.props=null;if(i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e=="number"?e:e.id]=t}}toString(){let e=MountedTree.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let r=e.toString();if(r){t&&(t+=",");t+=r}}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new TreeCursor(this.topNode,e)}cursorAt(e,t=0,r=0){let i=n.get(this)||this.topNode;let s=new TreeCursor(i);s.moveTo(e,t);n.set(this,s._tree);return s}get topNode(){return new TreeNode(this,0,0,null)}resolve(e,t=0){let r=resolveNode(n.get(this)||this.topNode,e,t,false);n.set(this,r);return r}resolveInner(e,t=0){let r=resolveNode(i.get(this)||this.topNode,e,t,true);i.set(this,r);return r}resolveStack(e,t=0){return stackIterator(this,e,t)}iterate(e){let{enter:t,leave:r,from:n=0,to:i=this.length}=e;let o=e.mode||0,l=(o&s.IncludeAnonymous)>0;for(let e=this.cursor(o|s.IncludeAnonymous);;){let s=false;if(e.from<=i&&e.to>=n&&(!l&&e.type.isAnonymous||t(e)!==false)){if(e.firstChild())continue;s=true}for(;;){s&&r&&(l||!e.type.isAnonymous)&&r(e);if(e.nextSibling())break;if(!e.parent())return;s=true}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:balanceRange(NodeType.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,r)=>new Tree(this.type,e,t,r,this.propValues)),e.makeTree||((e,t,r)=>new Tree(NodeType.none,e,t,r)))}static build(e){return buildTree(e)}}Tree.empty=new Tree(NodeType.none,[],[],0);class FlatBufferCursor{constructor(e,t){this.buffer=e;this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new FlatBufferCursor(this.buffer,this.index)}}class TreeBuffer{constructor(e,t,r){this.buffer=e;this.length=t;this.set=r}get type(){return NodeType.none}toString(){let e=[];for(let t=0;t<this.buffer.length;){e.push(this.childString(t));t=this.buffer[t+3]}return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3];let n=this.set.types[t],i=n.name;/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i));e+=4;if(r==e)return i;let s=[];while(e<r){s.push(this.childString(e));e=this.buffer[e+3]}return i+"("+s.join(",")+")"}findChild(e,t,r,n,i){let{buffer:s}=this,o=-1;for(let l=e;l!=t;l=s[l+3])if(checkSide(i,n,s[l+1],s[l+2])){o=l;if(r>0)break}return o}slice(e,t,r){let n=this.buffer;let i=new Uint16Array(t-e),s=0;for(let o=e,l=0;o<t;){i[l++]=n[o++];i[l++]=n[o++]-r;let t=i[l++]=n[o++]-r;i[l++]=n[o++]-e;s=Math.max(s,t)}return new TreeBuffer(i,s,this.set)}}function checkSide(e,t,r,n){switch(e){case-2:return r<t;case-1:return n>=t&&r<t;case 0:return r<t&&n>t;case 1:return r<=t&&n>t;case 2:return n>t;case 4:return true}}function resolveNode(e,t,r,n){var i;while(e.from==e.to||(r<1?e.from>=t:e.from>t)||(r>-1?e.to<=t:e.to<t)){let t=!n&&e instanceof TreeNode&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=n?0:s.IgnoreOverlays;if(n)for(let n=e,s=n.parent;s;n=s,s=n.parent)n instanceof TreeNode&&n.index<0&&((i=s.enter(t,r,o))===null||i===void 0?void 0:i.from)!=n.from&&(e=s);for(;;){let n=e.enter(t,r,o);if(!n)return e;e=n}}class BaseNode{cursor(e=0){return new TreeCursor(this,e)}getChild(e,t=null,r=null){let n=getChildren(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return getChildren(this,e,t,r)}resolve(e,t=0){return resolveNode(this,e,t,false)}resolveInner(e,t=0){return resolveNode(this,e,t,true)}matchContext(e){return matchNodeContext(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),r=this;while(t){let e=t.lastChild;if(!e||e.to!=t.to)break;if(e.type.isError&&e.from==e.to){r=t;t=e.prevSibling}else t=e}return r}get node(){return this}get next(){return this.parent}}class TreeNode extends BaseNode{constructor(e,t,r,n){super();this._tree=e;this.from=t;this.index=r;this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,n,i=0){for(let o=this;;){for(let{children:l,positions:f}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let h=l[e],u=f[e]+o.from;if(checkSide(n,r,u,u+h.length))if(h instanceof TreeBuffer){if(i&s.ExcludeBuffers)continue;let l=h.findChild(0,h.buffer.length,t,r-u,n);if(l>-1)return new BufferNode(new BufferContext(o,h,e,u),null,l)}else if(i&s.IncludeAnonymous||!h.type.isAnonymous||hasChild(h)){let l;if(!(i&s.IgnoreMounts)&&(l=MountedTree.get(h))&&!l.overlay)return new TreeNode(l.tree,u,e,o);let f=new TreeNode(h,u,e,o);return i&s.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(t<0?h.children.length-1:0,t,r,n)}}if(i&s.IncludeAnonymous||!o.type.isAnonymous)return null;e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length;o=o._parent;if(!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,r=0){let n;if(!(r&s.IgnoreOverlays)&&(n=MountedTree.get(this._tree))&&n.overlay){let r=e-this.from;for(let{from:e,to:i}of n.overlay)if((t>0?e<=r:e<r)&&(t<0?i>=r:i>r))return new TreeNode(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;while(e.type.isAnonymous&&e._parent)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function getChildren(e,t,r,n){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(r!=null)for(let e=false;!e;){e=i.type.is(r);if(!i.nextSibling())return s}for(;;){if(n!=null&&i.type.is(n))return s;i.type.is(t)&&s.push(i.node);if(!i.nextSibling())return n==null?s:[]}}function matchNodeContext(e,t,r=t.length-1){for(let n=e.parent;r>=0;n=n.parent){if(!n)return false;if(!n.type.isAnonymous){if(t[r]&&t[r]!=n.name)return false;r--}}return true}class BufferContext{constructor(e,t,r,n){this.parent=e;this.buffer=t;this.index=r;this.start=n}}class BufferNode extends BaseNode{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,r){super();this.context=e;this._parent=t;this.index=r;this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:n}=this.context;let i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,r);return i<0?null:new BufferNode(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,r=0){if(r&s.ExcludeBuffers)return null;let{buffer:n}=this.context;let i=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new BufferNode(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context;let t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new BufferNode(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context;let t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new BufferNode(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[];let{buffer:r}=this.context;let n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1];e.push(r.slice(n,i,s));t.push(0)}return new Tree(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function iterStack(e){if(!e.length)return null;let t=0,r=e[0];for(let n=1;n<e.length;n++){let i=e[n];if(i.from>r.from||i.to<r.to){r=i;t=n}}let n=r instanceof TreeNode&&r.index<0?null:r.parent;let i=e.slice();n?i[t]=n:i.splice(t,1);return new StackIterator(i,r)}class StackIterator{constructor(e,t){this.heads=e;this.node=t}get next(){return iterStack(this.heads)}}function stackIterator(e,t,r){let n=e.resolveInner(t,r),i=null;for(let e=n instanceof TreeNode?n:n.context.parent;e;e=e.parent)if(e.index<0){let s=e.parent;(i||(i=[n])).push(s.resolve(t,r));e=s}else{let s=MountedTree.get(e.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let o=new TreeNode(s.tree,s.overlay[0].from+e.from,-1,e);(i||(i=[n])).push(resolveNode(o,t,r,false))}}return i?iterStack(i):n}class TreeCursor{get name(){return this.type.name}constructor(e,t=0){this.mode=t;this.buffer=null;this.stack=[];this.index=0;this.bufferNode=null;if(e instanceof TreeNode)this.yieldNode(e);else{this._tree=e.context.parent;this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e;this.yieldBuf(e.index)}}yieldNode(e){if(!e)return false;this._tree=e;this.type=e.type;this.from=e.from;this.to=e.to;return true}yieldBuf(e,t){this.index=e;let{start:r,buffer:n}=this.buffer;this.type=t||n.set.types[n.buffer[e]];this.from=r+n.buffer[e+1];this.to=r+n.buffer[e+2];return true}yield(e){if(!e)return false;if(e instanceof TreeNode){this.buffer=null;return this.yieldNode(e)}this.buffer=e.context;return this.yieldBuf(e.index,e.type)}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:n}=this.buffer;let i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,r);if(i<0)return false;this.stack.push(this.index);return this.yieldBuf(i)}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?!(r&s.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&s.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&s.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();this.buffer=null;return this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let e=r<0?0:this.stack[r]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(e)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return false}else for(let e=0;e<this.index;e++)if(n.buffer.buffer[e+3]<this.index)return false;({index:t,parent:r}=n)}else({index:t,_parent:r}=this._tree);for(;r;({index:t,_parent:r}=r))if(t>-1)for(let n=t+e,i=e<0?-1:r._tree.children.length;n!=i;n+=e){let e=r._tree.children[n];if(this.mode&s.IncludeAnonymous||e instanceof TreeBuffer||!e.type.isAnonymous||hasChild(e))return false}return true}move(e,t){if(t&&this.enterChild(e,0,4))return true;for(;;){if(this.sibling(e))return true;if(this.atLastNode(e)||!this.parent())return false}}next(e=true){return this.move(1,e)}prev(e=true){return this.move(-1,e)}moveTo(e,t=0){while(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))if(!this.parent())break;while(this.enterChild(1,e,t));return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==n){if(n==this.index)return s;t=s;r=i+1;break e}n=this.stack[--i]}for(let e=r;e<this.stack.length;e++)t=new BufferNode(this.buffer,t,this.stack[e]);return this.bufferNode=new BufferNode(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let n=false;if(this.type.isAnonymous||e(this)!==false){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=true)}for(;;){n&&t&&t(this);n=this.type.isAnonymous;if(this.nextSibling())break;if(!r)return;this.parent();r--;n=true}}}matchContext(e){if(!this.buffer)return matchNodeContext(this.node,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let n=e.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)return matchNodeContext(this.node,e,n);let s=r[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[n]&&e[n]!=s.name)return false;n--}}return true}}function hasChild(e){return e.children.some((e=>e instanceof TreeBuffer||!e.type.isAnonymous||hasChild(e)))}function buildTree(t){var r;let{buffer:n,nodeSet:i,maxBufferLength:s=e,reused:o=[],minRepeatType:l=i.types.length}=t;let f=Array.isArray(n)?new FlatBufferCursor(n,n.length):n;let h=i.types;let u=0,a=0;function takeNode(e,t,r,n,d,p){let{id:c,start:g,end:m,size:x}=f;let y=a;while(x<0){f.next();if(x==-1){let t=o[c];r.push(t);n.push(g-e);return}if(x==-3){u=c;return}if(x==-4){a=c;return}throw new RangeError(`Unrecognized record size: ${x}`)}let b,N,w=h[c];let v=g-e;if(m-g<=s&&(N=findBufferSize(f.pos-t,d))){let t=new Uint16Array(N.size-N.skip);let r=f.pos-N.size,n=t.length;while(f.pos>r)n=copyToBuffer(N.start,t,n);b=new TreeBuffer(t,m-N.start,i);v=N.start-e}else{let e=f.pos-x;f.next();let t=[],r=[];let n=c>=l?c:-1;let i=0,o=m;while(f.pos>e)if(n>=0&&f.id==n&&f.size>=0){if(f.end<=o-s){makeRepeatLeaf(t,r,g,i,f.end,o,n,y);i=t.length;o=f.end}f.next()}else p>2500?takeFlatNode(g,e,t,r):takeNode(g,e,t,r,n,p+1);n>=0&&i>0&&i<t.length&&makeRepeatLeaf(t,r,g,i,g,o,n,y);t.reverse();r.reverse();if(n>-1&&i>0){let e=makeBalanced(w);b=balanceRange(w,t,r,0,t.length,0,m-g,e,e)}else b=makeTree(w,t,r,m-g,y-m)}r.push(b);n.push(v)}function takeFlatNode(e,t,r,n){let o=[];let l=0,h=-1;while(f.pos>t){let{id:e,start:t,end:r,size:n}=f;if(n>4)f.next();else{if(h>-1&&t<h)break;h<0&&(h=r-s);o.push(e,t,r);l++;f.next()}}if(l){let t=new Uint16Array(l*4);let s=o[o.length-2];for(let e=o.length-3,r=0;e>=0;e-=3){t[r++]=o[e];t[r++]=o[e+1]-s;t[r++]=o[e+2]-s;t[r++]=r}r.push(new TreeBuffer(t,o[2]-s,i));n.push(s-e)}}function makeBalanced(e){return(t,r,n)=>{let i,s,o=0,l=t.length-1;if(l>=0&&(i=t[l])instanceof Tree){if(!l&&i.type==e&&i.length==n)return i;(s=i.prop(NodeProp.lookAhead))&&(o=r[l]+i.length+s)}return makeTree(e,t,r,n,o)}}function makeRepeatLeaf(e,t,r,n,s,o,l,f){let h=[],u=[];while(e.length>n){h.push(e.pop());u.push(t.pop()+r-s)}e.push(makeTree(i.types[l],h,u,o-s,f-o));t.push(s-r)}function makeTree(e,t,r,n,i=0,s){if(u){let e=[NodeProp.contextHash,u];s=s?[e].concat(s):[e]}if(i>25){let e=[NodeProp.lookAhead,i];s=s?[e].concat(s):[e]}return new Tree(e,t,r,n,s)}function findBufferSize(e,t){let r=f.fork();let n=0,i=0,o=0,h=r.end-s;let u={size:0,start:0,skip:0};e:for(let s=r.pos-e;r.pos>s;){let e=r.size;if(r.id==t&&e>=0){u.size=n;u.start=i;u.skip=o;o+=4;n+=4;r.next();continue}let f=r.pos-e;if(e<0||f<s||r.start<h)break;let a=r.id>=l?4:0;let d=r.start;r.next();while(r.pos>f){if(r.size<0){if(r.size!=-3)break e;a+=4}else r.id>=l&&(a+=4);r.next()}i=d;n+=e;o+=a}if(t<0||n==e){u.size=n;u.start=i;u.skip=o}return u.size>4?u:void 0}function copyToBuffer(e,t,r){let{id:n,start:i,end:s,size:o}=f;f.next();if(o>=0&&n<l){let l=r;if(o>4){let n=f.pos-(o-4);while(f.pos>n)r=copyToBuffer(e,t,r)}t[--r]=l;t[--r]=s-e;t[--r]=i-e;t[--r]=n}else o==-3?u=n:o==-4&&(a=n);return r}let d=[],p=[];while(f.pos>0)takeNode(t.start||0,t.bufferStart||0,d,p,-1,0);let c=(r=t.length)!==null&&r!==void 0?r:d.length?p[0]+d[0].length:0;return new Tree(h[t.topID],d.reverse(),p.reverse(),c)}const o=new WeakMap;function nodeSize(e,t){if(!e.isAnonymous||t instanceof TreeBuffer||t.type!=e)return 1;let r=o.get(t);if(r==null){r=1;for(let n of t.children){if(n.type!=e||!(n instanceof Tree)){r=1;break}r+=nodeSize(e,n)}o.set(t,r)}return r}function balanceRange(e,t,r,n,i,s,o,l,f){let h=0;for(let r=n;r<i;r++)h+=nodeSize(e,t[r]);let u=Math.ceil(h*1.5/8);let a=[],d=[];function divide(t,r,n,i,o){for(let l=n;l<i;){let n=l,h=r[l],p=nodeSize(e,t[l]);l++;for(;l<i;l++){let r=nodeSize(e,t[l]);if(p+r>=u)break;p+=r}if(l==n+1){if(p>u){let e=t[n];divide(e.children,e.positions,0,e.children.length,r[n]+o);continue}a.push(t[n])}else{let i=r[l-1]+t[l-1].length-h;a.push(balanceRange(e,t,r,n,l,h,i,null,f))}d.push(h+o-s)}}divide(t,r,n,i,0);return(l||f)(a,d,o)}class NodeWeakMap{constructor(){this.map=new WeakMap}setBuffer(e,t,r){let n=this.map.get(e);n||this.map.set(e,n=new Map);n.set(t,r)}getBuffer(e,t){let r=this.map.get(e);return r&&r.get(t)}set(e,t){e instanceof BufferNode?this.setBuffer(e.context.buffer,e.index,t):e instanceof TreeNode&&this.map.set(e.tree,t)}get(e){return e instanceof BufferNode?this.getBuffer(e.context.buffer,e.index):e instanceof TreeNode?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class TreeFragment{constructor(e,t,r,n,i=false,s=false){this.from=e;this.to=t;this.tree=r;this.offset=n;this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],r=false){let n=[new TreeFragment(0,e.length,e,0,false,r)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,r=128){if(!t.length)return e;let n=[];let i=1,s=e.length?e[0]:null;for(let o=0,l=0,f=0;;o++){let h=o<t.length?t[o]:null;let u=h?h.fromA:1e9;if(u-l>=r)while(s&&s.from<u){let t=s;if(l>=t.from||u<=t.to||f){let e=Math.max(t.from,l)-f,r=Math.min(t.to,u)-f;t=e>=r?null:new TreeFragment(e,r,t.tree,t.offset+f,o>0,!!h)}t&&n.push(t);if(s.to>u)break;s=i<e.length?e[i++]:null}if(!h)break;l=h.toA;f=h.toA-h.toB}return n}}class Parser{startParse(e,t,r){typeof e=="string"&&(e=new StringInput(e));r=r?r.length?r.map((e=>new Range(e.from,e.to))):[new Range(0,0)]:[new Range(0,e.length)];return this.createParse(e,t||[],r)}parse(e,t,r){let n=this.startParse(e,t,r);for(;;){let e=n.advance();if(e)return e}}}class StringInput{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return false}read(e,t){return this.string.slice(e,t)}}function parseMixed(e){return(t,r,n,i)=>new MixedParse(t,e,r,n,i)}class InnerParse{constructor(e,t,r,n,i){this.parser=e;this.parse=t;this.overlay=r;this.target=n;this.from=i}}function checkRanges(e){if(!e.length||e.some((e=>e.from>=e.to)))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class ActiveOverlay{constructor(e,t,r,n,i,s,o){this.parser=e;this.predicate=t;this.mounts=r;this.index=n;this.start=i;this.target=s;this.prev=o;this.depth=0;this.ranges=[]}}const l=new NodeProp({perNode:true});class MixedParse{constructor(e,t,r,n,i){this.nest=t;this.input=r;this.fragments=n;this.ranges=i;this.inner=[];this.innerDone=0;this.baseTree=null;this.stoppedAt=null;this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;this.baseParse=null;this.baseTree=e;this.startInner();if(this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;this.stoppedAt!=null&&(e=new Tree(e.type,e.children,e.positions,e.length,e.propValues.concat([[l,this.stoppedAt]])));return e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[NodeProp.mounted.id]=new MountedTree(t,e.overlay,e.parser);e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){this.stoppedAt=e;if(this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new FragmentCursor(this.fragments);let t=null;let r=null;let n=new TreeCursor(new TreeNode(this.baseTree,this.ranges[0].from,0,null),s.IncludeAnonymous|s.IgnoreMounts);e:for(let i,s;;){let o,l=true;if(this.stoppedAt!=null&&n.from>=this.stoppedAt)l=false;else if(e.hasNode(n)){if(t){let e=t.mounts.find((e=>e.frag.from<=n.from&&e.frag.to>=n.to&&e.mount.overlay));if(e)for(let r of e.mount.overlay){let i=r.from+e.pos,s=r.to+e.pos;i>=n.from&&s<=n.to&&!t.ranges.some((e=>e.from<s&&e.to>i))&&t.ranges.push({from:i,to:s})}}l=false}else if(r&&(s=checkCover(r.ranges,n.from,n.to)))l=s!=2;else if(!n.type.isAnonymous&&(i=this.nest(n,this.input))&&(n.from<n.to||!i.overlay)){n.tree||materialize(n);let s=e.findMounts(n.from,i.parser);if(typeof i.overlay=="function")t=new ActiveOverlay(i.parser,i.overlay,s,this.inner.length,n.from,n.tree,t);else{let e=punchRanges(this.ranges,i.overlay||(n.from<n.to?[new Range(n.from,n.to)]:[]));e.length&&checkRanges(e);!e.length&&i.overlay||this.inner.push(new InnerParse(i.parser,e.length?i.parser.startParse(this.input,enterFragments(s,e),e):i.parser.startParse(""),i.overlay?i.overlay.map((e=>new Range(e.from-n.from,e.to-n.from))):null,n.tree,e.length?e[0].from:n.from));i.overlay?e.length&&(r={ranges:e,depth:0,prev:r}):l=false}}else if(t&&(o=t.predicate(n))){o===true&&(o=new Range(n.from,n.to));o.from<o.to&&t.ranges.push(o)}if(l&&n.firstChild()){t&&t.depth++;r&&r.depth++}else for(;;){if(n.nextSibling())break;if(!n.parent())break e;if(t&&! --t.depth){let e=punchRanges(this.ranges,t.ranges);if(e.length){checkRanges(e);this.inner.splice(t.index,0,new InnerParse(t.parser,t.parser.startParse(this.input,enterFragments(t.mounts,e),e),t.ranges.map((e=>new Range(e.from-t.start,e.to-t.start))),t.target,e[0].from))}t=t.prev}r&&! --r.depth&&(r=r.prev)}}}}function checkCover(e,t,r){for(let n of e){if(n.from>=r)break;if(n.to>t)return n.from<=t&&n.to>=r?2:1}return 0}function sliceBuf(e,t,r,n,i,s){if(t<r){let o=e.buffer[t+1];n.push(e.slice(t,r,o));i.push(o-s)}}function materialize(e){let{node:t}=e,r=[];let n=t.context.buffer;do{r.push(e.index);e.parent()}while(!e.tree);let i=e.tree,s=i.children.indexOf(n);let o=i.children[s],l=o.buffer,f=[s];function split(e,n,i,s,h,u){let a=r[u];let d=[],p=[];sliceBuf(o,e,a,d,p,s);let c=l[a+1],g=l[a+2];f.push(d.length);let m=u?split(a+4,l[a+3],o.set.types[l[a]],c,g-c,u-1):t.toTree();d.push(m);p.push(c-s);sliceBuf(o,l[a+3],n,d,p,s);return new Tree(i,d,p,h)}i.children[s]=split(0,l.length,NodeType.none,0,o.length,r.length-1);for(let t of f){let r=e.tree.children[t],n=e.tree.positions[t];e.yield(new TreeNode(r,n+e.from,t,e._tree))}}class StructureCursor{constructor(e,t){this.offset=t;this.done=false;this.cursor=e.cursor(s.IncludeAnonymous|s.IgnoreMounts)}moveTo(e){let{cursor:t}=this,r=e-this.offset;while(!this.done&&t.from<r)t.to>=e&&t.enter(r,1,s.IgnoreOverlays|s.ExcludeBuffers)||t.next(false)||(this.done=true)}hasNode(e){this.moveTo(e.from);if(!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return true;if(!(t.children.length&&t.positions[0]==0&&t.children[0]instanceof Tree))break;t=t.children[0]}return false}}class FragmentCursor{constructor(e){var t;this.fragments=e;this.curTo=0;this.fragI=0;if(e.length){let r=this.curFrag=e[0];this.curTo=(t=r.tree.prop(l))!==null&&t!==void 0?t:r.to;this.inner=new StructureCursor(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){while(this.curFrag&&e.from>=this.curTo)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;this.fragI++;if(this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(l))!==null&&e!==void 0?e:t.to;this.inner=new StructureCursor(t.tree,-t.offset)}}findMounts(e,t){var r;let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let i=(r=e.tree)===null||r===void 0?void 0:r.prop(NodeProp.mounted);if(i&&i.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let r=this.fragments[t];if(r.from>=e.to)break;r.tree==this.curFrag.tree&&n.push({frag:r,pos:e.from-r.offset,mount:i})}}}return n}}function punchRanges(e,t){let r=null,n=t;for(let i=1,s=0;i<e.length;i++){let o=e[i-1].to,l=e[i].from;for(;s<n.length;s++){let e=n[s];if(e.from>=l)break;if(!(e.to<=o)){r||(n=r=t.slice());if(e.from<o){r[s]=new Range(e.from,o);e.to>l&&r.splice(s+1,0,new Range(l,e.to))}else e.to>l?r[s--]=new Range(l,e.to):r.splice(s--,1)}}}return n}function findCoverChanges(e,t,r,n){let i=0,s=0,o=false,l=false,f=-1e9;let h=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from;let a=s==t.length?1e9:l?t[s].to:t[s].from;if(o!=l){let e=Math.max(f,r),t=Math.min(u,a,n);e<t&&h.push(new Range(e,t))}f=Math.min(u,a);if(f==1e9)break;if(u==f)if(o){o=false;i++}else o=true;if(a==f)if(l){l=false;s++}else l=true}return h}function enterFragments(e,t){let r=[];for(let{pos:n,mount:i,frag:s}of e){let e=n+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length;let l=Math.max(s.from,e),f=Math.min(s.to,o);if(i.overlay){let o=i.overlay.map((e=>new Range(e.from+n,e.to+n)));let h=findCoverChanges(t,o,l,f);for(let t=0,n=l;;t++){let o=t==h.length,l=o?f:h[t].from;l>n&&r.push(new TreeFragment(n,l,i.tree,-e,s.from>=n||s.openStart,s.to<=l||s.openEnd));if(o)break;n=h[t].to}}else r.push(new TreeFragment(l,f,i.tree,-e,s.from>=e||s.openStart,s.to<=o||s.openEnd))}return r}export{e as DefaultBufferLength,s as IterMode,MountedTree,NodeProp,NodeSet,NodeType,NodeWeakMap,Parser,Tree,TreeBuffer,TreeCursor,TreeFragment,parseMixed};
|
2
|
+
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{ExternalTokenizer as O,LocalTokenGroup as e,LRParser as Q}from"@lezer/lr";import{tags as a,styleTags as o}from"@lezer/highlight";const S=99,t=1,l=100,$=101,P=2;const r=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288];const n=58,i=40,X=95,s=91,c=45,y=46,d=35,p=37,m=38,g=92,z=10;function isAlpha(O){return O>=65&&O<=90||O>=97&&O<=122||O>=161}function isDigit(O){return O>=48&&O<=57}const W=new O(((O,e)=>{for(let Q=false,a=0,o=0;;o++){let{next:S}=O;if(isAlpha(S)||S==c||S==X||Q&&isDigit(S)){!Q&&(S!=c||o>0)&&(Q=true);a===o&&S==c&&a++;O.advance()}else{if(S!=g||O.peek(1)==z){Q&&O.acceptToken(S==i?l:a==2&&e.canShift(P)?P:$);break}O.advance();O.next>-1&&O.advance();Q=true}}}));const R=new O((O=>{if(r.includes(O.peek(-1))){let{next:e}=O;(isAlpha(e)||e==X||e==d||e==y||e==s||e==n&&isAlpha(O.peek(1))||e==c||e==m)&&O.acceptToken(S)}}));const f=new O((O=>{if(!r.includes(O.peek(-1))){let{next:e}=O;if(e==p){O.advance();O.acceptToken(t)}if(isAlpha(e)){do{O.advance()}while(isAlpha(O.next)||isDigit(O.next));O.acceptToken(t)}}}));const T=o({"AtKeyword import charset namespace keyframes media supports":a.definitionKeyword,"from to selector":a.keyword,NamespaceName:a.namespace,KeyframeName:a.labelName,KeyframeRangeName:a.operatorKeyword,TagName:a.tagName,ClassName:a.className,PseudoClassName:a.constant(a.className),IdName:a.labelName,"FeatureName PropertyName":a.propertyName,AttributeName:a.attributeName,NumberLiteral:a.number,KeywordQuery:a.keyword,UnaryQueryOp:a.operatorKeyword,"CallTag ValueName":a.atom,VariableName:a.variableName,Callee:a.operatorKeyword,Unit:a.unit,"UniversalSelector NestingSelector":a.definitionOperator,MatchOp:a.compareOperator,"ChildOp SiblingOp, LogicOp":a.logicOperator,BinOp:a.arithmeticOperator,Important:a.modifier,Comment:a.blockComment,ColorLiteral:a.color,"ParenthesizedContent StringLiteral":a.string,":":a.punctuation,"PseudoOp #":a.derefOperator,"; ,":a.separator,"( )":a.paren,"[ ]":a.squareBracket,"{ }":a.brace});const h={__proto__:null,lang:32,"nth-child":32,"nth-last-child":32,"nth-of-type":32,"nth-last-of-type":32,dir:32,"host-context":32,url:60,"url-prefix":60,domain:60,regexp:60,selector:138};const U={__proto__:null,"@import":118,"@media":142,"@charset":146,"@namespace":150,"@keyframes":156,"@supports":168};const u={__proto__:null,not:132,only:132};const Y=Q.deserialize({version:14,states:":^QYQ[OOO#_Q[OOP#fOWOOOOQP'#Cd'#CdOOQP'#Cc'#CcO#kQ[O'#CfO$_QXO'#CaO$fQ[O'#ChO$qQ[O'#DTO$vQ[O'#DWOOQP'#Em'#EmO${QdO'#DgO%jQ[O'#DtO${QdO'#DvO%{Q[O'#DxO&WQ[O'#D{O&`Q[O'#ERO&nQ[O'#ETOOQS'#El'#ElOOQS'#EW'#EWQYQ[OOO&uQXO'#CdO'jQWO'#DcO'oQWO'#EsO'zQ[O'#EsQOQWOOP(UO#tO'#C_POOO)C@[)C@[OOQP'#Cg'#CgOOQP,59Q,59QO#kQ[O,59QO(aQ[O'#E[O({QWO,58{O)TQ[O,59SO$qQ[O,59oO$vQ[O,59rO(aQ[O,59uO(aQ[O,59wO(aQ[O,59xO)`Q[O'#DbOOQS,58{,58{OOQP'#Ck'#CkOOQO'#DR'#DROOQP,59S,59SO)gQWO,59SO)lQWO,59SOOQP'#DV'#DVOOQP,59o,59oOOQO'#DX'#DXO)qQ`O,59rOOQS'#Cp'#CpO${QdO'#CqO)yQvO'#CsO+ZQtO,5:ROOQO'#Cx'#CxO)lQWO'#CwO+oQWO'#CyO+tQ[O'#DOOOQS'#Ep'#EpOOQO'#Dj'#DjO+|Q[O'#DqO,[QWO'#EtO&`Q[O'#DoO,jQWO'#DrOOQO'#Eu'#EuO)OQWO,5:`O,oQpO,5:bOOQS'#Dz'#DzO,wQWO,5:dO,|Q[O,5:dOOQO'#D}'#D}O-UQWO,5:gO-ZQWO,5:mO-cQWO,5:oOOQS-E8U-E8UO${QdO,59}O-kQ[O'#E^O-xQWO,5;_O-xQWO,5;_POOO'#EV'#EVP.TO#tO,58yPOOO,58y,58yOOQP1G.l1G.lO.zQXO,5:vOOQO-E8Y-E8YOOQS1G.g1G.gOOQP1G.n1G.nO)gQWO1G.nO)lQWO1G.nOOQP1G/Z1G/ZO/XQ`O1G/^O/rQXO1G/aO0YQXO1G/cO0pQXO1G/dO1WQWO,59|O1]Q[O'#DSO1dQdO'#CoOOQP1G/^1G/^O${QdO1G/^O1kQpO,59]OOQS,59_,59_O${QdO,59aO1sQWO1G/mOOQS,59c,59cO1xQ!bO,59eOOQS'#DP'#DPOOQS'#EY'#EYO2QQ[O,59jOOQS,59j,59jO2YQWO'#DjO2eQWO,5:VO2jQWO,5:]O&`Q[O,5:XO&`Q[O'#E_O2rQWO,5;`O2}QWO,5:ZO(aQ[O,5:^OOQS1G/z1G/zOOQS1G/|1G/|OOQS1G0O1G0OO3`QWO1G0OO3eQdO'#EOOOQS1G0R1G0ROOQS1G0X1G0XOOQS1G0Z1G0ZO3pQtO1G/iOOQO,5:x,5:xO4WQ[O,5:xOOQO-E8[-E8[O4eQWO1G0yPOOO-E8T-E8TPOOO1G.e1G.eOOQP7+$Y7+$YOOQP7+$x7+$xO${QdO7+$xOOQS1G/h1G/hO4pQXO'#ErO4wQWO,59nO4|QtO'#EXO5tQdO'#EoO6OQWO,59ZO6TQpO7+$xOOQS1G.w1G.wOOQS1G.{1G.{OOQS7+%X7+%XO6]QWO1G/POOQS-E8W-E8WOOQS1G/U1G/UO${QdO1G/qOOQO1G/w1G/wOOQO1G/s1G/sO6bQWO,5:yOOQO-E8]-E8]O6pQXO1G/xOOQS7+%j7+%jO6wQYO'#CsOOQO'#EQ'#EQO7SQ`O'#EPOOQO'#EP'#EPO7_QWO'#E`O7gQdO,5:jOOQS,5:j,5:jO7rQtO'#E]O${QdO'#E]O8sQdO7+%TOOQO7+%T7+%TOOQO1G0d1G0dO9WQpO<<HdO9`QWO,5;^OOQP1G/Y1G/YOOQS-E8V-E8VO${QdO'#EZO9hQWO,5;ZOOQT1G.u1G.uOOQP<<Hd<<HdOOQS7+$k7+$kO9pQdO7+%]OOQO7+%d7+%dOOQO,5:k,5:kO3hQdO'#EaO7_QWO,5:zOOQS,5:z,5:zOOQS-E8^-E8^OOQS1G0U1G0UO9wQtO,5:wOOQS-E8Z-E8ZOOQO<<Ho<<HoOOQPAN>OAN>OO:xQdO,5:uOOQO-E8X-E8XOOQO<<Hw<<HwOOQO,5:{,5:{OOQO-E8_-E8_OOQS1G0f1G0f",stateData:";[~O#ZOS#[QQ~OUYOXYO]VO^VOqXOxWO![aO!]ZO!i[O!k]O!m^O!p_O!v`O#XRO#bTO~OQfOUYOXYO]VO^VOqXOxWO![aO!]ZO!i[O!k]O!m^O!p_O!v`O#XeO#bTO~O#U#gP~P!ZO#[jO~O#XlO~O]qO^qOqsOtoOxrO!OtO!RvO#VuO#bnO~O!TwO~P#pO`}O#WzO#XyO~O#X!OO~O#X!QO~OQ![Ob!TOf![Oh![On!YOq!ZO#W!WO#X!SO#e!UO~Ob!^O!d!`O!g!aO#X!]O!T#hP~Oh!fOn!YO#X!eO~Oh!hO#X!hO~Ob!^O!d!`O!g!aO#X!]O~O!Y#hP~P%jO]WX]!WX^WXqWXtWXxWX!OWX!RWX!TWX#VWX#bWX~O]!mO~O!Y!nO#U#gX!S#gX~O#U#gX!S#gX~P!ZO#]!qO#^!qO#_!sO~OUYOXYO]VO^VOqXOxWO#XRO#bTO~OtoO!TwO~O`!zO#WzO#XyO~O!S#gP~P!ZOb#RO~Ob#SO~Op#TO|#UO~OP#WObgXjgX!YgX!dgX!ggX#XgXagXQgXfgXhgXngXqgXtgX!XgX#UgX#WgX#egXpgX!SgX~Ob!^Oj#XO!d!`O!g!aO#X!]O!Y#hP~Ob#[O~Op#`O#X#]O~Ob!^O!d!`O!g!aO#X#aO~Ot#eO!b#dO!T#hX!Y#hX~Ob#hO~Oj#XO!Y#jO~O!Y#kO~Oh#lOn!YO~O!T#mO~O!TwO!b#dO~O!TwO!Y#pO~O!Y#QX#U#QX!S#QX~P!ZO!Y!nO#U#ga!S#ga~O#]!qO#^!qO#_#wO~O]qO^qOqsOxrO!OtO!RvO#VuO#bnO~Ot#Oa!T#Oaa#Oa~P.`Op#yO|#zO~O]qO^qOqsOxrO#bnO~Ot}i!O}i!R}i!T}i#V}ia}i~P/aOt!Pi!O!Pi!R!Pi!T!Pi#V!Pia!Pi~P/aOt!Qi!O!Qi!R!Qi!T!Qi#V!Qia!Qi~P/aO!S#{O~Oa#fP~P(aOa#cP~P${Oa$SOj#XO~O!Y$UO~Oh$VOo$VO~Op$XO#X#]O~O]!`Xa!^X!b!^X~O]$YO~Oa$ZO!b#dO~Ot#eO!T#ha!Y#ha~O!b#dOt!ca!T!ca!Y!caa!ca~O!Y$`O~O!S$gO#X$bO#e$aO~Oj#XOt$iO!X$kO!Y!Vi#U!Vi!S!Vi~P${O!Y#Qa#U#Qa!S#Qa~P!ZO!Y!nO#U#gi!S#gi~Oa#fX~P#pOa$oO~Oj#XOQ!{Xa!{Xb!{Xf!{Xh!{Xn!{Xq!{Xt!{X#W!{X#X!{X#e!{X~Ot$qOa#cX~P${Oa$sO~Oj#XOp$tO~Oa$uO~O!b#dOt#Ra!T#Ra!Y#Ra~Oa$wO~P.`OP#WOtgX!TgX~O#e$aOt!sX!T!sX~Ot$yO!TwO~O!S$}O#X$bO#e$aO~Oj#XOQ#PXb#PXf#PXh#PXn#PXq#PXt#PX!X#PX!Y#PX#U#PX#W#PX#X#PX#e#PX!S#PX~Ot$iO!X%QO!Y!Vq#U!Vq!S!Vq~P${Oj#XOp%RO~OtoOa#fa~Ot$qOa#ca~Oa%UO~P${Oj#XOQ#Pab#Paf#Pah#Pan#Paq#Pat#Pa!X#Pa!Y#Pa#U#Pa#W#Pa#X#Pa#e#Pa!S#Pa~Oa!}at!}a~P${O#Zo#[#ej!R#e~",goto:"-g#jPPP#kP#nP#w$WP#w$g#wPP$mPPP$s$|$|P%`P$|P$|%z&^PPPP$|&vP&z'Q#wP'W#w'^P#wP#w#wPPP'd'y(WPP#nPP(_(_(i(_P(_P(_(_P#nP#nP#nP(l#nP(o(r(u(|#nP#nP)R)X)h)v)|*S*^*d*n*t*zPPPPPPPPPP+Q+ZP+v+yP,o,r,x-RRkQ_bOPdhw!n#skYOPdhotuvw!n#R#h#skSOPdhotuvw!n#R#h#sQmTR!tnQ{VR!xqQ!x}Q#Z!XR#x!zq![Z]!T!m#S#U#X#q#z$P$Y$i$j$q$v%Sp![Z]!T!m#S#U#X#q#z$P$Y$i$j$q$v%SU$d#m$f$yR$x$cq!XZ]!T!m#S#U#X#q#z$P$Y$i$j$q$v%Sp![Z]!T!m#S#U#X#q#z$P$Y$i$j$q$v%SQ!f^R#l!gT#^!Z#_Q|VR!yqQ!x|R#x!yQ!PWR!{rQ!RXR!|sQxUQ!wpQ#i!cQ#o!jQ#p!kQ${$eR%X$zSgPwQ!phQ#r!nR$l#sZfPhw!n#sa!b[`a!V!^!`#d#eR#b!^R!g^R!i_R#n!iS$e#m$fR%V$yV$c#m$f$yQ!rjR#v!rQdOShPwU!ldh#sR#s!nQ$P#SU$p$P$v%SQ$v$YR%S$qQ#_!ZR$W#_Q$r$PR%T$rQpUS!vp$nR$n#|Q$j#qR%P$jQ!ogS#t!o#uR#u!pQ#f!_R$^#fQ$f#mR$|$fQ$z$eR%W$z_cOPdhw!n#s^UOPdhw!n#sQ!uoQ!}tQ#OuQ#PvQ#|#RR$_#hR$Q#SQ!VZQ!d]Q#V!TQ#q!m[$O#S$P$Y$q$v%SQ$R#UQ$T#XS$h#q$jQ$m#zR%O$iR#}#RQiPR#QwQ!c[Q!kaR#Y!VU!_[a!VQ!j`Q#c!^Q#g!`Q$[#dR$]#e",nodeNames:"⚠ Unit VariableName Comment StyleSheet RuleSet UniversalSelector TagSelector TagName NestingSelector ClassSelector ClassName PseudoClassSelector : :: PseudoClassName PseudoClassName ) ( ArgList ValueName ParenthesizedValue ColorLiteral NumberLiteral StringLiteral BinaryExpression BinOp CallExpression Callee CallLiteral CallTag ParenthesizedContent ] [ LineNames LineName , PseudoClassName ArgList IdSelector # IdName AttributeSelector AttributeName MatchOp ChildSelector ChildOp DescendantSelector SiblingSelector SiblingOp } { Block Declaration PropertyName Important ; ImportStatement AtKeyword import KeywordQuery FeatureQuery FeatureName BinaryQuery LogicOp UnaryQuery UnaryQueryOp ParenthesizedQuery SelectorQuery selector MediaStatement media CharsetStatement charset NamespaceStatement namespace NamespaceName KeyframesStatement keyframes KeyframeName KeyframeList KeyframeSelector KeyframeRangeName SupportsStatement supports AtRule Styles",maxTerm:117,nodeProps:[["isolate",-2,3,24,""],["openedBy",17,"(",32,"[",50,"{"],["closedBy",18,")",33,"]",51,"}"]],propSources:[T],skippedNodes:[0,3,87],repeatNodeCount:11,tokenData:"J^~R!^OX$}X^%u^p$}pq%uqr)Xrs.Rst/utu6duv$}vw7^wx7oxy9^yz9oz{9t{|:_|}?Q}!O?c!O!P@Q!P!Q@i!Q![Ab![!]B]!]!^CX!^!_$}!_!`Cj!`!aC{!a!b$}!b!cDw!c!}$}!}#OFa#O#P$}#P#QFr#Q#R6d#R#T$}#T#UGT#U#c$}#c#dHf#d#o$}#o#pH{#p#q6d#q#rI^#r#sIo#s#y$}#y#z%u#z$f$}$f$g%u$g#BY$}#BY#BZ%u#BZ$IS$}$IS$I_%u$I_$I|$}$I|$JO%u$JO$JT$}$JT$JU%u$JU$KV$}$KV$KW%u$KW&FU$}&FU&FV%u&FV;'S$};'S;=`JW<%lO$}`%QSOy%^z;'S%^;'S;=`%o<%lO%^`%cSo`Oy%^z;'S%^;'S;=`%o<%lO%^`%rP;=`<%l%^~%zh#Z~OX%^X^'f^p%^pq'fqy%^z#y%^#y#z'f#z$f%^$f$g'f$g#BY%^#BY#BZ'f#BZ$IS%^$IS$I_'f$I_$I|%^$I|$JO'f$JO$JT%^$JT$JU'f$JU$KV%^$KV$KW'f$KW&FU%^&FU&FV'f&FV;'S%^;'S;=`%o<%lO%^~'mh#Z~o`OX%^X^'f^p%^pq'fqy%^z#y%^#y#z'f#z$f%^$f$g'f$g#BY%^#BY#BZ'f#BZ$IS%^$IS$I_'f$I_$I|%^$I|$JO'f$JO$JT%^$JT$JU'f$JU$KV%^$KV$KW'f$KW&FU%^&FU&FV'f&FV;'S%^;'S;=`%o<%lO%^l)[UOy%^z#]%^#]#^)n#^;'S%^;'S;=`%o<%lO%^l)sUo`Oy%^z#a%^#a#b*V#b;'S%^;'S;=`%o<%lO%^l*[Uo`Oy%^z#d%^#d#e*n#e;'S%^;'S;=`%o<%lO%^l*sUo`Oy%^z#c%^#c#d+V#d;'S%^;'S;=`%o<%lO%^l+[Uo`Oy%^z#f%^#f#g+n#g;'S%^;'S;=`%o<%lO%^l+sUo`Oy%^z#h%^#h#i,V#i;'S%^;'S;=`%o<%lO%^l,[Uo`Oy%^z#T%^#T#U,n#U;'S%^;'S;=`%o<%lO%^l,sUo`Oy%^z#b%^#b#c-V#c;'S%^;'S;=`%o<%lO%^l-[Uo`Oy%^z#h%^#h#i-n#i;'S%^;'S;=`%o<%lO%^l-uS!X[o`Oy%^z;'S%^;'S;=`%o<%lO%^~.UWOY.RZr.Rrs.ns#O.R#O#P.s#P;'S.R;'S;=`/o<%lO.R~.sOh~~.vRO;'S.R;'S;=`/P;=`O.R~/SXOY.RZr.Rrs.ns#O.R#O#P.s#P;'S.R;'S;=`/o;=`<%l.R<%lO.R~/rP;=`<%l.Rn/zYxQOy%^z!Q%^!Q![0j![!c%^!c!i0j!i#T%^#T#Z0j#Z;'S%^;'S;=`%o<%lO%^l0oYo`Oy%^z!Q%^!Q![1_![!c%^!c!i1_!i#T%^#T#Z1_#Z;'S%^;'S;=`%o<%lO%^l1dYo`Oy%^z!Q%^!Q![2S![!c%^!c!i2S!i#T%^#T#Z2S#Z;'S%^;'S;=`%o<%lO%^l2ZYf[o`Oy%^z!Q%^!Q![2y![!c%^!c!i2y!i#T%^#T#Z2y#Z;'S%^;'S;=`%o<%lO%^l3QYf[o`Oy%^z!Q%^!Q![3p![!c%^!c!i3p!i#T%^#T#Z3p#Z;'S%^;'S;=`%o<%lO%^l3uYo`Oy%^z!Q%^!Q![4e![!c%^!c!i4e!i#T%^#T#Z4e#Z;'S%^;'S;=`%o<%lO%^l4lYf[o`Oy%^z!Q%^!Q![5[![!c%^!c!i5[!i#T%^#T#Z5[#Z;'S%^;'S;=`%o<%lO%^l5aYo`Oy%^z!Q%^!Q![6P![!c%^!c!i6P!i#T%^#T#Z6P#Z;'S%^;'S;=`%o<%lO%^l6WSf[o`Oy%^z;'S%^;'S;=`%o<%lO%^d6gUOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^d7QS|So`Oy%^z;'S%^;'S;=`%o<%lO%^b7cSXQOy%^z;'S%^;'S;=`%o<%lO%^~7rWOY7oZw7owx.nx#O7o#O#P8[#P;'S7o;'S;=`9W<%lO7o~8_RO;'S7o;'S;=`8h;=`O7o~8kXOY7oZw7owx.nx#O7o#O#P8[#P;'S7o;'S;=`9W;=`<%l7o<%lO7o~9ZP;=`<%l7on9cSb^Oy%^z;'S%^;'S;=`%o<%lO%^~9tOa~n9{UUQjWOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^n:fWjW!RQOy%^z!O%^!O!P;O!P!Q%^!Q![>T![;'S%^;'S;=`%o<%lO%^l;TUo`Oy%^z!Q%^!Q![;g![;'S%^;'S;=`%o<%lO%^l;nYo`#e[Oy%^z!Q%^!Q![;g![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^l<cYo`Oy%^z{%^{|=R|}%^}!O=R!O!Q%^!Q![=j![;'S%^;'S;=`%o<%lO%^l=WUo`Oy%^z!Q%^!Q![=j![;'S%^;'S;=`%o<%lO%^l=qUo`#e[Oy%^z!Q%^!Q![=j![;'S%^;'S;=`%o<%lO%^l>[[o`#e[Oy%^z!O%^!O!P;g!P!Q%^!Q![>T![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^n?VSt^Oy%^z;'S%^;'S;=`%o<%lO%^l?hWjWOy%^z!O%^!O!P;O!P!Q%^!Q![>T![;'S%^;'S;=`%o<%lO%^n@VU#bQOy%^z!Q%^!Q![;g![;'S%^;'S;=`%o<%lO%^~@nTjWOy%^z{@}{;'S%^;'S;=`%o<%lO%^~AUSo`#[~Oy%^z;'S%^;'S;=`%o<%lO%^lAg[#e[Oy%^z!O%^!O!P;g!P!Q%^!Q![>T![!g%^!g!h<^!h#X%^#X#Y<^#Y;'S%^;'S;=`%o<%lO%^bBbU]QOy%^z![%^![!]Bt!];'S%^;'S;=`%o<%lO%^bB{S^Qo`Oy%^z;'S%^;'S;=`%o<%lO%^nC^S!Y^Oy%^z;'S%^;'S;=`%o<%lO%^dCoS|SOy%^z;'S%^;'S;=`%o<%lO%^bDQU!OQOy%^z!`%^!`!aDd!a;'S%^;'S;=`%o<%lO%^bDkS!OQo`Oy%^z;'S%^;'S;=`%o<%lO%^bDzWOy%^z!c%^!c!}Ed!}#T%^#T#oEd#o;'S%^;'S;=`%o<%lO%^bEk[![Qo`Oy%^z}%^}!OEd!O!Q%^!Q![Ed![!c%^!c!}Ed!}#T%^#T#oEd#o;'S%^;'S;=`%o<%lO%^nFfSq^Oy%^z;'S%^;'S;=`%o<%lO%^nFwSp^Oy%^z;'S%^;'S;=`%o<%lO%^bGWUOy%^z#b%^#b#cGj#c;'S%^;'S;=`%o<%lO%^bGoUo`Oy%^z#W%^#W#XHR#X;'S%^;'S;=`%o<%lO%^bHYS!bQo`Oy%^z;'S%^;'S;=`%o<%lO%^bHiUOy%^z#f%^#f#gHR#g;'S%^;'S;=`%o<%lO%^fIQS!TUOy%^z;'S%^;'S;=`%o<%lO%^nIcS!S^Oy%^z;'S%^;'S;=`%o<%lO%^fItU!RQOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^`JZP;=`<%l$}",tokenizers:[R,f,W,1,2,3,4,new e("m~RRYZ[z{a~~g~aO#^~~dP!P!Qg~lO#_~~",28,105)],topRules:{StyleSheet:[0,4],Styles:[1,86]},specialized:[{term:100,get:O=>h[O]||-1},{term:58,get:O=>U[O]||-1},{term:101,get:O=>u[O]||-1}],tokenPrec:1200});export{Y as parser};
|
2
|
+
|