···11+"use strict";function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get;}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver);}return desc.value;};}return _get.apply(this,arguments);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter);}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e3){throw _e3;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e4){didErr=true;err=_e4;},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]();}finally{if(didErr)throw err;}}};}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}(function(f){if((typeof exports==="undefined"?"undefined":_typeof(exports))==="object"&&typeof module!=="undefined"){module.exports=f();}else if(typeof define==="function"&&define.amd){define([],f);}else{var g;if(typeof window!=="undefined"){g=window;}else if(typeof global!=="undefined"){g=global;}else if(typeof self!=="undefined"){g=self;}else{g=this;}g.CodeMirror=f();}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a;}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r);},p,p.exports,r,e,n,t);}return n[i].exports;}for(var u="function"==typeof require&&require,i=0;i<t.length;i++){o(t[i]);}return o;}return r;}()({1:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var state=require('@codemirror/state');var view=require('@codemirror/view');var tooltip=require('@codemirror/tooltip');var language=require('@codemirror/language');var text=require('@codemirror/text');/**
22+An instance of this is passed to completion source functions.
33+*/var CompletionContext=/*#__PURE__*/function(){/**
44+ Create a new completion context. (Mostly useful for testing
55+ completion sources—in the editor, the extension will create
66+ these for you.)
77+ */function CompletionContext(/**
88+ The editor state that the completion happens in.
99+ */state,/**
1010+ The position at which the completion is happening.
1111+ */pos,/**
1212+ Indicates whether completion was activated explicitly, or
1313+ implicitly by typing. The usual way to respond to this is to
1414+ only return completions when either there is part of a
1515+ completable entity before the cursor, or `explicit` is true.
1616+ */explicit){_classCallCheck(this,CompletionContext);this.state=state;this.pos=pos;this.explicit=explicit;/**
1717+ @internal
1818+ */this.abortListeners=[];}/**
1919+ Get the extent, content, and (if there is a token) type of the
2020+ token before `this.pos`.
2121+ */_createClass(CompletionContext,[{key:"tokenBefore",value:function tokenBefore(types){var token=language.syntaxTree(this.state).resolveInner(this.pos,-1);while(token&&types.indexOf(token.name)<0){token=token.parent;}return token?{from:token.from,to:this.pos,text:this.state.sliceDoc(token.from,this.pos),type:token.type}:null;}/**
2222+ Get the match of the given expression directly before the
2323+ cursor.
2424+ */},{key:"matchBefore",value:function matchBefore(expr){var line=this.state.doc.lineAt(this.pos);var start=Math.max(line.from,this.pos-250);var str=line.text.slice(start-line.from,this.pos-line.from);var found=str.search(ensureAnchor(expr,false));return found<0?null:{from:start+found,to:this.pos,text:str.slice(found)};}/**
2525+ Yields true when the query has been aborted. Can be useful in
2626+ asynchronous queries to avoid doing work that will be ignored.
2727+ */},{key:"aborted",get:function get(){return this.abortListeners==null;}/**
2828+ Allows you to register abort handlers, which will be called when
2929+ the query is
3030+ [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
3131+ */},{key:"addEventListener",value:function addEventListener(type,listener){if(type=="abort"&&this.abortListeners)this.abortListeners.push(listener);}}]);return CompletionContext;}();function toSet(chars){var flat=Object.keys(chars).join("");var words=/\w/.test(flat);if(words)flat=flat.replace(/\w/g,"");return"[".concat(words?"\\w":"").concat(flat.replace(/[^\w\s]/g,"\\$&"),"]");}function prefixMatch(options){var first=Object.create(null),rest=Object.create(null);var _iterator=_createForOfIteratorHelper(options),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var label=_step.value.label;first[label[0]]=true;for(var i=1;i<label.length;i++){rest[label[i]]=true;}}}catch(err){_iterator.e(err);}finally{_iterator.f();}var source=toSet(first)+toSet(rest)+"*$";return[new RegExp("^"+source),new RegExp(source)];}/**
3232+Given a a fixed array of options, return an autocompleter that
3333+completes them.
3434+*/function completeFromList(list){var options=list.map(function(o){return typeof o=="string"?{label:o}:o;});var _ref=options.every(function(o){return /^\w+$/.test(o.label);})?[/\w*$/,/\w+$/]:prefixMatch(options),_ref2=_slicedToArray(_ref,2),span=_ref2[0],match=_ref2[1];return function(context){var token=context.matchBefore(match);return token||context.explicit?{from:token?token.from:context.pos,options:options,span:span}:null;};}/**
3535+Wrap the given completion source so that it will only fire when the
3636+cursor is in a syntax node with one of the given names.
3737+*/function ifIn(nodes,source){return function(context){for(var pos=language.syntaxTree(context.state).resolveInner(context.pos,-1);pos;pos=pos.parent){if(nodes.indexOf(pos.name)>-1)return source(context);}return null;};}/**
3838+Wrap the given completion source so that it will not fire when the
3939+cursor is in a syntax node with one of the given names.
4040+*/function ifNotIn(nodes,source){return function(context){for(var pos=language.syntaxTree(context.state).resolveInner(context.pos,-1);pos;pos=pos.parent){if(nodes.indexOf(pos.name)>-1)return null;}return source(context);};}var Option=/*#__PURE__*/_createClass(function Option(completion,source,match){_classCallCheck(this,Option);this.completion=completion;this.source=source;this.match=match;});function cur(state){return state.selection.main.head;}// Make sure the given regexp has a $ at its end and, if `start` is
4141+// true, a ^ at its start.
4242+function ensureAnchor(expr,start){var _a;var source=expr.source;var addStart=start&&source[0]!="^",addEnd=source[source.length-1]!="$";if(!addStart&&!addEnd)return expr;return new RegExp("".concat(addStart?"^":"","(?:").concat(source,")").concat(addEnd?"$":""),(_a=expr.flags)!==null&&_a!==void 0?_a:expr.ignoreCase?"i":"");}/**
4343+This annotation is added to transactions that are produced by
4444+picking a completion.
4545+*/var pickedCompletion=state.Annotation.define();function applyCompletion(view,option){var apply=option.completion.apply||option.completion.label;var result=option.source;if(typeof apply=="string"){view.dispatch({changes:{from:result.from,to:result.to,insert:apply},selection:{anchor:result.from+apply.length},userEvent:"input.complete",annotations:pickedCompletion.of(option.completion)});}else{apply(view,option.completion,result.from,result.to);}}var SourceCache=new WeakMap();function asSource(source){if(!Array.isArray(source))return source;var known=SourceCache.get(source);if(!known)SourceCache.set(source,known=completeFromList(source));return known;}// A pattern matcher for fuzzy completion matching. Create an instance
4646+// once for a pattern, and then use that to match any number of
4747+// completions.
4848+var FuzzyMatcher=/*#__PURE__*/function(){function FuzzyMatcher(pattern){_classCallCheck(this,FuzzyMatcher);this.pattern=pattern;this.chars=[];this.folded=[];// Buffers reused by calls to `match` to track matched character
4949+// positions.
5050+this.any=[];this.precise=[];this.byWord=[];for(var p=0;p<pattern.length;){var _char=text.codePointAt(pattern,p),size=text.codePointSize(_char);this.chars.push(_char);var part=pattern.slice(p,p+size),upper=part.toUpperCase();this.folded.push(text.codePointAt(upper==part?part.toLowerCase():upper,0));p+=size;}this.astral=pattern.length!=this.chars.length;}// Matches a given word (completion) against the pattern (input).
5151+// Will return null for no match, and otherwise an array that starts
5252+// with the match score, followed by any number of `from, to` pairs
5353+// indicating the matched parts of `word`.
5454+//
5555+// The score is a number that is more negative the worse the match
5656+// is. See `Penalty` above.
5757+_createClass(FuzzyMatcher,[{key:"match",value:function match(word){if(this.pattern.length==0)return[0];if(word.length<this.pattern.length)return null;var chars=this.chars,folded=this.folded,any=this.any,precise=this.precise,byWord=this.byWord;// For single-character queries, only match when they occur right
5858+// at the start
5959+if(chars.length==1){var first=text.codePointAt(word,0);return first==chars[0]?[0,0,text.codePointSize(first)]:first==folded[0]?[-200/* CaseFold */,0,text.codePointSize(first)]:null;}var direct=word.indexOf(this.pattern);if(direct==0)return[0,0,this.pattern.length];var len=chars.length,anyTo=0;if(direct<0){for(var i=0,e=Math.min(word.length,200);i<e&&anyTo<len;){var next=text.codePointAt(word,i);if(next==chars[anyTo]||next==folded[anyTo])any[anyTo++]=i;i+=text.codePointSize(next);}// No match, exit immediately
6060+if(anyTo<len)return null;}// This tracks the extent of the precise (non-folded, not
6161+// necessarily adjacent) match
6262+var preciseTo=0;// Tracks whether there is a match that hits only characters that
6363+// appear to be starting words. `byWordFolded` is set to true when
6464+// a case folded character is encountered in such a match
6565+var byWordTo=0,byWordFolded=false;// If we've found a partial adjacent match, these track its state
6666+var adjacentTo=0,adjacentStart=-1,adjacentEnd=-1;var hasLower=/[a-z]/.test(word),wordAdjacent=true;// Go over the option's text, scanning for the various kinds of matches
6767+for(var _i2=0,_e2=Math.min(word.length,200),prevType=0/* NonWord */;_i2<_e2&&byWordTo<len;){var _next=text.codePointAt(word,_i2);if(direct<0){if(preciseTo<len&&_next==chars[preciseTo])precise[preciseTo++]=_i2;if(adjacentTo<len){if(_next==chars[adjacentTo]||_next==folded[adjacentTo]){if(adjacentTo==0)adjacentStart=_i2;adjacentEnd=_i2+1;adjacentTo++;}else{adjacentTo=0;}}}var ch=void 0,type=_next<0xff?_next>=48&&_next<=57||_next>=97&&_next<=122?2/* Lower */:_next>=65&&_next<=90?1/* Upper */:0/* NonWord */:(ch=text.fromCodePoint(_next))!=ch.toLowerCase()?1/* Upper */:ch!=ch.toUpperCase()?2/* Lower */:0/* NonWord */;if(!_i2||type==1/* Upper */&&hasLower||prevType==0/* NonWord */&&type!=0/* NonWord */){if(chars[byWordTo]==_next||folded[byWordTo]==_next&&(byWordFolded=true))byWord[byWordTo++]=_i2;else if(byWord.length)wordAdjacent=false;}prevType=type;_i2+=text.codePointSize(_next);}if(byWordTo==len&&byWord[0]==0&&wordAdjacent)return this.result(-100/* ByWord */+(byWordFolded?-200/* CaseFold */:0),byWord,word);if(adjacentTo==len&&adjacentStart==0)return[-200/* CaseFold */-word.length,0,adjacentEnd];if(direct>-1)return[-700/* NotStart */-word.length,direct,direct+this.pattern.length];if(adjacentTo==len)return[-200/* CaseFold */+-700/* NotStart */-word.length,adjacentStart,adjacentEnd];if(byWordTo==len)return this.result(-100/* ByWord */+(byWordFolded?-200/* CaseFold */:0)+-700/* NotStart */+(wordAdjacent?0:-1100/* Gap */),byWord,word);return chars.length==2?null:this.result((any[0]?-700/* NotStart */:0)+-200/* CaseFold */+-1100/* Gap */,any,word);}},{key:"result",value:function result(score,positions,word){var result=[score-word.length],i=1;var _iterator2=_createForOfIteratorHelper(positions),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var pos=_step2.value;var to=pos+(this.astral?text.codePointSize(text.codePointAt(word,pos)):1);if(i>1&&result[i-1]==pos)result[i-1]=to;else{result[i++]=pos;result[i++]=to;}}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}return result;}}]);return FuzzyMatcher;}();var completionConfig=state.Facet.define({combine:function combine(configs){return state.combineConfig(configs,{activateOnTyping:true,override:null,maxRenderedOptions:100,defaultKeymap:true,optionClass:function optionClass(){return"";},aboveCursor:false,icons:true,addToOptions:[]},{defaultKeymap:function defaultKeymap(a,b){return a&&b;},icons:function icons(a,b){return a&&b;},optionClass:function optionClass(a,b){return function(c){return joinClass(a(c),b(c));};},addToOptions:function addToOptions(a,b){return a.concat(b);}});}});function joinClass(a,b){return a?b?a+" "+b:a:b;}function optionContent(config){var content=config.addToOptions.slice();if(config.icons)content.push({render:function render(completion){var _icon$classList;var icon=document.createElement("div");icon.classList.add("cm-completionIcon");if(completion.type)(_icon$classList=icon.classList).add.apply(_icon$classList,_toConsumableArray(completion.type.split(/\s+/g).map(function(cls){return"cm-completionIcon-"+cls;})));icon.setAttribute("aria-hidden","true");return icon;},position:20});content.push({render:function render(completion,_s,match){var labelElt=document.createElement("span");labelElt.className="cm-completionLabel";var label=completion.label,off=0;for(var j=1;j<match.length;){var from=match[j++],to=match[j++];if(from>off)labelElt.appendChild(document.createTextNode(label.slice(off,from)));var span=labelElt.appendChild(document.createElement("span"));span.appendChild(document.createTextNode(label.slice(from,to)));span.className="cm-completionMatchedText";off=to;}if(off<label.length)labelElt.appendChild(document.createTextNode(label.slice(off)));return labelElt;},position:50},{render:function render(completion){if(!completion.detail)return null;var detailElt=document.createElement("span");detailElt.className="cm-completionDetail";detailElt.textContent=completion.detail;return detailElt;},position:80});return content.sort(function(a,b){return a.position-b.position;}).map(function(a){return a.render;});}function createInfoDialog(option,view$1){var dom=document.createElement("div");dom.className="cm-tooltip cm-completionInfo";var info=option.completion.info;if(typeof info=="string"){dom.textContent=info;}else{var content=info(option.completion);if(content.then)content.then(function(node){return dom.appendChild(node);},function(e){return view.logException(view$1.state,e,"completion info");});else dom.appendChild(content);}return dom;}function rangeAroundSelected(total,selected,max){if(total<=max)return{from:0,to:total};if(selected<=total>>1){var _off=Math.floor(selected/max);return{from:_off*max,to:(_off+1)*max};}var off=Math.floor((total-selected)/max);return{from:total-(off+1)*max,to:total-off*max};}var CompletionTooltip=/*#__PURE__*/function(){function CompletionTooltip(view,stateField){var _this=this;_classCallCheck(this,CompletionTooltip);this.view=view;this.stateField=stateField;this.info=null;this.placeInfo={read:function read(){return _this.measureInfo();},write:function write(pos){return _this.positionInfo(pos);},key:this};var cState=view.state.field(stateField);var _cState$open=cState.open,options=_cState$open.options,selected=_cState$open.selected;var config=view.state.facet(completionConfig);this.optionContent=optionContent(config);this.optionClass=config.optionClass;this.range=rangeAroundSelected(options.length,selected,config.maxRenderedOptions);this.dom=document.createElement("div");this.dom.className="cm-tooltip-autocomplete";this.dom.addEventListener("mousedown",function(e){for(var dom=e.target,match;dom&&dom!=_this.dom;dom=dom.parentNode){if(dom.nodeName=="LI"&&(match=/-(\d+)$/.exec(dom.id))&&+match[1]<options.length){applyCompletion(view,options[+match[1]]);e.preventDefault();return;}}});this.list=this.dom.appendChild(this.createListBox(options,cState.id,this.range));this.list.addEventListener("scroll",function(){if(_this.info)_this.view.requestMeasure(_this.placeInfo);});}_createClass(CompletionTooltip,[{key:"mount",value:function mount(){this.updateSel();}},{key:"update",value:function update(_update){if(_update.state.field(this.stateField)!=_update.startState.field(this.stateField))this.updateSel();}},{key:"positioned",value:function positioned(){if(this.info)this.view.requestMeasure(this.placeInfo);}},{key:"updateSel",value:function updateSel(){var _this2=this;var cState=this.view.state.field(this.stateField),open=cState.open;if(open.selected<this.range.from||open.selected>=this.range.to){this.range=rangeAroundSelected(open.options.length,open.selected,this.view.state.facet(completionConfig).maxRenderedOptions);this.list.remove();this.list=this.dom.appendChild(this.createListBox(open.options,cState.id,this.range));this.list.addEventListener("scroll",function(){if(_this2.info)_this2.view.requestMeasure(_this2.placeInfo);});}if(this.updateSelectedOption(open.selected)){if(this.info){this.info.remove();this.info=null;}var option=open.options[open.selected];if(option.completion.info){this.info=this.dom.appendChild(createInfoDialog(option,this.view));this.view.requestMeasure(this.placeInfo);}}}},{key:"updateSelectedOption",value:function updateSelectedOption(selected){var set=null;for(var opt=this.list.firstChild,i=this.range.from;opt;opt=opt.nextSibling,i++){if(i==selected){if(!opt.hasAttribute("aria-selected")){opt.setAttribute("aria-selected","true");set=opt;}}else{if(opt.hasAttribute("aria-selected"))opt.removeAttribute("aria-selected");}}if(set)scrollIntoView(this.list,set);return set;}},{key:"measureInfo",value:function measureInfo(){var sel=this.dom.querySelector("[aria-selected]");if(!sel||!this.info)return null;var listRect=this.dom.getBoundingClientRect();var infoRect=this.info.getBoundingClientRect();var selRect=sel.getBoundingClientRect();if(selRect.top>Math.min(innerHeight,listRect.bottom)-10||selRect.bottom<Math.max(0,listRect.top)+10)return null;var top=Math.max(0,Math.min(selRect.top,innerHeight-infoRect.height))-listRect.top;var left=this.view.textDirection==view.Direction.RTL;var spaceLeft=listRect.left,spaceRight=innerWidth-listRect.right;if(left&&spaceLeft<Math.min(infoRect.width,spaceRight))left=false;else if(!left&&spaceRight<Math.min(infoRect.width,spaceLeft))left=true;return{top:top,left:left};}},{key:"positionInfo",value:function positionInfo(pos){if(this.info){this.info.style.top=(pos?pos.top:-1e6)+"px";if(pos){this.info.classList.toggle("cm-completionInfo-left",pos.left);this.info.classList.toggle("cm-completionInfo-right",!pos.left);}}}},{key:"createListBox",value:function createListBox(options,id,range){var ul=document.createElement("ul");ul.id=id;ul.setAttribute("role","listbox");for(var i=range.from;i<range.to;i++){var _options$i=options[i],completion=_options$i.completion,match=_options$i.match;var li=ul.appendChild(document.createElement("li"));li.id=id+"-"+i;li.setAttribute("role","option");var cls=this.optionClass(completion);if(cls)li.className=cls;var _iterator3=_createForOfIteratorHelper(this.optionContent),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var source=_step3.value;var node=source(completion,this.view.state,match);if(node)li.appendChild(node);}}catch(err){_iterator3.e(err);}finally{_iterator3.f();}}if(range.from)ul.classList.add("cm-completionListIncompleteTop");if(range.to<options.length)ul.classList.add("cm-completionListIncompleteBottom");return ul;}}]);return CompletionTooltip;}();// We allocate a new function instance every time the completion
6868+// changes to force redrawing/repositioning of the tooltip
6969+function completionTooltip(stateField){return function(view){return new CompletionTooltip(view,stateField);};}function scrollIntoView(container,element){var parent=container.getBoundingClientRect();var self=element.getBoundingClientRect();if(self.top<parent.top)container.scrollTop-=parent.top-self.top;else if(self.bottom>parent.bottom)container.scrollTop+=self.bottom-parent.bottom;}var MaxOptions=300;// Used to pick a preferred option when two options with the same
7070+// label occur in the result.
7171+function score(option){return(option.boost||0)*100+(option.apply?10:0)+(option.info?5:0)+(option.type?1:0);}function sortOptions(active,state){var options=[],i=0;var _iterator4=_createForOfIteratorHelper(active),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var a=_step4.value;if(a.hasResult()){if(a.result.filter===false){var _iterator6=_createForOfIteratorHelper(a.result.options),_step6;try{for(_iterator6.s();!(_step6=_iterator6.n()).done;){var option=_step6.value;options.push(new Option(option,a,[1e9-i++]));}}catch(err){_iterator6.e(err);}finally{_iterator6.f();}}else{var matcher=new FuzzyMatcher(state.sliceDoc(a.from,a.to)),match=void 0;var _iterator7=_createForOfIteratorHelper(a.result.options),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var _option=_step7.value;if(match=matcher.match(_option.label)){if(_option.boost!=null)match[0]+=_option.boost;options.push(new Option(_option,a,match));}}}catch(err){_iterator7.e(err);}finally{_iterator7.f();}}}}}catch(err){_iterator4.e(err);}finally{_iterator4.f();}options.sort(cmpOption);var result=[],prev=null;var _iterator5=_createForOfIteratorHelper(options.sort(cmpOption)),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var opt=_step5.value;if(result.length==MaxOptions)break;if(!prev||prev.label!=opt.completion.label||prev.detail!=opt.completion.detail||prev.type!=opt.completion.type||prev.apply!=opt.completion.apply)result.push(opt);else if(score(opt.completion)>score(prev))result[result.length-1]=opt;prev=opt.completion;}}catch(err){_iterator5.e(err);}finally{_iterator5.f();}return result;}var CompletionDialog=/*#__PURE__*/function(){function CompletionDialog(options,attrs,tooltip,timestamp,selected){_classCallCheck(this,CompletionDialog);this.options=options;this.attrs=attrs;this.tooltip=tooltip;this.timestamp=timestamp;this.selected=selected;}_createClass(CompletionDialog,[{key:"setSelected",value:function setSelected(selected,id){return selected==this.selected||selected>=this.options.length?this:new CompletionDialog(this.options,makeAttrs(id,selected),this.tooltip,this.timestamp,selected);}},{key:"map",value:function map(changes){return new CompletionDialog(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:changes.mapPos(this.tooltip.pos)}),this.timestamp,this.selected);}}],[{key:"build",value:function build(active,state,id,prev,conf){var options=sortOptions(active,state);if(!options.length)return null;var selected=0;if(prev&&prev.selected){var selectedValue=prev.options[prev.selected].completion;for(var i=0;i<options.length&&!selected;i++){if(options[i].completion==selectedValue)selected=i;}}return new CompletionDialog(options,makeAttrs(id,selected),{pos:active.reduce(function(a,b){return b.hasResult()?Math.min(a,b.from):a;},1e8),create:completionTooltip(completionState),above:conf.aboveCursor},prev?prev.timestamp:Date.now(),selected);}}]);return CompletionDialog;}();var CompletionState=/*#__PURE__*/function(){function CompletionState(active,id,open){_classCallCheck(this,CompletionState);this.active=active;this.id=id;this.open=open;}_createClass(CompletionState,[{key:"update",value:function update(tr){var _this3=this;var state=tr.state,conf=state.facet(completionConfig);var sources=conf.override||state.languageDataAt("autocomplete",cur(state)).map(asSource);var active=sources.map(function(source){var value=_this3.active.find(function(s){return s.source==source;})||new ActiveSource(source,_this3.active.some(function(a){return a.state!=0;}/* Inactive */)?1/* Pending */:0/* Inactive */);return value.update(tr,conf);});if(active.length==this.active.length&&active.every(function(a,i){return a==_this3.active[i];}))active=this.active;var open=tr.selection||active.some(function(a){return a.hasResult()&&tr.changes.touchesRange(a.from,a.to);})||!sameResults(active,this.active)?CompletionDialog.build(active,state,this.id,this.open,conf):this.open&&tr.docChanged?this.open.map(tr.changes):this.open;if(!open&&active.every(function(a){return a.state!=1;}/* Pending */)&&active.some(function(a){return a.hasResult();}))active=active.map(function(a){return a.hasResult()?new ActiveSource(a.source,0/* Inactive */):a;});var _iterator8=_createForOfIteratorHelper(tr.effects),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var effect=_step8.value;if(effect.is(setSelectedEffect))open=open&&open.setSelected(effect.value,this.id);}}catch(err){_iterator8.e(err);}finally{_iterator8.f();}return active==this.active&&open==this.open?this:new CompletionState(active,this.id,open);}},{key:"tooltip",get:function get(){return this.open?this.open.tooltip:null;}},{key:"attrs",get:function get(){return this.open?this.open.attrs:baseAttrs;}}],[{key:"start",value:function start(){return new CompletionState(none,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null);}}]);return CompletionState;}();function sameResults(a,b){if(a==b)return true;for(var iA=0,iB=0;;){while(iA<a.length&&!a[iA].hasResult){iA++;}while(iB<b.length&&!b[iB].hasResult){iB++;}var endA=iA==a.length,endB=iB==b.length;if(endA||endB)return endA==endB;if(a[iA++].result!=b[iB++].result)return false;}}var baseAttrs={"aria-autocomplete":"list","aria-expanded":"false"};function makeAttrs(id,selected){return{"aria-autocomplete":"list","aria-expanded":"true","aria-activedescendant":id+"-"+selected,"aria-controls":id};}var none=[];function cmpOption(a,b){var dScore=b.match[0]-a.match[0];if(dScore)return dScore;return a.completion.label.localeCompare(b.completion.label);}function getUserEvent(tr){return tr.isUserEvent("input.type")?"input":tr.isUserEvent("delete.backward")?"delete":null;}var ActiveSource=/*#__PURE__*/function(){function ActiveSource(source,state){var explicitPos=arguments.length>2&&arguments[2]!==undefined?arguments[2]:-1;_classCallCheck(this,ActiveSource);this.source=source;this.state=state;this.explicitPos=explicitPos;}_createClass(ActiveSource,[{key:"hasResult",value:function hasResult(){return false;}},{key:"update",value:function update(tr,conf){var event=getUserEvent(tr),value=this;if(event)value=value.handleUserEvent(tr,event,conf);else if(tr.docChanged)value=value.handleChange(tr);else if(tr.selection&&value.state!=0/* Inactive */)value=new ActiveSource(value.source,0/* Inactive */);var _iterator9=_createForOfIteratorHelper(tr.effects),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var effect=_step9.value;if(effect.is(startCompletionEffect))value=new ActiveSource(value.source,1/* Pending */,effect.value?cur(tr.state):-1);else if(effect.is(closeCompletionEffect))value=new ActiveSource(value.source,0/* Inactive */);else if(effect.is(setActiveEffect)){var _iterator10=_createForOfIteratorHelper(effect.value),_step10;try{for(_iterator10.s();!(_step10=_iterator10.n()).done;){var active=_step10.value;if(active.source==value.source)value=active;}}catch(err){_iterator10.e(err);}finally{_iterator10.f();}}}}catch(err){_iterator9.e(err);}finally{_iterator9.f();}return value;}},{key:"handleUserEvent",value:function handleUserEvent(tr,type,conf){return type=="delete"||!conf.activateOnTyping?this.map(tr.changes):new ActiveSource(this.source,1/* Pending */);}},{key:"handleChange",value:function handleChange(tr){return tr.changes.touchesRange(cur(tr.startState))?new ActiveSource(this.source,0/* Inactive */):this.map(tr.changes);}},{key:"map",value:function map(changes){return changes.empty||this.explicitPos<0?this:new ActiveSource(this.source,this.state,changes.mapPos(this.explicitPos));}}]);return ActiveSource;}();var ActiveResult=/*#__PURE__*/function(_ActiveSource){_inherits(ActiveResult,_ActiveSource);var _super=_createSuper(ActiveResult);function ActiveResult(source,explicitPos,result,from,to,span){var _this4;_classCallCheck(this,ActiveResult);_this4=_super.call(this,source,2/* Result */,explicitPos);_this4.result=result;_this4.from=from;_this4.to=to;_this4.span=span;return _this4;}_createClass(ActiveResult,[{key:"hasResult",value:function hasResult(){return true;}},{key:"handleUserEvent",value:function handleUserEvent(tr,type,conf){var from=tr.changes.mapPos(this.from),to=tr.changes.mapPos(this.to,1);var pos=cur(tr.state);if((this.explicitPos>-1?pos<from:pos<=from)||pos>to)return new ActiveSource(this.source,type=="input"&&conf.activateOnTyping?1/* Pending */:0/* Inactive */);var explicitPos=this.explicitPos<0?-1:tr.changes.mapPos(this.explicitPos);if(this.span&&(from==to||this.span.test(tr.state.sliceDoc(from,to))))return new ActiveResult(this.source,explicitPos,this.result,from,to,this.span);return new ActiveSource(this.source,1/* Pending */,explicitPos);}},{key:"handleChange",value:function handleChange(tr){return tr.changes.touchesRange(this.from,this.to)?new ActiveSource(this.source,0/* Inactive */):this.map(tr.changes);}},{key:"map",value:function map(mapping){return mapping.empty?this:new ActiveResult(this.source,this.explicitPos<0?-1:mapping.mapPos(this.explicitPos),this.result,mapping.mapPos(this.from),mapping.mapPos(this.to,1),this.span);}}]);return ActiveResult;}(ActiveSource);var startCompletionEffect=state.StateEffect.define();var closeCompletionEffect=state.StateEffect.define();var setActiveEffect=state.StateEffect.define({map:function map(sources,mapping){return sources.map(function(s){return s.map(mapping);});}});var setSelectedEffect=state.StateEffect.define();var completionState=state.StateField.define({create:function create(){return CompletionState.start();},update:function update(value,tr){return value.update(tr);},provide:function provide(f){return[tooltip.showTooltip.from(f,function(val){return val.tooltip;}),view.EditorView.contentAttributes.from(f,function(state){return state.attrs;})];}});var CompletionInteractMargin=75;/**
7272+Returns a command that moves the completion selection forward or
7373+backward by the given amount.
7474+*/function moveCompletionSelection(forward){var by=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"option";return function(view){var cState=view.state.field(completionState,false);if(!cState||!cState.open||Date.now()-cState.open.timestamp<CompletionInteractMargin)return false;var step=1,tooltip$1;if(by=="page"&&(tooltip$1=tooltip.getTooltip(view,cState.open.tooltip)))step=Math.max(2,Math.floor(tooltip$1.dom.offsetHeight/tooltip$1.dom.querySelector("li").offsetHeight)-1);var selected=cState.open.selected+step*(forward?1:-1),length=cState.open.options.length;if(selected<0)selected=by=="page"?0:length-1;else if(selected>=length)selected=by=="page"?length-1:0;view.dispatch({effects:setSelectedEffect.of(selected)});return true;};}/**
7575+Accept the current completion.
7676+*/var acceptCompletion=function acceptCompletion(view){var cState=view.state.field(completionState,false);if(view.state.readOnly||!cState||!cState.open||Date.now()-cState.open.timestamp<CompletionInteractMargin)return false;applyCompletion(view,cState.open.options[cState.open.selected]);return true;};/**
7777+Explicitly start autocompletion.
7878+*/var startCompletion=function startCompletion(view){var cState=view.state.field(completionState,false);if(!cState)return false;view.dispatch({effects:startCompletionEffect.of(true)});return true;};/**
7979+Close the currently active completion.
8080+*/var closeCompletion=function closeCompletion(view){var cState=view.state.field(completionState,false);if(!cState||!cState.active.some(function(a){return a.state!=0;}/* Inactive */))return false;view.dispatch({effects:closeCompletionEffect.of(null)});return true;};var RunningQuery=/*#__PURE__*/_createClass(function RunningQuery(active,context){_classCallCheck(this,RunningQuery);this.active=active;this.context=context;this.time=Date.now();this.updates=[];// Note that 'undefined' means 'not done yet', whereas 'null' means
8181+// 'query returned null'.
8282+this.done=undefined;});var DebounceTime=50,MaxUpdateCount=50,MinAbortTime=1000;var completionPlugin=view.ViewPlugin.fromClass(/*#__PURE__*/function(){function _class(view){_classCallCheck(this,_class);this.view=view;this.debounceUpdate=-1;this.running=[];this.debounceAccept=-1;this.composing=0/* None */;var _iterator11=_createForOfIteratorHelper(view.state.field(completionState).active),_step11;try{for(_iterator11.s();!(_step11=_iterator11.n()).done;){var active=_step11.value;if(active.state==1/* Pending */)this.startQuery(active);}}catch(err){_iterator11.e(err);}finally{_iterator11.f();}}_createClass(_class,[{key:"update",value:function update(_update2){var _this5=this;var cState=_update2.state.field(completionState);if(!_update2.selectionSet&&!_update2.docChanged&&_update2.startState.field(completionState)==cState)return;var doesReset=_update2.transactions.some(function(tr){return(tr.selection||tr.docChanged)&&!getUserEvent(tr);});for(var i=0;i<this.running.length;i++){var query=this.running[i];if(doesReset||query.updates.length+_update2.transactions.length>MaxUpdateCount&&query.time-Date.now()>MinAbortTime){var _iterator12=_createForOfIteratorHelper(query.context.abortListeners),_step12;try{for(_iterator12.s();!(_step12=_iterator12.n()).done;){var handler=_step12.value;try{handler();}catch(e){view.logException(this.view.state,e);}}}catch(err){_iterator12.e(err);}finally{_iterator12.f();}query.context.abortListeners=null;this.running.splice(i--,1);}else{var _query$updates;(_query$updates=query.updates).push.apply(_query$updates,_toConsumableArray(_update2.transactions));}}if(this.debounceUpdate>-1)clearTimeout(this.debounceUpdate);this.debounceUpdate=cState.active.some(function(a){return a.state==1/* Pending */&&!_this5.running.some(function(q){return q.active.source==a.source;});})?setTimeout(function(){return _this5.startUpdate();},DebounceTime):-1;if(this.composing!=0/* None */){var _iterator13=_createForOfIteratorHelper(_update2.transactions),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var tr=_step13.value;if(getUserEvent(tr)=="input")this.composing=2/* Changed */;else if(this.composing==2/* Changed */&&tr.selection)this.composing=3/* ChangedAndMoved */;}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}}},{key:"startUpdate",value:function startUpdate(){var _this6=this;this.debounceUpdate=-1;var state=this.view.state,cState=state.field(completionState);var _iterator14=_createForOfIteratorHelper(cState.active),_step14;try{var _loop=function _loop(){var active=_step14.value;if(active.state==1/* Pending */&&!_this6.running.some(function(r){return r.active.source==active.source;}))_this6.startQuery(active);};for(_iterator14.s();!(_step14=_iterator14.n()).done;){_loop();}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}},{key:"startQuery",value:function startQuery(active){var _this7=this;var state=this.view.state,pos=cur(state);var context=new CompletionContext(state,pos,active.explicitPos==pos);var pending=new RunningQuery(active,context);this.running.push(pending);Promise.resolve(active.source(context)).then(function(result){if(!pending.context.aborted){pending.done=result||null;_this7.scheduleAccept();}},function(err){_this7.view.dispatch({effects:closeCompletionEffect.of(null)});view.logException(_this7.view.state,err);});}},{key:"scheduleAccept",value:function scheduleAccept(){var _this8=this;if(this.running.every(function(q){return q.done!==undefined;}))this.accept();else if(this.debounceAccept<0)this.debounceAccept=setTimeout(function(){return _this8.accept();},DebounceTime);}// For each finished query in this.running, try to create a result
8383+// or, if appropriate, restart the query.
8484+},{key:"accept",value:function accept(){var _this9=this;var _a;if(this.debounceAccept>-1)clearTimeout(this.debounceAccept);this.debounceAccept=-1;var updated=[];var conf=this.view.state.facet(completionConfig);var _loop2=function _loop2(_i3){var query=_this9.running[_i3];if(query.done===undefined){i=_i3;return"continue";}_this9.running.splice(_i3--,1);if(query.done){var active=new ActiveResult(query.active.source,query.active.explicitPos,query.done,query.done.from,(_a=query.done.to)!==null&&_a!==void 0?_a:cur(query.updates.length?query.updates[0].startState:_this9.view.state),query.done.span&&query.done.filter!==false?ensureAnchor(query.done.span,true):null);// Replay the transactions that happened since the start of
8585+// the request and see if that preserves the result
8686+var _iterator15=_createForOfIteratorHelper(query.updates),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var tr=_step15.value;active=active.update(tr,conf);}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}if(active.hasResult()){updated.push(active);i=_i3;return"continue";}}var current=_this9.view.state.field(completionState).active.find(function(a){return a.source==query.active.source;});if(current&¤t.state==1/* Pending */){if(query.done==null){// Explicitly failed. Should clear the pending status if it
8787+// hasn't been re-set in the meantime.
8888+var _active=new ActiveSource(query.active.source,0/* Inactive */);var _iterator16=_createForOfIteratorHelper(query.updates),_step16;try{for(_iterator16.s();!(_step16=_iterator16.n()).done;){var _tr=_step16.value;_active=_active.update(_tr,conf);}}catch(err){_iterator16.e(err);}finally{_iterator16.f();}if(_active.state!=1/* Pending */)updated.push(_active);}else{// Cleared by subsequent transactions. Restart.
8989+_this9.startQuery(current);}}i=_i3;};for(var i=0;i<this.running.length;i++){var _ret=_loop2(i);if(_ret==="continue")continue;}if(updated.length)this.view.dispatch({effects:setActiveEffect.of(updated)});}}]);return _class;}(),{eventHandlers:{compositionstart:function compositionstart(){this.composing=1/* Started */;},compositionend:function compositionend(){var _this10=this;if(this.composing==3/* ChangedAndMoved */){// Safari fires compositionend events synchronously, possibly
9090+// from inside an update, so dispatch asynchronously to avoid reentrancy
9191+setTimeout(function(){return _this10.view.dispatch({effects:startCompletionEffect.of(false)});},20);}this.composing=0/* None */;}}});var baseTheme=view.EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:0.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"300px"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\uD83D\uDD11\uFE0E'"}// Disable emoji rendering
9292+},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});var FieldPos=/*#__PURE__*/_createClass(function FieldPos(field,line,from,to){_classCallCheck(this,FieldPos);this.field=field;this.line=line;this.from=from;this.to=to;});var FieldRange=/*#__PURE__*/function(){function FieldRange(field,from,to){_classCallCheck(this,FieldRange);this.field=field;this.from=from;this.to=to;}_createClass(FieldRange,[{key:"map",value:function map(changes){return new FieldRange(this.field,changes.mapPos(this.from,-1),changes.mapPos(this.to,1));}}]);return FieldRange;}();var Snippet=/*#__PURE__*/function(){function Snippet(lines,fieldPositions){_classCallCheck(this,Snippet);this.lines=lines;this.fieldPositions=fieldPositions;}_createClass(Snippet,[{key:"instantiate",value:function instantiate(state,pos){var text=[],lineStart=[pos];var lineObj=state.doc.lineAt(pos),baseIndent=/^\s*/.exec(lineObj.text)[0];var _iterator17=_createForOfIteratorHelper(this.lines),_step17;try{for(_iterator17.s();!(_step17=_iterator17.n()).done;){var line=_step17.value;if(text.length){var indent=baseIndent,tabs=/^\t*/.exec(line)[0].length;for(var _i4=0;_i4<tabs;_i4++){indent+=state.facet(language.indentUnit);}lineStart.push(pos+indent.length-tabs);line=indent+line.slice(tabs);}text.push(line);pos+=line.length+1;}}catch(err){_iterator17.e(err);}finally{_iterator17.f();}var ranges=this.fieldPositions.map(function(pos){return new FieldRange(pos.field,lineStart[pos.line]+pos.from,lineStart[pos.line]+pos.to);});return{text:text,ranges:ranges};}}],[{key:"parse",value:function parse(template){var fields=[];var lines=[],positions=[],m;var _iterator18=_createForOfIteratorHelper(template.split(/\r\n?|\n/)),_step18;try{for(_iterator18.s();!(_step18=_iterator18.n()).done;){var line=_step18.value;while(m=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(line)){var seq=m[1]?+m[1]:null,name=m[2]||m[3]||"",found=-1;for(var _i5=0;_i5<fields.length;_i5++){if(seq!=null?fields[_i5].seq==seq:name?fields[_i5].name==name:false)found=_i5;}if(found<0){var _i6=0;while(_i6<fields.length&&(seq==null||fields[_i6].seq!=null&&fields[_i6].seq<seq)){_i6++;}fields.splice(_i6,0,{seq:seq,name:name});found=_i6;var _iterator19=_createForOfIteratorHelper(positions),_step19;try{for(_iterator19.s();!(_step19=_iterator19.n()).done;){var pos=_step19.value;if(pos.field>=found)pos.field++;}}catch(err){_iterator19.e(err);}finally{_iterator19.f();}}positions.push(new FieldPos(found,lines.length,m.index,m.index+name.length));line=line.slice(0,m.index)+name+line.slice(m.index+m[0].length);}lines.push(line);}}catch(err){_iterator18.e(err);}finally{_iterator18.f();}return new Snippet(lines,positions);}}]);return Snippet;}();var fieldMarker=view.Decoration.widget({widget:new(/*#__PURE__*/function(_view$WidgetType){_inherits(_class2,_view$WidgetType);var _super2=_createSuper(_class2);function _class2(){_classCallCheck(this,_class2);return _super2.apply(this,arguments);}_createClass(_class2,[{key:"toDOM",value:function toDOM(){var span=document.createElement("span");span.className="cm-snippetFieldPosition";return span;}},{key:"ignoreEvent",value:function ignoreEvent(){return false;}}]);return _class2;}(view.WidgetType))()});var fieldRange=view.Decoration.mark({"class":"cm-snippetField"});var ActiveSnippet=/*#__PURE__*/function(){function ActiveSnippet(ranges,active){_classCallCheck(this,ActiveSnippet);this.ranges=ranges;this.active=active;this.deco=view.Decoration.set(ranges.map(function(r){return(r.from==r.to?fieldMarker:fieldRange).range(r.from,r.to);}));}_createClass(ActiveSnippet,[{key:"map",value:function map(changes){return new ActiveSnippet(this.ranges.map(function(r){return r.map(changes);}),this.active);}},{key:"selectionInsideField",value:function selectionInsideField(sel){var _this11=this;return sel.ranges.every(function(range){return _this11.ranges.some(function(r){return r.field==_this11.active&&r.from<=range.from&&r.to>=range.to;});});}}]);return ActiveSnippet;}();var setActive=state.StateEffect.define({map:function map(value,changes){return value&&value.map(changes);}});var moveToField=state.StateEffect.define();var snippetState=state.StateField.define({create:function create(){return null;},update:function update(value,tr){var _iterator20=_createForOfIteratorHelper(tr.effects),_step20;try{for(_iterator20.s();!(_step20=_iterator20.n()).done;){var effect=_step20.value;if(effect.is(setActive))return effect.value;if(effect.is(moveToField)&&value)return new ActiveSnippet(value.ranges,effect.value);}}catch(err){_iterator20.e(err);}finally{_iterator20.f();}if(value&&tr.docChanged)value=value.map(tr.changes);if(value&&tr.selection&&!value.selectionInsideField(tr.selection))value=null;return value;},provide:function provide(f){return view.EditorView.decorations.from(f,function(val){return val?val.deco:view.Decoration.none;});}});function fieldSelection(ranges,field){return state.EditorSelection.create(ranges.filter(function(r){return r.field==field;}).map(function(r){return state.EditorSelection.range(r.from,r.to);}));}/**
9393+Convert a snippet template to a function that can apply it.
9494+Snippets are written using syntax like this:
9595+9696+ "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"
9797+9898+Each `${}` placeholder (you may also use `#{}`) indicates a field
9999+that the user can fill in. Its name, if any, will be the default
100100+content for the field.
101101+102102+When the snippet is activated by calling the returned function,
103103+the code is inserted at the given position. Newlines in the
104104+template are indented by the indentation of the start line, plus
105105+one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
106106+the newline.
107107+108108+On activation, (all instances of) the first field are selected.
109109+The user can move between fields with Tab and Shift-Tab as long as
110110+the fields are active. Moving to the last field or moving the
111111+cursor out of the current field deactivates the fields.
112112+113113+The order of fields defaults to textual order, but you can add
114114+numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
115115+a custom order.
116116+*/function snippet(template){var snippet=Snippet.parse(template);return function(editor,_completion,from,to){var _snippet$instantiate=snippet.instantiate(editor.state,from),text=_snippet$instantiate.text,ranges=_snippet$instantiate.ranges;var spec={changes:{from:from,to:to,insert:state.Text.of(text)}};if(ranges.length)spec.selection=fieldSelection(ranges,0);if(ranges.length>1){var active=new ActiveSnippet(ranges,0);var effects=spec.effects=[setActive.of(active)];if(editor.state.field(snippetState,false)===undefined)effects.push(state.StateEffect.appendConfig.of([snippetState,addSnippetKeymap,snippetPointerHandler,baseTheme]));}editor.dispatch(editor.state.update(spec));};}function moveField(dir){return function(_ref3){var state=_ref3.state,dispatch=_ref3.dispatch;var active=state.field(snippetState,false);if(!active||dir<0&&active.active==0)return false;var next=active.active+dir,last=dir>0&&!active.ranges.some(function(r){return r.field==next+dir;});dispatch(state.update({selection:fieldSelection(active.ranges,next),effects:setActive.of(last?null:new ActiveSnippet(active.ranges,next))}));return true;};}/**
117117+A command that clears the active snippet, if any.
118118+*/var clearSnippet=function clearSnippet(_ref4){var state=_ref4.state,dispatch=_ref4.dispatch;var active=state.field(snippetState,false);if(!active)return false;dispatch(state.update({effects:setActive.of(null)}));return true;};/**
119119+Move to the next snippet field, if available.
120120+*/var nextSnippetField=moveField(1);/**
121121+Move to the previous snippet field, if available.
122122+*/var prevSnippetField=moveField(-1);var defaultSnippetKeymap=[{key:"Tab",run:nextSnippetField,shift:prevSnippetField},{key:"Escape",run:clearSnippet}];/**
123123+A facet that can be used to configure the key bindings used by
124124+snippets. The default binds Tab to
125125+[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
126126+[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
127127+to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
128128+*/var snippetKeymap=state.Facet.define({combine:function combine(maps){return maps.length?maps[0]:defaultSnippetKeymap;}});var addSnippetKeymap=state.Prec.highest(view.keymap.compute([snippetKeymap],function(state){return state.facet(snippetKeymap);}));/**
129129+Create a completion from a snippet. Returns an object with the
130130+properties from `completion`, plus an `apply` function that
131131+applies the snippet.
132132+*/function snippetCompletion(template,completion){return Object.assign(Object.assign({},completion),{apply:snippet(template)});}var snippetPointerHandler=view.EditorView.domEventHandlers({mousedown:function mousedown(event,view){var active=view.state.field(snippetState,false),pos;if(!active||(pos=view.posAtCoords({x:event.clientX,y:event.clientY}))==null)return false;var match=active.ranges.find(function(r){return r.from<=pos&&r.to>=pos;});if(!match||match.field==active.active)return false;view.dispatch({selection:fieldSelection(active.ranges,match.field),effects:setActive.of(active.ranges.some(function(r){return r.field>match.field;})?new ActiveSnippet(active.ranges,match.field):null)});return true;}});function wordRE(wordChars){var escaped=wordChars.replace(/[\\[.+*?(){|^$]/g,"\\$&");try{return new RegExp("[\\p{Alphabetic}\\p{Number}_".concat(escaped,"]+"),"ug");}catch(_a){return new RegExp("[w".concat(escaped,"]"),"g");}}function mapRE(re,f){return new RegExp(f(re.source),re.unicode?"u":"");}var wordCaches=Object.create(null);function wordCache(wordChars){return wordCaches[wordChars]||(wordCaches[wordChars]=new WeakMap());}function storeWords(doc,wordRE,result,seen,ignoreAt){for(var lines=doc.iterLines(),pos=0;!lines.next().done;){var value=lines.value,m=void 0;wordRE.lastIndex=0;while(m=wordRE.exec(value)){if(!seen[m[0]]&&pos+m.index!=ignoreAt){result.push({type:"text",label:m[0]});seen[m[0]]=true;if(result.length>=2000/* MaxList */)return;}}pos+=value.length+1;}}function collectWords(doc,cache,wordRE,to,ignoreAt){var big=doc.length>=1000/* MinCacheLen */;var cached=big&&cache.get(doc);if(cached)return cached;var result=[],seen=Object.create(null);if(doc.children){var pos=0;var _iterator21=_createForOfIteratorHelper(doc.children),_step21;try{for(_iterator21.s();!(_step21=_iterator21.n()).done;){var ch=_step21.value;if(ch.length>=1000/* MinCacheLen */){var _iterator22=_createForOfIteratorHelper(collectWords(ch,cache,wordRE,to-pos,ignoreAt-pos)),_step22;try{for(_iterator22.s();!(_step22=_iterator22.n()).done;){var c=_step22.value;if(!seen[c.label]){seen[c.label]=true;result.push(c);}}}catch(err){_iterator22.e(err);}finally{_iterator22.f();}}else{storeWords(ch,wordRE,result,seen,ignoreAt-pos);}pos+=ch.length+1;}}catch(err){_iterator21.e(err);}finally{_iterator21.f();}}else{storeWords(doc,wordRE,result,seen,ignoreAt);}if(big&&result.length<2000/* MaxList */)cache.set(doc,result);return result;}/**
133133+A completion source that will scan the document for words (using a
134134+[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and
135135+return those as completions.
136136+*/var completeAnyWord=function completeAnyWord(context){var wordChars=context.state.languageDataAt("wordChars",context.pos).join("");var re=wordRE(wordChars);var token=context.matchBefore(mapRE(re,function(s){return s+"$";}));if(!token&&!context.explicit)return null;var from=token?token.from:context.pos;var options=collectWords(context.state.doc,wordCache(wordChars),re,50000/* Range */,from);return{from:from,options:options,span:mapRE(re,function(s){return"^"+s;})};};/**
137137+Returns an extension that enables autocompletion.
138138+*/function autocompletion(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return[completionState,completionConfig.of(config),completionPlugin,completionKeymapExt,baseTheme];}/**
139139+Basic keybindings for autocompletion.
140140+141141+ - Ctrl-Space: [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
142142+ - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
143143+ - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
144144+ - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
145145+ - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
146146+ - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
147147+ - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
148148+*/var completionKeymap=[{key:"Ctrl-Space",run:startCompletion},{key:"Escape",run:closeCompletion},{key:"ArrowDown",run:moveCompletionSelection(true)},{key:"ArrowUp",run:moveCompletionSelection(false)},{key:"PageDown",run:moveCompletionSelection(true,"page")},{key:"PageUp",run:moveCompletionSelection(false,"page")},{key:"Enter",run:acceptCompletion}];var completionKeymapExt=state.Prec.highest(view.keymap.computeN([completionConfig],function(state){return state.facet(completionConfig).defaultKeymap?[completionKeymap]:[];}));/**
149149+Get the current completion status. When completions are available,
150150+this will return `"active"`. When completions are pending (in the
151151+process of being queried), this returns `"pending"`. Otherwise, it
152152+returns `null`.
153153+*/function completionStatus(state){var cState=state.field(completionState,false);return cState&&cState.active.some(function(a){return a.state==1;}/* Pending */)?"pending":cState&&cState.active.some(function(a){return a.state!=0;}/* Inactive */)?"active":null;}/**
154154+Returns the available completions as an array.
155155+*/function currentCompletions(state){var _a;var open=(_a=state.field(completionState,false))===null||_a===void 0?void 0:_a.open;return open?open.options.map(function(o){return o.completion;}):[];}/**
156156+Return the currently selected completion, if any.
157157+*/function selectedCompletion(state){var _a;var open=(_a=state.field(completionState,false))===null||_a===void 0?void 0:_a.open;return open?open.options[open.selected].completion:null;}exports.CompletionContext=CompletionContext;exports.acceptCompletion=acceptCompletion;exports.autocompletion=autocompletion;exports.clearSnippet=clearSnippet;exports.closeCompletion=closeCompletion;exports.completeAnyWord=completeAnyWord;exports.completeFromList=completeFromList;exports.completionKeymap=completionKeymap;exports.completionStatus=completionStatus;exports.currentCompletions=currentCompletions;exports.ifIn=ifIn;exports.ifNotIn=ifNotIn;exports.moveCompletionSelection=moveCompletionSelection;exports.nextSnippetField=nextSnippetField;exports.pickedCompletion=pickedCompletion;exports.prevSnippetField=prevSnippetField;exports.selectedCompletion=selectedCompletion;exports.snippet=snippet;exports.snippetCompletion=snippetCompletion;exports.snippetKeymap=snippetKeymap;exports.startCompletion=startCompletion;},{"@codemirror/language":13,"@codemirror/state":22,"@codemirror/text":24,"@codemirror/tooltip":26,"@codemirror/view":27}],2:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var view=require('@codemirror/view');var state=require('@codemirror/state');var history=require('@codemirror/history');var fold=require('@codemirror/fold');var language=require('@codemirror/language');var gutter=require('@codemirror/gutter');var commands=require('@codemirror/commands');var matchbrackets=require('@codemirror/matchbrackets');var closebrackets=require('@codemirror/closebrackets');var search=require('@codemirror/search');var autocomplete=require('@codemirror/autocomplete');var comment=require('@codemirror/comment');var rectangularSelection=require('@codemirror/rectangular-selection');var highlight=require('@codemirror/highlight');var lint=require('@codemirror/lint');/**
158158+This is an extension value that just pulls together a whole lot of
159159+extensions that you might want in a basic editor. It is meant as a
160160+convenient helper to quickly set up CodeMirror without installing
161161+and importing a lot of packages.
162162+163163+Specifically, it includes...
164164+165165+ - [the default command bindings](https://codemirror.net/6/docs/ref/#commands.defaultKeymap)
166166+ - [line numbers](https://codemirror.net/6/docs/ref/#gutter.lineNumbers)
167167+ - [special character highlighting](https://codemirror.net/6/docs/ref/#view.highlightSpecialChars)
168168+ - [the undo history](https://codemirror.net/6/docs/ref/#history.history)
169169+ - [a fold gutter](https://codemirror.net/6/docs/ref/#fold.foldGutter)
170170+ - [custom selection drawing](https://codemirror.net/6/docs/ref/#view.drawSelection)
171171+ - [multiple selections](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
172172+ - [reindentation on input](https://codemirror.net/6/docs/ref/#language.indentOnInput)
173173+ - [the default highlight style](https://codemirror.net/6/docs/ref/#highlight.defaultHighlightStyle) (as fallback)
174174+ - [bracket matching](https://codemirror.net/6/docs/ref/#matchbrackets.bracketMatching)
175175+ - [bracket closing](https://codemirror.net/6/docs/ref/#closebrackets.closeBrackets)
176176+ - [autocompletion](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion)
177177+ - [rectangular selection](https://codemirror.net/6/docs/ref/#rectangular-selection.rectangularSelection)
178178+ - [active line highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLine)
179179+ - [active line gutter highlighting](https://codemirror.net/6/docs/ref/#gutter.highlightActiveLineGutter)
180180+ - [selection match highlighting](https://codemirror.net/6/docs/ref/#search.highlightSelectionMatches)
181181+ - [search](https://codemirror.net/6/docs/ref/#search.searchKeymap)
182182+ - [commenting](https://codemirror.net/6/docs/ref/#comment.commentKeymap)
183183+ - [linting](https://codemirror.net/6/docs/ref/#lint.lintKeymap)
184184+185185+(You'll probably want to add some language package to your setup
186186+too.)
187187+188188+This package does not allow customization. The idea is that, once
189189+you decide you want to configure your editor more precisely, you
190190+take this package's source (which is just a bunch of imports and
191191+an array literal), copy it into your own code, and adjust it as
192192+desired.
193193+*/var basicSetup=[gutter.lineNumbers(),gutter.highlightActiveLineGutter(),view.highlightSpecialChars(),history.history(),fold.foldGutter(),view.drawSelection(),state.EditorState.allowMultipleSelections.of(true),language.indentOnInput(),highlight.defaultHighlightStyle.fallback,matchbrackets.bracketMatching(),closebrackets.closeBrackets(),autocomplete.autocompletion(),rectangularSelection.rectangularSelection(),view.highlightActiveLine(),search.highlightSelectionMatches(),view.keymap.of([].concat(_toConsumableArray(closebrackets.closeBracketsKeymap),_toConsumableArray(commands.defaultKeymap),_toConsumableArray(search.searchKeymap),_toConsumableArray(history.historyKeymap),_toConsumableArray(fold.foldKeymap),_toConsumableArray(comment.commentKeymap),_toConsumableArray(autocomplete.completionKeymap),_toConsumableArray(lint.lintKeymap)))];Object.defineProperty(exports,'EditorView',{enumerable:true,get:function get(){return view.EditorView;}});Object.defineProperty(exports,'EditorState',{enumerable:true,get:function get(){return state.EditorState;}});exports.basicSetup=basicSetup;},{"@codemirror/autocomplete":1,"@codemirror/closebrackets":3,"@codemirror/commands":4,"@codemirror/comment":6,"@codemirror/fold":7,"@codemirror/gutter":9,"@codemirror/highlight":11,"@codemirror/history":12,"@codemirror/language":13,"@codemirror/lint":15,"@codemirror/matchbrackets":16,"@codemirror/rectangular-selection":19,"@codemirror/search":20,"@codemirror/state":22,"@codemirror/view":27}],3:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var view=require('@codemirror/view');var state=require('@codemirror/state');var rangeset=require('@codemirror/rangeset');var text=require('@codemirror/text');var language=require('@codemirror/language');var defaults={brackets:["(","[","{","'",'"'],before:")]}'\":;>"};var closeBracketEffect=state.StateEffect.define({map:function map(value,mapping){var mapped=mapping.mapPos(value,-1,state.MapMode.TrackAfter);return mapped==null?undefined:mapped;}});var skipBracketEffect=state.StateEffect.define({map:function map(value,mapping){return mapping.mapPos(value);}});var closedBracket=new(/*#__PURE__*/function(_rangeset$RangeValue){_inherits(_class3,_rangeset$RangeValue);var _super3=_createSuper(_class3);function _class3(){_classCallCheck(this,_class3);return _super3.apply(this,arguments);}return _createClass(_class3);}(rangeset.RangeValue))();closedBracket.startSide=1;closedBracket.endSide=-1;var bracketState=state.StateField.define({create:function create(){return rangeset.RangeSet.empty;},update:function update(value,tr){if(tr.selection){var lineStart=tr.state.doc.lineAt(tr.selection.main.head).from;var prevLineStart=tr.startState.doc.lineAt(tr.startState.selection.main.head).from;if(lineStart!=tr.changes.mapPos(prevLineStart,-1))value=rangeset.RangeSet.empty;}value=value.map(tr.changes);var _iterator23=_createForOfIteratorHelper(tr.effects),_step23;try{var _loop3=function _loop3(){var effect=_step23.value;if(effect.is(closeBracketEffect))value=value.update({add:[closedBracket.range(effect.value,effect.value+1)]});else if(effect.is(skipBracketEffect))value=value.update({filter:function filter(from){return from!=effect.value;}});};for(_iterator23.s();!(_step23=_iterator23.n()).done;){_loop3();}}catch(err){_iterator23.e(err);}finally{_iterator23.f();}return value;}});/**
194194+Extension to enable bracket-closing behavior. When a closeable
195195+bracket is typed, its closing bracket is immediately inserted
196196+after the cursor. When closing a bracket directly in front of a
197197+closing bracket inserted by the extension, the cursor moves over
198198+that bracket.
199199+*/function closeBrackets(){return[view.EditorView.inputHandler.of(handleInput),bracketState];}var definedClosing="()[]{}<>";function closing(ch){for(var _i7=0;_i7<definedClosing.length;_i7+=2){if(definedClosing.charCodeAt(_i7)==ch)return definedClosing.charAt(_i7+1);}return text.fromCodePoint(ch<128?ch:ch+1);}function config(state,pos){return state.languageDataAt("closeBrackets",pos)[0]||defaults;}function handleInput(view,from,to,insert){if(view.composing)return false;var sel=view.state.selection.main;if(insert.length>2||insert.length==2&&text.codePointSize(text.codePointAt(insert,0))==1||from!=sel.from||to!=sel.to)return false;var tr=insertBracket(view.state,insert);if(!tr)return false;view.dispatch(tr);return true;}/**
200200+Command that implements deleting a pair of matching brackets when
201201+the cursor is between them.
202202+*/var deleteBracketPair=function deleteBracketPair(_ref5){var state$1=_ref5.state,dispatch=_ref5.dispatch;var conf=config(state$1,state$1.selection.main.head);var tokens=conf.brackets||defaults.brackets;var dont=null,changes=state$1.changeByRange(function(range){if(range.empty){var before=prevChar(state$1.doc,range.head);var _iterator24=_createForOfIteratorHelper(tokens),_step24;try{for(_iterator24.s();!(_step24=_iterator24.n()).done;){var token=_step24.value;if(token==before&&nextChar(state$1.doc,range.head)==closing(text.codePointAt(token,0)))return{changes:{from:range.head-token.length,to:range.head+token.length},range:state.EditorSelection.cursor(range.head-token.length),userEvent:"delete.backward"};}}catch(err){_iterator24.e(err);}finally{_iterator24.f();}}return{range:dont=range};});if(!dont)dispatch(state$1.update(changes,{scrollIntoView:true}));return!dont;};/**
203203+Close-brackets related key bindings. Binds Backspace to
204204+[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#closebrackets.deleteBracketPair).
205205+*/var closeBracketsKeymap=[{key:"Backspace",run:deleteBracketPair}];/**
206206+Implements the extension's behavior on text insertion. If the
207207+given string counts as a bracket in the language around the
208208+selection, and replacing the selection with it requires custom
209209+behavior (inserting a closing version or skipping past a
210210+previously-closed bracket), this function returns a transaction
211211+representing that custom behavior. (You only need this if you want
212212+to programmatically insert brackets—the
213213+[`closeBrackets`](https://codemirror.net/6/docs/ref/#closebrackets.closeBrackets) extension will
214214+take care of running this for user input.)
215215+*/function insertBracket(state,bracket){var conf=config(state,state.selection.main.head);var tokens=conf.brackets||defaults.brackets;var _iterator25=_createForOfIteratorHelper(tokens),_step25;try{for(_iterator25.s();!(_step25=_iterator25.n()).done;){var tok=_step25.value;var closed=closing(text.codePointAt(tok,0));if(bracket==tok)return closed==tok?handleSame(state,tok,tokens.indexOf(tok+tok+tok)>-1):handleOpen(state,tok,closed,conf.before||defaults.before);if(bracket==closed&&closedBracketAt(state,state.selection.main.from))return handleClose(state,tok,closed);}}catch(err){_iterator25.e(err);}finally{_iterator25.f();}return null;}function closedBracketAt(state,pos){var found=false;state.field(bracketState).between(0,state.doc.length,function(from){if(from==pos)found=true;});return found;}function nextChar(doc,pos){var next=doc.sliceString(pos,pos+2);return next.slice(0,text.codePointSize(text.codePointAt(next,0)));}function prevChar(doc,pos){var prev=doc.sliceString(pos-2,pos);return text.codePointSize(text.codePointAt(prev,0))==prev.length?prev:prev.slice(1);}function handleOpen(state$1,open,close,closeBefore){var dont=null,changes=state$1.changeByRange(function(range){if(!range.empty)return{changes:[{insert:open,from:range.from},{insert:close,from:range.to}],effects:closeBracketEffect.of(range.to+open.length),range:state.EditorSelection.range(range.anchor+open.length,range.head+open.length)};var next=nextChar(state$1.doc,range.head);if(!next||/\s/.test(next)||closeBefore.indexOf(next)>-1)return{changes:{insert:open+close,from:range.head},effects:closeBracketEffect.of(range.head+open.length),range:state.EditorSelection.cursor(range.head+open.length)};return{range:dont=range};});return dont?null:state$1.update(changes,{scrollIntoView:true,userEvent:"input.type"});}function handleClose(state$1,_open,close){var dont=null,moved=state$1.selection.ranges.map(function(range){if(range.empty&&nextChar(state$1.doc,range.head)==close)return state.EditorSelection.cursor(range.head+close.length);return dont=range;});return dont?null:state$1.update({selection:state.EditorSelection.create(moved,state$1.selection.mainIndex),scrollIntoView:true,effects:state$1.selection.ranges.map(function(_ref6){var from=_ref6.from;return skipBracketEffect.of(from);})});}// Handles cases where the open and close token are the same, and
216216+// possibly triple quotes (as in `"""abc"""`-style quoting).
217217+function handleSame(state$1,token,allowTriple){var dont=null,changes=state$1.changeByRange(function(range){if(!range.empty)return{changes:[{insert:token,from:range.from},{insert:token,from:range.to}],effects:closeBracketEffect.of(range.to+token.length),range:state.EditorSelection.range(range.anchor+token.length,range.head+token.length)};var pos=range.head,next=nextChar(state$1.doc,pos);if(next==token){if(nodeStart(state$1,pos)){return{changes:{insert:token+token,from:pos},effects:closeBracketEffect.of(pos+token.length),range:state.EditorSelection.cursor(pos+token.length)};}else if(closedBracketAt(state$1,pos)){var isTriple=allowTriple&&state$1.sliceDoc(pos,pos+token.length*3)==token+token+token;return{range:state.EditorSelection.cursor(pos+token.length*(isTriple?3:1)),effects:skipBracketEffect.of(pos)};}}else if(allowTriple&&state$1.sliceDoc(pos-2*token.length,pos)==token+token&&nodeStart(state$1,pos-2*token.length)){return{changes:{insert:token+token+token+token,from:pos},effects:closeBracketEffect.of(pos+token.length),range:state.EditorSelection.cursor(pos+token.length)};}else if(state$1.charCategorizer(pos)(next)!=state.CharCategory.Word){var prev=state$1.sliceDoc(pos-1,pos);if(prev!=token&&state$1.charCategorizer(pos)(prev)!=state.CharCategory.Word)return{changes:{insert:token+token,from:pos},effects:closeBracketEffect.of(pos+token.length),range:state.EditorSelection.cursor(pos+token.length)};}return{range:dont=range};});return dont?null:state$1.update(changes,{scrollIntoView:true,userEvent:"input.type"});}function nodeStart(state,pos){var tree=language.syntaxTree(state).resolveInner(pos+1);return tree.parent&&tree.from==pos;}exports.closeBrackets=closeBrackets;exports.closeBracketsKeymap=closeBracketsKeymap;exports.deleteBracketPair=deleteBracketPair;exports.insertBracket=insertBracket;},{"@codemirror/language":13,"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/text":24,"@codemirror/view":27}],4:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var state=require('@codemirror/state');var text=require('@codemirror/text');var view=require('@codemirror/view');var matchbrackets=require('@codemirror/matchbrackets');var language=require('@codemirror/language');var common=require('@lezer/common');function updateSel(sel,by){return state.EditorSelection.create(sel.ranges.map(by),sel.mainIndex);}function setSel(state,selection){return state.update({selection:selection,scrollIntoView:true,userEvent:"select"});}function moveSel(_ref7,how){var state=_ref7.state,dispatch=_ref7.dispatch;var selection=updateSel(state.selection,how);if(selection.eq(state.selection))return false;dispatch(setSel(state,selection));return true;}function rangeEnd(range,forward){return state.EditorSelection.cursor(forward?range.to:range.from);}function cursorByChar(view,forward){return moveSel(view,function(range){return range.empty?view.moveByChar(range,forward):rangeEnd(range,forward);});}/**
218218+Move the selection one character to the left (which is backward in
219219+left-to-right text, forward in right-to-left text).
220220+*/var cursorCharLeft=function cursorCharLeft(view$1){return cursorByChar(view$1,view$1.textDirection!=view.Direction.LTR);};/**
221221+Move the selection one character to the right.
222222+*/var cursorCharRight=function cursorCharRight(view$1){return cursorByChar(view$1,view$1.textDirection==view.Direction.LTR);};/**
223223+Move the selection one character forward.
224224+*/var cursorCharForward=function cursorCharForward(view){return cursorByChar(view,true);};/**
225225+Move the selection one character backward.
226226+*/var cursorCharBackward=function cursorCharBackward(view){return cursorByChar(view,false);};function cursorByGroup(view,forward){return moveSel(view,function(range){return range.empty?view.moveByGroup(range,forward):rangeEnd(range,forward);});}/**
227227+Move the selection to the left across one group of word or
228228+non-word (but also non-space) characters.
229229+*/var cursorGroupLeft=function cursorGroupLeft(view$1){return cursorByGroup(view$1,view$1.textDirection!=view.Direction.LTR);};/**
230230+Move the selection one group to the right.
231231+*/var cursorGroupRight=function cursorGroupRight(view$1){return cursorByGroup(view$1,view$1.textDirection==view.Direction.LTR);};/**
232232+Move the selection one group forward.
233233+*/var cursorGroupForward=function cursorGroupForward(view){return cursorByGroup(view,true);};/**
234234+Move the selection one group backward.
235235+*/var cursorGroupBackward=function cursorGroupBackward(view){return cursorByGroup(view,false);};function moveBySubword(view,range,forward){var categorize=view.state.charCategorizer(range.from);return view.moveByChar(range,forward,function(start){var cat=state.CharCategory.Space,pos=range.from;var done=false,sawUpper=false,sawLower=false;var step=function step(next){if(done)return false;pos+=forward?next.length:-next.length;var nextCat=categorize(next),ahead;if(cat==state.CharCategory.Space)cat=nextCat;if(cat!=nextCat)return false;if(cat==state.CharCategory.Word){if(next.toLowerCase()==next){if(!forward&&sawUpper)return false;sawLower=true;}else if(sawLower){if(forward)return false;done=true;}else{if(sawUpper&&forward&&categorize(ahead=view.state.sliceDoc(pos,pos+1))==state.CharCategory.Word&&ahead.toLowerCase()==ahead)return false;sawUpper=true;}}return true;};step(start);return step;});}function cursorBySubword(view,forward){return moveSel(view,function(range){return range.empty?moveBySubword(view,range,forward):rangeEnd(range,forward);});}/**
236236+Move the selection one group or camel-case subword forward.
237237+*/var cursorSubwordForward=function cursorSubwordForward(view){return cursorBySubword(view,true);};/**
238238+Move the selection one group or camel-case subword backward.
239239+*/var cursorSubwordBackward=function cursorSubwordBackward(view){return cursorBySubword(view,false);};function interestingNode(state,node,bracketProp){if(node.type.prop(bracketProp))return true;var len=node.to-node.from;return len&&(len>2||/[^\s,.;:]/.test(state.sliceDoc(node.from,node.to)))||node.firstChild;}function moveBySyntax(state$1,start,forward){var pos=language.syntaxTree(state$1).resolveInner(start.head);var bracketProp=forward?common.NodeProp.closedBy:common.NodeProp.openedBy;// Scan forward through child nodes to see if there's an interesting
240240+// node ahead.
241241+for(var at=start.head;;){var next=forward?pos.childAfter(at):pos.childBefore(at);if(!next)break;if(interestingNode(state$1,next,bracketProp))pos=next;else at=forward?next.to:next.from;}var bracket=pos.type.prop(bracketProp),match,newPos;if(bracket&&(match=forward?matchbrackets.matchBrackets(state$1,pos.from,1):matchbrackets.matchBrackets(state$1,pos.to,-1))&&match.matched)newPos=forward?match.end.to:match.end.from;else newPos=forward?pos.to:pos.from;return state.EditorSelection.cursor(newPos,forward?-1:1);}/**
242242+Move the cursor over the next syntactic element to the left.
243243+*/var cursorSyntaxLeft=function cursorSyntaxLeft(view$1){return moveSel(view$1,function(range){return moveBySyntax(view$1.state,range,view$1.textDirection!=view.Direction.LTR);});};/**
244244+Move the cursor over the next syntactic element to the right.
245245+*/var cursorSyntaxRight=function cursorSyntaxRight(view$1){return moveSel(view$1,function(range){return moveBySyntax(view$1.state,range,view$1.textDirection==view.Direction.LTR);});};function cursorByLine(view,forward){return moveSel(view,function(range){if(!range.empty)return rangeEnd(range,forward);var moved=view.moveVertically(range,forward);return moved.head!=range.head?moved:view.moveToLineBoundary(range,forward);});}/**
246246+Move the selection one line up.
247247+*/var cursorLineUp=function cursorLineUp(view){return cursorByLine(view,false);};/**
248248+Move the selection one line down.
249249+*/var cursorLineDown=function cursorLineDown(view){return cursorByLine(view,true);};function cursorByPage(view$1,forward){var state=view$1.state,selection=updateSel(state.selection,function(range){return range.empty?view$1.moveVertically(range,forward,view$1.dom.clientHeight):rangeEnd(range,forward);});if(selection.eq(state.selection))return false;var startPos=view$1.coordsAtPos(state.selection.main.head);var scrollRect=view$1.scrollDOM.getBoundingClientRect();view$1.dispatch(setSel(state,selection),{effects:startPos&&startPos.top>scrollRect.top&&startPos.bottom<scrollRect.bottom?view.EditorView.scrollIntoView(selection.main.head,{y:"start",yMargin:startPos.top-scrollRect.top}):undefined});return true;}/**
250250+Move the selection one page up.
251251+*/var cursorPageUp=function cursorPageUp(view){return cursorByPage(view,false);};/**
252252+Move the selection one page down.
253253+*/var cursorPageDown=function cursorPageDown(view){return cursorByPage(view,true);};function moveByLineBoundary(view,start,forward){var line=view.lineBlockAt(start.head),moved=view.moveToLineBoundary(start,forward);if(moved.head==start.head&&moved.head!=(forward?line.to:line.from))moved=view.moveToLineBoundary(start,forward,false);if(!forward&&moved.head==line.from&&line.length){var space=/^\s*/.exec(view.state.sliceDoc(line.from,Math.min(line.from+100,line.to)))[0].length;if(space&&start.head!=line.from+space)moved=state.EditorSelection.cursor(line.from+space);}return moved;}/**
254254+Move the selection to the next line wrap point, or to the end of
255255+the line if there isn't one left on this line.
256256+*/var cursorLineBoundaryForward=function cursorLineBoundaryForward(view){return moveSel(view,function(range){return moveByLineBoundary(view,range,true);});};/**
257257+Move the selection to previous line wrap point, or failing that to
258258+the start of the line. If the line is indented, and the cursor
259259+isn't already at the end of the indentation, this will move to the
260260+end of the indentation instead of the start of the line.
261261+*/var cursorLineBoundaryBackward=function cursorLineBoundaryBackward(view){return moveSel(view,function(range){return moveByLineBoundary(view,range,false);});};/**
262262+Move the selection to the start of the line.
263263+*/var cursorLineStart=function cursorLineStart(view){return moveSel(view,function(range){return state.EditorSelection.cursor(view.lineBlockAt(range.head).from,1);});};/**
264264+Move the selection to the end of the line.
265265+*/var cursorLineEnd=function cursorLineEnd(view){return moveSel(view,function(range){return state.EditorSelection.cursor(view.lineBlockAt(range.head).to,-1);});};function toMatchingBracket(state$1,dispatch,extend){var found=false,selection=updateSel(state$1.selection,function(range){var matching=matchbrackets.matchBrackets(state$1,range.head,-1)||matchbrackets.matchBrackets(state$1,range.head,1)||range.head>0&&matchbrackets.matchBrackets(state$1,range.head-1,1)||range.head<state$1.doc.length&&matchbrackets.matchBrackets(state$1,range.head+1,-1);if(!matching||!matching.end)return range;found=true;var head=matching.start.from==range.head?matching.end.to:matching.end.from;return extend?state.EditorSelection.range(range.anchor,head):state.EditorSelection.cursor(head);});if(!found)return false;dispatch(setSel(state$1,selection));return true;}/**
266266+Move the selection to the bracket matching the one it is currently
267267+on, if any.
268268+*/var cursorMatchingBracket=function cursorMatchingBracket(_ref8){var state=_ref8.state,dispatch=_ref8.dispatch;return toMatchingBracket(state,dispatch,false);};/**
269269+Extend the selection to the bracket matching the one the selection
270270+head is currently on, if any.
271271+*/var selectMatchingBracket=function selectMatchingBracket(_ref9){var state=_ref9.state,dispatch=_ref9.dispatch;return toMatchingBracket(state,dispatch,true);};function extendSel(view,how){var selection=updateSel(view.state.selection,function(range){var head=how(range);return state.EditorSelection.range(range.anchor,head.head,head.goalColumn);});if(selection.eq(view.state.selection))return false;view.dispatch(setSel(view.state,selection));return true;}function selectByChar(view,forward){return extendSel(view,function(range){return view.moveByChar(range,forward);});}/**
272272+Move the selection head one character to the left, while leaving
273273+the anchor in place.
274274+*/var selectCharLeft=function selectCharLeft(view$1){return selectByChar(view$1,view$1.textDirection!=view.Direction.LTR);};/**
275275+Move the selection head one character to the right.
276276+*/var selectCharRight=function selectCharRight(view$1){return selectByChar(view$1,view$1.textDirection==view.Direction.LTR);};/**
277277+Move the selection head one character forward.
278278+*/var selectCharForward=function selectCharForward(view){return selectByChar(view,true);};/**
279279+Move the selection head one character backward.
280280+*/var selectCharBackward=function selectCharBackward(view){return selectByChar(view,false);};function selectByGroup(view,forward){return extendSel(view,function(range){return view.moveByGroup(range,forward);});}/**
281281+Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to
282282+the left.
283283+*/var selectGroupLeft=function selectGroupLeft(view$1){return selectByGroup(view$1,view$1.textDirection!=view.Direction.LTR);};/**
284284+Move the selection head one group to the right.
285285+*/var selectGroupRight=function selectGroupRight(view$1){return selectByGroup(view$1,view$1.textDirection==view.Direction.LTR);};/**
286286+Move the selection head one group forward.
287287+*/var selectGroupForward=function selectGroupForward(view){return selectByGroup(view,true);};/**
288288+Move the selection head one group backward.
289289+*/var selectGroupBackward=function selectGroupBackward(view){return selectByGroup(view,false);};function selectBySubword(view,forward){return extendSel(view,function(range){return moveBySubword(view,range,forward);});}/**
290290+Move the selection head one group or camel-case subword forward.
291291+*/var selectSubwordForward=function selectSubwordForward(view){return selectBySubword(view,true);};/**
292292+Move the selection head one group or subword backward.
293293+*/var selectSubwordBackward=function selectSubwordBackward(view){return selectBySubword(view,false);};/**
294294+Move the selection head over the next syntactic element to the left.
295295+*/var selectSyntaxLeft=function selectSyntaxLeft(view$1){return extendSel(view$1,function(range){return moveBySyntax(view$1.state,range,view$1.textDirection!=view.Direction.LTR);});};/**
296296+Move the selection head over the next syntactic element to the right.
297297+*/var selectSyntaxRight=function selectSyntaxRight(view$1){return extendSel(view$1,function(range){return moveBySyntax(view$1.state,range,view$1.textDirection==view.Direction.LTR);});};function selectByLine(view,forward){return extendSel(view,function(range){return view.moveVertically(range,forward);});}/**
298298+Move the selection head one line up.
299299+*/var selectLineUp=function selectLineUp(view){return selectByLine(view,false);};/**
300300+Move the selection head one line down.
301301+*/var selectLineDown=function selectLineDown(view){return selectByLine(view,true);};function selectByPage(view,forward){return extendSel(view,function(range){return view.moveVertically(range,forward,view.dom.clientHeight);});}/**
302302+Move the selection head one page up.
303303+*/var selectPageUp=function selectPageUp(view){return selectByPage(view,false);};/**
304304+Move the selection head one page down.
305305+*/var selectPageDown=function selectPageDown(view){return selectByPage(view,true);};/**
306306+Move the selection head to the next line boundary.
307307+*/var selectLineBoundaryForward=function selectLineBoundaryForward(view){return extendSel(view,function(range){return moveByLineBoundary(view,range,true);});};/**
308308+Move the selection head to the previous line boundary.
309309+*/var selectLineBoundaryBackward=function selectLineBoundaryBackward(view){return extendSel(view,function(range){return moveByLineBoundary(view,range,false);});};/**
310310+Move the selection head to the start of the line.
311311+*/var selectLineStart=function selectLineStart(view){return extendSel(view,function(range){return state.EditorSelection.cursor(view.lineBlockAt(range.head).from);});};/**
312312+Move the selection head to the end of the line.
313313+*/var selectLineEnd=function selectLineEnd(view){return extendSel(view,function(range){return state.EditorSelection.cursor(view.lineBlockAt(range.head).to);});};/**
314314+Move the selection to the start of the document.
315315+*/var cursorDocStart=function cursorDocStart(_ref10){var state=_ref10.state,dispatch=_ref10.dispatch;dispatch(setSel(state,{anchor:0}));return true;};/**
316316+Move the selection to the end of the document.
317317+*/var cursorDocEnd=function cursorDocEnd(_ref11){var state=_ref11.state,dispatch=_ref11.dispatch;dispatch(setSel(state,{anchor:state.doc.length}));return true;};/**
318318+Move the selection head to the start of the document.
319319+*/var selectDocStart=function selectDocStart(_ref12){var state=_ref12.state,dispatch=_ref12.dispatch;dispatch(setSel(state,{anchor:state.selection.main.anchor,head:0}));return true;};/**
320320+Move the selection head to the end of the document.
321321+*/var selectDocEnd=function selectDocEnd(_ref13){var state=_ref13.state,dispatch=_ref13.dispatch;dispatch(setSel(state,{anchor:state.selection.main.anchor,head:state.doc.length}));return true;};/**
322322+Select the entire document.
323323+*/var selectAll=function selectAll(_ref14){var state=_ref14.state,dispatch=_ref14.dispatch;dispatch(state.update({selection:{anchor:0,head:state.doc.length},userEvent:"select"}));return true;};/**
324324+Expand the selection to cover entire lines.
325325+*/var selectLine=function selectLine(_ref15){var state$1=_ref15.state,dispatch=_ref15.dispatch;var ranges=selectedLineBlocks(state$1).map(function(_ref16){var from=_ref16.from,to=_ref16.to;return state.EditorSelection.range(from,Math.min(to+1,state$1.doc.length));});dispatch(state$1.update({selection:state.EditorSelection.create(ranges),userEvent:"select"}));return true;};/**
326326+Select the next syntactic construct that is larger than the
327327+selection. Note that this will only work insofar as the language
328328+[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
329329+syntax tree.
330330+*/var selectParentSyntax=function selectParentSyntax(_ref17){var state$1=_ref17.state,dispatch=_ref17.dispatch;var selection=updateSel(state$1.selection,function(range){var _a;var context=language.syntaxTree(state$1).resolveInner(range.head,1);while(!(context.from<range.from&&context.to>=range.to||context.to>range.to&&context.from<=range.from||!((_a=context.parent)===null||_a===void 0?void 0:_a.parent))){context=context.parent;}return state.EditorSelection.range(context.to,context.from);});dispatch(setSel(state$1,selection));return true;};/**
331331+Simplify the current selection. When multiple ranges are selected,
332332+reduce it to its main range. Otherwise, if the selection is
333333+non-empty, convert it to a cursor selection.
334334+*/var simplifySelection=function simplifySelection(_ref18){var state$1=_ref18.state,dispatch=_ref18.dispatch;var cur=state$1.selection,selection=null;if(cur.ranges.length>1)selection=state.EditorSelection.create([cur.main]);else if(!cur.main.empty)selection=state.EditorSelection.create([state.EditorSelection.cursor(cur.main.head)]);if(!selection)return false;dispatch(setSel(state$1,selection));return true;};function deleteBy(_ref19,by){var state$1=_ref19.state,dispatch=_ref19.dispatch;if(state$1.readOnly)return false;var event="delete.selection";var changes=state$1.changeByRange(function(range){var from=range.from,to=range.to;if(from==to){var towards=by(from);if(towards<from)event="delete.backward";else if(towards>from)event="delete.forward";from=Math.min(from,towards);to=Math.max(to,towards);}return from==to?{range:range}:{changes:{from:from,to:to},range:state.EditorSelection.cursor(from)};});if(changes.changes.empty)return false;dispatch(state$1.update(changes,{scrollIntoView:true,userEvent:event}));return true;}function skipAtomic(target,pos,forward){if(target instanceof view.EditorView){var _iterator26=_createForOfIteratorHelper(target.pluginField(view.PluginField.atomicRanges)),_step26;try{for(_iterator26.s();!(_step26=_iterator26.n()).done;){var ranges=_step26.value;ranges.between(pos,pos,function(from,to){if(from<pos&&to>pos)pos=forward?to:from;});}}catch(err){_iterator26.e(err);}finally{_iterator26.f();}}return pos;}var deleteByChar=function deleteByChar(target,forward){return deleteBy(target,function(pos){var state=target.state,line=state.doc.lineAt(pos),before,targetPos;if(!forward&&pos>line.from&&pos<line.from+200&&!/[^ \t]/.test(before=line.text.slice(0,pos-line.from))){if(before[before.length-1]=="\t")return pos-1;var col=text.countColumn(before,state.tabSize),drop=col%language.getIndentUnit(state)||language.getIndentUnit(state);for(var _i8=0;_i8<drop&&before[before.length-1-_i8]==" ";_i8++){pos--;}targetPos=pos;}else{targetPos=text.findClusterBreak(line.text,pos-line.from,forward,forward)+line.from;if(targetPos==pos&&line.number!=(forward?state.doc.lines:1))targetPos+=forward?1:-1;}return skipAtomic(target,targetPos,forward);});};/**
335335+Delete the selection, or, for cursor selections, the character
336336+before the cursor.
337337+*/var deleteCharBackward=function deleteCharBackward(view){return deleteByChar(view,false);};/**
338338+Delete the selection or the character after the cursor.
339339+*/var deleteCharForward=function deleteCharForward(view){return deleteByChar(view,true);};var deleteByGroup=function deleteByGroup(target,forward){return deleteBy(target,function(start){var pos=start,state=target.state,line=state.doc.lineAt(pos);var categorize=state.charCategorizer(pos);for(var cat=null;;){if(pos==(forward?line.to:line.from)){if(pos==start&&line.number!=(forward?state.doc.lines:1))pos+=forward?1:-1;break;}var next=text.findClusterBreak(line.text,pos-line.from,forward)+line.from;var nextChar=line.text.slice(Math.min(pos,next)-line.from,Math.max(pos,next)-line.from);var nextCat=categorize(nextChar);if(cat!=null&&nextCat!=cat)break;if(nextChar!=" "||pos!=start)cat=nextCat;pos=next;}return skipAtomic(target,pos,forward);});};/**
340340+Delete the selection or backward until the end of the next
341341+[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
342342+whitespace when they consist of a single space.
343343+*/var deleteGroupBackward=function deleteGroupBackward(target){return deleteByGroup(target,false);};/**
344344+Delete the selection or forward until the end of the next group.
345345+*/var deleteGroupForward=function deleteGroupForward(target){return deleteByGroup(target,true);};/**
346346+Delete the selection, or, if it is a cursor selection, delete to
347347+the end of the line. If the cursor is directly at the end of the
348348+line, delete the line break after it.
349349+*/var deleteToLineEnd=function deleteToLineEnd(view){return deleteBy(view,function(pos){var lineEnd=view.lineBlockAt(pos).to;return skipAtomic(view,pos<lineEnd?lineEnd:Math.min(view.state.doc.length,pos+1),true);});};/**
350350+Delete the selection, or, if it is a cursor selection, delete to
351351+the start of the line. If the cursor is directly at the start of the
352352+line, delete the line break before it.
353353+*/var deleteToLineStart=function deleteToLineStart(view){return deleteBy(view,function(pos){var lineStart=view.lineBlockAt(pos).from;return skipAtomic(view,pos>lineStart?lineStart:Math.max(0,pos-1),false);});};/**
354354+Delete all whitespace directly before a line end from the
355355+document.
356356+*/var deleteTrailingWhitespace=function deleteTrailingWhitespace(_ref20){var state=_ref20.state,dispatch=_ref20.dispatch;if(state.readOnly)return false;var changes=[];for(var pos=0,prev="",iter=state.doc.iter();;){iter.next();if(iter.lineBreak||iter.done){var trailing=prev.search(/\s+$/);if(trailing>-1)changes.push({from:pos-(prev.length-trailing),to:pos});if(iter.done)break;prev="";}else{prev=iter.value;}pos+=iter.value.length;}if(!changes.length)return false;dispatch(state.update({changes:changes,userEvent:"delete"}));return true;};/**
357357+Replace each selection range with a line break, leaving the cursor
358358+on the line before the break.
359359+*/var splitLine=function splitLine(_ref21){var state$1=_ref21.state,dispatch=_ref21.dispatch;if(state$1.readOnly)return false;var changes=state$1.changeByRange(function(range){return{changes:{from:range.from,to:range.to,insert:text.Text.of(["",""])},range:state.EditorSelection.cursor(range.from)};});dispatch(state$1.update(changes,{scrollIntoView:true,userEvent:"input"}));return true;};/**
360360+Flip the characters before and after the cursor(s).
361361+*/var transposeChars=function transposeChars(_ref22){var state$1=_ref22.state,dispatch=_ref22.dispatch;if(state$1.readOnly)return false;var changes=state$1.changeByRange(function(range){if(!range.empty||range.from==0||range.from==state$1.doc.length)return{range:range};var pos=range.from,line=state$1.doc.lineAt(pos);var from=pos==line.from?pos-1:text.findClusterBreak(line.text,pos-line.from,false)+line.from;var to=pos==line.to?pos+1:text.findClusterBreak(line.text,pos-line.from,true)+line.from;return{changes:{from:from,to:to,insert:state$1.doc.slice(pos,to).append(state$1.doc.slice(from,pos))},range:state.EditorSelection.cursor(to)};});if(changes.changes.empty)return false;dispatch(state$1.update(changes,{scrollIntoView:true,userEvent:"move.character"}));return true;};function selectedLineBlocks(state){var blocks=[],upto=-1;var _iterator27=_createForOfIteratorHelper(state.selection.ranges),_step27;try{for(_iterator27.s();!(_step27=_iterator27.n()).done;){var range=_step27.value;var startLine=state.doc.lineAt(range.from),endLine=state.doc.lineAt(range.to);if(!range.empty&&range.to==endLine.from)endLine=state.doc.lineAt(range.to-1);if(upto>=startLine.number){var prev=blocks[blocks.length-1];prev.to=endLine.to;prev.ranges.push(range);}else{blocks.push({from:startLine.from,to:endLine.to,ranges:[range]});}upto=endLine.number+1;}}catch(err){_iterator27.e(err);}finally{_iterator27.f();}return blocks;}function moveLine(state$1,dispatch,forward){if(state$1.readOnly)return false;var changes=[],ranges=[];var _iterator28=_createForOfIteratorHelper(selectedLineBlocks(state$1)),_step28;try{for(_iterator28.s();!(_step28=_iterator28.n()).done;){var block=_step28.value;if(forward?block.to==state$1.doc.length:block.from==0)continue;var nextLine=state$1.doc.lineAt(forward?block.to+1:block.from-1);var size=nextLine.length+1;if(forward){changes.push({from:block.to,to:nextLine.to},{from:block.from,insert:nextLine.text+state$1.lineBreak});var _iterator29=_createForOfIteratorHelper(block.ranges),_step29;try{for(_iterator29.s();!(_step29=_iterator29.n()).done;){var r=_step29.value;ranges.push(state.EditorSelection.range(Math.min(state$1.doc.length,r.anchor+size),Math.min(state$1.doc.length,r.head+size)));}}catch(err){_iterator29.e(err);}finally{_iterator29.f();}}else{changes.push({from:nextLine.from,to:block.from},{from:block.to,insert:state$1.lineBreak+nextLine.text});var _iterator30=_createForOfIteratorHelper(block.ranges),_step30;try{for(_iterator30.s();!(_step30=_iterator30.n()).done;){var _r=_step30.value;ranges.push(state.EditorSelection.range(_r.anchor-size,_r.head-size));}}catch(err){_iterator30.e(err);}finally{_iterator30.f();}}}}catch(err){_iterator28.e(err);}finally{_iterator28.f();}if(!changes.length)return false;dispatch(state$1.update({changes:changes,scrollIntoView:true,selection:state.EditorSelection.create(ranges,state$1.selection.mainIndex),userEvent:"move.line"}));return true;}/**
362362+Move the selected lines up one line.
363363+*/var moveLineUp=function moveLineUp(_ref23){var state=_ref23.state,dispatch=_ref23.dispatch;return moveLine(state,dispatch,false);};/**
364364+Move the selected lines down one line.
365365+*/var moveLineDown=function moveLineDown(_ref24){var state=_ref24.state,dispatch=_ref24.dispatch;return moveLine(state,dispatch,true);};function copyLine(state,dispatch,forward){if(state.readOnly)return false;var changes=[];var _iterator31=_createForOfIteratorHelper(selectedLineBlocks(state)),_step31;try{for(_iterator31.s();!(_step31=_iterator31.n()).done;){var block=_step31.value;if(forward)changes.push({from:block.from,insert:state.doc.slice(block.from,block.to)+state.lineBreak});else changes.push({from:block.to,insert:state.lineBreak+state.doc.slice(block.from,block.to)});}}catch(err){_iterator31.e(err);}finally{_iterator31.f();}dispatch(state.update({changes:changes,scrollIntoView:true,userEvent:"input.copyline"}));return true;}/**
366366+Create a copy of the selected lines. Keep the selection in the top copy.
367367+*/var copyLineUp=function copyLineUp(_ref25){var state=_ref25.state,dispatch=_ref25.dispatch;return copyLine(state,dispatch,false);};/**
368368+Create a copy of the selected lines. Keep the selection in the bottom copy.
369369+*/var copyLineDown=function copyLineDown(_ref26){var state=_ref26.state,dispatch=_ref26.dispatch;return copyLine(state,dispatch,true);};/**
370370+Delete selected lines.
371371+*/var deleteLine=function deleteLine(view){if(view.state.readOnly)return false;var state=view.state,changes=state.changes(selectedLineBlocks(state).map(function(_ref27){var from=_ref27.from,to=_ref27.to;if(from>0)from--;else if(to<state.doc.length)to++;return{from:from,to:to};}));var selection=updateSel(state.selection,function(range){return view.moveVertically(range,true);}).map(changes);view.dispatch({changes:changes,selection:selection,scrollIntoView:true,userEvent:"delete.line"});return true;};/**
372372+Replace the selection with a newline.
373373+*/var insertNewline=function insertNewline(_ref28){var state=_ref28.state,dispatch=_ref28.dispatch;dispatch(state.update(state.replaceSelection(state.lineBreak),{scrollIntoView:true,userEvent:"input"}));return true;};function isBetweenBrackets(state,pos){if(/\(\)|\[\]|\{\}/.test(state.sliceDoc(pos-1,pos+1)))return{from:pos,to:pos};var context=language.syntaxTree(state).resolveInner(pos);var before=context.childBefore(pos),after=context.childAfter(pos),closedBy;if(before&&after&&before.to<=pos&&after.from>=pos&&(closedBy=before.type.prop(common.NodeProp.closedBy))&&closedBy.indexOf(after.name)>-1&&state.doc.lineAt(before.to).from==state.doc.lineAt(after.from).from)return{from:before.to,to:after.from};return null;}/**
374374+Replace the selection with a newline and indent the newly created
375375+line(s). If the current line consists only of whitespace, this
376376+will also delete that whitespace. When the cursor is between
377377+matching brackets, an additional newline will be inserted after
378378+the cursor.
379379+*/var insertNewlineAndIndent=newlineAndIndent(false);/**
380380+Create a blank, indented line below the current line.
381381+*/var insertBlankLine=newlineAndIndent(true);function newlineAndIndent(atEof){return function(_ref29){var state$1=_ref29.state,dispatch=_ref29.dispatch;if(state$1.readOnly)return false;var changes=state$1.changeByRange(function(range){var from=range.from,to=range.to,line=state$1.doc.lineAt(from);var explode=!atEof&&from==to&&isBetweenBrackets(state$1,from);if(atEof)from=to=(to<=line.to?line:state$1.doc.lineAt(to)).to;var cx=new language.IndentContext(state$1,{simulateBreak:from,simulateDoubleBreak:!!explode});var indent=language.getIndentation(cx,from);if(indent==null)indent=/^\s*/.exec(state$1.doc.lineAt(from).text)[0].length;while(to<line.to&&/\s/.test(line.text[to-line.from])){to++;}if(explode){from=explode.from;to=explode.to;}else if(from>line.from&&from<line.from+100&&!/\S/.test(line.text.slice(0,from)))from=line.from;var insert=["",language.indentString(state$1,indent)];if(explode)insert.push(language.indentString(state$1,cx.lineIndent(line.from,-1)));return{changes:{from:from,to:to,insert:text.Text.of(insert)},range:state.EditorSelection.cursor(from+1+insert[1].length)};});dispatch(state$1.update(changes,{scrollIntoView:true,userEvent:"input"}));return true;};}function changeBySelectedLine(state$1,f){var atLine=-1;return state$1.changeByRange(function(range){var changes=[];for(var pos=range.from;pos<=range.to;){var line=state$1.doc.lineAt(pos);if(line.number>atLine&&(range.empty||range.to>line.from)){f(line,changes,range);atLine=line.number;}pos=line.to+1;}var changeSet=state$1.changes(changes);return{changes:changes,range:state.EditorSelection.range(changeSet.mapPos(range.anchor,1),changeSet.mapPos(range.head,1))};});}/**
382382+Auto-indent the selected lines. This uses the [indentation service
383383+facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
384384+information.
385385+*/var indentSelection=function indentSelection(_ref30){var state=_ref30.state,dispatch=_ref30.dispatch;if(state.readOnly)return false;var updated=Object.create(null);var context=new language.IndentContext(state,{overrideIndentation:function overrideIndentation(start){var found=updated[start];return found==null?-1:found;}});var changes=changeBySelectedLine(state,function(line,changes,range){var indent=language.getIndentation(context,line.from);if(indent==null)return;if(!/\S/.test(line.text))indent=0;var cur=/^\s*/.exec(line.text)[0];var norm=language.indentString(state,indent);if(cur!=norm||range.from<line.from+cur.length){updated[line.from]=indent;changes.push({from:line.from,to:line.from+cur.length,insert:norm});}});if(!changes.changes.empty)dispatch(state.update(changes,{userEvent:"indent"}));return true;};/**
386386+Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
387387+lines.
388388+*/var indentMore=function indentMore(_ref31){var state=_ref31.state,dispatch=_ref31.dispatch;if(state.readOnly)return false;dispatch(state.update(changeBySelectedLine(state,function(line,changes){changes.push({from:line.from,insert:state.facet(language.indentUnit)});}),{userEvent:"input.indent"}));return true;};/**
389389+Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
390390+selected lines.
391391+*/var indentLess=function indentLess(_ref32){var state=_ref32.state,dispatch=_ref32.dispatch;if(state.readOnly)return false;dispatch(state.update(changeBySelectedLine(state,function(line,changes){var space=/^\s*/.exec(line.text)[0];if(!space)return;var col=text.countColumn(space,state.tabSize),keep=0;var insert=language.indentString(state,Math.max(0,col-language.getIndentUnit(state)));while(keep<space.length&&keep<insert.length&&space.charCodeAt(keep)==insert.charCodeAt(keep)){keep++;}changes.push({from:line.from+keep,to:line.from+space.length,insert:insert.slice(keep)});}),{userEvent:"delete.dedent"}));return true;};/**
392392+Insert a tab character at the cursor or, if something is selected,
393393+use [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire
394394+selection.
395395+*/var insertTab=function insertTab(_ref33){var state=_ref33.state,dispatch=_ref33.dispatch;if(state.selection.ranges.some(function(r){return!r.empty;}))return indentMore({state:state,dispatch:dispatch});dispatch(state.update(state.replaceSelection("\t"),{scrollIntoView:true,userEvent:"input"}));return true;};/**
396396+Array of key bindings containing the Emacs-style bindings that are
397397+available on macOS by default.
398398+399399+ - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
400400+ - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
401401+ - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
402402+ - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
403403+ - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
404404+ - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
405405+ - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
406406+ - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
407407+ - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)
408408+ - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
409409+ - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)
410410+ - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
411411+ - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
412412+ - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
413413+*/var emacsStyleKeymap=[{key:"Ctrl-b",run:cursorCharLeft,shift:selectCharLeft,preventDefault:true},{key:"Ctrl-f",run:cursorCharRight,shift:selectCharRight},{key:"Ctrl-p",run:cursorLineUp,shift:selectLineUp},{key:"Ctrl-n",run:cursorLineDown,shift:selectLineDown},{key:"Ctrl-a",run:cursorLineStart,shift:selectLineStart},{key:"Ctrl-e",run:cursorLineEnd,shift:selectLineEnd},{key:"Ctrl-d",run:deleteCharForward},{key:"Ctrl-h",run:deleteCharBackward},{key:"Ctrl-k",run:deleteToLineEnd},{key:"Ctrl-Alt-h",run:deleteGroupBackward},{key:"Ctrl-o",run:splitLine},{key:"Ctrl-t",run:transposeChars},{key:"Ctrl-v",run:cursorPageDown}];/**
414414+An array of key bindings closely sticking to platform-standard or
415415+widely used bindings. (This includes the bindings from
416416+[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
417417+property changed to `mac`.)
418418+419419+ - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
420420+ - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
421421+ - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)
422422+ - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)
423423+ - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
424424+ - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
425425+ - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
426426+ - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
427427+ - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
428428+ - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
429429+ - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
430430+ - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
431431+ - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
432432+ - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
433433+ - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)
434434+ - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)
435435+ - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
436436+ - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
437437+ - Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)
438438+ - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)
439439+ - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
440440+ - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
441441+ - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
442442+ - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
443443+ - Cmd-Backspace (macOS): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).
444444+ - Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).
445445+*/var standardKeymap=[{key:"ArrowLeft",run:cursorCharLeft,shift:selectCharLeft,preventDefault:true},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:cursorGroupLeft,shift:selectGroupLeft},{mac:"Cmd-ArrowLeft",run:cursorLineBoundaryBackward,shift:selectLineBoundaryBackward},{key:"ArrowRight",run:cursorCharRight,shift:selectCharRight,preventDefault:true},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:cursorGroupRight,shift:selectGroupRight},{mac:"Cmd-ArrowRight",run:cursorLineBoundaryForward,shift:selectLineBoundaryForward},{key:"ArrowUp",run:cursorLineUp,shift:selectLineUp,preventDefault:true},{mac:"Cmd-ArrowUp",run:cursorDocStart,shift:selectDocStart},{mac:"Ctrl-ArrowUp",run:cursorPageUp,shift:selectPageUp},{key:"ArrowDown",run:cursorLineDown,shift:selectLineDown,preventDefault:true},{mac:"Cmd-ArrowDown",run:cursorDocEnd,shift:selectDocEnd},{mac:"Ctrl-ArrowDown",run:cursorPageDown,shift:selectPageDown},{key:"PageUp",run:cursorPageUp,shift:selectPageUp},{key:"PageDown",run:cursorPageDown,shift:selectPageDown},{key:"Home",run:cursorLineBoundaryBackward,shift:selectLineBoundaryBackward},{key:"Mod-Home",run:cursorDocStart,shift:selectDocStart},{key:"End",run:cursorLineBoundaryForward,shift:selectLineBoundaryForward},{key:"Mod-End",run:cursorDocEnd,shift:selectDocEnd},{key:"Enter",run:insertNewlineAndIndent},{key:"Mod-a",run:selectAll},{key:"Backspace",run:deleteCharBackward,shift:deleteCharBackward},{key:"Delete",run:deleteCharForward},{key:"Mod-Backspace",mac:"Alt-Backspace",run:deleteGroupBackward},{key:"Mod-Delete",mac:"Alt-Delete",run:deleteGroupForward},{mac:"Mod-Backspace",run:deleteToLineStart},{mac:"Mod-Delete",run:deleteToLineEnd}].concat(emacsStyleKeymap.map(function(b){return{mac:b.key,run:b.run,shift:b.shift};}));/**
446446+The default keymap. Includes all bindings from
447447+[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:
448448+449449+- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)
450450+- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)
451451+- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)
452452+- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
453453+- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
454454+- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
455455+- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
456456+- Ctrl-Enter (Comd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
457457+- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
458458+- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)
459459+- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)
460460+- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)
461461+- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)
462462+- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)
463463+- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)
464464+*/var defaultKeymap=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cursorSyntaxLeft,shift:selectSyntaxLeft},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:cursorSyntaxRight,shift:selectSyntaxRight},{key:"Alt-ArrowUp",run:moveLineUp},{key:"Shift-Alt-ArrowUp",run:copyLineUp},{key:"Alt-ArrowDown",run:moveLineDown},{key:"Shift-Alt-ArrowDown",run:copyLineDown},{key:"Escape",run:simplifySelection},{key:"Mod-Enter",run:insertBlankLine},{key:"Alt-l",mac:"Ctrl-l",run:selectLine},{key:"Mod-i",run:selectParentSyntax,preventDefault:true},{key:"Mod-[",run:indentLess},{key:"Mod-]",run:indentMore},{key:"Mod-Alt-\\",run:indentSelection},{key:"Shift-Mod-k",run:deleteLine},{key:"Shift-Mod-\\",run:cursorMatchingBracket}].concat(standardKeymap);/**
465465+A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and
466466+Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).
467467+Please see the [Tab example](../../examples/tab/) before using
468468+this.
469469+*/var indentWithTab={key:"Tab",run:indentMore,shift:indentLess};exports.copyLineDown=copyLineDown;exports.copyLineUp=copyLineUp;exports.cursorCharBackward=cursorCharBackward;exports.cursorCharForward=cursorCharForward;exports.cursorCharLeft=cursorCharLeft;exports.cursorCharRight=cursorCharRight;exports.cursorDocEnd=cursorDocEnd;exports.cursorDocStart=cursorDocStart;exports.cursorGroupBackward=cursorGroupBackward;exports.cursorGroupForward=cursorGroupForward;exports.cursorGroupLeft=cursorGroupLeft;exports.cursorGroupRight=cursorGroupRight;exports.cursorLineBoundaryBackward=cursorLineBoundaryBackward;exports.cursorLineBoundaryForward=cursorLineBoundaryForward;exports.cursorLineDown=cursorLineDown;exports.cursorLineEnd=cursorLineEnd;exports.cursorLineStart=cursorLineStart;exports.cursorLineUp=cursorLineUp;exports.cursorMatchingBracket=cursorMatchingBracket;exports.cursorPageDown=cursorPageDown;exports.cursorPageUp=cursorPageUp;exports.cursorSubwordBackward=cursorSubwordBackward;exports.cursorSubwordForward=cursorSubwordForward;exports.cursorSyntaxLeft=cursorSyntaxLeft;exports.cursorSyntaxRight=cursorSyntaxRight;exports.defaultKeymap=defaultKeymap;exports.deleteCharBackward=deleteCharBackward;exports.deleteCharForward=deleteCharForward;exports.deleteGroupBackward=deleteGroupBackward;exports.deleteGroupForward=deleteGroupForward;exports.deleteLine=deleteLine;exports.deleteToLineEnd=deleteToLineEnd;exports.deleteToLineStart=deleteToLineStart;exports.deleteTrailingWhitespace=deleteTrailingWhitespace;exports.emacsStyleKeymap=emacsStyleKeymap;exports.indentLess=indentLess;exports.indentMore=indentMore;exports.indentSelection=indentSelection;exports.indentWithTab=indentWithTab;exports.insertBlankLine=insertBlankLine;exports.insertNewline=insertNewline;exports.insertNewlineAndIndent=insertNewlineAndIndent;exports.insertTab=insertTab;exports.moveLineDown=moveLineDown;exports.moveLineUp=moveLineUp;exports.selectAll=selectAll;exports.selectCharBackward=selectCharBackward;exports.selectCharForward=selectCharForward;exports.selectCharLeft=selectCharLeft;exports.selectCharRight=selectCharRight;exports.selectDocEnd=selectDocEnd;exports.selectDocStart=selectDocStart;exports.selectGroupBackward=selectGroupBackward;exports.selectGroupForward=selectGroupForward;exports.selectGroupLeft=selectGroupLeft;exports.selectGroupRight=selectGroupRight;exports.selectLine=selectLine;exports.selectLineBoundaryBackward=selectLineBoundaryBackward;exports.selectLineBoundaryForward=selectLineBoundaryForward;exports.selectLineDown=selectLineDown;exports.selectLineEnd=selectLineEnd;exports.selectLineStart=selectLineStart;exports.selectLineUp=selectLineUp;exports.selectMatchingBracket=selectMatchingBracket;exports.selectPageDown=selectPageDown;exports.selectPageUp=selectPageUp;exports.selectParentSyntax=selectParentSyntax;exports.selectSubwordBackward=selectSubwordBackward;exports.selectSubwordForward=selectSubwordForward;exports.selectSyntaxLeft=selectSyntaxLeft;exports.selectSyntaxRight=selectSyntaxRight;exports.simplifySelection=simplifySelection;exports.splitLine=splitLine;exports.standardKeymap=standardKeymap;exports.transposeChars=transposeChars;},{"@codemirror/language":13,"@codemirror/matchbrackets":16,"@codemirror/state":22,"@codemirror/text":24,"@codemirror/view":5,"@lezer/common":28}],5:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var state=require('@codemirror/state');var styleMod=require('style-mod');var rangeset=require('@codemirror/rangeset');var text=require('@codemirror/text');var w3cKeyname=require('w3c-keyname');function getSelection(root){var target;// Browsers differ on whether shadow roots have a getSelection
470470+// method. If it exists, use that, otherwise, call it on the
471471+// document.
472472+if(root.nodeType==11){// Shadow root
473473+target=root.getSelection?root:root.ownerDocument;}else{target=root;}return target.getSelection();}function contains(dom,node){return node?dom.contains(node.nodeType!=1?node.parentNode:node):false;}function deepActiveElement(){var elt=document.activeElement;while(elt&&elt.shadowRoot){elt=elt.shadowRoot.activeElement;}return elt;}function hasSelection(dom,selection){if(!selection.anchorNode)return false;try{// Firefox will raise 'permission denied' errors when accessing
474474+// properties of `sel.anchorNode` when it's in a generated CSS
475475+// element.
476476+return contains(dom,selection.anchorNode);}catch(_){return false;}}function clientRectsFor(dom){if(dom.nodeType==3)return textRange(dom,0,dom.nodeValue.length).getClientRects();else if(dom.nodeType==1)return dom.getClientRects();else return[];}// Scans forward and backward through DOM positions equivalent to the
477477+// given one to see if the two are in the same place (i.e. after a
478478+// text node vs at the end of that text node)
479479+function isEquivalentPosition(node,off,targetNode,targetOff){return targetNode?scanFor(node,off,targetNode,targetOff,-1)||scanFor(node,off,targetNode,targetOff,1):false;}function domIndex(node){for(var index=0;;index++){node=node.previousSibling;if(!node)return index;}}function scanFor(node,off,targetNode,targetOff,dir){for(;;){if(node==targetNode&&off==targetOff)return true;if(off==(dir<0?0:maxOffset(node))){if(node.nodeName=="DIV")return false;var parent=node.parentNode;if(!parent||parent.nodeType!=1)return false;off=domIndex(node)+(dir<0?0:1);node=parent;}else if(node.nodeType==1){node=node.childNodes[off+(dir<0?-1:0)];if(node.nodeType==1&&node.contentEditable=="false")return false;off=dir<0?maxOffset(node):0;}else{return false;}}}function maxOffset(node){return node.nodeType==3?node.nodeValue.length:node.childNodes.length;}var Rect0={left:0,right:0,top:0,bottom:0};function flattenRect(rect,left){var x=left?rect.left:rect.right;return{left:x,right:x,top:rect.top,bottom:rect.bottom};}function windowRect(win){return{left:0,right:win.innerWidth,top:0,bottom:win.innerHeight};}function scrollRectIntoView(dom,rect,side,x,y,xMargin,yMargin,ltr){var doc=dom.ownerDocument,win=doc.defaultView;for(var cur=dom;cur;){if(cur.nodeType==1){// Element
480480+var bounding=void 0,top=cur==doc.body;if(top){bounding=windowRect(win);}else{if(cur.scrollHeight<=cur.clientHeight&&cur.scrollWidth<=cur.clientWidth){cur=cur.parentNode;continue;}var _rect=cur.getBoundingClientRect();// Make sure scrollbar width isn't included in the rectangle
481481+bounding={left:_rect.left,right:_rect.left+cur.clientWidth,top:_rect.top,bottom:_rect.top+cur.clientHeight};}var moveX=0,moveY=0;if(y=="nearest"){if(rect.top<bounding.top){moveY=-(bounding.top-rect.top+yMargin);if(side>0&&rect.bottom>bounding.bottom+moveY)moveY=rect.bottom-bounding.bottom+moveY+yMargin;}else if(rect.bottom>bounding.bottom){moveY=rect.bottom-bounding.bottom+yMargin;if(side<0&&rect.top-moveY<bounding.top)moveY=-(bounding.top+moveY-rect.top+yMargin);}}else{var rectHeight=rect.bottom-rect.top,boundingHeight=bounding.bottom-bounding.top;var targetTop=y=="center"&&rectHeight<=boundingHeight?rect.top+rectHeight/2-boundingHeight/2:y=="start"||y=="center"&&side<0?rect.top-yMargin:rect.bottom-boundingHeight+yMargin;moveY=targetTop-bounding.top;}if(x=="nearest"){if(rect.left<bounding.left){moveX=-(bounding.left-rect.left+xMargin);if(side>0&&rect.right>bounding.right+moveX)moveX=rect.right-bounding.right+moveX+xMargin;}else if(rect.right>bounding.right){moveX=rect.right-bounding.right+xMargin;if(side<0&&rect.left<bounding.left+moveX)moveX=-(bounding.left+moveX-rect.left+xMargin);}}else{var targetLeft=x=="center"?rect.left+(rect.right-rect.left)/2-(bounding.right-bounding.left)/2:x=="start"==ltr?rect.left-xMargin:rect.right-(bounding.right-bounding.left)+xMargin;moveX=targetLeft-bounding.left;}if(moveX||moveY){if(top){win.scrollBy(moveX,moveY);}else{if(moveY){var start=cur.scrollTop;cur.scrollTop+=moveY;moveY=cur.scrollTop-start;}if(moveX){var _start2=cur.scrollLeft;cur.scrollLeft+=moveX;moveX=cur.scrollLeft-_start2;}rect={left:rect.left-moveX,top:rect.top-moveY,right:rect.right-moveX,bottom:rect.bottom-moveY};}}if(top)break;cur=cur.assignedSlot||cur.parentNode;x=y="nearest";}else if(cur.nodeType==11){// A shadow root
482482+cur=cur.host;}else{break;}}}var DOMSelectionState=/*#__PURE__*/function(){function DOMSelectionState(){_classCallCheck(this,DOMSelectionState);this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0;}_createClass(DOMSelectionState,[{key:"eq",value:function eq(domSel){return this.anchorNode==domSel.anchorNode&&this.anchorOffset==domSel.anchorOffset&&this.focusNode==domSel.focusNode&&this.focusOffset==domSel.focusOffset;}},{key:"setRange",value:function setRange(range){this.set(range.anchorNode,range.anchorOffset,range.focusNode,range.focusOffset);}},{key:"set",value:function set(anchorNode,anchorOffset,focusNode,focusOffset){this.anchorNode=anchorNode;this.anchorOffset=anchorOffset;this.focusNode=focusNode;this.focusOffset=focusOffset;}}]);return DOMSelectionState;}();var preventScrollSupported=null;// Feature-detects support for .focus({preventScroll: true}), and uses
483483+// a fallback kludge when not supported.
484484+function focusPreventScroll(dom){if(dom.setActive)return dom.setActive();// in IE
485485+if(preventScrollSupported)return dom.focus(preventScrollSupported);var stack=[];for(var cur=dom;cur;cur=cur.parentNode){stack.push(cur,cur.scrollTop,cur.scrollLeft);if(cur==cur.ownerDocument)break;}dom.focus(preventScrollSupported==null?Object.defineProperties({},{preventScroll:{get:function get(){preventScrollSupported={preventScroll:true};return true;},configurable:true,enumerable:true}}):undefined);if(!preventScrollSupported){preventScrollSupported=false;for(var _i9=0;_i9<stack.length;){var elt=stack[_i9++],top=stack[_i9++],left=stack[_i9++];if(elt.scrollTop!=top)elt.scrollTop=top;if(elt.scrollLeft!=left)elt.scrollLeft=left;}}}var scratchRange;function textRange(node,from){var to=arguments.length>2&&arguments[2]!==undefined?arguments[2]:from;var range=scratchRange||(scratchRange=document.createRange());range.setEnd(node,to);range.setStart(node,from);return range;}function dispatchKey(elt,name,code){var options={key:name,code:name,keyCode:code,which:code,cancelable:true};var down=new KeyboardEvent("keydown",options);down.synthetic=true;elt.dispatchEvent(down);var up=new KeyboardEvent("keyup",options);up.synthetic=true;elt.dispatchEvent(up);return down.defaultPrevented||up.defaultPrevented;}function getRoot(node){while(node){if(node&&(node.nodeType==9||node.nodeType==11&&node.host))return node;node=node.assignedSlot||node.parentNode;}return null;}function clearAttributes(node){while(node.attributes.length){node.removeAttributeNode(node.attributes[0]);}}var DOMPos=/*#__PURE__*/function(){function DOMPos(node,offset){var precise=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;_classCallCheck(this,DOMPos);this.node=node;this.offset=offset;this.precise=precise;}_createClass(DOMPos,null,[{key:"before",value:function before(dom,precise){return new DOMPos(dom.parentNode,domIndex(dom),precise);}},{key:"after",value:function after(dom,precise){return new DOMPos(dom.parentNode,domIndex(dom)+1,precise);}}]);return DOMPos;}();var noChildren=[];var ContentView=/*#__PURE__*/function(){function ContentView(){_classCallCheck(this,ContentView);this.parent=null;this.dom=null;this.dirty=2/* Node */;}_createClass(ContentView,[{key:"editorView",get:function get(){if(!this.parent)throw new Error("Accessing view in orphan content view");return this.parent.editorView;}},{key:"overrideDOMText",get:function get(){return null;}},{key:"posAtStart",get:function get(){return this.parent?this.parent.posBefore(this):0;}},{key:"posAtEnd",get:function get(){return this.posAtStart+this.length;}},{key:"posBefore",value:function posBefore(view){var pos=this.posAtStart;var _iterator32=_createForOfIteratorHelper(this.children),_step32;try{for(_iterator32.s();!(_step32=_iterator32.n()).done;){var child=_step32.value;if(child==view)return pos;pos+=child.length+child.breakAfter;}}catch(err){_iterator32.e(err);}finally{_iterator32.f();}throw new RangeError("Invalid child in posBefore");}},{key:"posAfter",value:function posAfter(view){return this.posBefore(view)+view.length;}// Will return a rectangle directly before (when side < 0), after
486486+// (side > 0) or directly on (when the browser supports it) the
487487+// given position.
488488+},{key:"coordsAt",value:function coordsAt(_pos,_side){return null;}},{key:"sync",value:function sync(track){if(this.dirty&2/* Node */){var parent=this.dom;var pos=parent.firstChild;var _iterator33=_createForOfIteratorHelper(this.children),_step33;try{for(_iterator33.s();!(_step33=_iterator33.n()).done;){var child=_step33.value;if(child.dirty){if(!child.dom&&pos){var contentView=ContentView.get(pos);if(!contentView||!contentView.parent&&contentView.constructor==child.constructor)child.reuseDOM(pos);}child.sync(track);child.dirty=0/* Not */;}if(track&&!track.written&&track.node==parent&&pos!=child.dom)track.written=true;if(child.dom.parentNode==parent){while(pos&&pos!=child.dom){pos=rm(pos);}pos=child.dom.nextSibling;}else{parent.insertBefore(child.dom,pos);}}}catch(err){_iterator33.e(err);}finally{_iterator33.f();}if(pos&&track&&track.node==parent)track.written=true;while(pos){pos=rm(pos);}}else if(this.dirty&1/* Child */){var _iterator34=_createForOfIteratorHelper(this.children),_step34;try{for(_iterator34.s();!(_step34=_iterator34.n()).done;){var _child=_step34.value;if(_child.dirty){_child.sync(track);_child.dirty=0/* Not */;}}}catch(err){_iterator34.e(err);}finally{_iterator34.f();}}}},{key:"reuseDOM",value:function reuseDOM(_dom){}},{key:"localPosFromDOM",value:function localPosFromDOM(node,offset){var after;if(node==this.dom){after=this.dom.childNodes[offset];}else{var bias=maxOffset(node)==0?0:offset==0?-1:1;for(;;){var parent=node.parentNode;if(parent==this.dom)break;if(bias==0&&parent.firstChild!=parent.lastChild){if(node==parent.firstChild)bias=-1;else bias=1;}node=parent;}if(bias<0)after=node;else after=node.nextSibling;}if(after==this.dom.firstChild)return 0;while(after&&!ContentView.get(after)){after=after.nextSibling;}if(!after)return this.length;for(var _i10=0,pos=0;;_i10++){var child=this.children[_i10];if(child.dom==after)return pos;pos+=child.length+child.breakAfter;}}},{key:"domBoundsAround",value:function domBoundsAround(from,to){var offset=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var fromI=-1,fromStart=-1,toI=-1,toEnd=-1;for(var _i11=0,pos=offset,prevEnd=offset;_i11<this.children.length;_i11++){var child=this.children[_i11],end=pos+child.length;if(pos<from&&end>to)return child.domBoundsAround(from,to,pos);if(end>=from&&fromI==-1){fromI=_i11;fromStart=pos;}if(pos>to&&child.dom.parentNode==this.dom){toI=_i11;toEnd=prevEnd;break;}prevEnd=end;pos=end+child.breakAfter;}return{from:fromStart,to:toEnd<0?offset+this.length:toEnd,startDOM:(fromI?this.children[fromI-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:toI<this.children.length&&toI>=0?this.children[toI].dom:null};}},{key:"markDirty",value:function markDirty(){var andParent=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;this.dirty|=2/* Node */;this.markParentsDirty(andParent);}},{key:"markParentsDirty",value:function markParentsDirty(childList){for(var parent=this.parent;parent;parent=parent.parent){if(childList)parent.dirty|=2/* Node */;if(parent.dirty&1/* Child */)return;parent.dirty|=1/* Child */;childList=false;}}},{key:"setParent",value:function setParent(parent){if(this.parent!=parent){this.parent=parent;if(this.dirty)this.markParentsDirty(true);}}},{key:"setDOM",value:function setDOM(dom){if(this.dom)this.dom.cmView=null;this.dom=dom;dom.cmView=this;}},{key:"rootView",get:function get(){for(var v=this;;){var parent=v.parent;if(!parent)return v;v=parent;}}},{key:"replaceChildren",value:function replaceChildren(from,to){var _this$children;var children=arguments.length>2&&arguments[2]!==undefined?arguments[2]:noChildren;this.markDirty();for(var _i12=from;_i12<to;_i12++){var child=this.children[_i12];if(child.parent==this)child.destroy();}(_this$children=this.children).splice.apply(_this$children,[from,to-from].concat(_toConsumableArray(children)));for(var _i13=0;_i13<children.length;_i13++){children[_i13].setParent(this);}}},{key:"ignoreMutation",value:function ignoreMutation(_rec){return false;}},{key:"ignoreEvent",value:function ignoreEvent(_event){return false;}},{key:"childCursor",value:function childCursor(){var pos=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.length;return new ChildCursor(this.children,pos,this.children.length);}},{key:"childPos",value:function childPos(pos){var bias=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;return this.childCursor().findPos(pos,bias);}},{key:"toString",value:function toString(){var name=this.constructor.name.replace("View","");return name+(this.children.length?"("+this.children.join()+")":this.length?"["+(name=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"");}},{key:"isEditable",get:function get(){return true;}},{key:"merge",value:function merge(from,to,source,hasStart,openStart,openEnd){return false;}},{key:"become",value:function become(other){return false;}// When this is a zero-length view with a side, this should return a
489489+// number <= 0 to indicate it is before its position, or a
490490+// number > 0 when after its position.
491491+},{key:"getSide",value:function getSide(){return 0;}},{key:"destroy",value:function destroy(){this.parent=null;}}],[{key:"get",value:function get(node){return node.cmView;}}]);return ContentView;}();ContentView.prototype.breakAfter=0;// Remove a DOM node and return its next sibling.
492492+function rm(dom){var next=dom.nextSibling;dom.parentNode.removeChild(dom);return next;}var ChildCursor=/*#__PURE__*/function(){function ChildCursor(children,pos,i){_classCallCheck(this,ChildCursor);this.children=children;this.pos=pos;this.i=i;this.off=0;}_createClass(ChildCursor,[{key:"findPos",value:function findPos(pos){var bias=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;for(;;){if(pos>this.pos||pos==this.pos&&(bias>0||this.i==0||this.children[this.i-1].breakAfter)){this.off=pos-this.pos;return this;}var next=this.children[--this.i];this.pos-=next.length+next.breakAfter;}}}]);return ChildCursor;}();function replaceRange(parent,fromI,fromOff,toI,toOff,insert,breakAtStart,openStart,openEnd){var children=parent.children;var before=children.length?children[fromI]:null;var last=insert.length?insert[insert.length-1]:null;var breakAtEnd=last?last.breakAfter:breakAtStart;// Change within a single child
493493+if(fromI==toI&&before&&!breakAtStart&&!breakAtEnd&&insert.length<2&&before.merge(fromOff,toOff,insert.length?last:null,fromOff==0,openStart,openEnd))return;if(toI<children.length){var after=children[toI];// Make sure the end of the child after the update is preserved in `after`
494494+if(after&&toOff<after.length){// If we're splitting a child, separate part of it to avoid that
495495+// being mangled when updating the child before the update.
496496+if(fromI==toI){after=after.split(toOff);toOff=0;}// If the element after the replacement should be merged with
497497+// the last replacing element, update `content`
498498+if(!breakAtEnd&&last&&after.merge(0,toOff,last,true,0,openEnd)){insert[insert.length-1]=after;}else{// Remove the start of the after element, if necessary, and
499499+// add it to `content`.
500500+if(toOff)after.merge(0,toOff,null,false,0,openEnd);insert.push(after);}}else if(after===null||after===void 0?void 0:after.breakAfter){// The element at `toI` is entirely covered by this range.
501501+// Preserve its line break, if any.
502502+if(last)last.breakAfter=1;else breakAtStart=1;}// Since we've handled the next element from the current elements
503503+// now, make sure `toI` points after that.
504504+toI++;}if(before){before.breakAfter=breakAtStart;if(fromOff>0){if(!breakAtStart&&insert.length&&before.merge(fromOff,before.length,insert[0],false,openStart,0)){before.breakAfter=insert.shift().breakAfter;}else if(fromOff<before.length||before.children.length&&before.children[before.children.length-1].length==0){before.merge(fromOff,before.length,null,false,openStart,0);}fromI++;}}// Try to merge widgets on the boundaries of the replacement
505505+while(fromI<toI&&insert.length){if(children[toI-1].become(insert[insert.length-1])){toI--;insert.pop();openEnd=insert.length?0:openStart;}else if(children[fromI].become(insert[0])){fromI++;insert.shift();openStart=insert.length?0:openEnd;}else{break;}}if(!insert.length&&fromI&&toI<children.length&&!children[fromI-1].breakAfter&&children[toI].merge(0,0,children[fromI-1],false,openStart,openEnd))fromI--;if(fromI<toI||insert.length)parent.replaceChildren(fromI,toI,insert);}function mergeChildrenInto(parent,from,to,insert,openStart,openEnd){var cur=parent.childCursor();var _cur$findPos=cur.findPos(to,1),toI=_cur$findPos.i,toOff=_cur$findPos.off;var _cur$findPos2=cur.findPos(from,-1),fromI=_cur$findPos2.i,fromOff=_cur$findPos2.off;var dLen=from-to;var _iterator35=_createForOfIteratorHelper(insert),_step35;try{for(_iterator35.s();!(_step35=_iterator35.n()).done;){var view=_step35.value;dLen+=view.length;}}catch(err){_iterator35.e(err);}finally{_iterator35.f();}parent.length+=dLen;replaceRange(parent,fromI,fromOff,toI,toOff,insert,0,openStart,openEnd);}var _ref34=typeof navigator!="undefined"?[navigator,document]:[{userAgent:"",vendor:"",platform:""},{documentElement:{style:{}}}],_ref35=_slicedToArray(_ref34,2),nav=_ref35[0],doc=_ref35[1];var ie_edge=/Edge\/(\d+)/.exec(nav.userAgent);var ie_upto10=/MSIE \d/.test(nav.userAgent);var ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);var ie=!!(ie_upto10||ie_11up||ie_edge);var gecko=!ie&&/gecko\/(\d+)/i.test(nav.userAgent);var chrome=!ie&&/Chrome\/(\d+)/.exec(nav.userAgent);var webkit=("webkitFontSmoothing"in doc.documentElement.style);var safari=!ie&&/Apple Computer/.test(nav.vendor);var ios=safari&&(/Mobile\/\w+/.test(nav.userAgent)||nav.maxTouchPoints>2);var browser={mac:ios||/Mac/.test(nav.platform),windows:/Win/.test(nav.platform),linux:/Linux|X11/.test(nav.platform),ie:ie,ie_version:ie_upto10?doc.documentMode||6:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko:gecko,gecko_version:gecko?+(/Firefox\/(\d+)/.exec(nav.userAgent)||[0,0])[1]:0,chrome:!!chrome,chrome_version:chrome?+chrome[1]:0,ios:ios,android:/Android\b/.test(nav.userAgent),webkit:webkit,safari:safari,webkit_version:webkit?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:doc.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};var MaxJoinLen=256;var TextView=/*#__PURE__*/function(_ContentView){_inherits(TextView,_ContentView);var _super4=_createSuper(TextView);function TextView(text){var _this12;_classCallCheck(this,TextView);_this12=_super4.call(this);_this12.text=text;return _this12;}_createClass(TextView,[{key:"length",get:function get(){return this.text.length;}},{key:"createDOM",value:function createDOM(textDOM){this.setDOM(textDOM||document.createTextNode(this.text));}},{key:"sync",value:function sync(track){if(!this.dom)this.createDOM();if(this.dom.nodeValue!=this.text){if(track&&track.node==this.dom)track.written=true;this.dom.nodeValue=this.text;}}},{key:"reuseDOM",value:function reuseDOM(dom){if(dom.nodeType==3)this.createDOM(dom);}},{key:"merge",value:function merge(from,to,source){if(source&&(!(source instanceof TextView)||this.length-(to-from)+source.length>MaxJoinLen))return false;this.text=this.text.slice(0,from)+(source?source.text:"")+this.text.slice(to);this.markDirty();return true;}},{key:"split",value:function split(from){var result=new TextView(this.text.slice(from));this.text=this.text.slice(0,from);this.markDirty();return result;}},{key:"localPosFromDOM",value:function localPosFromDOM(node,offset){return node==this.dom?offset:offset?this.text.length:0;}},{key:"domAtPos",value:function domAtPos(pos){return new DOMPos(this.dom,pos);}},{key:"domBoundsAround",value:function domBoundsAround(_from,_to,offset){return{from:offset,to:offset+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling};}},{key:"coordsAt",value:function coordsAt(pos,side){return textCoords(this.dom,pos,side);}}]);return TextView;}(ContentView);var MarkView=/*#__PURE__*/function(_ContentView2){_inherits(MarkView,_ContentView2);var _super5=_createSuper(MarkView);function MarkView(mark){var _this13;var children=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var length=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;_classCallCheck(this,MarkView);_this13=_super5.call(this);_this13.mark=mark;_this13.children=children;_this13.length=length;var _iterator36=_createForOfIteratorHelper(children),_step36;try{for(_iterator36.s();!(_step36=_iterator36.n()).done;){var ch=_step36.value;ch.setParent(_assertThisInitialized(_this13));}}catch(err){_iterator36.e(err);}finally{_iterator36.f();}return _this13;}_createClass(MarkView,[{key:"setAttrs",value:function setAttrs(dom){clearAttributes(dom);if(this.mark["class"])dom.className=this.mark["class"];if(this.mark.attrs)for(var name in this.mark.attrs){dom.setAttribute(name,this.mark.attrs[name]);}return dom;}},{key:"reuseDOM",value:function reuseDOM(node){if(node.nodeName==this.mark.tagName.toUpperCase()){this.setDOM(node);this.dirty|=4/* Attrs */|2/* Node */;}}},{key:"sync",value:function sync(track){if(!this.dom)this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));else if(this.dirty&4/* Attrs */)this.setAttrs(this.dom);_get(_getPrototypeOf(MarkView.prototype),"sync",this).call(this,track);}},{key:"merge",value:function merge(from,to,source,_hasStart,openStart,openEnd){if(source&&(!(source instanceof MarkView&&source.mark.eq(this.mark))||from&&openStart<=0||to<this.length&&openEnd<=0))return false;mergeChildrenInto(this,from,to,source?source.children:[],openStart-1,openEnd-1);this.markDirty();return true;}},{key:"split",value:function split(from){var result=[],off=0,detachFrom=-1,i=0;var _iterator37=_createForOfIteratorHelper(this.children),_step37;try{for(_iterator37.s();!(_step37=_iterator37.n()).done;){var elt=_step37.value;var end=off+elt.length;if(end>from)result.push(off<from?elt.split(from-off):elt);if(detachFrom<0&&off>=from)detachFrom=i;off=end;i++;}}catch(err){_iterator37.e(err);}finally{_iterator37.f();}var length=this.length-from;this.length=from;if(detachFrom>-1){this.children.length=detachFrom;this.markDirty();}return new MarkView(this.mark,result,length);}},{key:"domAtPos",value:function domAtPos(pos){return inlineDOMAtPos(this.dom,this.children,pos);}},{key:"coordsAt",value:function coordsAt(pos,side){return coordsInChildren(this,pos,side);}}]);return MarkView;}(ContentView);function textCoords(text,pos,side){var length=text.nodeValue.length;if(pos>length)pos=length;var from=pos,to=pos,flatten=0;if(pos==0&&side<0||pos==length&&side>=0){if(!(browser.chrome||browser.gecko)){// These browsers reliably return valid rectangles for empty ranges
506506+if(pos){from--;flatten=1;}// FIXME this is wrong in RTL text
507507+else{to++;flatten=-1;}}}else{if(side<0)from--;else to++;}var rects=textRange(text,from,to).getClientRects();if(!rects.length)return Rect0;var rect=rects[(flatten?flatten<0:side>=0)?0:rects.length-1];if(browser.safari&&!flatten&&rect.width==0)rect=Array.prototype.find.call(rects,function(r){return r.width;})||rect;return flatten?flattenRect(rect,flatten<0):rect||null;}// Also used for collapsed ranges that don't have a placeholder widget!
508508+var WidgetView=/*#__PURE__*/function(_ContentView3){_inherits(WidgetView,_ContentView3);var _super6=_createSuper(WidgetView);function WidgetView(widget,length,side){var _this14;_classCallCheck(this,WidgetView);_this14=_super6.call(this);_this14.widget=widget;_this14.length=length;_this14.side=side;return _this14;}_createClass(WidgetView,[{key:"split",value:function split(from){var result=WidgetView.create(this.widget,this.length-from,this.side);this.length-=from;return result;}},{key:"sync",value:function sync(){if(!this.dom||!this.widget.updateDOM(this.dom)){this.setDOM(this.widget.toDOM(this.editorView));this.dom.contentEditable="false";}}},{key:"getSide",value:function getSide(){return this.side;}},{key:"merge",value:function merge(from,to,source,hasStart,openStart,openEnd){if(source&&(!(source instanceof WidgetView)||!this.widget.compare(source.widget)||from>0&&openStart<=0||to<this.length&&openEnd<=0))return false;this.length=from+(source?source.length:0)+(this.length-to);return true;}},{key:"become",value:function become(other){if(other.length==this.length&&other instanceof WidgetView&&other.side==this.side){if(this.widget.constructor==other.widget.constructor){if(!this.widget.eq(other.widget))this.markDirty(true);this.widget=other.widget;return true;}}return false;}},{key:"ignoreMutation",value:function ignoreMutation(){return true;}},{key:"ignoreEvent",value:function ignoreEvent(event){return this.widget.ignoreEvent(event);}},{key:"overrideDOMText",get:function get(){if(this.length==0)return text.Text.empty;var top=this;while(top.parent){top=top.parent;}var view=top.editorView,text$1=view&&view.state.doc,start=this.posAtStart;return text$1?text$1.slice(start,start+this.length):text.Text.empty;}},{key:"domAtPos",value:function domAtPos(pos){return pos==0?DOMPos.before(this.dom):DOMPos.after(this.dom,pos==this.length);}},{key:"domBoundsAround",value:function domBoundsAround(){return null;}},{key:"coordsAt",value:function coordsAt(pos,side){var rects=this.dom.getClientRects(),rect=null;if(!rects.length)return Rect0;for(var _i14=pos>0?rects.length-1:0;;_i14+=pos>0?-1:1){rect=rects[_i14];if(pos>0?_i14==0:_i14==rects.length-1||rect.top<rect.bottom)break;}return pos==0&&side>0||pos==this.length&&side<=0?rect:flattenRect(rect,pos==0);}},{key:"isEditable",get:function get(){return false;}},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(WidgetView.prototype),"destroy",this).call(this);if(this.dom)this.widget.destroy(this.dom);}}],[{key:"create",value:function create(widget,length,side){return new(widget.customView||WidgetView)(widget,length,side);}}]);return WidgetView;}(ContentView);var CompositionView=/*#__PURE__*/function(_WidgetView){_inherits(CompositionView,_WidgetView);var _super7=_createSuper(CompositionView);function CompositionView(){_classCallCheck(this,CompositionView);return _super7.apply(this,arguments);}_createClass(CompositionView,[{key:"domAtPos",value:function domAtPos(pos){return new DOMPos(this.widget.text,pos);}},{key:"sync",value:function sync(){this.setDOM(this.widget.toDOM());}},{key:"localPosFromDOM",value:function localPosFromDOM(node,offset){return!offset?0:node.nodeType==3?Math.min(offset,this.length):this.length;}},{key:"ignoreMutation",value:function ignoreMutation(){return false;}},{key:"overrideDOMText",get:function get(){return null;}},{key:"coordsAt",value:function coordsAt(pos,side){return textCoords(this.widget.text,pos,side);}},{key:"isEditable",get:function get(){return true;}}]);return CompositionView;}(WidgetView);// Use two characters on Android, to prevent Chrome from closing the
509509+// virtual keyboard when backspacing after a widget (#602).
510510+var ZeroWidthSpace=browser.android?"\u200B\u200B":"\u200B";// These are drawn around uneditable widgets to avoid a number of
511511+// browser bugs that show up when the cursor is directly next to
512512+// uneditable inline content.
513513+var WidgetBufferView=/*#__PURE__*/function(_ContentView4){_inherits(WidgetBufferView,_ContentView4);var _super8=_createSuper(WidgetBufferView);function WidgetBufferView(side){var _this15;_classCallCheck(this,WidgetBufferView);_this15=_super8.call(this);_this15.side=side;return _this15;}_createClass(WidgetBufferView,[{key:"length",get:function get(){return 0;}},{key:"merge",value:function merge(){return false;}},{key:"become",value:function become(other){return other instanceof WidgetBufferView&&other.side==this.side;}},{key:"split",value:function split(){return new WidgetBufferView(this.side);}},{key:"sync",value:function sync(){if(!this.dom)this.setDOM(document.createTextNode(ZeroWidthSpace));else if(this.dirty&&this.dom.nodeValue!=ZeroWidthSpace)this.dom.nodeValue=ZeroWidthSpace;}},{key:"getSide",value:function getSide(){return this.side;}},{key:"domAtPos",value:function domAtPos(pos){return DOMPos.before(this.dom);}},{key:"localPosFromDOM",value:function localPosFromDOM(){return 0;}},{key:"domBoundsAround",value:function domBoundsAround(){return null;}},{key:"coordsAt",value:function coordsAt(pos){var rects=clientRectsFor(this.dom);return rects[rects.length-1]||null;}},{key:"overrideDOMText",get:function get(){return text.Text.of([this.dom.nodeValue.replace(/\u200b/g,"")]);}}]);return WidgetBufferView;}(ContentView);TextView.prototype.children=WidgetView.prototype.children=WidgetBufferView.prototype.children=noChildren;function inlineDOMAtPos(dom,children,pos){var i=0;for(var off=0;i<children.length;i++){var child=children[i],end=off+child.length;if(end==off&&child.getSide()<=0)continue;if(pos>off&&pos<end&&child.dom.parentNode==dom)return child.domAtPos(pos-off);if(pos<=off)break;off=end;}for(;i>0;i--){var before=children[i-1].dom;if(before.parentNode==dom)return DOMPos.after(before);}return new DOMPos(dom,0);}// Assumes `view`, if a mark view, has precisely 1 child.
514514+function joinInlineInto(parent,view,open){var last,children=parent.children;if(open>0&&view instanceof MarkView&&children.length&&(last=children[children.length-1])instanceof MarkView&&last.mark.eq(view.mark)){joinInlineInto(last,view.children[0],open-1);}else{children.push(view);view.setParent(parent);}parent.length+=view.length;}function coordsInChildren(view,pos,side){for(var off=0,_i15=0;_i15<view.children.length;_i15++){var child=view.children[_i15],end=off+child.length,next=void 0;if((side<=0||end==view.length||child.getSide()>0?end>=pos:end>pos)&&(pos<end||_i15+1==view.children.length||(next=view.children[_i15+1]).length||next.getSide()>0)){var flatten=0;if(end==off){if(child.getSide()<=0)continue;flatten=side=-child.getSide();}var rect=child.coordsAt(pos-off,side);return flatten&&rect?flattenRect(rect,side<0):rect;}off=end;}var last=view.dom.lastChild;if(!last)return view.dom.getBoundingClientRect();var rects=clientRectsFor(last);return rects[rects.length-1]||null;}function combineAttrs(source,target){for(var name in source){if(name=="class"&&target["class"])target["class"]+=" "+source["class"];else if(name=="style"&&target.style)target.style+=";"+source.style;else target[name]=source[name];}return target;}function attrsEq(a,b){if(a==b)return true;if(!a||!b)return false;var keysA=Object.keys(a),keysB=Object.keys(b);if(keysA.length!=keysB.length)return false;for(var _i16=0,_keysA=keysA;_i16<_keysA.length;_i16++){var key=_keysA[_i16];if(keysB.indexOf(key)==-1||a[key]!==b[key])return false;}return true;}function _updateAttrs(dom,prev,attrs){if(prev)for(var name in prev){if(!(attrs&&name in attrs))dom.removeAttribute(name);}if(attrs)for(var _name in attrs){if(!(prev&&prev[_name]==attrs[_name]))dom.setAttribute(_name,attrs[_name]);}}/**
515515+Widgets added to the content are described by subclasses of this
516516+class. Using a description object like that makes it possible to
517517+delay creating of the DOM structure for a widget until it is
518518+needed, and to avoid redrawing widgets even when the decorations
519519+that define them are recreated.
520520+*/var WidgetType=/*#__PURE__*/function(){function WidgetType(){_classCallCheck(this,WidgetType);}_createClass(WidgetType,[{key:"eq",value:/**
521521+ Compare this instance to another instance of the same type.
522522+ (TypeScript can't express this, but only instances of the same
523523+ specific class will be passed to this method.) This is used to
524524+ avoid redrawing widgets when they are replaced by a new
525525+ decoration of the same type. The default implementation just
526526+ returns `false`, which will cause new instances of the widget to
527527+ always be redrawn.
528528+ */function eq(_widget){return false;}/**
529529+ Update a DOM element created by a widget of the same type (but
530530+ different, non-`eq` content) to reflect this widget. May return
531531+ true to indicate that it could update, false to indicate it
532532+ couldn't (in which case the widget will be redrawn). The default
533533+ implementation just returns false.
534534+ */},{key:"updateDOM",value:function updateDOM(_dom){return false;}/**
535535+ @internal
536536+ */},{key:"compare",value:function compare(other){return this==other||this.constructor==other.constructor&&this.eq(other);}/**
537537+ The estimated height this widget will have, to be used when
538538+ estimating the height of content that hasn't been drawn. May
539539+ return -1 to indicate you don't know. The default implementation
540540+ returns -1.
541541+ */},{key:"estimatedHeight",get:function get(){return-1;}/**
542542+ Can be used to configure which kinds of events inside the widget
543543+ should be ignored by the editor. The default is to ignore all
544544+ events.
545545+ */},{key:"ignoreEvent",value:function ignoreEvent(_event){return true;}/**
546546+ @internal
547547+ */},{key:"customView",get:function get(){return null;}/**
548548+ This is called when the an instance of the widget is removed
549549+ from the editor view.
550550+ */},{key:"destroy",value:function destroy(_dom){}}]);return WidgetType;}();/**
551551+The different types of blocks that can occur in an editor view.
552552+*/exports.BlockType=void 0;(function(BlockType){/**
553553+ A line of text.
554554+ */BlockType[BlockType["Text"]=0]="Text";/**
555555+ A block widget associated with the position after it.
556556+ */BlockType[BlockType["WidgetBefore"]=1]="WidgetBefore";/**
557557+ A block widget associated with the position before it.
558558+ */BlockType[BlockType["WidgetAfter"]=2]="WidgetAfter";/**
559559+ A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
560560+ */BlockType[BlockType["WidgetRange"]=3]="WidgetRange";})(exports.BlockType||(exports.BlockType={}));/**
561561+A decoration provides information on how to draw or style a piece
562562+of content. You'll usually use it wrapped in a
563563+[`Range`](https://codemirror.net/6/docs/ref/#rangeset.Range), which adds a start and end position.
564564+*/var Decoration=/*#__PURE__*/function(_rangeset$RangeValue2){_inherits(Decoration,_rangeset$RangeValue2);var _super9=_createSuper(Decoration);/**
565565+ @internal
566566+ */function Decoration(/**
567567+ @internal
568568+ */startSide,/**
569569+ @internal
570570+ */endSide,/**
571571+ @internal
572572+ */widget,/**
573573+ The config object used to create this decoration. You can
574574+ include additional properties in there to store metadata about
575575+ your decoration.
576576+ */spec){var _this16;_classCallCheck(this,Decoration);_this16=_super9.call(this);_this16.startSide=startSide;_this16.endSide=endSide;_this16.widget=widget;_this16.spec=spec;return _this16;}/**
577577+ @internal
578578+ */_createClass(Decoration,[{key:"heightRelevant",get:function get(){return false;}/**
579579+ Create a mark decoration, which influences the styling of the
580580+ content in its range. Nested mark decorations will cause nested
581581+ DOM elements to be created. Nesting order is determined by
582582+ precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations) or
583583+ (below the facet-provided decorations) [view
584584+ plugin](https://codemirror.net/6/docs/ref/#view.PluginSpec.decorations). Such elements are split
585585+ on line boundaries and on the boundaries of higher-precedence
586586+ decorations.
587587+ */},{key:"hasHeight",value:/**
588588+ @internal
589589+ */function hasHeight(){return this.widget?this.widget.estimatedHeight>-1:false;}}],[{key:"mark",value:function mark(spec){return new MarkDecoration(spec);}/**
590590+ Create a widget decoration, which adds an element at the given
591591+ position.
592592+ */},{key:"widget",value:function widget(spec){var side=spec.side||0,block=!!spec.block;side+=block?side>0?300000000/* BlockAfter */:-400000000/* BlockBefore */:side>0?100000000/* InlineAfter */:-100000000/* InlineBefore */;return new PointDecoration(spec,side,side,block,spec.widget||null,false);}/**
593593+ Create a replace decoration which replaces the given range with
594594+ a widget, or simply hides it.
595595+ */},{key:"replace",value:function replace(spec){var block=!!spec.block;var _getInclusive=getInclusive(spec,block),start=_getInclusive.start,end=_getInclusive.end;var startSide=block?start?-300000000/* BlockIncStart */:-1/* InlineIncStart */:400000000/* NonIncStart */;var endSide=block?end?200000000/* BlockIncEnd */:1/* InlineIncEnd */:-500000000/* NonIncEnd */;return new PointDecoration(spec,startSide,endSide,block,spec.widget||null,true);}/**
596596+ Create a line decoration, which can add DOM attributes to the
597597+ line starting at the given position.
598598+ */},{key:"line",value:function line(spec){return new LineDecoration(spec);}/**
599599+ Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
600600+ decorated range or ranges. If the ranges aren't already sorted,
601601+ pass `true` for `sort` to make the library sort them for you.
602602+ */},{key:"set",value:function set(of){var sort=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return rangeset.RangeSet.of(of,sort);}}]);return Decoration;}(rangeset.RangeValue);/**
603603+The empty set of decorations.
604604+*/Decoration.none=rangeset.RangeSet.empty;var MarkDecoration=/*#__PURE__*/function(_Decoration){_inherits(MarkDecoration,_Decoration);var _super10=_createSuper(MarkDecoration);function MarkDecoration(spec){var _this17;_classCallCheck(this,MarkDecoration);var _getInclusive2=getInclusive(spec),start=_getInclusive2.start,end=_getInclusive2.end;_this17=_super10.call(this,start?-1/* InlineIncStart */:400000000/* NonIncStart */,end?1/* InlineIncEnd */:-500000000/* NonIncEnd */,null,spec);_this17.tagName=spec.tagName||"span";_this17["class"]=spec["class"]||"";_this17.attrs=spec.attributes||null;return _this17;}_createClass(MarkDecoration,[{key:"eq",value:function eq(other){return this==other||other instanceof MarkDecoration&&this.tagName==other.tagName&&this["class"]==other["class"]&&attrsEq(this.attrs,other.attrs);}},{key:"range",value:function range(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:from;if(from>=to)throw new RangeError("Mark decorations may not be empty");return _get(_getPrototypeOf(MarkDecoration.prototype),"range",this).call(this,from,to);}}]);return MarkDecoration;}(Decoration);MarkDecoration.prototype.point=false;var LineDecoration=/*#__PURE__*/function(_Decoration2){_inherits(LineDecoration,_Decoration2);var _super11=_createSuper(LineDecoration);function LineDecoration(spec){_classCallCheck(this,LineDecoration);return _super11.call(this,-200000000/* Line */,-200000000/* Line */,null,spec);}_createClass(LineDecoration,[{key:"eq",value:function eq(other){return other instanceof LineDecoration&&attrsEq(this.spec.attributes,other.spec.attributes);}},{key:"range",value:function range(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:from;if(to!=from)throw new RangeError("Line decoration ranges must be zero-length");return _get(_getPrototypeOf(LineDecoration.prototype),"range",this).call(this,from,to);}}]);return LineDecoration;}(Decoration);LineDecoration.prototype.mapMode=state.MapMode.TrackBefore;LineDecoration.prototype.point=true;var PointDecoration=/*#__PURE__*/function(_Decoration3){_inherits(PointDecoration,_Decoration3);var _super12=_createSuper(PointDecoration);function PointDecoration(spec,startSide,endSide,block,widget,isReplace){var _this18;_classCallCheck(this,PointDecoration);_this18=_super12.call(this,startSide,endSide,widget,spec);_this18.block=block;_this18.isReplace=isReplace;_this18.mapMode=!block?state.MapMode.TrackDel:startSide<=0?state.MapMode.TrackBefore:state.MapMode.TrackAfter;return _this18;}// Only relevant when this.block == true
605605+_createClass(PointDecoration,[{key:"type",get:function get(){return this.startSide<this.endSide?exports.BlockType.WidgetRange:this.startSide<=0?exports.BlockType.WidgetBefore:exports.BlockType.WidgetAfter;}},{key:"heightRelevant",get:function get(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5;}},{key:"eq",value:function eq(other){return other instanceof PointDecoration&&widgetsEq(this.widget,other.widget)&&this.block==other.block&&this.startSide==other.startSide&&this.endSide==other.endSide;}},{key:"range",value:function range(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:from;if(this.isReplace&&(from>to||from==to&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&to!=from)throw new RangeError("Widget decorations can only have zero-length ranges");return _get(_getPrototypeOf(PointDecoration.prototype),"range",this).call(this,from,to);}}]);return PointDecoration;}(Decoration);PointDecoration.prototype.point=true;function getInclusive(spec){var block=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var start=spec.inclusiveStart,end=spec.inclusiveEnd;if(start==null)start=spec.inclusive;if(end==null)end=spec.inclusive;return{start:start!==null&&start!==void 0?start:block,end:end!==null&&end!==void 0?end:block};}function widgetsEq(a,b){return a==b||!!(a&&b&&a.compare(b));}function addRange(from,to,ranges){var margin=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;var last=ranges.length-1;if(last>=0&&ranges[last]+margin>=from)ranges[last]=Math.max(ranges[last],to);else ranges.push(from,to);}var LineView=/*#__PURE__*/function(_ContentView5){_inherits(LineView,_ContentView5);var _super13=_createSuper(LineView);function LineView(){var _this19;_classCallCheck(this,LineView);_this19=_super13.apply(this,arguments);_this19.children=[];_this19.length=0;_this19.prevAttrs=undefined;_this19.attrs=null;_this19.breakAfter=0;return _this19;}// Consumes source
606606+_createClass(LineView,[{key:"merge",value:function merge(from,to,source,hasStart,openStart,openEnd){if(source){if(!(source instanceof LineView))return false;if(!this.dom)source.transferDOM(this);// Reuse source.dom when appropriate
607607+}if(hasStart)this.setDeco(source?source.attrs:null);mergeChildrenInto(this,from,to,source?source.children:[],openStart,openEnd);return true;}},{key:"split",value:function split(at){var end=new LineView();end.breakAfter=this.breakAfter;if(this.length==0)return end;var _this$childPos=this.childPos(at),i=_this$childPos.i,off=_this$childPos.off;if(off){end.append(this.children[i].split(off),0);this.children[i].merge(off,this.children[i].length,null,false,0,0);i++;}for(var j=i;j<this.children.length;j++){end.append(this.children[j],0);}while(i>0&&this.children[i-1].length==0){this.children[--i].destroy();}this.children.length=i;this.markDirty();this.length=at;return end;}},{key:"transferDOM",value:function transferDOM(other){if(!this.dom)return;other.setDOM(this.dom);other.prevAttrs=this.prevAttrs===undefined?this.attrs:this.prevAttrs;this.prevAttrs=undefined;this.dom=null;}},{key:"setDeco",value:function setDeco(attrs){if(!attrsEq(this.attrs,attrs)){if(this.dom){this.prevAttrs=this.attrs;this.markDirty();}this.attrs=attrs;}}},{key:"append",value:function append(child,openStart){joinInlineInto(this,child,openStart);}// Only called when building a line view in ContentBuilder
608608+},{key:"addLineDeco",value:function addLineDeco(deco){var attrs=deco.spec.attributes,cls=deco.spec["class"];if(attrs)this.attrs=combineAttrs(attrs,this.attrs||{});if(cls)this.attrs=combineAttrs({"class":cls},this.attrs||{});}},{key:"domAtPos",value:function domAtPos(pos){return inlineDOMAtPos(this.dom,this.children,pos);}},{key:"reuseDOM",value:function reuseDOM(node){if(node.nodeName=="DIV"){this.setDOM(node);this.dirty|=4/* Attrs */|2/* Node */;}}},{key:"sync",value:function sync(track){var _a;if(!this.dom){this.setDOM(document.createElement("div"));this.dom.className="cm-line";this.prevAttrs=this.attrs?null:undefined;}else if(this.dirty&4/* Attrs */){clearAttributes(this.dom);this.dom.className="cm-line";this.prevAttrs=this.attrs?null:undefined;}if(this.prevAttrs!==undefined){_updateAttrs(this.dom,this.prevAttrs,this.attrs);this.dom.classList.add("cm-line");this.prevAttrs=undefined;}_get(_getPrototypeOf(LineView.prototype),"sync",this).call(this,track);var last=this.dom.lastChild;while(last&&ContentView.get(last)instanceof MarkView){last=last.lastChild;}if(!last||last.nodeName!="BR"&&((_a=ContentView.get(last))===null||_a===void 0?void 0:_a.isEditable)==false&&(!browser.ios||!this.children.some(function(ch){return ch instanceof TextView;}))){var hack=document.createElement("BR");hack.cmIgnore=true;this.dom.appendChild(hack);}}},{key:"measureTextSize",value:function measureTextSize(){if(this.children.length==0||this.length>20)return null;var totalWidth=0;var _iterator38=_createForOfIteratorHelper(this.children),_step38;try{for(_iterator38.s();!(_step38=_iterator38.n()).done;){var child=_step38.value;if(!(child instanceof TextView))return null;var rects=clientRectsFor(child.dom);if(rects.length!=1)return null;totalWidth+=rects[0].width;}}catch(err){_iterator38.e(err);}finally{_iterator38.f();}return{lineHeight:this.dom.getBoundingClientRect().height,charWidth:totalWidth/this.length};}},{key:"coordsAt",value:function coordsAt(pos,side){return coordsInChildren(this,pos,side);}},{key:"become",value:function become(_other){return false;}},{key:"type",get:function get(){return exports.BlockType.Text;}}],[{key:"find",value:function find(docView,pos){for(var _i17=0,off=0;_i17<docView.children.length;_i17++){var block=docView.children[_i17],end=off+block.length;if(end>=pos){if(block instanceof LineView)return block;if(end>pos)break;}off=end+block.breakAfter;}return null;}}]);return LineView;}(ContentView);var BlockWidgetView=/*#__PURE__*/function(_ContentView6){_inherits(BlockWidgetView,_ContentView6);var _super14=_createSuper(BlockWidgetView);function BlockWidgetView(widget,length,type){var _this20;_classCallCheck(this,BlockWidgetView);_this20=_super14.call(this);_this20.widget=widget;_this20.length=length;_this20.type=type;_this20.breakAfter=0;return _this20;}_createClass(BlockWidgetView,[{key:"merge",value:function merge(from,to,source,_takeDeco,openStart,openEnd){if(source&&(!(source instanceof BlockWidgetView)||!this.widget.compare(source.widget)||from>0&&openStart<=0||to<this.length&&openEnd<=0))return false;this.length=from+(source?source.length:0)+(this.length-to);return true;}},{key:"domAtPos",value:function domAtPos(pos){return pos==0?DOMPos.before(this.dom):DOMPos.after(this.dom,pos==this.length);}},{key:"split",value:function split(at){var len=this.length-at;this.length=at;var end=new BlockWidgetView(this.widget,len,this.type);end.breakAfter=this.breakAfter;return end;}},{key:"children",get:function get(){return noChildren;}},{key:"sync",value:function sync(){if(!this.dom||!this.widget.updateDOM(this.dom)){this.setDOM(this.widget.toDOM(this.editorView));this.dom.contentEditable="false";}}},{key:"overrideDOMText",get:function get(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):state.Text.empty;}},{key:"domBoundsAround",value:function domBoundsAround(){return null;}},{key:"become",value:function become(other){if(other instanceof BlockWidgetView&&other.type==this.type&&other.widget.constructor==this.widget.constructor){if(!other.widget.eq(this.widget))this.markDirty(true);this.widget=other.widget;this.length=other.length;this.breakAfter=other.breakAfter;return true;}return false;}},{key:"ignoreMutation",value:function ignoreMutation(){return true;}},{key:"ignoreEvent",value:function ignoreEvent(event){return this.widget.ignoreEvent(event);}},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(BlockWidgetView.prototype),"destroy",this).call(this);if(this.dom)this.widget.destroy(this.dom);}}]);return BlockWidgetView;}(ContentView);var ContentBuilder=/*#__PURE__*/function(){function ContentBuilder(doc,pos,end,disallowBlockEffectsBelow){_classCallCheck(this,ContentBuilder);this.doc=doc;this.pos=pos;this.end=end;this.disallowBlockEffectsBelow=disallowBlockEffectsBelow;this.content=[];this.curLine=null;this.breakAtStart=0;this.pendingBuffer=0/* No */;// Set to false directly after a widget that covers the position after it
609609+this.atCursorPos=true;this.openStart=-1;this.openEnd=-1;this.text="";this.textOff=0;this.cursor=doc.iter();this.skip=pos;}_createClass(ContentBuilder,[{key:"posCovered",value:function posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;var last=this.content[this.content.length-1];return!last.breakAfter&&!(last instanceof BlockWidgetView&&last.type==exports.BlockType.WidgetBefore);}},{key:"getLine",value:function getLine(){if(!this.curLine){this.content.push(this.curLine=new LineView());this.atCursorPos=true;}return this.curLine;}},{key:"flushBuffer",value:function flushBuffer(active){if(this.pendingBuffer){this.curLine.append(wrapMarks(new WidgetBufferView(-1),active),active.length);this.pendingBuffer=0/* No */;}}},{key:"addBlockWidget",value:function addBlockWidget(view){this.flushBuffer([]);this.curLine=null;this.content.push(view);}},{key:"finish",value:function finish(openEnd){if(!openEnd)this.flushBuffer([]);else this.pendingBuffer=0/* No */;if(!this.posCovered())this.getLine();}},{key:"buildText",value:function buildText(length,active,openStart){while(length>0){if(this.textOff==this.text.length){var _this$cursor$next=this.cursor.next(this.skip),value=_this$cursor$next.value,lineBreak=_this$cursor$next.lineBreak,done=_this$cursor$next.done;this.skip=0;if(done)throw new Error("Ran out of text content when drawing inline views");if(lineBreak){if(!this.posCovered())this.getLine();if(this.content.length)this.content[this.content.length-1].breakAfter=1;else this.breakAtStart=1;this.flushBuffer([]);this.curLine=null;length--;continue;}else{this.text=value;this.textOff=0;}}var take=Math.min(this.text.length-this.textOff,length,512/* Chunk */);this.flushBuffer(active.slice(0,openStart));this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+take)),active),openStart);this.atCursorPos=true;this.textOff+=take;length-=take;openStart=0;}}},{key:"span",value:function span(from,to,active,openStart){this.buildText(to-from,active,openStart);this.pos=to;if(this.openStart<0)this.openStart=openStart;}},{key:"point",value:function point(from,to,deco,active,openStart){var len=to-from;if(deco instanceof PointDecoration){if(deco.block){var type=deco.type;if(type==exports.BlockType.WidgetAfter&&!this.posCovered())this.getLine();this.addBlockWidget(new BlockWidgetView(deco.widget||new NullWidget("div"),len,type));}else{var view=WidgetView.create(deco.widget||new NullWidget("span"),len,deco.startSide);var cursorBefore=this.atCursorPos&&!view.isEditable&&openStart<=active.length&&(from<to||deco.startSide>0);var cursorAfter=!view.isEditable&&(from<to||deco.startSide<=0);var line=this.getLine();if(this.pendingBuffer==2/* IfCursor */&&!cursorBefore)this.pendingBuffer=0/* No */;this.flushBuffer(active);if(cursorBefore){line.append(wrapMarks(new WidgetBufferView(1),active),openStart);openStart=active.length+Math.max(0,openStart-active.length);}line.append(wrapMarks(view,active),openStart);this.atCursorPos=cursorAfter;this.pendingBuffer=!cursorAfter?0/* No */:from<to?1/* Yes */:2/* IfCursor */;}}else if(this.doc.lineAt(this.pos).from==this.pos){// Line decoration
610610+this.getLine().addLineDeco(deco);}if(len){// Advance the iterator past the replaced content
611611+if(this.textOff+len<=this.text.length){this.textOff+=len;}else{this.skip+=len-(this.text.length-this.textOff);this.text="";this.textOff=0;}this.pos=to;}if(this.openStart<0)this.openStart=openStart;}},{key:"filterPoint",value:function filterPoint(from,to,value,index){if(index>=this.disallowBlockEffectsBelow||!(value instanceof PointDecoration))return true;if(value.block)throw new RangeError("Block decorations may not be specified via plugins");return to<=this.doc.lineAt(this.pos).to;}}],[{key:"build",value:function build(text,from,to,decorations,pluginDecorationLength){var builder=new ContentBuilder(text,from,to,pluginDecorationLength);builder.openEnd=rangeset.RangeSet.spans(decorations,from,to,builder);if(builder.openStart<0)builder.openStart=builder.openEnd;builder.finish(builder.openEnd);return builder;}}]);return ContentBuilder;}();function wrapMarks(view,active){var _iterator39=_createForOfIteratorHelper(active),_step39;try{for(_iterator39.s();!(_step39=_iterator39.n()).done;){var mark=_step39.value;view=new MarkView(mark,[view],view.length);}}catch(err){_iterator39.e(err);}finally{_iterator39.f();}return view;}var NullWidget=/*#__PURE__*/function(_WidgetType){_inherits(NullWidget,_WidgetType);var _super15=_createSuper(NullWidget);function NullWidget(tag){var _this21;_classCallCheck(this,NullWidget);_this21=_super15.call(this);_this21.tag=tag;return _this21;}_createClass(NullWidget,[{key:"eq",value:function eq(other){return other.tag==this.tag;}},{key:"toDOM",value:function toDOM(){return document.createElement(this.tag);}},{key:"updateDOM",value:function updateDOM(elt){return elt.nodeName.toLowerCase()==this.tag;}}]);return NullWidget;}(WidgetType);var none=[];var clickAddsSelectionRange=state.Facet.define();var dragMovesSelection$1=state.Facet.define();var mouseSelectionStyle=state.Facet.define();var exceptionSink=state.Facet.define();var updateListener=state.Facet.define();var inputHandler=state.Facet.define();// FIXME remove
612612+var scrollTo=state.StateEffect.define({map:function map(range,changes){return range.map(changes);}});// FIXME remove
613613+var centerOn=state.StateEffect.define({map:function map(range,changes){return range.map(changes);}});var ScrollTarget=/*#__PURE__*/function(){function ScrollTarget(range){var y=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"nearest";var x=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"nearest";var yMargin=arguments.length>3&&arguments[3]!==undefined?arguments[3]:5;var xMargin=arguments.length>4&&arguments[4]!==undefined?arguments[4]:5;_classCallCheck(this,ScrollTarget);this.range=range;this.y=y;this.x=x;this.yMargin=yMargin;this.xMargin=xMargin;}_createClass(ScrollTarget,[{key:"map",value:function map(changes){return changes.empty?this:new ScrollTarget(this.range.map(changes),this.y,this.x,this.yMargin,this.xMargin);}}]);return ScrollTarget;}();var _scrollIntoView2=state.StateEffect.define({map:function map(t,ch){return t.map(ch);}});/**
614614+Log or report an unhandled exception in client code. Should
615615+probably only be used by extension code that allows client code to
616616+provide functions, and calls those functions in a context where an
617617+exception can't be propagated to calling code in a reasonable way
618618+(for example when in an event handler).
619619+620620+Either calls a handler registered with
621621+[`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
622622+`window.onerror`, if defined, or `console.error` (in which case
623623+it'll pass `context`, when given, as first argument).
624624+*/function logException(state,exception,context){var handler=state.facet(exceptionSink);if(handler.length)handler[0](exception);else if(window.onerror)window.onerror(String(exception),context,undefined,undefined,exception);else if(context)console.error(context+":",exception);else console.error(exception);}var editable=state.Facet.define({combine:function combine(values){return values.length?values[0]:true;}});/**
625625+Used to [declare](https://codemirror.net/6/docs/ref/#view.PluginSpec.provide) which
626626+[fields](https://codemirror.net/6/docs/ref/#view.PluginValue) a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin)
627627+provides.
628628+*/var PluginFieldProvider=/*#__PURE__*/_createClass(/**
629629+ @internal
630630+ */function PluginFieldProvider(/**
631631+ @internal
632632+ */field,/**
633633+ @internal
634634+ */get){_classCallCheck(this,PluginFieldProvider);this.field=field;this.get=get;});/**
635635+Plugin fields are a mechanism for allowing plugins to provide
636636+values that can be retrieved through the
637637+[`pluginField`](https://codemirror.net/6/docs/ref/#view.EditorView.pluginField) view method.
638638+*/var PluginField=/*#__PURE__*/function(){function PluginField(){_classCallCheck(this,PluginField);}_createClass(PluginField,[{key:"from",value:/**
639639+ Create a [provider](https://codemirror.net/6/docs/ref/#view.PluginFieldProvider) for this field,
640640+ to use with a plugin's [provide](https://codemirror.net/6/docs/ref/#view.PluginSpec.provide)
641641+ option.
642642+ */function from(get){return new PluginFieldProvider(this,get);}/**
643643+ Define a new plugin field.
644644+ */}],[{key:"define",value:function define(){return new PluginField();}}]);return PluginField;}();/**
645645+This field can be used by plugins to provide
646646+[decorations](https://codemirror.net/6/docs/ref/#view.Decoration).
647647+648648+**Note**: For reasons of data flow (plugins are only updated
649649+after the viewport is computed), decorations produced by plugins
650650+are _not_ taken into account when predicting the vertical layout
651651+structure of the editor. They **must not** introduce block
652652+widgets (that will raise an error) or replacing decorations that
653653+cover line breaks (these will be ignored if they occur). Such
654654+decorations, or others that cause a large amount of vertical
655655+size shift compared to the undecorated content, should be
656656+provided through the state-level [`decorations`
657657+facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations) instead.
658658+*/PluginField.decorations=PluginField.define();/**
659659+Used to provide ranges that should be treated as atoms as far as
660660+cursor motion is concerned. This causes methods like
661661+[`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
662662+[`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
663663+commands built on top of them) to skip across such regions when
664664+a selection endpoint would enter them. This does _not_ prevent
665665+direct programmatic [selection
666666+updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
667667+regions.
668668+*/PluginField.atomicRanges=PluginField.define();/**
669669+Plugins can provide additional scroll margins (space around the
670670+sides of the scrolling element that should be considered
671671+invisible) through this field. This can be useful when the
672672+plugin introduces elements that cover part of that element (for
673673+example a horizontally fixed gutter).
674674+*/PluginField.scrollMargins=PluginField.define();var nextPluginID=0;var viewPlugin=state.Facet.define();/**
675675+View plugins associate stateful values with a view. They can
676676+influence the way the content is drawn, and are notified of things
677677+that happen in the view.
678678+*/var ViewPlugin=/*#__PURE__*/function(){function ViewPlugin(/**
679679+ @internal
680680+ */id,/**
681681+ @internal
682682+ */create,/**
683683+ @internal
684684+ */fields){_classCallCheck(this,ViewPlugin);this.id=id;this.create=create;this.fields=fields;this.extension=viewPlugin.of(this);}/**
685685+ Define a plugin from a constructor function that creates the
686686+ plugin's value, given an editor view.
687687+ */_createClass(ViewPlugin,null,[{key:"define",value:function define(create,spec){var _ref36=spec||{},eventHandlers=_ref36.eventHandlers,provide=_ref36.provide,decorations=_ref36.decorations;var fields=[];if(provide){var _iterator40=_createForOfIteratorHelper(Array.isArray(provide)?provide:[provide]),_step40;try{for(_iterator40.s();!(_step40=_iterator40.n()).done;){var provider=_step40.value;fields.push(provider);}}catch(err){_iterator40.e(err);}finally{_iterator40.f();}}if(eventHandlers)fields.push(domEventHandlers.from(function(value){return{plugin:value,handlers:eventHandlers};}));if(decorations)fields.push(PluginField.decorations.from(decorations));return new ViewPlugin(nextPluginID++,create,fields);}/**
688688+ Create a plugin for a class whose constructor takes a single
689689+ editor view as argument.
690690+ */},{key:"fromClass",value:function fromClass(cls,spec){return ViewPlugin.define(function(view){return new cls(view);},spec);}}]);return ViewPlugin;}();var domEventHandlers=PluginField.define();var PluginInstance=/*#__PURE__*/function(){function PluginInstance(spec){_classCallCheck(this,PluginInstance);this.spec=spec;// When starting an update, all plugins have this field set to the
691691+// update object, indicating they need to be updated. When finished
692692+// updating, it is set to `false`. Retrieving a plugin that needs to
693693+// be updated with `view.plugin` forces an eager update.
694694+this.mustUpdate=null;// This is null when the plugin is initially created, but
695695+// initialized on the first update.
696696+this.value=null;}_createClass(PluginInstance,[{key:"takeField",value:function takeField(type,target){if(this.spec){var _iterator41=_createForOfIteratorHelper(this.spec.fields),_step41;try{for(_iterator41.s();!(_step41=_iterator41.n()).done;){var _step41$value=_step41.value,field=_step41$value.field,get=_step41$value.get;if(field==type)target.push(get(this.value));}}catch(err){_iterator41.e(err);}finally{_iterator41.f();}}}},{key:"update",value:function update(view){if(!this.value){if(this.spec){try{this.value=this.spec.create(view);}catch(e){logException(view.state,e,"CodeMirror plugin crashed");this.deactivate();}}}else if(this.mustUpdate){var update=this.mustUpdate;this.mustUpdate=null;if(this.value.update){try{this.value.update(update);}catch(e){logException(update.state,e,"CodeMirror plugin crashed");if(this.value.destroy)try{this.value.destroy();}catch(_){}this.deactivate();}}}return this;}},{key:"destroy",value:function destroy(view){var _a;if((_a=this.value)===null||_a===void 0?void 0:_a.destroy){try{this.value.destroy();}catch(e){logException(view.state,e,"CodeMirror plugin crashed");}}}},{key:"deactivate",value:function deactivate(){this.spec=this.value=null;}}]);return PluginInstance;}();var editorAttributes=state.Facet.define();var contentAttributes=state.Facet.define();// Provide decorations
697697+var decorations=state.Facet.define();var styleModule=state.Facet.define();var ChangedRange=/*#__PURE__*/function(){function ChangedRange(fromA,toA,fromB,toB){_classCallCheck(this,ChangedRange);this.fromA=fromA;this.toA=toA;this.fromB=fromB;this.toB=toB;}_createClass(ChangedRange,[{key:"join",value:function join(other){return new ChangedRange(Math.min(this.fromA,other.fromA),Math.max(this.toA,other.toA),Math.min(this.fromB,other.fromB),Math.max(this.toB,other.toB));}},{key:"addToSet",value:function addToSet(set){var i=set.length,me=this;for(;i>0;i--){var range=set[i-1];if(range.fromA>me.toA)continue;if(range.toA<me.fromA)break;me=me.join(range);set.splice(i-1,1);}set.splice(i,0,me);return set;}}],[{key:"extendWithRanges",value:function extendWithRanges(diff,ranges){if(ranges.length==0)return diff;var result=[];for(var dI=0,rI=0,posA=0,posB=0;;dI++){var next=dI==diff.length?null:diff[dI],off=posA-posB;var end=next?next.fromB:1e9;while(rI<ranges.length&&ranges[rI]<end){var from=ranges[rI],to=ranges[rI+1];var fromB=Math.max(posB,from),toB=Math.min(end,to);if(fromB<=toB)new ChangedRange(fromB+off,toB+off,fromB,toB).addToSet(result);if(to>end)break;else rI+=2;}if(!next)return result;new ChangedRange(next.fromA,next.toA,next.fromB,next.toB).addToSet(result);posA=next.toA;posB=next.toB;}}}]);return ChangedRange;}();/**
698698+View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
699699+class, which describe what happened, whenever the view is updated.
700700+*/var ViewUpdate=/*#__PURE__*/function(){/**
701701+ @internal
702702+ */function ViewUpdate(/**
703703+ The editor view that the update is associated with.
704704+ */view,/**
705705+ The new editor state.
706706+ */state$1){var transactions=arguments.length>2&&arguments[2]!==undefined?arguments[2]:none;_classCallCheck(this,ViewUpdate);this.view=view;this.state=state$1;this.transactions=transactions;/**
707707+ @internal
708708+ */this.flags=0;this.startState=view.state;this.changes=state.ChangeSet.empty(this.startState.doc.length);var _iterator42=_createForOfIteratorHelper(transactions),_step42;try{for(_iterator42.s();!(_step42=_iterator42.n()).done;){var tr=_step42.value;this.changes=this.changes.compose(tr.changes);}}catch(err){_iterator42.e(err);}finally{_iterator42.f();}var changedRanges=[];this.changes.iterChangedRanges(function(fromA,toA,fromB,toB){return changedRanges.push(new ChangedRange(fromA,toA,fromB,toB));});this.changedRanges=changedRanges;var focus=view.hasFocus;if(focus!=view.inputState.notifiedFocused){view.inputState.notifiedFocused=focus;this.flags|=1/* Focus */;}}/**
709709+ Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
710710+ [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
711711+ update.
712712+ */_createClass(ViewUpdate,[{key:"viewportChanged",get:function get(){return(this.flags&4/* Viewport */)>0;}/**
713713+ Indicates whether the height of an element in the editor changed
714714+ in this update.
715715+ */},{key:"heightChanged",get:function get(){return(this.flags&2/* Height */)>0;}/**
716716+ Returns true when the document was modified or the size of the
717717+ editor, or elements within the editor, changed.
718718+ */},{key:"geometryChanged",get:function get(){return this.docChanged||(this.flags&(8/* Geometry */|2/* Height */))>0;}/**
719719+ True when this update indicates a focus change.
720720+ */},{key:"focusChanged",get:function get(){return(this.flags&1/* Focus */)>0;}/**
721721+ Whether the document changed in this update.
722722+ */},{key:"docChanged",get:function get(){return!this.changes.empty;}/**
723723+ Whether the selection was explicitly set in this update.
724724+ */},{key:"selectionSet",get:function get(){return this.transactions.some(function(tr){return tr.selection;});}/**
725725+ @internal
726726+ */},{key:"empty",get:function get(){return this.flags==0&&this.transactions.length==0;}}]);return ViewUpdate;}();/**
727727+Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
728728+*/exports.Direction=void 0;(function(Direction){// (These are chosen to match the base levels, in bidi algorithm
729729+// terms, of spans in that direction.)
730730+/**
731731+ Left-to-right.
732732+ */Direction[Direction["LTR"]=0]="LTR";/**
733733+ Right-to-left.
734734+ */Direction[Direction["RTL"]=1]="RTL";})(exports.Direction||(exports.Direction={}));var LTR=exports.Direction.LTR,RTL=exports.Direction.RTL;// Decode a string with each type encoded as log2(type)
735735+function dec(str){var result=[];for(var _i18=0;_i18<str.length;_i18++){result.push(1<<+str[_i18]);}return result;}// Character types for codepoints 0 to 0xf8
736736+var LowTypes=dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");// Character types for codepoints 0x600 to 0x6f9
737737+var ArabicTypes=dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");var Brackets=Object.create(null),BracketStack=[];// There's a lot more in
738738+// https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
739739+// which are left out to keep code size down.
740740+for(var _i19=0,_arr2=["()","[]","{}"];_i19<_arr2.length;_i19++){var p=_arr2[_i19];var l=p.charCodeAt(0),r=p.charCodeAt(1);Brackets[l]=r;Brackets[r]=-l;}function charType(ch){return ch<=0xf7?LowTypes[ch]:0x590<=ch&&ch<=0x5f4?2/* R */:0x600<=ch&&ch<=0x6f9?ArabicTypes[ch-0x600]:0x6ee<=ch&&ch<=0x8ac?4/* AL */:0x2000<=ch&&ch<=0x200b?256/* NI */:ch==0x200c?256/* NI */:1/* L */;}var BidiRE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;/**
741741+Represents a contiguous range of text that has a single direction
742742+(as in left-to-right or right-to-left).
743743+*/var BidiSpan=/*#__PURE__*/function(){/**
744744+ @internal
745745+ */function BidiSpan(/**
746746+ The start of the span (relative to the start of the line).
747747+ */from,/**
748748+ The end of the span.
749749+ */to,/**
750750+ The ["bidi
751751+ level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
752752+ of the span (in this context, 0 means
753753+ left-to-right, 1 means right-to-left, 2 means left-to-right
754754+ number inside right-to-left text).
755755+ */level){_classCallCheck(this,BidiSpan);this.from=from;this.to=to;this.level=level;}/**
756756+ The direction of this span.
757757+ */_createClass(BidiSpan,[{key:"dir",get:function get(){return this.level%2?RTL:LTR;}/**
758758+ @internal
759759+ */},{key:"side",value:function side(end,dir){return this.dir==dir==end?this.to:this.from;}/**
760760+ @internal
761761+ */}],[{key:"find",value:function find(order,index,level,assoc){var maybe=-1;for(var _i20=0;_i20<order.length;_i20++){var span=order[_i20];if(span.from<=index&&span.to>=index){if(span.level==level)return _i20;// When multiple spans match, if assoc != 0, take the one that
762762+// covers that side, otherwise take the one with the minimum
763763+// level.
764764+if(maybe<0||(assoc!=0?assoc<0?span.from<index:span.to>index:order[maybe].level>span.level))maybe=_i20;}}if(maybe<0)throw new RangeError("Index out of range");return maybe;}}]);return BidiSpan;}();// Reused array of character types
765765+var types=[];function computeOrder(line,direction){var len=line.length,outerType=direction==LTR?1/* L */:2/* R */,oppositeType=direction==LTR?2/* R */:1/* L */;if(!line||outerType==1/* L */&&!BidiRE.test(line))return trivialOrder(len);// W1. Examine each non-spacing mark (NSM) in the level run, and
766766+// change the type of the NSM to the type of the previous
767767+// character. If the NSM is at the start of the level run, it will
768768+// get the type of sor.
769769+// W2. Search backwards from each instance of a European number
770770+// until the first strong type (R, L, AL, or sor) is found. If an
771771+// AL is found, change the type of the European number to Arabic
772772+// number.
773773+// W3. Change all ALs to R.
774774+// (Left after this: L, R, EN, AN, ET, CS, NI)
775775+for(var _i21=0,prev=outerType,prevStrong=outerType;_i21<len;_i21++){var type=charType(line.charCodeAt(_i21));if(type==512/* NSM */)type=prev;else if(type==8/* EN */&&prevStrong==4/* AL */)type=16/* AN */;types[_i21]=type==4/* AL */?2/* R */:type;if(type&7/* Strong */)prevStrong=type;prev=type;}// W5. A sequence of European terminators adjacent to European
776776+// numbers changes to all European numbers.
777777+// W6. Otherwise, separators and terminators change to Other
778778+// Neutral.
779779+// W7. Search backwards from each instance of a European number
780780+// until the first strong type (R, L, or sor) is found. If an L is
781781+// found, then change the type of the European number to L.
782782+// (Left after this: L, R, EN+AN, NI)
783783+for(var _i22=0,_prev=outerType,_prevStrong=outerType;_i22<len;_i22++){var _type2=types[_i22];if(_type2==128/* CS */){if(_i22<len-1&&_prev==types[_i22+1]&&_prev&24/* Num */)_type2=types[_i22]=_prev;else types[_i22]=256/* NI */;}else if(_type2==64/* ET */){var end=_i22+1;while(end<len&&types[end]==64/* ET */){end++;}var replace=_i22&&_prev==8/* EN */||end<len&&types[end]==8/* EN */?_prevStrong==1/* L */?1/* L */:8/* EN */:256/* NI */;for(var j=_i22;j<end;j++){types[j]=replace;}_i22=end-1;}else if(_type2==8/* EN */&&_prevStrong==1/* L */){types[_i22]=1/* L */;}_prev=_type2;if(_type2&7/* Strong */)_prevStrong=_type2;}// N0. Process bracket pairs in an isolating run sequence
784784+// sequentially in the logical order of the text positions of the
785785+// opening paired brackets using the logic given below. Within this
786786+// scope, bidirectional types EN and AN are treated as R.
787787+for(var _i23=0,sI=0,context=0,ch,br,_type3;_i23<len;_i23++){// Keeps [startIndex, type, strongSeen] triples for each open
788788+// bracket on BracketStack.
789789+if(br=Brackets[ch=line.charCodeAt(_i23)]){if(br<0){// Closing bracket
790790+for(var sJ=sI-3;sJ>=0;sJ-=3){if(BracketStack[sJ+1]==-br){var flags=BracketStack[sJ+2];var _type4=flags&2/* EmbedInside */?outerType:!(flags&4/* OppositeInside */)?0:flags&1/* OppositeBefore */?oppositeType:outerType;if(_type4)types[_i23]=types[BracketStack[sJ]]=_type4;sI=sJ;break;}}}else if(BracketStack.length==189/* MaxDepth */){break;}else{BracketStack[sI++]=_i23;BracketStack[sI++]=ch;BracketStack[sI++]=context;}}else if((_type3=types[_i23])==2/* R */||_type3==1/* L */){var embed=_type3==outerType;context=embed?0:1/* OppositeBefore */;for(var _sJ=sI-3;_sJ>=0;_sJ-=3){var cur=BracketStack[_sJ+2];if(cur&2/* EmbedInside */)break;if(embed){BracketStack[_sJ+2]|=2/* EmbedInside */;}else{if(cur&4/* OppositeInside */)break;BracketStack[_sJ+2]|=4/* OppositeInside */;}}}}// N1. A sequence of neutrals takes the direction of the
791791+// surrounding strong text if the text on both sides has the same
792792+// direction. European and Arabic numbers act as if they were R in
793793+// terms of their influence on neutrals. Start-of-level-run (sor)
794794+// and end-of-level-run (eor) are used at level run boundaries.
795795+// N2. Any remaining neutrals take the embedding direction.
796796+// (Left after this: L, R, EN+AN)
797797+for(var _i24=0;_i24<len;_i24++){if(types[_i24]==256/* NI */){var _end2=_i24+1;while(_end2<len&&types[_end2]==256/* NI */){_end2++;}var beforeL=(_i24?types[_i24-1]:outerType)==1/* L */;var afterL=(_end2<len?types[_end2]:outerType)==1/* L */;var _replace=beforeL==afterL?beforeL?1/* L */:2/* R */:outerType;for(var _j=_i24;_j<_end2;_j++){types[_j]=_replace;}_i24=_end2-1;}}// Here we depart from the documented algorithm, in order to avoid
798798+// building up an actual levels array. Since there are only three
799799+// levels (0, 1, 2) in an implementation that doesn't take
800800+// explicit embedding into account, we can build up the order on
801801+// the fly, without following the level-based algorithm.
802802+var order=[];if(outerType==1/* L */){for(var _i25=0;_i25<len;){var start=_i25,rtl=types[_i25++]!=1/* L */;while(_i25<len&&rtl==(types[_i25]!=1/* L */)){_i25++;}if(rtl){for(var _j2=_i25;_j2>start;){var _end3=_j2,_l=types[--_j2]!=2/* R */;while(_j2>start&&_l==(types[_j2-1]!=2/* R */)){_j2--;}order.push(new BidiSpan(_j2,_end3,_l?2:1));}}else{order.push(new BidiSpan(start,_i25,0));}}}else{for(var _i26=0;_i26<len;){var _start3=_i26,_rtl=types[_i26++]==2/* R */;while(_i26<len&&_rtl==(types[_i26]==2/* R */)){_i26++;}order.push(new BidiSpan(_start3,_i26,_rtl?1:2));}}return order;}function trivialOrder(length){return[new BidiSpan(0,length,0)];}var movedOver="";function moveVisually(line,order,dir,start,forward){var _a;var startIndex=start.head-line.from,spanI=-1;if(startIndex==0){if(!forward||!line.length)return null;if(order[0].level!=dir){startIndex=order[0].side(false,dir);spanI=0;}}else if(startIndex==line.length){if(forward)return null;var last=order[order.length-1];if(last.level!=dir){startIndex=last.side(true,dir);spanI=order.length-1;}}if(spanI<0)spanI=BidiSpan.find(order,startIndex,(_a=start.bidiLevel)!==null&&_a!==void 0?_a:-1,start.assoc);var span=order[spanI];// End of span. (But not end of line--that was checked for above.)
803803+if(startIndex==span.side(forward,dir)){span=order[spanI+=forward?1:-1];startIndex=span.side(!forward,dir);}var indexForward=forward==(span.dir==dir);var nextIndex=text.findClusterBreak(line.text,startIndex,indexForward);movedOver=line.text.slice(Math.min(startIndex,nextIndex),Math.max(startIndex,nextIndex));if(nextIndex!=span.side(forward,dir))return state.EditorSelection.cursor(nextIndex+line.from,indexForward?-1:1,span.level);var nextSpan=spanI==(forward?order.length-1:0)?null:order[spanI+(forward?1:-1)];if(!nextSpan&&span.level!=dir)return state.EditorSelection.cursor(forward?line.to:line.from,forward?-1:1,dir);if(nextSpan&&nextSpan.level<span.level)return state.EditorSelection.cursor(nextSpan.side(!forward,dir)+line.from,forward?1:-1,nextSpan.level);return state.EditorSelection.cursor(nextIndex+line.from,forward?-1:1,span.level);}var DOMReader=/*#__PURE__*/function(){function DOMReader(points,view){_classCallCheck(this,DOMReader);this.points=points;this.view=view;this.text="";this.lineBreak=view.state.lineBreak;}_createClass(DOMReader,[{key:"readRange",value:function readRange(start,end){if(!start)return this;var parent=start.parentNode;for(var cur=start;;){this.findPointBefore(parent,cur);this.readNode(cur);var next=cur.nextSibling;if(next==end)break;var view=ContentView.get(cur),nextView=ContentView.get(next);if(view&&nextView?view.breakAfter:(view?view.breakAfter:isBlockElement(cur))||isBlockElement(next)&&(cur.nodeName!="BR"||cur.cmIgnore))this.text+=this.lineBreak;cur=next;}this.findPointBefore(parent,end);return this;}},{key:"readTextNode",value:function readTextNode(node){var _a,_b;var text=node.nodeValue;if(/^\u200b/.test(text)&&((_a=node.previousSibling)===null||_a===void 0?void 0:_a.contentEditable)=="false")text=text.slice(1);if(/\u200b$/.test(text)&&((_b=node.nextSibling)===null||_b===void 0?void 0:_b.contentEditable)=="false")text=text.slice(0,text.length-1);return text;}},{key:"readNode",value:function readNode(node){if(node.cmIgnore)return;var view=ContentView.get(node);var fromView=view&&view.overrideDOMText;var text;if(fromView!=null)text=fromView.sliceString(0,undefined,this.lineBreak);else if(node.nodeType==3)text=this.readTextNode(node);else if(node.nodeName=="BR")text=node.nextSibling?this.lineBreak:"";else if(node.nodeType==1)this.readRange(node.firstChild,null);if(text!=null){this.findPointIn(node,text.length);this.text+=text;// Chrome inserts two newlines when pressing shift-enter at the
804804+// end of a line. This drops one of those.
805805+if(browser.chrome&&this.view.inputState.lastKeyCode==13&&!node.nextSibling&&/\n\n$/.test(this.text))this.text=this.text.slice(0,-1);}}},{key:"findPointBefore",value:function findPointBefore(node,next){var _iterator43=_createForOfIteratorHelper(this.points),_step43;try{for(_iterator43.s();!(_step43=_iterator43.n()).done;){var point=_step43.value;if(point.node==node&&node.childNodes[point.offset]==next)point.pos=this.text.length;}}catch(err){_iterator43.e(err);}finally{_iterator43.f();}}},{key:"findPointIn",value:function findPointIn(node,maxLen){var _iterator44=_createForOfIteratorHelper(this.points),_step44;try{for(_iterator44.s();!(_step44=_iterator44.n()).done;){var point=_step44.value;if(point.node==node)point.pos=this.text.length+Math.min(point.offset,maxLen);}}catch(err){_iterator44.e(err);}finally{_iterator44.f();}}}]);return DOMReader;}();function isBlockElement(node){return node.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);}var DOMPoint=/*#__PURE__*/_createClass(function DOMPoint(node,offset){_classCallCheck(this,DOMPoint);this.node=node;this.offset=offset;this.pos=-1;});var DocView=/*#__PURE__*/function(_ContentView7){_inherits(DocView,_ContentView7);var _super16=_createSuper(DocView);function DocView(view){var _this22;_classCallCheck(this,DocView);_this22=_super16.call(this);_this22.view=view;_this22.compositionDeco=Decoration.none;_this22.decorations=[];_this22.pluginDecorationLength=0;// Track a minimum width for the editor. When measuring sizes in
806806+// measureVisibleLineHeights, this is updated to point at the width
807807+// of a given element and its extent in the document. When a change
808808+// happens in that range, these are reset. That way, once we've seen
809809+// a line/element of a given length, we keep the editor wide enough
810810+// to fit at least that element, until it is changed, at which point
811811+// we forget it again.
812812+_this22.minWidth=0;_this22.minWidthFrom=0;_this22.minWidthTo=0;// Track whether the DOM selection was set in a lossy way, so that
813813+// we don't mess it up when reading it back it
814814+_this22.impreciseAnchor=null;_this22.impreciseHead=null;_this22.forceSelection=false;// Used by the resize observer to ignore resizes that we caused
815815+// ourselves
816816+_this22.lastUpdate=Date.now();_this22.setDOM(view.contentDOM);_this22.children=[new LineView()];_this22.children[0].setParent(_assertThisInitialized(_this22));_this22.updateDeco();_this22.updateInner([new ChangedRange(0,0,0,view.state.doc.length)],0);return _this22;}_createClass(DocView,[{key:"root",get:function get(){return this.view.root;}},{key:"editorView",get:function get(){return this.view;}},{key:"length",get:function get(){return this.view.state.doc.length;}// Update the document view to a given state. scrollIntoView can be
817817+// used as a hint to compute a new viewport that includes that
818818+// position, if we know the editor is going to scroll that position
819819+// into view.
820820+},{key:"update",value:function update(_update3){var _this23=this;var changedRanges=_update3.changedRanges;if(this.minWidth>0&&changedRanges.length){if(!changedRanges.every(function(_ref37){var fromA=_ref37.fromA,toA=_ref37.toA;return toA<_this23.minWidthFrom||fromA>_this23.minWidthTo;})){this.minWidth=this.minWidthFrom=this.minWidthTo=0;}else{this.minWidthFrom=_update3.changes.mapPos(this.minWidthFrom,1);this.minWidthTo=_update3.changes.mapPos(this.minWidthTo,1);}}if(this.view.inputState.composing<0)this.compositionDeco=Decoration.none;else if(_update3.transactions.length||this.dirty)this.compositionDeco=computeCompositionDeco(this.view,_update3.changes);// When the DOM nodes around the selection are moved to another
821821+// parent, Chrome sometimes reports a different selection through
822822+// getSelection than the one that it actually shows to the user.
823823+// This forces a selection update when lines are joined to work
824824+// around that. Issue #54
825825+if((browser.ie||browser.chrome)&&!this.compositionDeco.size&&_update3&&_update3.state.doc.lines!=_update3.startState.doc.lines)this.forceSelection=true;var prevDeco=this.decorations,deco=this.updateDeco();var decoDiff=findChangedDeco(prevDeco,deco,_update3.changes);changedRanges=ChangedRange.extendWithRanges(changedRanges,decoDiff);if(this.dirty==0/* Not */&&changedRanges.length==0){return false;}else{this.updateInner(changedRanges,_update3.startState.doc.length);if(_update3.transactions.length)this.lastUpdate=Date.now();return true;}}// Used by update and the constructor do perform the actual DOM
826826+// update
827827+},{key:"updateInner",value:function updateInner(changes,oldLength){var _this24=this;this.view.viewState.mustMeasureContent=true;this.updateChildren(changes,oldLength);var observer=this.view.observer;observer.ignore(function(){// Lock the height during redrawing, since Chrome sometimes
828828+// messes with the scroll position during DOM mutation (though
829829+// no relayout is triggered and I cannot imagine how it can
830830+// recompute the scroll position without a layout)
831831+_this24.dom.style.height=_this24.view.viewState.contentHeight+"px";_this24.dom.style.minWidth=_this24.minWidth?_this24.minWidth+"px":"";// Chrome will sometimes, when DOM mutations occur directly
832832+// around the selection, get confused and report a different
833833+// selection from the one it displays (issue #218). This tries
834834+// to detect that situation.
835835+var track=browser.chrome||browser.ios?{node:observer.selectionRange.focusNode,written:false}:undefined;_this24.sync(track);_this24.dirty=0/* Not */;if(track&&(track.written||observer.selectionRange.focusNode!=track.node))_this24.forceSelection=true;_this24.dom.style.height="";});var gaps=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length){var _iterator45=_createForOfIteratorHelper(this.children),_step45;try{for(_iterator45.s();!(_step45=_iterator45.n()).done;){var child=_step45.value;if(child instanceof BlockWidgetView&&child.widget instanceof BlockGapWidget)gaps.push(child.dom);}}catch(err){_iterator45.e(err);}finally{_iterator45.f();}}observer.updateGaps(gaps);}},{key:"updateChildren",value:function updateChildren(changes,oldLength){var cursor=this.childCursor(oldLength);for(var _i27=changes.length-1;;_i27--){var next=_i27>=0?changes[_i27]:null;if(!next)break;var fromA=next.fromA,toA=next.toA,fromB=next.fromB,toB=next.toB;var _ContentBuilder$build=ContentBuilder.build(this.view.state.doc,fromB,toB,this.decorations,this.pluginDecorationLength),content=_ContentBuilder$build.content,breakAtStart=_ContentBuilder$build.breakAtStart,openStart=_ContentBuilder$build.openStart,openEnd=_ContentBuilder$build.openEnd;var _cursor$findPos=cursor.findPos(toA,1),toI=_cursor$findPos.i,toOff=_cursor$findPos.off;var _cursor$findPos2=cursor.findPos(fromA,-1),fromI=_cursor$findPos2.i,fromOff=_cursor$findPos2.off;replaceRange(this,fromI,fromOff,toI,toOff,content,breakAtStart,openStart,openEnd);}}// Sync the DOM selection to this.state.selection
836836+},{key:"updateSelection",value:function updateSelection(){var _this25=this;var mustRead=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var fromPointer=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(mustRead)this.view.observer.readSelectionRange();if(!(fromPointer||this.mayControlSelection())||browser.ios&&this.view.inputState.rapidCompositionStart)return;var force=this.forceSelection;this.forceSelection=false;var main=this.view.state.selection.main;// FIXME need to handle the case where the selection falls inside a block range
837837+var anchor=this.domAtPos(main.anchor);var head=main.empty?anchor:this.domAtPos(main.head);// Always reset on Firefox when next to an uneditable node to
838838+// avoid invisible cursor bugs (#111)
839839+if(browser.gecko&&main.empty&&betweenUneditable(anchor)){var dummy=document.createTextNode("");this.view.observer.ignore(function(){return anchor.node.insertBefore(dummy,anchor.node.childNodes[anchor.offset]||null);});anchor=head=new DOMPos(dummy,0);force=true;}var domSel=this.view.observer.selectionRange;// If the selection is already here, or in an equivalent position, don't touch it
840840+if(force||!domSel.focusNode||!isEquivalentPosition(anchor.node,anchor.offset,domSel.anchorNode,domSel.anchorOffset)||!isEquivalentPosition(head.node,head.offset,domSel.focusNode,domSel.focusOffset)){this.view.observer.ignore(function(){// Chrome Android will hide the virtual keyboard when tapping
841841+// inside an uneditable node, and not bring it back when we
842842+// move the cursor to its proper position. This tries to
843843+// restore the keyboard by cycling focus.
844844+if(browser.android&&browser.chrome&&_this25.dom.contains(domSel.focusNode)&&inUneditable(domSel.focusNode,_this25.dom)){_this25.dom.blur();_this25.dom.focus({preventScroll:true});}var rawSel=getSelection(_this25.root);if(main.empty){// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
845845+if(browser.gecko){var nextTo=nextToUneditable(anchor.node,anchor.offset);if(nextTo&&nextTo!=(1/* Before */|2/* After */)){var _text=nearbyTextNode(anchor.node,anchor.offset,nextTo==1/* Before */?1:-1);if(_text)anchor=new DOMPos(_text,nextTo==1/* Before */?0:_text.nodeValue.length);}}rawSel.collapse(anchor.node,anchor.offset);if(main.bidiLevel!=null&&domSel.cursorBidiLevel!=null)domSel.cursorBidiLevel=main.bidiLevel;}else if(rawSel.extend){// Selection.extend can be used to create an 'inverted' selection
846846+// (one where the focus is before the anchor), but not all
847847+// browsers support it yet.
848848+rawSel.collapse(anchor.node,anchor.offset);rawSel.extend(head.node,head.offset);}else{// Primitive (IE) way
849849+var range=document.createRange();if(main.anchor>main.head){var _ref38=[head,anchor];anchor=_ref38[0];head=_ref38[1];}range.setEnd(head.node,head.offset);range.setStart(anchor.node,anchor.offset);rawSel.removeAllRanges();rawSel.addRange(range);}});this.view.observer.setSelectionRange(anchor,head);}this.impreciseAnchor=anchor.precise?null:new DOMPos(domSel.anchorNode,domSel.anchorOffset);this.impreciseHead=head.precise?null:new DOMPos(domSel.focusNode,domSel.focusOffset);}},{key:"enforceCursorAssoc",value:function enforceCursorAssoc(){if(this.compositionDeco.size)return;var cursor=this.view.state.selection.main;var sel=getSelection(this.root);if(!cursor.empty||!cursor.assoc||!sel.modify)return;var line=LineView.find(this,cursor.head);if(!line)return;var lineStart=line.posAtStart;if(cursor.head==lineStart||cursor.head==lineStart+line.length)return;var before=this.coordsAt(cursor.head,-1),after=this.coordsAt(cursor.head,1);if(!before||!after||before.bottom>after.top)return;var dom=this.domAtPos(cursor.head+cursor.assoc);sel.collapse(dom.node,dom.offset);sel.modify("move",cursor.assoc<0?"forward":"backward","lineboundary");}},{key:"mayControlSelection",value:function mayControlSelection(){return this.view.state.facet(editable)?this.root.activeElement==this.dom:hasSelection(this.dom,this.view.observer.selectionRange);}},{key:"nearest",value:function nearest(dom){for(var cur=dom;cur;){var domView=ContentView.get(cur);if(domView&&domView.rootView==this)return domView;cur=cur.parentNode;}return null;}},{key:"posFromDOM",value:function posFromDOM(node,offset){var view=this.nearest(node);if(!view)throw new RangeError("Trying to find position for a DOM position outside of the document");return view.localPosFromDOM(node,offset)+view.posAtStart;}},{key:"domAtPos",value:function domAtPos(pos){var _this$childCursor$fin=this.childCursor().findPos(pos,-1),i=_this$childCursor$fin.i,off=_this$childCursor$fin.off;for(;i<this.children.length-1;){var child=this.children[i];if(off<child.length||child instanceof LineView)break;i++;off=0;}return this.children[i].domAtPos(off);}},{key:"coordsAt",value:function coordsAt(pos,side){for(var off=this.length,_i28=this.children.length-1;;_i28--){var child=this.children[_i28],start=off-child.breakAfter-child.length;if(pos>start||pos==start&&child.type!=exports.BlockType.WidgetBefore&&child.type!=exports.BlockType.WidgetAfter&&(!_i28||side==2||this.children[_i28-1].breakAfter||this.children[_i28-1].type==exports.BlockType.WidgetBefore&&side>-2))return child.coordsAt(pos-start,side);off=start;}}},{key:"measureVisibleLineHeights",value:function measureVisibleLineHeights(){var result=[],_this$view$viewState$=this.view.viewState.viewport,from=_this$view$viewState$.from,to=_this$view$viewState$.to;var contentWidth=this.view.contentDOM.clientWidth;var isWider=contentWidth>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1;var widest=-1;for(var pos=0,_i29=0;_i29<this.children.length;_i29++){var child=this.children[_i29],end=pos+child.length;if(end>to)break;if(pos>=from){var childRect=child.dom.getBoundingClientRect();result.push(childRect.height);if(isWider){var last=child.dom.lastChild;var rects=last?clientRectsFor(last):[];if(rects.length){var rect=rects[rects.length-1];var width=this.view.textDirection==exports.Direction.LTR?rect.right-childRect.left:childRect.right-rect.left;if(width>widest){widest=width;this.minWidth=contentWidth;this.minWidthFrom=pos;this.minWidthTo=end;}}}}pos=end+child.breakAfter;}return result;}},{key:"measureTextSize",value:function measureTextSize(){var _this26=this;var _iterator46=_createForOfIteratorHelper(this.children),_step46;try{for(_iterator46.s();!(_step46=_iterator46.n()).done;){var child=_step46.value;if(child instanceof LineView){var measure=child.measureTextSize();if(measure)return measure;}}// If no workable line exists, force a layout of a measurable element
850850+}catch(err){_iterator46.e(err);}finally{_iterator46.f();}var dummy=document.createElement("div"),lineHeight,charWidth;dummy.className="cm-line";dummy.textContent="abc def ghi jkl mno pqr stu";this.view.observer.ignore(function(){_this26.dom.appendChild(dummy);var rect=clientRectsFor(dummy.firstChild)[0];lineHeight=dummy.getBoundingClientRect().height;charWidth=rect?rect.width/27:7;dummy.remove();});return{lineHeight:lineHeight,charWidth:charWidth};}},{key:"childCursor",value:function childCursor(){var pos=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.length;// Move back to start of last element when possible, so that
851851+// `ChildCursor.findPos` doesn't have to deal with the edge case
852852+// of being after the last element.
853853+var i=this.children.length;if(i)pos-=this.children[--i].length;return new ChildCursor(this.children,pos,i);}},{key:"computeBlockGapDeco",value:function computeBlockGapDeco(){var deco=[],vs=this.view.viewState;for(var pos=0,_i30=0;;_i30++){var next=_i30==vs.viewports.length?null:vs.viewports[_i30];var end=next?next.from-1:this.length;if(end>pos){var height=vs.lineBlockAt(end).bottom-vs.lineBlockAt(pos).top;deco.push(Decoration.replace({widget:new BlockGapWidget(height),block:true,inclusive:true}).range(pos,end));}if(!next)break;pos=next.to+1;}return Decoration.set(deco);}},{key:"updateDeco",value:function updateDeco(){var pluginDecorations=this.view.pluginField(PluginField.decorations);this.pluginDecorationLength=pluginDecorations.length;return this.decorations=[].concat(_toConsumableArray(pluginDecorations),_toConsumableArray(this.view.state.facet(decorations)),[this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]);}},{key:"scrollIntoView",value:function scrollIntoView(target){var range=target.range;var rect=this.coordsAt(range.head,range.empty?range.assoc:range.head>range.anchor?-1:1),other;if(!rect)return;if(!range.empty&&(other=this.coordsAt(range.anchor,range.anchor>range.head?-1:1)))rect={left:Math.min(rect.left,other.left),top:Math.min(rect.top,other.top),right:Math.max(rect.right,other.right),bottom:Math.max(rect.bottom,other.bottom)};var mLeft=0,mRight=0,mTop=0,mBottom=0;var _iterator47=_createForOfIteratorHelper(this.view.pluginField(PluginField.scrollMargins)),_step47;try{for(_iterator47.s();!(_step47=_iterator47.n()).done;){var margins=_step47.value;if(margins){var left=margins.left,right=margins.right,top=margins.top,bottom=margins.bottom;if(left!=null)mLeft=Math.max(mLeft,left);if(right!=null)mRight=Math.max(mRight,right);if(top!=null)mTop=Math.max(mTop,top);if(bottom!=null)mBottom=Math.max(mBottom,bottom);}}}catch(err){_iterator47.e(err);}finally{_iterator47.f();}var targetRect={left:rect.left-mLeft,top:rect.top-mTop,right:rect.right+mRight,bottom:rect.bottom+mBottom};scrollRectIntoView(this.view.scrollDOM,targetRect,range.head<range.anchor?-1:1,target.x,target.y,target.xMargin,target.yMargin,this.view.textDirection==exports.Direction.LTR);}}]);return DocView;}(ContentView);function betweenUneditable(pos){return pos.node.nodeType==1&&pos.node.firstChild&&(pos.offset==0||pos.node.childNodes[pos.offset-1].contentEditable=="false")&&(pos.offset==pos.node.childNodes.length||pos.node.childNodes[pos.offset].contentEditable=="false");}var BlockGapWidget=/*#__PURE__*/function(_WidgetType2){_inherits(BlockGapWidget,_WidgetType2);var _super17=_createSuper(BlockGapWidget);function BlockGapWidget(height){var _this27;_classCallCheck(this,BlockGapWidget);_this27=_super17.call(this);_this27.height=height;return _this27;}_createClass(BlockGapWidget,[{key:"toDOM",value:function toDOM(){var elt=document.createElement("div");this.updateDOM(elt);return elt;}},{key:"eq",value:function eq(other){return other.height==this.height;}},{key:"updateDOM",value:function updateDOM(elt){elt.style.height=this.height+"px";return true;}},{key:"estimatedHeight",get:function get(){return this.height;}}]);return BlockGapWidget;}(WidgetType);function compositionSurroundingNode(view){var sel=view.observer.selectionRange;var textNode=sel.focusNode&&nearbyTextNode(sel.focusNode,sel.focusOffset,0);if(!textNode)return null;var cView=view.docView.nearest(textNode);if(!cView)return null;if(cView instanceof LineView){var topNode=textNode;while(topNode.parentNode!=cView.dom){topNode=topNode.parentNode;}var prev=topNode.previousSibling;while(prev&&!ContentView.get(prev)){prev=prev.previousSibling;}var pos=prev?ContentView.get(prev).posAtEnd:cView.posAtStart;return{from:pos,to:pos,node:topNode,text:textNode};}else{for(;;){var _cView=cView,parent=_cView.parent;if(!parent)return null;if(parent instanceof LineView)break;cView=parent;}var from=cView.posAtStart;return{from:from,to:from+cView.length,node:cView.dom,text:textNode};}}function computeCompositionDeco(view,changes){var surrounding=compositionSurroundingNode(view);if(!surrounding)return Decoration.none;var from=surrounding.from,to=surrounding.to,node=surrounding.node,textNode=surrounding.text;var newFrom=changes.mapPos(from,1),newTo=Math.max(newFrom,changes.mapPos(to,-1));var state=view.state,text=node.nodeType==3?node.nodeValue:new DOMReader([],view).readRange(node.firstChild,null).text;if(newTo-newFrom<text.length){if(state.sliceDoc(newFrom,Math.min(state.doc.length,newFrom+text.length))==text)newTo=newFrom+text.length;else if(state.sliceDoc(Math.max(0,newTo-text.length),newTo)==text)newFrom=newTo-text.length;else return Decoration.none;}else if(state.sliceDoc(newFrom,newTo)!=text){return Decoration.none;}return Decoration.set(Decoration.replace({widget:new CompositionWidget(node,textNode)}).range(newFrom,newTo));}var CompositionWidget=/*#__PURE__*/function(_WidgetType3){_inherits(CompositionWidget,_WidgetType3);var _super18=_createSuper(CompositionWidget);function CompositionWidget(top,text){var _this28;_classCallCheck(this,CompositionWidget);_this28=_super18.call(this);_this28.top=top;_this28.text=text;return _this28;}_createClass(CompositionWidget,[{key:"eq",value:function eq(other){return this.top==other.top&&this.text==other.text;}},{key:"toDOM",value:function toDOM(){return this.top;}},{key:"ignoreEvent",value:function ignoreEvent(){return false;}},{key:"customView",get:function get(){return CompositionView;}}]);return CompositionWidget;}(WidgetType);function nearbyTextNode(node,offset,side){for(;;){if(node.nodeType==3)return node;if(node.nodeType==1&&offset>0&&side<=0){node=node.childNodes[offset-1];offset=maxOffset(node);}else if(node.nodeType==1&&offset<node.childNodes.length&&side>=0){node=node.childNodes[offset];offset=0;}else{return null;}}}function nextToUneditable(node,offset){if(node.nodeType!=1)return 0;return(offset&&node.childNodes[offset-1].contentEditable=="false"?1/* Before */:0)|(offset<node.childNodes.length&&node.childNodes[offset].contentEditable=="false"?2/* After */:0);}var DecorationComparator$1=/*#__PURE__*/function(){function DecorationComparator$1(){_classCallCheck(this,DecorationComparator$1);this.changes=[];}_createClass(DecorationComparator$1,[{key:"compareRange",value:function compareRange(from,to){addRange(from,to,this.changes);}},{key:"comparePoint",value:function comparePoint(from,to){addRange(from,to,this.changes);}}]);return DecorationComparator$1;}();function findChangedDeco(a,b,diff){var comp=new DecorationComparator$1();rangeset.RangeSet.compare(a,b,diff,comp);return comp.changes;}function inUneditable(node,inside){for(var cur=node;cur&&cur!=inside;cur=cur.assignedSlot||cur.parentNode){if(cur.nodeType==1&&cur.contentEditable=='false'){return true;}}return false;}function groupAt(state$1,pos){var bias=arguments.length>2&&arguments[2]!==undefined?arguments[2]:1;var categorize=state$1.charCategorizer(pos);var line=state$1.doc.lineAt(pos),linePos=pos-line.from;if(line.length==0)return state.EditorSelection.cursor(pos);if(linePos==0)bias=1;else if(linePos==line.length)bias=-1;var from=linePos,to=linePos;if(bias<0)from=text.findClusterBreak(line.text,linePos,false);else to=text.findClusterBreak(line.text,linePos);var cat=categorize(line.text.slice(from,to));while(from>0){var prev=text.findClusterBreak(line.text,from,false);if(categorize(line.text.slice(prev,from))!=cat)break;from=prev;}while(to<line.length){var next=text.findClusterBreak(line.text,to);if(categorize(line.text.slice(to,next))!=cat)break;to=next;}return state.EditorSelection.range(from+line.from,to+line.from);}// Search the DOM for the {node, offset} position closest to the given
854854+// coordinates. Very inefficient and crude, but can usually be avoided
855855+// by calling caret(Position|Range)FromPoint instead.
856856+function getdx(x,rect){return rect.left>x?rect.left-x:Math.max(0,x-rect.right);}function getdy(y,rect){return rect.top>y?rect.top-y:Math.max(0,y-rect.bottom);}function yOverlap(a,b){return a.top<b.bottom-1&&a.bottom>b.top+1;}function upTop(rect,top){return top<rect.top?{top:top,left:rect.left,right:rect.right,bottom:rect.bottom}:rect;}function upBot(rect,bottom){return bottom>rect.bottom?{top:rect.top,left:rect.left,right:rect.right,bottom:bottom}:rect;}function domPosAtCoords(parent,x,y){var closest,closestRect,closestX,closestY;var above,below,aboveRect,belowRect;for(var child=parent.firstChild;child;child=child.nextSibling){var rects=clientRectsFor(child);for(var _i31=0;_i31<rects.length;_i31++){var rect=rects[_i31];if(closestRect&&yOverlap(closestRect,rect))rect=upTop(upBot(rect,closestRect.bottom),closestRect.top);var dx=getdx(x,rect),dy=getdy(y,rect);if(dx==0&&dy==0)return child.nodeType==3?domPosInText(child,x,y):domPosAtCoords(child,x,y);if(!closest||closestY>dy||closestY==dy&&closestX>dx){closest=child;closestRect=rect;closestX=dx;closestY=dy;}if(dx==0){if(y>rect.bottom&&(!aboveRect||aboveRect.bottom<rect.bottom)){above=child;aboveRect=rect;}else if(y<rect.top&&(!belowRect||belowRect.top>rect.top)){below=child;belowRect=rect;}}else if(aboveRect&&yOverlap(aboveRect,rect)){aboveRect=upBot(aboveRect,rect.bottom);}else if(belowRect&&yOverlap(belowRect,rect)){belowRect=upTop(belowRect,rect.top);}}}if(aboveRect&&aboveRect.bottom>=y){closest=above;closestRect=aboveRect;}else if(belowRect&&belowRect.top<=y){closest=below;closestRect=belowRect;}if(!closest)return{node:parent,offset:0};var clipX=Math.max(closestRect.left,Math.min(closestRect.right,x));if(closest.nodeType==3)return domPosInText(closest,clipX,y);if(!closestX&&closest.contentEditable=="true")return domPosAtCoords(closest,clipX,y);var offset=Array.prototype.indexOf.call(parent.childNodes,closest)+(x>=(closestRect.left+closestRect.right)/2?1:0);return{node:parent,offset:offset};}function domPosInText(node,x,y){var len=node.nodeValue.length;var closestOffset=-1,closestDY=1e9,generalSide=0;for(var _i32=0;_i32<len;_i32++){var rects=textRange(node,_i32,_i32+1).getClientRects();for(var j=0;j<rects.length;j++){var rect=rects[j];if(rect.top==rect.bottom)continue;if(!generalSide)generalSide=x-rect.left;var dy=(rect.top>y?rect.top-y:y-rect.bottom)-1;if(rect.left-1<=x&&rect.right+1>=x&&dy<closestDY){var right=x>=(rect.left+rect.right)/2,after=right;if(browser.chrome||browser.gecko){// Check for RTL on browsers that support getting client
857857+// rects for empty ranges.
858858+var rectBefore=textRange(node,_i32).getBoundingClientRect();if(rectBefore.left==rect.right)after=!right;}if(dy<=0)return{node:node,offset:_i32+(after?1:0)};closestOffset=_i32+(after?1:0);closestDY=dy;}}}return{node:node,offset:closestOffset>-1?closestOffset:generalSide>0?node.nodeValue.length:0};}function _posAtCoords(view,_ref39,precise){var x=_ref39.x,y=_ref39.y;var bias=arguments.length>3&&arguments[3]!==undefined?arguments[3]:-1;var _a;var content=view.contentDOM.getBoundingClientRect(),docTop=content.top+view.viewState.paddingTop;var block,docHeight=view.viewState.docHeight;var yOffset=y-docTop;if(yOffset<0)return 0;if(yOffset>docHeight)return view.state.doc.length;// Scan for a text block near the queried y position
859859+for(var halfLine=view.defaultLineHeight/2,bounced=false;;){block=view.elementAtHeight(yOffset);if(block.type==exports.BlockType.Text)break;for(;;){// Move the y position out of this block
860860+yOffset=bias>0?block.bottom+halfLine:block.top-halfLine;if(yOffset>=0&&yOffset<=docHeight)break;// If the document consists entirely of replaced widgets, we
861861+// won't find a text block, so return 0
862862+if(bounced)return precise?null:0;bounced=true;bias=-bias;}}y=docTop+yOffset;var lineStart=block.from;// If this is outside of the rendered viewport, we can't determine a position
863863+if(lineStart<view.viewport.from)return view.viewport.from==0?0:precise?null:posAtCoordsImprecise(view,content,block,x,y);if(lineStart>view.viewport.to)return view.viewport.to==view.state.doc.length?view.state.doc.length:precise?null:posAtCoordsImprecise(view,content,block,x,y);// Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
864864+var doc=view.dom.ownerDocument;var root=view.root.elementFromPoint?view.root:doc;var element=root.elementFromPoint(x,y);if(element&&!view.contentDOM.contains(element))element=null;// If the element is unexpected, clip x at the sides of the content area and try again
865865+if(!element){x=Math.max(content.left+1,Math.min(content.right-1,x));element=root.elementFromPoint(x,y);if(element&&!view.contentDOM.contains(element))element=null;}// There's visible editor content under the point, so we can try
866866+// using caret(Position|Range)FromPoint as a shortcut
867867+var node,offset=-1;if(element&&((_a=view.docView.nearest(element))===null||_a===void 0?void 0:_a.isEditable)!=false){if(doc.caretPositionFromPoint){var pos=doc.caretPositionFromPoint(x,y);if(pos){node=pos.offsetNode;offset=pos.offset;}}else if(doc.caretRangeFromPoint){var range=doc.caretRangeFromPoint(x,y);if(range){node=range.startContainer;offset=range.startOffset;if(browser.safari&&isSuspiciousCaretResult(node,offset,x))node=undefined;}}}// No luck, do our own (potentially expensive) search
868868+if(!node||!view.docView.dom.contains(node)){var line=LineView.find(view.docView,lineStart);if(!line)return yOffset>block.top+block.height/2?block.to:block.from;var _domPosAtCoords=domPosAtCoords(line.dom,x,y);node=_domPosAtCoords.node;offset=_domPosAtCoords.offset;}return view.docView.posFromDOM(node,offset);}function posAtCoordsImprecise(view,contentRect,block,x,y){var into=Math.round((x-contentRect.left)*view.defaultCharacterWidth);if(view.lineWrapping&&block.height>view.defaultLineHeight*1.5){var line=Math.floor((y-block.top)/view.defaultLineHeight);into+=line*view.viewState.heightOracle.lineLength;}var content=view.state.sliceDoc(block.from,block.to);return block.from+text.findColumn(content,into,view.state.tabSize);}// In case of a high line height, Safari's caretRangeFromPoint treats
869869+// the space between lines as belonging to the last character of the
870870+// line before. This is used to detect such a result so that it can be
871871+// ignored (issue #401).
872872+function isSuspiciousCaretResult(node,offset,x){var len;if(node.nodeType!=3||offset!=(len=node.nodeValue.length))return false;for(var next=node.nextSibling;next;next=next.nextSibling){if(next.nodeType!=1||next.nodeName!="BR")return false;}return textRange(node,len-1,len).getBoundingClientRect().left>x;}function _moveToLineBoundary(view,start,forward,includeWrap){var line=view.state.doc.lineAt(start.head);var coords=!includeWrap||!view.lineWrapping?null:view.coordsAtPos(start.assoc<0&&start.head>line.from?start.head-1:start.head);if(coords){var editorRect=view.dom.getBoundingClientRect();var pos=view.posAtCoords({x:forward==(view.textDirection==exports.Direction.LTR)?editorRect.right-1:editorRect.left+1,y:(coords.top+coords.bottom)/2});if(pos!=null)return state.EditorSelection.cursor(pos,forward?-1:1);}var lineView=LineView.find(view.docView,start.head);var end=lineView?forward?lineView.posAtEnd:lineView.posAtStart:forward?line.to:line.from;return state.EditorSelection.cursor(end,forward?-1:1);}function _moveByChar(view,start,forward,by){var line=view.state.doc.lineAt(start.head),spans=view.bidiSpans(line);for(var cur=start,check=null;;){var next=moveVisually(line,spans,view.textDirection,cur,forward),_char2=movedOver;if(!next){if(line.number==(forward?view.state.doc.lines:1))return cur;_char2="\n";line=view.state.doc.line(line.number+(forward?1:-1));spans=view.bidiSpans(line);next=state.EditorSelection.cursor(forward?line.from:line.to);}if(!check){if(!by)return next;check=by(_char2);}else if(!check(_char2)){return cur;}cur=next;}}function byGroup(view,pos,start){var categorize=view.state.charCategorizer(pos);var cat=categorize(start);return function(next){var nextCat=categorize(next);if(cat==state.CharCategory.Space)cat=nextCat;return cat==nextCat;};}function _moveVertically(view,start,forward,distance){var startPos=start.head,dir=forward?1:-1;if(startPos==(forward?view.state.doc.length:0))return state.EditorSelection.cursor(startPos,start.assoc);var goal=start.goalColumn,startY;var rect=view.contentDOM.getBoundingClientRect();var startCoords=view.coordsAtPos(startPos),docTop=view.documentTop;if(startCoords){if(goal==null)goal=startCoords.left-rect.left;startY=dir<0?startCoords.top:startCoords.bottom;}else{var line=view.viewState.lineBlockAt(startPos-docTop);if(goal==null)goal=Math.min(rect.right-rect.left,view.defaultCharacterWidth*(startPos-line.from));startY=(dir<0?line.top:line.bottom)+docTop;}var resolvedGoal=rect.left+goal;var dist=distance!==null&&distance!==void 0?distance:view.defaultLineHeight>>1;for(var extra=0;;extra+=10){var curY=startY+(dist+extra)*dir;var pos=_posAtCoords(view,{x:resolvedGoal,y:curY},false,dir);if(curY<rect.top||curY>rect.bottom||(dir<0?pos<startPos:pos>startPos))return state.EditorSelection.cursor(pos,start.assoc,undefined,goal);}}function skipAtoms(view,oldPos,pos){var atoms=view.pluginField(PluginField.atomicRanges);for(;;){var moved=false;var _iterator48=_createForOfIteratorHelper(atoms),_step48;try{for(_iterator48.s();!(_step48=_iterator48.n()).done;){var set=_step48.value;set.between(pos.from-1,pos.from+1,function(from,to,value){if(pos.from>from&&pos.from<to){pos=oldPos.from>pos.from?state.EditorSelection.cursor(from,1):state.EditorSelection.cursor(to,-1);moved=true;}});}}catch(err){_iterator48.e(err);}finally{_iterator48.f();}if(!moved)return pos;}}// This will also be where dragging info and such goes
873873+var InputState=/*#__PURE__*/function(){function InputState(view){var _this29=this;_classCallCheck(this,InputState);this.lastKeyCode=0;this.lastKeyTime=0;// On iOS, some keys need to have their default behavior happen
874874+// (after which we retroactively handle them and reset the DOM) to
875875+// avoid messing up the virtual keyboard state.
876876+this.pendingIOSKey=undefined;this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastEscPress=0;this.lastContextMenu=0;this.scrollHandlers=[];this.registeredEvents=[];this.customHandlers=[];// -1 means not in a composition. Otherwise, this counts the number
877877+// of changes made during the composition. The count is used to
878878+// avoid treating the start state of the composition, before any
879879+// changes have been made, as part of the composition.
880880+this.composing=-1;// Tracks whether the next change should be marked as starting the
881881+// composition (null means no composition, true means next is the
882882+// first, false means first has already been marked for this
883883+// composition)
884884+this.compositionFirstChange=null;this.compositionEndedAt=0;this.rapidCompositionStart=false;this.mouseSelection=null;var _loop4=function _loop4(type){var handler=handlers[type];view.contentDOM.addEventListener(type,function(event){if(type=="keydown"&&_this29.keydown(view,event))return;if(!eventBelongsToEditor(view,event)||_this29.ignoreDuringComposition(event))return;if(_this29.mustFlushObserver(event))view.observer.forceFlush();if(_this29.runCustomHandlers(type,view,event))event.preventDefault();else handler(view,event);});_this29.registeredEvents.push(type);};for(var type in handlers){_loop4(type);}this.notifiedFocused=view.hasFocus;this.ensureHandlers(view);// On Safari adding an input event handler somehow prevents an
885885+// issue where the composition vanishes when you press enter.
886886+if(browser.safari)view.contentDOM.addEventListener("input",function(){return null;});}_createClass(InputState,[{key:"setSelectionOrigin",value:function setSelectionOrigin(origin){this.lastSelectionOrigin=origin;this.lastSelectionTime=Date.now();}},{key:"ensureHandlers",value:function ensureHandlers(view){var _this30=this;var handlers=this.customHandlers=view.pluginField(domEventHandlers);var _iterator49=_createForOfIteratorHelper(handlers),_step49;try{for(_iterator49.s();!(_step49=_iterator49.n()).done;){var set=_step49.value;var _loop5=function _loop5(type){if(_this30.registeredEvents.indexOf(type)<0&&type!="scroll"){_this30.registeredEvents.push(type);view.contentDOM.addEventListener(type,function(event){if(!eventBelongsToEditor(view,event))return;if(_this30.runCustomHandlers(type,view,event))event.preventDefault();});}};for(var type in set.handlers){_loop5(type);}}}catch(err){_iterator49.e(err);}finally{_iterator49.f();}}},{key:"runCustomHandlers",value:function runCustomHandlers(type,view,event){var _iterator50=_createForOfIteratorHelper(this.customHandlers),_step50;try{for(_iterator50.s();!(_step50=_iterator50.n()).done;){var set=_step50.value;var handler=set.handlers[type];if(handler){try{if(handler.call(set.plugin,event,view)||event.defaultPrevented)return true;}catch(e){logException(view.state,e);}}}}catch(err){_iterator50.e(err);}finally{_iterator50.f();}return false;}},{key:"runScrollHandlers",value:function runScrollHandlers(view,event){var _iterator51=_createForOfIteratorHelper(this.customHandlers),_step51;try{for(_iterator51.s();!(_step51=_iterator51.n()).done;){var set=_step51.value;var handler=set.handlers.scroll;if(handler){try{handler.call(set.plugin,event,view);}catch(e){logException(view.state,e);}}}}catch(err){_iterator51.e(err);}finally{_iterator51.f();}}},{key:"keydown",value:function keydown(view,event){var _this31=this;// Must always run, even if a custom handler handled the event
887887+this.lastKeyCode=event.keyCode;this.lastKeyTime=Date.now();if(this.screenKeyEvent(view,event))return true;// Chrome for Android usually doesn't fire proper key events, but
888888+// occasionally does, usually surrounded by a bunch of complicated
889889+// composition changes. When an enter or backspace key event is
890890+// seen, hold off on handling DOM events for a bit, and then
891891+// dispatch it.
892892+if(browser.android&&browser.chrome&&!event.synthetic&&(event.keyCode==13||event.keyCode==8)){view.observer.delayAndroidKey(event.key,event.keyCode);return true;}// Prevent the default behavior of Enter on iOS makes the
893893+// virtual keyboard get stuck in the wrong (lowercase)
894894+// state. So we let it go through, and then, in
895895+// applyDOMChange, notify key handlers of it and reset to
896896+// the state they produce.
897897+var pending;if(browser.ios&&(pending=PendingKeys.find(function(key){return key.keyCode==event.keyCode;}))&&!(event.ctrlKey||event.altKey||event.metaKey)&&!event.synthetic){this.pendingIOSKey=pending;setTimeout(function(){return _this31.flushIOSKey(view);},250);return true;}return false;}},{key:"flushIOSKey",value:function flushIOSKey(view){var key=this.pendingIOSKey;if(!key)return false;this.pendingIOSKey=undefined;return dispatchKey(view.contentDOM,key.key,key.keyCode);}},{key:"ignoreDuringComposition",value:function ignoreDuringComposition(event){if(!/^key/.test(event.type))return false;if(this.composing>0)return true;// See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
898898+// On some input method editors (IMEs), the Enter key is used to
899899+// confirm character selection. On Safari, when Enter is pressed,
900900+// compositionend and keydown events are sometimes emitted in the
901901+// wrong order. The key event should still be ignored, even when
902902+// it happens after the compositionend event.
903903+if(browser.safari&&Date.now()-this.compositionEndedAt<500){this.compositionEndedAt=0;return true;}return false;}},{key:"screenKeyEvent",value:function screenKeyEvent(view,event){var protectedTab=event.keyCode==9&&Date.now()<this.lastEscPress+2000;if(event.keyCode==27)this.lastEscPress=Date.now();else if(modifierCodes.indexOf(event.keyCode)<0)this.lastEscPress=0;return protectedTab;}},{key:"mustFlushObserver",value:function mustFlushObserver(event){return event.type=="keydown"&&event.keyCode!=229||event.type=="compositionend"&&!browser.ios;}},{key:"startMouseSelection",value:function startMouseSelection(mouseSelection){if(this.mouseSelection)this.mouseSelection.destroy();this.mouseSelection=mouseSelection;}},{key:"update",value:function update(_update4){if(this.mouseSelection)this.mouseSelection.update(_update4);if(_update4.transactions.length)this.lastKeyCode=this.lastSelectionTime=0;}},{key:"destroy",value:function destroy(){if(this.mouseSelection)this.mouseSelection.destroy();}}]);return InputState;}();var PendingKeys=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}];// Key codes for modifier keys
904904+var modifierCodes=[16,17,18,20,91,92,224,225];var MouseSelection=/*#__PURE__*/function(){function MouseSelection(view,startEvent,style,mustSelect){_classCallCheck(this,MouseSelection);this.view=view;this.style=style;this.mustSelect=mustSelect;this.lastEvent=startEvent;var doc=view.contentDOM.ownerDocument;doc.addEventListener("mousemove",this.move=this.move.bind(this));doc.addEventListener("mouseup",this.up=this.up.bind(this));this.extend=startEvent.shiftKey;this.multiple=view.state.facet(state.EditorState.allowMultipleSelections)&&addsSelectionRange(view,startEvent);this.dragMove=dragMovesSelection(view,startEvent);this.dragging=isInPrimarySelection(view,startEvent)&&getClickType(startEvent)==1?null:false;// When clicking outside of the selection, immediately apply the
905905+// effect of starting the selection
906906+if(this.dragging===false){startEvent.preventDefault();this.select(startEvent);}}_createClass(MouseSelection,[{key:"move",value:function move(event){if(event.buttons==0)return this.destroy();if(this.dragging!==false)return;this.select(this.lastEvent=event);}},{key:"up",value:function up(event){if(this.dragging==null)this.select(this.lastEvent);if(!this.dragging)event.preventDefault();this.destroy();}},{key:"destroy",value:function destroy(){var doc=this.view.contentDOM.ownerDocument;doc.removeEventListener("mousemove",this.move);doc.removeEventListener("mouseup",this.up);this.view.inputState.mouseSelection=null;}},{key:"select",value:function select(event){var selection=this.style.get(event,this.extend,this.multiple);if(this.mustSelect||!selection.eq(this.view.state.selection)||selection.main.assoc!=this.view.state.selection.main.assoc)this.view.dispatch({selection:selection,userEvent:"select.pointer",scrollIntoView:true});this.mustSelect=false;}},{key:"update",value:function update(_update5){var _this32=this;if(_update5.docChanged&&this.dragging)this.dragging=this.dragging.map(_update5.changes);if(this.style.update(_update5))setTimeout(function(){return _this32.select(_this32.lastEvent);},20);}}]);return MouseSelection;}();function addsSelectionRange(view,event){var facet=view.state.facet(clickAddsSelectionRange);return facet.length?facet[0](event):browser.mac?event.metaKey:event.ctrlKey;}function dragMovesSelection(view,event){var facet=view.state.facet(dragMovesSelection$1);return facet.length?facet[0](event):browser.mac?!event.altKey:!event.ctrlKey;}function isInPrimarySelection(view,event){var main=view.state.selection.main;if(main.empty)return false;// On boundary clicks, check whether the coordinates are inside the
907907+// selection's client rectangles
908908+var sel=getSelection(view.root);if(sel.rangeCount==0)return true;var rects=sel.getRangeAt(0).getClientRects();for(var _i33=0;_i33<rects.length;_i33++){var rect=rects[_i33];if(rect.left<=event.clientX&&rect.right>=event.clientX&&rect.top<=event.clientY&&rect.bottom>=event.clientY)return true;}return false;}function eventBelongsToEditor(view,event){if(!event.bubbles)return true;if(event.defaultPrevented)return false;for(var node=event.target,cView;node!=view.contentDOM;node=node.parentNode){if(!node||node.nodeType==11||(cView=ContentView.get(node))&&cView.ignoreEvent(event))return false;}return true;}var handlers=Object.create(null);// This is very crude, but unfortunately both these browsers _pretend_
909909+// that they have a clipboard API—all the objects and methods are
910910+// there, they just don't work, and they are hard to test.
911911+var brokenClipboardAPI=browser.ie&&browser.ie_version<15||browser.ios&&browser.webkit_version<604;function capturePaste(view){var parent=view.dom.parentNode;if(!parent)return;var target=parent.appendChild(document.createElement("textarea"));target.style.cssText="position: fixed; left: -10000px; top: 10px";target.focus();setTimeout(function(){view.focus();target.remove();doPaste(view,target.value);},50);}function doPaste(view,input){var state$1=view.state,changes,i=1,text=state$1.toText(input);var byLine=text.lines==state$1.selection.ranges.length;var linewise=lastLinewiseCopy!=null&&state$1.selection.ranges.every(function(r){return r.empty;})&&lastLinewiseCopy==text.toString();if(linewise){var lastLine=-1;changes=state$1.changeByRange(function(range){var line=state$1.doc.lineAt(range.from);if(line.from==lastLine)return{range:range};lastLine=line.from;var insert=state$1.toText((byLine?text.line(i++).text:input)+state$1.lineBreak);return{changes:{from:line.from,insert:insert},range:state.EditorSelection.cursor(range.from+insert.length)};});}else if(byLine){changes=state$1.changeByRange(function(range){var line=text.line(i++);return{changes:{from:range.from,to:range.to,insert:line.text},range:state.EditorSelection.cursor(range.from+line.length)};});}else{changes=state$1.replaceSelection(text);}view.dispatch(changes,{userEvent:"input.paste",scrollIntoView:true});}handlers.keydown=function(view,event){view.inputState.setSelectionOrigin("select");};var lastTouch=0;handlers.touchstart=function(view,e){lastTouch=Date.now();view.inputState.setSelectionOrigin("select.pointer");};handlers.touchmove=function(view){view.inputState.setSelectionOrigin("select.pointer");};handlers.mousedown=function(view,event){view.observer.flush();if(lastTouch>Date.now()-2000&&getClickType(event)==1)return;// Ignore touch interaction
912912+var style=null;var _iterator52=_createForOfIteratorHelper(view.state.facet(mouseSelectionStyle)),_step52;try{for(_iterator52.s();!(_step52=_iterator52.n()).done;){var makeStyle=_step52.value;style=makeStyle(view,event);if(style)break;}}catch(err){_iterator52.e(err);}finally{_iterator52.f();}if(!style&&event.button==0)style=basicMouseSelection(view,event);if(style){var mustFocus=view.root.activeElement!=view.contentDOM;if(mustFocus)view.observer.ignore(function(){return focusPreventScroll(view.contentDOM);});view.inputState.startMouseSelection(new MouseSelection(view,event,style,mustFocus));}};function rangeForClick(view,pos,bias,type){if(type==1){// Single click
913913+return state.EditorSelection.cursor(pos,bias);}else if(type==2){// Double click
914914+return groupAt(view.state,pos,bias);}else{// Triple click
915915+var visual=LineView.find(view.docView,pos),line=view.state.doc.lineAt(visual?visual.posAtEnd:pos);var from=visual?visual.posAtStart:line.from,to=visual?visual.posAtEnd:line.to;if(to<view.state.doc.length&&to==line.to)to++;return state.EditorSelection.range(from,to);}}var insideY=function insideY(y,rect){return y>=rect.top&&y<=rect.bottom;};var inside=function inside(x,y,rect){return insideY(y,rect)&&x>=rect.left&&x<=rect.right;};// Try to determine, for the given coordinates, associated with the
916916+// given position, whether they are related to the element before or
917917+// the element after the position.
918918+function findPositionSide(view,pos,x,y){var line=LineView.find(view.docView,pos);if(!line)return 1;var off=pos-line.posAtStart;// Line boundaries point into the line
919919+if(off==0)return 1;if(off==line.length)return-1;// Positions on top of an element point at that element
920920+var before=line.coordsAt(off,-1);if(before&&inside(x,y,before))return-1;var after=line.coordsAt(off,1);if(after&&inside(x,y,after))return 1;// This is probably a line wrap point. Pick before if the point is
921921+// beside it.
922922+return before&&insideY(y,before)?-1:1;}function queryPos(view,event){var pos=view.posAtCoords({x:event.clientX,y:event.clientY},false);return{pos:pos,bias:findPositionSide(view,pos,event.clientX,event.clientY)};}var BadMouseDetail=browser.ie&&browser.ie_version<=11;var lastMouseDown=null,lastMouseDownCount=0,lastMouseDownTime=0;function getClickType(event){if(!BadMouseDetail)return event.detail;var last=lastMouseDown,lastTime=lastMouseDownTime;lastMouseDown=event;lastMouseDownTime=Date.now();return lastMouseDownCount=!last||lastTime>Date.now()-400&&Math.abs(last.clientX-event.clientX)<2&&Math.abs(last.clientY-event.clientY)<2?(lastMouseDownCount+1)%3:1;}function basicMouseSelection(view,event){var start=queryPos(view,event),type=getClickType(event);var startSel=view.state.selection;var last=start,lastEvent=event;return{update:function update(_update6){if(_update6.docChanged){if(start)start.pos=_update6.changes.mapPos(start.pos);startSel=startSel.map(_update6.changes);lastEvent=null;}},get:function get(event,extend,multiple){var cur;if(lastEvent&&event.clientX==lastEvent.clientX&&event.clientY==lastEvent.clientY)cur=last;else{cur=last=queryPos(view,event);lastEvent=event;}if(!cur||!start)return startSel;var range=rangeForClick(view,cur.pos,cur.bias,type);if(start.pos!=cur.pos&&!extend){var startRange=rangeForClick(view,start.pos,start.bias,type);var from=Math.min(startRange.from,range.from),to=Math.max(startRange.to,range.to);range=from<range.from?state.EditorSelection.range(from,to):state.EditorSelection.range(to,from);}if(extend)return startSel.replaceRange(startSel.main.extend(range.from,range.to));else if(multiple)return startSel.addRange(range);else return state.EditorSelection.create([range]);}};}handlers.dragstart=function(view,event){var main=view.state.selection.main;var mouseSelection=view.inputState.mouseSelection;if(mouseSelection)mouseSelection.dragging=main;if(event.dataTransfer){event.dataTransfer.setData("Text",view.state.sliceDoc(main.from,main.to));event.dataTransfer.effectAllowed="copyMove";}};function dropText(view,event,text,direct){if(!text)return;var dropPos=view.posAtCoords({x:event.clientX,y:event.clientY},false);event.preventDefault();var mouseSelection=view.inputState.mouseSelection;var del=direct&&mouseSelection&&mouseSelection.dragging&&mouseSelection.dragMove?{from:mouseSelection.dragging.from,to:mouseSelection.dragging.to}:null;var ins={from:dropPos,insert:text};var changes=view.state.changes(del?[del,ins]:ins);view.focus();view.dispatch({changes:changes,selection:{anchor:changes.mapPos(dropPos,-1),head:changes.mapPos(dropPos,1)},userEvent:del?"move.drop":"input.drop"});}handlers.drop=function(view,event){if(!event.dataTransfer)return;if(view.state.readOnly)return event.preventDefault();var files=event.dataTransfer.files;if(files&&files.length){(function(){// For a file drop, read the file's text.
923923+event.preventDefault();var text=Array(files.length),read=0;var finishFile=function finishFile(){if(++read==files.length)dropText(view,event,text.filter(function(s){return s!=null;}).join(view.state.lineBreak),false);};var _loop6=function _loop6(_i34){var reader=new FileReader();reader.onerror=finishFile;reader.onload=function(){if(!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))text[_i34]=reader.result;finishFile();};reader.readAsText(files[_i34]);};for(var _i34=0;_i34<files.length;_i34++){_loop6(_i34);}})();}else{dropText(view,event,event.dataTransfer.getData("Text"),true);}};handlers.paste=function(view,event){if(view.state.readOnly)return event.preventDefault();view.observer.flush();var data=brokenClipboardAPI?null:event.clipboardData;if(data){doPaste(view,data.getData("text/plain"));event.preventDefault();}else{capturePaste(view);}};function captureCopy(view,text){// The extra wrapper is somehow necessary on IE/Edge to prevent the
924924+// content from being mangled when it is put onto the clipboard
925925+var parent=view.dom.parentNode;if(!parent)return;var target=parent.appendChild(document.createElement("textarea"));target.style.cssText="position: fixed; left: -10000px; top: 10px";target.value=text;target.focus();target.selectionEnd=text.length;target.selectionStart=0;setTimeout(function(){target.remove();view.focus();},50);}function copiedRange(state){var content=[],ranges=[],linewise=false;var _iterator53=_createForOfIteratorHelper(state.selection.ranges),_step53;try{for(_iterator53.s();!(_step53=_iterator53.n()).done;){var range=_step53.value;if(!range.empty){content.push(state.sliceDoc(range.from,range.to));ranges.push(range);}}}catch(err){_iterator53.e(err);}finally{_iterator53.f();}if(!content.length){// Nothing selected, do a line-wise copy
926926+var upto=-1;var _iterator54=_createForOfIteratorHelper(state.selection.ranges),_step54;try{for(_iterator54.s();!(_step54=_iterator54.n()).done;){var from=_step54.value.from;var line=state.doc.lineAt(from);if(line.number>upto){content.push(line.text);ranges.push({from:line.from,to:Math.min(state.doc.length,line.to+1)});}upto=line.number;}}catch(err){_iterator54.e(err);}finally{_iterator54.f();}linewise=true;}return{text:content.join(state.lineBreak),ranges:ranges,linewise:linewise};}var lastLinewiseCopy=null;handlers.copy=handlers.cut=function(view,event){var _copiedRange=copiedRange(view.state),text=_copiedRange.text,ranges=_copiedRange.ranges,linewise=_copiedRange.linewise;if(!text&&!linewise)return;lastLinewiseCopy=linewise?text:null;var data=brokenClipboardAPI?null:event.clipboardData;if(data){event.preventDefault();data.clearData();data.setData("text/plain",text);}else{captureCopy(view,text);}if(event.type=="cut"&&!view.state.readOnly)view.dispatch({changes:ranges,scrollIntoView:true,userEvent:"delete.cut"});};handlers.focus=handlers.blur=function(view){setTimeout(function(){if(view.hasFocus!=view.inputState.notifiedFocused)view.update([]);},10);};handlers.beforeprint=function(view){view.viewState.printing=true;view.requestMeasure();setTimeout(function(){view.viewState.printing=false;view.requestMeasure();},2000);};function forceClearComposition(view,rapid){if(view.docView.compositionDeco.size){view.inputState.rapidCompositionStart=rapid;try{view.update([]);}finally{view.inputState.rapidCompositionStart=false;}}}handlers.compositionstart=handlers.compositionupdate=function(view){if(view.inputState.compositionFirstChange==null)view.inputState.compositionFirstChange=true;if(view.inputState.composing<0){// FIXME possibly set a timeout to clear it again on Android
927927+view.inputState.composing=0;if(view.docView.compositionDeco.size){view.observer.flush();forceClearComposition(view,true);}}};handlers.compositionend=function(view){view.inputState.composing=-1;view.inputState.compositionEndedAt=Date.now();view.inputState.compositionFirstChange=null;setTimeout(function(){if(view.inputState.composing<0)forceClearComposition(view,false);},50);};handlers.contextmenu=function(view){view.inputState.lastContextMenu=Date.now();};handlers.beforeinput=function(view,event){var _a;// Because Chrome Android doesn't fire useful key events, use
928928+// beforeinput to detect backspace (and possibly enter and delete,
929929+// but those usually don't even seem to fire beforeinput events at
930930+// the moment) and fake a key event for it.
931931+//
932932+// (preventDefault on beforeinput, though supported in the spec,
933933+// seems to do nothing at all on Chrome).
934934+var pending;if(browser.chrome&&browser.android&&(pending=PendingKeys.find(function(key){return key.inputType==event.inputType;}))){view.observer.delayAndroidKey(pending.key,pending.keyCode);if(pending.key=="Backspace"||pending.key=="Delete"){var startViewHeight=((_a=window.visualViewport)===null||_a===void 0?void 0:_a.height)||0;setTimeout(function(){var _a;// Backspacing near uneditable nodes on Chrome Android sometimes
935935+// closes the virtual keyboard. This tries to crudely detect
936936+// that and refocus to get it back.
937937+if((((_a=window.visualViewport)===null||_a===void 0?void 0:_a.height)||0)>startViewHeight+10&&view.hasFocus){view.contentDOM.blur();view.focus();}},100);}}};var wrappingWhiteSpace=["pre-wrap","normal","pre-line","break-spaces"];var HeightOracle=/*#__PURE__*/function(){function HeightOracle(){_classCallCheck(this,HeightOracle);this.doc=text.Text.empty;this.lineWrapping=false;this.direction=exports.Direction.LTR;this.heightSamples={};this.lineHeight=14;this.charWidth=7;this.lineLength=30;// Used to track, during updateHeight, if any actual heights changed
938938+this.heightChanged=false;}_createClass(HeightOracle,[{key:"heightForGap",value:function heightForGap(from,to){var lines=this.doc.lineAt(to).number-this.doc.lineAt(from).number+1;if(this.lineWrapping)lines+=Math.ceil((to-from-lines*this.lineLength*0.5)/this.lineLength);return this.lineHeight*lines;}},{key:"heightForLine",value:function heightForLine(length){if(!this.lineWrapping)return this.lineHeight;var lines=1+Math.max(0,Math.ceil((length-this.lineLength)/(this.lineLength-5)));return lines*this.lineHeight;}},{key:"setDoc",value:function setDoc(doc){this.doc=doc;return this;}},{key:"mustRefreshForStyle",value:function mustRefreshForStyle(whiteSpace,direction){return wrappingWhiteSpace.indexOf(whiteSpace)>-1!=this.lineWrapping||this.direction!=direction;}},{key:"mustRefreshForHeights",value:function mustRefreshForHeights(lineHeights){var newHeight=false;for(var _i35=0;_i35<lineHeights.length;_i35++){var h=lineHeights[_i35];if(h<0){_i35++;}else if(!this.heightSamples[Math.floor(h*10)]){// Round to .1 pixels
939939+newHeight=true;this.heightSamples[Math.floor(h*10)]=true;}}return newHeight;}},{key:"refresh",value:function refresh(whiteSpace,direction,lineHeight,charWidth,lineLength,knownHeights){var lineWrapping=wrappingWhiteSpace.indexOf(whiteSpace)>-1;var changed=Math.round(lineHeight)!=Math.round(this.lineHeight)||this.lineWrapping!=lineWrapping||this.direction!=direction;this.lineWrapping=lineWrapping;this.direction=direction;this.lineHeight=lineHeight;this.charWidth=charWidth;this.lineLength=lineLength;if(changed){this.heightSamples={};for(var _i36=0;_i36<knownHeights.length;_i36++){var h=knownHeights[_i36];if(h<0)_i36++;else this.heightSamples[Math.floor(h*10)]=true;}}return changed;}}]);return HeightOracle;}();// This object is used by `updateHeight` to make DOM measurements
940940+// arrive at the right nides. The `heights` array is a sequence of
941941+// block heights, starting from position `from`.
942942+var MeasuredHeights=/*#__PURE__*/function(){function MeasuredHeights(from,heights){_classCallCheck(this,MeasuredHeights);this.from=from;this.heights=heights;this.index=0;}_createClass(MeasuredHeights,[{key:"more",get:function get(){return this.index<this.heights.length;}}]);return MeasuredHeights;}();/**
943943+Record used to represent information about a block-level element
944944+in the editor view.
945945+*/var BlockInfo=/*#__PURE__*/function(){/**
946946+ @internal
947947+ */function BlockInfo(/**
948948+ The start of the element in the document.
949949+ */from,/**
950950+ The length of the element.
951951+ */length,/**
952952+ The top position of the element (relative to the top of the
953953+ document).
954954+ */top,/**
955955+ Its height.
956956+ */height,/**
957957+ The type of element this is. When querying lines, this may be
958958+ an array of all the blocks that make up the line.
959959+ */type){_classCallCheck(this,BlockInfo);this.from=from;this.length=length;this.top=top;this.height=height;this.type=type;}/**
960960+ The end of the element as a document position.
961961+ */_createClass(BlockInfo,[{key:"to",get:function get(){return this.from+this.length;}/**
962962+ The bottom position of the element.
963963+ */},{key:"bottom",get:function get(){return this.top+this.height;}/**
964964+ @internal
965965+ */},{key:"join",value:function join(other){var detail=(Array.isArray(this.type)?this.type:[this]).concat(Array.isArray(other.type)?other.type:[other]);return new BlockInfo(this.from,this.length+other.length,this.top,this.height+other.height,detail);}/**
966966+ FIXME remove on next breaking release @internal
967967+ */},{key:"moveY",value:function moveY(offset){return!offset?this:new BlockInfo(this.from,this.length,this.top+offset,this.height,Array.isArray(this.type)?this.type.map(function(b){return b.moveY(offset);}):this.type);}}]);return BlockInfo;}();var QueryType;(function(QueryType){QueryType[QueryType["ByPos"]=0]="ByPos";QueryType[QueryType["ByHeight"]=1]="ByHeight";QueryType[QueryType["ByPosNoHeight"]=2]="ByPosNoHeight";})(QueryType||(QueryType={}));var Epsilon=1e-3;var HeightMap=/*#__PURE__*/function(){function HeightMap(length,// The number of characters covered
968968+height){var flags=arguments.length>2&&arguments[2]!==undefined?arguments[2]:2;_classCallCheck(this,HeightMap);this.length=length;this.height=height;this.flags=flags;}_createClass(HeightMap,[{key:"outdated",get:function get(){return(this.flags&2/* Outdated */)>0;},set:function set(value){this.flags=(value?2/* Outdated */:0)|this.flags&~2/* Outdated */;}},{key:"setHeight",value:function setHeight(oracle,height){if(this.height!=height){if(Math.abs(this.height-height)>Epsilon)oracle.heightChanged=true;this.height=height;}}// Base case is to replace a leaf node, which simply builds a tree
969969+// from the new nodes and returns that (HeightMapBranch and
970970+// HeightMapGap override this to actually use from/to)
971971+},{key:"replace",value:function replace(_from,_to,nodes){return HeightMap.of(nodes);}// Again, these are base cases, and are overridden for branch and gap nodes.
972972+},{key:"decomposeLeft",value:function decomposeLeft(_to,result){result.push(this);}},{key:"decomposeRight",value:function decomposeRight(_from,result){result.push(this);}},{key:"applyChanges",value:function applyChanges(decorations,oldDoc,oracle,changes){var me=this;for(var _i37=changes.length-1;_i37>=0;_i37--){var _changes$_i=changes[_i37],fromA=_changes$_i.fromA,toA=_changes$_i.toA,fromB=_changes$_i.fromB,toB=_changes$_i.toB;var start=me.lineAt(fromA,QueryType.ByPosNoHeight,oldDoc,0,0);var end=start.to>=toA?start:me.lineAt(toA,QueryType.ByPosNoHeight,oldDoc,0,0);toB+=end.to-toA;toA=end.to;while(_i37>0&&start.from<=changes[_i37-1].toA){fromA=changes[_i37-1].fromA;fromB=changes[_i37-1].fromB;_i37--;if(fromA<start.from)start=me.lineAt(fromA,QueryType.ByPosNoHeight,oldDoc,0,0);}fromB+=start.from-fromA;fromA=start.from;var nodes=NodeBuilder.build(oracle,decorations,fromB,toB);me=me.replace(fromA,toA,nodes);}return me.updateHeight(oracle,0);}}],[{key:"empty",value:function empty(){return new HeightMapText(0,0);}// nodes uses null values to indicate the position of line breaks.
973973+// There are never line breaks at the start or end of the array, or
974974+// two line breaks next to each other, and the array isn't allowed
975975+// to be empty (same restrictions as return value from the builder).
976976+},{key:"of",value:function of(nodes){if(nodes.length==1)return nodes[0];var i=0,j=nodes.length,before=0,after=0;for(;;){if(i==j){if(before>after*2){var split=nodes[i-1];if(split["break"])nodes.splice(--i,1,split.left,null,split.right);else nodes.splice(--i,1,split.left,split.right);j+=1+split["break"];before-=split.size;}else if(after>before*2){var _split=nodes[j];if(_split["break"])nodes.splice(j,1,_split.left,null,_split.right);else nodes.splice(j,1,_split.left,_split.right);j+=2+_split["break"];after-=_split.size;}else{break;}}else if(before<after){var next=nodes[i++];if(next)before+=next.size;}else{var _next2=nodes[--j];if(_next2)after+=_next2.size;}}var brk=0;if(nodes[i-1]==null){brk=1;i--;}else if(nodes[i]==null){brk=1;j++;}return new HeightMapBranch(HeightMap.of(nodes.slice(0,i)),brk,HeightMap.of(nodes.slice(j)));}}]);return HeightMap;}();HeightMap.prototype.size=1;var HeightMapBlock=/*#__PURE__*/function(_HeightMap){_inherits(HeightMapBlock,_HeightMap);var _super19=_createSuper(HeightMapBlock);function HeightMapBlock(length,height,type){var _this33;_classCallCheck(this,HeightMapBlock);_this33=_super19.call(this,length,height);_this33.type=type;return _this33;}_createClass(HeightMapBlock,[{key:"blockAt",value:function blockAt(_height,_doc,top,offset){return new BlockInfo(offset,this.length,top,this.height,this.type);}},{key:"lineAt",value:function lineAt(_value,_type,doc,top,offset){return this.blockAt(0,doc,top,offset);}},{key:"forEachLine",value:function forEachLine(_from,_to,doc,top,offset,f){f(this.blockAt(0,doc,top,offset));}},{key:"updateHeight",value:function updateHeight(oracle){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var _force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var measured=arguments.length>3?arguments[3]:undefined;if(measured&&measured.from<=offset&&measured.more)this.setHeight(oracle,measured.heights[measured.index++]);this.outdated=false;return this;}},{key:"toString",value:function toString(){return"block(".concat(this.length,")");}}]);return HeightMapBlock;}(HeightMap);var HeightMapText=/*#__PURE__*/function(_HeightMapBlock){_inherits(HeightMapText,_HeightMapBlock);var _super20=_createSuper(HeightMapText);function HeightMapText(length,height){var _this34;_classCallCheck(this,HeightMapText);_this34=_super20.call(this,length,height,exports.BlockType.Text);_this34.collapsed=0;// Amount of collapsed content in the line
977977+_this34.widgetHeight=0;// Maximum inline widget height
978978+return _this34;}_createClass(HeightMapText,[{key:"replace",value:function replace(_from,_to,nodes){var node=nodes[0];if(nodes.length==1&&(node instanceof HeightMapText||node instanceof HeightMapGap&&node.flags&4/* SingleLine */)&&Math.abs(this.length-node.length)<10){if(node instanceof HeightMapGap)node=new HeightMapText(node.length,this.height);else node.height=this.height;if(!this.outdated)node.outdated=false;return node;}else{return HeightMap.of(nodes);}}},{key:"updateHeight",value:function updateHeight(oracle){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var measured=arguments.length>3?arguments[3]:undefined;if(measured&&measured.from<=offset&&measured.more)this.setHeight(oracle,measured.heights[measured.index++]);else if(force||this.outdated)this.setHeight(oracle,Math.max(this.widgetHeight,oracle.heightForLine(this.length-this.collapsed)));this.outdated=false;return this;}},{key:"toString",value:function toString(){return"line(".concat(this.length).concat(this.collapsed?-this.collapsed:"").concat(this.widgetHeight?":"+this.widgetHeight:"",")");}}]);return HeightMapText;}(HeightMapBlock);var HeightMapGap=/*#__PURE__*/function(_HeightMap2){_inherits(HeightMapGap,_HeightMap2);var _super21=_createSuper(HeightMapGap);function HeightMapGap(length){_classCallCheck(this,HeightMapGap);return _super21.call(this,length,0);}_createClass(HeightMapGap,[{key:"lines",value:function lines(doc,offset){var firstLine=doc.lineAt(offset).number,lastLine=doc.lineAt(offset+this.length).number;return{firstLine:firstLine,lastLine:lastLine,lineHeight:this.height/(lastLine-firstLine+1)};}},{key:"blockAt",value:function blockAt(height,doc,top,offset){var _this$lines=this.lines(doc,offset),firstLine=_this$lines.firstLine,lastLine=_this$lines.lastLine,lineHeight=_this$lines.lineHeight;var line=Math.max(0,Math.min(lastLine-firstLine,Math.floor((height-top)/lineHeight)));var _doc$line=doc.line(firstLine+line),from=_doc$line.from,length=_doc$line.length;return new BlockInfo(from,length,top+lineHeight*line,lineHeight,exports.BlockType.Text);}},{key:"lineAt",value:function lineAt(value,type,doc,top,offset){if(type==QueryType.ByHeight)return this.blockAt(value,doc,top,offset);if(type==QueryType.ByPosNoHeight){var _doc$lineAt=doc.lineAt(value),_from2=_doc$lineAt.from,to=_doc$lineAt.to;return new BlockInfo(_from2,to-_from2,0,0,exports.BlockType.Text);}var _this$lines2=this.lines(doc,offset),firstLine=_this$lines2.firstLine,lineHeight=_this$lines2.lineHeight;var _doc$lineAt2=doc.lineAt(value),from=_doc$lineAt2.from,length=_doc$lineAt2.length,number=_doc$lineAt2.number;return new BlockInfo(from,length,top+lineHeight*(number-firstLine),lineHeight,exports.BlockType.Text);}},{key:"forEachLine",value:function forEachLine(from,to,doc,top,offset,f){var _this$lines3=this.lines(doc,offset),firstLine=_this$lines3.firstLine,lineHeight=_this$lines3.lineHeight;for(var pos=Math.max(from,offset),end=Math.min(offset+this.length,to);pos<=end;){var line=doc.lineAt(pos);if(pos==from)top+=lineHeight*(line.number-firstLine);f(new BlockInfo(line.from,line.length,top,lineHeight,exports.BlockType.Text));top+=lineHeight;pos=line.to+1;}}},{key:"replace",value:function replace(from,to,nodes){var after=this.length-to;if(after>0){var last=nodes[nodes.length-1];if(last instanceof HeightMapGap)nodes[nodes.length-1]=new HeightMapGap(last.length+after);else nodes.push(null,new HeightMapGap(after-1));}if(from>0){var first=nodes[0];if(first instanceof HeightMapGap)nodes[0]=new HeightMapGap(from+first.length);else nodes.unshift(new HeightMapGap(from-1),null);}return HeightMap.of(nodes);}},{key:"decomposeLeft",value:function decomposeLeft(to,result){result.push(new HeightMapGap(to-1),null);}},{key:"decomposeRight",value:function decomposeRight(from,result){result.push(null,new HeightMapGap(this.length-from-1));}},{key:"updateHeight",value:function updateHeight(oracle){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var measured=arguments.length>3?arguments[3]:undefined;var end=offset+this.length;if(measured&&measured.from<=offset+this.length&&measured.more){// Fill in part of this gap with measured lines. We know there
979979+// can't be widgets or collapsed ranges in those lines, because
980980+// they would already have been added to the heightmap (gaps
981981+// only contain plain text).
982982+var nodes=[],pos=Math.max(offset,measured.from),singleHeight=-1;var wasChanged=oracle.heightChanged;if(measured.from>offset)nodes.push(new HeightMapGap(measured.from-offset-1).updateHeight(oracle,offset));while(pos<=end&&measured.more){var len=oracle.doc.lineAt(pos).length;if(nodes.length)nodes.push(null);var height=measured.heights[measured.index++];if(singleHeight==-1)singleHeight=height;else if(Math.abs(height-singleHeight)>=Epsilon)singleHeight=-2;var line=new HeightMapText(len,height);line.outdated=false;nodes.push(line);pos+=len+1;}if(pos<=end)nodes.push(null,new HeightMapGap(end-pos).updateHeight(oracle,pos));var result=HeightMap.of(nodes);oracle.heightChanged=wasChanged||singleHeight<0||Math.abs(result.height-this.height)>=Epsilon||Math.abs(singleHeight-this.lines(oracle.doc,offset).lineHeight)>=Epsilon;return result;}else if(force||this.outdated){this.setHeight(oracle,oracle.heightForGap(offset,offset+this.length));this.outdated=false;}return this;}},{key:"toString",value:function toString(){return"gap(".concat(this.length,")");}}]);return HeightMapGap;}(HeightMap);var HeightMapBranch=/*#__PURE__*/function(_HeightMap3){_inherits(HeightMapBranch,_HeightMap3);var _super22=_createSuper(HeightMapBranch);function HeightMapBranch(left,brk,right){var _this35;_classCallCheck(this,HeightMapBranch);_this35=_super22.call(this,left.length+brk+right.length,left.height+right.height,brk|(left.outdated||right.outdated?2/* Outdated */:0));_this35.left=left;_this35.right=right;_this35.size=left.size+right.size;return _this35;}_createClass(HeightMapBranch,[{key:"break",get:function get(){return this.flags&1/* Break */;}},{key:"blockAt",value:function blockAt(height,doc,top,offset){var mid=top+this.left.height;return height<mid?this.left.blockAt(height,doc,top,offset):this.right.blockAt(height,doc,mid,offset+this.left.length+this["break"]);}},{key:"lineAt",value:function lineAt(value,type,doc,top,offset){var rightTop=top+this.left.height,rightOffset=offset+this.left.length+this["break"];var left=type==QueryType.ByHeight?value<rightTop:value<rightOffset;var base=left?this.left.lineAt(value,type,doc,top,offset):this.right.lineAt(value,type,doc,rightTop,rightOffset);if(this["break"]||(left?base.to<rightOffset:base.from>rightOffset))return base;var subQuery=type==QueryType.ByPosNoHeight?QueryType.ByPosNoHeight:QueryType.ByPos;if(left)return base.join(this.right.lineAt(rightOffset,subQuery,doc,rightTop,rightOffset));else return this.left.lineAt(rightOffset,subQuery,doc,top,offset).join(base);}},{key:"forEachLine",value:function forEachLine(from,to,doc,top,offset,f){var rightTop=top+this.left.height,rightOffset=offset+this.left.length+this["break"];if(this["break"]){if(from<rightOffset)this.left.forEachLine(from,to,doc,top,offset,f);if(to>=rightOffset)this.right.forEachLine(from,to,doc,rightTop,rightOffset,f);}else{var mid=this.lineAt(rightOffset,QueryType.ByPos,doc,top,offset);if(from<mid.from)this.left.forEachLine(from,mid.from-1,doc,top,offset,f);if(mid.to>=from&&mid.from<=to)f(mid);if(to>mid.to)this.right.forEachLine(mid.to+1,to,doc,rightTop,rightOffset,f);}}},{key:"replace",value:function replace(from,to,nodes){var rightStart=this.left.length+this["break"];if(to<rightStart)return this.balanced(this.left.replace(from,to,nodes),this.right);if(from>this.left.length)return this.balanced(this.left,this.right.replace(from-rightStart,to-rightStart,nodes));var result=[];if(from>0)this.decomposeLeft(from,result);var left=result.length;var _iterator55=_createForOfIteratorHelper(nodes),_step55;try{for(_iterator55.s();!(_step55=_iterator55.n()).done;){var node=_step55.value;result.push(node);}}catch(err){_iterator55.e(err);}finally{_iterator55.f();}if(from>0)mergeGaps(result,left-1);if(to<this.length){var right=result.length;this.decomposeRight(to,result);mergeGaps(result,right);}return HeightMap.of(result);}},{key:"decomposeLeft",value:function decomposeLeft(to,result){var left=this.left.length;if(to<=left)return this.left.decomposeLeft(to,result);result.push(this.left);if(this["break"]){left++;if(to>=left)result.push(null);}if(to>left)this.right.decomposeLeft(to-left,result);}},{key:"decomposeRight",value:function decomposeRight(from,result){var left=this.left.length,right=left+this["break"];if(from>=right)return this.right.decomposeRight(from-right,result);if(from<left)this.left.decomposeRight(from,result);if(this["break"]&&from<right)result.push(null);result.push(this.right);}},{key:"balanced",value:function balanced(left,right){if(left.size>2*right.size||right.size>2*left.size)return HeightMap.of(this["break"]?[left,null,right]:[left,right]);this.left=left;this.right=right;this.height=left.height+right.height;this.outdated=left.outdated||right.outdated;this.size=left.size+right.size;this.length=left.length+this["break"]+right.length;return this;}},{key:"updateHeight",value:function updateHeight(oracle){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var measured=arguments.length>3?arguments[3]:undefined;var left=this.left,right=this.right,rightStart=offset+left.length+this["break"],rebalance=null;if(measured&&measured.from<=offset+left.length&&measured.more)rebalance=left=left.updateHeight(oracle,offset,force,measured);else left.updateHeight(oracle,offset,force);if(measured&&measured.from<=rightStart+right.length&&measured.more)rebalance=right=right.updateHeight(oracle,rightStart,force,measured);else right.updateHeight(oracle,rightStart,force);if(rebalance)return this.balanced(left,right);this.height=this.left.height+this.right.height;this.outdated=false;return this;}},{key:"toString",value:function toString(){return this.left+(this["break"]?" ":"-")+this.right;}}]);return HeightMapBranch;}(HeightMap);function mergeGaps(nodes,around){var before,after;if(nodes[around]==null&&(before=nodes[around-1])instanceof HeightMapGap&&(after=nodes[around+1])instanceof HeightMapGap)nodes.splice(around-1,3,new HeightMapGap(before.length+1+after.length));}var relevantWidgetHeight=5;var NodeBuilder=/*#__PURE__*/function(){function NodeBuilder(pos,oracle){_classCallCheck(this,NodeBuilder);this.pos=pos;this.oracle=oracle;this.nodes=[];this.lineStart=-1;this.lineEnd=-1;this.covering=null;this.writtenTo=pos;}_createClass(NodeBuilder,[{key:"isCovered",get:function get(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering;}},{key:"span",value:function span(_from,to){if(this.lineStart>-1){var end=Math.min(to,this.lineEnd),last=this.nodes[this.nodes.length-1];if(last instanceof HeightMapText)last.length+=end-this.pos;else if(end>this.pos||!this.isCovered)this.nodes.push(new HeightMapText(end-this.pos,-1));this.writtenTo=end;if(to>end){this.nodes.push(null);this.writtenTo++;this.lineStart=-1;}}this.pos=to;}},{key:"point",value:function point(from,to,deco){if(from<to||deco.heightRelevant){var height=deco.widget?deco.widget.estimatedHeight:0;if(height<0)height=this.oracle.lineHeight;var len=to-from;if(deco.block){this.addBlock(new HeightMapBlock(len,height,deco.type));}else if(len||height>=relevantWidgetHeight){this.addLineDeco(height,len);}}else if(to>from){this.span(from,to);}if(this.lineEnd>-1&&this.lineEnd<this.pos)this.lineEnd=this.oracle.doc.lineAt(this.pos).to;}},{key:"enterLine",value:function enterLine(){if(this.lineStart>-1)return;var _this$oracle$doc$line=this.oracle.doc.lineAt(this.pos),from=_this$oracle$doc$line.from,to=_this$oracle$doc$line.to;this.lineStart=from;this.lineEnd=to;if(this.writtenTo<from){if(this.writtenTo<from-1||this.nodes[this.nodes.length-1]==null)this.nodes.push(this.blankContent(this.writtenTo,from-1));this.nodes.push(null);}if(this.pos>from)this.nodes.push(new HeightMapText(this.pos-from,-1));this.writtenTo=this.pos;}},{key:"blankContent",value:function blankContent(from,to){var gap=new HeightMapGap(to-from);if(this.oracle.doc.lineAt(from).to==to)gap.flags|=4/* SingleLine */;return gap;}},{key:"ensureLine",value:function ensureLine(){this.enterLine();var last=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(last instanceof HeightMapText)return last;var line=new HeightMapText(0,-1);this.nodes.push(line);return line;}},{key:"addBlock",value:function addBlock(block){this.enterLine();if(block.type==exports.BlockType.WidgetAfter&&!this.isCovered)this.ensureLine();this.nodes.push(block);this.writtenTo=this.pos=this.pos+block.length;if(block.type!=exports.BlockType.WidgetBefore)this.covering=block;}},{key:"addLineDeco",value:function addLineDeco(height,length){var line=this.ensureLine();line.length+=length;line.collapsed+=length;line.widgetHeight=Math.max(line.widgetHeight,height);this.writtenTo=this.pos=this.pos+length;}},{key:"finish",value:function finish(from){var last=this.nodes.length==0?null:this.nodes[this.nodes.length-1];if(this.lineStart>-1&&!(last instanceof HeightMapText)&&!this.isCovered)this.nodes.push(new HeightMapText(0,-1));else if(this.writtenTo<this.pos||last==null)this.nodes.push(this.blankContent(this.writtenTo,this.pos));var pos=from;var _iterator56=_createForOfIteratorHelper(this.nodes),_step56;try{for(_iterator56.s();!(_step56=_iterator56.n()).done;){var node=_step56.value;if(node instanceof HeightMapText)node.updateHeight(this.oracle,pos);pos+=node?node.length:1;}}catch(err){_iterator56.e(err);}finally{_iterator56.f();}return this.nodes;}// Always called with a region that on both sides either stretches
983983+// to a line break or the end of the document.
984984+// The returned array uses null to indicate line breaks, but never
985985+// starts or ends in a line break, or has multiple line breaks next
986986+// to each other.
987987+}],[{key:"build",value:function build(oracle,decorations,from,to){var builder=new NodeBuilder(from,oracle);rangeset.RangeSet.spans(decorations,from,to,builder,0);return builder.finish(from);}}]);return NodeBuilder;}();function heightRelevantDecoChanges(a,b,diff){var comp=new DecorationComparator();rangeset.RangeSet.compare(a,b,diff,comp,0);return comp.changes;}var DecorationComparator=/*#__PURE__*/function(){function DecorationComparator(){_classCallCheck(this,DecorationComparator);this.changes=[];}_createClass(DecorationComparator,[{key:"compareRange",value:function compareRange(){}},{key:"comparePoint",value:function comparePoint(from,to,a,b){if(from<to||a&&a.heightRelevant||b&&b.heightRelevant)addRange(from,to,this.changes,5);}}]);return DecorationComparator;}();function visiblePixelRange(dom,paddingTop){var rect=dom.getBoundingClientRect();var left=Math.max(0,rect.left),right=Math.min(innerWidth,rect.right);var top=Math.max(0,rect.top),bottom=Math.min(innerHeight,rect.bottom);var body=dom.ownerDocument.body;for(var parent=dom.parentNode;parent&&parent!=body;){if(parent.nodeType==1){var elt=parent;var style=window.getComputedStyle(elt);if((elt.scrollHeight>elt.clientHeight||elt.scrollWidth>elt.clientWidth)&&style.overflow!="visible"){var parentRect=elt.getBoundingClientRect();left=Math.max(left,parentRect.left);right=Math.min(right,parentRect.right);top=Math.max(top,parentRect.top);bottom=Math.min(bottom,parentRect.bottom);}parent=style.position=="absolute"||style.position=="fixed"?elt.offsetParent:elt.parentNode;}else if(parent.nodeType==11){// Shadow root
988988+parent=parent.host;}else{break;}}return{left:left-rect.left,right:Math.max(left,right)-rect.left,top:top-(rect.top+paddingTop),bottom:Math.max(top,bottom)-(rect.top+paddingTop)};}// Line gaps are placeholder widgets used to hide pieces of overlong
989989+// lines within the viewport, as a kludge to keep the editor
990990+// responsive when a ridiculously long line is loaded into it.
991991+var LineGap=/*#__PURE__*/function(){function LineGap(from,to,size){_classCallCheck(this,LineGap);this.from=from;this.to=to;this.size=size;}_createClass(LineGap,[{key:"draw",value:function draw(wrapping){return Decoration.replace({widget:new LineGapWidget(this.size,wrapping)}).range(this.from,this.to);}}],[{key:"same",value:function same(a,b){if(a.length!=b.length)return false;for(var _i38=0;_i38<a.length;_i38++){var gA=a[_i38],gB=b[_i38];if(gA.from!=gB.from||gA.to!=gB.to||gA.size!=gB.size)return false;}return true;}}]);return LineGap;}();var LineGapWidget=/*#__PURE__*/function(_WidgetType4){_inherits(LineGapWidget,_WidgetType4);var _super23=_createSuper(LineGapWidget);function LineGapWidget(size,vertical){var _this36;_classCallCheck(this,LineGapWidget);_this36=_super23.call(this);_this36.size=size;_this36.vertical=vertical;return _this36;}_createClass(LineGapWidget,[{key:"eq",value:function eq(other){return other.size==this.size&&other.vertical==this.vertical;}},{key:"toDOM",value:function toDOM(){var elt=document.createElement("div");if(this.vertical){elt.style.height=this.size+"px";}else{elt.style.width=this.size+"px";elt.style.height="2px";elt.style.display="inline-block";}return elt;}},{key:"estimatedHeight",get:function get(){return this.vertical?this.size:-1;}}]);return LineGapWidget;}(WidgetType);var ViewState=/*#__PURE__*/function(){function ViewState(state){_classCallCheck(this,ViewState);this.state=state;// These are contentDOM-local coordinates
992992+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.heightOracle=new HeightOracle();// See VP.MaxDOMHeight
993993+this.scaler=IdScaler;this.scrollTarget=null;// Briefly set to true when printing, to disable viewport limiting
994994+this.printing=false;// Flag set when editor content was redrawn, so that the next
995995+// measure stage knows it must read DOM layout
996996+this.mustMeasureContent=true;this.visibleRanges=[];// Cursor 'assoc' is only significant when the cursor is on a line
997997+// wrap point, where it must stick to the character that it is
998998+// associated with. Since browsers don't provide a reasonable
999999+// interface to set or query this, when a selection is set that
10001000+// might cause this to be significant, this flag is set. The next
10011001+// measure phase will check whether the cursor is on a line-wrapping
10021002+// boundary and, if so, reset it to make sure it is positioned in
10031003+// the right place.
10041004+this.mustEnforceCursorAssoc=false;this.heightMap=HeightMap.empty().applyChanges(state.facet(decorations),text.Text.empty,this.heightOracle.setDoc(state.doc),[new ChangedRange(0,0,0,state.doc.length)]);this.viewport=this.getViewport(0,null);this.updateViewportLines();this.updateForViewport();this.lineGaps=this.ensureLineGaps([]);this.lineGapDeco=Decoration.set(this.lineGaps.map(function(gap){return gap.draw(false);}));this.computeVisibleRanges();}_createClass(ViewState,[{key:"updateForViewport",value:function updateForViewport(){var _this37=this;var viewports=[this.viewport],main=this.state.selection.main;var _loop7=function _loop7(_i39){var pos=_i39?main.head:main.anchor;if(!viewports.some(function(_ref40){var from=_ref40.from,to=_ref40.to;return pos>=from&&pos<=to;})){var _this37$lineBlockAt=_this37.lineBlockAt(pos),from=_this37$lineBlockAt.from,to=_this37$lineBlockAt.to;viewports.push(new Viewport(from,to));}};for(var _i39=0;_i39<=1;_i39++){_loop7(_i39);}this.viewports=viewports.sort(function(a,b){return a.from-b.from;});this.scaler=this.heightMap.height<=7000000/* MaxDOMHeight */?IdScaler:new BigScaler(this.heightOracle.doc,this.heightMap,this.viewports);}},{key:"updateViewportLines",value:function updateViewportLines(){var _this38=this;this.viewportLines=[];this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,function(block){_this38.viewportLines.push(_this38.scaler.scale==1?block:scaleBlock(block,_this38.scaler));});}},{key:"update",value:function update(_update7){var scrollTarget=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var prev=this.state;this.state=_update7.state;var newDeco=this.state.facet(decorations);var contentChanges=_update7.changedRanges;var heightChanges=ChangedRange.extendWithRanges(contentChanges,heightRelevantDecoChanges(_update7.startState.facet(decorations),newDeco,_update7?_update7.changes:state.ChangeSet.empty(this.state.doc.length)));var prevHeight=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(newDeco,prev.doc,this.heightOracle.setDoc(this.state.doc),heightChanges);if(this.heightMap.height!=prevHeight)_update7.flags|=2/* Height */;var viewport=heightChanges.length?this.mapViewport(this.viewport,_update7.changes):this.viewport;if(scrollTarget&&(scrollTarget.range.head<viewport.from||scrollTarget.range.head>viewport.to)||!this.viewportIsAppropriate(viewport))viewport=this.getViewport(0,scrollTarget);var updateLines=!_update7.changes.empty||_update7.flags&2/* Height */||viewport.from!=this.viewport.from||viewport.to!=this.viewport.to;this.viewport=viewport;this.updateForViewport();if(updateLines)this.updateViewportLines();if(this.lineGaps.length||this.viewport.to-this.viewport.from>4000/* DoubleMargin */)this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,_update7.changes)));_update7.flags|=this.computeVisibleRanges();if(scrollTarget)this.scrollTarget=scrollTarget;if(!this.mustEnforceCursorAssoc&&_update7.selectionSet&&_update7.view.lineWrapping&&_update7.state.selection.main.empty&&_update7.state.selection.main.assoc)this.mustEnforceCursorAssoc=true;}},{key:"measure",value:function measure(view){var dom=view.contentDOM,style=window.getComputedStyle(dom);var oracle=this.heightOracle;var whiteSpace=style.whiteSpace,direction=style.direction=="rtl"?exports.Direction.RTL:exports.Direction.LTR;var refresh=this.heightOracle.mustRefreshForStyle(whiteSpace,direction);var measureContent=refresh||this.mustMeasureContent||this.contentDOMHeight!=dom.clientHeight;var result=0,bias=0;if(measureContent){this.mustMeasureContent=false;this.contentDOMHeight=dom.clientHeight;// Vertical padding
10051005+var paddingTop=parseInt(style.paddingTop)||0,paddingBottom=parseInt(style.paddingBottom)||0;if(this.paddingTop!=paddingTop||this.paddingBottom!=paddingBottom){result|=8/* Geometry */;this.paddingTop=paddingTop;this.paddingBottom=paddingBottom;}}// Pixel viewport
10061006+var pixelViewport=this.printing?{top:-1e8,bottom:1e8,left:-1e8,right:1e8}:visiblePixelRange(dom,this.paddingTop);var dTop=pixelViewport.top-this.pixelViewport.top,dBottom=pixelViewport.bottom-this.pixelViewport.bottom;this.pixelViewport=pixelViewport;var inView=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(inView!=this.inView){this.inView=inView;if(inView)measureContent=true;}if(!this.inView)return 0;var contentWidth=dom.clientWidth;if(this.contentDOMWidth!=contentWidth||this.editorHeight!=view.scrollDOM.clientHeight||this.editorWidth!=view.scrollDOM.clientWidth){this.contentDOMWidth=contentWidth;this.editorHeight=view.scrollDOM.clientHeight;this.editorWidth=view.scrollDOM.clientWidth;result|=8/* Geometry */;}if(measureContent){var lineHeights=view.docView.measureVisibleLineHeights();if(oracle.mustRefreshForHeights(lineHeights))refresh=true;if(refresh||oracle.lineWrapping&&Math.abs(contentWidth-this.contentDOMWidth)>oracle.charWidth){var _view$docView$measure=view.docView.measureTextSize(),lineHeight=_view$docView$measure.lineHeight,charWidth=_view$docView$measure.charWidth;refresh=oracle.refresh(whiteSpace,direction,lineHeight,charWidth,contentWidth/charWidth,lineHeights);if(refresh){view.docView.minWidth=0;result|=8/* Geometry */;}}if(dTop>0&&dBottom>0)bias=Math.max(dTop,dBottom);else if(dTop<0&&dBottom<0)bias=Math.min(dTop,dBottom);oracle.heightChanged=false;this.heightMap=this.heightMap.updateHeight(oracle,0,refresh,new MeasuredHeights(this.viewport.from,lineHeights));if(oracle.heightChanged)result|=2/* Height */;}var viewportChange=!this.viewportIsAppropriate(this.viewport,bias)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);if(viewportChange)this.viewport=this.getViewport(bias,this.scrollTarget);this.updateForViewport();if(result&2/* Height */||viewportChange)this.updateViewportLines();if(this.lineGaps.length||this.viewport.to-this.viewport.from>4000/* DoubleMargin */)this.updateLineGaps(this.ensureLineGaps(refresh?[]:this.lineGaps));result|=this.computeVisibleRanges();if(this.mustEnforceCursorAssoc){this.mustEnforceCursorAssoc=false;// This is done in the read stage, because moving the selection
10071007+// to a line end is going to trigger a layout anyway, so it
10081008+// can't be a pure write. It should be rare that it does any
10091009+// writing.
10101010+view.docView.enforceCursorAssoc();}return result;}},{key:"visibleTop",get:function get(){return this.scaler.fromDOM(this.pixelViewport.top);}},{key:"visibleBottom",get:function get(){return this.scaler.fromDOM(this.pixelViewport.bottom);}},{key:"getViewport",value:function getViewport(bias,scrollTarget){// This will divide VP.Margin between the top and the
10111011+// bottom, depending on the bias (the change in viewport position
10121012+// since the last update). It'll hold a number between 0 and 1
10131013+var marginTop=0.5-Math.max(-0.5,Math.min(0.5,bias/1000/* Margin *//2));var map=this.heightMap,doc=this.state.doc,visibleTop=this.visibleTop,visibleBottom=this.visibleBottom;var viewport=new Viewport(map.lineAt(visibleTop-marginTop*1000/* Margin */,QueryType.ByHeight,doc,0,0).from,map.lineAt(visibleBottom+(1-marginTop)*1000/* Margin */,QueryType.ByHeight,doc,0,0).to);// If scrollTarget is given, make sure the viewport includes that position
10141014+if(scrollTarget){var head=scrollTarget.range.head,viewHeight=this.editorHeight;if(head<viewport.from||head>viewport.to){var block=map.lineAt(head,QueryType.ByPos,doc,0,0),topPos;if(scrollTarget.y=="center")topPos=(block.top+block.bottom)/2-viewHeight/2;else if(scrollTarget.y=="start"||scrollTarget.y=="nearest"&&head<viewport.from)topPos=block.top;else topPos=block.bottom-viewHeight;viewport=new Viewport(map.lineAt(topPos-1000/* Margin *//2,QueryType.ByHeight,doc,0,0).from,map.lineAt(topPos+viewHeight+1000/* Margin *//2,QueryType.ByHeight,doc,0,0).to);}}return viewport;}},{key:"mapViewport",value:function mapViewport(viewport,changes){var from=changes.mapPos(viewport.from,-1),to=changes.mapPos(viewport.to,1);return new Viewport(this.heightMap.lineAt(from,QueryType.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(to,QueryType.ByPos,this.state.doc,0,0).to);}// Checks if a given viewport covers the visible part of the
10151015+// document and not too much beyond that.
10161016+},{key:"viewportIsAppropriate",value:function viewportIsAppropriate(_ref41){var from=_ref41.from,to=_ref41.to;var bias=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;if(!this.inView)return true;var _this$heightMap$lineA=this.heightMap.lineAt(from,QueryType.ByPos,this.state.doc,0,0),top=_this$heightMap$lineA.top;var _this$heightMap$lineA2=this.heightMap.lineAt(to,QueryType.ByPos,this.state.doc,0,0),bottom=_this$heightMap$lineA2.bottom;var visibleTop=this.visibleTop,visibleBottom=this.visibleBottom;return(from==0||top<=visibleTop-Math.max(10/* MinCoverMargin */,Math.min(-bias,250/* MaxCoverMargin */)))&&(to==this.state.doc.length||bottom>=visibleBottom+Math.max(10/* MinCoverMargin */,Math.min(bias,250/* MaxCoverMargin */)))&&top>visibleTop-2*1000/* Margin */&&bottom<visibleBottom+2*1000/* Margin */;}},{key:"mapLineGaps",value:function mapLineGaps(gaps,changes){if(!gaps.length||changes.empty)return gaps;var mapped=[];var _iterator57=_createForOfIteratorHelper(gaps),_step57;try{for(_iterator57.s();!(_step57=_iterator57.n()).done;){var gap=_step57.value;if(!changes.touchesRange(gap.from,gap.to))mapped.push(new LineGap(changes.mapPos(gap.from),changes.mapPos(gap.to),gap.size));}}catch(err){_iterator57.e(err);}finally{_iterator57.f();}return mapped;}// Computes positions in the viewport where the start or end of a
10171017+// line should be hidden, trying to reuse existing line gaps when
10181018+// appropriate to avoid unneccesary redraws.
10191019+// Uses crude character-counting for the positioning and sizing,
10201020+// since actual DOM coordinates aren't always available and
10211021+// predictable. Relies on generous margins (see LG.Margin) to hide
10221022+// the artifacts this might produce from the user.
10231023+},{key:"ensureLineGaps",value:function ensureLineGaps(current){var _this39=this;var gaps=[];// This won't work at all in predominantly right-to-left text.
10241024+if(this.heightOracle.direction!=exports.Direction.LTR)return gaps;var _iterator58=_createForOfIteratorHelper(this.viewportLines),_step58;try{var _loop8=function _loop8(){var line=_step58.value;if(line.length<4000/* DoubleMargin */)return"continue";var structure=lineStructure(line.from,line.to,_this39.state);if(structure.total<4000/* DoubleMargin */)return"continue";var viewFrom=void 0,viewTo=void 0;if(_this39.heightOracle.lineWrapping){var marginHeight=2000/* Margin *//_this39.heightOracle.lineLength*_this39.heightOracle.lineHeight;viewFrom=findPosition(structure,(_this39.visibleTop-line.top-marginHeight)/line.height);viewTo=findPosition(structure,(_this39.visibleBottom-line.top+marginHeight)/line.height);}else{var totalWidth=structure.total*_this39.heightOracle.charWidth;var marginWidth=2000/* Margin */*_this39.heightOracle.charWidth;viewFrom=findPosition(structure,(_this39.pixelViewport.left-marginWidth)/totalWidth);viewTo=findPosition(structure,(_this39.pixelViewport.right+marginWidth)/totalWidth);}var outside=[];if(viewFrom>line.from)outside.push({from:line.from,to:viewFrom});if(viewTo<line.to)outside.push({from:viewTo,to:line.to});var sel=_this39.state.selection.main;// Make sure the gaps don't cover a selection end
10251025+if(sel.from>=line.from&&sel.from<=line.to)cutRange(outside,sel.from-10/* SelectionMargin */,sel.from+10/* SelectionMargin */);if(!sel.empty&&sel.to>=line.from&&sel.to<=line.to)cutRange(outside,sel.to-10/* SelectionMargin */,sel.to+10/* SelectionMargin */);var _loop9=function _loop9(){var _outside$_i=_outside[_i40],from=_outside$_i.from,to=_outside$_i.to;if(to-from>1000/* HalfMargin */){gaps.push(find(current,function(gap){return gap.from>=line.from&&gap.to<=line.to&&Math.abs(gap.from-from)<1000/* HalfMargin */&&Math.abs(gap.to-to)<1000;}/* HalfMargin */)||new LineGap(from,to,_this39.gapSize(line,from,to,structure)));}};for(var _i40=0,_outside=outside;_i40<_outside.length;_i40++){_loop9();}};for(_iterator58.s();!(_step58=_iterator58.n()).done;){var _ret2=_loop8();if(_ret2==="continue")continue;}}catch(err){_iterator58.e(err);}finally{_iterator58.f();}return gaps;}},{key:"gapSize",value:function gapSize(line,from,to,structure){var fraction=findFraction(structure,to)-findFraction(structure,from);if(this.heightOracle.lineWrapping){return line.height*fraction;}else{return structure.total*this.heightOracle.charWidth*fraction;}}},{key:"updateLineGaps",value:function updateLineGaps(gaps){var _this40=this;if(!LineGap.same(gaps,this.lineGaps)){this.lineGaps=gaps;this.lineGapDeco=Decoration.set(gaps.map(function(gap){return gap.draw(_this40.heightOracle.lineWrapping);}));}}},{key:"computeVisibleRanges",value:function computeVisibleRanges(){var deco=this.state.facet(decorations);if(this.lineGaps.length)deco=deco.concat(this.lineGapDeco);var ranges=[];rangeset.RangeSet.spans(deco,this.viewport.from,this.viewport.to,{span:function span(from,to){ranges.push({from:from,to:to});},point:function point(){}},20);var changed=ranges.length!=this.visibleRanges.length||this.visibleRanges.some(function(r,i){return r.from!=ranges[i].from||r.to!=ranges[i].to;});this.visibleRanges=ranges;return changed?4/* Viewport */:0;}},{key:"lineBlockAt",value:function lineBlockAt(pos){return pos>=this.viewport.from&&pos<=this.viewport.to&&this.viewportLines.find(function(b){return b.from<=pos&&b.to>=pos;})||scaleBlock(this.heightMap.lineAt(pos,QueryType.ByPos,this.state.doc,0,0),this.scaler);}},{key:"lineBlockAtHeight",value:function lineBlockAtHeight(height){return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height),QueryType.ByHeight,this.state.doc,0,0),this.scaler);}},{key:"elementAtHeight",value:function elementAtHeight(height){return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height),this.state.doc,0,0),this.scaler);}},{key:"docHeight",get:function get(){return this.scaler.toDOM(this.heightMap.height);}},{key:"contentHeight",get:function get(){return this.docHeight+this.paddingTop+this.paddingBottom;}}]);return ViewState;}();var Viewport=/*#__PURE__*/_createClass(function Viewport(from,to){_classCallCheck(this,Viewport);this.from=from;this.to=to;});function lineStructure(from,to,state){var ranges=[],pos=from,total=0;rangeset.RangeSet.spans(state.facet(decorations),from,to,{span:function span(){},point:function point(from,to){if(from>pos){ranges.push({from:pos,to:from});total+=from-pos;}pos=to;}},20);// We're only interested in collapsed ranges of a significant size
10261026+if(pos<to){ranges.push({from:pos,to:to});total+=to-pos;}return{total:total,ranges:ranges};}function findPosition(_ref42,ratio){var total=_ref42.total,ranges=_ref42.ranges;if(ratio<=0)return ranges[0].from;if(ratio>=1)return ranges[ranges.length-1].to;var dist=Math.floor(total*ratio);for(var _i41=0;;_i41++){var _ranges$_i=ranges[_i41],from=_ranges$_i.from,to=_ranges$_i.to,size=to-from;if(dist<=size)return from+dist;dist-=size;}}function findFraction(structure,pos){var counted=0;var _iterator59=_createForOfIteratorHelper(structure.ranges),_step59;try{for(_iterator59.s();!(_step59=_iterator59.n()).done;){var _step59$value=_step59.value,from=_step59$value.from,to=_step59$value.to;if(pos<=to){counted+=pos-from;break;}counted+=to-from;}}catch(err){_iterator59.e(err);}finally{_iterator59.f();}return counted/structure.total;}function cutRange(ranges,from,to){for(var _i42=0;_i42<ranges.length;_i42++){var _r2=ranges[_i42];if(_r2.from<to&&_r2.to>from){var pieces=[];if(_r2.from<from)pieces.push({from:_r2.from,to:from});if(_r2.to>to)pieces.push({from:to,to:_r2.to});ranges.splice.apply(ranges,[_i42,1].concat(pieces));_i42+=pieces.length-1;}}}function find(array,f){var _iterator60=_createForOfIteratorHelper(array),_step60;try{for(_iterator60.s();!(_step60=_iterator60.n()).done;){var val=_step60.value;if(f(val))return val;}}catch(err){_iterator60.e(err);}finally{_iterator60.f();}return undefined;}// Don't scale when the document height is within the range of what
10271027+// the DOM can handle.
10281028+var IdScaler={toDOM:function toDOM(n){return n;},fromDOM:function fromDOM(n){return n;},scale:1};// When the height is too big (> VP.MaxDOMHeight), scale down the
10291029+// regions outside the viewports so that the total height is
10301030+// VP.MaxDOMHeight.
10311031+var BigScaler=/*#__PURE__*/function(){function BigScaler(doc,heightMap,viewports){_classCallCheck(this,BigScaler);var vpHeight=0,base=0,domBase=0;this.viewports=viewports.map(function(_ref43){var from=_ref43.from,to=_ref43.to;var top=heightMap.lineAt(from,QueryType.ByPos,doc,0,0).top;var bottom=heightMap.lineAt(to,QueryType.ByPos,doc,0,0).bottom;vpHeight+=bottom-top;return{from:from,to:to,top:top,bottom:bottom,domTop:0,domBottom:0};});this.scale=(7000000/* MaxDOMHeight */-vpHeight)/(heightMap.height-vpHeight);var _iterator61=_createForOfIteratorHelper(this.viewports),_step61;try{for(_iterator61.s();!(_step61=_iterator61.n()).done;){var obj=_step61.value;obj.domTop=domBase+(obj.top-base)*this.scale;domBase=obj.domBottom=obj.domTop+(obj.bottom-obj.top);base=obj.bottom;}}catch(err){_iterator61.e(err);}finally{_iterator61.f();}}_createClass(BigScaler,[{key:"toDOM",value:function toDOM(n){for(var _i43=0,base=0,domBase=0;;_i43++){var vp=_i43<this.viewports.length?this.viewports[_i43]:null;if(!vp||n<vp.top)return domBase+(n-base)*this.scale;if(n<=vp.bottom)return vp.domTop+(n-vp.top);base=vp.bottom;domBase=vp.domBottom;}}},{key:"fromDOM",value:function fromDOM(n){for(var _i44=0,base=0,domBase=0;;_i44++){var vp=_i44<this.viewports.length?this.viewports[_i44]:null;if(!vp||n<vp.domTop)return base+(n-domBase)/this.scale;if(n<=vp.domBottom)return vp.top+(n-vp.domTop);base=vp.bottom;domBase=vp.domBottom;}}}]);return BigScaler;}();function scaleBlock(block,scaler){if(scaler.scale==1)return block;var bTop=scaler.toDOM(block.top),bBottom=scaler.toDOM(block.bottom);return new BlockInfo(block.from,block.length,bTop,bBottom-bTop,Array.isArray(block.type)?block.type.map(function(b){return scaleBlock(b,scaler);}):block.type);}var _theme=state.Facet.define({combine:function combine(strs){return strs.join(" ");}});var darkTheme=state.Facet.define({combine:function combine(values){return values.indexOf(true)>-1;}});var baseThemeID=styleMod.StyleModule.newName(),baseLightID=styleMod.StyleModule.newName(),baseDarkID=styleMod.StyleModule.newName();var lightDarkIDs={"&light":"."+baseLightID,"&dark":"."+baseDarkID};function buildTheme(main,spec,scopes){return new styleMod.StyleModule(spec,{finish:function finish(sel){return /&/.test(sel)?sel.replace(/&\w*/,function(m){if(m=="&")return main;if(!scopes||!scopes[m])throw new RangeError("Unsupported selector: ".concat(m));return scopes[m];}):main+" "+sel;}});}var baseTheme=buildTheme("."+baseThemeID,{"&.cm-editor":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{// Provide a simple default outline to make sure a focused
10321032+// editor is visually distinct. Can't leave the default behavior
10331033+// because that will apply to the content element, which is
10341034+// inside the scrollable container and doesn't include the
10351035+// gutters. We also can't use an 'auto' outline, since those
10361036+// are, for some reason, drawn behind the element content, which
10371037+// will cause things like the active line background to cover
10381038+// the outline (#297).
10391039+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,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},// Two animations defined so that we can switch between them to
10401040+// restart the animation without forcing another style
10411041+// recomputation.
10421042+"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor, .cm-dropCursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".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"}},lightDarkIDs);var observeOptions={childList:true,characterData:true,subtree:true,attributes:true,characterDataOldValue:true};// IE11 has very broken mutation observers, so we also listen to
10431043+// DOMCharacterDataModified there
10441044+var useCharData=browser.ie&&browser.ie_version<=11;var DOMObserver=/*#__PURE__*/function(){function DOMObserver(view,onChange,onScrollChanged){var _this41=this;_classCallCheck(this,DOMObserver);this.view=view;this.onChange=onChange;this.onScrollChanged=onScrollChanged;this.active=false;// The known selection. Kept in our own object, as opposed to just
10451045+// directly accessing the selection because:
10461046+// - Safari doesn't report the right selection in shadow DOM
10471047+// - Reading from the selection forces a DOM layout
10481048+// - This way, we can ignore selectionchange events if we have
10491049+// already seen the 'new' selection
10501050+this.selectionRange=new DOMSelectionState();// Set when a selection change is detected, cleared on flush
10511051+this.selectionChanged=false;this.delayedFlush=-1;this.resizeTimeout=-1;this.queue=[];this.delayedAndroidKey=null;this.scrollTargets=[];this.intersection=null;this.resize=null;this.intersecting=false;this.gapIntersection=null;this.gaps=[];// Timeout for scheduling check of the parents that need scroll handlers
10521052+this.parentCheck=-1;this.dom=view.contentDOM;this.observer=new MutationObserver(function(mutations){var _iterator62=_createForOfIteratorHelper(mutations),_step62;try{for(_iterator62.s();!(_step62=_iterator62.n()).done;){var mut=_step62.value;_this41.queue.push(mut);}// IE11 will sometimes (on typing over a selection or
10531053+// backspacing out a single character text node) call the
10541054+// observer callback before actually updating the DOM.
10551055+//
10561056+// Unrelatedly, iOS Safari will, when ending a composition,
10571057+// sometimes first clear it, deliver the mutations, and then
10581058+// reinsert the finished text. CodeMirror's handling of the
10591059+// deletion will prevent the reinsertion from happening,
10601060+// breaking composition.
10611061+}catch(err){_iterator62.e(err);}finally{_iterator62.f();}if((browser.ie&&browser.ie_version<=11||browser.ios&&view.composing)&&mutations.some(function(m){return m.type=="childList"&&m.removedNodes.length||m.type=="characterData"&&m.oldValue.length>m.target.nodeValue.length;}))_this41.flushSoon();else _this41.flush();});if(useCharData)this.onCharData=function(event){_this41.queue.push({target:event.target,type:"characterData",oldValue:event.prevValue});_this41.flushSoon();};this.onSelectionChange=this.onSelectionChange.bind(this);if(typeof ResizeObserver=="function"){this.resize=new ResizeObserver(function(){if(_this41.view.docView.lastUpdate<Date.now()-75&&_this41.resizeTimeout<0)_this41.resizeTimeout=setTimeout(function(){_this41.resizeTimeout=-1;_this41.view.requestMeasure();},50);});this.resize.observe(view.scrollDOM);}this.start();this.onScroll=this.onScroll.bind(this);window.addEventListener("scroll",this.onScroll);if(typeof IntersectionObserver=="function"){this.intersection=new IntersectionObserver(function(entries){if(_this41.parentCheck<0)_this41.parentCheck=setTimeout(_this41.listenForScroll.bind(_this41),1000);if(entries.length>0&&entries[entries.length-1].intersectionRatio>0!=_this41.intersecting){_this41.intersecting=!_this41.intersecting;if(_this41.intersecting!=_this41.view.inView)_this41.onScrollChanged(document.createEvent("Event"));}},{});this.intersection.observe(this.dom);this.gapIntersection=new IntersectionObserver(function(entries){if(entries.length>0&&entries[entries.length-1].intersectionRatio>0)_this41.onScrollChanged(document.createEvent("Event"));},{});}this.listenForScroll();this.readSelectionRange();this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange);}_createClass(DOMObserver,[{key:"onScroll",value:function onScroll(e){if(this.intersecting)this.flush(false);this.onScrollChanged(e);}},{key:"updateGaps",value:function updateGaps(gaps){if(this.gapIntersection&&(gaps.length!=this.gaps.length||this.gaps.some(function(g,i){return g!=gaps[i];}))){this.gapIntersection.disconnect();var _iterator63=_createForOfIteratorHelper(gaps),_step63;try{for(_iterator63.s();!(_step63=_iterator63.n()).done;){var gap=_step63.value;this.gapIntersection.observe(gap);}}catch(err){_iterator63.e(err);}finally{_iterator63.f();}this.gaps=gaps;}}},{key:"onSelectionChange",value:function onSelectionChange(event){if(!this.readSelectionRange()||this.delayedAndroidKey)return;var view=this.view,sel=this.selectionRange;if(view.state.facet(editable)?view.root.activeElement!=this.dom:!hasSelection(view.dom,sel))return;var context=sel.anchorNode&&view.docView.nearest(sel.anchorNode);if(context&&context.ignoreEvent(event))return;// Deletions on IE11 fire their events in the wrong order, giving
10621062+// us a selection change event before the DOM changes are
10631063+// reported.
10641064+// Chrome Android has a similar issue when backspacing out a
10651065+// selection (#645).
10661066+if((browser.ie&&browser.ie_version<=11||browser.android&&browser.chrome)&&!view.state.selection.main.empty&&// (Selection.isCollapsed isn't reliable on IE)
10671067+sel.focusNode&&isEquivalentPosition(sel.focusNode,sel.focusOffset,sel.anchorNode,sel.anchorOffset))this.flushSoon();else this.flush(false);}},{key:"readSelectionRange",value:function readSelectionRange(){var root=this.view.root,domSel=getSelection(root);// The Selection object is broken in shadow roots in Safari. See
10681068+// https://github.com/codemirror/codemirror.next/issues/414
10691069+var range=browser.safari&&root.nodeType==11&&deepActiveElement()==this.view.contentDOM&&safariSelectionRangeHack(this.view)||domSel;if(this.selectionRange.eq(range))return false;this.selectionRange.setRange(range);return this.selectionChanged=true;}},{key:"setSelectionRange",value:function setSelectionRange(anchor,head){this.selectionRange.set(anchor.node,anchor.offset,head.node,head.offset);this.selectionChanged=false;}},{key:"listenForScroll",value:function listenForScroll(){this.parentCheck=-1;var i=0,changed=null;for(var dom=this.dom;dom;){if(dom.nodeType==1){if(!changed&&i<this.scrollTargets.length&&this.scrollTargets[i]==dom)i++;else if(!changed)changed=this.scrollTargets.slice(0,i);if(changed)changed.push(dom);dom=dom.assignedSlot||dom.parentNode;}else if(dom.nodeType==11){// Shadow root
10701070+dom=dom.host;}else{break;}}if(i<this.scrollTargets.length&&!changed)changed=this.scrollTargets.slice(0,i);if(changed){var _iterator64=_createForOfIteratorHelper(this.scrollTargets),_step64;try{for(_iterator64.s();!(_step64=_iterator64.n()).done;){var _dom2=_step64.value;_dom2.removeEventListener("scroll",this.onScroll);}}catch(err){_iterator64.e(err);}finally{_iterator64.f();}var _iterator65=_createForOfIteratorHelper(this.scrollTargets=changed),_step65;try{for(_iterator65.s();!(_step65=_iterator65.n()).done;){var _dom3=_step65.value;_dom3.addEventListener("scroll",this.onScroll);}}catch(err){_iterator65.e(err);}finally{_iterator65.f();}}}},{key:"ignore",value:function ignore(f){if(!this.active)return f();try{this.stop();return f();}finally{this.start();this.clear();}}},{key:"start",value:function start(){if(this.active)return;this.observer.observe(this.dom,observeOptions);if(useCharData)this.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.active=true;}},{key:"stop",value:function stop(){if(!this.active)return;this.active=false;this.observer.disconnect();if(useCharData)this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData);}// Throw away any pending changes
10711071+},{key:"clear",value:function clear(){this.observer.takeRecords();this.queue.length=0;this.selectionChanged=false;}// Chrome Android, especially in combination with GBoard, not only
10721072+// doesn't reliably fire regular key events, but also often
10731073+// surrounds the effect of enter or backspace with a bunch of
10741074+// composition events that, when interrupted, cause text duplication
10751075+// or other kinds of corruption. This hack makes the editor back off
10761076+// from handling DOM changes for a moment when such a key is
10771077+// detected (via beforeinput or keydown), and then dispatches the
10781078+// key event, throwing away the DOM changes if it gets handled.
10791079+},{key:"delayAndroidKey",value:function delayAndroidKey(key,keyCode){var _this42=this;if(!this.delayedAndroidKey)requestAnimationFrame(function(){var key=_this42.delayedAndroidKey;_this42.delayedAndroidKey=null;var startState=_this42.view.state;if(dispatchKey(_this42.view.contentDOM,key.key,key.keyCode))_this42.processRecords();else _this42.flush();if(_this42.view.state==startState)_this42.view.update([]);});// Since backspace beforeinput is sometimes signalled spuriously,
10801080+// Enter always takes precedence.
10811081+if(!this.delayedAndroidKey||key=="Enter")this.delayedAndroidKey={key:key,keyCode:keyCode};}},{key:"flushSoon",value:function flushSoon(){var _this43=this;if(this.delayedFlush<0)this.delayedFlush=window.setTimeout(function(){_this43.delayedFlush=-1;_this43.flush();},20);}},{key:"forceFlush",value:function forceFlush(){if(this.delayedFlush>=0){window.clearTimeout(this.delayedFlush);this.delayedFlush=-1;this.flush();}}},{key:"processRecords",value:function processRecords(){var records=this.queue;var _iterator66=_createForOfIteratorHelper(this.observer.takeRecords()),_step66;try{for(_iterator66.s();!(_step66=_iterator66.n()).done;){var mut=_step66.value;records.push(mut);}}catch(err){_iterator66.e(err);}finally{_iterator66.f();}if(records.length)this.queue=[];var from=-1,to=-1,typeOver=false;var _iterator67=_createForOfIteratorHelper(records),_step67;try{for(_iterator67.s();!(_step67=_iterator67.n()).done;){var record=_step67.value;var range=this.readMutation(record);if(!range)continue;if(range.typeOver)typeOver=true;if(from==-1){from=range.from;to=range.to;}else{from=Math.min(range.from,from);to=Math.max(range.to,to);}}}catch(err){_iterator67.e(err);}finally{_iterator67.f();}return{from:from,to:to,typeOver:typeOver};}// Apply pending changes, if any
10821082+},{key:"flush",value:function flush(){var readSelection=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;// Completely hold off flushing when pending keys are set—the code
10831083+// managing those will make sure processRecords is called and the
10841084+// view is resynchronized after
10851085+if(this.delayedFlush>=0||this.delayedAndroidKey)return;if(readSelection)this.readSelectionRange();var _this$processRecords=this.processRecords(),from=_this$processRecords.from,to=_this$processRecords.to,typeOver=_this$processRecords.typeOver;var newSel=this.selectionChanged&&hasSelection(this.dom,this.selectionRange);if(from<0&&!newSel)return;this.selectionChanged=false;var startState=this.view.state;this.onChange(from,to,typeOver);// The view wasn't updated
10861086+if(this.view.state==startState)this.view.update([]);}},{key:"readMutation",value:function readMutation(rec){var cView=this.view.docView.nearest(rec.target);if(!cView||cView.ignoreMutation(rec))return null;cView.markDirty(rec.type=="attributes");if(rec.type=="attributes")cView.dirty|=4/* Attrs */;if(rec.type=="childList"){var childBefore=findChild(cView,rec.previousSibling||rec.target.previousSibling,-1);var childAfter=findChild(cView,rec.nextSibling||rec.target.nextSibling,1);return{from:childBefore?cView.posAfter(childBefore):cView.posAtStart,to:childAfter?cView.posBefore(childAfter):cView.posAtEnd,typeOver:false};}else if(rec.type=="characterData"){return{from:cView.posAtStart,to:cView.posAtEnd,typeOver:rec.target.nodeValue==rec.oldValue};}else{return null;}}},{key:"destroy",value:function destroy(){var _a,_b,_c;this.stop();(_a=this.intersection)===null||_a===void 0?void 0:_a.disconnect();(_b=this.gapIntersection)===null||_b===void 0?void 0:_b.disconnect();(_c=this.resize)===null||_c===void 0?void 0:_c.disconnect();var _iterator68=_createForOfIteratorHelper(this.scrollTargets),_step68;try{for(_iterator68.s();!(_step68=_iterator68.n()).done;){var dom=_step68.value;dom.removeEventListener("scroll",this.onScroll);}}catch(err){_iterator68.e(err);}finally{_iterator68.f();}window.removeEventListener("scroll",this.onScroll);this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange);clearTimeout(this.parentCheck);clearTimeout(this.resizeTimeout);}}]);return DOMObserver;}();function findChild(cView,dom,dir){while(dom){var curView=ContentView.get(dom);if(curView&&curView.parent==cView)return curView;var parent=dom.parentNode;dom=parent!=cView.dom?parent:dir>0?dom.nextSibling:dom.previousSibling;}return null;}// Used to work around a Safari Selection/shadow DOM bug (#414)
10871087+function safariSelectionRangeHack(view){var found=null;// Because Safari (at least in 2018-2021) doesn't provide regular
10881088+// access to the selection inside a shadowroot, we have to perform a
10891089+// ridiculous hack to get at it—using `execCommand` to trigger a
10901090+// `beforeInput` event so that we can read the target range from the
10911091+// event.
10921092+function read(event){event.preventDefault();event.stopImmediatePropagation();found=event.getTargetRanges()[0];}view.contentDOM.addEventListener("beforeinput",read,true);document.execCommand("indent");view.contentDOM.removeEventListener("beforeinput",read,true);if(!found)return null;var anchorNode=found.startContainer,anchorOffset=found.startOffset;var focusNode=found.endContainer,focusOffset=found.endOffset;var curAnchor=view.docView.domAtPos(view.state.selection.main.anchor);// Since such a range doesn't distinguish between anchor and head,
10931093+// use a heuristic that flips it around if its end matches the
10941094+// current anchor.
10951095+if(isEquivalentPosition(curAnchor.node,curAnchor.offset,focusNode,focusOffset)){var _ref44=[focusNode,focusOffset,anchorNode,anchorOffset];anchorNode=_ref44[0];anchorOffset=_ref44[1];focusNode=_ref44[2];focusOffset=_ref44[3];}return{anchorNode:anchorNode,anchorOffset:anchorOffset,focusNode:focusNode,focusOffset:focusOffset};}function applyDOMChange(view,start,end,typeOver){var change,newSel;var sel=view.state.selection.main;if(start>-1){var bounds=view.docView.domBoundsAround(start,end,0);if(!bounds||view.state.readOnly)return;var from=bounds.from,to=bounds.to;var selPoints=view.docView.impreciseHead||view.docView.impreciseAnchor?[]:selectionPoints(view);var reader=new DOMReader(selPoints,view);reader.readRange(bounds.startDOM,bounds.endDOM);newSel=selectionFromPoints(selPoints,from);var preferredPos=sel.from,preferredSide=null;// Prefer anchoring to end when Backspace is pressed (or, on
10961096+// Android, when something was deleted)
10971097+if(view.inputState.lastKeyCode===8&&view.inputState.lastKeyTime>Date.now()-100||browser.android&&reader.text.length<to-from){preferredPos=sel.to;preferredSide="end";}var diff=findDiff(view.state.sliceDoc(from,to),reader.text,preferredPos-from,preferredSide);if(diff)change={from:from+diff.from,to:from+diff.toA,insert:view.state.toText(reader.text.slice(diff.from,diff.toB))};}else if(view.hasFocus||!view.state.facet(editable)){var domSel=view.observer.selectionRange;var _view$docView=view.docView,iHead=_view$docView.impreciseHead,iAnchor=_view$docView.impreciseAnchor;var head=iHead&&iHead.node==domSel.focusNode&&iHead.offset==domSel.focusOffset||!contains(view.contentDOM,domSel.focusNode)?view.state.selection.main.head:view.docView.posFromDOM(domSel.focusNode,domSel.focusOffset);var anchor=iAnchor&&iAnchor.node==domSel.anchorNode&&iAnchor.offset==domSel.anchorOffset||!contains(view.contentDOM,domSel.anchorNode)?view.state.selection.main.anchor:view.docView.posFromDOM(domSel.anchorNode,domSel.anchorOffset);if(head!=sel.head||anchor!=sel.anchor)newSel=state.EditorSelection.single(anchor,head);}if(!change&&!newSel)return;// Heuristic to notice typing over a selected character
10981098+if(!change&&typeOver&&!sel.empty&&newSel&&newSel.main.empty)change={from:sel.from,to:sel.to,insert:view.state.doc.slice(sel.from,sel.to)};// If the change is inside the selection and covers most of it,
10991099+// assume it is a selection replace (with identical characters at
11001100+// the start/end not included in the diff)
11011101+else if(change&&change.from>=sel.from&&change.to<=sel.to&&(change.from!=sel.from||change.to!=sel.to)&&sel.to-sel.from-(change.to-change.from)<=4)change={from:sel.from,to:sel.to,insert:view.state.doc.slice(sel.from,change.from).append(change.insert).append(view.state.doc.slice(change.to,sel.to))};if(change){var startState=view.state;if(browser.ios&&view.inputState.flushIOSKey(view))return;// Android browsers don't fire reasonable key events for enter,
11021102+// backspace, or delete. So this detects changes that look like
11031103+// they're caused by those keys, and reinterprets them as key
11041104+// events. (Some of these keys are also handled by beforeinput
11051105+// events and the pendingAndroidKey mechanism, but that's not
11061106+// reliable in all situations.)
11071107+if(browser.android&&(change.from==sel.from&&change.to==sel.to&&change.insert.length==1&&change.insert.lines==2&&dispatchKey(view.contentDOM,"Enter",13)||change.from==sel.from-1&&change.to==sel.to&&change.insert.length==0&&dispatchKey(view.contentDOM,"Backspace",8)||change.from==sel.from&&change.to==sel.to+1&&change.insert.length==0&&dispatchKey(view.contentDOM,"Delete",46)))return;var _text2=change.insert.toString();if(view.state.facet(inputHandler).some(function(h){return h(view,change.from,change.to,_text2);}))return;if(view.inputState.composing>=0)view.inputState.composing++;var tr;if(change.from>=sel.from&&change.to<=sel.to&&change.to-change.from>=(sel.to-sel.from)/3&&(!newSel||newSel.main.empty&&newSel.main.from==change.from+change.insert.length)&&view.inputState.composing<0){var before=sel.from<change.from?startState.sliceDoc(sel.from,change.from):"";var after=sel.to>change.to?startState.sliceDoc(change.to,sel.to):"";tr=startState.replaceSelection(view.state.toText(before+change.insert.sliceString(0,undefined,view.state.lineBreak)+after));}else{var changes=startState.changes(change);var mainSel=newSel&&!startState.selection.main.eq(newSel.main)&&newSel.main.to<=changes.newLength?newSel.main:undefined;// Try to apply a composition change to all cursors
11081108+if(startState.selection.ranges.length>1&&view.inputState.composing>=0&&change.to<=sel.to&&change.to>=sel.to-10){var replaced=view.state.sliceDoc(change.from,change.to);var compositionRange=compositionSurroundingNode(view)||view.state.doc.lineAt(sel.head);var offset=sel.to-change.to,size=sel.to-sel.from;tr=startState.changeByRange(function(range){if(range.from==sel.from&&range.to==sel.to)return{changes:changes,range:mainSel||range.map(changes)};var to=range.to-offset,from=to-replaced.length;if(range.to-range.from!=size||view.state.sliceDoc(from,to)!=replaced||// Unfortunately, there's no way to make multiple
11091109+// changes in the same node work without aborting
11101110+// composition, so cursors in the composition range are
11111111+// ignored.
11121112+compositionRange&&range.to>=compositionRange.from&&range.from<=compositionRange.to)return{range:range};var rangeChanges=startState.changes({from:from,to:to,insert:change.insert}),selOff=range.to-sel.to;return{changes:rangeChanges,range:!mainSel?range.map(rangeChanges):state.EditorSelection.range(Math.max(0,mainSel.anchor+selOff),Math.max(0,mainSel.head+selOff))};});}else{tr={changes:changes,selection:mainSel&&startState.selection.replaceRange(mainSel)};}}var userEvent="input.type";if(view.composing){userEvent+=".compose";if(view.inputState.compositionFirstChange){userEvent+=".start";view.inputState.compositionFirstChange=false;}}view.dispatch(tr,{scrollIntoView:true,userEvent:userEvent});}else if(newSel&&!newSel.main.eq(sel)){var _scrollIntoView=false,_userEvent="select";if(view.inputState.lastSelectionTime>Date.now()-50){if(view.inputState.lastSelectionOrigin=="select")_scrollIntoView=true;_userEvent=view.inputState.lastSelectionOrigin;}view.dispatch({selection:newSel,scrollIntoView:_scrollIntoView,userEvent:_userEvent});}}function findDiff(a,b,preferredPos,preferredSide){var minLen=Math.min(a.length,b.length);var from=0;while(from<minLen&&a.charCodeAt(from)==b.charCodeAt(from)){from++;}if(from==minLen&&a.length==b.length)return null;var toA=a.length,toB=b.length;while(toA>0&&toB>0&&a.charCodeAt(toA-1)==b.charCodeAt(toB-1)){toA--;toB--;}if(preferredSide=="end"){var adjust=Math.max(0,from-Math.min(toA,toB));preferredPos-=toA+adjust-from;}if(toA<from&&a.length<b.length){var move=preferredPos<=from&&preferredPos>=toA?from-preferredPos:0;from-=move;toB=from+(toB-toA);toA=from;}else if(toB<from){var _move=preferredPos<=from&&preferredPos>=toB?from-preferredPos:0;from-=_move;toA=from+(toA-toB);toB=from;}return{from:from,toA:toA,toB:toB};}function selectionPoints(view){var result=[];if(view.root.activeElement!=view.contentDOM)return result;var _view$observer$select=view.observer.selectionRange,anchorNode=_view$observer$select.anchorNode,anchorOffset=_view$observer$select.anchorOffset,focusNode=_view$observer$select.focusNode,focusOffset=_view$observer$select.focusOffset;if(anchorNode){result.push(new DOMPoint(anchorNode,anchorOffset));if(focusNode!=anchorNode||focusOffset!=anchorOffset)result.push(new DOMPoint(focusNode,focusOffset));}return result;}function selectionFromPoints(points,base){if(points.length==0)return null;var anchor=points[0].pos,head=points.length==2?points[1].pos:anchor;return anchor>-1&&head>-1?state.EditorSelection.single(anchor+base,head+base):null;}// The editor's update state machine looks something like this:
11131113+//
11141114+// Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
11151115+// ↑ ↓
11161116+// Updating (measure)
11171117+//
11181118+// The difference between 'Idle' and 'Idle (unchecked)' lies in
11191119+// whether a layout check has been scheduled. A regular update through
11201120+// the `update` method updates the DOM in a write-only fashion, and
11211121+// relies on a check (scheduled with `requestAnimationFrame`) to make
11221122+// sure everything is where it should be and the viewport covers the
11231123+// visible code. That check continues to measure and then optionally
11241124+// update until it reaches a coherent state.
11251125+/**
11261126+An editor view represents the editor's user interface. It holds
11271127+the editable DOM surface, and possibly other elements such as the
11281128+line number gutter. It handles events and dispatches state
11291129+transactions for editing actions.
11301130+*/var EditorView=/*#__PURE__*/function(){/**
11311131+ Construct a new view. You'll usually want to put `view.dom` into
11321132+ your document after creating a view, so that the user can see
11331133+ it.
11341134+ */function EditorView(){var _this44=this;var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,EditorView);this.plugins=[];this.pluginMap=new Map();this.editorAttrs={};this.contentAttrs={};this.bidiCache=[];this.destroyed=false;/**
11351135+ @internal
11361136+ */this.updateState=2/* Updating */;/**
11371137+ @internal
11381138+ */this.measureScheduled=-1;/**
11391139+ @internal
11401140+ */this.measureRequests=[];this.contentDOM=document.createElement("div");this.scrollDOM=document.createElement("div");this.scrollDOM.tabIndex=-1;this.scrollDOM.className="cm-scroller";this.scrollDOM.appendChild(this.contentDOM);this.announceDOM=document.createElement("div");this.announceDOM.style.cssText="position: absolute; top: -10000px";this.announceDOM.setAttribute("aria-live","polite");this.dom=document.createElement("div");this.dom.appendChild(this.announceDOM);this.dom.appendChild(this.scrollDOM);this._dispatch=config.dispatch||function(tr){return _this44.update([tr]);};this.dispatch=this.dispatch.bind(this);this.root=config.root||getRoot(config.parent)||document;this.viewState=new ViewState(config.state||state.EditorState.create());this.plugins=this.state.facet(viewPlugin).map(function(spec){return new PluginInstance(spec);});var _iterator69=_createForOfIteratorHelper(this.plugins),_step69;try{for(_iterator69.s();!(_step69=_iterator69.n()).done;){var _plugin3=_step69.value;_plugin3.update(this);}}catch(err){_iterator69.e(err);}finally{_iterator69.f();}this.observer=new DOMObserver(this,function(from,to,typeOver){applyDOMChange(_this44,from,to,typeOver);},function(event){_this44.inputState.runScrollHandlers(_this44,event);if(_this44.observer.intersecting)_this44.measure();});this.inputState=new InputState(this);this.docView=new DocView(this);this.mountStyles();this.updateAttrs();this.updateState=0/* Idle */;ensureGlobalHandler();this.requestMeasure();if(config.parent)config.parent.appendChild(this.dom);}/**
11411141+ The current editor state.
11421142+ */_createClass(EditorView,[{key:"state",get:function get(){return this.viewState.state;}/**
11431143+ To be able to display large documents without consuming too much
11441144+ memory or overloading the browser, CodeMirror only draws the
11451145+ code that is visible (plus a margin around it) to the DOM. This
11461146+ property tells you the extent of the current drawn viewport, in
11471147+ document positions.
11481148+ */},{key:"viewport",get:function get(){return this.viewState.viewport;}/**
11491149+ When there are, for example, large collapsed ranges in the
11501150+ viewport, its size can be a lot bigger than the actual visible
11511151+ content. Thus, if you are doing something like styling the
11521152+ content in the viewport, it is preferable to only do so for
11531153+ these ranges, which are the subset of the viewport that is
11541154+ actually drawn.
11551155+ */},{key:"visibleRanges",get:function get(){return this.viewState.visibleRanges;}/**
11561156+ Returns false when the editor is entirely scrolled out of view
11571157+ or otherwise hidden.
11581158+ */},{key:"inView",get:function get(){return this.viewState.inView;}/**
11591159+ Indicates whether the user is currently composing text via
11601160+ [IME](https://en.wikipedia.org/wiki/Input_method).
11611161+ */},{key:"composing",get:function get(){return this.inputState.composing>0;}},{key:"dispatch",value:function dispatch(){var _this$state;this._dispatch(arguments.length==1&&(arguments.length<=0?undefined:arguments[0])instanceof state.Transaction?arguments.length<=0?undefined:arguments[0]:(_this$state=this.state).update.apply(_this$state,arguments));}/**
11621162+ Update the view for the given array of transactions. This will
11631163+ update the visible document and selection to match the state
11641164+ produced by the transactions, and notify view plugins of the
11651165+ change. You should usually call
11661166+ [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
11671167+ as a primitive.
11681168+ */},{key:"update",value:function update(transactions){if(this.updateState!=0/* Idle */)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");var redrawn=false,update;var state$1=this.state;var _iterator70=_createForOfIteratorHelper(transactions),_step70;try{for(_iterator70.s();!(_step70=_iterator70.n()).done;){var _tr2=_step70.value;if(_tr2.startState!=state$1)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");state$1=_tr2.state;}}catch(err){_iterator70.e(err);}finally{_iterator70.f();}if(this.destroyed){this.viewState.state=state$1;return;}// When the phrases change, redraw the editor
11691169+if(state$1.facet(state.EditorState.phrases)!=this.state.facet(state.EditorState.phrases))return this.setState(state$1);update=new ViewUpdate(this,state$1,transactions);var scrollTarget=this.viewState.scrollTarget;try{this.updateState=2/* Updating */;var _iterator71=_createForOfIteratorHelper(transactions),_step71;try{for(_iterator71.s();!(_step71=_iterator71.n()).done;){var tr=_step71.value;if(scrollTarget)scrollTarget=scrollTarget.map(tr.changes);if(tr.scrollIntoView){var main=tr.state.selection.main;scrollTarget=new ScrollTarget(main.empty?main:state.EditorSelection.cursor(main.head,main.head>main.anchor?-1:1));}var _iterator72=_createForOfIteratorHelper(tr.effects),_step72;try{for(_iterator72.s();!(_step72=_iterator72.n()).done;){var e=_step72.value;if(e.is(scrollTo))scrollTarget=new ScrollTarget(e.value);else if(e.is(centerOn))scrollTarget=new ScrollTarget(e.value,"center");else if(e.is(_scrollIntoView2))scrollTarget=e.value;}}catch(err){_iterator72.e(err);}finally{_iterator72.f();}}}catch(err){_iterator71.e(err);}finally{_iterator71.f();}this.viewState.update(update,scrollTarget);this.bidiCache=CachedOrder.update(this.bidiCache,update.changes);if(!update.empty){this.updatePlugins(update);this.inputState.update(update);}redrawn=this.docView.update(update);if(this.state.facet(styleModule)!=this.styleModules)this.mountStyles();this.updateAttrs();this.showAnnouncements(transactions);this.docView.updateSelection(redrawn,transactions.some(function(tr){return tr.isUserEvent("select.pointer");}));}finally{this.updateState=0/* Idle */;}if(redrawn||scrollTarget||this.viewState.mustEnforceCursorAssoc)this.requestMeasure();if(!update.empty){var _iterator73=_createForOfIteratorHelper(this.state.facet(updateListener)),_step73;try{for(_iterator73.s();!(_step73=_iterator73.n()).done;){var listener=_step73.value;listener(update);}}catch(err){_iterator73.e(err);}finally{_iterator73.f();}}}/**
11701170+ Reset the view to the given state. (This will cause the entire
11711171+ document to be redrawn and all view plugins to be reinitialized,
11721172+ so you should probably only use it when the new state isn't
11731173+ derived from the old state. Otherwise, use
11741174+ [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
11751175+ */},{key:"setState",value:function setState(newState){if(this.updateState!=0/* Idle */)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=newState;return;}this.updateState=2/* Updating */;var hadFocus=this.hasFocus;try{var _iterator74=_createForOfIteratorHelper(this.plugins),_step74;try{for(_iterator74.s();!(_step74=_iterator74.n()).done;){var _plugin4=_step74.value;_plugin4.destroy(this);}}catch(err){_iterator74.e(err);}finally{_iterator74.f();}this.viewState=new ViewState(newState);this.plugins=newState.facet(viewPlugin).map(function(spec){return new PluginInstance(spec);});this.pluginMap.clear();var _iterator75=_createForOfIteratorHelper(this.plugins),_step75;try{for(_iterator75.s();!(_step75=_iterator75.n()).done;){var _plugin5=_step75.value;_plugin5.update(this);}}catch(err){_iterator75.e(err);}finally{_iterator75.f();}this.docView=new DocView(this);this.inputState.ensureHandlers(this);this.mountStyles();this.updateAttrs();this.bidiCache=[];}finally{this.updateState=0/* Idle */;}if(hadFocus)this.focus();this.requestMeasure();}},{key:"updatePlugins",value:function updatePlugins(update){var prevSpecs=update.startState.facet(viewPlugin),specs=update.state.facet(viewPlugin);if(prevSpecs!=specs){var newPlugins=[];var _iterator76=_createForOfIteratorHelper(specs),_step76;try{for(_iterator76.s();!(_step76=_iterator76.n()).done;){var spec=_step76.value;var found=prevSpecs.indexOf(spec);if(found<0){newPlugins.push(new PluginInstance(spec));}else{var _plugin6=this.plugins[found];_plugin6.mustUpdate=update;newPlugins.push(_plugin6);}}}catch(err){_iterator76.e(err);}finally{_iterator76.f();}var _iterator77=_createForOfIteratorHelper(this.plugins),_step77;try{for(_iterator77.s();!(_step77=_iterator77.n()).done;){var _plugin7=_step77.value;if(_plugin7.mustUpdate!=update)_plugin7.destroy(this);}}catch(err){_iterator77.e(err);}finally{_iterator77.f();}this.plugins=newPlugins;this.pluginMap.clear();this.inputState.ensureHandlers(this);}else{var _iterator78=_createForOfIteratorHelper(this.plugins),_step78;try{for(_iterator78.s();!(_step78=_iterator78.n()).done;){var _p=_step78.value;_p.mustUpdate=update;}}catch(err){_iterator78.e(err);}finally{_iterator78.f();}}for(var _i45=0;_i45<this.plugins.length;_i45++){this.plugins[_i45].update(this);}}/**
11761176+ @internal
11771177+ */},{key:"measure",value:function measure(){var _this45=this;var flush=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;if(this.destroyed)return;if(this.measureScheduled>-1)cancelAnimationFrame(this.measureScheduled);this.measureScheduled=0;// Prevent requestMeasure calls from scheduling another animation frame
11781178+if(flush)this.observer.flush();var updated=null;try{for(var _i46=0;;_i46++){this.updateState=1/* Measuring */;var oldViewport=this.viewport;var changed=this.viewState.measure(this);if(!changed&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(_i46>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break;}var measuring=[];// Only run measure requests in this cycle when the viewport didn't change
11791179+if(!(changed&4/* Viewport */)){var _ref45=[measuring,this.measureRequests];this.measureRequests=_ref45[0];measuring=_ref45[1];}var measured=measuring.map(function(m){try{return m.read(_this45);}catch(e){logException(_this45.state,e);return BadMeasure;}});var update=new ViewUpdate(this,this.state),redrawn=false,scrolled=false;update.flags|=changed;if(!updated)updated=update;else updated.flags|=changed;this.updateState=2/* Updating */;if(!update.empty){this.updatePlugins(update);this.inputState.update(update);this.updateAttrs();redrawn=this.docView.update(update);}for(var _i47=0;_i47<measuring.length;_i47++){if(measured[_i47]!=BadMeasure){try{var m=measuring[_i47];if(m.write)m.write(measured[_i47],this);}catch(e){logException(this.state,e);}}}if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget);this.viewState.scrollTarget=null;scrolled=true;}if(redrawn)this.docView.updateSelection(true);if(this.viewport.from==oldViewport.from&&this.viewport.to==oldViewport.to&&!scrolled&&this.measureRequests.length==0)break;}}finally{this.updateState=0/* Idle */;this.measureScheduled=-1;}if(updated&&!updated.empty){var _iterator79=_createForOfIteratorHelper(this.state.facet(updateListener)),_step79;try{for(_iterator79.s();!(_step79=_iterator79.n()).done;){var listener=_step79.value;listener(updated);}}catch(err){_iterator79.e(err);}finally{_iterator79.f();}}}/**
11801180+ Get the CSS classes for the currently active editor themes.
11811181+ */},{key:"themeClasses",get:function get(){return baseThemeID+" "+(this.state.facet(darkTheme)?baseDarkID:baseLightID)+" "+this.state.facet(_theme);}},{key:"updateAttrs",value:function updateAttrs(){var _this46=this;var editorAttrs=attrsFromFacet(this,editorAttributes,{"class":"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses});var contentAttrs={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:!this.state.facet(editable)?"false":"true","class":"cm-content",style:"".concat(browser.tabSize,": ").concat(this.state.tabSize),role:"textbox","aria-multiline":"true"};if(this.state.readOnly)contentAttrs["aria-readonly"]="true";attrsFromFacet(this,contentAttributes,contentAttrs);this.observer.ignore(function(){_updateAttrs(_this46.contentDOM,_this46.contentAttrs,contentAttrs);_updateAttrs(_this46.dom,_this46.editorAttrs,editorAttrs);});this.editorAttrs=editorAttrs;this.contentAttrs=contentAttrs;}},{key:"showAnnouncements",value:function showAnnouncements(trs){var first=true;var _iterator80=_createForOfIteratorHelper(trs),_step80;try{for(_iterator80.s();!(_step80=_iterator80.n()).done;){var tr=_step80.value;var _iterator81=_createForOfIteratorHelper(tr.effects),_step81;try{for(_iterator81.s();!(_step81=_iterator81.n()).done;){var effect=_step81.value;if(effect.is(EditorView.announce)){if(first)this.announceDOM.textContent="";first=false;var div=this.announceDOM.appendChild(document.createElement("div"));div.textContent=effect.value;}}}catch(err){_iterator81.e(err);}finally{_iterator81.f();}}}catch(err){_iterator80.e(err);}finally{_iterator80.f();}}},{key:"mountStyles",value:function mountStyles(){this.styleModules=this.state.facet(styleModule);styleMod.StyleModule.mount(this.root,this.styleModules.concat(baseTheme).reverse());}},{key:"readMeasured",value:function readMeasured(){if(this.updateState==2/* Updating */)throw new Error("Reading the editor layout isn't allowed during an update");if(this.updateState==0/* Idle */&&this.measureScheduled>-1)this.measure(false);}/**
11821182+ Schedule a layout measurement, optionally providing callbacks to
11831183+ do custom DOM measuring followed by a DOM write phase. Using
11841184+ this is preferable reading DOM layout directly from, for
11851185+ example, an event handler, because it'll make sure measuring and
11861186+ drawing done by other components is synchronized, avoiding
11871187+ unnecessary DOM layout computations.
11881188+ */},{key:"requestMeasure",value:function requestMeasure(request){var _this47=this;if(this.measureScheduled<0)this.measureScheduled=requestAnimationFrame(function(){return _this47.measure();});if(request){if(request.key!=null)for(var _i48=0;_i48<this.measureRequests.length;_i48++){if(this.measureRequests[_i48].key===request.key){this.measureRequests[_i48]=request;return;}}this.measureRequests.push(request);}}/**
11891189+ Collect all values provided by the active plugins for a given
11901190+ field.
11911191+ */},{key:"pluginField",value:function pluginField(field){var result=[];var _iterator82=_createForOfIteratorHelper(this.plugins),_step82;try{for(_iterator82.s();!(_step82=_iterator82.n()).done;){var _plugin8=_step82.value;_plugin8.update(this).takeField(field,result);}}catch(err){_iterator82.e(err);}finally{_iterator82.f();}return result;}/**
11921192+ Get the value of a specific plugin, if present. Note that
11931193+ plugins that crash can be dropped from a view, so even when you
11941194+ know you registered a given plugin, it is recommended to check
11951195+ the return value of this method.
11961196+ */},{key:"plugin",value:function plugin(_plugin2){var known=this.pluginMap.get(_plugin2);if(known===undefined||known&&known.spec!=_plugin2)this.pluginMap.set(_plugin2,known=this.plugins.find(function(p){return p.spec==_plugin2;})||null);return known&&known.update(this).value;}/**
11971197+ The top position of the document, in screen coordinates. This
11981198+ may be negative when the editor is scrolled down. Points
11991199+ directly to the top of the first line, not above the padding.
12001200+ */},{key:"documentTop",get:function get(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop;}/**
12011201+ Reports the padding above and below the document.
12021202+ */},{key:"documentPadding",get:function get(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom};}/**
12031203+ Find the line or block widget at the given vertical position.
12041204+12051205+ By default, this position is interpreted as a screen position,
12061206+ meaning `docTop` is set to the DOM top position of the editor
12071207+ content (forcing a layout). You can pass a different `docTop`
12081208+ value—for example 0 to interpret `height` as a document-relative
12091209+ position, or a precomputed document top
12101210+ (`view.contentDOM.getBoundingClientRect().top`) to limit layout
12111211+ queries.
12121212+12131213+ *Deprecated: use `elementAtHeight` instead.*
12141214+ */},{key:"blockAtHeight",value:function blockAtHeight(height,docTop){var top=ensureTop(docTop,this);return this.elementAtHeight(height-top).moveY(top);}/**
12151215+ Find the text line or block widget at the given vertical
12161216+ position (which is interpreted as relative to the [top of the
12171217+ document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)
12181218+ */},{key:"elementAtHeight",value:function elementAtHeight(height){this.readMeasured();return this.viewState.elementAtHeight(height);}/**
12191219+ Find information for the visual line (see
12201220+ [`visualLineAt`](https://codemirror.net/6/docs/ref/#view.EditorView.visualLineAt)) at the given
12211221+ vertical position. The resulting block info might hold another
12221222+ array of block info structs in its `type` field if this line
12231223+ consists of more than one block.
12241224+12251225+ Defaults to treating `height` as a screen position. See
12261226+ [`blockAtHeight`](https://codemirror.net/6/docs/ref/#view.EditorView.blockAtHeight) for the
12271227+ interpretation of the `docTop` parameter.
12281228+12291229+ *Deprecated: use `lineBlockAtHeight` instead.*
12301230+ */},{key:"visualLineAtHeight",value:function visualLineAtHeight(height,docTop){var top=ensureTop(docTop,this);return this.lineBlockAtHeight(height-top).moveY(top);}/**
12311231+ Find the line block (see
12321232+ [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
12331233+ height.
12341234+ */},{key:"lineBlockAtHeight",value:function lineBlockAtHeight(height){this.readMeasured();return this.viewState.lineBlockAtHeight(height);}/**
12351235+ Iterate over the height information of the visual lines in the
12361236+ viewport. The heights of lines are reported relative to the
12371237+ given document top, which defaults to the screen position of the
12381238+ document (forcing a layout).
12391239+12401240+ *Deprecated: use `viewportLineBlocks` instead.*
12411241+ */},{key:"viewportLines",value:function viewportLines(f,docTop){var top=ensureTop(docTop,this);var _iterator83=_createForOfIteratorHelper(this.viewportLineBlocks),_step83;try{for(_iterator83.s();!(_step83=_iterator83.n()).done;){var line=_step83.value;f(line.moveY(top));}}catch(err){_iterator83.e(err);}finally{_iterator83.f();}}/**
12421242+ Get the extent and vertical position of all [line
12431243+ blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
12441244+ are relative to the [top of the
12451245+ document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
12461246+ */},{key:"viewportLineBlocks",get:function get(){return this.viewState.viewportLines;}/**
12471247+ Find the extent and height of the visual line (a range delimited
12481248+ on both sides by either non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^range)
12491249+ line breaks, or the start/end of the document) at the given position.
12501250+12511251+ Vertical positions are computed relative to the `docTop`
12521252+ argument, which defaults to 0 for this method. You can pass
12531253+ `view.contentDOM.getBoundingClientRect().top` here to get screen
12541254+ coordinates.
12551255+12561256+ *Deprecated: use `lineBlockAt` instead.*
12571257+ */},{key:"visualLineAt",value:function visualLineAt(pos){var docTop=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return this.lineBlockAt(pos).moveY(docTop+this.viewState.paddingTop);}/**
12581258+ Find the line block around the given document position. A line
12591259+ block is a range delimited on both sides by either a
12601260+ non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^range) line breaks, or the
12611261+ start/end of the document. It will usually just hold a line of
12621262+ text, but may be broken into multiple textblocks by block
12631263+ widgets.
12641264+ */},{key:"lineBlockAt",value:function lineBlockAt(pos){return this.viewState.lineBlockAt(pos);}/**
12651265+ The editor's total content height.
12661266+ */},{key:"contentHeight",get:function get(){return this.viewState.contentHeight;}/**
12671267+ Move a cursor position by [grapheme
12681268+ cluster](https://codemirror.net/6/docs/ref/#text.findClusterBreak). `forward` determines whether
12691269+ the motion is away from the line start, or towards it. Motion in
12701270+ bidirectional text is in visual order, in the editor's [text
12711271+ direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). When the start
12721272+ position was the last one on the line, the returned position
12731273+ will be across the line break. If there is no further line, the
12741274+ original position is returned.
12751275+12761276+ By default, this method moves over a single cluster. The
12771277+ optional `by` argument can be used to move across more. It will
12781278+ be called with the first cluster as argument, and should return
12791279+ a predicate that determines, for each subsequent cluster,
12801280+ whether it should also be moved over.
12811281+ */},{key:"moveByChar",value:function moveByChar(start,forward,by){return skipAtoms(this,start,_moveByChar(this,start,forward,by));}/**
12821282+ Move a cursor position across the next group of either
12831283+ [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
12841284+ non-whitespace characters.
12851285+ */},{key:"moveByGroup",value:function moveByGroup(start,forward){var _this48=this;return skipAtoms(this,start,_moveByChar(this,start,forward,function(initial){return byGroup(_this48,start.head,initial);}));}/**
12861286+ Move to the next line boundary in the given direction. If
12871287+ `includeWrap` is true, line wrapping is on, and there is a
12881288+ further wrap point on the current line, the wrap point will be
12891289+ returned. Otherwise this function will return the start or end
12901290+ of the line.
12911291+ */},{key:"moveToLineBoundary",value:function moveToLineBoundary(start,forward){var includeWrap=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return _moveToLineBoundary(this,start,forward,includeWrap);}/**
12921292+ Move a cursor position vertically. When `distance` isn't given,
12931293+ it defaults to moving to the next line (including wrapped
12941294+ lines). Otherwise, `distance` should provide a positive distance
12951295+ in pixels.
12961296+12971297+ When `start` has a
12981298+ [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
12991299+ motion will use that as a target horizontal position. Otherwise,
13001300+ the cursor's own horizontal position is used. The returned
13011301+ cursor will have its goal column set to whichever column was
13021302+ used.
13031303+ */},{key:"moveVertically",value:function moveVertically(start,forward,distance){return skipAtoms(this,start,_moveVertically(this,start,forward,distance));}// FIXME remove on next major version
13041304+},{key:"scrollPosIntoView",value:function scrollPosIntoView(pos){this.dispatch({effects:scrollTo.of(state.EditorSelection.cursor(pos))});}/**
13051305+ Find the DOM parent node and offset (child offset if `node` is
13061306+ an element, character offset when it is a text node) at the
13071307+ given document position.
13081308+13091309+ Note that for positions that aren't currently in
13101310+ `visibleRanges`, the resulting DOM position isn't necessarily
13111311+ meaningful (it may just point before or after a placeholder
13121312+ element).
13131313+ */},{key:"domAtPos",value:function domAtPos(pos){return this.docView.domAtPos(pos);}/**
13141314+ Find the document position at the given DOM node. Can be useful
13151315+ for associating positions with DOM events. Will raise an error
13161316+ when `node` isn't part of the editor content.
13171317+ */},{key:"posAtDOM",value:function posAtDOM(node){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return this.docView.posFromDOM(node,offset);}},{key:"posAtCoords",value:function posAtCoords(coords){var precise=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;this.readMeasured();return _posAtCoords(this,coords,precise);}/**
13181318+ Get the screen coordinates at the given document position.
13191319+ `side` determines whether the coordinates are based on the
13201320+ element before (-1) or after (1) the position (if no element is
13211321+ available on the given side, the method will transparently use
13221322+ another strategy to get reasonable coordinates).
13231323+ */},{key:"coordsAtPos",value:function coordsAtPos(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;this.readMeasured();var rect=this.docView.coordsAt(pos,side);if(!rect||rect.left==rect.right)return rect;var line=this.state.doc.lineAt(pos),order=this.bidiSpans(line);var span=order[BidiSpan.find(order,pos-line.from,-1,side)];return flattenRect(rect,span.dir==exports.Direction.LTR==side>0);}/**
13241324+ The default width of a character in the editor. May not
13251325+ accurately reflect the width of all characters (given variable
13261326+ width fonts or styling of invididual ranges).
13271327+ */},{key:"defaultCharacterWidth",get:function get(){return this.viewState.heightOracle.charWidth;}/**
13281328+ The default height of a line in the editor. May not be accurate
13291329+ for all lines.
13301330+ */},{key:"defaultLineHeight",get:function get(){return this.viewState.heightOracle.lineHeight;}/**
13311331+ The text direction
13321332+ ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
13331333+ CSS property) of the editor.
13341334+ */},{key:"textDirection",get:function get(){return this.viewState.heightOracle.direction;}/**
13351335+ Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
13361336+ (as determined by the
13371337+ [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
13381338+ CSS property of its content element).
13391339+ */},{key:"lineWrapping",get:function get(){return this.viewState.heightOracle.lineWrapping;}/**
13401340+ Returns the bidirectional text structure of the given line
13411341+ (which should be in the current document) as an array of span
13421342+ objects. The order of these spans matches the [text
13431343+ direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
13441344+ left-to-right, the leftmost spans come first, otherwise the
13451345+ rightmost spans come first.
13461346+ */},{key:"bidiSpans",value:function bidiSpans(line){if(line.length>MaxBidiLine)return trivialOrder(line.length);var dir=this.textDirection;var _iterator84=_createForOfIteratorHelper(this.bidiCache),_step84;try{for(_iterator84.s();!(_step84=_iterator84.n()).done;){var entry=_step84.value;if(entry.from==line.from&&entry.dir==dir)return entry.order;}}catch(err){_iterator84.e(err);}finally{_iterator84.f();}var order=computeOrder(line.text,this.textDirection);this.bidiCache.push(new CachedOrder(line.from,line.to,dir,order));return order;}/**
13471347+ Check whether the editor has focus.
13481348+ */},{key:"hasFocus",get:function get(){var _a;// Safari return false for hasFocus when the context menu is open
13491349+// or closing, which leads us to ignore selection changes from the
13501350+// context menu because it looks like the editor isn't focused.
13511351+// This kludges around that.
13521352+return(document.hasFocus()||browser.safari&&((_a=this.inputState)===null||_a===void 0?void 0:_a.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM;}/**
13531353+ Put focus on the editor.
13541354+ */},{key:"focus",value:function focus(){var _this49=this;this.observer.ignore(function(){focusPreventScroll(_this49.contentDOM);_this49.docView.updateSelection();});}/**
13551355+ Clean up this editor view, removing its element from the
13561356+ document, unregistering event handlers, and notifying
13571357+ plugins. The view instance can no longer be used after
13581358+ calling this.
13591359+ */},{key:"destroy",value:function destroy(){var _iterator85=_createForOfIteratorHelper(this.plugins),_step85;try{for(_iterator85.s();!(_step85=_iterator85.n()).done;){var _plugin9=_step85.value;_plugin9.destroy(this);}}catch(err){_iterator85.e(err);}finally{_iterator85.f();}this.plugins=[];this.inputState.destroy();this.dom.remove();this.observer.destroy();if(this.measureScheduled>-1)cancelAnimationFrame(this.measureScheduled);this.destroyed=true;}/**
13601360+ Returns an effect that can be
13611361+ [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
13621362+ cause it to scroll the given position or range into view.
13631363+ */}],[{key:"scrollIntoView",value:function scrollIntoView(pos){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return _scrollIntoView2.of(new ScrollTarget(typeof pos=="number"?state.EditorSelection.cursor(pos):pos,options.y,options.x,options.yMargin,options.xMargin));}/**
13641364+ Facet that can be used to add DOM event handlers. The value
13651365+ should be an object mapping event names to handler functions. The
13661366+ first such function to return true will be assumed to have handled
13671367+ that event, and no other handlers or built-in behavior will be
13681368+ activated for it.
13691369+ These are registered on the [content
13701370+ element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except for `scroll`
13711371+ handlers, which will be called any time the editor's [scroll
13721372+ element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of its parent nodes
13731373+ is scrolled.
13741374+ */},{key:"domEventHandlers",value:function domEventHandlers(handlers){return ViewPlugin.define(function(){return{};},{eventHandlers:handlers});}/**
13751375+ Create a theme extension. The first argument can be a
13761376+ [`style-mod`](https://github.com/marijnh/style-mod#documentation)
13771377+ style spec providing the styles for the theme. These will be
13781378+ prefixed with a generated class for the style.
13791379+13801380+ Because the selectors will be prefixed with a scope class, rule
13811381+ that directly match the editor's [wrapper
13821382+ element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
13831383+ added—need to be explicitly differentiated by adding an `&` to
13841384+ the selector for that element—for example
13851385+ `&.cm-focused`.
13861386+13871387+ When `dark` is set to true, the theme will be marked as dark,
13881388+ which will cause the `&dark` rules from [base
13891389+ themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
13901390+ `&light` when a light theme is active).
13911391+ */},{key:"theme",value:function theme(spec,options){var prefix=styleMod.StyleModule.newName();var result=[_theme.of(prefix),styleModule.of(buildTheme(".".concat(prefix),spec))];if(options&&options.dark)result.push(darkTheme.of(true));return result;}/**
13921392+ Create an extension that adds styles to the base theme. Like
13931393+ with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
13941394+ place of the editor wrapper element when directly targeting
13951395+ that. You can also use `&dark` or `&light` instead to only
13961396+ target editors with a dark or light theme.
13971397+ */},{key:"baseTheme",value:function baseTheme(spec){return state.Prec.lowest(styleModule.of(buildTheme("."+baseThemeID,spec,lightDarkIDs)));}}]);return EditorView;}();/**
13981398+Effect that can be [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a
13991399+transaction to make it scroll the given range into view.
14001400+14011401+*Deprecated*. Use [`scrollIntoView`](https://codemirror.net/6/docs/ref/#view.EditorView^scrollIntoView) instead.
14021402+*/EditorView.scrollTo=scrollTo;/**
14031403+Effect that makes the editor scroll the given range to the
14041404+center of the visible view.
14051405+14061406+*Deprecated*. Use [`scrollIntoView`](https://codemirror.net/6/docs/ref/#view.EditorView^scrollIntoView) instead.
14071407+*/EditorView.centerOn=centerOn;/**
14081408+Facet to add a [style
14091409+module](https://github.com/marijnh/style-mod#documentation) to
14101410+an editor view. The view will ensure that the module is
14111411+mounted in its [document
14121412+root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
14131413+*/EditorView.styleModule=styleModule;/**
14141414+An input handler can override the way changes to the editable
14151415+DOM content are handled. Handlers are passed the document
14161416+positions between which the change was found, and the new
14171417+content. When one returns true, no further input handlers are
14181418+called and the default behavior is prevented.
14191419+*/EditorView.inputHandler=inputHandler;/**
14201420+Allows you to provide a function that should be called when the
14211421+library catches an exception from an extension (mostly from view
14221422+plugins, but may be used by other extensions to route exceptions
14231423+from user-code-provided callbacks). This is mostly useful for
14241424+debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
14251425+*/EditorView.exceptionSink=exceptionSink;/**
14261426+A facet that can be used to register a function to be called
14271427+every time the view updates.
14281428+*/EditorView.updateListener=updateListener;/**
14291429+Facet that controls whether the editor content DOM is editable.
14301430+When its highest-precedence value is `false`, the element will
14311431+not longer have its `contenteditable` attribute set. (Note that
14321432+this doesn't affect API calls that change the editor content,
14331433+even when those are bound to keys or buttons. See the
14341434+[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
14351435+*/EditorView.editable=editable;/**
14361436+Allows you to influence the way mouse selection happens. The
14371437+functions in this facet will be called for a `mousedown` event
14381438+on the editor, and can return an object that overrides the way a
14391439+selection is computed from that mouse click or drag.
14401440+*/EditorView.mouseSelectionStyle=mouseSelectionStyle;/**
14411441+Facet used to configure whether a given selection drag event
14421442+should move or copy the selection. The given predicate will be
14431443+called with the `mousedown` event, and can return `true` when
14441444+the drag should move the content.
14451445+*/EditorView.dragMovesSelection=dragMovesSelection$1;/**
14461446+Facet used to configure whether a given selecting click adds
14471447+a new range to the existing selection or replaces it entirely.
14481448+*/EditorView.clickAddsSelectionRange=clickAddsSelectionRange;/**
14491449+A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
14501450+are shown in the view. See also [view
14511451+plugins](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), which have a separate
14521452+mechanism for providing decorations.
14531453+*/EditorView.decorations=decorations;/**
14541454+This facet records whether a dark theme is active. The extension
14551455+returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
14561456+includes an instance of this when the `dark` option is set to
14571457+true.
14581458+*/EditorView.darkTheme=darkTheme;/**
14591459+Facet that provides additional DOM attributes for the editor's
14601460+editable DOM element.
14611461+*/EditorView.contentAttributes=contentAttributes;/**
14621462+Facet that provides DOM attributes for the editor's outer
14631463+element.
14641464+*/EditorView.editorAttributes=editorAttributes;/**
14651465+An extension that enables line wrapping in the editor (by
14661466+setting CSS `white-space` to `pre-wrap` in the content).
14671467+*/EditorView.lineWrapping=EditorView.contentAttributes.of({"class":"cm-lineWrapping"});/**
14681468+State effect used to include screen reader announcements in a
14691469+transaction. These will be added to the DOM in a visually hidden
14701470+element with `aria-live="polite"` set, and should be used to
14711471+describe effects that are visually obvious but may not be
14721472+noticed by screen reader users (such as moving to the next
14731473+search match).
14741474+*/EditorView.announce=state.StateEffect.define();// Maximum line length for which we compute accurate bidi info
14751475+var MaxBidiLine=4096;// FIXME remove this and its callers on next breaking release
14761476+function ensureTop(given,view){return(given==null?view.contentDOM.getBoundingClientRect().top:given)+view.viewState.paddingTop;}var resizeDebounce=-1;function ensureGlobalHandler(){window.addEventListener("resize",function(){if(resizeDebounce==-1)resizeDebounce=setTimeout(handleResize,50);});}function handleResize(){resizeDebounce=-1;var found=document.querySelectorAll(".cm-content");for(var _i49=0;_i49<found.length;_i49++){var docView=ContentView.get(found[_i49]);if(docView)docView.editorView.requestMeasure();}}var BadMeasure={};var CachedOrder=/*#__PURE__*/function(){function CachedOrder(from,to,dir,order){_classCallCheck(this,CachedOrder);this.from=from;this.to=to;this.dir=dir;this.order=order;}_createClass(CachedOrder,null,[{key:"update",value:function update(cache,changes){if(changes.empty)return cache;var result=[],lastDir=cache.length?cache[cache.length-1].dir:exports.Direction.LTR;for(var _i50=Math.max(0,cache.length-10);_i50<cache.length;_i50++){var entry=cache[_i50];if(entry.dir==lastDir&&!changes.touchesRange(entry.from,entry.to))result.push(new CachedOrder(changes.mapPos(entry.from,1),changes.mapPos(entry.to,-1),entry.dir,entry.order));}return result;}}]);return CachedOrder;}();function attrsFromFacet(view,facet,base){for(var sources=view.state.facet(facet),_i51=sources.length-1;_i51>=0;_i51--){var source=sources[_i51],value=typeof source=="function"?source(view):source;if(value)combineAttrs(value,base);}return base;}var currentPlatform=browser.mac?"mac":browser.windows?"win":browser.linux?"linux":"key";function normalizeKeyName(name,platform){var parts=name.split(/-(?!$)/);var result=parts[parts.length-1];if(result=="Space")result=" ";var alt,ctrl,shift,meta;for(var _i52=0;_i52<parts.length-1;++_i52){var mod=parts[_i52];if(/^(cmd|meta|m)$/i.test(mod))meta=true;else if(/^a(lt)?$/i.test(mod))alt=true;else if(/^(c|ctrl|control)$/i.test(mod))ctrl=true;else if(/^s(hift)?$/i.test(mod))shift=true;else if(/^mod$/i.test(mod)){if(platform=="mac")meta=true;else ctrl=true;}else throw new Error("Unrecognized modifier name: "+mod);}if(alt)result="Alt-"+result;if(ctrl)result="Ctrl-"+result;if(meta)result="Meta-"+result;if(shift)result="Shift-"+result;return result;}function modifiers(name,event,shift){if(event.altKey)name="Alt-"+name;if(event.ctrlKey)name="Ctrl-"+name;if(event.metaKey)name="Meta-"+name;if(shift!==false&&event.shiftKey)name="Shift-"+name;return name;}var handleKeyEvents=EditorView.domEventHandlers({keydown:function keydown(event,view){return runHandlers(getKeymap(view.state),event,view,"editor");}});/**
14771477+Facet used for registering keymaps.
14781478+14791479+You can add multiple keymaps to an editor. Their priorities
14801480+determine their precedence (the ones specified early or with high
14811481+priority get checked first). When a handler has returned `true`
14821482+for a given key, no further handlers are called.
14831483+*/var keymap=state.Facet.define({enables:handleKeyEvents});var Keymaps=new WeakMap();// This is hidden behind an indirection, rather than directly computed
14841484+// by the facet, to keep internal types out of the facet's type.
14851485+function getKeymap(state){var bindings=state.facet(keymap);var map=Keymaps.get(bindings);if(!map)Keymaps.set(bindings,map=buildKeymap(bindings.reduce(function(a,b){return a.concat(b);},[])));return map;}/**
14861486+Run the key handlers registered for a given scope. The event
14871487+object should be `"keydown"` event. Returns true if any of the
14881488+handlers handled it.
14891489+*/function runScopeHandlers(view,event,scope){return runHandlers(getKeymap(view.state),event,view,scope);}var storedPrefix=null;var PrefixTimeout=4000;function buildKeymap(bindings){var platform=arguments.length>1&&arguments[1]!==undefined?arguments[1]:currentPlatform;var bound=Object.create(null);var isPrefix=Object.create(null);var checkPrefix=function checkPrefix(name,is){var current=isPrefix[name];if(current==null)isPrefix[name]=is;else if(current!=is)throw new Error("Key binding "+name+" is used both as a regular binding and as a multi-stroke prefix");};var add=function add(scope,key,command,preventDefault){var scopeObj=bound[scope]||(bound[scope]=Object.create(null));var parts=key.split(/ (?!$)/).map(function(k){return normalizeKeyName(k,platform);});var _loop10=function _loop10(_i53){var prefix=parts.slice(0,_i53).join(" ");checkPrefix(prefix,true);if(!scopeObj[prefix])scopeObj[prefix]={preventDefault:true,commands:[function(view){var ourObj=storedPrefix={view:view,prefix:prefix,scope:scope};setTimeout(function(){if(storedPrefix==ourObj)storedPrefix=null;},PrefixTimeout);return true;}]};};for(var _i53=1;_i53<parts.length;_i53++){_loop10(_i53);}var full=parts.join(" ");checkPrefix(full,false);var binding=scopeObj[full]||(scopeObj[full]={preventDefault:false,commands:[]});binding.commands.push(command);if(preventDefault)binding.preventDefault=true;};var _iterator86=_createForOfIteratorHelper(bindings),_step86;try{for(_iterator86.s();!(_step86=_iterator86.n()).done;){var b=_step86.value;var name=b[platform]||b.key;if(!name)continue;var _iterator87=_createForOfIteratorHelper(b.scope?b.scope.split(" "):["editor"]),_step87;try{for(_iterator87.s();!(_step87=_iterator87.n()).done;){var scope=_step87.value;add(scope,name,b.run,b.preventDefault);if(b.shift)add(scope,"Shift-"+name,b.shift,b.preventDefault);}}catch(err){_iterator87.e(err);}finally{_iterator87.f();}}}catch(err){_iterator86.e(err);}finally{_iterator86.f();}return bound;}function runHandlers(map,event,view,scope){var name=w3cKeyname.keyName(event),isChar=name.length==1&&name!=" ";var prefix="",fallthrough=false;if(storedPrefix&&storedPrefix.view==view&&storedPrefix.scope==scope){prefix=storedPrefix.prefix+" ";if(fallthrough=modifierCodes.indexOf(event.keyCode)<0)storedPrefix=null;}var runFor=function runFor(binding){if(binding){var _iterator88=_createForOfIteratorHelper(binding.commands),_step88;try{for(_iterator88.s();!(_step88=_iterator88.n()).done;){var cmd=_step88.value;if(cmd(view))return true;}}catch(err){_iterator88.e(err);}finally{_iterator88.f();}if(binding.preventDefault)fallthrough=true;}return false;};var scopeObj=map[scope],baseName;if(scopeObj){if(runFor(scopeObj[prefix+modifiers(name,event,!isChar)]))return true;if(isChar&&(event.shiftKey||event.altKey||event.metaKey)&&(baseName=w3cKeyname.base[event.keyCode])&&baseName!=name){if(runFor(scopeObj[prefix+modifiers(baseName,event,true)]))return true;}else if(isChar&&event.shiftKey){if(runFor(scopeObj[prefix+modifiers(name,event,true)]))return true;}}return fallthrough;}var CanHidePrimary=!browser.ios;// FIXME test IE
14901490+var selectionConfig=state.Facet.define({combine:function combine(configs){return state.combineConfig(configs,{cursorBlinkRate:1200,drawRangeCursor:true},{cursorBlinkRate:function cursorBlinkRate(a,b){return Math.min(a,b);},drawRangeCursor:function drawRangeCursor(a,b){return a||b;}});}});/**
14911491+Returns an extension that hides the browser's native selection and
14921492+cursor, replacing the selection with a background behind the text
14931493+(with the `cm-selectionBackground` class), and the
14941494+cursors with elements overlaid over the code (using
14951495+`cm-cursor-primary` and `cm-cursor-secondary`).
14961496+14971497+This allows the editor to display secondary selection ranges, and
14981498+tends to produce a type of selection more in line with that users
14991499+expect in a text editor (the native selection styling will often
15001500+leave gaps between lines and won't fill the horizontal space after
15011501+a line when the selection continues past it).
15021502+15031503+It does have a performance cost, in that it requires an extra DOM
15041504+layout cycle for many updates (the selection is drawn based on DOM
15051505+layout information that's only available after laying out the
15061506+content).
15071507+*/function drawSelection(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return[selectionConfig.of(config),drawSelectionPlugin,hideNativeSelection];}var Piece=/*#__PURE__*/function(){function Piece(left,top,width,height,className){_classCallCheck(this,Piece);this.left=left;this.top=top;this.width=width;this.height=height;this.className=className;}_createClass(Piece,[{key:"draw",value:function draw(){var elt=document.createElement("div");elt.className=this.className;this.adjust(elt);return elt;}},{key:"adjust",value:function adjust(elt){elt.style.left=this.left+"px";elt.style.top=this.top+"px";if(this.width>=0)elt.style.width=this.width+"px";elt.style.height=this.height+"px";}},{key:"eq",value:function eq(p){return this.left==p.left&&this.top==p.top&&this.width==p.width&&this.height==p.height&&this.className==p.className;}}]);return Piece;}();var drawSelectionPlugin=ViewPlugin.fromClass(/*#__PURE__*/function(){function _class4(view){_classCallCheck(this,_class4);this.view=view;this.rangePieces=[];this.cursors=[];this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)};this.selectionLayer=view.scrollDOM.appendChild(document.createElement("div"));this.selectionLayer.className="cm-selectionLayer";this.selectionLayer.setAttribute("aria-hidden","true");this.cursorLayer=view.scrollDOM.appendChild(document.createElement("div"));this.cursorLayer.className="cm-cursorLayer";this.cursorLayer.setAttribute("aria-hidden","true");view.requestMeasure(this.measureReq);this.setBlinkRate();}_createClass(_class4,[{key:"setBlinkRate",value:function setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(selectionConfig).cursorBlinkRate+"ms";}},{key:"update",value:function update(_update8){var confChanged=_update8.startState.facet(selectionConfig)!=_update8.state.facet(selectionConfig);if(confChanged||_update8.selectionSet||_update8.geometryChanged||_update8.viewportChanged)this.view.requestMeasure(this.measureReq);if(_update8.transactions.some(function(tr){return tr.scrollIntoView;}))this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink";if(confChanged)this.setBlinkRate();}},{key:"readPos",value:function readPos(){var _this50=this;var state=this.view.state,conf=state.facet(selectionConfig);var rangePieces=state.selection.ranges.map(function(r){return r.empty?[]:measureRange(_this50.view,r);}).reduce(function(a,b){return a.concat(b);});var cursors=[];var _iterator89=_createForOfIteratorHelper(state.selection.ranges),_step89;try{for(_iterator89.s();!(_step89=_iterator89.n()).done;){var _r3=_step89.value;var prim=_r3==state.selection.main;if(_r3.empty?!prim||CanHidePrimary:conf.drawRangeCursor){var piece=measureCursor(this.view,_r3,prim);if(piece)cursors.push(piece);}}}catch(err){_iterator89.e(err);}finally{_iterator89.f();}return{rangePieces:rangePieces,cursors:cursors};}},{key:"drawSel",value:function drawSel(_ref46){var _this51=this;var rangePieces=_ref46.rangePieces,cursors=_ref46.cursors;if(rangePieces.length!=this.rangePieces.length||rangePieces.some(function(p,i){return!p.eq(_this51.rangePieces[i]);})){this.selectionLayer.textContent="";var _iterator90=_createForOfIteratorHelper(rangePieces),_step90;try{for(_iterator90.s();!(_step90=_iterator90.n()).done;){var _p2=_step90.value;this.selectionLayer.appendChild(_p2.draw());}}catch(err){_iterator90.e(err);}finally{_iterator90.f();}this.rangePieces=rangePieces;}if(cursors.length!=this.cursors.length||cursors.some(function(c,i){return!c.eq(_this51.cursors[i]);})){var oldCursors=this.cursorLayer.children;if(oldCursors.length!==cursors.length){this.cursorLayer.textContent="";var _iterator91=_createForOfIteratorHelper(cursors),_step91;try{for(_iterator91.s();!(_step91=_iterator91.n()).done;){var c=_step91.value;this.cursorLayer.appendChild(c.draw());}}catch(err){_iterator91.e(err);}finally{_iterator91.f();}}else{cursors.forEach(function(c,idx){return c.adjust(oldCursors[idx]);});}this.cursors=cursors;}}},{key:"destroy",value:function destroy(){this.selectionLayer.remove();this.cursorLayer.remove();}}]);return _class4;}());var themeSpec={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};if(CanHidePrimary)themeSpec[".cm-line"].caretColor="transparent !important";var hideNativeSelection=state.Prec.highest(EditorView.theme(themeSpec));function getBase(view){var rect=view.scrollDOM.getBoundingClientRect();var left=view.textDirection==exports.Direction.LTR?rect.left:rect.right-view.scrollDOM.clientWidth;return{left:left-view.scrollDOM.scrollLeft,top:rect.top-view.scrollDOM.scrollTop};}function wrappedLine(view,pos,inside){var range=state.EditorSelection.cursor(pos);return{from:Math.max(inside.from,view.moveToLineBoundary(range,false,true).from),to:Math.min(inside.to,view.moveToLineBoundary(range,true,true).from),type:exports.BlockType.Text};}function blockAt(view,pos){var line=view.lineBlockAt(pos);if(Array.isArray(line.type)){var _iterator92=_createForOfIteratorHelper(line.type),_step92;try{for(_iterator92.s();!(_step92=_iterator92.n()).done;){var _l2=_step92.value;if(_l2.to>pos||_l2.to==pos&&(_l2.to==line.to||_l2.type==exports.BlockType.Text))return _l2;}}catch(err){_iterator92.e(err);}finally{_iterator92.f();}}return line;}function measureRange(view,range){if(range.to<=view.viewport.from||range.from>=view.viewport.to)return[];var from=Math.max(range.from,view.viewport.from),to=Math.min(range.to,view.viewport.to);var ltr=view.textDirection==exports.Direction.LTR;var content=view.contentDOM,contentRect=content.getBoundingClientRect(),base=getBase(view);var lineStyle=window.getComputedStyle(content.firstChild);var leftSide=contentRect.left+parseInt(lineStyle.paddingLeft)+Math.min(0,parseInt(lineStyle.textIndent));var rightSide=contentRect.right-parseInt(lineStyle.paddingRight);var startBlock=blockAt(view,from),endBlock=blockAt(view,to);var visualStart=startBlock.type==exports.BlockType.Text?startBlock:null;var visualEnd=endBlock.type==exports.BlockType.Text?endBlock:null;if(view.lineWrapping){if(visualStart)visualStart=wrappedLine(view,from,visualStart);if(visualEnd)visualEnd=wrappedLine(view,to,visualEnd);}if(visualStart&&visualEnd&&visualStart.from==visualEnd.from){return pieces(drawForLine(range.from,range.to,visualStart));}else{var top=visualStart?drawForLine(range.from,null,visualStart):drawForWidget(startBlock,false);var bottom=visualEnd?drawForLine(null,range.to,visualEnd):drawForWidget(endBlock,true);var between=[];if((visualStart||startBlock).to<(visualEnd||endBlock).from-1)between.push(piece(leftSide,top.bottom,rightSide,bottom.top));else if(top.bottom<bottom.top&&view.elementAtHeight((top.bottom+bottom.top)/2).type==exports.BlockType.Text)top.bottom=bottom.top=(top.bottom+bottom.top)/2;return pieces(top).concat(between).concat(pieces(bottom));}function piece(left,top,right,bottom){return new Piece(left-base.left,top-base.top-0.01/* Epsilon */,right-left,bottom-top+0.01/* Epsilon */,"cm-selectionBackground");}function pieces(_ref47){var top=_ref47.top,bottom=_ref47.bottom,horizontal=_ref47.horizontal;var pieces=[];for(var _i54=0;_i54<horizontal.length;_i54+=2){pieces.push(piece(horizontal[_i54],top,horizontal[_i54+1],bottom));}return pieces;}// Gets passed from/to in line-local positions
15081508+function drawForLine(from,to,line){var top=1e9,bottom=-1e9,horizontal=[];function addSpan(from,fromOpen,to,toOpen,dir){// Passing 2/-2 is a kludge to force the view to return
15091509+// coordinates on the proper side of block widgets, since
15101510+// normalizing the side there, though appropriate for most
15111511+// coordsAtPos queries, would break selection drawing.
15121512+var fromCoords=view.coordsAtPos(from,from==line.to?-2:2);var toCoords=view.coordsAtPos(to,to==line.from?2:-2);top=Math.min(fromCoords.top,toCoords.top,top);bottom=Math.max(fromCoords.bottom,toCoords.bottom,bottom);if(dir==exports.Direction.LTR)horizontal.push(ltr&&fromOpen?leftSide:fromCoords.left,ltr&&toOpen?rightSide:toCoords.right);else horizontal.push(!ltr&&toOpen?leftSide:toCoords.left,!ltr&&fromOpen?rightSide:fromCoords.right);}var start=from!==null&&from!==void 0?from:line.from,end=to!==null&&to!==void 0?to:line.to;// Split the range by visible range and document line
15131513+var _iterator93=_createForOfIteratorHelper(view.visibleRanges),_step93;try{for(_iterator93.s();!(_step93=_iterator93.n()).done;){var _r4=_step93.value;if(_r4.to>start&&_r4.from<end){for(var pos=Math.max(_r4.from,start),endPos=Math.min(_r4.to,end);;){var docLine=view.state.doc.lineAt(pos);var _iterator94=_createForOfIteratorHelper(view.bidiSpans(docLine)),_step94;try{for(_iterator94.s();!(_step94=_iterator94.n()).done;){var span=_step94.value;var spanFrom=span.from+docLine.from,spanTo=span.to+docLine.from;if(spanFrom>=endPos)break;if(spanTo>pos)addSpan(Math.max(spanFrom,pos),from==null&&spanFrom<=start,Math.min(spanTo,endPos),to==null&&spanTo>=end,span.dir);}}catch(err){_iterator94.e(err);}finally{_iterator94.f();}pos=docLine.to+1;if(pos>=endPos)break;}}}}catch(err){_iterator93.e(err);}finally{_iterator93.f();}if(horizontal.length==0)addSpan(start,from==null,end,to==null,view.textDirection);return{top:top,bottom:bottom,horizontal:horizontal};}function drawForWidget(block,top){var y=contentRect.top+(top?block.top:block.bottom);return{top:y,bottom:y,horizontal:[]};}}function measureCursor(view,cursor,primary){var pos=view.coordsAtPos(cursor.head,cursor.assoc||1);if(!pos)return null;var base=getBase(view);return new Piece(pos.left-base.left,pos.top-base.top,-1,pos.bottom-pos.top,primary?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary");}var setDropCursorPos=state.StateEffect.define({map:function map(pos,mapping){return pos==null?null:mapping.mapPos(pos);}});var dropCursorPos=state.StateField.define({create:function create(){return null;},update:function update(pos,tr){if(pos!=null)pos=tr.changes.mapPos(pos);return tr.effects.reduce(function(pos,e){return e.is(setDropCursorPos)?e.value:pos;},pos);}});var drawDropCursor=ViewPlugin.fromClass(/*#__PURE__*/function(){function _class5(view){_classCallCheck(this,_class5);this.view=view;this.cursor=null;this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)};}_createClass(_class5,[{key:"update",value:function update(_update9){var _a;var cursorPos=_update9.state.field(dropCursorPos);if(cursorPos==null){if(this.cursor!=null){(_a=this.cursor)===null||_a===void 0?void 0:_a.remove();this.cursor=null;}}else{if(!this.cursor){this.cursor=this.view.scrollDOM.appendChild(document.createElement("div"));this.cursor.className="cm-dropCursor";}if(_update9.startState.field(dropCursorPos)!=cursorPos||_update9.docChanged||_update9.geometryChanged)this.view.requestMeasure(this.measureReq);}}},{key:"readPos",value:function readPos(){var pos=this.view.state.field(dropCursorPos);var rect=pos!=null&&this.view.coordsAtPos(pos);if(!rect)return null;var outer=this.view.scrollDOM.getBoundingClientRect();return{left:rect.left-outer.left+this.view.scrollDOM.scrollLeft,top:rect.top-outer.top+this.view.scrollDOM.scrollTop,height:rect.bottom-rect.top};}},{key:"drawCursor",value:function drawCursor(pos){if(this.cursor){if(pos){this.cursor.style.left=pos.left+"px";this.cursor.style.top=pos.top+"px";this.cursor.style.height=pos.height+"px";}else{this.cursor.style.left="-100000px";}}}},{key:"destroy",value:function destroy(){if(this.cursor)this.cursor.remove();}},{key:"setDropPos",value:function setDropPos(pos){if(this.view.state.field(dropCursorPos)!=pos)this.view.dispatch({effects:setDropCursorPos.of(pos)});}}]);return _class5;}(),{eventHandlers:{dragover:function dragover(event){this.setDropPos(this.view.posAtCoords({x:event.clientX,y:event.clientY}));},dragleave:function dragleave(event){if(event.target==this.view.contentDOM||!this.view.contentDOM.contains(event.relatedTarget))this.setDropPos(null);},dragend:function dragend(){this.setDropPos(null);},drop:function drop(){this.setDropPos(null);}}});/**
15141514+Draws a cursor at the current drop position when something is
15151515+dragged over the editor.
15161516+*/function dropCursor(){return[dropCursorPos,drawDropCursor];}function iterMatches(doc,re,from,to,f){re.lastIndex=0;for(var cursor=doc.iterRange(from,to),pos=from,m;!cursor.next().done;pos+=cursor.value.length){if(!cursor.lineBreak)while(m=re.exec(cursor.value)){f(pos+m.index,pos+m.index+m[0].length,m);}}}function matchRanges(view,maxLength){var visible=view.visibleRanges;if(visible.length==1&&visible[0].from==view.viewport.from&&visible[0].to==view.viewport.to)return visible;var result=[];var _iterator95=_createForOfIteratorHelper(visible),_step95;try{for(_iterator95.s();!(_step95=_iterator95.n()).done;){var _step95$value=_step95.value,from=_step95$value.from,to=_step95$value.to;from=Math.max(view.state.doc.lineAt(from).from,from-maxLength);to=Math.min(view.state.doc.lineAt(to).to,to+maxLength);if(result.length&&result[result.length-1].to>=from)result[result.length-1].to=to;else result.push({from:from,to:to});}}catch(err){_iterator95.e(err);}finally{_iterator95.f();}return result;}/**
15171517+Helper class used to make it easier to maintain decorations on
15181518+visible code that matches a given regular expression. To be used
15191519+in a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object
15201520+represent a matching configuration.
15211521+*/var MatchDecorator=/*#__PURE__*/function(){/**
15221522+ Create a decorator.
15231523+ */function MatchDecorator(config){_classCallCheck(this,MatchDecorator);var regexp=config.regexp,decoration=config.decoration,boundary=config.boundary,_config$maxLength=config.maxLength,maxLength=_config$maxLength===void 0?1000:_config$maxLength;if(!regexp.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=regexp;this.getDeco=typeof decoration=="function"?decoration:function(){return decoration;};this.boundary=boundary;this.maxLength=maxLength;}/**
15241524+ Compute the full set of decorations for matches in the given
15251525+ view's viewport. You'll want to call this when initializing your
15261526+ plugin.
15271527+ */_createClass(MatchDecorator,[{key:"createDeco",value:function createDeco(view){var _this52=this;var build=new rangeset.RangeSetBuilder();var _iterator96=_createForOfIteratorHelper(matchRanges(view,this.maxLength)),_step96;try{for(_iterator96.s();!(_step96=_iterator96.n()).done;){var _step96$value=_step96.value,from=_step96$value.from,to=_step96$value.to;iterMatches(view.state.doc,this.regexp,from,to,function(a,b,m){return build.add(a,b,_this52.getDeco(m,view,a));});}}catch(err){_iterator96.e(err);}finally{_iterator96.f();}return build.finish();}/**
15281528+ Update a set of decorations for a view update. `deco` _must_ be
15291529+ the set of decorations produced by _this_ `MatchDecorator` for
15301530+ the view state before the update.
15311531+ */},{key:"updateDeco",value:function updateDeco(update,deco){var changeFrom=1e9,changeTo=-1;if(update.docChanged)update.changes.iterChanges(function(_f,_t,from,to){if(to>update.view.viewport.from&&from<update.view.viewport.to){changeFrom=Math.min(from,changeFrom);changeTo=Math.max(to,changeTo);}});if(update.viewportChanged||changeTo-changeFrom>1000)return this.createDeco(update.view);if(changeTo>-1)return this.updateRange(update.view,deco.map(update.changes),changeFrom,changeTo);return deco;}},{key:"updateRange",value:function updateRange(view,deco,updateFrom,updateTo){var _this53=this;var _iterator97=_createForOfIteratorHelper(view.visibleRanges),_step97;try{for(_iterator97.s();!(_step97=_iterator97.n()).done;){var _r5=_step97.value;var from=Math.max(_r5.from,updateFrom),to=Math.min(_r5.to,updateTo);if(to>from){(function(){var fromLine=view.state.doc.lineAt(from),toLine=fromLine.to<to?view.state.doc.lineAt(to):fromLine;var start=Math.max(_r5.from,fromLine.from),end=Math.min(_r5.to,toLine.to);if(_this53.boundary){for(;from>fromLine.from;from--){if(_this53.boundary.test(fromLine.text[from-1-fromLine.from])){start=from;break;}}for(;to<toLine.to;to++){if(_this53.boundary.test(toLine.text[to-toLine.from])){end=to;break;}}}var ranges=[],m=void 0;if(fromLine==toLine){_this53.regexp.lastIndex=start-fromLine.from;while((m=_this53.regexp.exec(fromLine.text))&&m.index<end-fromLine.from){var pos=m.index+fromLine.from;ranges.push(_this53.getDeco(m,view,pos).range(pos,pos+m[0].length));}}else{iterMatches(view.state.doc,_this53.regexp,start,end,function(from,to,m){return ranges.push(_this53.getDeco(m,view,from).range(from,to));});}deco=deco.update({filterFrom:start,filterTo:end,filter:function filter(from,to){return from<start||to>end;},add:ranges});})();}}}catch(err){_iterator97.e(err);}finally{_iterator97.f();}return deco;}}]);return MatchDecorator;}();var UnicodeRegexpSupport=/x/.unicode!=null?"gu":"g";var Specials=new RegExp("[\0-\b\n-\x1F\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\uFEFF\uFFF9-\uFFFC]",UnicodeRegexpSupport);var Names={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",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};var _supportsTabSize=null;function supportsTabSize(){var _a;if(_supportsTabSize==null&&typeof document!="undefined"&&document.body){var styles=document.body.style;_supportsTabSize=((_a=styles.tabSize)!==null&&_a!==void 0?_a:styles.MozTabSize)!=null;}return _supportsTabSize||false;}var specialCharConfig=state.Facet.define({combine:function combine(configs){var config=state.combineConfig(configs,{render:null,specialChars:Specials,addSpecialChars:null});if(config.replaceTabs=!supportsTabSize())config.specialChars=new RegExp("\t|"+config.specialChars.source,UnicodeRegexpSupport);if(config.addSpecialChars)config.specialChars=new RegExp(config.specialChars.source+"|"+config.addSpecialChars.source,UnicodeRegexpSupport);return config;}});/**
15321532+Returns an extension that installs highlighting of special
15331533+characters.
15341534+*/function highlightSpecialChars(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return[specialCharConfig.of(config),specialCharPlugin()];}var _plugin=null;function specialCharPlugin(){return _plugin||(_plugin=ViewPlugin.fromClass(/*#__PURE__*/function(){function _class6(view){_classCallCheck(this,_class6);this.view=view;this.decorations=Decoration.none;this.decorationCache=Object.create(null);this.decorator=this.makeDecorator(view.state.facet(specialCharConfig));this.decorations=this.decorator.createDeco(view);}_createClass(_class6,[{key:"makeDecorator",value:function makeDecorator(conf){var _this54=this;return new MatchDecorator({regexp:conf.specialChars,decoration:function decoration(m,view,pos){var doc=view.state.doc;var code=text.codePointAt(m[0],0);if(code==9){var line=doc.lineAt(pos);var size=view.state.tabSize,col=text.countColumn(line.text,size,pos-line.from);return Decoration.replace({widget:new TabWidget((size-col%size)*_this54.view.defaultCharacterWidth)});}return _this54.decorationCache[code]||(_this54.decorationCache[code]=Decoration.replace({widget:new SpecialCharWidget(conf,code)}));},boundary:conf.replaceTabs?undefined:/[^]/});}},{key:"update",value:function update(_update10){var conf=_update10.state.facet(specialCharConfig);if(_update10.startState.facet(specialCharConfig)!=conf){this.decorator=this.makeDecorator(conf);this.decorations=this.decorator.createDeco(_update10.view);}else{this.decorations=this.decorator.updateDeco(_update10,this.decorations);}}}]);return _class6;}(),{decorations:function decorations(v){return v.decorations;}}));}var DefaultPlaceholder="\u2022";// Assigns placeholder characters from the Control Pictures block to
15351535+// ASCII control characters
15361536+function placeholder$1(code){if(code>=32)return DefaultPlaceholder;if(code==10)return"\u2424";return String.fromCharCode(9216+code);}var SpecialCharWidget=/*#__PURE__*/function(_WidgetType5){_inherits(SpecialCharWidget,_WidgetType5);var _super24=_createSuper(SpecialCharWidget);function SpecialCharWidget(options,code){var _this55;_classCallCheck(this,SpecialCharWidget);_this55=_super24.call(this);_this55.options=options;_this55.code=code;return _this55;}_createClass(SpecialCharWidget,[{key:"eq",value:function eq(other){return other.code==this.code;}},{key:"toDOM",value:function toDOM(view){var ph=placeholder$1(this.code);var desc=view.state.phrase("Control character")+" "+(Names[this.code]||"0x"+this.code.toString(16));var custom=this.options.render&&this.options.render(this.code,desc,ph);if(custom)return custom;var span=document.createElement("span");span.textContent=ph;span.title=desc;span.setAttribute("aria-label",desc);span.className="cm-specialChar";return span;}},{key:"ignoreEvent",value:function ignoreEvent(){return false;}}]);return SpecialCharWidget;}(WidgetType);var TabWidget=/*#__PURE__*/function(_WidgetType6){_inherits(TabWidget,_WidgetType6);var _super25=_createSuper(TabWidget);function TabWidget(width){var _this56;_classCallCheck(this,TabWidget);_this56=_super25.call(this);_this56.width=width;return _this56;}_createClass(TabWidget,[{key:"eq",value:function eq(other){return other.width==this.width;}},{key:"toDOM",value:function toDOM(){var span=document.createElement("span");span.textContent="\t";span.className="cm-tab";span.style.width=this.width+"px";return span;}},{key:"ignoreEvent",value:function ignoreEvent(){return false;}}]);return TabWidget;}(WidgetType);var plugin=ViewPlugin.fromClass(/*#__PURE__*/function(){function _class7(){_classCallCheck(this,_class7);this.height=1000;this.attrs={style:"padding-bottom: 1000px"};}_createClass(_class7,[{key:"update",value:function update(_update11){var height=_update11.view.viewState.editorHeight-_update11.view.defaultLineHeight;if(height!=this.height){this.height=height;this.attrs={style:"padding-bottom: ".concat(height,"px")};}}}]);return _class7;}());/**
15371537+Returns an extension that makes sure the content has a bottom
15381538+margin equivalent to the height of the editor, minus one line
15391539+height, so that every line in the document can be scrolled to the
15401540+top of the editor.
15411541+15421542+This is only meaningful when the editor is scrollable, and should
15431543+not be enabled in editors that take the size of their content.
15441544+*/function scrollPastEnd(){return[plugin,contentAttributes.of(function(view){var _a;return((_a=view.plugin(plugin))===null||_a===void 0?void 0:_a.attrs)||null;})];}/**
15451545+Mark lines that have a cursor on them with the `"cm-activeLine"`
15461546+DOM class.
15471547+*/function highlightActiveLine(){return activeLineHighlighter;}var lineDeco=Decoration.line({"class":"cm-activeLine"});var activeLineHighlighter=ViewPlugin.fromClass(/*#__PURE__*/function(){function _class8(view){_classCallCheck(this,_class8);this.decorations=this.getDeco(view);}_createClass(_class8,[{key:"update",value:function update(_update12){if(_update12.docChanged||_update12.selectionSet)this.decorations=this.getDeco(_update12.view);}},{key:"getDeco",value:function getDeco(view){var lastLineStart=-1,deco=[];var _iterator98=_createForOfIteratorHelper(view.state.selection.ranges),_step98;try{for(_iterator98.s();!(_step98=_iterator98.n()).done;){var _r6=_step98.value;if(!_r6.empty)return Decoration.none;var line=view.lineBlockAt(_r6.head);if(line.from>lastLineStart){deco.push(lineDeco.range(line.from));lastLineStart=line.from;}}}catch(err){_iterator98.e(err);}finally{_iterator98.f();}return Decoration.set(deco);}}]);return _class8;}(),{decorations:function decorations(v){return v.decorations;}});var Placeholder=/*#__PURE__*/function(_WidgetType7){_inherits(Placeholder,_WidgetType7);var _super26=_createSuper(Placeholder);function Placeholder(content){var _this57;_classCallCheck(this,Placeholder);_this57=_super26.call(this);_this57.content=content;return _this57;}_createClass(Placeholder,[{key:"toDOM",value:function toDOM(){var wrap=document.createElement("span");wrap.className="cm-placeholder";wrap.style.pointerEvents="none";wrap.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content);if(typeof this.content=="string")wrap.setAttribute("aria-label","placeholder "+this.content);else wrap.setAttribute("aria-hidden","true");return wrap;}},{key:"ignoreEvent",value:function ignoreEvent(){return false;}}]);return Placeholder;}(WidgetType);/**
15481548+Extension that enables a placeholder—a piece of example content
15491549+to show when the editor is empty.
15501550+*/function placeholder(content){return ViewPlugin.fromClass(/*#__PURE__*/function(){function _class9(view){_classCallCheck(this,_class9);this.view=view;this.placeholder=Decoration.set([Decoration.widget({widget:new Placeholder(content),side:1}).range(0)]);}_createClass(_class9,[{key:"decorations",get:function get(){return this.view.state.doc.length?Decoration.none:this.placeholder;}}]);return _class9;}(),{decorations:function decorations(v){return v.decorations;}});}/**
15511551+@internal
15521552+*/var __test={HeightMap:HeightMap,HeightOracle:HeightOracle,MeasuredHeights:MeasuredHeights,QueryType:QueryType,ChangedRange:ChangedRange,computeOrder:computeOrder,moveVisually:moveVisually};Object.defineProperty(exports,'Range',{enumerable:true,get:function get(){return rangeset.Range;}});exports.BidiSpan=BidiSpan;exports.BlockInfo=BlockInfo;exports.Decoration=Decoration;exports.EditorView=EditorView;exports.MatchDecorator=MatchDecorator;exports.PluginField=PluginField;exports.PluginFieldProvider=PluginFieldProvider;exports.ViewPlugin=ViewPlugin;exports.ViewUpdate=ViewUpdate;exports.WidgetType=WidgetType;exports.__test=__test;exports.drawSelection=drawSelection;exports.dropCursor=dropCursor;exports.highlightActiveLine=highlightActiveLine;exports.highlightSpecialChars=highlightSpecialChars;exports.keymap=keymap;exports.logException=logException;exports.placeholder=placeholder;exports.runScopeHandlers=runScopeHandlers;exports.scrollPastEnd=scrollPastEnd;},{"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/text":24,"style-mod":30,"w3c-keyname":31}],6:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var state=require('@codemirror/state');/**
15531553+Comment or uncomment the current selection. Will use line comments
15541554+if available, otherwise falling back to block comments.
15551555+*/var toggleComment=function toggleComment(target){var config=getConfig(target.state);return config.line?toggleLineComment(target):config.block?toggleBlockComment(target):false;};function command(f,option){return function(_ref48){var state=_ref48.state,dispatch=_ref48.dispatch;var tr=f(option,state.selection.ranges,state);if(!tr)return false;dispatch(state.update(tr));return true;};}/**
15561556+Comment or uncomment the current selection using line comments.
15571557+The line comment syntax is taken from the
15581558+[`commentTokens`](https://codemirror.net/6/docs/ref/#comment.CommentTokens) [language
15591559+data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
15601560+*/var toggleLineComment=command(changeLineComment,0/* Toggle */);/**
15611561+Comment the current selection using line comments.
15621562+*/var lineComment=command(changeLineComment,1/* Comment */);/**
15631563+Uncomment the current selection using line comments.
15641564+*/var lineUncomment=command(changeLineComment,2/* Uncomment */);/**
15651565+Comment or uncomment the current selection using block comments.
15661566+The block comment syntax is taken from the
15671567+[`commentTokens`](https://codemirror.net/6/docs/ref/#comment.CommentTokens) [language
15681568+data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
15691569+*/var toggleBlockComment=command(changeBlockComment,0/* Toggle */);/**
15701570+Comment the current selection using block comments.
15711571+*/var blockComment=command(changeBlockComment,1/* Comment */);/**
15721572+Uncomment the current selection using block comments.
15731573+*/var blockUncomment=command(changeBlockComment,2/* Uncomment */);/**
15741574+Default key bindings for this package.
15751575+15761576+ - Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#comment.toggleComment).
15771577+ - Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#comment.toggleBlockComment).
15781578+*/var commentKeymap=[{key:"Mod-/",run:toggleComment},{key:"Alt-A",run:toggleBlockComment}];function getConfig(state){var pos=arguments.length>1&&arguments[1]!==undefined?arguments[1]:state.selection.main.head;var data=state.languageDataAt("commentTokens",pos);return data.length?data[0]:{};}var SearchMargin=50;/**
15791579+Determines if the given range is block-commented in the given
15801580+state.
15811581+*/function findBlockComment(state,_ref49,from,to){var open=_ref49.open,close=_ref49.close;var textBefore=state.sliceDoc(from-SearchMargin,from);var textAfter=state.sliceDoc(to,to+SearchMargin);var spaceBefore=/\s*$/.exec(textBefore)[0].length,spaceAfter=/^\s*/.exec(textAfter)[0].length;var beforeOff=textBefore.length-spaceBefore;if(textBefore.slice(beforeOff-open.length,beforeOff)==open&&textAfter.slice(spaceAfter,spaceAfter+close.length)==close){return{open:{pos:from-spaceBefore,margin:spaceBefore&&1},close:{pos:to+spaceAfter,margin:spaceAfter&&1}};}var startText,endText;if(to-from<=2*SearchMargin){startText=endText=state.sliceDoc(from,to);}else{startText=state.sliceDoc(from,from+SearchMargin);endText=state.sliceDoc(to-SearchMargin,to);}var startSpace=/^\s*/.exec(startText)[0].length,endSpace=/\s*$/.exec(endText)[0].length;var endOff=endText.length-endSpace-close.length;if(startText.slice(startSpace,startSpace+open.length)==open&&endText.slice(endOff,endOff+close.length)==close){return{open:{pos:from+startSpace+open.length,margin:/\s/.test(startText.charAt(startSpace+open.length))?1:0},close:{pos:to-endSpace-close.length,margin:/\s/.test(endText.charAt(endOff-1))?1:0}};}return null;}// Performs toggle, comment and uncomment of block comments in
15821582+// languages that support them.
15831583+function changeBlockComment(option,ranges,state$1){var tokens=ranges.map(function(r){return getConfig(state$1,r.from).block;});if(!tokens.every(function(c){return c;}))return null;var comments=ranges.map(function(r,i){return findBlockComment(state$1,tokens[i],r.from,r.to);});if(option!=2/* Uncomment */&&!comments.every(function(c){return c;})){var index=0;return state$1.changeByRange(function(range){var _tokens$index=tokens[index++],open=_tokens$index.open,close=_tokens$index.close;if(comments[index])return{range:range};var shift=open.length+1;return{changes:[{from:range.from,insert:open+" "},{from:range.to,insert:" "+close}],range:state.EditorSelection.range(range.anchor+shift,range.head+shift)};});}else if(option!=1/* Comment */&&comments.some(function(c){return c;})){var changes=[];for(var _i55=0,comment;_i55<comments.length;_i55++){if(comment=comments[_i55]){var token=tokens[_i55],_comment=comment,open=_comment.open,close=_comment.close;changes.push({from:open.pos-token.open.length,to:open.pos+open.margin},{from:close.pos-close.margin,to:close.pos+token.close.length});}}return{changes:changes};}return null;}// Performs toggle, comment and uncomment of line comments.
15841584+function changeLineComment(option,ranges,state){var lines=[];var prevLine=-1;var _iterator99=_createForOfIteratorHelper(ranges),_step99;try{for(_iterator99.s();!(_step99=_iterator99.n()).done;){var _step99$value=_step99.value,_from3=_step99$value.from,_to2=_step99$value.to;var startI=lines.length,minIndent=1e9;for(var pos=_from3;pos<=_to2;){var _line2=state.doc.lineAt(pos);if(_line2.from>prevLine&&(_from3==_to2||_to2>_line2.from)){prevLine=_line2.from;var _token2=getConfig(state,pos).line;if(!_token2)continue;var _indent=/^\s*/.exec(_line2.text)[0].length;var _empty=_indent==_line2.length;var _comment2=_line2.text.slice(_indent,_indent+_token2.length)==_token2?_indent:-1;if(_indent<_line2.text.length&&_indent<minIndent)minIndent=_indent;lines.push({line:_line2,comment:_comment2,token:_token2,indent:_indent,empty:_empty,single:false});}pos=_line2.to+1;}if(minIndent<1e9)for(var _i56=startI;_i56<lines.length;_i56++){if(lines[_i56].indent<lines[_i56].line.text.length)lines[_i56].indent=minIndent;}if(lines.length==startI+1)lines[startI].single=true;}}catch(err){_iterator99.e(err);}finally{_iterator99.f();}if(option!=2/* Uncomment */&&lines.some(function(l){return l.comment<0&&(!l.empty||l.single);})){var changes=[];var _iterator100=_createForOfIteratorHelper(lines),_step100;try{for(_iterator100.s();!(_step100=_iterator100.n()).done;){var _step100$value=_step100.value,line=_step100$value.line,token=_step100$value.token,indent=_step100$value.indent,empty=_step100$value.empty,single=_step100$value.single;if(single||!empty)changes.push({from:line.from+indent,insert:token+" "});}}catch(err){_iterator100.e(err);}finally{_iterator100.f();}var changeSet=state.changes(changes);return{changes:changeSet,selection:state.selection.map(changeSet,1)};}else if(option!=1/* Comment */&&lines.some(function(l){return l.comment>=0;})){var _changes=[];var _iterator101=_createForOfIteratorHelper(lines),_step101;try{for(_iterator101.s();!(_step101=_iterator101.n()).done;){var _step101$value=_step101.value,_line=_step101$value.line,comment=_step101$value.comment,_token=_step101$value.token;if(comment>=0){var from=_line.from+comment,to=from+_token.length;if(_line.text[to-_line.from]==" ")to++;_changes.push({from:from,to:to});}}}catch(err){_iterator101.e(err);}finally{_iterator101.f();}return{changes:_changes};}return null;}exports.blockComment=blockComment;exports.blockUncomment=blockUncomment;exports.commentKeymap=commentKeymap;exports.lineComment=lineComment;exports.lineUncomment=lineUncomment;exports.toggleBlockComment=toggleBlockComment;exports.toggleComment=toggleComment;exports.toggleLineComment=toggleLineComment;},{"@codemirror/state":22}],7:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var state=require('@codemirror/state');var view=require('@codemirror/view');var language=require('@codemirror/language');var gutter=require('@codemirror/gutter');var rangeset=require('@codemirror/rangeset');function mapRange(range,mapping){var from=mapping.mapPos(range.from,1),to=mapping.mapPos(range.to,-1);return from>=to?undefined:{from:from,to:to};}/**
15851585+State effect that can be attached to a transaction to fold the
15861586+given range. (You probably only need this in exceptional
15871587+circumstances—usually you'll just want to let
15881588+[`foldCode`](https://codemirror.net/6/docs/ref/#fold.foldCode) and the [fold
15891589+gutter](https://codemirror.net/6/docs/ref/#fold.foldGutter) create the transactions.)
15901590+*/var foldEffect=state.StateEffect.define({map:mapRange});/**
15911591+State effect that unfolds the given range (if it was folded).
15921592+*/var unfoldEffect=state.StateEffect.define({map:mapRange});function selectedLines(view){var lines=[];var _iterator102=_createForOfIteratorHelper(view.state.selection.ranges),_step102;try{var _loop11=function _loop11(){var head=_step102.value.head;if(lines.some(function(l){return l.from<=head&&l.to>=head;}))return"continue";lines.push(view.lineBlockAt(head));};for(_iterator102.s();!(_step102=_iterator102.n()).done;){var _ret3=_loop11();if(_ret3==="continue")continue;}}catch(err){_iterator102.e(err);}finally{_iterator102.f();}return lines;}var foldState=state.StateField.define({create:function create(){return view.Decoration.none;},update:function update(folded,tr){folded=folded.map(tr.changes);var _iterator103=_createForOfIteratorHelper(tr.effects),_step103;try{var _loop12=function _loop12(){var e=_step103.value;if(e.is(foldEffect)&&!foldExists(folded,e.value.from,e.value.to))folded=folded.update({add:[foldWidget.range(e.value.from,e.value.to)]});else if(e.is(unfoldEffect))folded=folded.update({filter:function filter(from,to){return e.value.from!=from||e.value.to!=to;},filterFrom:e.value.from,filterTo:e.value.to});};for(_iterator103.s();!(_step103=_iterator103.n()).done;){_loop12();}// Clear folded ranges that cover the selection head
15931593+}catch(err){_iterator103.e(err);}finally{_iterator103.f();}if(tr.selection){var onSelection=false,head=tr.selection.main.head;folded.between(head,head,function(a,b){if(a<head&&b>head)onSelection=true;});if(onSelection)folded=folded.update({filterFrom:head,filterTo:head,filter:function filter(a,b){return b<=head||a>=head;}});}return folded;},provide:function provide(f){return view.EditorView.decorations.from(f);}});/**
15941594+Get a [range set](https://codemirror.net/6/docs/ref/#rangeset.RangeSet) containing the folded ranges
15951595+in the given state.
15961596+*/function foldedRanges(state){return state.field(foldState,false)||rangeset.RangeSet.empty;}function foldInside(state,from,to){var _a;var found=null;(_a=state.field(foldState,false))===null||_a===void 0?void 0:_a.between(from,to,function(from,to){if(!found||found.from>from)found={from:from,to:to};});return found;}function foldExists(folded,from,to){var found=false;folded.between(from,from,function(a,b){if(a==from&&b==to)found=true;});return found;}function maybeEnable(state$1,other){return state$1.field(foldState,false)?other:other.concat(state.StateEffect.appendConfig.of(codeFolding()));}/**
15971597+Fold the lines that are selected, if possible.
15981598+*/var foldCode=function foldCode(view){var _iterator104=_createForOfIteratorHelper(selectedLines(view)),_step104;try{for(_iterator104.s();!(_step104=_iterator104.n()).done;){var line=_step104.value;var range=language.foldable(view.state,line.from,line.to);if(range){view.dispatch({effects:maybeEnable(view.state,[foldEffect.of(range),announceFold(view,range)])});return true;}}}catch(err){_iterator104.e(err);}finally{_iterator104.f();}return false;};/**
15991599+Unfold folded ranges on selected lines.
16001600+*/var unfoldCode=function unfoldCode(view){if(!view.state.field(foldState,false))return false;var effects=[];var _iterator105=_createForOfIteratorHelper(selectedLines(view)),_step105;try{for(_iterator105.s();!(_step105=_iterator105.n()).done;){var line=_step105.value;var folded=foldInside(view.state,line.from,line.to);if(folded)effects.push(unfoldEffect.of(folded),announceFold(view,folded,false));}}catch(err){_iterator105.e(err);}finally{_iterator105.f();}if(effects.length)view.dispatch({effects:effects});return effects.length>0;};function announceFold(view$1,range){var fold=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var lineFrom=view$1.state.doc.lineAt(range.from).number,lineTo=view$1.state.doc.lineAt(range.to).number;return view.EditorView.announce.of("".concat(view$1.state.phrase(fold?"Folded lines":"Unfolded lines")," ").concat(lineFrom," ").concat(view$1.state.phrase("to")," ").concat(lineTo,"."));}/**
16011601+Fold all top-level foldable ranges.
16021602+*/var foldAll=function foldAll(view){var state=view.state,effects=[];for(var pos=0;pos<state.doc.length;){var line=view.lineBlockAt(pos),range=language.foldable(state,line.from,line.to);if(range)effects.push(foldEffect.of(range));pos=(range?view.lineBlockAt(range.to):line).to+1;}if(effects.length)view.dispatch({effects:maybeEnable(view.state,effects)});return!!effects.length;};/**
16031603+Unfold all folded code.
16041604+*/var unfoldAll=function unfoldAll(view){var field=view.state.field(foldState,false);if(!field||!field.size)return false;var effects=[];field.between(0,view.state.doc.length,function(from,to){effects.push(unfoldEffect.of({from:from,to:to}));});view.dispatch({effects:effects});return true;};/**
16051605+Default fold-related key bindings.
16061606+16071607+ - Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#fold.foldCode).
16081608+ - Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#fold.unfoldCode).
16091609+ - Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#fold.foldAll).
16101610+ - Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#fold.unfoldAll).
16111611+*/var foldKeymap=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:foldCode},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:unfoldCode},{key:"Ctrl-Alt-[",run:foldAll},{key:"Ctrl-Alt-]",run:unfoldAll}];var defaultConfig={placeholderDOM:null,placeholderText:"…"};var foldConfig=state.Facet.define({combine:function combine(values){return state.combineConfig(values,defaultConfig);}});/**
16121612+Create an extension that configures code folding.
16131613+*/function codeFolding(config){var result=[foldState,baseTheme];if(config)result.push(foldConfig.of(config));return result;}var foldWidget=view.Decoration.replace({widget:new(/*#__PURE__*/function(_view$WidgetType2){_inherits(_class10,_view$WidgetType2);var _super27=_createSuper(_class10);function _class10(){_classCallCheck(this,_class10);return _super27.apply(this,arguments);}_createClass(_class10,[{key:"toDOM",value:function toDOM(view){var state=view.state,conf=state.facet(foldConfig);var onclick=function onclick(event){var line=view.lineBlockAt(view.posAtDOM(event.target));var folded=foldInside(view.state,line.from,line.to);if(folded)view.dispatch({effects:unfoldEffect.of(folded)});event.preventDefault();};if(conf.placeholderDOM)return conf.placeholderDOM(view,onclick);var element=document.createElement("span");element.textContent=conf.placeholderText;element.setAttribute("aria-label",state.phrase("folded code"));element.title=state.phrase("unfold");element.className="cm-foldPlaceholder";element.onclick=onclick;return element;}}]);return _class10;}(view.WidgetType))()});var foldGutterDefaults={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{}};var FoldMarker=/*#__PURE__*/function(_gutter$GutterMarker){_inherits(FoldMarker,_gutter$GutterMarker);var _super28=_createSuper(FoldMarker);function FoldMarker(config,open){var _this58;_classCallCheck(this,FoldMarker);_this58=_super28.call(this);_this58.config=config;_this58.open=open;return _this58;}_createClass(FoldMarker,[{key:"eq",value:function eq(other){return this.config==other.config&&this.open==other.open;}},{key:"toDOM",value:function toDOM(view){if(this.config.markerDOM)return this.config.markerDOM(this.open);var span=document.createElement("span");span.textContent=this.open?this.config.openText:this.config.closedText;span.title=view.state.phrase(this.open?"Fold line":"Unfold line");return span;}}]);return FoldMarker;}(gutter.GutterMarker);/**
16141614+Create an extension that registers a fold gutter, which shows a
16151615+fold status indicator before foldable lines (which can be clicked
16161616+to fold or unfold the line).
16171617+*/function foldGutter(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var fullConfig=Object.assign(Object.assign({},foldGutterDefaults),config);var canFold=new FoldMarker(fullConfig,true),canUnfold=new FoldMarker(fullConfig,false);var _markers=view.ViewPlugin.fromClass(/*#__PURE__*/function(){function _class11(view){_classCallCheck(this,_class11);this.from=view.viewport.from;this.markers=this.buildMarkers(view);}_createClass(_class11,[{key:"update",value:function update(_update13){if(_update13.docChanged||_update13.viewportChanged||_update13.startState.facet(language.language)!=_update13.state.facet(language.language)||_update13.startState.field(foldState,false)!=_update13.state.field(foldState,false))this.markers=this.buildMarkers(_update13.view);}},{key:"buildMarkers",value:function buildMarkers(view){var builder=new rangeset.RangeSetBuilder();var _iterator106=_createForOfIteratorHelper(view.viewportLineBlocks),_step106;try{for(_iterator106.s();!(_step106=_iterator106.n()).done;){var line=_step106.value;var mark=foldInside(view.state,line.from,line.to)?canUnfold:language.foldable(view.state,line.from,line.to)?canFold:null;if(mark)builder.add(line.from,line.from,mark);}}catch(err){_iterator106.e(err);}finally{_iterator106.f();}return builder.finish();}}]);return _class11;}());var domEventHandlers=fullConfig.domEventHandlers;return[_markers,gutter.gutter({"class":"cm-foldGutter",markers:function markers(view){var _a;return((_a=view.plugin(_markers))===null||_a===void 0?void 0:_a.markers)||rangeset.RangeSet.empty;},initialSpacer:function initialSpacer(){return new FoldMarker(fullConfig,false);},domEventHandlers:Object.assign(Object.assign({},domEventHandlers),{click:function click(view,line,event){if(domEventHandlers.click&&domEventHandlers.click(view,line,event))return true;var folded=foldInside(view.state,line.from,line.to);if(folded){view.dispatch({effects:unfoldEffect.of(folded)});return true;}var range=language.foldable(view.state,line.from,line.to);if(range){view.dispatch({effects:foldEffect.of(range)});return true;}return false;}})}),codeFolding()];}var baseTheme=view.EditorView.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});exports.codeFolding=codeFolding;exports.foldAll=foldAll;exports.foldCode=foldCode;exports.foldEffect=foldEffect;exports.foldGutter=foldGutter;exports.foldKeymap=foldKeymap;exports.foldedRanges=foldedRanges;exports.unfoldAll=unfoldAll;exports.unfoldCode=unfoldCode;exports.unfoldEffect=unfoldEffect;},{"@codemirror/gutter":9,"@codemirror/language":13,"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/view":8}],8:[function(require,module,exports){arguments[4][5][0].apply(exports,arguments);},{"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/text":24,"dup":5,"style-mod":30,"w3c-keyname":31}],9:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var view=require('@codemirror/view');var rangeset=require('@codemirror/rangeset');var state=require('@codemirror/state');/**
16181618+A gutter marker represents a bit of information attached to a line
16191619+in a specific gutter. Your own custom markers have to extend this
16201620+class.
16211621+*/var GutterMarker=/*#__PURE__*/function(_rangeset$RangeValue3){_inherits(GutterMarker,_rangeset$RangeValue3);var _super29=_createSuper(GutterMarker);function GutterMarker(){_classCallCheck(this,GutterMarker);return _super29.apply(this,arguments);}_createClass(GutterMarker,[{key:"compare",value:/**
16221622+ @internal
16231623+ */function compare(other){return this==other||this.constructor==other.constructor&&this.eq(other);}/**
16241624+ Compare this marker to another marker of the same type.
16251625+ */},{key:"eq",value:function eq(other){return false;}/**
16261626+ Called if the marker has a `toDOM` method and its representation
16271627+ was removed from a gutter.
16281628+ */},{key:"destroy",value:function destroy(dom){}}]);return GutterMarker;}(rangeset.RangeValue);GutterMarker.prototype.elementClass="";GutterMarker.prototype.toDOM=undefined;GutterMarker.prototype.mapMode=state.MapMode.TrackBefore;GutterMarker.prototype.startSide=GutterMarker.prototype.endSide=-1;GutterMarker.prototype.point=true;/**
16291629+Facet used to add a class to all gutter elements for a given line.
16301630+Markers given to this facet should _only_ define an
16311631+[`elementclass`](https://codemirror.net/6/docs/ref/#gutter.GutterMarker.elementClass), not a
16321632+[`toDOM`](https://codemirror.net/6/docs/ref/#gutter.GutterMarker.toDOM) (or the marker will appear
16331633+in all gutters for the line).
16341634+*/var gutterLineClass=state.Facet.define();var defaults={"class":"",renderEmptyElements:false,elementStyle:"",markers:function markers(){return rangeset.RangeSet.empty;},lineMarker:function lineMarker(){return null;},lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}};var activeGutters=state.Facet.define();/**
16351635+Define an editor gutter. The order in which the gutters appear is
16361636+determined by their extension priority.
16371637+*/function gutter(config){return[gutters(),activeGutters.of(Object.assign(Object.assign({},defaults),config))];}var baseTheme=view.EditorView.baseTheme({".cm-gutters":{display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#999",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"}});var unfixGutters=state.Facet.define({combine:function combine(values){return values.some(function(x){return x;});}});/**
16381638+The gutter-drawing plugin is automatically enabled when you add a
16391639+gutter, but you can use this function to explicitly configure it.
16401640+16411641+Unless `fixed` is explicitly set to `false`, the gutters are
16421642+fixed, meaning they don't scroll along with the content
16431643+horizontally (except on Internet Explorer, which doesn't support
16441644+CSS [`position:
16451645+sticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).
16461646+*/function gutters(config){var result=[gutterView,baseTheme];if(config&&config.fixed===false)result.push(unfixGutters.of(true));return result;}var gutterView=view.ViewPlugin.fromClass(/*#__PURE__*/function(){function _class12(view){_classCallCheck(this,_class12);this.view=view;this.prevViewport=view.viewport;this.dom=document.createElement("div");this.dom.className="cm-gutters";this.dom.setAttribute("aria-hidden","true");this.dom.style.minHeight=this.view.contentHeight+"px";this.gutters=view.state.facet(activeGutters).map(function(conf){return new SingleGutterView(view,conf);});var _iterator107=_createForOfIteratorHelper(this.gutters),_step107;try{for(_iterator107.s();!(_step107=_iterator107.n()).done;){var _gutter=_step107.value;this.dom.appendChild(_gutter.dom);}}catch(err){_iterator107.e(err);}finally{_iterator107.f();}this.fixed=!view.state.facet(unfixGutters);if(this.fixed){// FIXME IE11 fallback, which doesn't support position: sticky,
16471647+// by using position: relative + event handlers that realign the
16481648+// gutter (or just force fixed=false on IE11?)
16491649+this.dom.style.position="sticky";}this.syncGutters(false);view.scrollDOM.insertBefore(this.dom,view.contentDOM);}_createClass(_class12,[{key:"update",value:function update(_update14){if(this.updateGutters(_update14)){// Detach during sync when the viewport changed significantly
16501650+// (such as during scrolling), since for large updates that is
16511651+// faster.
16521652+var vpA=this.prevViewport,vpB=_update14.view.viewport;var vpOverlap=Math.min(vpA.to,vpB.to)-Math.max(vpA.from,vpB.from);this.syncGutters(vpOverlap<(vpB.to-vpB.from)*0.8);}if(_update14.geometryChanged)this.dom.style.minHeight=this.view.contentHeight+"px";if(this.view.state.facet(unfixGutters)!=!this.fixed){this.fixed=!this.fixed;this.dom.style.position=this.fixed?"sticky":"";}this.prevViewport=_update14.view.viewport;}},{key:"syncGutters",value:function syncGutters(detach){var _this59=this;var after=this.dom.nextSibling;if(detach)this.dom.remove();var lineClasses=rangeset.RangeSet.iter(this.view.state.facet(gutterLineClass),this.view.viewport.from);var classSet=[];var contexts=this.gutters.map(function(gutter){return new UpdateContext(gutter,_this59.view.viewport,-_this59.view.documentPadding.top);});var _iterator108=_createForOfIteratorHelper(this.view.viewportLineBlocks),_step108;try{for(_iterator108.s();!(_step108=_iterator108.n()).done;){var line=_step108.value;var text=void 0;if(Array.isArray(line.type)){var _iterator110=_createForOfIteratorHelper(line.type),_step110;try{for(_iterator110.s();!(_step110=_iterator110.n()).done;){var b=_step110.value;if(b.type==view.BlockType.Text){text=b;break;}}}catch(err){_iterator110.e(err);}finally{_iterator110.f();}}else{text=line.type==view.BlockType.Text?line:undefined;}if(!text)continue;if(classSet.length)classSet=[];advanceCursor(lineClasses,classSet,line.from);var _iterator111=_createForOfIteratorHelper(contexts),_step111;try{for(_iterator111.s();!(_step111=_iterator111.n()).done;){var cx=_step111.value;cx.line(this.view,text,classSet);}}catch(err){_iterator111.e(err);}finally{_iterator111.f();}}}catch(err){_iterator108.e(err);}finally{_iterator108.f();}var _iterator109=_createForOfIteratorHelper(contexts),_step109;try{for(_iterator109.s();!(_step109=_iterator109.n()).done;){var _cx=_step109.value;_cx.finish();}}catch(err){_iterator109.e(err);}finally{_iterator109.f();}if(detach)this.view.scrollDOM.insertBefore(this.dom,after);}},{key:"updateGutters",value:function updateGutters(update){var prev=update.startState.facet(activeGutters),cur=update.state.facet(activeGutters);var change=update.docChanged||update.heightChanged||update.viewportChanged||!rangeset.RangeSet.eq(update.startState.facet(gutterLineClass),update.state.facet(gutterLineClass),update.view.viewport.from,update.view.viewport.to);if(prev==cur){var _iterator112=_createForOfIteratorHelper(this.gutters),_step112;try{for(_iterator112.s();!(_step112=_iterator112.n()).done;){var _gutter2=_step112.value;if(_gutter2.update(update))change=true;}}catch(err){_iterator112.e(err);}finally{_iterator112.f();}}else{change=true;var _gutters=[];var _iterator113=_createForOfIteratorHelper(cur),_step113;try{for(_iterator113.s();!(_step113=_iterator113.n()).done;){var conf=_step113.value;var known=prev.indexOf(conf);if(known<0){_gutters.push(new SingleGutterView(this.view,conf));}else{this.gutters[known].update(update);_gutters.push(this.gutters[known]);}}}catch(err){_iterator113.e(err);}finally{_iterator113.f();}var _iterator114=_createForOfIteratorHelper(this.gutters),_step114;try{for(_iterator114.s();!(_step114=_iterator114.n()).done;){var _g=_step114.value;_g.dom.remove();if(_gutters.indexOf(_g)<0)_g.destroy();}}catch(err){_iterator114.e(err);}finally{_iterator114.f();}for(var _i57=0,_gutters2=_gutters;_i57<_gutters2.length;_i57++){var g=_gutters2[_i57];this.dom.appendChild(g.dom);}this.gutters=_gutters;}return change;}},{key:"destroy",value:function destroy(){var _iterator115=_createForOfIteratorHelper(this.gutters),_step115;try{for(_iterator115.s();!(_step115=_iterator115.n()).done;){var _view=_step115.value;_view.destroy();}}catch(err){_iterator115.e(err);}finally{_iterator115.f();}this.dom.remove();}}]);return _class12;}(),{provide:view.PluginField.scrollMargins.from(function(value){if(value.gutters.length==0||!value.fixed)return null;return value.view.textDirection==view.Direction.LTR?{left:value.dom.offsetWidth}:{right:value.dom.offsetWidth};})});function asArray(val){return Array.isArray(val)?val:[val];}function advanceCursor(cursor,collect,pos){while(cursor.value&&cursor.from<=pos){if(cursor.from==pos)collect.push(cursor.value);cursor.next();}}var UpdateContext=/*#__PURE__*/function(){function UpdateContext(gutter,viewport,height){_classCallCheck(this,UpdateContext);this.gutter=gutter;this.height=height;this.localMarkers=[];this.i=0;this.cursor=rangeset.RangeSet.iter(gutter.markers,viewport.from);}_createClass(UpdateContext,[{key:"line",value:function line(view,_line3,extraMarkers){if(this.localMarkers.length)this.localMarkers=[];advanceCursor(this.cursor,this.localMarkers,_line3.from);var localMarkers=extraMarkers.length?this.localMarkers.concat(extraMarkers):this.localMarkers;var forLine=this.gutter.config.lineMarker(view,_line3,localMarkers);if(forLine)localMarkers.unshift(forLine);var gutter=this.gutter;if(localMarkers.length==0&&!gutter.config.renderEmptyElements)return;var above=_line3.top-this.height;if(this.i==gutter.elements.length){var newElt=new GutterElement(view,_line3.height,above,localMarkers);gutter.elements.push(newElt);gutter.dom.appendChild(newElt.dom);}else{gutter.elements[this.i].update(view,_line3.height,above,localMarkers);}this.height=_line3.bottom;this.i++;}},{key:"finish",value:function finish(){var gutter=this.gutter;while(gutter.elements.length>this.i){var last=gutter.elements.pop();gutter.dom.removeChild(last.dom);last.destroy();}}}]);return UpdateContext;}();var SingleGutterView=/*#__PURE__*/function(){function SingleGutterView(view,config){var _this60=this;_classCallCheck(this,SingleGutterView);this.view=view;this.config=config;this.elements=[];this.spacer=null;this.dom=document.createElement("div");this.dom.className="cm-gutter"+(this.config["class"]?" "+this.config["class"]:"");var _loop13=function _loop13(prop){_this60.dom.addEventListener(prop,function(event){var line=view.lineBlockAtHeight(event.clientY-view.documentTop);if(config.domEventHandlers[prop](view,line,event))event.preventDefault();});};for(var prop in config.domEventHandlers){_loop13(prop);}this.markers=asArray(config.markers(view));if(config.initialSpacer){this.spacer=new GutterElement(view,0,0,[config.initialSpacer(view)]);this.dom.appendChild(this.spacer.dom);this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none";}}_createClass(SingleGutterView,[{key:"update",value:function update(_update15){var prevMarkers=this.markers;this.markers=asArray(this.config.markers(_update15.view));if(this.spacer&&this.config.updateSpacer){var updated=this.config.updateSpacer(this.spacer.markers[0],_update15);if(updated!=this.spacer.markers[0])this.spacer.update(_update15.view,0,0,[updated]);}var vp=_update15.view.viewport;return!rangeset.RangeSet.eq(this.markers,prevMarkers,vp.from,vp.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(_update15):false);}},{key:"destroy",value:function destroy(){var _iterator116=_createForOfIteratorHelper(this.elements),_step116;try{for(_iterator116.s();!(_step116=_iterator116.n()).done;){var elt=_step116.value;elt.destroy();}}catch(err){_iterator116.e(err);}finally{_iterator116.f();}}}]);return SingleGutterView;}();var GutterElement=/*#__PURE__*/function(){function GutterElement(view,height,above,markers){_classCallCheck(this,GutterElement);this.height=-1;this.above=0;this.markers=[];this.dom=document.createElement("div");this.update(view,height,above,markers);}_createClass(GutterElement,[{key:"update",value:function update(view,height,above,markers){if(this.height!=height)this.dom.style.height=(this.height=height)+"px";if(this.above!=above)this.dom.style.marginTop=(this.above=above)?above+"px":"";if(!sameMarkers(this.markers,markers))this.setMarkers(view,markers);}},{key:"setMarkers",value:function setMarkers(view,markers){var cls="cm-gutterElement",domPos=this.dom.firstChild;for(var iNew=0,iOld=0;;){var skipTo=iOld,marker=iNew<markers.length?markers[iNew++]:null,matched=false;if(marker){var c=marker.elementClass;if(c)cls+=" "+c;for(var _i58=iOld;_i58<this.markers.length;_i58++){if(this.markers[_i58].compare(marker)){skipTo=_i58;matched=true;break;}}}else{skipTo=this.markers.length;}while(iOld<skipTo){var next=this.markers[iOld++];if(next.toDOM){next.destroy(domPos);var after=domPos.nextSibling;domPos.remove();domPos=after;}}if(!marker)break;if(marker.toDOM){if(matched)domPos=domPos.nextSibling;else this.dom.insertBefore(marker.toDOM(view),domPos);}if(matched)iOld++;}this.dom.className=cls;this.markers=markers;}},{key:"destroy",value:function destroy(){this.setMarkers(null,[]);// First argument not used unless creating markers
16531653+}}]);return GutterElement;}();function sameMarkers(a,b){if(a.length!=b.length)return false;for(var _i59=0;_i59<a.length;_i59++){if(!a[_i59].compare(b[_i59]))return false;}return true;}/**
16541654+Facet used to provide markers to the line number gutter.
16551655+*/var lineNumberMarkers=state.Facet.define();var lineNumberConfig=state.Facet.define({combine:function combine(values){return state.combineConfig(values,{formatNumber:String,domEventHandlers:{}},{domEventHandlers:function domEventHandlers(a,b){var result=Object.assign({},a);var _loop14=function _loop14(event){var exists=result[event],add=b[event];result[event]=exists?function(view,line,event){return exists(view,line,event)||add(view,line,event);}:add;};for(var event in b){_loop14(event);}return result;}});}});var NumberMarker=/*#__PURE__*/function(_GutterMarker){_inherits(NumberMarker,_GutterMarker);var _super30=_createSuper(NumberMarker);function NumberMarker(number){var _this61;_classCallCheck(this,NumberMarker);_this61=_super30.call(this);_this61.number=number;return _this61;}_createClass(NumberMarker,[{key:"eq",value:function eq(other){return this.number==other.number;}},{key:"toDOM",value:function toDOM(){return document.createTextNode(this.number);}}]);return NumberMarker;}(GutterMarker);function formatNumber(view,number){return view.state.facet(lineNumberConfig).formatNumber(number,view.state);}var lineNumberGutter=activeGutters.compute([lineNumberConfig],function(state){return{"class":"cm-lineNumbers",renderEmptyElements:false,markers:function markers(view){return view.state.facet(lineNumberMarkers);},lineMarker:function lineMarker(view,line,others){if(others.some(function(m){return m.toDOM;}))return null;return new NumberMarker(formatNumber(view,view.state.doc.lineAt(line.from).number));},lineMarkerChange:function lineMarkerChange(update){return update.startState.facet(lineNumberConfig)!=update.state.facet(lineNumberConfig);},initialSpacer:function initialSpacer(view){return new NumberMarker(formatNumber(view,maxLineNumber(view.state.doc.lines)));},updateSpacer:function updateSpacer(spacer,update){var max=formatNumber(update.view,maxLineNumber(update.view.state.doc.lines));return max==spacer.number?spacer:new NumberMarker(max);},domEventHandlers:state.facet(lineNumberConfig).domEventHandlers};});/**
16561656+Create a line number gutter extension.
16571657+*/function lineNumbers(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return[lineNumberConfig.of(config),gutters(),lineNumberGutter];}function maxLineNumber(lines){var last=9;while(last<lines){last=last*10+9;}return last;}var activeLineGutterMarker=new(/*#__PURE__*/function(_GutterMarker2){_inherits(_class13,_GutterMarker2);var _super31=_createSuper(_class13);function _class13(){var _this62;_classCallCheck(this,_class13);_this62=_super31.apply(this,arguments);_this62.elementClass="cm-activeLineGutter";return _this62;}return _createClass(_class13);}(GutterMarker))();var activeLineGutterHighlighter=gutterLineClass.compute(["selection"],function(state){var marks=[],last=-1;var _iterator117=_createForOfIteratorHelper(state.selection.ranges),_step117;try{for(_iterator117.s();!(_step117=_iterator117.n()).done;){var range=_step117.value;if(range.empty){var linePos=state.doc.lineAt(range.head).from;if(linePos>last){last=linePos;marks.push(activeLineGutterMarker.range(linePos));}}}}catch(err){_iterator117.e(err);}finally{_iterator117.f();}return rangeset.RangeSet.of(marks);});/**
16581658+Returns an extension that adds a `cm-activeLineGutter` class to
16591659+all gutter elements on the [active
16601660+line](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).
16611661+*/function highlightActiveLineGutter(){return activeLineGutterHighlighter;}exports.GutterMarker=GutterMarker;exports.gutter=gutter;exports.gutterLineClass=gutterLineClass;exports.gutters=gutters;exports.highlightActiveLineGutter=highlightActiveLineGutter;exports.lineNumberMarkers=lineNumberMarkers;exports.lineNumbers=lineNumbers;},{"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/view":10}],10:[function(require,module,exports){arguments[4][5][0].apply(exports,arguments);},{"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/text":24,"dup":5,"style-mod":30,"w3c-keyname":31}],11:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var common=require('@lezer/common');var styleMod=require('style-mod');var view=require('@codemirror/view');var state=require('@codemirror/state');var language=require('@codemirror/language');var rangeset=require('@codemirror/rangeset');var nextTagID=0;/**
16621662+Highlighting tags are markers that denote a highlighting category.
16631663+They are [associated](https://codemirror.net/6/docs/ref/#highlight.styleTags) with parts of a syntax
16641664+tree by a language mode, and then mapped to an actual CSS style by
16651665+a [highlight style](https://codemirror.net/6/docs/ref/#highlight.HighlightStyle).
16661666+16671667+Because syntax tree node types and highlight styles have to be
16681668+able to talk the same language, CodeMirror uses a mostly _closed_
16691669+[vocabulary](https://codemirror.net/6/docs/ref/#highlight.tags) of syntax tags (as opposed to
16701670+traditional open string-based systems, which make it hard for
16711671+highlighting themes to cover all the tokens produced by the
16721672+various languages).
16731673+16741674+It _is_ possible to [define](https://codemirror.net/6/docs/ref/#highlight.Tag^define) your own
16751675+highlighting tags for system-internal use (where you control both
16761676+the language package and the highlighter), but such tags will not
16771677+be picked up by regular highlighters (though you can derive them
16781678+from standard tags to allow highlighters to fall back to those).
16791679+*/var Tag=/*#__PURE__*/function(){/**
16801680+ @internal
16811681+ */function Tag(/**
16821682+ The set of tags that match this tag, starting with this one
16831683+ itself, sorted in order of decreasing specificity. @internal
16841684+ */set,/**
16851685+ The base unmodified tag that this one is based on, if it's
16861686+ modified @internal
16871687+ */base,/**
16881688+ The modifiers applied to this.base @internal
16891689+ */modified){_classCallCheck(this,Tag);this.set=set;this.base=base;this.modified=modified;/**
16901690+ @internal
16911691+ */this.id=nextTagID++;}/**
16921692+ Define a new tag. If `parent` is given, the tag is treated as a
16931693+ sub-tag of that parent, and [highlight
16941694+ styles](https://codemirror.net/6/docs/ref/#highlight.HighlightStyle) that don't mention this tag
16951695+ will try to fall back to the parent tag (or grandparent tag,
16961696+ etc).
16971697+ */_createClass(Tag,null,[{key:"define",value:function define(parent){if(parent===null||parent===void 0?void 0:parent.base)throw new Error("Can not derive from a modified tag");var tag=new Tag([],null,[]);tag.set.push(tag);if(parent){var _iterator118=_createForOfIteratorHelper(parent.set),_step118;try{for(_iterator118.s();!(_step118=_iterator118.n()).done;){var _t2=_step118.value;tag.set.push(_t2);}}catch(err){_iterator118.e(err);}finally{_iterator118.f();}}return tag;}/**
16981698+ Define a tag _modifier_, which is a function that, given a tag,
16991699+ will return a tag that is a subtag of the original. Applying the
17001700+ same modifier to a twice tag will return the same value (`m1(t1)
17011701+ == m1(t1)`) and applying multiple modifiers will, regardless or
17021702+ order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
17031703+17041704+ When multiple modifiers are applied to a given base tag, each
17051705+ smaller set of modifiers is registered as a parent, so that for
17061706+ example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
17071707+ `m1(m3(t1)`, and so on.
17081708+ */},{key:"defineModifier",value:function defineModifier(){var mod=new Modifier();return function(tag){if(tag.modified.indexOf(mod)>-1)return tag;return Modifier.get(tag.base||tag,tag.modified.concat(mod).sort(function(a,b){return a.id-b.id;}));};}}]);return Tag;}();var nextModifierID=0;var Modifier=/*#__PURE__*/function(){function Modifier(){_classCallCheck(this,Modifier);this.instances=[];this.id=nextModifierID++;}_createClass(Modifier,null,[{key:"get",value:function get(base,mods){if(!mods.length)return base;var exists=mods[0].instances.find(function(t){return t.base==base&&sameArray(mods,t.modified);});if(exists)return exists;var set=[],tag=new Tag(set,base,mods);var _iterator119=_createForOfIteratorHelper(mods),_step119;try{for(_iterator119.s();!(_step119=_iterator119.n()).done;){var m=_step119.value;m.instances.push(tag);}}catch(err){_iterator119.e(err);}finally{_iterator119.f();}var configs=permute(mods);var _iterator120=_createForOfIteratorHelper(base.set),_step120;try{for(_iterator120.s();!(_step120=_iterator120.n()).done;){var parent=_step120.value;var _iterator121=_createForOfIteratorHelper(configs),_step121;try{for(_iterator121.s();!(_step121=_iterator121.n()).done;){var config=_step121.value;set.push(Modifier.get(parent,config));}}catch(err){_iterator121.e(err);}finally{_iterator121.f();}}}catch(err){_iterator120.e(err);}finally{_iterator120.f();}return tag;}}]);return Modifier;}();function sameArray(a,b){return a.length==b.length&&a.every(function(x,i){return x==b[i];});}function permute(array){var result=[array];for(var _i60=0;_i60<array.length;_i60++){var _iterator122=_createForOfIteratorHelper(permute(array.slice(0,_i60).concat(array.slice(_i60+1)))),_step122;try{for(_iterator122.s();!(_step122=_iterator122.n()).done;){var a=_step122.value;result.push(a);}}catch(err){_iterator122.e(err);}finally{_iterator122.f();}}return result;}/**
17091709+This function is used to add a set of tags to a language syntax
17101710+via
17111711+[`LRParser.configure`](https://lezer.codemirror.net/docs/ref#lr.LRParser.configure).
17121712+17131713+The argument object maps node selectors to [highlighting
17141714+tags](https://codemirror.net/6/docs/ref/#highlight.Tag) or arrays of tags.
17151715+17161716+Node selectors may hold one or more (space-separated) node paths.
17171717+Such a path can be a [node
17181718+name](https://lezer.codemirror.net/docs/ref#common.NodeType.name),
17191719+or multiple node names (or `*` wildcards) separated by slash
17201720+characters, as in `"Block/Declaration/VariableName"`. Such a path
17211721+matches the final node but only if its direct parent nodes are the
17221722+other nodes mentioned. A `*` in such a path matches any parent,
17231723+but only a single level—wildcards that match multiple parents
17241724+aren't supported, both for efficiency reasons and because Lezer
17251725+trees make it rather hard to reason about what they would match.)
17261726+17271727+A path can be ended with `/...` to indicate that the tag assigned
17281728+to the node should also apply to all child nodes, even if they
17291729+match their own style (by default, only the innermost style is
17301730+used).
17311731+17321732+When a path ends in `!`, as in `Attribute!`, no further matching
17331733+happens for the node's child nodes, and the entire node gets the
17341734+given style.
17351735+17361736+In this notation, node names that contain `/`, `!`, `*`, or `...`
17371737+must be quoted as JSON strings.
17381738+17391739+For example:
17401740+17411741+```javascript
17421742+parser.withProps(
17431743+ styleTags({
17441744+ // Style Number and BigNumber nodes
17451745+ "Number BigNumber": tags.number,
17461746+ // Style Escape nodes whose parent is String
17471747+ "String/Escape": tags.escape,
17481748+ // Style anything inside Attributes nodes
17491749+ "Attributes!": tags.meta,
17501750+ // Add a style to all content inside Italic nodes
17511751+ "Italic/...": tags.emphasis,
17521752+ // Style InvalidString nodes as both `string` and `invalid`
17531753+ "InvalidString": [tags.string, tags.invalid],
17541754+ // Style the node named "/" as punctuation
17551755+ '"/"': tags.punctuation
17561756+ })
17571757+)
17581758+```
17591759+*/function styleTags(spec){var byName=Object.create(null);for(var prop in spec){var _tags=spec[prop];if(!Array.isArray(_tags))_tags=[_tags];var _iterator123=_createForOfIteratorHelper(prop.split(" ")),_step123;try{for(_iterator123.s();!(_step123=_iterator123.n()).done;){var part=_step123.value;if(part){var pieces=[],mode=2/* Normal */,rest=part;for(var pos=0;;){if(rest=="..."&&pos>0&&pos+3==part.length){mode=1/* Inherit */;break;}var m=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);if(!m)throw new RangeError("Invalid path: "+part);pieces.push(m[0]=="*"?null:m[0][0]=='"'?JSON.parse(m[0]):m[0]);pos+=m[0].length;if(pos==part.length)break;var next=part[pos++];if(pos==part.length&&next=="!"){mode=0/* Opaque */;break;}if(next!="/")throw new RangeError("Invalid path: "+part);rest=part.slice(pos);}var last=pieces.length-1,inner=pieces[last];if(!inner)throw new RangeError("Invalid path: "+part);var rule=new Rule(_tags,mode,last>0?pieces.slice(0,last):null);byName[inner]=rule.sort(byName[inner]);}}}catch(err){_iterator123.e(err);}finally{_iterator123.f();}}return ruleNodeProp.add(byName);}var ruleNodeProp=new common.NodeProp();var highlightStyle=state.Facet.define({combine:function combine(stylings){return stylings.length?HighlightStyle.combinedMatch(stylings):null;}});var fallbackHighlightStyle=state.Facet.define({combine:function combine(values){return values.length?values[0].match:null;}});function getHighlightStyle(state){return state.facet(highlightStyle)||state.facet(fallbackHighlightStyle);}var Rule=/*#__PURE__*/function(){function Rule(tags,mode,context,next){_classCallCheck(this,Rule);this.tags=tags;this.mode=mode;this.context=context;this.next=next;}_createClass(Rule,[{key:"sort",value:function sort(other){if(!other||other.depth<this.depth){this.next=other;return this;}other.next=this.sort(other.next);return other;}},{key:"depth",get:function get(){return this.context?this.context.length:0;}}]);return Rule;}();/**
17601760+A highlight style associates CSS styles with higlighting
17611761+[tags](https://codemirror.net/6/docs/ref/#highlight.Tag).
17621762+*/var HighlightStyle=/*#__PURE__*/function(){function HighlightStyle(spec,options){_classCallCheck(this,HighlightStyle);this.map=Object.create(null);var modSpec;function def(spec){var cls=styleMod.StyleModule.newName();(modSpec||(modSpec=Object.create(null)))["."+cls]=spec;return cls;}this.all=typeof options.all=="string"?options.all:options.all?def(options.all):null;var _iterator124=_createForOfIteratorHelper(spec),_step124;try{for(_iterator124.s();!(_step124=_iterator124.n()).done;){var style=_step124.value;var cls=(style["class"]||def(Object.assign({},style,{tag:null})))+(this.all?" "+this.all:"");var _tags2=style.tag;if(!Array.isArray(_tags2))this.map[_tags2.id]=cls;else{var _iterator125=_createForOfIteratorHelper(_tags2),_step125;try{for(_iterator125.s();!(_step125=_iterator125.n()).done;){var tag=_step125.value;this.map[tag.id]=cls;}}catch(err){_iterator125.e(err);}finally{_iterator125.f();}}}}catch(err){_iterator124.e(err);}finally{_iterator124.f();}this.module=modSpec?new styleMod.StyleModule(modSpec):null;this.scope=options.scope||null;this.match=this.match.bind(this);var ext=[treeHighlighter];if(this.module)ext.push(view.EditorView.styleModule.of(this.module));this.extension=ext.concat(highlightStyle.of(this));this.fallback=ext.concat(fallbackHighlightStyle.of(this));}/**
17631763+ Returns the CSS class associated with the given tag, if any.
17641764+ This method is bound to the instance by the constructor.
17651765+ */_createClass(HighlightStyle,[{key:"match",value:function match(tag,scope){if(this.scope&&scope!=this.scope)return null;var _iterator126=_createForOfIteratorHelper(tag.set),_step126;try{for(_iterator126.s();!(_step126=_iterator126.n()).done;){var _t3=_step126.value;var match=this.map[_t3.id];if(match!==undefined){if(_t3!=tag)this.map[tag.id]=match;return match;}}}catch(err){_iterator126.e(err);}finally{_iterator126.f();}return this.map[tag.id]=this.all;}/**
17661766+ Combines an array of highlight styles into a single match
17671767+ function that returns all of the classes assigned by the styles
17681768+ for a given tag.
17691769+ */}],[{key:"combinedMatch",value:function combinedMatch(styles){if(styles.length==1)return styles[0].match;var cache=styles.some(function(s){return s.scope;})?undefined:Object.create(null);return function(tag,scope){var cached=cache&&cache[tag.id];if(cached!==undefined)return cached;var result=null;var _iterator127=_createForOfIteratorHelper(styles),_step127;try{for(_iterator127.s();!(_step127=_iterator127.n()).done;){var style=_step127.value;var value=style.match(tag,scope);if(value)result=result?result+" "+value:value;}}catch(err){_iterator127.e(err);}finally{_iterator127.f();}if(cache)cache[tag.id]=result;return result;};}/**
17701770+ Create a highlighter style that associates the given styles to
17711771+ the given tags. The spec must be objects that hold a style tag
17721772+ or array of tags in their `tag` property, and either a single
17731773+ `class` property providing a static CSS class (for highlighters
17741774+ like [`classHighlightStyle`](https://codemirror.net/6/docs/ref/#highlight.classHighlightStyle)
17751775+ that rely on external styling), or a
17761776+ [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
17771777+ set of CSS properties (which define the styling for those tags).
17781778+17791779+ The CSS rules created for a highlighter will be emitted in the
17801780+ order of the spec's properties. That means that for elements that
17811781+ have multiple tags associated with them, styles defined further
17821782+ down in the list will have a higher CSS precedence than styles
17831783+ defined earlier.
17841784+ */},{key:"define",value:function define(specs,options){return new HighlightStyle(specs,options||{});}/**
17851785+ Returns the CSS classes (if any) that the highlight styles
17861786+ active in the given state would assign to the given a style
17871787+ [tag](https://codemirror.net/6/docs/ref/#highlight.Tag) and (optional) language
17881788+ [scope](https://codemirror.net/6/docs/ref/#highlight.HighlightStyle^define^options.scope).
17891789+ */},{key:"get",value:function get(state,tag,scope){var style=getHighlightStyle(state);return style&&style(tag,scope||common.NodeType.none);}}]);return HighlightStyle;}();/**
17901790+Run the tree highlighter over the given tree.
17911791+*/function highlightTree(tree,/**
17921792+Get the CSS classes used to style a given [tag](https://codemirror.net/6/docs/ref/#highlight.Tag),
17931793+or `null` if it isn't styled. (You'll often want to pass a
17941794+highlight style's [`match`](https://codemirror.net/6/docs/ref/#highlight.HighlightStyle.match)
17951795+method here.)
17961796+*/getStyle,/**
17971797+Assign styling to a region of the text. Will be called, in order
17981798+of position, for any ranges where more than zero classes apply.
17991799+`classes` is a space separated string of CSS classes.
18001800+*/putStyle){var from=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;var to=arguments.length>4&&arguments[4]!==undefined?arguments[4]:tree.length;highlightTreeRange(tree,from,to,getStyle,putStyle);}var TreeHighlighter=/*#__PURE__*/function(){function TreeHighlighter(view){_classCallCheck(this,TreeHighlighter);this.markCache=Object.create(null);this.tree=language.syntaxTree(view.state);this.decorations=this.buildDeco(view,getHighlightStyle(view.state));}_createClass(TreeHighlighter,[{key:"update",value:function update(_update16){var tree=language.syntaxTree(_update16.state),style=getHighlightStyle(_update16.state);var styleChange=style!=_update16.startState.facet(highlightStyle);if(tree.length<_update16.view.viewport.to&&!styleChange&&tree.type==this.tree.type){this.decorations=this.decorations.map(_update16.changes);}else if(tree!=this.tree||_update16.viewportChanged||styleChange){this.tree=tree;this.decorations=this.buildDeco(_update16.view,style);}}},{key:"buildDeco",value:function buildDeco(view$1,match){var _this63=this;if(!match||!this.tree.length)return view.Decoration.none;var builder=new rangeset.RangeSetBuilder();var _iterator128=_createForOfIteratorHelper(view$1.visibleRanges),_step128;try{for(_iterator128.s();!(_step128=_iterator128.n()).done;){var _step128$value=_step128.value,from=_step128$value.from,to=_step128$value.to;highlightTreeRange(this.tree,from,to,match,function(from,to,style){builder.add(from,to,_this63.markCache[style]||(_this63.markCache[style]=view.Decoration.mark({"class":style})));});}}catch(err){_iterator128.e(err);}finally{_iterator128.f();}return builder.finish();}}]);return TreeHighlighter;}();// This extension installs a highlighter that highlights based on the
18011801+// syntax tree and highlight style.
18021802+var treeHighlighter=state.Prec.high(view.ViewPlugin.fromClass(TreeHighlighter,{decorations:function decorations(v){return v.decorations;}}));var nodeStack=[""];var HighlightBuilder=/*#__PURE__*/function(){function HighlightBuilder(at,style,span){_classCallCheck(this,HighlightBuilder);this.at=at;this.style=style;this.span=span;this["class"]="";}_createClass(HighlightBuilder,[{key:"startSpan",value:function startSpan(at,cls){if(cls!=this["class"]){this.flush(at);if(at>this.at)this.at=at;this["class"]=cls;}}},{key:"flush",value:function flush(to){if(to>this.at&&this["class"])this.span(this.at,to,this["class"]);}},{key:"highlightRange",value:function highlightRange(cursor,from,to,inheritedClass,depth,scope){var type=cursor.type,start=cursor.from,end=cursor.to;if(start>=to||end<=from)return;nodeStack[depth]=type.name;if(type.isTop)scope=type;var cls=inheritedClass;var rule=type.prop(ruleNodeProp),opaque=false;while(rule){if(!rule.context||matchContext(rule.context,nodeStack,depth)){var _iterator129=_createForOfIteratorHelper(rule.tags),_step129;try{for(_iterator129.s();!(_step129=_iterator129.n()).done;){var tag=_step129.value;var st=this.style(tag,scope);if(st){if(cls)cls+=" ";cls+=st;if(rule.mode==1/* Inherit */)inheritedClass+=(inheritedClass?" ":"")+st;else if(rule.mode==0/* Opaque */)opaque=true;}}}catch(err){_iterator129.e(err);}finally{_iterator129.f();}break;}rule=rule.next;}this.startSpan(cursor.from,cls);if(opaque)return;var mounted=cursor.tree&&cursor.tree.prop(common.NodeProp.mounted);if(mounted&&mounted.overlay){var inner=cursor.node.enter(mounted.overlay[0].from+start,1);var hasChild=cursor.firstChild();for(var _i61=0,pos=start;;_i61++){var next=_i61<mounted.overlay.length?mounted.overlay[_i61]:null;var nextPos=next?next.from+start:end;var rangeFrom=Math.max(from,pos),rangeTo=Math.min(to,nextPos);if(rangeFrom<rangeTo&&hasChild){while(cursor.from<rangeTo){this.highlightRange(cursor,rangeFrom,rangeTo,inheritedClass,depth+1,scope);this.startSpan(Math.min(to,cursor.to),cls);if(cursor.to>=nextPos||!cursor.nextSibling())break;}}if(!next||nextPos>to)break;pos=next.to+start;if(pos>from){this.highlightRange(inner.cursor,Math.max(from,next.from+start),Math.min(to,pos),inheritedClass,depth,mounted.tree.type);this.startSpan(pos,cls);}}if(hasChild)cursor.parent();}else if(cursor.firstChild()){do{if(cursor.to<=from)continue;if(cursor.from>=to)break;this.highlightRange(cursor,from,to,inheritedClass,depth+1,scope);this.startSpan(Math.min(to,cursor.to),cls);}while(cursor.nextSibling());cursor.parent();}}}]);return HighlightBuilder;}();function highlightTreeRange(tree,from,to,style,span){var builder=new HighlightBuilder(from,style,span);builder.highlightRange(tree.cursor(),from,to,"",0,tree.type);builder.flush(to);}function matchContext(context,stack,depth){if(context.length>depth-1)return false;for(var d=depth-1,_i62=context.length-1;_i62>=0;_i62--,d--){var check=context[_i62];if(check&&check!=stack[d])return false;}return true;}var t=Tag.define;var comment=t(),name=t(),typeName=t(name),propertyName=t(name),literal=t(),string=t(literal),number=t(literal),content=t(),heading=t(content),keyword=t(),operator=t(),punctuation=t(),bracket=t(punctuation),meta=t();/**
18031803+The default set of highlighting [tags](https://codemirror.net/6/docs/ref/#highlight.Tag^define) used
18041804+by regular language packages and themes.
18051805+18061806+This collection is heavily biased towards programming languages,
18071807+and necessarily incomplete. A full ontology of syntactic
18081808+constructs would fill a stack of books, and be impractical to
18091809+write themes for. So try to make do with this set. If all else
18101810+fails, [open an
18111811+issue](https://github.com/codemirror/codemirror.next) to propose a
18121812+new tag, or [define](https://codemirror.net/6/docs/ref/#highlight.Tag^define) a local custom tag for
18131813+your use case.
18141814+18151815+Note that it is not obligatory to always attach the most specific
18161816+tag possible to an element—if your grammar can't easily
18171817+distinguish a certain type of element (such as a local variable),
18181818+it is okay to style it as its more general variant (a variable).
18191819+18201820+For tags that extend some parent tag, the documentation links to
18211821+the parent.
18221822+*/var tags={/**
18231823+ A comment.
18241824+ */comment:comment,/**
18251825+ A line [comment](https://codemirror.net/6/docs/ref/#highlight.tags.comment).
18261826+ */lineComment:t(comment),/**
18271827+ A block [comment](https://codemirror.net/6/docs/ref/#highlight.tags.comment).
18281828+ */blockComment:t(comment),/**
18291829+ A documentation [comment](https://codemirror.net/6/docs/ref/#highlight.tags.comment).
18301830+ */docComment:t(comment),/**
18311831+ Any kind of identifier.
18321832+ */name:name,/**
18331833+ The [name](https://codemirror.net/6/docs/ref/#highlight.tags.name) of a variable.
18341834+ */variableName:t(name),/**
18351835+ A type [name](https://codemirror.net/6/docs/ref/#highlight.tags.name).
18361836+ */typeName:typeName,/**
18371837+ A tag name (subtag of [`typeName`](https://codemirror.net/6/docs/ref/#highlight.tags.typeName)).
18381838+ */tagName:t(typeName),/**
18391839+ A property or field [name](https://codemirror.net/6/docs/ref/#highlight.tags.name).
18401840+ */propertyName:propertyName,/**
18411841+ An attribute name (subtag of [`propertyName`](https://codemirror.net/6/docs/ref/#highlight.tags.propertyName)).
18421842+ */attributeName:t(propertyName),/**
18431843+ The [name](https://codemirror.net/6/docs/ref/#highlight.tags.name) of a class.
18441844+ */className:t(name),/**
18451845+ A label [name](https://codemirror.net/6/docs/ref/#highlight.tags.name).
18461846+ */labelName:t(name),/**
18471847+ A namespace [name](https://codemirror.net/6/docs/ref/#highlight.tags.name).
18481848+ */namespace:t(name),/**
18491849+ The [name](https://codemirror.net/6/docs/ref/#highlight.tags.name) of a macro.
18501850+ */macroName:t(name),/**
18511851+ A literal value.
18521852+ */literal:literal,/**
18531853+ A string [literal](https://codemirror.net/6/docs/ref/#highlight.tags.literal).
18541854+ */string:string,/**
18551855+ A documentation [string](https://codemirror.net/6/docs/ref/#highlight.tags.string).
18561856+ */docString:t(string),/**
18571857+ A character literal (subtag of [string](https://codemirror.net/6/docs/ref/#highlight.tags.string)).
18581858+ */character:t(string),/**
18591859+ An attribute value (subtag of [string](https://codemirror.net/6/docs/ref/#highlight.tags.string)).
18601860+ */attributeValue:t(string),/**
18611861+ A number [literal](https://codemirror.net/6/docs/ref/#highlight.tags.literal).
18621862+ */number:number,/**
18631863+ An integer [number](https://codemirror.net/6/docs/ref/#highlight.tags.number) literal.
18641864+ */integer:t(number),/**
18651865+ A floating-point [number](https://codemirror.net/6/docs/ref/#highlight.tags.number) literal.
18661866+ */"float":t(number),/**
18671867+ A boolean [literal](https://codemirror.net/6/docs/ref/#highlight.tags.literal).
18681868+ */bool:t(literal),/**
18691869+ Regular expression [literal](https://codemirror.net/6/docs/ref/#highlight.tags.literal).
18701870+ */regexp:t(literal),/**
18711871+ An escape [literal](https://codemirror.net/6/docs/ref/#highlight.tags.literal), for example a
18721872+ backslash escape in a string.
18731873+ */escape:t(literal),/**
18741874+ A color [literal](https://codemirror.net/6/docs/ref/#highlight.tags.literal).
18751875+ */color:t(literal),/**
18761876+ A URL [literal](https://codemirror.net/6/docs/ref/#highlight.tags.literal).
18771877+ */url:t(literal),/**
18781878+ A language keyword.
18791879+ */keyword:keyword,/**
18801880+ The [keyword](https://codemirror.net/6/docs/ref/#highlight.tags.keyword) for the self or this
18811881+ object.
18821882+ */self:t(keyword),/**
18831883+ The [keyword](https://codemirror.net/6/docs/ref/#highlight.tags.keyword) for null.
18841884+ */"null":t(keyword),/**
18851885+ A [keyword](https://codemirror.net/6/docs/ref/#highlight.tags.keyword) denoting some atomic value.
18861886+ */atom:t(keyword),/**
18871887+ A [keyword](https://codemirror.net/6/docs/ref/#highlight.tags.keyword) that represents a unit.
18881888+ */unit:t(keyword),/**
18891889+ A modifier [keyword](https://codemirror.net/6/docs/ref/#highlight.tags.keyword).
18901890+ */modifier:t(keyword),/**
18911891+ A [keyword](https://codemirror.net/6/docs/ref/#highlight.tags.keyword) that acts as an operator.
18921892+ */operatorKeyword:t(keyword),/**
18931893+ A control-flow related [keyword](https://codemirror.net/6/docs/ref/#highlight.tags.keyword).
18941894+ */controlKeyword:t(keyword),/**
18951895+ A [keyword](https://codemirror.net/6/docs/ref/#highlight.tags.keyword) that defines something.
18961896+ */definitionKeyword:t(keyword),/**
18971897+ A [keyword](https://codemirror.net/6/docs/ref/#highlight.tags.keyword) related to defining or
18981898+ interfacing with modules.
18991899+ */moduleKeyword:t(keyword),/**
19001900+ An operator.
19011901+ */operator:operator,/**
19021902+ An [operator](https://codemirror.net/6/docs/ref/#highlight.tags.operator) that defines something.
19031903+ */derefOperator:t(operator),/**
19041904+ Arithmetic-related [operator](https://codemirror.net/6/docs/ref/#highlight.tags.operator).
19051905+ */arithmeticOperator:t(operator),/**
19061906+ Logical [operator](https://codemirror.net/6/docs/ref/#highlight.tags.operator).
19071907+ */logicOperator:t(operator),/**
19081908+ Bit [operator](https://codemirror.net/6/docs/ref/#highlight.tags.operator).
19091909+ */bitwiseOperator:t(operator),/**
19101910+ Comparison [operator](https://codemirror.net/6/docs/ref/#highlight.tags.operator).
19111911+ */compareOperator:t(operator),/**
19121912+ [Operator](https://codemirror.net/6/docs/ref/#highlight.tags.operator) that updates its operand.
19131913+ */updateOperator:t(operator),/**
19141914+ [Operator](https://codemirror.net/6/docs/ref/#highlight.tags.operator) that defines something.
19151915+ */definitionOperator:t(operator),/**
19161916+ Type-related [operator](https://codemirror.net/6/docs/ref/#highlight.tags.operator).
19171917+ */typeOperator:t(operator),/**
19181918+ Control-flow [operator](https://codemirror.net/6/docs/ref/#highlight.tags.operator).
19191919+ */controlOperator:t(operator),/**
19201920+ Program or markup punctuation.
19211921+ */punctuation:punctuation,/**
19221922+ [Punctuation](https://codemirror.net/6/docs/ref/#highlight.tags.punctuation) that separates
19231923+ things.
19241924+ */separator:t(punctuation),/**
19251925+ Bracket-style [punctuation](https://codemirror.net/6/docs/ref/#highlight.tags.punctuation).
19261926+ */bracket:bracket,/**
19271927+ Angle [brackets](https://codemirror.net/6/docs/ref/#highlight.tags.bracket) (usually `<` and `>`
19281928+ tokens).
19291929+ */angleBracket:t(bracket),/**
19301930+ Square [brackets](https://codemirror.net/6/docs/ref/#highlight.tags.bracket) (usually `[` and `]`
19311931+ tokens).
19321932+ */squareBracket:t(bracket),/**
19331933+ Parentheses (usually `(` and `)` tokens). Subtag of
19341934+ [bracket](https://codemirror.net/6/docs/ref/#highlight.tags.bracket).
19351935+ */paren:t(bracket),/**
19361936+ Braces (usually `{` and `}` tokens). Subtag of
19371937+ [bracket](https://codemirror.net/6/docs/ref/#highlight.tags.bracket).
19381938+ */brace:t(bracket),/**
19391939+ Content, for example plain text in XML or markup documents.
19401940+ */content:content,/**
19411941+ [Content](https://codemirror.net/6/docs/ref/#highlight.tags.content) that represents a heading.
19421942+ */heading:heading,/**
19431943+ A level 1 [heading](https://codemirror.net/6/docs/ref/#highlight.tags.heading).
19441944+ */heading1:t(heading),/**
19451945+ A level 2 [heading](https://codemirror.net/6/docs/ref/#highlight.tags.heading).
19461946+ */heading2:t(heading),/**
19471947+ A level 3 [heading](https://codemirror.net/6/docs/ref/#highlight.tags.heading).
19481948+ */heading3:t(heading),/**
19491949+ A level 4 [heading](https://codemirror.net/6/docs/ref/#highlight.tags.heading).
19501950+ */heading4:t(heading),/**
19511951+ A level 5 [heading](https://codemirror.net/6/docs/ref/#highlight.tags.heading).
19521952+ */heading5:t(heading),/**
19531953+ A level 6 [heading](https://codemirror.net/6/docs/ref/#highlight.tags.heading).
19541954+ */heading6:t(heading),/**
19551955+ A prose separator (such as a horizontal rule).
19561956+ */contentSeparator:t(content),/**
19571957+ [Content](https://codemirror.net/6/docs/ref/#highlight.tags.content) that represents a list.
19581958+ */list:t(content),/**
19591959+ [Content](https://codemirror.net/6/docs/ref/#highlight.tags.content) that represents a quote.
19601960+ */quote:t(content),/**
19611961+ [Content](https://codemirror.net/6/docs/ref/#highlight.tags.content) that is emphasized.
19621962+ */emphasis:t(content),/**
19631963+ [Content](https://codemirror.net/6/docs/ref/#highlight.tags.content) that is styled strong.
19641964+ */strong:t(content),/**
19651965+ [Content](https://codemirror.net/6/docs/ref/#highlight.tags.content) that is part of a link.
19661966+ */link:t(content),/**
19671967+ [Content](https://codemirror.net/6/docs/ref/#highlight.tags.content) that is styled as code or
19681968+ monospace.
19691969+ */monospace:t(content),/**
19701970+ [Content](https://codemirror.net/6/docs/ref/#highlight.tags.content) that has a strike-through
19711971+ style.
19721972+ */strikethrough:t(content),/**
19731973+ Inserted text in a change-tracking format.
19741974+ */inserted:t(),/**
19751975+ Deleted text.
19761976+ */deleted:t(),/**
19771977+ Changed text.
19781978+ */changed:t(),/**
19791979+ An invalid or unsyntactic element.
19801980+ */invalid:t(),/**
19811981+ Metadata or meta-instruction.
19821982+ */meta:meta,/**
19831983+ [Metadata](https://codemirror.net/6/docs/ref/#highlight.tags.meta) that applies to the entire
19841984+ document.
19851985+ */documentMeta:t(meta),/**
19861986+ [Metadata](https://codemirror.net/6/docs/ref/#highlight.tags.meta) that annotates or adds
19871987+ attributes to a given syntactic element.
19881988+ */annotation:t(meta),/**
19891989+ Processing instruction or preprocessor directive. Subtag of
19901990+ [meta](https://codemirror.net/6/docs/ref/#highlight.tags.meta).
19911991+ */processingInstruction:t(meta),/**
19921992+ [Modifier](https://codemirror.net/6/docs/ref/#highlight.Tag^defineModifier) that indicates that a
19931993+ given element is being defined. Expected to be used with the
19941994+ various [name](https://codemirror.net/6/docs/ref/#highlight.tags.name) tags.
19951995+ */definition:Tag.defineModifier(),/**
19961996+ [Modifier](https://codemirror.net/6/docs/ref/#highlight.Tag^defineModifier) that indicates that
19971997+ something is constant. Mostly expected to be used with
19981998+ [variable names](https://codemirror.net/6/docs/ref/#highlight.tags.variableName).
19991999+ */constant:Tag.defineModifier(),/**
20002000+ [Modifier](https://codemirror.net/6/docs/ref/#highlight.Tag^defineModifier) used to indicate that
20012001+ a [variable](https://codemirror.net/6/docs/ref/#highlight.tags.variableName) or [property
20022002+ name](https://codemirror.net/6/docs/ref/#highlight.tags.propertyName) is being called or defined
20032003+ as a function.
20042004+ */"function":Tag.defineModifier(),/**
20052005+ [Modifier](https://codemirror.net/6/docs/ref/#highlight.Tag^defineModifier) that can be applied to
20062006+ [names](https://codemirror.net/6/docs/ref/#highlight.tags.name) to indicate that they belong to
20072007+ the language's standard environment.
20082008+ */standard:Tag.defineModifier(),/**
20092009+ [Modifier](https://codemirror.net/6/docs/ref/#highlight.Tag^defineModifier) that indicates a given
20102010+ [names](https://codemirror.net/6/docs/ref/#highlight.tags.name) is local to some scope.
20112011+ */local:Tag.defineModifier(),/**
20122012+ A generic variant [modifier](https://codemirror.net/6/docs/ref/#highlight.Tag^defineModifier) that
20132013+ can be used to tag language-specific alternative variants of
20142014+ some common tag. It is recommended for themes to define special
20152015+ forms of at least the [string](https://codemirror.net/6/docs/ref/#highlight.tags.string) and
20162016+ [variable name](https://codemirror.net/6/docs/ref/#highlight.tags.variableName) tags, since those
20172017+ come up a lot.
20182018+ */special:Tag.defineModifier()};/**
20192019+A default highlight style (works well with light themes).
20202020+*/var defaultHighlightStyle=HighlightStyle.define([{tag:tags.link,textDecoration:"underline"},{tag:tags.heading,textDecoration:"underline",fontWeight:"bold"},{tag:tags.emphasis,fontStyle:"italic"},{tag:tags.strong,fontWeight:"bold"},{tag:tags.strikethrough,textDecoration:"line-through"},{tag:tags.keyword,color:"#708"},{tag:[tags.atom,tags.bool,tags.url,tags.contentSeparator,tags.labelName],color:"#219"},{tag:[tags.literal,tags.inserted],color:"#164"},{tag:[tags.string,tags.deleted],color:"#a11"},{tag:[tags.regexp,tags.escape,tags.special(tags.string)],color:"#e40"},{tag:tags.definition(tags.variableName),color:"#00f"},{tag:tags.local(tags.variableName),color:"#30a"},{tag:[tags.typeName,tags.namespace],color:"#085"},{tag:tags.className,color:"#167"},{tag:[tags.special(tags.variableName),tags.macroName],color:"#256"},{tag:tags.definition(tags.propertyName),color:"#00c"},{tag:tags.comment,color:"#940"},{tag:tags.meta,color:"#7a757a"},{tag:tags.invalid,color:"#f00"}]);/**
20212021+This is a highlight style that adds stable, predictable classes to
20222022+tokens, for styling with external CSS.
20232023+20242024+These tags are mapped to their name prefixed with `"cmt-"` (for
20252025+example `"cmt-comment"`):
20262026+20272027+* [`link`](https://codemirror.net/6/docs/ref/#highlight.tags.link)
20282028+* [`heading`](https://codemirror.net/6/docs/ref/#highlight.tags.heading)
20292029+* [`emphasis`](https://codemirror.net/6/docs/ref/#highlight.tags.emphasis)
20302030+* [`strong`](https://codemirror.net/6/docs/ref/#highlight.tags.strong)
20312031+* [`keyword`](https://codemirror.net/6/docs/ref/#highlight.tags.keyword)
20322032+* [`atom`](https://codemirror.net/6/docs/ref/#highlight.tags.atom) [`bool`](https://codemirror.net/6/docs/ref/#highlight.tags.bool)
20332033+* [`url`](https://codemirror.net/6/docs/ref/#highlight.tags.url)
20342034+* [`labelName`](https://codemirror.net/6/docs/ref/#highlight.tags.labelName)
20352035+* [`inserted`](https://codemirror.net/6/docs/ref/#highlight.tags.inserted)
20362036+* [`deleted`](https://codemirror.net/6/docs/ref/#highlight.tags.deleted)
20372037+* [`literal`](https://codemirror.net/6/docs/ref/#highlight.tags.literal)
20382038+* [`string`](https://codemirror.net/6/docs/ref/#highlight.tags.string)
20392039+* [`number`](https://codemirror.net/6/docs/ref/#highlight.tags.number)
20402040+* [`variableName`](https://codemirror.net/6/docs/ref/#highlight.tags.variableName)
20412041+* [`typeName`](https://codemirror.net/6/docs/ref/#highlight.tags.typeName)
20422042+* [`namespace`](https://codemirror.net/6/docs/ref/#highlight.tags.namespace)
20432043+* [`className`](https://codemirror.net/6/docs/ref/#highlight.tags.className)
20442044+* [`macroName`](https://codemirror.net/6/docs/ref/#highlight.tags.macroName)
20452045+* [`propertyName`](https://codemirror.net/6/docs/ref/#highlight.tags.propertyName)
20462046+* [`operator`](https://codemirror.net/6/docs/ref/#highlight.tags.operator)
20472047+* [`comment`](https://codemirror.net/6/docs/ref/#highlight.tags.comment)
20482048+* [`meta`](https://codemirror.net/6/docs/ref/#highlight.tags.meta)
20492049+* [`punctuation`](https://codemirror.net/6/docs/ref/#highlight.tags.puncutation)
20502050+* [`invalid`](https://codemirror.net/6/docs/ref/#highlight.tags.invalid)
20512051+20522052+In addition, these mappings are provided:
20532053+20542054+* [`regexp`](https://codemirror.net/6/docs/ref/#highlight.tags.regexp),
20552055+ [`escape`](https://codemirror.net/6/docs/ref/#highlight.tags.escape), and
20562056+ [`special`](https://codemirror.net/6/docs/ref/#highlight.tags.special)[`(string)`](https://codemirror.net/6/docs/ref/#highlight.tags.string)
20572057+ are mapped to `"cmt-string2"`
20582058+* [`special`](https://codemirror.net/6/docs/ref/#highlight.tags.special)[`(variableName)`](https://codemirror.net/6/docs/ref/#highlight.tags.variableName)
20592059+ to `"cmt-variableName2"`
20602060+* [`local`](https://codemirror.net/6/docs/ref/#highlight.tags.local)[`(variableName)`](https://codemirror.net/6/docs/ref/#highlight.tags.variableName)
20612061+ to `"cmt-variableName cmt-local"`
20622062+* [`definition`](https://codemirror.net/6/docs/ref/#highlight.tags.definition)[`(variableName)`](https://codemirror.net/6/docs/ref/#highlight.tags.variableName)
20632063+ to `"cmt-variableName cmt-definition"`
20642064+* [`definition`](https://codemirror.net/6/docs/ref/#highlight.tags.definition)[`(propertyName)`](https://codemirror.net/6/docs/ref/#highlight.tags.propertyName)
20652065+ to `"cmt-propertyName cmt-definition"`
20662066+*/var classHighlightStyle=HighlightStyle.define([{tag:tags.link,"class":"cmt-link"},{tag:tags.heading,"class":"cmt-heading"},{tag:tags.emphasis,"class":"cmt-emphasis"},{tag:tags.strong,"class":"cmt-strong"},{tag:tags.keyword,"class":"cmt-keyword"},{tag:tags.atom,"class":"cmt-atom"},{tag:tags.bool,"class":"cmt-bool"},{tag:tags.url,"class":"cmt-url"},{tag:tags.labelName,"class":"cmt-labelName"},{tag:tags.inserted,"class":"cmt-inserted"},{tag:tags.deleted,"class":"cmt-deleted"},{tag:tags.literal,"class":"cmt-literal"},{tag:tags.string,"class":"cmt-string"},{tag:tags.number,"class":"cmt-number"},{tag:[tags.regexp,tags.escape,tags.special(tags.string)],"class":"cmt-string2"},{tag:tags.variableName,"class":"cmt-variableName"},{tag:tags.local(tags.variableName),"class":"cmt-variableName cmt-local"},{tag:tags.definition(tags.variableName),"class":"cmt-variableName cmt-definition"},{tag:tags.special(tags.variableName),"class":"cmt-variableName2"},{tag:tags.definition(tags.propertyName),"class":"cmt-propertyName cmt-definition"},{tag:tags.typeName,"class":"cmt-typeName"},{tag:tags.namespace,"class":"cmt-namespace"},{tag:tags.className,"class":"cmt-className"},{tag:tags.macroName,"class":"cmt-macroName"},{tag:tags.propertyName,"class":"cmt-propertyName"},{tag:tags.operator,"class":"cmt-operator"},{tag:tags.comment,"class":"cmt-comment"},{tag:tags.meta,"class":"cmt-meta"},{tag:tags.invalid,"class":"cmt-invalid"},{tag:tags.punctuation,"class":"cmt-punctuation"}]);exports.HighlightStyle=HighlightStyle;exports.Tag=Tag;exports.classHighlightStyle=classHighlightStyle;exports.defaultHighlightStyle=defaultHighlightStyle;exports.highlightTree=highlightTree;exports.styleTags=styleTags;exports.tags=tags;},{"@codemirror/language":13,"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/view":27,"@lezer/common":28,"style-mod":30}],12:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var state=require('@codemirror/state');var view=require('@codemirror/view');var fromHistory=state.Annotation.define();/**
20672067+Transaction annotation that will prevent that transaction from
20682068+being combined with other transactions in the undo history. Given
20692069+`"before"`, it'll prevent merging with previous transactions. With
20702070+`"after"`, subsequent transactions won't be combined with this
20712071+one. With `"full"`, the transaction is isolated on both sides.
20722072+*/var isolateHistory=state.Annotation.define();/**
20732073+This facet provides a way to register functions that, given a
20742074+transaction, provide a set of effects that the history should
20752075+store when inverting the transaction. This can be used to
20762076+integrate some kinds of effects in the history, so that they can
20772077+be undone (and redone again).
20782078+*/var invertedEffects=state.Facet.define();var historyConfig=state.Facet.define({combine:function combine(configs){return state.combineConfig(configs,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min});}});function changeEnd(changes){var end=0;changes.iterChangedRanges(function(_,to){return end=to;});return end;}var historyField_=state.StateField.define({create:function create(){return HistoryState.empty;},update:function update(state$1,tr){var config=tr.state.facet(historyConfig);var fromHist=tr.annotation(fromHistory);if(fromHist){var selection=tr.docChanged?state.EditorSelection.single(changeEnd(tr.changes)):undefined;var item=HistEvent.fromTransaction(tr,selection),from=fromHist.side;var other=from==0/* Done */?state$1.undone:state$1.done;if(item)other=updateBranch(other,other.length,config.minDepth,item);else other=_addSelection(other,tr.startState.selection);return new HistoryState(from==0/* Done */?fromHist.rest:other,from==0/* Done */?other:fromHist.rest);}var isolate=tr.annotation(isolateHistory);if(isolate=="full"||isolate=="before")state$1=state$1.isolate();if(tr.annotation(state.Transaction.addToHistory)===false)return!tr.changes.empty?state$1.addMapping(tr.changes.desc):state$1;var event=HistEvent.fromTransaction(tr);var time=tr.annotation(state.Transaction.time),userEvent=tr.annotation(state.Transaction.userEvent);if(event)state$1=state$1.addChanges(event,time,userEvent,config.newGroupDelay,config.minDepth);else if(tr.selection)state$1=state$1.addSelection(tr.startState.selection,time,userEvent,config.newGroupDelay);if(isolate=="full"||isolate=="after")state$1=state$1.isolate();return state$1;},toJSON:function toJSON(value){return{done:value.done.map(function(e){return e.toJSON();}),undone:value.undone.map(function(e){return e.toJSON();})};},fromJSON:function fromJSON(json){return new HistoryState(json.done.map(HistEvent.fromJSON),json.undone.map(HistEvent.fromJSON));}});/**
20792079+Create a history extension with the given configuration.
20802080+*/function history(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return[historyField_,historyConfig.of(config),view.EditorView.domEventHandlers({beforeinput:function beforeinput(e,view){var command=e.inputType=="historyUndo"?undo:e.inputType=="historyRedo"?redo:null;if(!command)return false;e.preventDefault();return command(view);}})];}/**
20812081+The state field used to store the history data. Should probably
20822082+only be used when you want to
20832083+[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or
20842084+[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way
20852085+that preserves history.
20862086+*/var historyField=historyField_;function cmd(side,selection){return function(_ref50){var state=_ref50.state,dispatch=_ref50.dispatch;if(!selection&&state.readOnly)return false;var historyState=state.field(historyField_,false);if(!historyState)return false;var tr=historyState.pop(side,state,selection);if(!tr)return false;dispatch(tr);return true;};}/**
20872087+Undo a single group of history events. Returns false if no group
20882088+was available.
20892089+*/var undo=cmd(0/* Done */,false);/**
20902090+Redo a group of history events. Returns false if no group was
20912091+available.
20922092+*/var redo=cmd(1/* Undone */,false);/**
20932093+Undo a selection change.
20942094+*/var undoSelection=cmd(0/* Done */,true);/**
20952095+Redo a selection change.
20962096+*/var redoSelection=cmd(1/* Undone */,true);function depth(side){return function(state){var histState=state.field(historyField_,false);if(!histState)return 0;var branch=side==0/* Done */?histState.done:histState.undone;return branch.length-(branch.length&&!branch[0].changes?1:0);};}/**
20972097+The amount of undoable change events available in a given state.
20982098+*/var undoDepth=depth(0/* Done */);/**
20992099+The amount of redoable change events available in a given state.
21002100+*/var redoDepth=depth(1/* Undone */);// History events store groups of changes or effects that need to be
21012101+// undone/redone together.
21022102+var HistEvent=/*#__PURE__*/function(){function HistEvent(// The changes in this event. Normal events hold at least one
21032103+// change or effect. But it may be necessary to store selection
21042104+// events before the first change, in which case a special type of
21052105+// instance is created which doesn't hold any changes, with
21062106+// changes == startSelection == undefined
21072107+changes,// The effects associated with this event
21082108+effects,mapped,// The selection before this event
21092109+startSelection,// Stores selection changes after this event, to be used for
21102110+// selection undo/redo.
21112111+selectionsAfter){_classCallCheck(this,HistEvent);this.changes=changes;this.effects=effects;this.mapped=mapped;this.startSelection=startSelection;this.selectionsAfter=selectionsAfter;}_createClass(HistEvent,[{key:"setSelAfter",value:function setSelAfter(after){return new HistEvent(this.changes,this.effects,this.mapped,this.startSelection,after);}},{key:"toJSON",value:function toJSON(){var _a,_b,_c;return{changes:(_a=this.changes)===null||_a===void 0?void 0:_a.toJSON(),mapped:(_b=this.mapped)===null||_b===void 0?void 0:_b.toJSON(),startSelection:(_c=this.startSelection)===null||_c===void 0?void 0:_c.toJSON(),selectionsAfter:this.selectionsAfter.map(function(s){return s.toJSON();})};}}],[{key:"fromJSON",value:function fromJSON(json){return new HistEvent(json.changes&&state.ChangeSet.fromJSON(json.changes),[],json.mapped&&state.ChangeDesc.fromJSON(json.mapped),json.startSelection&&state.EditorSelection.fromJSON(json.startSelection),json.selectionsAfter.map(state.EditorSelection.fromJSON));}// This does not check `addToHistory` and such, it assumes the
21122112+// transaction needs to be converted to an item. Returns null when
21132113+// there are no changes or effects in the transaction.
21142114+},{key:"fromTransaction",value:function fromTransaction(tr,selection){var effects=none;var _iterator130=_createForOfIteratorHelper(tr.startState.facet(invertedEffects)),_step130;try{for(_iterator130.s();!(_step130=_iterator130.n()).done;){var invert=_step130.value;var result=invert(tr);if(result.length)effects=effects.concat(result);}}catch(err){_iterator130.e(err);}finally{_iterator130.f();}if(!effects.length&&tr.changes.empty)return null;return new HistEvent(tr.changes.invert(tr.startState.doc),effects,undefined,selection||tr.startState.selection,none);}},{key:"selection",value:function selection(selections){return new HistEvent(undefined,none,undefined,undefined,selections);}}]);return HistEvent;}();function updateBranch(branch,to,maxLen,newEvent){var start=to+1>maxLen+20?to-maxLen-1:0;var newBranch=branch.slice(start,to);newBranch.push(newEvent);return newBranch;}function isAdjacent(a,b){var ranges=[],isAdjacent=false;a.iterChangedRanges(function(f,t){return ranges.push(f,t);});b.iterChangedRanges(function(_f,_t,f,t){for(var _i63=0;_i63<ranges.length;){var from=ranges[_i63++],to=ranges[_i63++];if(t>=from&&f<=to)isAdjacent=true;}});return isAdjacent;}function eqSelectionShape(a,b){return a.ranges.length==b.ranges.length&&a.ranges.filter(function(r,i){return r.empty!=b.ranges[i].empty;}).length===0;}function conc(a,b){return!a.length?b:!b.length?a:a.concat(b);}var none=[];var MaxSelectionsPerEvent=200;function _addSelection(branch,selection){if(!branch.length){return[HistEvent.selection([selection])];}else{var lastEvent=branch[branch.length-1];var sels=lastEvent.selectionsAfter.slice(Math.max(0,lastEvent.selectionsAfter.length-MaxSelectionsPerEvent));if(sels.length&&sels[sels.length-1].eq(selection))return branch;sels.push(selection);return updateBranch(branch,branch.length-1,1e9,lastEvent.setSelAfter(sels));}}// Assumes the top item has one or more selectionAfter values
21152115+function popSelection(branch){var last=branch[branch.length-1];var newBranch=branch.slice();newBranch[branch.length-1]=last.setSelAfter(last.selectionsAfter.slice(0,last.selectionsAfter.length-1));return newBranch;}// Add a mapping to the top event in the given branch. If this maps
21162116+// away all the changes and effects in that item, drop it and
21172117+// propagate the mapping to the next item.
21182118+function addMappingToBranch(branch,mapping){if(!branch.length)return branch;var length=branch.length,selections=none;while(length){var event=mapEvent(branch[length-1],mapping,selections);if(event.changes&&!event.changes.empty||event.effects.length){// Event survived mapping
21192119+var result=branch.slice(0,length);result[length-1]=event;return result;}else{// Drop this event, since there's no changes or effects left
21202120+mapping=event.mapped;length--;selections=event.selectionsAfter;}}return selections.length?[HistEvent.selection(selections)]:none;}function mapEvent(event,mapping,extraSelections){var selections=conc(event.selectionsAfter.length?event.selectionsAfter.map(function(s){return s.map(mapping);}):none,extraSelections);// Change-less events don't store mappings (they are always the last event in a branch)
21212121+if(!event.changes)return HistEvent.selection(selections);var mappedChanges=event.changes.map(mapping),before=mapping.mapDesc(event.changes,true);var fullMapping=event.mapped?event.mapped.composeDesc(before):before;return new HistEvent(mappedChanges,state.StateEffect.mapEffects(event.effects,mapping),fullMapping,event.startSelection.map(before),selections);}var joinableUserEvent=/^(input\.type|delete)($|\.)/;var HistoryState=/*#__PURE__*/function(){function HistoryState(done,undone){var prevTime=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var prevUserEvent=arguments.length>3&&arguments[3]!==undefined?arguments[3]:undefined;_classCallCheck(this,HistoryState);this.done=done;this.undone=undone;this.prevTime=prevTime;this.prevUserEvent=prevUserEvent;}_createClass(HistoryState,[{key:"isolate",value:function isolate(){return this.prevTime?new HistoryState(this.done,this.undone):this;}},{key:"addChanges",value:function addChanges(event,time,userEvent,newGroupDelay,maxLen){var done=this.done,lastEvent=done[done.length-1];if(lastEvent&&lastEvent.changes&&!lastEvent.changes.empty&&event.changes&&(!userEvent||joinableUserEvent.test(userEvent))&&(!lastEvent.selectionsAfter.length&&time-this.prevTime<newGroupDelay&&isAdjacent(lastEvent.changes,event.changes)||// For compose (but not compose.start) events, always join with previous event
21222122+userEvent=="input.type.compose")){done=updateBranch(done,done.length-1,maxLen,new HistEvent(event.changes.compose(lastEvent.changes),conc(event.effects,lastEvent.effects),lastEvent.mapped,lastEvent.startSelection,none));}else{done=updateBranch(done,done.length,maxLen,event);}return new HistoryState(done,none,time,userEvent);}},{key:"addSelection",value:function addSelection(selection,time,userEvent,newGroupDelay){var last=this.done.length?this.done[this.done.length-1].selectionsAfter:none;if(last.length>0&&time-this.prevTime<newGroupDelay&&userEvent==this.prevUserEvent&&userEvent&&/^select($|\.)/.test(userEvent)&&eqSelectionShape(last[last.length-1],selection))return this;return new HistoryState(_addSelection(this.done,selection),this.undone,time,userEvent);}},{key:"addMapping",value:function addMapping(mapping){return new HistoryState(addMappingToBranch(this.done,mapping),addMappingToBranch(this.undone,mapping),this.prevTime,this.prevUserEvent);}},{key:"pop",value:function pop(side,state,selection){var branch=side==0/* Done */?this.done:this.undone;if(branch.length==0)return null;var event=branch[branch.length-1];if(selection&&event.selectionsAfter.length){return state.update({selection:event.selectionsAfter[event.selectionsAfter.length-1],annotations:fromHistory.of({side:side,rest:popSelection(branch)}),userEvent:side==0/* Done */?"select.undo":"select.redo",scrollIntoView:true});}else if(!event.changes){return null;}else{var rest=branch.length==1?none:branch.slice(0,branch.length-1);if(event.mapped)rest=addMappingToBranch(rest,event.mapped);return state.update({changes:event.changes,selection:event.startSelection,effects:event.effects,annotations:fromHistory.of({side:side,rest:rest}),filter:false,userEvent:side==0/* Done */?"undo":"redo",scrollIntoView:true});}}}]);return HistoryState;}();HistoryState.empty=new HistoryState(none,none);/**
21232123+Default key bindings for the undo history.
21242124+21252125+- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#history.undo).
21262126+- Mod-y (Mod-Shift-z on macOS): [`redo`](https://codemirror.net/6/docs/ref/#history.redo).
21272127+- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#history.undoSelection).
21282128+- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#history.redoSelection).
21292129+*/var historyKeymap=[{key:"Mod-z",run:undo,preventDefault:true},{key:"Mod-y",mac:"Mod-Shift-z",run:redo,preventDefault:true},{key:"Mod-u",run:undoSelection,preventDefault:true},{key:"Alt-u",mac:"Mod-Shift-u",run:redoSelection,preventDefault:true}];exports.history=history;exports.historyField=historyField;exports.historyKeymap=historyKeymap;exports.invertedEffects=invertedEffects;exports.isolateHistory=isolateHistory;exports.redo=redo;exports.redoDepth=redoDepth;exports.redoSelection=redoSelection;exports.undo=undo;exports.undoDepth=undoDepth;exports.undoSelection=undoSelection;},{"@codemirror/state":22,"@codemirror/view":27}],13:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var common=require('@lezer/common');var state=require('@codemirror/state');var view=require('@codemirror/view');var text=require('@codemirror/text');/**
21302130+Node prop stored in a grammar's top syntax node to provide the
21312131+facet that stores language data for that language.
21322132+*/var languageDataProp=new common.NodeProp();/**
21332133+Helper function to define a facet (to be added to the top syntax
21342134+node(s) for a language via
21352135+[`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be
21362136+used to associate language data with the language. You
21372137+probably only need this when subclassing
21382138+[`Language`](https://codemirror.net/6/docs/ref/#language.Language).
21392139+*/function defineLanguageFacet(baseData){return state.Facet.define({combine:baseData?function(values){return values.concat(baseData);}:undefined});}/**
21402140+A language object manages parsing and per-language
21412141+[metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
21422142+managed as a [Lezer](https://lezer.codemirror.net) tree. You'll
21432143+want to subclass this class for custom parsers, or use the
21442144+[`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage) or
21452145+[`StreamLanguage`](https://codemirror.net/6/docs/ref/#stream-parser.StreamLanguage) abstractions for
21462146+[Lezer](https://lezer.codemirror.net/) or stream parsers.
21472147+*/var Language=/*#__PURE__*/function(){/**
21482148+ Construct a language object. You usually don't need to invoke
21492149+ this directly. But when you do, make sure you use
21502150+ [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet) to create
21512151+ the first argument.
21522152+ */function Language(/**
21532153+ The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) data
21542154+ facet used for this language.
21552155+ */data,parser,/**
21562156+ The node type of the top node of trees produced by this parser.
21572157+ */topNode){var extraExtensions=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[];_classCallCheck(this,Language);this.data=data;this.topNode=topNode;// Kludge to define EditorState.tree as a debugging helper,
21582158+// without the EditorState package actually knowing about
21592159+// languages and lezer trees.
21602160+if(!state.EditorState.prototype.hasOwnProperty("tree"))Object.defineProperty(state.EditorState.prototype,"tree",{get:function get(){return syntaxTree(this);}});this.parser=parser;this.extension=[language.of(this),state.EditorState.languageData.of(function(state,pos,side){return state.facet(languageDataFacetAt(state,pos,side));})].concat(extraExtensions);}/**
21612161+ Query whether this language is active at the given position.
21622162+ */_createClass(Language,[{key:"isActiveAt",value:function isActiveAt(state,pos){var side=arguments.length>2&&arguments[2]!==undefined?arguments[2]:-1;return languageDataFacetAt(state,pos,side)==this.data;}/**
21632163+ Find the document regions that were parsed using this language.
21642164+ The returned regions will _include_ any nested languages rooted
21652165+ in this language, when those exist.
21662166+ */},{key:"findRegions",value:function findRegions(state){var _this64=this;var lang=state.facet(language);if((lang===null||lang===void 0?void 0:lang.data)==this.data)return[{from:0,to:state.doc.length}];if(!lang||!lang.allowsNesting)return[];var result=[];var explore=function explore(tree,from){if(tree.prop(languageDataProp)==_this64.data){result.push({from:from,to:from+tree.length});return;}var mount=tree.prop(common.NodeProp.mounted);if(mount){if(mount.tree.prop(languageDataProp)==_this64.data){if(mount.overlay){var _iterator131=_createForOfIteratorHelper(mount.overlay),_step131;try{for(_iterator131.s();!(_step131=_iterator131.n()).done;){var r=_step131.value;result.push({from:r.from+from,to:r.to+from});}}catch(err){_iterator131.e(err);}finally{_iterator131.f();}}else result.push({from:from,to:from+tree.length});return;}else if(mount.overlay){var size=result.length;explore(mount.tree,mount.overlay[0].from+from);if(result.length>size)return;}}for(var _i64=0;_i64<tree.children.length;_i64++){var ch=tree.children[_i64];if(ch instanceof common.Tree)explore(ch,tree.positions[_i64]+from);}};explore(syntaxTree(state),0);return result;}/**
21672167+ Indicates whether this language allows nested languages. The
21682168+ default implementation returns true.
21692169+ */},{key:"allowsNesting",get:function get(){return true;}}]);return Language;}();/**
21702170+@internal
21712171+*/Language.setState=state.StateEffect.define();function languageDataFacetAt(state,pos,side){var topLang=state.facet(language);if(!topLang)return null;var facet=topLang.data;if(topLang.allowsNesting){for(var node=syntaxTree(state).topNode;node;node=node.enter(pos,side,true,false)){facet=node.type.prop(languageDataProp)||facet;}}return facet;}/**
21722172+A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
21732173+[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
21742174+parsers.
21752175+*/var LRLanguage=/*#__PURE__*/function(_Language){_inherits(LRLanguage,_Language);var _super32=_createSuper(LRLanguage);function LRLanguage(data,parser){var _this65;_classCallCheck(this,LRLanguage);_this65=_super32.call(this,data,parser,parser.topNode);_this65.parser=parser;return _this65;}/**
21762176+ Define a language from a parser.
21772177+ */_createClass(LRLanguage,[{key:"configure",value:/**
21782178+ Create a new instance of this language with a reconfigured
21792179+ version of its parser.
21802180+ */function configure(options){return new LRLanguage(this.data,this.parser.configure(options));}},{key:"allowsNesting",get:function get(){return this.parser.wrappers.length>0;}// FIXME
21812181+}],[{key:"define",value:function define(spec){var data=defineLanguageFacet(spec.languageData);return new LRLanguage(data,spec.parser.configure({props:[languageDataProp.add(function(type){return type.isTop?data:undefined;})]}));}}]);return LRLanguage;}(Language);/**
21822182+Get the syntax tree for a state, which is the current (possibly
21832183+incomplete) parse tree of active [language](https://codemirror.net/6/docs/ref/#language.Language),
21842184+or the empty tree if there is no language available.
21852185+*/function syntaxTree(state){var field=state.field(Language.state,false);return field?field.tree:common.Tree.empty;}/**
21862186+Try to get a parse tree that spans at least up to `upto`. The
21872187+method will do at most `timeout` milliseconds of work to parse
21882188+up to that point if the tree isn't already available.
21892189+*/function ensureSyntaxTree(state,upto){var timeout=arguments.length>2&&arguments[2]!==undefined?arguments[2]:50;var _a;var parse=(_a=state.field(Language.state,false))===null||_a===void 0?void 0:_a.context;return!parse?null:parse.isDone(upto)||parse.work(timeout,upto)?parse.tree:null;}/**
21902190+Queries whether there is a full syntax tree available up to the
21912191+given document position. If there isn't, the background parse
21922192+process _might_ still be working and update the tree further, but
21932193+there is no guarantee of that—the parser will [stop
21942194+working](https://codemirror.net/6/docs/ref/#language.syntaxParserStopped) when it has spent a
21952195+certain amount of time or has moved beyond the visible viewport.
21962196+Always returns false if no language has been enabled.
21972197+*/function syntaxTreeAvailable(state){var upto=arguments.length>1&&arguments[1]!==undefined?arguments[1]:state.doc.length;var _a;return((_a=state.field(Language.state,false))===null||_a===void 0?void 0:_a.context.isDone(upto))||false;}/**
21982198+Tells you whether the language parser is planning to do more
21992199+parsing work (in a `requestIdleCallback` pseudo-thread) or has
22002200+stopped running, either because it parsed the entire document,
22012201+because it spent too much time and was cut off, or because there
22022202+is no language parser enabled.
22032203+*/function syntaxParserRunning(view){var _a;return((_a=view.plugin(parseWorker))===null||_a===void 0?void 0:_a.isWorking())||false;}// Lezer-style Input object for a Text document.
22042204+var DocInput=/*#__PURE__*/function(){function DocInput(doc){var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:doc.length;_classCallCheck(this,DocInput);this.doc=doc;this.length=length;this.cursorPos=0;this.string="";this.cursor=doc.iter();}_createClass(DocInput,[{key:"syncTo",value:function syncTo(pos){this.string=this.cursor.next(pos-this.cursorPos).value;this.cursorPos=pos+this.string.length;return this.cursorPos-this.string.length;}},{key:"chunk",value:function chunk(pos){this.syncTo(pos);return this.string;}},{key:"lineChunks",get:function get(){return true;}},{key:"read",value:function read(from,to){var stringStart=this.cursorPos-this.string.length;if(from<stringStart||to>=this.cursorPos)return this.doc.sliceString(from,to);else return this.string.slice(from-stringStart,to-stringStart);}}]);return DocInput;}();var currentContext=null;/**
22052205+A parse context provided to parsers working on the editor content.
22062206+*/var ParseContext=/*#__PURE__*/function(){/**
22072207+ @internal
22082208+ */function ParseContext(parser,/**
22092209+ The current editor state.
22102210+ */state){var fragments=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var/**
22112211+ @internal
22122212+ */tree=arguments.length>3?arguments[3]:undefined;var treeLen=arguments.length>4?arguments[4]:undefined;var/**
22132213+ The current editor viewport (or some overapproximation
22142214+ thereof). Intended to be used for opportunistically avoiding
22152215+ work (in which case
22162216+ [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
22172217+ should be called to make sure the parser is restarted when the
22182218+ skipped region becomes visible).
22192219+ */viewport=arguments.length>5?arguments[5]:undefined;var/**
22202220+ @internal
22212221+ */skipped=arguments.length>6?arguments[6]:undefined;var/**
22222222+ This is where skipping parsers can register a promise that,
22232223+ when resolved, will schedule a new parse. It is cleared when
22242224+ the parse worker picks up the promise. @internal
22252225+ */scheduleOn=arguments.length>7?arguments[7]:undefined;_classCallCheck(this,ParseContext);this.parser=parser;this.state=state;this.fragments=fragments;this.tree=tree;this.treeLen=treeLen;this.viewport=viewport;this.skipped=skipped;this.scheduleOn=scheduleOn;this.parse=null;/**
22262226+ @internal
22272227+ */this.tempSkipped=[];}_createClass(ParseContext,[{key:"startParse",value:function startParse(){return this.parser.startParse(new DocInput(this.state.doc),this.fragments);}/**
22282228+ @internal
22292229+ */},{key:"work",value:function work(time,upto){var _this66=this;if(upto!=null&&upto>=this.state.doc.length)upto=undefined;if(this.tree!=common.Tree.empty&&this.isDone(upto!==null&&upto!==void 0?upto:this.state.doc.length)){this.takeTree();return true;}return this.withContext(function(){var _a;var endTime=Date.now()+time;if(!_this66.parse)_this66.parse=_this66.startParse();if(upto!=null&&(_this66.parse.stoppedAt==null||_this66.parse.stoppedAt>upto)&&upto<_this66.state.doc.length)_this66.parse.stopAt(upto);for(;;){var done=_this66.parse.advance();if(done){_this66.fragments=_this66.withoutTempSkipped(common.TreeFragment.addTree(done,_this66.fragments,_this66.parse.stoppedAt!=null));_this66.treeLen=(_a=_this66.parse.stoppedAt)!==null&&_a!==void 0?_a:_this66.state.doc.length;_this66.tree=done;_this66.parse=null;if(_this66.treeLen<(upto!==null&&upto!==void 0?upto:_this66.state.doc.length))_this66.parse=_this66.startParse();else return true;}if(Date.now()>endTime)return false;}});}/**
22302230+ @internal
22312231+ */},{key:"takeTree",value:function takeTree(){var _this67=this;var pos,tree;if(this.parse&&(pos=this.parse.parsedPos)>=this.treeLen){if(this.parse.stoppedAt==null||this.parse.stoppedAt>pos)this.parse.stopAt(pos);this.withContext(function(){while(!(tree=_this67.parse.advance())){}});this.treeLen=pos;this.tree=tree;this.fragments=this.withoutTempSkipped(common.TreeFragment.addTree(this.tree,this.fragments,true));this.parse=null;}}},{key:"withContext",value:function withContext(f){var prev=currentContext;currentContext=this;try{return f();}finally{currentContext=prev;}}},{key:"withoutTempSkipped",value:function withoutTempSkipped(fragments){for(var r;r=this.tempSkipped.pop();){fragments=cutFragments(fragments,r.from,r.to);}return fragments;}/**
22322232+ @internal
22332233+ */},{key:"changes",value:function changes(_changes2,newState){var fragments=this.fragments,tree=this.tree,treeLen=this.treeLen,viewport=this.viewport,skipped=this.skipped;this.takeTree();if(!_changes2.empty){var ranges=[];_changes2.iterChangedRanges(function(fromA,toA,fromB,toB){return ranges.push({fromA:fromA,toA:toA,fromB:fromB,toB:toB});});fragments=common.TreeFragment.applyChanges(fragments,ranges);tree=common.Tree.empty;treeLen=0;viewport={from:_changes2.mapPos(viewport.from,-1),to:_changes2.mapPos(viewport.to,1)};if(this.skipped.length){skipped=[];var _iterator132=_createForOfIteratorHelper(this.skipped),_step132;try{for(_iterator132.s();!(_step132=_iterator132.n()).done;){var r=_step132.value;var from=_changes2.mapPos(r.from,1),to=_changes2.mapPos(r.to,-1);if(from<to)skipped.push({from:from,to:to});}}catch(err){_iterator132.e(err);}finally{_iterator132.f();}}}return new ParseContext(this.parser,newState,fragments,tree,treeLen,viewport,skipped,this.scheduleOn);}/**
22342234+ @internal
22352235+ */},{key:"updateViewport",value:function updateViewport(viewport){if(this.viewport.from==viewport.from&&this.viewport.to==viewport.to)return false;this.viewport=viewport;var startLen=this.skipped.length;for(var _i65=0;_i65<this.skipped.length;_i65++){var _this$skipped$_i=this.skipped[_i65],from=_this$skipped$_i.from,to=_this$skipped$_i.to;if(from<viewport.to&&to>viewport.from){this.fragments=cutFragments(this.fragments,from,to);this.skipped.splice(_i65--,1);}}if(this.skipped.length>=startLen)return false;this.reset();return true;}/**
22362236+ @internal
22372237+ */},{key:"reset",value:function reset(){if(this.parse){this.takeTree();this.parse=null;}}/**
22382238+ Notify the parse scheduler that the given region was skipped
22392239+ because it wasn't in view, and the parse should be restarted
22402240+ when it comes into view.
22412241+ */},{key:"skipUntilInView",value:function skipUntilInView(from,to){this.skipped.push({from:from,to:to});}/**
22422242+ Returns a parser intended to be used as placeholder when
22432243+ asynchronously loading a nested parser. It'll skip its input and
22442244+ mark it as not-really-parsed, so that the next update will parse
22452245+ it again.
22462246+22472247+ When `until` is given, a reparse will be scheduled when that
22482248+ promise resolves.
22492249+ */},{key:"isDone",value:/**
22502250+ @internal
22512251+ */function isDone(upto){upto=Math.min(upto,this.state.doc.length);var frags=this.fragments;return this.treeLen>=upto&&frags.length&&frags[0].from==0&&frags[0].to>=upto;}/**
22522252+ Get the context for the current parse, or `null` if no editor
22532253+ parse is in progress.
22542254+ */}],[{key:"getSkippingParser",value:function getSkippingParser(until){return new(/*#__PURE__*/function(_common$Parser){_inherits(_class14,_common$Parser);var _super33=_createSuper(_class14);function _class14(){_classCallCheck(this,_class14);return _super33.apply(this,arguments);}_createClass(_class14,[{key:"createParse",value:function createParse(input,fragments,ranges){var from=ranges[0].from,to=ranges[ranges.length-1].to;var parser={parsedPos:from,advance:function advance(){var cx=currentContext;if(cx){var _iterator133=_createForOfIteratorHelper(ranges),_step133;try{for(_iterator133.s();!(_step133=_iterator133.n()).done;){var r=_step133.value;cx.tempSkipped.push(r);}}catch(err){_iterator133.e(err);}finally{_iterator133.f();}if(until)cx.scheduleOn=cx.scheduleOn?Promise.all([cx.scheduleOn,until]):until;}this.parsedPos=to;return new common.Tree(common.NodeType.none,[],[],to-from);},stoppedAt:null,stopAt:function stopAt(){}};return parser;}}]);return _class14;}(common.Parser))();}},{key:"get",value:function get(){return currentContext;}}]);return ParseContext;}();function cutFragments(fragments,from,to){return common.TreeFragment.applyChanges(fragments,[{fromA:from,toA:to,fromB:from,toB:to}]);}var LanguageState=/*#__PURE__*/function(){function LanguageState(// A mutable parse state that is used to preserve work done during
22552255+// the lifetime of a state when moving to the next state.
22562256+context){_classCallCheck(this,LanguageState);this.context=context;this.tree=context.tree;}_createClass(LanguageState,[{key:"apply",value:function apply(tr){if(!tr.docChanged)return this;var newCx=this.context.changes(tr.changes,tr.state);// If the previous parse wasn't done, go forward only up to its
22572257+// end position or the end of the viewport, to avoid slowing down
22582258+// state updates with parse work beyond the viewport.
22592259+var upto=this.context.treeLen==tr.startState.doc.length?undefined:Math.max(tr.changes.mapPos(this.context.treeLen),newCx.viewport.to);if(!newCx.work(20/* Apply */,upto))newCx.takeTree();return new LanguageState(newCx);}}],[{key:"init",value:function init(state){var vpTo=Math.min(3000/* InitViewport */,state.doc.length);var parseState=new ParseContext(state.facet(language).parser,state,[],common.Tree.empty,0,{from:0,to:vpTo},[],null);if(!parseState.work(20/* Apply */,vpTo))parseState.takeTree();return new LanguageState(parseState);}}]);return LanguageState;}();Language.state=state.StateField.define({create:LanguageState.init,update:function update(value,tr){var _iterator134=_createForOfIteratorHelper(tr.effects),_step134;try{for(_iterator134.s();!(_step134=_iterator134.n()).done;){var e=_step134.value;if(e.is(Language.setState))return e.value;}}catch(err){_iterator134.e(err);}finally{_iterator134.f();}if(tr.startState.facet(language)!=tr.state.facet(language))return LanguageState.init(tr.state);return value.apply(tr);}});var requestIdle=function requestIdle(callback){var timeout=setTimeout(function(){return callback();},500/* MaxPause */);return function(){return clearTimeout(timeout);};};if(typeof requestIdleCallback!="undefined")requestIdle=function requestIdle(callback){var idle=-1,timeout=setTimeout(function(){idle=requestIdleCallback(callback,{timeout:500/* MaxPause */-100/* MinPause */});},100/* MinPause */);return function(){return idle<0?clearTimeout(timeout):cancelIdleCallback(idle);};};var parseWorker=view.ViewPlugin.fromClass(/*#__PURE__*/function(){function ParseWorker(view){_classCallCheck(this,ParseWorker);this.view=view;this.working=null;this.workScheduled=0;// End of the current time chunk
22602260+this.chunkEnd=-1;// Milliseconds of budget left for this chunk
22612261+this.chunkBudget=-1;this.work=this.work.bind(this);this.scheduleWork();}_createClass(ParseWorker,[{key:"update",value:function update(_update17){var cx=this.view.state.field(Language.state).context;if(cx.updateViewport(_update17.view.viewport)||this.view.viewport.to>cx.treeLen)this.scheduleWork();if(_update17.docChanged){if(this.view.hasFocus)this.chunkBudget+=50/* ChangeBonus */;this.scheduleWork();}this.checkAsyncSchedule(cx);}},{key:"scheduleWork",value:function scheduleWork(){if(this.working)return;var state=this.view.state,field=state.field(Language.state);if(field.tree!=field.context.tree||!field.context.isDone(state.doc.length))this.working=requestIdle(this.work);}},{key:"work",value:function work(deadline){this.working=null;var now=Date.now();if(this.chunkEnd<now&&(this.chunkEnd<0||this.view.hasFocus)){// Start a new chunk
22622262+this.chunkEnd=now+30000/* ChunkTime */;this.chunkBudget=3000/* ChunkBudget */;}if(this.chunkBudget<=0)return;// No more budget
22632263+var _this$view=this.view,state=_this$view.state,vpTo=_this$view.viewport.to,field=state.field(Language.state);if(field.tree==field.context.tree&&field.context.isDone(vpTo+100000/* MaxParseAhead */))return;var time=Math.min(this.chunkBudget,100/* Slice */,deadline?Math.max(25/* MinSlice */,deadline.timeRemaining()-5):1e9);var viewportFirst=field.context.treeLen<vpTo&&state.doc.length>vpTo+1000;var done=field.context.work(time,vpTo+(viewportFirst?0:100000/* MaxParseAhead */));this.chunkBudget-=Date.now()-now;if(done||this.chunkBudget<=0){field.context.takeTree();this.view.dispatch({effects:Language.setState.of(new LanguageState(field.context))});}if(this.chunkBudget>0&&!(done&&!viewportFirst))this.scheduleWork();this.checkAsyncSchedule(field.context);}},{key:"checkAsyncSchedule",value:function checkAsyncSchedule(cx){var _this68=this;if(cx.scheduleOn){this.workScheduled++;cx.scheduleOn.then(function(){return _this68.scheduleWork();})["catch"](function(err){return view.logException(_this68.view.state,err);}).then(function(){return _this68.workScheduled--;});cx.scheduleOn=null;}}},{key:"destroy",value:function destroy(){if(this.working)this.working();}},{key:"isWorking",value:function isWorking(){return this.working||this.workScheduled>0;}}]);return ParseWorker;}(),{eventHandlers:{focus:function focus(){this.scheduleWork();}}});/**
22642264+The facet used to associate a language with an editor state.
22652265+*/var language=state.Facet.define({combine:function combine(languages){return languages.length?languages[0]:null;},enables:[Language.state,parseWorker]});/**
22662266+This class bundles a [language object](https://codemirror.net/6/docs/ref/#language.Language) with an
22672267+optional set of supporting extensions. Language packages are
22682268+encouraged to export a function that optionally takes a
22692269+configuration object and returns a `LanguageSupport` instance, as
22702270+the main way for client code to use the package.
22712271+*/var LanguageSupport=/*#__PURE__*/_createClass(/**
22722272+ Create a support object.
22732273+ */function LanguageSupport(/**
22742274+ The language object.
22752275+ */language){var support=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];_classCallCheck(this,LanguageSupport);this.language=language;this.support=support;this.extension=[language,support];});/**
22762276+Language descriptions are used to store metadata about languages
22772277+and to dynamically load them. Their main role is finding the
22782278+appropriate language for a filename or dynamically loading nested
22792279+parsers.
22802280+*/var LanguageDescription=/*#__PURE__*/function(){function LanguageDescription(/**
22812281+ The name of this language.
22822282+ */name,/**
22832283+ Alternative names for the mode (lowercased, includes `this.name`).
22842284+ */alias,/**
22852285+ File extensions associated with this language.
22862286+ */extensions,/**
22872287+ Optional filename pattern that should be associated with this
22882288+ language.
22892289+ */filename,loadFunc){var support=arguments.length>5&&arguments[5]!==undefined?arguments[5]:undefined;_classCallCheck(this,LanguageDescription);this.name=name;this.alias=alias;this.extensions=extensions;this.filename=filename;this.loadFunc=loadFunc;this.support=support;this.loading=null;}/**
22902290+ Start loading the the language. Will return a promise that
22912291+ resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)
22922292+ object when the language successfully loads.
22932293+ */_createClass(LanguageDescription,[{key:"load",value:function load(){var _this69=this;return this.loading||(this.loading=this.loadFunc().then(function(support){return _this69.support=support;},function(err){_this69.loading=null;throw err;}));}/**
22942294+ Create a language description.
22952295+ */}],[{key:"of",value:function of(spec){var load=spec.load,support=spec.support;if(!load){if(!support)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");load=function load(){return Promise.resolve(support);};}return new LanguageDescription(spec.name,(spec.alias||[]).concat(spec.name).map(function(s){return s.toLowerCase();}),spec.extensions||[],spec.filename,load,support);}/**
22962296+ Look for a language in the given array of descriptions that
22972297+ matches the filename. Will first match
22982298+ [`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,
22992299+ and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),
23002300+ and return the first language that matches.
23012301+ */},{key:"matchFilename",value:function matchFilename(descs,filename){var _iterator135=_createForOfIteratorHelper(descs),_step135;try{for(_iterator135.s();!(_step135=_iterator135.n()).done;){var _d2=_step135.value;if(_d2.filename&&_d2.filename.test(filename))return _d2;}}catch(err){_iterator135.e(err);}finally{_iterator135.f();}var ext=/\.([^.]+)$/.exec(filename);if(ext){var _iterator136=_createForOfIteratorHelper(descs),_step136;try{for(_iterator136.s();!(_step136=_iterator136.n()).done;){var d=_step136.value;if(d.extensions.indexOf(ext[1])>-1)return d;}}catch(err){_iterator136.e(err);}finally{_iterator136.f();}}return null;}/**
23022302+ Look for a language whose name or alias matches the the given
23032303+ name (case-insensitively). If `fuzzy` is true, and no direct
23042304+ matchs is found, this'll also search for a language whose name
23052305+ or alias occurs in the string (for names shorter than three
23062306+ characters, only when surrounded by non-word characters).
23072307+ */},{key:"matchLanguageName",value:function matchLanguageName(descs,name){var fuzzy=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;name=name.toLowerCase();var _iterator137=_createForOfIteratorHelper(descs),_step137;try{for(_iterator137.s();!(_step137=_iterator137.n()).done;){var _d3=_step137.value;if(_d3.alias.some(function(a){return a==name;}))return _d3;}}catch(err){_iterator137.e(err);}finally{_iterator137.f();}if(fuzzy){var _iterator138=_createForOfIteratorHelper(descs),_step138;try{for(_iterator138.s();!(_step138=_iterator138.n()).done;){var d=_step138.value;var _iterator139=_createForOfIteratorHelper(d.alias),_step139;try{for(_iterator139.s();!(_step139=_iterator139.n()).done;){var a=_step139.value;var found=name.indexOf(a);if(found>-1&&(a.length>2||!/\w/.test(name[found-1])&&!/\w/.test(name[found+a.length])))return d;}}catch(err){_iterator139.e(err);}finally{_iterator139.f();}}}catch(err){_iterator138.e(err);}finally{_iterator138.f();}}return null;}}]);return LanguageDescription;}();/**
23082308+Facet that defines a way to provide a function that computes the
23092309+appropriate indentation depth at the start of a given line, or
23102310+`null` to indicate no appropriate indentation could be determined.
23112311+*/var indentService=state.Facet.define();/**
23122312+Facet for overriding the unit by which indentation happens.
23132313+Should be a string consisting either entirely of spaces or
23142314+entirely of tabs. When not set, this defaults to 2 spaces.
23152315+*/var indentUnit=state.Facet.define({combine:function combine(values){if(!values.length)return" ";if(!/^(?: +|\t+)$/.test(values[0]))throw new Error("Invalid indent unit: "+JSON.stringify(values[0]));return values[0];}});/**
23162316+Return the _column width_ of an indent unit in the state.
23172317+Determined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)
23182318+facet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that
23192319+contains tabs.
23202320+*/function getIndentUnit(state){var unit=state.facet(indentUnit);return unit.charCodeAt(0)==9?state.tabSize*unit.length:unit.length;}/**
23212321+Create an indentation string that covers columns 0 to `cols`.
23222322+Will use tabs for as much of the columns as possible when the
23232323+[`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains
23242324+tabs.
23252325+*/function indentString(state,cols){var result="",ts=state.tabSize;if(state.facet(indentUnit).charCodeAt(0)==9)while(cols>=ts){result+="\t";cols-=ts;}for(var _i66=0;_i66<cols;_i66++){result+=" ";}return result;}/**
23262326+Get the indentation at the given position. Will first consult any
23272327+[indent services](https://codemirror.net/6/docs/ref/#language.indentService) that are registered,
23282328+and if none of those return an indentation, this will check the
23292329+syntax tree for the [indent node prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp)
23302330+and use that if found. Returns a number when an indentation could
23312331+be determined, and null otherwise.
23322332+*/function getIndentation(context,pos){if(context instanceof state.EditorState)context=new IndentContext(context);var _iterator140=_createForOfIteratorHelper(context.state.facet(indentService)),_step140;try{for(_iterator140.s();!(_step140=_iterator140.n()).done;){var service=_step140.value;var result=service(context,pos);if(result!=null)return result;}}catch(err){_iterator140.e(err);}finally{_iterator140.f();}var tree=syntaxTree(context.state);return tree?syntaxIndentation(context,tree,pos):null;}/**
23332333+Indentation contexts are used when calling [indentation
23342334+services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
23352335+useful in indentation logic, and can selectively override the
23362336+indentation reported for some lines.
23372337+*/var IndentContext=/*#__PURE__*/function(){/**
23382338+ Create an indent context.
23392339+ */function IndentContext(/**
23402340+ The editor state.
23412341+ */state){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,IndentContext);this.state=state;this.options=options;this.unit=getIndentUnit(state);}/**
23422342+ Get a description of the line at the given position, taking
23432343+ [simulated line
23442344+ breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
23452345+ into account. If there is such a break at `pos`, the `bias`
23462346+ argument determines whether the part of the line line before or
23472347+ after the break is used.
23482348+ */_createClass(IndentContext,[{key:"lineAt",value:function lineAt(pos){var bias=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var line=this.state.doc.lineAt(pos);var simulateBreak=this.options.simulateBreak;if(simulateBreak!=null&&simulateBreak>=line.from&&simulateBreak<=line.to){if(bias<0?simulateBreak<pos:simulateBreak<=pos)return{text:line.text.slice(simulateBreak-line.from),from:simulateBreak};else return{text:line.text.slice(0,simulateBreak-line.from),from:line.from};}return line;}/**
23492349+ Get the text directly after `pos`, either the entire line
23502350+ or the next 100 characters, whichever is shorter.
23512351+ */},{key:"textAfterPos",value:function textAfterPos(pos){var bias=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;if(this.options.simulateDoubleBreak&&pos==this.options.simulateBreak)return"";var _this$lineAt=this.lineAt(pos,bias),text=_this$lineAt.text,from=_this$lineAt.from;return text.slice(pos-from,Math.min(text.length,pos+100-from));}/**
23522352+ Find the column for the given position.
23532353+ */},{key:"column",value:function column(pos){var bias=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var _this$lineAt2=this.lineAt(pos,bias),text=_this$lineAt2.text,from=_this$lineAt2.from;var result=this.countColumn(text,pos-from);var override=this.options.overrideIndentation?this.options.overrideIndentation(from):-1;if(override>-1)result+=override-this.countColumn(text,text.search(/\S|$/));return result;}/**
23542354+ Find the column position (taking tabs into account) of the given
23552355+ position in the given string.
23562356+ */},{key:"countColumn",value:function countColumn(line){var pos=arguments.length>1&&arguments[1]!==undefined?arguments[1]:line.length;return text.countColumn(line,this.state.tabSize,pos);}/**
23572357+ Find the indentation column of the line at the given point.
23582358+ */},{key:"lineIndent",value:function lineIndent(pos){var bias=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var _this$lineAt3=this.lineAt(pos,bias),text=_this$lineAt3.text,from=_this$lineAt3.from;var override=this.options.overrideIndentation;if(override){var overriden=override(from);if(overriden>-1)return overriden;}return this.countColumn(text,text.search(/\S|$/));}/**
23592359+ Returns the [simulated line
23602360+ break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
23612361+ for this context, if any.
23622362+ */},{key:"simulatedBreak",get:function get(){return this.options.simulateBreak||null;}}]);return IndentContext;}();/**
23632363+A syntax tree node prop used to associate indentation strategies
23642364+with node types. Such a strategy is a function from an indentation
23652365+context to a column number or null, where null indicates that no
23662366+definitive indentation can be determined.
23672367+*/var indentNodeProp=new common.NodeProp();// Compute the indentation for a given position from the syntax tree.
23682368+function syntaxIndentation(cx,ast,pos){return indentFrom(ast.resolveInner(pos).enterUnfinishedNodesBefore(pos),pos,cx);}function ignoreClosed(cx){return cx.pos==cx.options.simulateBreak&&cx.options.simulateDoubleBreak;}function indentStrategy(tree){var strategy=tree.type.prop(indentNodeProp);if(strategy)return strategy;var first=tree.firstChild,close;if(first&&(close=first.type.prop(common.NodeProp.closedBy))){var last=tree.lastChild,closed=last&&close.indexOf(last.name)>-1;return function(cx){return delimitedStrategy(cx,true,1,undefined,closed&&!ignoreClosed(cx)?last.from:undefined);};}return tree.parent==null?topIndent:null;}function indentFrom(node,pos,base){for(;node;node=node.parent){var strategy=indentStrategy(node);if(strategy)return strategy(new TreeIndentContext(base,pos,node));}return null;}function topIndent(){return 0;}/**
23692369+Objects of this type provide context information and helper
23702370+methods to indentation functions.
23712371+*/var TreeIndentContext=/*#__PURE__*/function(_IndentContext){_inherits(TreeIndentContext,_IndentContext);var _super34=_createSuper(TreeIndentContext);/**
23722372+ @internal
23732373+ */function TreeIndentContext(base,/**
23742374+ The position at which indentation is being computed.
23752375+ */pos,/**
23762376+ The syntax tree node to which the indentation strategy
23772377+ applies.
23782378+ */node){var _this70;_classCallCheck(this,TreeIndentContext);_this70=_super34.call(this,base.state,base.options);_this70.base=base;_this70.pos=pos;_this70.node=node;return _this70;}/**
23792379+ Get the text directly after `this.pos`, either the entire line
23802380+ or the next 100 characters, whichever is shorter.
23812381+ */_createClass(TreeIndentContext,[{key:"textAfter",get:function get(){return this.textAfterPos(this.pos);}/**
23822382+ Get the indentation at the reference line for `this.node`, which
23832383+ is the line on which it starts, unless there is a node that is
23842384+ _not_ a parent of this node covering the start of that line. If
23852385+ so, the line at the start of that node is tried, again skipping
23862386+ on if it is covered by another such node.
23872387+ */},{key:"baseIndent",get:function get(){var line=this.state.doc.lineAt(this.node.from);// Skip line starts that are covered by a sibling (or cousin, etc)
23882388+for(;;){var atBreak=this.node.resolve(line.from);while(atBreak.parent&&atBreak.parent.from==atBreak.from){atBreak=atBreak.parent;}if(isParent(atBreak,this.node))break;line=this.state.doc.lineAt(atBreak.from);}return this.lineIndent(line.from);}/**
23892389+ Continue looking for indentations in the node's parent nodes,
23902390+ and return the result of that.
23912391+ */},{key:"continue",value:function _continue(){var parent=this.node.parent;return parent?indentFrom(parent,this.pos,this.base):0;}}]);return TreeIndentContext;}(IndentContext);function isParent(parent,of){for(var cur=of;cur;cur=cur.parent){if(parent==cur)return true;}return false;}// Check whether a delimited node is aligned (meaning there are
23922392+// non-skipped nodes on the same line as the opening delimiter). And
23932393+// if so, return the opening token.
23942394+function bracketedAligned(context){var tree=context.node;var openToken=tree.childAfter(tree.from),last=tree.lastChild;if(!openToken)return null;var sim=context.options.simulateBreak;var openLine=context.state.doc.lineAt(openToken.from);var lineEnd=sim==null||sim<=openLine.from?openLine.to:Math.min(openLine.to,sim);for(var pos=openToken.to;;){var next=tree.childAfter(pos);if(!next||next==last)return null;if(!next.type.isSkipped)return next.from<lineEnd?openToken:null;pos=next.to;}}/**
23952395+An indentation strategy for delimited (usually bracketed) nodes.
23962396+Will, by default, indent one unit more than the parent's base
23972397+indent unless the line starts with a closing token. When `align`
23982398+is true and there are non-skipped nodes on the node's opening
23992399+line, the content of the node will be aligned with the end of the
24002400+opening node, like this:
24012401+24022402+ foo(bar,
24032403+ baz)
24042404+*/function delimitedIndent(_ref51){var closing=_ref51.closing,_ref51$align=_ref51.align,align=_ref51$align===void 0?true:_ref51$align,_ref51$units=_ref51.units,units=_ref51$units===void 0?1:_ref51$units;return function(context){return delimitedStrategy(context,align,units,closing);};}function delimitedStrategy(context,align,units,closing,closedAt){var after=context.textAfter,space=after.match(/^\s*/)[0].length;var closed=closing&&after.slice(space,space+closing.length)==closing||closedAt==context.pos+space;var aligned=align?bracketedAligned(context):null;if(aligned)return closed?context.column(aligned.from):context.column(aligned.to);return context.baseIndent+(closed?0:context.unit*units);}/**
24052405+An indentation strategy that aligns a node's content to its base
24062406+indentation.
24072407+*/var flatIndent=function flatIndent(context){return context.baseIndent;};/**
24082408+Creates an indentation strategy that, by default, indents
24092409+continued lines one unit more than the node's base indentation.
24102410+You can provide `except` to prevent indentation of lines that
24112411+match a pattern (for example `/^else\b/` in `if`/`else`
24122412+constructs), and you can change the amount of units used with the
24132413+`units` option.
24142414+*/function continuedIndent(){var _ref52=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},except=_ref52.except,_ref52$units=_ref52.units,units=_ref52$units===void 0?1:_ref52$units;return function(context){var matchExcept=except&&except.test(context.textAfter);return context.baseIndent+(matchExcept?0:units*context.unit);};}var DontIndentBeyond=200;/**
24152415+Enables reindentation on input. When a language defines an
24162416+`indentOnInput` field in its [language
24172417+data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular
24182418+expression, the line at the cursor will be reindented whenever new
24192419+text is typed and the input from the start of the line up to the
24202420+cursor matches that regexp.
24212421+24222422+To avoid unneccesary reindents, it is recommended to start the
24232423+regexp with `^` (usually followed by `\s*`), and end it with `$`.
24242424+For example, `/^\s*\}$/` will reindent when a closing brace is
24252425+added at the start of a line.
24262426+*/function indentOnInput(){return state.EditorState.transactionFilter.of(function(tr){if(!tr.docChanged||!tr.isUserEvent("input.type"))return tr;var rules=tr.startState.languageDataAt("indentOnInput",tr.startState.selection.main.head);if(!rules.length)return tr;var doc=tr.newDoc,head=tr.newSelection.main.head,line=doc.lineAt(head);if(head>line.from+DontIndentBeyond)return tr;var lineStart=doc.sliceString(line.from,head);if(!rules.some(function(r){return r.test(lineStart);}))return tr;var state=tr.state,last=-1,changes=[];var _iterator141=_createForOfIteratorHelper(state.selection.ranges),_step141;try{for(_iterator141.s();!(_step141=_iterator141.n()).done;){var _head=_step141.value.head;var _line4=state.doc.lineAt(_head);if(_line4.from==last)continue;last=_line4.from;var indent=getIndentation(state,_line4.from);if(indent==null)continue;var cur=/^\s*/.exec(_line4.text)[0];var norm=indentString(state,indent);if(cur!=norm)changes.push({from:_line4.from,to:_line4.from+cur.length,insert:norm});}}catch(err){_iterator141.e(err);}finally{_iterator141.f();}return changes.length?[tr,{changes:changes,sequential:true}]:tr;});}/**
24272427+A facet that registers a code folding service. When called with
24282428+the extent of a line, such a function should return a foldable
24292429+range that starts on that line (but continues beyond it), if one
24302430+can be found.
24312431+*/var foldService=state.Facet.define();/**
24322432+This node prop is used to associate folding information with
24332433+syntax node types. Given a syntax node, it should check whether
24342434+that tree is foldable and return the range that can be collapsed
24352435+when it is.
24362436+*/var foldNodeProp=new common.NodeProp();/**
24372437+[Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but
24382438+the first and the last child of a syntax node. Useful for nodes
24392439+that start and end with delimiters.
24402440+*/function foldInside(node){var first=node.firstChild,last=node.lastChild;return first&&first.to<last.from?{from:first.to,to:last.type.isError?node.to:last.from}:null;}function syntaxFolding(state,start,end){var tree=syntaxTree(state);if(tree.length==0)return null;var inner=tree.resolveInner(end);var found=null;for(var cur=inner;cur;cur=cur.parent){if(cur.to<=end||cur.from>end)continue;if(found&&cur.from<start)break;var prop=cur.type.prop(foldNodeProp);if(prop){var value=prop(cur,state);if(value&&value.from<=end&&value.from>=start&&value.to>end)found=value;}}return found;}/**
24412441+Check whether the given line is foldable. First asks any fold
24422442+services registered through
24432443+[`foldService`](https://codemirror.net/6/docs/ref/#language.foldService), and if none of them return
24442444+a result, tries to query the [fold node
24452445+prop](https://codemirror.net/6/docs/ref/#language.foldNodeProp) of syntax nodes that cover the end
24462446+of the line.
24472447+*/function foldable(state,lineStart,lineEnd){var _iterator142=_createForOfIteratorHelper(state.facet(foldService)),_step142;try{for(_iterator142.s();!(_step142=_iterator142.n()).done;){var service=_step142.value;var result=service(state,lineStart,lineEnd);if(result)return result;}}catch(err){_iterator142.e(err);}finally{_iterator142.f();}return syntaxFolding(state,lineStart,lineEnd);}exports.IndentContext=IndentContext;exports.LRLanguage=LRLanguage;exports.Language=Language;exports.LanguageDescription=LanguageDescription;exports.LanguageSupport=LanguageSupport;exports.ParseContext=ParseContext;exports.TreeIndentContext=TreeIndentContext;exports.continuedIndent=continuedIndent;exports.defineLanguageFacet=defineLanguageFacet;exports.delimitedIndent=delimitedIndent;exports.ensureSyntaxTree=ensureSyntaxTree;exports.flatIndent=flatIndent;exports.foldInside=foldInside;exports.foldNodeProp=foldNodeProp;exports.foldService=foldService;exports.foldable=foldable;exports.getIndentUnit=getIndentUnit;exports.getIndentation=getIndentation;exports.indentNodeProp=indentNodeProp;exports.indentOnInput=indentOnInput;exports.indentService=indentService;exports.indentString=indentString;exports.indentUnit=indentUnit;exports.language=language;exports.languageDataProp=languageDataProp;exports.syntaxParserRunning=syntaxParserRunning;exports.syntaxTree=syntaxTree;exports.syntaxTreeAvailable=syntaxTreeAvailable;},{"@codemirror/state":22,"@codemirror/text":24,"@codemirror/view":27,"@lezer/common":28}],14:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});function mlLike(parserConfig){var words={'as':'keyword','do':'keyword','else':'keyword','end':'keyword','exception':'keyword','fun':'keyword','functor':'keyword','if':'keyword','in':'keyword','include':'keyword','let':'keyword','of':'keyword','open':'keyword','rec':'keyword','struct':'keyword','then':'keyword','type':'keyword','val':'keyword','while':'keyword','with':'keyword'};var extraWords=parserConfig.extraWords||{};for(var prop in extraWords){if(extraWords.hasOwnProperty(prop)){words[prop]=parserConfig.extraWords[prop];}}var hintWords=[];for(var k in words){hintWords.push(k);}function tokenBase(stream,state){var ch=stream.next();if(ch==='"'){state.tokenize=tokenString;return state.tokenize(stream,state);}if(ch==='{'){if(stream.eat('|')){state.longString=true;state.tokenize=tokenLongString;return state.tokenize(stream,state);}}if(ch==='('){if(stream.eat('*')){state.commentLevel++;state.tokenize=tokenComment;return state.tokenize(stream,state);}}if(ch==='~'||ch==='?'){stream.eatWhile(/\w/);return'variableName.special';}if(ch==='`'){stream.eatWhile(/\w/);return'quote';}if(ch==='/'&&parserConfig.slashComments&&stream.eat('/')){stream.skipToEnd();return'comment';}if(/\d/.test(ch)){if(ch==='0'&&stream.eat(/[bB]/)){stream.eatWhile(/[01]/);}if(ch==='0'&&stream.eat(/[xX]/)){stream.eatWhile(/[0-9a-fA-F]/);}if(ch==='0'&&stream.eat(/[oO]/)){stream.eatWhile(/[0-7]/);}else{stream.eatWhile(/[\d_]/);if(stream.eat('.')){stream.eatWhile(/[\d]/);}if(stream.eat(/[eE]/)){stream.eatWhile(/[\d\-+]/);}}return'number';}if(/[+\-*&%=<>!?|@\.~:]/.test(ch)){return'operator';}if(/[\w\xa1-\uffff]/.test(ch)){stream.eatWhile(/[\w\xa1-\uffff]/);var cur=stream.current();return words.hasOwnProperty(cur)?words[cur]:'variable';}return null;}function tokenString(stream,state){var next,end=false,escaped=false;while((next=stream.next())!=null){if(next==='"'&&!escaped){end=true;break;}escaped=!escaped&&next==='\\';}if(end&&!escaped){state.tokenize=tokenBase;}return'string';}function tokenComment(stream,state){var prev,next;while(state.commentLevel>0&&(next=stream.next())!=null){if(prev==='('&&next==='*')state.commentLevel++;if(prev==='*'&&next===')')state.commentLevel--;prev=next;}if(state.commentLevel<=0){state.tokenize=tokenBase;}return'comment';}function tokenLongString(stream,state){var prev,next;while(state.longString&&(next=stream.next())!=null){if(prev==='|'&&next==='}')state.longString=false;prev=next;}if(!state.longString){state.tokenize=tokenBase;}return'string';}return{startState:function startState(){return{tokenize:tokenBase,commentLevel:0,longString:false};},token:function token(stream,state){if(stream.eatSpace())return null;return state.tokenize(stream,state);},languageData:{autocomplete:hintWords,commentTokens:{line:parserConfig.slashComments?"//":undefined,block:{open:"(*",close:"*)"}}}};}var oCaml=mlLike({extraWords:{'and':'keyword','assert':'keyword','begin':'keyword','class':'keyword','constraint':'keyword','done':'keyword','downto':'keyword','external':'keyword','function':'keyword','initializer':'keyword','lazy':'keyword','match':'keyword','method':'keyword','module':'keyword','mutable':'keyword','new':'keyword','nonrec':'keyword','object':'keyword','private':'keyword','sig':'keyword','to':'keyword','try':'keyword','value':'keyword','virtual':'keyword','when':'keyword',// builtins
24482448+'raise':'builtin','failwith':'builtin','true':'builtin','false':'builtin',// Pervasives builtins
24492449+'asr':'builtin','land':'builtin','lor':'builtin','lsl':'builtin','lsr':'builtin','lxor':'builtin','mod':'builtin','or':'builtin',// More Pervasives
24502450+'raise_notrace':'builtin','trace':'builtin','exit':'builtin','print_string':'builtin','print_endline':'builtin','int':'type','float':'type','bool':'type','char':'type','string':'type','unit':'type',// Modules
24512451+'List':'builtin'}});var fSharp=mlLike({extraWords:{'abstract':'keyword','assert':'keyword','base':'keyword','begin':'keyword','class':'keyword','default':'keyword','delegate':'keyword','do!':'keyword','done':'keyword','downcast':'keyword','downto':'keyword','elif':'keyword','extern':'keyword','finally':'keyword','for':'keyword','function':'keyword','global':'keyword','inherit':'keyword','inline':'keyword','interface':'keyword','internal':'keyword','lazy':'keyword','let!':'keyword','match':'keyword','member':'keyword','module':'keyword','mutable':'keyword','namespace':'keyword','new':'keyword','null':'keyword','override':'keyword','private':'keyword','public':'keyword','return!':'keyword','return':'keyword','select':'keyword','static':'keyword','to':'keyword','try':'keyword','upcast':'keyword','use!':'keyword','use':'keyword','void':'keyword','when':'keyword','yield!':'keyword','yield':'keyword',// Reserved words
24522452+'atomic':'keyword','break':'keyword','checked':'keyword','component':'keyword','const':'keyword','constraint':'keyword','constructor':'keyword','continue':'keyword','eager':'keyword','event':'keyword','external':'keyword','fixed':'keyword','method':'keyword','mixin':'keyword','object':'keyword','parallel':'keyword','process':'keyword','protected':'keyword','pure':'keyword','sealed':'keyword','tailcall':'keyword','trait':'keyword','virtual':'keyword','volatile':'keyword',// builtins
24532453+'List':'builtin','Seq':'builtin','Map':'builtin','Set':'builtin','Option':'builtin','int':'builtin','string':'builtin','not':'builtin','true':'builtin','false':'builtin','raise':'builtin','failwith':'builtin'},slashComments:true});var sml=mlLike({extraWords:{'abstype':'keyword','and':'keyword','andalso':'keyword','case':'keyword','datatype':'keyword','fn':'keyword','handle':'keyword','infix':'keyword','infixr':'keyword','local':'keyword','nonfix':'keyword','op':'keyword','orelse':'keyword','raise':'keyword','withtype':'keyword','eqtype':'keyword','sharing':'keyword','sig':'keyword','signature':'keyword','structure':'keyword','where':'keyword','true':'keyword','false':'keyword',// types
24542454+'int':'builtin','real':'builtin','string':'builtin','char':'builtin','bool':'builtin'},slashComments:true});exports.fSharp=fSharp;exports.oCaml=oCaml;exports.sml=sml;},{}],15:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var view=require('@codemirror/view');var state=require('@codemirror/state');var tooltip=require('@codemirror/tooltip');var panel=require('@codemirror/panel');var gutter=require('@codemirror/gutter');var rangeset=require('@codemirror/rangeset');var elt=require('crelt');function _interopDefaultLegacy(e){return e&&_typeof(e)==='object'&&'default'in e?e:{'default':e};}var elt__default=/*#__PURE__*/_interopDefaultLegacy(elt);var SelectedDiagnostic=/*#__PURE__*/_createClass(function SelectedDiagnostic(from,to,diagnostic){_classCallCheck(this,SelectedDiagnostic);this.from=from;this.to=to;this.diagnostic=diagnostic;});var LintState=/*#__PURE__*/function(){function LintState(diagnostics,panel,selected){_classCallCheck(this,LintState);this.diagnostics=diagnostics;this.panel=panel;this.selected=selected;}_createClass(LintState,null,[{key:"init",value:function init(diagnostics,panel,state){var ranges=view.Decoration.set(diagnostics.map(function(d){// For zero-length ranges or ranges covering only a line break, create a widget
24552455+return d.from==d.to||d.from==d.to-1&&state.doc.lineAt(d.from).to==d.from?view.Decoration.widget({widget:new DiagnosticWidget(d),diagnostic:d}).range(d.from):view.Decoration.mark({attributes:{"class":"cm-lintRange cm-lintRange-"+d.severity},diagnostic:d}).range(d.from,d.to);}),true);return new LintState(ranges,panel,findDiagnostic(ranges));}}]);return LintState;}();function findDiagnostic(diagnostics){var diagnostic=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var after=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var found=null;diagnostics.between(after,1e9,function(from,to,_ref53){var spec=_ref53.spec;if(diagnostic&&spec.diagnostic!=diagnostic)return;found=new SelectedDiagnostic(from,to,spec.diagnostic);return false;});return found;}function maybeEnableLint(state$1,effects){return state$1.field(lintState,false)?effects:effects.concat(state.StateEffect.appendConfig.of([lintState,view.EditorView.decorations.compute([lintState],function(state){var _state$field=state.field(lintState),selected=_state$field.selected,panel=_state$field.panel;return!selected||!panel||selected.from==selected.to?view.Decoration.none:view.Decoration.set([activeMark.range(selected.from,selected.to)]);}),tooltip.hoverTooltip(lintTooltip),baseTheme]));}/**
24562456+Returns a transaction spec which updates the current set of
24572457+diagnostics, and enables the lint extension if if wasn't already
24582458+active.
24592459+*/function setDiagnostics(state,diagnostics){return{effects:maybeEnableLint(state,[setDiagnosticsEffect.of(diagnostics)])};}/**
24602460+The state effect that updates the set of active diagnostics. Can
24612461+be useful when writing an extension that needs to track these.
24622462+*/var setDiagnosticsEffect=state.StateEffect.define();var togglePanel=state.StateEffect.define();var movePanelSelection=state.StateEffect.define();var lintState=state.StateField.define({create:function create(){return new LintState(view.Decoration.none,null,null);},update:function update(value,tr){if(tr.docChanged){var mapped=value.diagnostics.map(tr.changes),selected=null;if(value.selected){var selPos=tr.changes.mapPos(value.selected.from,1);selected=findDiagnostic(mapped,value.selected.diagnostic,selPos)||findDiagnostic(mapped,null,selPos);}value=new LintState(mapped,value.panel,selected);}var _iterator143=_createForOfIteratorHelper(tr.effects),_step143;try{for(_iterator143.s();!(_step143=_iterator143.n()).done;){var effect=_step143.value;if(effect.is(setDiagnosticsEffect)){value=LintState.init(effect.value,value.panel,tr.state);}else if(effect.is(togglePanel)){value=new LintState(value.diagnostics,effect.value?LintPanel.open:null,value.selected);}else if(effect.is(movePanelSelection)){value=new LintState(value.diagnostics,value.panel,effect.value);}}}catch(err){_iterator143.e(err);}finally{_iterator143.f();}return value;},provide:function provide(f){return[panel.showPanel.from(f,function(val){return val.panel;}),view.EditorView.decorations.from(f,function(s){return s.diagnostics;})];}});/**
24632463+Returns the number of active lint diagnostics in the given state.
24642464+*/function diagnosticCount(state){var lint=state.field(lintState,false);return lint?lint.diagnostics.size:0;}var activeMark=view.Decoration.mark({"class":"cm-lintRange cm-lintRange-active"});function lintTooltip(view,pos,side){var _view$state$field=view.state.field(lintState),diagnostics=_view$state$field.diagnostics;var found=[],stackStart=2e8,stackEnd=0;diagnostics.between(pos-(side<0?1:0),pos+(side>0?1:0),function(from,to,_ref54){var spec=_ref54.spec;if(pos>=from&&pos<=to&&(from==to||(pos>from||side>0)&&(pos<to||side<0))){found.push(spec.diagnostic);stackStart=Math.min(from,stackStart);stackEnd=Math.max(to,stackEnd);}});if(!found.length)return null;return{pos:stackStart,end:stackEnd,above:view.state.doc.lineAt(stackStart).to<stackEnd,create:function create(){return{dom:diagnosticsTooltip(view,found)};}};}function diagnosticsTooltip(view,diagnostics){return elt__default['default']("ul",{"class":"cm-tooltip-lint"},diagnostics.map(function(d){return renderDiagnostic(view,d,false);}));}/**
24652465+Command to open and focus the lint panel.
24662466+*/var openLintPanel=function openLintPanel(view){var field=view.state.field(lintState,false);if(!field||!field.panel)view.dispatch({effects:maybeEnableLint(view.state,[togglePanel.of(true)])});var panel$1=panel.getPanel(view,LintPanel.open);if(panel$1)panel$1.dom.querySelector(".cm-panel-lint ul").focus();return true;};/**
24672467+Command to close the lint panel, when open.
24682468+*/var closeLintPanel=function closeLintPanel(view){var field=view.state.field(lintState,false);if(!field||!field.panel)return false;view.dispatch({effects:togglePanel.of(false)});return true;};/**
24692469+Move the selection to the next diagnostic.
24702470+*/var nextDiagnostic=function nextDiagnostic(view){var field=view.state.field(lintState,false);if(!field)return false;var sel=view.state.selection.main,next=field.diagnostics.iter(sel.to+1);if(!next.value){next=field.diagnostics.iter(0);if(!next.value||next.from==sel.from&&next.to==sel.to)return false;}view.dispatch({selection:{anchor:next.from,head:next.to},scrollIntoView:true});return true;};/**
24712471+A set of default key bindings for the lint functionality.
24722472+24732473+- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
24742474+- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
24752475+*/var lintKeymap=[{key:"Mod-Shift-m",run:openLintPanel},{key:"F8",run:nextDiagnostic}];var lintPlugin=view.ViewPlugin.fromClass(/*#__PURE__*/function(){function _class15(view){_classCallCheck(this,_class15);this.view=view;this.timeout=-1;this.set=true;var _view$state$facet=view.state.facet(lintSource),delay=_view$state$facet.delay;this.lintTime=Date.now()+delay;this.run=this.run.bind(this);this.timeout=setTimeout(this.run,delay);}_createClass(_class15,[{key:"run",value:function run(){var _this71=this;var now=Date.now();if(now<this.lintTime-10){setTimeout(this.run,this.lintTime-now);}else{this.set=false;var _state2=this.view.state,_state2$facet=_state2.facet(lintSource),sources=_state2$facet.sources;Promise.all(sources.map(function(source){return Promise.resolve(source(_this71.view));})).then(function(annotations){var _a,_b;var all=annotations.reduce(function(a,b){return a.concat(b);});if(_this71.view.state.doc==_state2.doc&&(all.length||((_b=(_a=_this71.view.state.field(lintState,false))===null||_a===void 0?void 0:_a.diagnostics)===null||_b===void 0?void 0:_b.size)))_this71.view.dispatch(setDiagnostics(_this71.view.state,all));},function(error){view.logException(_this71.view.state,error);});}}},{key:"update",value:function update(_update18){var source=_update18.state.facet(lintSource);if(_update18.docChanged||source!=_update18.startState.facet(lintSource)){this.lintTime=Date.now()+source.delay;if(!this.set){this.set=true;this.timeout=setTimeout(this.run,source.delay);}}}},{key:"force",value:function force(){if(this.set){this.lintTime=Date.now();this.run();}}},{key:"destroy",value:function destroy(){clearTimeout(this.timeout);}}]);return _class15;}());var lintSource=state.Facet.define({combine:function combine(input){return{sources:input.map(function(i){return i.source;}),delay:input.length?Math.max.apply(Math,_toConsumableArray(input.map(function(i){return i.delay;}))):750};},enables:lintPlugin});/**
24762476+Given a diagnostic source, this function returns an extension that
24772477+enables linting with that source. It will be called whenever the
24782478+editor is idle (after its content changed).
24792479+*/function linter(source){var config=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var _a;return lintSource.of({source:source,delay:(_a=config.delay)!==null&&_a!==void 0?_a:750});}/**
24802480+Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
24812481+editor is idle to run right away.
24822482+*/function forceLinting(view){var plugin=view.plugin(lintPlugin);if(plugin)plugin.force();}function assignKeys(actions){var assigned=[];if(actions){var _iterator144=_createForOfIteratorHelper(actions),_step144;try{actions:for(_iterator144.s();!(_step144=_iterator144.n()).done;){var name=_step144.value.name;var _loop15=function _loop15(_i67){var ch=name[_i67];if(/[a-zA-Z]/.test(ch)&&!assigned.some(function(c){return c.toLowerCase()==ch.toLowerCase();})){assigned.push(ch);return"continue|actions";}};for(var _i67=0;_i67<name.length;_i67++){var _ret4=_loop15(_i67);if(_ret4==="continue|actions")continue actions;}assigned.push("");}}catch(err){_iterator144.e(err);}finally{_iterator144.f();}}return assigned;}function renderDiagnostic(view,diagnostic,inPanel){var _a;var keys=inPanel?assignKeys(diagnostic.actions):[];return elt__default['default']("li",{"class":"cm-diagnostic cm-diagnostic-"+diagnostic.severity},elt__default['default']("span",{"class":"cm-diagnosticText"},diagnostic.message),(_a=diagnostic.actions)===null||_a===void 0?void 0:_a.map(function(action,i){var click=function click(e){e.preventDefault();var found=findDiagnostic(view.state.field(lintState).diagnostics,diagnostic);if(found)action.apply(view,found.from,found.to);};var name=action.name,keyIndex=keys[i]?name.indexOf(keys[i]):-1;var nameElt=keyIndex<0?name:[name.slice(0,keyIndex),elt__default['default']("u",name.slice(keyIndex,keyIndex+1)),name.slice(keyIndex+1)];return elt__default['default']("button",{type:"button","class":"cm-diagnosticAction",onclick:click,onmousedown:click,"aria-label":" Action: ".concat(name).concat(keyIndex<0?"":" (access key \"".concat(keys[i],")\""),".")},nameElt);}),diagnostic.source&&elt__default['default']("div",{"class":"cm-diagnosticSource"},diagnostic.source));}var DiagnosticWidget=/*#__PURE__*/function(_view$WidgetType3){_inherits(DiagnosticWidget,_view$WidgetType3);var _super35=_createSuper(DiagnosticWidget);function DiagnosticWidget(diagnostic){var _this72;_classCallCheck(this,DiagnosticWidget);_this72=_super35.call(this);_this72.diagnostic=diagnostic;return _this72;}_createClass(DiagnosticWidget,[{key:"eq",value:function eq(other){return other.diagnostic==this.diagnostic;}},{key:"toDOM",value:function toDOM(){return elt__default['default']("span",{"class":"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity});}}]);return DiagnosticWidget;}(view.WidgetType);var PanelItem=/*#__PURE__*/_createClass(function PanelItem(view,diagnostic){_classCallCheck(this,PanelItem);this.diagnostic=diagnostic;this.id="item_"+Math.floor(Math.random()*0xffffffff).toString(16);this.dom=renderDiagnostic(view,diagnostic,true);this.dom.id=this.id;this.dom.setAttribute("role","option");});var LintPanel=/*#__PURE__*/function(){function LintPanel(view){var _this73=this;_classCallCheck(this,LintPanel);this.view=view;this.items=[];var onkeydown=function onkeydown(event){if(event.keyCode==27){// Escape
24832483+closeLintPanel(_this73.view);_this73.view.focus();}else if(event.keyCode==38||event.keyCode==33){// ArrowUp, PageUp
24842484+_this73.moveSelection((_this73.selectedIndex-1+_this73.items.length)%_this73.items.length);}else if(event.keyCode==40||event.keyCode==34){// ArrowDown, PageDown
24852485+_this73.moveSelection((_this73.selectedIndex+1)%_this73.items.length);}else if(event.keyCode==36){// Home
24862486+_this73.moveSelection(0);}else if(event.keyCode==35){// End
24872487+_this73.moveSelection(_this73.items.length-1);}else if(event.keyCode==13){// Enter
24882488+_this73.view.focus();}else if(event.keyCode>=65&&event.keyCode<=90&&_this73.selectedIndex>=0){// A-Z
24892489+var diagnostic=_this73.items[_this73.selectedIndex].diagnostic,keys=assignKeys(diagnostic.actions);for(var _i68=0;_i68<keys.length;_i68++){if(keys[_i68].toUpperCase().charCodeAt(0)==event.keyCode){var found=findDiagnostic(_this73.view.state.field(lintState).diagnostics,diagnostic);if(found)diagnostic.actions[_i68].apply(view,found.from,found.to);}}}else{return;}event.preventDefault();};var onclick=function onclick(event){for(var _i69=0;_i69<_this73.items.length;_i69++){if(_this73.items[_i69].dom.contains(event.target))_this73.moveSelection(_i69);}};this.list=elt__default['default']("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:onkeydown,onclick:onclick});this.dom=elt__default['default']("div",{"class":"cm-panel-lint"},this.list,elt__default['default']("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:function onclick(){return closeLintPanel(_this73.view);}},"×"));this.update();}_createClass(LintPanel,[{key:"selectedIndex",get:function get(){var selected=this.view.state.field(lintState).selected;if(!selected)return-1;for(var _i70=0;_i70<this.items.length;_i70++){if(this.items[_i70].diagnostic==selected.diagnostic)return _i70;}return-1;}},{key:"update",value:function update(){var _this74=this;var _this$view$state$fiel=this.view.state.field(lintState),diagnostics=_this$view$state$fiel.diagnostics,selected=_this$view$state$fiel.selected;var i=0,needsSync=false,newSelectedItem=null;diagnostics.between(0,this.view.state.doc.length,function(_start,_end,_ref55){var spec=_ref55.spec;var found=-1,item;for(var j=i;j<_this74.items.length;j++){if(_this74.items[j].diagnostic==spec.diagnostic){found=j;break;}}if(found<0){item=new PanelItem(_this74.view,spec.diagnostic);_this74.items.splice(i,0,item);needsSync=true;}else{item=_this74.items[found];if(found>i){_this74.items.splice(i,found-i);needsSync=true;}}if(selected&&item.diagnostic==selected.diagnostic){if(!item.dom.hasAttribute("aria-selected")){item.dom.setAttribute("aria-selected","true");newSelectedItem=item;}}else if(item.dom.hasAttribute("aria-selected")){item.dom.removeAttribute("aria-selected");}i++;});while(i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0)){needsSync=true;this.items.pop();}if(this.items.length==0){this.items.push(new PanelItem(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")}));needsSync=true;}if(newSelectedItem){this.list.setAttribute("aria-activedescendant",newSelectedItem.id);this.view.requestMeasure({key:this,read:function read(){return{sel:newSelectedItem.dom.getBoundingClientRect(),panel:_this74.list.getBoundingClientRect()};},write:function write(_ref56){var sel=_ref56.sel,panel=_ref56.panel;if(sel.top<panel.top)_this74.list.scrollTop-=panel.top-sel.top;else if(sel.bottom>panel.bottom)_this74.list.scrollTop+=sel.bottom-panel.bottom;}});}else if(this.selectedIndex<0){this.list.removeAttribute("aria-activedescendant");}if(needsSync)this.sync();}},{key:"sync",value:function sync(){var domPos=this.list.firstChild;function rm(){var prev=domPos;domPos=prev.nextSibling;prev.remove();}var _iterator145=_createForOfIteratorHelper(this.items),_step145;try{for(_iterator145.s();!(_step145=_iterator145.n()).done;){var item=_step145.value;if(item.dom.parentNode==this.list){while(domPos!=item.dom){rm();}domPos=item.dom.nextSibling;}else{this.list.insertBefore(item.dom,domPos);}}}catch(err){_iterator145.e(err);}finally{_iterator145.f();}while(domPos){rm();}}},{key:"moveSelection",value:function moveSelection(selectedIndex){if(this.selectedIndex<0)return;var field=this.view.state.field(lintState);var selection=findDiagnostic(field.diagnostics,this.items[selectedIndex].diagnostic);if(!selection)return;this.view.dispatch({selection:{anchor:selection.from,head:selection.to},scrollIntoView:true,effects:movePanelSelection.of(selection)});}}],[{key:"open",value:function open(view){return new LintPanel(view);}}]);return LintPanel;}();function svg(content){var attrs=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"viewBox=\"0 0 40 40\"";return"url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" ".concat(attrs,">").concat(encodeURIComponent(content),"</svg>')");}function underline(color){return svg("<path d=\"m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0\" stroke=\"".concat(color,"\" fill=\"none\" stroke-width=\".7\"/>"),"width=\"6\" height=\"3\"");}var baseTheme=view.EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:underline("#d11")},".cm-lintRange-warning":{backgroundImage:underline("orange")},".cm-lintRange-info":{backgroundImage:underline("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});var LintGutterMarker=/*#__PURE__*/function(_gutter$GutterMarker2){_inherits(LintGutterMarker,_gutter$GutterMarker2);var _super36=_createSuper(LintGutterMarker);function LintGutterMarker(diagnostics){var _this75;_classCallCheck(this,LintGutterMarker);_this75=_super36.call(this);_this75.diagnostics=diagnostics;_this75.severity=diagnostics.reduce(function(max,d){var s=d.severity;return s=="error"||s=="warning"&&max=="info"?s:max;},"info");return _this75;}_createClass(LintGutterMarker,[{key:"toDOM",value:function toDOM(view){var _this76=this;var elt=document.createElement("div");elt.className="cm-lint-marker cm-lint-marker-"+this.severity;elt.onmouseover=function(){return gutterMarkerMouseOver(view,elt,_this76.diagnostics);};return elt;}}]);return LintGutterMarker;}(gutter.GutterMarker);function trackHoverOn(view,marker){var mousemove=function mousemove(event){var rect=marker.getBoundingClientRect();if(event.clientX>rect.left-10/* Margin */&&event.clientX<rect.right+10/* Margin */&&event.clientY>rect.top-10/* Margin */&&event.clientY<rect.bottom+10/* Margin */)return;for(var target=event.target;target;target=target.parentNode){if(target.nodeType==1&&target.classList.contains("cm-tooltip-lint"))return;}window.removeEventListener("mousemove",mousemove);if(view.state.field(lintGutterTooltip))view.dispatch({effects:setLintGutterTooltip.of(null)});};window.addEventListener("mousemove",mousemove);}function gutterMarkerMouseOver(view,marker,diagnostics){function hovered(){var line=view.visualLineAtHeight(marker.getBoundingClientRect().top+5);var linePos=view.coordsAtPos(line.from),markerRect=marker.getBoundingClientRect();if(linePos){view.dispatch({effects:setLintGutterTooltip.of({pos:line.from,above:false,create:function create(){return{dom:diagnosticsTooltip(view,diagnostics),offset:{x:markerRect.left-linePos.left,y:0}};}})});}marker.onmouseout=marker.onmousemove=null;trackHoverOn(view,marker);}var hoverTimeout=setTimeout(hovered,600/* Time */);marker.onmouseout=function(){clearTimeout(hoverTimeout);marker.onmouseout=marker.onmousemove=null;};marker.onmousemove=function(){clearTimeout(hoverTimeout);hoverTimeout=setTimeout(hovered,600/* Time */);};}function markersForDiagnostics(doc,diagnostics){var byLine=Object.create(null);var _iterator146=_createForOfIteratorHelper(diagnostics),_step146;try{for(_iterator146.s();!(_step146=_iterator146.n()).done;){var diagnostic=_step146.value;var _line5=doc.lineAt(diagnostic.from);(byLine[_line5.from]||(byLine[_line5.from]=[])).push(diagnostic);}}catch(err){_iterator146.e(err);}finally{_iterator146.f();}var markers=[];for(var line in byLine){markers.push(new LintGutterMarker(byLine[line]).range(+line));}return rangeset.RangeSet.of(markers,true);}var lintGutterExtension=gutter.gutter({"class":"cm-gutter-lint",markers:function markers(view){return view.state.field(lintGutterMarkers);}});var lintGutterMarkers=state.StateField.define({create:function create(){return rangeset.RangeSet.empty;},update:function update(markers,tr){markers=markers.map(tr.changes);var _iterator147=_createForOfIteratorHelper(tr.effects),_step147;try{for(_iterator147.s();!(_step147=_iterator147.n()).done;){var effect=_step147.value;if(effect.is(setDiagnosticsEffect)){markers=markersForDiagnostics(tr.state.doc,effect.value);}}}catch(err){_iterator147.e(err);}finally{_iterator147.f();}return markers;}});var setLintGutterTooltip=state.StateEffect.define();var lintGutterTooltip=state.StateField.define({create:function create(){return null;},update:function update(tooltip,tr){if(tooltip&&tr.docChanged)tooltip=Object.assign(Object.assign({},tooltip),{pos:tr.changes.mapPos(tooltip.pos)});return tr.effects.reduce(function(t,e){return e.is(setLintGutterTooltip)?e.value:t;},tooltip);},provide:function provide(field){return tooltip.showTooltip.from(field);}});var lintGutterTheme=view.EditorView.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:"0 .2em",display:"flex",flexDirection:"column",justifyContent:"center"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:svg("<path fill=\"#aaf\" stroke=\"#77e\" stroke-width=\"6\" stroke-linejoin=\"round\" d=\"M5 5L35 5L35 35L5 35Z\"/>")},".cm-lint-marker-warning":{content:svg("<path fill=\"#fe8\" stroke=\"#fd7\" stroke-width=\"6\" stroke-linejoin=\"round\" d=\"M20 6L37 35L3 35Z\"/>")},".cm-lint-marker-error:before":{content:svg("<circle cx=\"20\" cy=\"20\" r=\"15\" fill=\"#f87\" stroke=\"#f43\" stroke-width=\"6\"/>")}});/**
24902490+Returns an extension that installs a gutter showing markers for
24912491+each line that has diagnostics, which can be hovered over to see
24922492+the diagnostics.
24932493+*/function lintGutter(){return[lintGutterMarkers,lintGutterExtension,lintGutterTheme,lintGutterTooltip];}exports.closeLintPanel=closeLintPanel;exports.diagnosticCount=diagnosticCount;exports.forceLinting=forceLinting;exports.lintGutter=lintGutter;exports.lintKeymap=lintKeymap;exports.linter=linter;exports.nextDiagnostic=nextDiagnostic;exports.openLintPanel=openLintPanel;exports.setDiagnostics=setDiagnostics;exports.setDiagnosticsEffect=setDiagnosticsEffect;},{"@codemirror/gutter":9,"@codemirror/panel":17,"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/tooltip":26,"@codemirror/view":27,"crelt":29}],16:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var state=require('@codemirror/state');var language=require('@codemirror/language');var view=require('@codemirror/view');var common=require('@lezer/common');var baseTheme=view.EditorView.baseTheme({".cm-matchingBracket":{backgroundColor:"#328c8252"},".cm-nonmatchingBracket":{backgroundColor:"#bb555544"}});var DefaultScanDist=10000,DefaultBrackets="()[]{}";var bracketMatchingConfig=state.Facet.define({combine:function combine(configs){return state.combineConfig(configs,{afterCursor:true,brackets:DefaultBrackets,maxScanDistance:DefaultScanDist});}});var matchingMark=view.Decoration.mark({"class":"cm-matchingBracket"}),nonmatchingMark=view.Decoration.mark({"class":"cm-nonmatchingBracket"});var bracketMatchingState=state.StateField.define({create:function create(){return view.Decoration.none;},update:function update(deco,tr){if(!tr.docChanged&&!tr.selection)return deco;var decorations=[];var config=tr.state.facet(bracketMatchingConfig);var _iterator148=_createForOfIteratorHelper(tr.state.selection.ranges),_step148;try{for(_iterator148.s();!(_step148=_iterator148.n()).done;){var range=_step148.value;if(!range.empty)continue;var match=matchBrackets(tr.state,range.head,-1,config)||range.head>0&&matchBrackets(tr.state,range.head-1,1,config)||config.afterCursor&&(matchBrackets(tr.state,range.head,1,config)||range.head<tr.state.doc.length&&matchBrackets(tr.state,range.head+1,-1,config));if(!match)continue;var mark=match.matched?matchingMark:nonmatchingMark;decorations.push(mark.range(match.start.from,match.start.to));if(match.end)decorations.push(mark.range(match.end.from,match.end.to));}}catch(err){_iterator148.e(err);}finally{_iterator148.f();}return view.Decoration.set(decorations,true);},provide:function provide(f){return view.EditorView.decorations.from(f);}});var bracketMatchingUnique=[bracketMatchingState,baseTheme];/**
24942494+Create an extension that enables bracket matching. Whenever the
24952495+cursor is next to a bracket, that bracket and the one it matches
24962496+are highlighted. Or, when no matching bracket is found, another
24972497+highlighting style is used to indicate this.
24982498+*/function bracketMatching(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return[bracketMatchingConfig.of(config),bracketMatchingUnique];}function matchingNodes(node,dir,brackets){var byProp=node.prop(dir<0?common.NodeProp.openedBy:common.NodeProp.closedBy);if(byProp)return byProp;if(node.name.length==1){var index=brackets.indexOf(node.name);if(index>-1&&index%2==(dir<0?1:0))return[brackets[index+dir]];}return null;}/**
24992499+Find the matching bracket for the token at `pos`, scanning
25002500+direction `dir`. Only the `brackets` and `maxScanDistance`
25012501+properties are used from `config`, if given. Returns null if no
25022502+bracket was found at `pos`, or a match result otherwise.
25032503+*/function matchBrackets(state,pos,dir){var config=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var maxScanDistance=config.maxScanDistance||DefaultScanDist,brackets=config.brackets||DefaultBrackets;var tree=language.syntaxTree(state),node=tree.resolveInner(pos,dir);for(var cur=node;cur;cur=cur.parent){var matches=matchingNodes(cur.type,dir,brackets);if(matches&&cur.from<cur.to)return matchMarkedBrackets(state,pos,dir,cur,matches,brackets);}return matchPlainBrackets(state,pos,dir,tree,node.type,maxScanDistance,brackets);}function matchMarkedBrackets(_state,_pos,dir,token,matching,brackets){var parent=token.parent,firstToken={from:token.from,to:token.to};var depth=0,cursor=parent===null||parent===void 0?void 0:parent.cursor;if(cursor&&(dir<0?cursor.childBefore(token.from):cursor.childAfter(token.to)))do{if(dir<0?cursor.to<=token.from:cursor.from>=token.to){if(depth==0&&matching.indexOf(cursor.type.name)>-1&&cursor.from<cursor.to){return{start:firstToken,end:{from:cursor.from,to:cursor.to},matched:true};}else if(matchingNodes(cursor.type,dir,brackets)){depth++;}else if(matchingNodes(cursor.type,-dir,brackets)){depth--;if(depth==0)return{start:firstToken,end:cursor.from==cursor.to?undefined:{from:cursor.from,to:cursor.to},matched:false};}}}while(dir<0?cursor.prevSibling():cursor.nextSibling());return{start:firstToken,matched:false};}function matchPlainBrackets(state,pos,dir,tree,tokenType,maxScanDistance,brackets){var startCh=dir<0?state.sliceDoc(pos-1,pos):state.sliceDoc(pos,pos+1);var bracket=brackets.indexOf(startCh);if(bracket<0||bracket%2==0!=dir>0)return null;var startToken={from:dir<0?pos-1:pos,to:dir>0?pos+1:pos};var iter=state.doc.iterRange(pos,dir>0?state.doc.length:0),depth=0;for(var distance=0;!iter.next().done&&distance<=maxScanDistance;){var text=iter.value;if(dir<0)distance+=text.length;var basePos=pos+distance*dir;for(var _pos2=dir>0?0:text.length-1,end=dir>0?text.length:-1;_pos2!=end;_pos2+=dir){var found=brackets.indexOf(text[_pos2]);if(found<0||tree.resolve(basePos+_pos2,1).type!=tokenType)continue;if(found%2==0==dir>0){depth++;}else if(depth==1){// Closing
25042504+return{start:startToken,end:{from:basePos+_pos2,to:basePos+_pos2+1},matched:found>>1==bracket>>1};}else{depth--;}}if(dir>0)distance+=text.length;}return iter.done?{start:startToken,matched:false}:null;}exports.bracketMatching=bracketMatching;exports.matchBrackets=matchBrackets;},{"@codemirror/language":13,"@codemirror/state":22,"@codemirror/view":27,"@lezer/common":28}],17:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var view=require('@codemirror/view');var state=require('@codemirror/state');var panelConfig=state.Facet.define({combine:function combine(configs){var topContainer,bottomContainer;var _iterator149=_createForOfIteratorHelper(configs),_step149;try{for(_iterator149.s();!(_step149=_iterator149.n()).done;){var c=_step149.value;topContainer=topContainer||c.topContainer;bottomContainer=bottomContainer||c.bottomContainer;}}catch(err){_iterator149.e(err);}finally{_iterator149.f();}return{topContainer:topContainer,bottomContainer:bottomContainer};}});/**
25052505+Configures the panel-managing extension.
25062506+*/function panels(config){return config?[panelConfig.of(config)]:[];}/**
25072507+Get the active panel created by the given constructor, if any.
25082508+This can be useful when you need access to your panels' DOM
25092509+structure.
25102510+*/function getPanel(view,panel){var plugin=view.plugin(panelPlugin);var index=plugin?plugin.specs.indexOf(panel):-1;return index>-1?plugin.panels[index]:null;}var panelPlugin=view.ViewPlugin.fromClass(/*#__PURE__*/function(){function _class16(view){_classCallCheck(this,_class16);this.input=view.state.facet(showPanel);this.specs=this.input.filter(function(s){return s;});this.panels=this.specs.map(function(spec){return spec(view);});var conf=view.state.facet(panelConfig);this.top=new PanelGroup(view,true,conf.topContainer);this.bottom=new PanelGroup(view,false,conf.bottomContainer);this.top.sync(this.panels.filter(function(p){return p.top;}));this.bottom.sync(this.panels.filter(function(p){return!p.top;}));var _iterator150=_createForOfIteratorHelper(this.panels),_step150;try{for(_iterator150.s();!(_step150=_iterator150.n()).done;){var p=_step150.value;p.dom.classList.add("cm-panel");if(p.mount)p.mount();}}catch(err){_iterator150.e(err);}finally{_iterator150.f();}}_createClass(_class16,[{key:"update",value:function update(_update19){var conf=_update19.state.facet(panelConfig);if(this.top.container!=conf.topContainer){this.top.sync([]);this.top=new PanelGroup(_update19.view,true,conf.topContainer);}if(this.bottom.container!=conf.bottomContainer){this.bottom.sync([]);this.bottom=new PanelGroup(_update19.view,false,conf.bottomContainer);}this.top.syncClasses();this.bottom.syncClasses();var input=_update19.state.facet(showPanel);if(input!=this.input){var specs=input.filter(function(x){return x;});var _panels=[],top=[],bottom=[],mount=[];var _iterator151=_createForOfIteratorHelper(specs),_step151;try{for(_iterator151.s();!(_step151=_iterator151.n()).done;){var spec=_step151.value;var known=this.specs.indexOf(spec),panel=void 0;if(known<0){panel=spec(_update19.view);mount.push(panel);}else{panel=this.panels[known];if(panel.update)panel.update(_update19);}_panels.push(panel);(panel.top?top:bottom).push(panel);}}catch(err){_iterator151.e(err);}finally{_iterator151.f();}this.specs=specs;this.panels=_panels;this.top.sync(top);this.bottom.sync(bottom);for(var _i71=0,_mount=mount;_i71<_mount.length;_i71++){var p=_mount[_i71];p.dom.classList.add("cm-panel");if(p.mount)p.mount();}}else{var _iterator152=_createForOfIteratorHelper(this.panels),_step152;try{for(_iterator152.s();!(_step152=_iterator152.n()).done;){var _p3=_step152.value;if(_p3.update)_p3.update(_update19);}}catch(err){_iterator152.e(err);}finally{_iterator152.f();}}}},{key:"destroy",value:function destroy(){this.top.sync([]);this.bottom.sync([]);}}]);return _class16;}(),{provide:view.PluginField.scrollMargins.from(function(value){return{top:value.top.scrollMargin(),bottom:value.bottom.scrollMargin()};})});var PanelGroup=/*#__PURE__*/function(){function PanelGroup(view,top,container){_classCallCheck(this,PanelGroup);this.view=view;this.top=top;this.container=container;this.dom=undefined;this.classes="";this.panels=[];this.syncClasses();}_createClass(PanelGroup,[{key:"sync",value:function sync(panels){var _iterator153=_createForOfIteratorHelper(this.panels),_step153;try{for(_iterator153.s();!(_step153=_iterator153.n()).done;){var p=_step153.value;if(p.destroy&&panels.indexOf(p)<0)p.destroy();}}catch(err){_iterator153.e(err);}finally{_iterator153.f();}this.panels=panels;this.syncDOM();}},{key:"syncDOM",value:function syncDOM(){if(this.panels.length==0){if(this.dom){this.dom.remove();this.dom=undefined;}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";var parent=this.container||this.view.dom;parent.insertBefore(this.dom,this.top?parent.firstChild:null);}var curDOM=this.dom.firstChild;var _iterator154=_createForOfIteratorHelper(this.panels),_step154;try{for(_iterator154.s();!(_step154=_iterator154.n()).done;){var panel=_step154.value;if(panel.dom.parentNode==this.dom){while(curDOM!=panel.dom){curDOM=rm(curDOM);}curDOM=curDOM.nextSibling;}else{this.dom.insertBefore(panel.dom,curDOM);}}}catch(err){_iterator154.e(err);}finally{_iterator154.f();}while(curDOM){curDOM=rm(curDOM);}}},{key:"scrollMargin",value:function 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);}},{key:"syncClasses",value:function syncClasses(){if(!this.container||this.classes==this.view.themeClasses)return;var _iterator155=_createForOfIteratorHelper(this.classes.split(" ")),_step155;try{for(_iterator155.s();!(_step155=_iterator155.n()).done;){var cls=_step155.value;if(cls)this.container.classList.remove(cls);}}catch(err){_iterator155.e(err);}finally{_iterator155.f();}var _iterator156=_createForOfIteratorHelper((this.classes=this.view.themeClasses).split(" ")),_step156;try{for(_iterator156.s();!(_step156=_iterator156.n()).done;){var _cls=_step156.value;if(_cls)this.container.classList.add(_cls);}}catch(err){_iterator156.e(err);}finally{_iterator156.f();}}}]);return PanelGroup;}();function rm(node){var next=node.nextSibling;node.remove();return next;}var baseTheme=view.EditorView.baseTheme({".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"}});/**
25112511+Opening a panel is done by providing a constructor function for
25122512+the panel through this facet. (The panel is closed again when its
25132513+constructor is no longer provided.) Values of `null` are ignored.
25142514+*/var showPanel=state.Facet.define({enables:[panelPlugin,baseTheme]});exports.getPanel=getPanel;exports.panels=panels;exports.showPanel=showPanel;},{"@codemirror/state":22,"@codemirror/view":27}],18:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var state=require('@codemirror/state');/**
25152515+Each range is associated with a value, which must inherit from
25162516+this class.
25172517+*/var RangeValue=/*#__PURE__*/function(){function RangeValue(){_classCallCheck(this,RangeValue);}_createClass(RangeValue,[{key:"eq",value:/**
25182518+ Compare this value with another value. The default
25192519+ implementation compares by identity.
25202520+ */function eq(other){return this==other;}/**
25212521+ Create a [range](https://codemirror.net/6/docs/ref/#rangeset.Range) with this value.
25222522+ */},{key:"range",value:function range(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:from;return new Range(from,to,this);}}]);return RangeValue;}();RangeValue.prototype.startSide=RangeValue.prototype.endSide=0;RangeValue.prototype.point=false;RangeValue.prototype.mapMode=state.MapMode.TrackDel;/**
25232523+A range associates a value with a range of positions.
25242524+*/var Range=/*#__PURE__*/_createClass(/**
25252525+ @internal
25262526+ */function Range(/**
25272527+ The range's start position.
25282528+ */from,/**
25292529+ Its end position.
25302530+ */to,/**
25312531+ The value associated with this range.
25322532+ */value){_classCallCheck(this,Range);this.from=from;this.to=to;this.value=value;});function cmpRange(a,b){return a.from-b.from||a.value.startSide-b.value.startSide;}var Chunk=/*#__PURE__*/function(){function Chunk(from,to,value,// Chunks are marked with the largest point that occurs
25332533+// in them (or -1 for no points), so that scans that are
25342534+// only interested in points (such as the
25352535+// heightmap-related logic) can skip range-only chunks.
25362536+maxPoint){_classCallCheck(this,Chunk);this.from=from;this.to=to;this.value=value;this.maxPoint=maxPoint;}_createClass(Chunk,[{key:"length",get:function get(){return this.to[this.to.length-1];}// Find the index of the given position and side. Use the ranges'
25372537+// `from` pos when `end == false`, `to` when `end == true`.
25382538+},{key:"findIndex",value:function findIndex(pos,side,end){var startAt=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;var arr=end?this.to:this.from;for(var lo=startAt,hi=arr.length;;){if(lo==hi)return lo;var mid=lo+hi>>1;var diff=arr[mid]-pos||(end?this.value[mid].endSide:this.value[mid].startSide)-side;if(mid==lo)return diff>=0?lo:hi;if(diff>=0)hi=mid;else lo=mid+1;}}},{key:"between",value:function between(offset,from,to,f){for(var _i72=this.findIndex(from,-1000000000/* Far */,true),e=this.findIndex(to,1000000000/* Far */,false,_i72);_i72<e;_i72++){if(f(this.from[_i72]+offset,this.to[_i72]+offset,this.value[_i72])===false)return false;}}},{key:"map",value:function map(offset,changes){var value=[],from=[],to=[],newPos=-1,maxPoint=-1;for(var _i73=0;_i73<this.value.length;_i73++){var val=this.value[_i73],curFrom=this.from[_i73]+offset,curTo=this.to[_i73]+offset,newFrom=void 0,newTo=void 0;if(curFrom==curTo){var mapped=changes.mapPos(curFrom,val.startSide,val.mapMode);if(mapped==null)continue;newFrom=newTo=mapped;if(val.startSide!=val.endSide){newTo=changes.mapPos(curFrom,val.endSide);if(newTo<newFrom)continue;}}else{newFrom=changes.mapPos(curFrom,val.startSide);newTo=changes.mapPos(curTo,val.endSide);if(newFrom>newTo||newFrom==newTo&&val.startSide>0&&val.endSide<=0)continue;}if((newTo-newFrom||val.endSide-val.startSide)<0)continue;if(newPos<0)newPos=newFrom;if(val.point)maxPoint=Math.max(maxPoint,newTo-newFrom);value.push(val);from.push(newFrom-newPos);to.push(newTo-newPos);}return{mapped:value.length?new Chunk(from,to,value,maxPoint):null,pos:newPos};}}]);return Chunk;}();/**
25392539+A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#rangeset.Range) in a
25402540+way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#rangeset.RangeSet.map) and
25412541+[update](https://codemirror.net/6/docs/ref/#rangeset.RangeSet.update). This is an immutable data
25422542+structure.
25432543+*/var RangeSet=/*#__PURE__*/function(){/**
25442544+ @internal
25452545+ */function RangeSet(/**
25462546+ @internal
25472547+ */chunkPos,/**
25482548+ @internal
25492549+ */chunk){var nextLayer=arguments.length>2&&arguments[2]!==undefined?arguments[2]:RangeSet.empty;var/**
25502550+ @internal
25512551+ */maxPoint=arguments.length>3?arguments[3]:undefined;_classCallCheck(this,RangeSet);this.chunkPos=chunkPos;this.chunk=chunk;this.nextLayer=nextLayer;this.maxPoint=maxPoint;}/**
25522552+ @internal
25532553+ */_createClass(RangeSet,[{key:"length",get:function get(){var last=this.chunk.length-1;return last<0?0:Math.max(this.chunkEnd(last),this.nextLayer.length);}/**
25542554+ The number of ranges in the set.
25552555+ */},{key:"size",get:function get(){if(this.isEmpty)return 0;var size=this.nextLayer.size;var _iterator157=_createForOfIteratorHelper(this.chunk),_step157;try{for(_iterator157.s();!(_step157=_iterator157.n()).done;){var chunk=_step157.value;size+=chunk.value.length;}}catch(err){_iterator157.e(err);}finally{_iterator157.f();}return size;}/**
25562556+ @internal
25572557+ */},{key:"chunkEnd",value:function chunkEnd(index){return this.chunkPos[index]+this.chunk[index].length;}/**
25582558+ Update the range set, optionally adding new ranges or filtering
25592559+ out existing ones.
25602560+25612561+ (The extra type parameter is just there as a kludge to work
25622562+ around TypeScript variance issues that prevented `RangeSet<X>`
25632563+ from being a subtype of `RangeSet<Y>` when `X` is a subtype of
25642564+ `Y`.)
25652565+ */},{key:"update",value:function update(updateSpec){var _updateSpec$add=updateSpec.add,add=_updateSpec$add===void 0?[]:_updateSpec$add,_updateSpec$sort=updateSpec.sort,sort=_updateSpec$sort===void 0?false:_updateSpec$sort,_updateSpec$filterFro=updateSpec.filterFrom,filterFrom=_updateSpec$filterFro===void 0?0:_updateSpec$filterFro,_updateSpec$filterTo=updateSpec.filterTo,filterTo=_updateSpec$filterTo===void 0?this.length:_updateSpec$filterTo;var filter=updateSpec.filter;if(add.length==0&&!filter)return this;if(sort)add.slice().sort(cmpRange);if(this.isEmpty)return add.length?RangeSet.of(add):this;var cur=new LayerCursor(this,null,-1)["goto"](0),i=0,spill=[];var builder=new RangeSetBuilder();while(cur.value||i<add.length){if(i<add.length&&(cur.from-add[i].from||cur.startSide-add[i].value.startSide)>=0){var range=add[i++];if(!builder.addInner(range.from,range.to,range.value))spill.push(range);}else if(cur.rangeIndex==1&&cur.chunkIndex<this.chunk.length&&(i==add.length||this.chunkEnd(cur.chunkIndex)<add[i].from)&&(!filter||filterFrom>this.chunkEnd(cur.chunkIndex)||filterTo<this.chunkPos[cur.chunkIndex])&&builder.addChunk(this.chunkPos[cur.chunkIndex],this.chunk[cur.chunkIndex])){cur.nextChunk();}else{if(!filter||filterFrom>cur.to||filterTo<cur.from||filter(cur.from,cur.to,cur.value)){if(!builder.addInner(cur.from,cur.to,cur.value))spill.push(new Range(cur.from,cur.to,cur.value));}cur.next();}}return builder.finishInner(this.nextLayer.isEmpty&&!spill.length?RangeSet.empty:this.nextLayer.update({add:spill,filter:filter,filterFrom:filterFrom,filterTo:filterTo}));}/**
25662566+ Map this range set through a set of changes, return the new set.
25672567+ */},{key:"map",value:function map(changes){if(changes.length==0||this.isEmpty)return this;var chunks=[],chunkPos=[],maxPoint=-1;for(var _i74=0;_i74<this.chunk.length;_i74++){var start=this.chunkPos[_i74],chunk=this.chunk[_i74];var touch=changes.touchesRange(start,start+chunk.length);if(touch===false){maxPoint=Math.max(maxPoint,chunk.maxPoint);chunks.push(chunk);chunkPos.push(changes.mapPos(start));}else if(touch===true){var _chunk$map=chunk.map(start,changes),mapped=_chunk$map.mapped,pos=_chunk$map.pos;if(mapped){maxPoint=Math.max(maxPoint,mapped.maxPoint);chunks.push(mapped);chunkPos.push(pos);}}}var next=this.nextLayer.map(changes);return chunks.length==0?next:new RangeSet(chunkPos,chunks,next,maxPoint);}/**
25682568+ Iterate over the ranges that touch the region `from` to `to`,
25692569+ calling `f` for each. There is no guarantee that the ranges will
25702570+ be reported in any specific order. When the callback returns
25712571+ `false`, iteration stops.
25722572+ */},{key:"between",value:function between(from,to,f){if(this.isEmpty)return;for(var _i75=0;_i75<this.chunk.length;_i75++){var start=this.chunkPos[_i75],chunk=this.chunk[_i75];if(to>=start&&from<=start+chunk.length&&chunk.between(start,from-start,to-start,f)===false)return;}this.nextLayer.between(from,to,f);}/**
25732573+ Iterate over the ranges in this set, in order, including all
25742574+ ranges that end at or after `from`.
25752575+ */},{key:"iter",value:function iter(){var from=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;return HeapCursor.from([this])["goto"](from);}/**
25762576+ @internal
25772577+ */},{key:"isEmpty",get:function get(){return this.nextLayer==this;}/**
25782578+ Iterate over the ranges in a collection of sets, in order,
25792579+ starting from `from`.
25802580+ */}],[{key:"iter",value:function iter(sets){var from=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return HeapCursor.from(sets)["goto"](from);}/**
25812581+ Iterate over two groups of sets, calling methods on `comparator`
25822582+ to notify it of possible differences.
25832583+ */},{key:"compare",value:function compare(oldSets,newSets,/**
25842584+ This indicates how the underlying data changed between these
25852585+ ranges, and is needed to synchronize the iteration. `from` and
25862586+ `to` are coordinates in the _new_ space, after these changes.
25872587+ */textDiff,comparator){var minPointSize=arguments.length>4&&arguments[4]!==undefined?arguments[4]:-1;var a=oldSets.filter(function(set){return set.maxPoint>0||!set.isEmpty&&set.maxPoint>=minPointSize;});var b=newSets.filter(function(set){return set.maxPoint>0||!set.isEmpty&&set.maxPoint>=minPointSize;});var sharedChunks=findSharedChunks(a,b,textDiff);var sideA=new SpanCursor(a,sharedChunks,minPointSize);var sideB=new SpanCursor(b,sharedChunks,minPointSize);textDiff.iterGaps(function(fromA,fromB,length){return _compare(sideA,fromA,sideB,fromB,length,comparator);});if(textDiff.empty&&textDiff.length==0)_compare(sideA,0,sideB,0,0,comparator);}/**
25882588+ Compare the contents of two groups of range sets, returning true
25892589+ if they are equivalent in the given range.
25902590+ */},{key:"eq",value:function eq(oldSets,newSets){var from=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var to=arguments.length>3?arguments[3]:undefined;if(to==null)to=1000000000/* Far */;var a=oldSets.filter(function(set){return!set.isEmpty&&newSets.indexOf(set)<0;});var b=newSets.filter(function(set){return!set.isEmpty&&oldSets.indexOf(set)<0;});if(a.length!=b.length)return false;if(!a.length)return true;var sharedChunks=findSharedChunks(a,b);var sideA=new SpanCursor(a,sharedChunks,0)["goto"](from),sideB=new SpanCursor(b,sharedChunks,0)["goto"](from);for(;;){if(sideA.to!=sideB.to||!sameValues(sideA.active,sideB.active)||sideA.point&&(!sideB.point||!sideA.point.eq(sideB.point)))return false;if(sideA.to>to)return true;sideA.next();sideB.next();}}/**
25912591+ Iterate over a group of range sets at the same time, notifying
25922592+ the iterator about the ranges covering every given piece of
25932593+ content. Returns the open count (see
25942594+ [`SpanIterator.span`](https://codemirror.net/6/docs/ref/#rangeset.SpanIterator.span)) at the end
25952595+ of the iteration.
25962596+ */},{key:"spans",value:function spans(sets,from,to,iterator){var minPointSize=arguments.length>4&&arguments[4]!==undefined?arguments[4]:-1;var _a;var cursor=new SpanCursor(sets,null,minPointSize,(_a=iterator.filterPoint)===null||_a===void 0?void 0:_a.bind(iterator))["goto"](from),pos=from;var open=cursor.openStart;for(;;){var curTo=Math.min(cursor.to,to);if(cursor.point){iterator.point(pos,curTo,cursor.point,cursor.activeForPoint(cursor.to),open);open=cursor.openEnd(curTo)+(cursor.to>curTo?1:0);}else if(curTo>pos){iterator.span(pos,curTo,cursor.active,open);open=cursor.openEnd(curTo);}if(cursor.to>to)break;pos=cursor.to;cursor.next();}return open;}/**
25972597+ Create a range set for the given range or array of ranges. By
25982598+ default, this expects the ranges to be _sorted_ (by start
25992599+ position and, if two start at the same position,
26002600+ `value.startSide`). You can pass `true` as second argument to
26012601+ cause the method to sort them.
26022602+ */},{key:"of",value:function of(ranges){var sort=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var build=new RangeSetBuilder();var _iterator158=_createForOfIteratorHelper(ranges instanceof Range?[ranges]:sort?lazySort(ranges):ranges),_step158;try{for(_iterator158.s();!(_step158=_iterator158.n()).done;){var range=_step158.value;build.add(range.from,range.to,range.value);}}catch(err){_iterator158.e(err);}finally{_iterator158.f();}return build.finish();}}]);return RangeSet;}();/**
26032603+The empty set of ranges.
26042604+*/RangeSet.empty=new RangeSet([],[],null,-1);function lazySort(ranges){if(ranges.length>1)for(var prev=ranges[0],_i76=1;_i76<ranges.length;_i76++){var cur=ranges[_i76];if(cmpRange(prev,cur)>0)return ranges.slice().sort(cmpRange);prev=cur;}return ranges;}RangeSet.empty.nextLayer=RangeSet.empty;/**
26052605+A range set builder is a data structure that helps build up a
26062606+[range set](https://codemirror.net/6/docs/ref/#rangeset.RangeSet) directly, without first allocating
26072607+an array of [`Range`](https://codemirror.net/6/docs/ref/#rangeset.Range) objects.
26082608+*/var RangeSetBuilder=/*#__PURE__*/function(){/**
26092609+ Create an empty builder.
26102610+ */function RangeSetBuilder(){_classCallCheck(this,RangeSetBuilder);this.chunks=[];this.chunkPos=[];this.chunkStart=-1;this.last=null;this.lastFrom=-1000000000/* Far */;this.lastTo=-1000000000/* Far */;this.from=[];this.to=[];this.value=[];this.maxPoint=-1;this.setMaxPoint=-1;this.nextLayer=null;}_createClass(RangeSetBuilder,[{key:"finishChunk",value:function finishChunk(newArrays){this.chunks.push(new Chunk(this.from,this.to,this.value,this.maxPoint));this.chunkPos.push(this.chunkStart);this.chunkStart=-1;this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint);this.maxPoint=-1;if(newArrays){this.from=[];this.to=[];this.value=[];}}/**
26112611+ Add a range. Ranges should be added in sorted (by `from` and
26122612+ `value.startSide`) order.
26132613+ */},{key:"add",value:function add(from,to,value){if(!this.addInner(from,to,value))(this.nextLayer||(this.nextLayer=new RangeSetBuilder())).add(from,to,value);}/**
26142614+ @internal
26152615+ */},{key:"addInner",value:function addInner(from,to,value){var diff=from-this.lastTo||value.startSide-this.last.endSide;if(diff<=0&&(from-this.lastFrom||value.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");if(diff<0)return false;if(this.from.length==250/* ChunkSize */)this.finishChunk(true);if(this.chunkStart<0)this.chunkStart=from;this.from.push(from-this.chunkStart);this.to.push(to-this.chunkStart);this.last=value;this.lastFrom=from;this.lastTo=to;this.value.push(value);if(value.point)this.maxPoint=Math.max(this.maxPoint,to-from);return true;}/**
26162616+ @internal
26172617+ */},{key:"addChunk",value:function addChunk(from,chunk){if((from-this.lastTo||chunk.value[0].startSide-this.last.endSide)<0)return false;if(this.from.length)this.finishChunk(true);this.setMaxPoint=Math.max(this.setMaxPoint,chunk.maxPoint);this.chunks.push(chunk);this.chunkPos.push(from);var last=chunk.value.length-1;this.last=chunk.value[last];this.lastFrom=chunk.from[last]+from;this.lastTo=chunk.to[last]+from;return true;}/**
26182618+ Finish the range set. Returns the new set. The builder can't be
26192619+ used anymore after this has been called.
26202620+ */},{key:"finish",value:function finish(){return this.finishInner(RangeSet.empty);}/**
26212621+ @internal
26222622+ */},{key:"finishInner",value:function finishInner(next){if(this.from.length)this.finishChunk(false);if(this.chunks.length==0)return next;var result=new RangeSet(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(next):next,this.setMaxPoint);this.from=null;// Make sure further `add` calls produce errors
26232623+return result;}}]);return RangeSetBuilder;}();function findSharedChunks(a,b,textDiff){var inA=new Map();var _iterator159=_createForOfIteratorHelper(a),_step159;try{for(_iterator159.s();!(_step159=_iterator159.n()).done;){var set=_step159.value;for(var _i77=0;_i77<set.chunk.length;_i77++){if(set.chunk[_i77].maxPoint<=0)inA.set(set.chunk[_i77],set.chunkPos[_i77]);}}}catch(err){_iterator159.e(err);}finally{_iterator159.f();}var shared=new Set();var _iterator160=_createForOfIteratorHelper(b),_step160;try{for(_iterator160.s();!(_step160=_iterator160.n()).done;){var _set=_step160.value;for(var _i78=0;_i78<_set.chunk.length;_i78++){var known=inA.get(_set.chunk[_i78]);if(known!=null&&(textDiff?textDiff.mapPos(known):known)==_set.chunkPos[_i78]&&!(textDiff===null||textDiff===void 0?void 0:textDiff.touchesRange(known,known+_set.chunk[_i78].length)))shared.add(_set.chunk[_i78]);}}}catch(err){_iterator160.e(err);}finally{_iterator160.f();}return shared;}var LayerCursor=/*#__PURE__*/function(){function LayerCursor(layer,skip,minPoint){var rank=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;_classCallCheck(this,LayerCursor);this.layer=layer;this.skip=skip;this.minPoint=minPoint;this.rank=rank;}_createClass(LayerCursor,[{key:"startSide",get:function get(){return this.value?this.value.startSide:0;}},{key:"endSide",get:function get(){return this.value?this.value.endSide:0;}},{key:"goto",value:function goto(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:-1000000000;this.chunkIndex=this.rangeIndex=0;this.gotoInner(pos,side,false);return this;}},{key:"gotoInner",value:function gotoInner(pos,side,forward){while(this.chunkIndex<this.layer.chunk.length){var next=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(next)||this.layer.chunkEnd(this.chunkIndex)<pos||next.maxPoint<this.minPoint))break;this.chunkIndex++;forward=false;}if(this.chunkIndex<this.layer.chunk.length){var rangeIndex=this.layer.chunk[this.chunkIndex].findIndex(pos-this.layer.chunkPos[this.chunkIndex],side,true);if(!forward||this.rangeIndex<rangeIndex)this.setRangeIndex(rangeIndex);}this.next();}},{key:"forward",value:function forward(pos,side){if((this.to-pos||this.endSide-side)<0)this.gotoInner(pos,side,true);}},{key:"next",value:function next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1000000000/* Far */;this.value=null;break;}else{var chunkPos=this.layer.chunkPos[this.chunkIndex],chunk=this.layer.chunk[this.chunkIndex];var from=chunkPos+chunk.from[this.rangeIndex];this.from=from;this.to=chunkPos+chunk.to[this.rangeIndex];this.value=chunk.value[this.rangeIndex];this.setRangeIndex(this.rangeIndex+1);if(this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break;}}}},{key:"setRangeIndex",value:function setRangeIndex(index){if(index==this.layer.chunk[this.chunkIndex].value.length){this.chunkIndex++;if(this.skip){while(this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex])){this.chunkIndex++;}}this.rangeIndex=0;}else{this.rangeIndex=index;}}},{key:"nextChunk",value:function nextChunk(){this.chunkIndex++;this.rangeIndex=0;this.next();}},{key:"compare",value:function compare(other){return this.from-other.from||this.startSide-other.startSide||this.to-other.to||this.endSide-other.endSide;}}]);return LayerCursor;}();var HeapCursor=/*#__PURE__*/function(){function HeapCursor(heap){_classCallCheck(this,HeapCursor);this.heap=heap;}_createClass(HeapCursor,[{key:"startSide",get:function get(){return this.value?this.value.startSide:0;}},{key:"goto",value:function goto(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:-1000000000;var _iterator161=_createForOfIteratorHelper(this.heap),_step161;try{for(_iterator161.s();!(_step161=_iterator161.n()).done;){var cur=_step161.value;cur["goto"](pos,side);}}catch(err){_iterator161.e(err);}finally{_iterator161.f();}for(var _i79=this.heap.length>>1;_i79>=0;_i79--){heapBubble(this.heap,_i79);}this.next();return this;}},{key:"forward",value:function forward(pos,side){var _iterator162=_createForOfIteratorHelper(this.heap),_step162;try{for(_iterator162.s();!(_step162=_iterator162.n()).done;){var cur=_step162.value;cur.forward(pos,side);}}catch(err){_iterator162.e(err);}finally{_iterator162.f();}for(var _i80=this.heap.length>>1;_i80>=0;_i80--){heapBubble(this.heap,_i80);}if((this.to-pos||this.value.endSide-side)<0)this.next();}},{key:"next",value:function next(){if(this.heap.length==0){this.from=this.to=1000000000/* Far */;this.value=null;this.rank=-1;}else{var top=this.heap[0];this.from=top.from;this.to=top.to;this.value=top.value;this.rank=top.rank;if(top.value)top.next();heapBubble(this.heap,0);}}}],[{key:"from",value:function from(sets){var skip=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var minPoint=arguments.length>2&&arguments[2]!==undefined?arguments[2]:-1;var heap=[];for(var _i81=0;_i81<sets.length;_i81++){for(var cur=sets[_i81];!cur.isEmpty;cur=cur.nextLayer){if(cur.maxPoint>=minPoint)heap.push(new LayerCursor(cur,skip,minPoint,_i81));}}return heap.length==1?heap[0]:new HeapCursor(heap);}}]);return HeapCursor;}();function heapBubble(heap,index){for(var cur=heap[index];;){var childIndex=(index<<1)+1;if(childIndex>=heap.length)break;var child=heap[childIndex];if(childIndex+1<heap.length&&child.compare(heap[childIndex+1])>=0){child=heap[childIndex+1];childIndex++;}if(cur.compare(child)<0)break;heap[childIndex]=cur;heap[index]=child;index=childIndex;}}var SpanCursor=/*#__PURE__*/function(){function SpanCursor(sets,skip,minPoint){var filterPoint=arguments.length>3&&arguments[3]!==undefined?arguments[3]:function(){return true;};_classCallCheck(this,SpanCursor);this.minPoint=minPoint;this.filterPoint=filterPoint;this.active=[];this.activeTo=[];this.activeRank=[];this.minActive=-1;// A currently active point range, if any
26242624+this.point=null;this.pointFrom=0;this.pointRank=0;this.to=-1000000000/* Far */;this.endSide=0;this.openStart=-1;this.cursor=HeapCursor.from(sets,skip,minPoint);}_createClass(SpanCursor,[{key:"goto",value:function goto(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:-1000000000;this.cursor["goto"](pos,side);this.active.length=this.activeTo.length=this.activeRank.length=0;this.minActive=-1;this.to=pos;this.endSide=side;this.openStart=-1;this.next();return this;}},{key:"forward",value:function forward(pos,side){while(this.minActive>-1&&(this.activeTo[this.minActive]-pos||this.active[this.minActive].endSide-side)<0){this.removeActive(this.minActive);}this.cursor.forward(pos,side);}},{key:"removeActive",value:function removeActive(index){remove(this.active,index);remove(this.activeTo,index);remove(this.activeRank,index);this.minActive=findMinIndex(this.active,this.activeTo);}},{key:"addActive",value:function addActive(trackOpen){var i=0,_this$cursor=this.cursor,value=_this$cursor.value,to=_this$cursor.to,rank=_this$cursor.rank;while(i<this.activeRank.length&&this.activeRank[i]<=rank){i++;}insert(this.active,i,value);insert(this.activeTo,i,to);insert(this.activeRank,i,rank);if(trackOpen)insert(trackOpen,i,this.cursor.from);this.minActive=findMinIndex(this.active,this.activeTo);}// After calling this, if `this.point` != null, the next range is a
26252625+// point. Otherwise, it's a regular range, covered by `this.active`.
26262626+},{key:"next",value:function next(){var from=this.to,wasPoint=this.point;this.point=null;var trackOpen=this.openStart<0?[]:null,trackExtra=0;for(;;){var a=this.minActive;if(a>-1&&(this.activeTo[a]-this.cursor.from||this.active[a].endSide-this.cursor.startSide)<0){if(this.activeTo[a]>from){this.to=this.activeTo[a];this.endSide=this.active[a].endSide;break;}this.removeActive(a);if(trackOpen)remove(trackOpen,a);}else if(!this.cursor.value){this.to=this.endSide=1000000000/* Far */;break;}else if(this.cursor.from>from){this.to=this.cursor.from;this.endSide=this.cursor.startSide;break;}else{var nextVal=this.cursor.value;if(!nextVal.point){// Opening a range
26272627+this.addActive(trackOpen);this.cursor.next();}else if(wasPoint&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to){// Ignore any non-empty points that end precisely at the end of the prev point
26282628+this.cursor.next();}else if(!this.filterPoint(this.cursor.from,this.cursor.to,this.cursor.value,this.cursor.rank)){this.cursor.next();}else{// New point
26292629+this.point=nextVal;this.pointFrom=this.cursor.from;this.pointRank=this.cursor.rank;this.to=this.cursor.to;this.endSide=nextVal.endSide;if(this.cursor.from<from)trackExtra=1;this.cursor.next();if(this.to>from)this.forward(this.to,this.endSide);break;}}}if(trackOpen){var openStart=0;while(openStart<trackOpen.length&&trackOpen[openStart]<from){openStart++;}this.openStart=openStart+trackExtra;}}},{key:"activeForPoint",value:function activeForPoint(to){if(!this.active.length)return this.active;var active=[];for(var _i82=this.active.length-1;_i82>=0;_i82--){if(this.activeRank[_i82]<this.pointRank)break;if(this.activeTo[_i82]>to||this.activeTo[_i82]==to&&this.active[_i82].endSide>=this.point.endSide)active.push(this.active[_i82]);}return active.reverse();}},{key:"openEnd",value:function openEnd(to){var open=0;for(var _i83=this.activeTo.length-1;_i83>=0&&this.activeTo[_i83]>to;_i83--){open++;}return open;}}]);return SpanCursor;}();function _compare(a,startA,b,startB,length,comparator){a["goto"](startA);b["goto"](startB);var endB=startB+length;var pos=startB,dPos=startB-startA;for(;;){var diff=a.to+dPos-b.to||a.endSide-b.endSide;var end=diff<0?a.to+dPos:b.to,clipEnd=Math.min(end,endB);if(a.point||b.point){if(!(a.point&&b.point&&(a.point==b.point||a.point.eq(b.point))&&sameValues(a.activeForPoint(a.to+dPos),b.activeForPoint(b.to))))comparator.comparePoint(pos,clipEnd,a.point,b.point);}else{if(clipEnd>pos&&!sameValues(a.active,b.active))comparator.compareRange(pos,clipEnd,a.active,b.active);}if(end>endB)break;pos=end;if(diff<=0)a.next();if(diff>=0)b.next();}}function sameValues(a,b){if(a.length!=b.length)return false;for(var _i84=0;_i84<a.length;_i84++){if(a[_i84]!=b[_i84]&&!a[_i84].eq(b[_i84]))return false;}return true;}function remove(array,index){for(var _i85=index,e=array.length-1;_i85<e;_i85++){array[_i85]=array[_i85+1];}array.pop();}function insert(array,index,value){for(var _i86=array.length-1;_i86>=index;_i86--){array[_i86+1]=array[_i86];}array[index]=value;}function findMinIndex(value,array){var found=-1,foundPos=1000000000/* Far */;for(var _i87=0;_i87<array.length;_i87++){if((array[_i87]-foundPos||value[_i87].endSide-value[found].endSide)<0){found=_i87;foundPos=array[_i87];}}return found;}exports.Range=Range;exports.RangeSet=RangeSet;exports.RangeSetBuilder=RangeSetBuilder;exports.RangeValue=RangeValue;},{"@codemirror/state":22}],19:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var state=require('@codemirror/state');var view=require('@codemirror/view');var text=require('@codemirror/text');// Don't compute precise column positions for line offsets above this
26302630+// (since it could get expensive). Assume offset==column for them.
26312631+var MaxOff=2000;function rectangleFor(state$1,a,b){var startLine=Math.min(a.line,b.line),endLine=Math.max(a.line,b.line);var ranges=[];if(a.off>MaxOff||b.off>MaxOff||a.col<0||b.col<0){var startOff=Math.min(a.off,b.off),endOff=Math.max(a.off,b.off);for(var _i88=startLine;_i88<=endLine;_i88++){var line=state$1.doc.line(_i88);if(line.length<=endOff)ranges.push(state.EditorSelection.range(line.from+startOff,line.to+endOff));}}else{var startCol=Math.min(a.col,b.col),endCol=Math.max(a.col,b.col);for(var _i89=startLine;_i89<=endLine;_i89++){var _line6=state$1.doc.line(_i89);var start=text.findColumn(_line6.text,startCol,state$1.tabSize,true);if(start>-1){var end=text.findColumn(_line6.text,endCol,state$1.tabSize);ranges.push(state.EditorSelection.range(_line6.from+start,_line6.from+end));}}}return ranges;}function absoluteColumn(view,x){var ref=view.coordsAtPos(view.viewport.from);return ref?Math.round(Math.abs((ref.left-x)/view.defaultCharacterWidth)):-1;}function getPos(view,event){var offset=view.posAtCoords({x:event.clientX,y:event.clientY},false);var line=view.state.doc.lineAt(offset),off=offset-line.from;var col=off>MaxOff?-1:off==line.length?absoluteColumn(view,event.clientX):text.countColumn(line.text,view.state.tabSize,offset-line.from);return{line:line.number,col:col,off:off};}function rectangleSelectionStyle(view,event){var start=getPos(view,event),startSel=view.state.selection;if(!start)return null;return{update:function update(_update20){if(_update20.docChanged){var newStart=_update20.changes.mapPos(_update20.startState.doc.line(start.line).from);var newLine=_update20.state.doc.lineAt(newStart);start={line:newLine.number,col:start.col,off:Math.min(start.off,newLine.length)};startSel=startSel.map(_update20.changes);}},get:function get(event,_extend,multiple){var cur=getPos(view,event);if(!cur)return startSel;var ranges=rectangleFor(view.state,start,cur);if(!ranges.length)return startSel;if(multiple)return state.EditorSelection.create(ranges.concat(startSel.ranges));else return state.EditorSelection.create(ranges);}};}/**
26322632+Create an extension that enables rectangular selections. By
26332633+default, it will react to left mouse drag with the Alt key held
26342634+down. When such a selection occurs, the text within the rectangle
26352635+that was dragged over will be selected, as one selection
26362636+[range](https://codemirror.net/6/docs/ref/#state.SelectionRange) per line.
26372637+*/function rectangularSelection(options){var filter=(options===null||options===void 0?void 0:options.eventFilter)||function(e){return e.altKey&&e.button==0;};return view.EditorView.mouseSelectionStyle.of(function(view,event){return filter(event)?rectangleSelectionStyle(view,event):null;});}exports.rectangularSelection=rectangularSelection;},{"@codemirror/state":22,"@codemirror/text":24,"@codemirror/view":27}],20:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var view=require('@codemirror/view');var state=require('@codemirror/state');var panel=require('@codemirror/panel');var rangeset=require('@codemirror/rangeset');var elt=require('crelt');var text=require('@codemirror/text');function _interopDefaultLegacy(e){return e&&_typeof(e)==='object'&&'default'in e?e:{'default':e};}var elt__default=/*#__PURE__*/_interopDefaultLegacy(elt);var basicNormalize=typeof String.prototype.normalize=="function"?function(x){return x.normalize("NFKD");}:function(x){return x;};/**
26382638+A search cursor provides an iterator over text matches in a
26392639+document.
26402640+*/var SearchCursor=/*#__PURE__*/function(){/**
26412641+ Create a text cursor. The query is the search string, `from` to
26422642+ `to` provides the region to search.
26432643+26442644+ When `normalize` is given, it will be called, on both the query
26452645+ string and the content it is matched against, before comparing.
26462646+ You can, for example, create a case-insensitive search by
26472647+ passing `s => s.toLowerCase()`.
26482648+26492649+ Text is always normalized with
26502650+ [`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
26512651+ (when supported).
26522652+ */function SearchCursor(text,query){var from=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var to=arguments.length>3&&arguments[3]!==undefined?arguments[3]:text.length;var normalize=arguments.length>4?arguments[4]:undefined;_classCallCheck(this,SearchCursor);/**
26532653+ The current match (only holds a meaningful value after
26542654+ [`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
26552655+ `done` is false).
26562656+ */this.value={from:0,to:0};/**
26572657+ Whether the end of the iterated region has been reached.
26582658+ */this.done=false;this.matches=[];this.buffer="";this.bufferPos=0;this.iter=text.iterRange(from,to);this.bufferStart=from;this.normalize=normalize?function(x){return normalize(basicNormalize(x));}:basicNormalize;this.query=this.normalize(query);}_createClass(SearchCursor,[{key:"peek",value:function peek(){if(this.bufferPos==this.buffer.length){this.bufferStart+=this.buffer.length;this.iter.next();if(this.iter.done)return-1;this.bufferPos=0;this.buffer=this.iter.value;}return text.codePointAt(this.buffer,this.bufferPos);}/**
26592659+ Look for the next match. Updates the iterator's
26602660+ [`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
26612661+ [`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
26622662+ at least once before using the cursor.
26632663+ */},{key:"next",value:function next(){while(this.matches.length){this.matches.pop();}return this.nextOverlapping();}/**
26642664+ The `next` method will ignore matches that partially overlap a
26652665+ previous match. This method behaves like `next`, but includes
26662666+ such matches.
26672667+ */},{key:"nextOverlapping",value:function nextOverlapping(){for(;;){var next=this.peek();if(next<0){this.done=true;return this;}var str=text.fromCodePoint(next),start=this.bufferStart+this.bufferPos;this.bufferPos+=text.codePointSize(next);var norm=this.normalize(str);for(var _i90=0,pos=start;;_i90++){var code=norm.charCodeAt(_i90);var match=this.match(code,pos);if(match){this.value=match;return this;}if(_i90==norm.length-1)break;if(pos==start&&_i90<str.length&&str.charCodeAt(_i90)==code)pos++;}}}},{key:"match",value:function match(code,pos){var match=null;for(var _i91=0;_i91<this.matches.length;_i91+=2){var index=this.matches[_i91],keep=false;if(this.query.charCodeAt(index)==code){if(index==this.query.length-1){match={from:this.matches[_i91+1],to:pos+1};}else{this.matches[_i91]++;keep=true;}}if(!keep){this.matches.splice(_i91,2);_i91-=2;}}if(this.query.charCodeAt(0)==code){if(this.query.length==1)match={from:pos,to:pos+1};else this.matches.push(1,pos);}return match;}}]);return SearchCursor;}();if(typeof Symbol!="undefined")SearchCursor.prototype[Symbol.iterator]=function(){return this;};var empty={from:-1,to:-1,match:/.*/.exec("")};var baseFlags="gm"+(/x/.unicode==null?"":"u");/**
26682668+This class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)
26692669+but searches for a regular expression pattern instead of a plain
26702670+string.
26712671+*/var RegExpCursor=/*#__PURE__*/function(){/**
26722672+ Create a cursor that will search the given range in the given
26732673+ document. `query` should be the raw pattern (as you'd pass it to
26742674+ `new RegExp`).
26752675+ */function RegExpCursor(text,query,options){var from=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;var to=arguments.length>4&&arguments[4]!==undefined?arguments[4]:text.length;_classCallCheck(this,RegExpCursor);this.to=to;this.curLine="";/**
26762676+ Set to `true` when the cursor has reached the end of the search
26772677+ range.
26782678+ */this.done=false;/**
26792679+ Will contain an object with the extent of the match and the
26802680+ match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)
26812681+ sucessfully finds a match.
26822682+ */this.value=empty;if(/\\[sWDnr]|\n|\r|\[\^/.test(query))return new MultilineRegExpCursor(text,query,options,from,to);this.re=new RegExp(query,baseFlags+((options===null||options===void 0?void 0:options.ignoreCase)?"i":""));this.iter=text.iter();var startLine=text.lineAt(from);this.curLineStart=startLine.from;this.matchPos=from;this.getLine(this.curLineStart);}_createClass(RegExpCursor,[{key:"getLine",value:function getLine(skip){this.iter.next(skip);if(this.iter.lineBreak){this.curLine="";}else{this.curLine=this.iter.value;if(this.curLineStart+this.curLine.length>this.to)this.curLine=this.curLine.slice(0,this.to-this.curLineStart);this.iter.next();}}},{key:"nextLine",value:function nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1;if(this.curLineStart>this.to)this.curLine="";else this.getLine(0);}/**
26832683+ Move to the next match, if there is one.
26842684+ */},{key:"next",value:function next(){for(var off=this.matchPos-this.curLineStart;;){this.re.lastIndex=off;var match=this.matchPos<=this.to&&this.re.exec(this.curLine);if(match){var from=this.curLineStart+match.index,to=from+match[0].length;this.matchPos=to+(from==to?1:0);if(from==this.curLine.length)this.nextLine();if(from<to||from>this.value.to){this.value={from:from,to:to,match:match};return this;}off=this.matchPos-this.curLineStart;}else if(this.curLineStart+this.curLine.length<this.to){this.nextLine();off=0;}else{this.done=true;return this;}}}}]);return RegExpCursor;}();var flattened=new WeakMap();// Reusable (partially) flattened document strings
26852685+var FlattenedDoc=/*#__PURE__*/function(){function FlattenedDoc(from,text){_classCallCheck(this,FlattenedDoc);this.from=from;this.text=text;}_createClass(FlattenedDoc,[{key:"to",get:function get(){return this.from+this.text.length;}}],[{key:"get",value:function get(doc,from,to){var cached=flattened.get(doc);if(!cached||cached.from>=to||cached.to<=from){var flat=new FlattenedDoc(from,doc.sliceString(from,to));flattened.set(doc,flat);return flat;}if(cached.from==from&&cached.to==to)return cached;var text=cached.text,cachedFrom=cached.from;if(cachedFrom>from){text=doc.sliceString(from,cachedFrom)+text;cachedFrom=from;}if(cached.to<to)text+=doc.sliceString(cached.to,to);flattened.set(doc,new FlattenedDoc(cachedFrom,text));return new FlattenedDoc(from,text.slice(from-cachedFrom,to-cachedFrom));}}]);return FlattenedDoc;}();var MultilineRegExpCursor=/*#__PURE__*/function(){function MultilineRegExpCursor(text,query,options,from,to){_classCallCheck(this,MultilineRegExpCursor);this.text=text;this.to=to;this.done=false;this.value=empty;this.matchPos=from;this.re=new RegExp(query,baseFlags+((options===null||options===void 0?void 0:options.ignoreCase)?"i":""));this.flat=FlattenedDoc.get(text,from,this.chunkEnd(from+5000/* Base */));}_createClass(MultilineRegExpCursor,[{key:"chunkEnd",value:function chunkEnd(pos){return pos>=this.to?this.to:this.text.lineAt(pos).to;}},{key:"next",value:function next(){for(;;){var off=this.re.lastIndex=this.matchPos-this.flat.from;var match=this.re.exec(this.flat.text);// Skip empty matches directly after the last match
26862686+if(match&&!match[0]&&match.index==off){this.re.lastIndex=off+1;match=this.re.exec(this.flat.text);}// If a match goes almost to the end of a noncomplete chunk, try
26872687+// again, since it'll likely be able to match more
26882688+if(match&&this.flat.to<this.to&&match.index+match[0].length>this.flat.text.length-10)match=null;if(match){var from=this.flat.from+match.index,to=from+match[0].length;this.value={from:from,to:to,match:match};this.matchPos=to+(from==to?1:0);return this;}else{if(this.flat.to==this.to){this.done=true;return this;}// Grow the flattened doc
26892689+this.flat=FlattenedDoc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2));}}}}]);return MultilineRegExpCursor;}();if(typeof Symbol!="undefined"){RegExpCursor.prototype[Symbol.iterator]=MultilineRegExpCursor.prototype[Symbol.iterator]=function(){return this;};}function validRegExp(source){try{new RegExp(source,baseFlags);return true;}catch(_a){return false;}}function createLineDialog(view){var input=elt__default["default"]("input",{"class":"cm-textfield",name:"line"});var dom=elt__default["default"]("form",{"class":"cm-gotoLine",onkeydown:function onkeydown(event){if(event.keyCode==27){// Escape
26902690+event.preventDefault();view.dispatch({effects:dialogEffect.of(false)});view.focus();}else if(event.keyCode==13){// Enter
26912691+event.preventDefault();go();}},onsubmit:function onsubmit(event){event.preventDefault();go();}},elt__default["default"]("label",view.state.phrase("Go to line"),": ",input)," ",elt__default["default"]("button",{"class":"cm-button",type:"submit"},view.state.phrase("go")));function go(){var match=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(input.value);if(!match)return;var state$1=view.state,startLine=state$1.doc.lineAt(state$1.selection.main.head);var _match=_slicedToArray(match,5),sign=_match[1],ln=_match[2],cl=_match[3],percent=_match[4];var col=cl?+cl.slice(1):0;var line=ln?+ln:startLine.number;if(ln&&percent){var pc=line/100;if(sign)pc=pc*(sign=="-"?-1:1)+startLine.number/state$1.doc.lines;line=Math.round(state$1.doc.lines*pc);}else if(ln&&sign){line=line*(sign=="-"?-1:1)+startLine.number;}var docLine=state$1.doc.line(Math.max(1,Math.min(state$1.doc.lines,line)));view.dispatch({effects:dialogEffect.of(false),selection:state.EditorSelection.cursor(docLine.from+Math.max(0,Math.min(col,docLine.length))),scrollIntoView:true});view.focus();}return{dom:dom,pos:-10};}var dialogEffect=state.StateEffect.define();var dialogField=state.StateField.define({create:function create(){return true;},update:function update(value,tr){var _iterator163=_createForOfIteratorHelper(tr.effects),_step163;try{for(_iterator163.s();!(_step163=_iterator163.n()).done;){var e=_step163.value;if(e.is(dialogEffect))value=e.value;}}catch(err){_iterator163.e(err);}finally{_iterator163.f();}return value;},provide:function provide(f){return panel.showPanel.from(f,function(val){return val?createLineDialog:null;});}});/**
26922692+Command that shows a dialog asking the user for a line number, and
26932693+when a valid position is provided, moves the cursor to that line.
26942694+26952695+Supports line numbers, relative line offsets prefixed with `+` or
26962696+`-`, document percentages suffixed with `%`, and an optional
26972697+column position by adding `:` and a second number after the line
26982698+number.
26992699+27002700+The dialog can be styled with the `panel.gotoLine` theme
27012701+selector.
27022702+*/var gotoLine=function gotoLine(view){var panel$1=panel.getPanel(view,createLineDialog);if(!panel$1){var effects=[dialogEffect.of(true)];if(view.state.field(dialogField,false)==null)effects.push(state.StateEffect.appendConfig.of([dialogField,baseTheme$1]));view.dispatch({effects:effects});panel$1=panel.getPanel(view,createLineDialog);}if(panel$1)panel$1.dom.querySelector("input").focus();return true;};var baseTheme$1=view.EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});var defaultHighlightOptions={highlightWordAroundCursor:false,minSelectionLength:1,maxMatches:100};var highlightConfig=state.Facet.define({combine:function combine(options){return state.combineConfig(options,defaultHighlightOptions,{highlightWordAroundCursor:function highlightWordAroundCursor(a,b){return a||b;},minSelectionLength:Math.min,maxMatches:Math.min});}});/**
27032703+This extension highlights text that matches the selection. It uses
27042704+the `"cm-selectionMatch"` class for the highlighting. When
27052705+`highlightWordAroundCursor` is enabled, the word at the cursor
27062706+itself will be highlighted with `"cm-selectionMatch-main"`.
27072707+*/function highlightSelectionMatches(options){var ext=[defaultTheme,matchHighlighter];if(options)ext.push(highlightConfig.of(options));return ext;}var matchDeco=view.Decoration.mark({"class":"cm-selectionMatch"});var mainMatchDeco=view.Decoration.mark({"class":"cm-selectionMatch cm-selectionMatch-main"});var matchHighlighter=view.ViewPlugin.fromClass(/*#__PURE__*/function(){function _class17(view){_classCallCheck(this,_class17);this.decorations=this.getDeco(view);}_createClass(_class17,[{key:"update",value:function update(_update21){if(_update21.selectionSet||_update21.docChanged||_update21.viewportChanged)this.decorations=this.getDeco(_update21.view);}},{key:"getDeco",value:function getDeco(view$1){var conf=view$1.state.facet(highlightConfig);var state$1=view$1.state,sel=state$1.selection;if(sel.ranges.length>1)return view.Decoration.none;var range=sel.main,query,check=null;if(range.empty){if(!conf.highlightWordAroundCursor)return view.Decoration.none;var word=state$1.wordAt(range.head);if(!word)return view.Decoration.none;check=state$1.charCategorizer(range.head);query=state$1.sliceDoc(word.from,word.to);}else{var len=range.to-range.from;if(len<conf.minSelectionLength||len>200)return view.Decoration.none;query=state$1.sliceDoc(range.from,range.to).trim();if(!query)return view.Decoration.none;}var deco=[];var _iterator164=_createForOfIteratorHelper(view$1.visibleRanges),_step164;try{for(_iterator164.s();!(_step164=_iterator164.n()).done;){var part=_step164.value;var cursor=new SearchCursor(state$1.doc,query,part.from,part.to);while(!cursor.next().done){var _cursor$value=cursor.value,from=_cursor$value.from,to=_cursor$value.to;if(!check||(from==0||check(state$1.sliceDoc(from-1,from))!=state.CharCategory.Word)&&(to==state$1.doc.length||check(state$1.sliceDoc(to,to+1))!=state.CharCategory.Word)){if(check&&from<=range.from&&to>=range.to)deco.push(mainMatchDeco.range(from,to));else if(from>=range.to||to<=range.from)deco.push(matchDeco.range(from,to));if(deco.length>conf.maxMatches)return view.Decoration.none;}}}}catch(err){_iterator164.e(err);}finally{_iterator164.f();}return view.Decoration.set(deco);}}]);return _class17;}(),{decorations:function decorations(v){return v.decorations;}});var defaultTheme=view.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});// Select the words around the cursors.
27082708+var selectWord=function selectWord(_ref57){var state$1=_ref57.state,dispatch=_ref57.dispatch;var selection=state$1.selection;var newSel=state.EditorSelection.create(selection.ranges.map(function(range){return state$1.wordAt(range.head)||state.EditorSelection.cursor(range.head);}),selection.mainIndex);if(newSel.eq(selection))return false;dispatch(state$1.update({selection:newSel}));return true;};// Find next occurrence of query relative to last cursor. Wrap around
27092709+// the document if there are no more matches.
27102710+function findNextOccurrence(state,query){var _state$selection=state.selection,main=_state$selection.main,ranges=_state$selection.ranges;var word=state.wordAt(main.head),fullWord=word&&word.from==main.from&&word.to==main.to;var _loop16=function _loop16(_cycled,_cursor){_cursor.next();if(_cursor.done){if(_cycled){cursor=_cursor;{cycled=_cycled;return{v:null};}}_cursor=new SearchCursor(state.doc,query,0,Math.max(0,ranges[ranges.length-1].from-1));_cycled=true;}else{if(_cycled&&ranges.some(function(r){return r.from==_cursor.value.from;})){cursor=_cursor;{cycled=_cycled;return"continue";}}if(fullWord){var _word=state.wordAt(_cursor.value.from);if(!_word||_word.from!=_cursor.value.from||_word.to!=_cursor.value.to){cursor=_cursor;{cycled=_cycled;return"continue";}}}cycled=_cycled;cursor=_cursor;return{v:_cursor.value};}cycled=_cycled;cursor=_cursor;};for(var cycled=false,cursor=new SearchCursor(state.doc,query,ranges[ranges.length-1].to);;){var _ret5=_loop16(cycled,cursor);if(_ret5==="continue")continue;if(_typeof(_ret5)==="object")return _ret5.v;}}/**
27112711+Select next occurrence of the current selection.
27122712+Expand selection to the word when selection range is empty.
27132713+*/var selectNextOccurrence=function selectNextOccurrence(_ref58){var state$1=_ref58.state,dispatch=_ref58.dispatch;var ranges=state$1.selection.ranges;if(ranges.some(function(sel){return sel.from===sel.to;}))return selectWord({state:state$1,dispatch:dispatch});var searchedText=state$1.sliceDoc(ranges[0].from,ranges[0].to);if(state$1.selection.ranges.some(function(r){return state$1.sliceDoc(r.from,r.to)!=searchedText;}))return false;var range=findNextOccurrence(state$1,searchedText);if(!range)return false;dispatch(state$1.update({selection:state$1.selection.addRange(state.EditorSelection.range(range.from,range.to),false),effects:view.EditorView.scrollIntoView(range.to)}));return true;};var searchConfigFacet=state.Facet.define({combine:function combine(configs){var _a;return{top:configs.reduce(function(val,conf){return val!==null&&val!==void 0?val:conf.top;},undefined)||false,caseSensitive:configs.reduce(function(val,conf){return val!==null&&val!==void 0?val:conf.caseSensitive||conf.matchCase;},undefined)||false,createPanel:((_a=configs.find(function(c){return c.createPanel;}))===null||_a===void 0?void 0:_a.createPanel)||function(view){return new SearchPanel(view);}};}});/**
27142714+Configure the behavior of the search extension.
27152715+*/function searchConfig(config){return searchConfigFacet.of(config);}/**
27162716+A search query. Part of the editor's search state.
27172717+*/var SearchQuery=/*#__PURE__*/function(){/**
27182718+ Create a query object.
27192719+ */function SearchQuery(config){_classCallCheck(this,SearchQuery);this.search=config.search;this.caseSensitive=!!config.caseSensitive;this.regexp=!!config.regexp;this.replace=config.replace||"";this.valid=!!this.search&&(!this.regexp||validRegExp(this.search));}/**
27202720+ Compare this query to another query.
27212721+ */_createClass(SearchQuery,[{key:"eq",value:function eq(other){return this.search==other.search&&this.replace==other.replace&&this.caseSensitive==other.caseSensitive&&this.regexp==other.regexp;}/**
27222722+ @internal
27232723+ */},{key:"create",value:function create(){return this.regexp?new RegExpQuery(this):new StringQuery(this);}}]);return SearchQuery;}();var QueryType=/*#__PURE__*/_createClass(function QueryType(spec){_classCallCheck(this,QueryType);this.spec=spec;});var StringQuery=/*#__PURE__*/function(_QueryType){_inherits(StringQuery,_QueryType);var _super37=_createSuper(StringQuery);function StringQuery(spec){var _this77;_classCallCheck(this,StringQuery);_this77=_super37.call(this,spec);_this77.unquoted=spec.search.replace(/\\([nrt\\])/g,function(_,ch){return ch=="n"?"\n":ch=="r"?"\r":ch=="t"?"\t":"\\";});return _this77;}_createClass(StringQuery,[{key:"cursor",value:function cursor(doc){var from=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var to=arguments.length>2&&arguments[2]!==undefined?arguments[2]:doc.length;return new SearchCursor(doc,this.unquoted,from,to,this.spec.caseSensitive?undefined:function(x){return x.toLowerCase();});}},{key:"nextMatch",value:function nextMatch(doc,curFrom,curTo){var cursor=this.cursor(doc,curTo).nextOverlapping();if(cursor.done)cursor=this.cursor(doc,0,curFrom).nextOverlapping();return cursor.done?null:cursor.value;}// Searching in reverse is, rather than implementing inverted search
27242724+// cursor, done by scanning chunk after chunk forward.
27252725+},{key:"prevMatchInRange",value:function prevMatchInRange(doc,from,to){for(var pos=to;;){var start=Math.max(from,pos-10000/* ChunkSize */-this.unquoted.length);var _cursor2=this.cursor(doc,start,pos),range=null;while(!_cursor2.nextOverlapping().done){range=_cursor2.value;}if(range)return range;if(start==from)return null;pos-=10000/* ChunkSize */;}}},{key:"prevMatch",value:function prevMatch(doc,curFrom,curTo){return this.prevMatchInRange(doc,0,curFrom)||this.prevMatchInRange(doc,curTo,doc.length);}},{key:"getReplacement",value:function getReplacement(_result){return this.spec.replace;}},{key:"matchAll",value:function matchAll(doc,limit){var cursor=this.cursor(doc),ranges=[];while(!cursor.next().done){if(ranges.length>=limit)return null;ranges.push(cursor.value);}return ranges;}},{key:"highlight",value:function highlight(doc,from,to,add){var cursor=this.cursor(doc,Math.max(0,from-this.unquoted.length),Math.min(to+this.unquoted.length,doc.length));while(!cursor.next().done){add(cursor.value.from,cursor.value.to);}}}]);return StringQuery;}(QueryType);var RegExpQuery=/*#__PURE__*/function(_QueryType2){_inherits(RegExpQuery,_QueryType2);var _super38=_createSuper(RegExpQuery);function RegExpQuery(){_classCallCheck(this,RegExpQuery);return _super38.apply(this,arguments);}_createClass(RegExpQuery,[{key:"cursor",value:function cursor(doc){var from=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var to=arguments.length>2&&arguments[2]!==undefined?arguments[2]:doc.length;return new RegExpCursor(doc,this.spec.search,this.spec.caseSensitive?undefined:{ignoreCase:true},from,to);}},{key:"nextMatch",value:function nextMatch(doc,curFrom,curTo){var cursor=this.cursor(doc,curTo).next();if(cursor.done)cursor=this.cursor(doc,0,curFrom).next();return cursor.done?null:cursor.value;}},{key:"prevMatchInRange",value:function prevMatchInRange(doc,from,to){for(var size=1;;size++){var start=Math.max(from,to-size*10000/* ChunkSize */);var _cursor3=this.cursor(doc,start,to),range=null;while(!_cursor3.next().done){range=_cursor3.value;}if(range&&(start==from||range.from>start+10))return range;if(start==from)return null;}}},{key:"prevMatch",value:function prevMatch(doc,curFrom,curTo){return this.prevMatchInRange(doc,0,curFrom)||this.prevMatchInRange(doc,curTo,doc.length);}},{key:"getReplacement",value:function getReplacement(result){return this.spec.replace.replace(/\$([$&\d+])/g,function(m,i){return i=="$"?"$":i=="&"?result.match[0]:i!="0"&&+i<result.match.length?result.match[i]:m;});}},{key:"matchAll",value:function matchAll(doc,limit){var cursor=this.cursor(doc),ranges=[];while(!cursor.next().done){if(ranges.length>=limit)return null;ranges.push(cursor.value);}return ranges;}},{key:"highlight",value:function highlight(doc,from,to,add){var cursor=this.cursor(doc,Math.max(0,from-250/* HighlightMargin */),Math.min(to+250/* HighlightMargin */,doc.length));while(!cursor.next().done){add(cursor.value.from,cursor.value.to);}}}]);return RegExpQuery;}(QueryType);/**
27262726+A state effect that updates the current search query.
27272727+*/var setSearchQuery=state.StateEffect.define();var togglePanel=state.StateEffect.define();var searchState=state.StateField.define({create:function create(state){return new SearchState(defaultQuery(state).create(),createSearchPanel);},update:function update(value,tr){var _iterator165=_createForOfIteratorHelper(tr.effects),_step165;try{for(_iterator165.s();!(_step165=_iterator165.n()).done;){var effect=_step165.value;if(effect.is(setSearchQuery))value=new SearchState(effect.value.create(),value.panel);else if(effect.is(togglePanel))value=new SearchState(value.query,effect.value?createSearchPanel:null);}}catch(err){_iterator165.e(err);}finally{_iterator165.f();}return value;},provide:function provide(f){return panel.showPanel.from(f,function(val){return val.panel;});}});/**
27282728+Get the current search query from an editor state.
27292729+*/function getSearchQuery(state){var curState=state.field(searchState,false);return curState?curState.query.spec:defaultQuery(state);}var SearchState=/*#__PURE__*/_createClass(function SearchState(query,panel){_classCallCheck(this,SearchState);this.query=query;this.panel=panel;});var matchMark=view.Decoration.mark({"class":"cm-searchMatch"}),selectedMatchMark=view.Decoration.mark({"class":"cm-searchMatch cm-searchMatch-selected"});var searchHighlighter=view.ViewPlugin.fromClass(/*#__PURE__*/function(){function _class18(view){_classCallCheck(this,_class18);this.view=view;this.decorations=this.highlight(view.state.field(searchState));}_createClass(_class18,[{key:"update",value:function update(_update22){var state=_update22.state.field(searchState);if(state!=_update22.startState.field(searchState)||_update22.docChanged||_update22.selectionSet)this.decorations=this.highlight(state);}},{key:"highlight",value:function highlight(_ref59){var query=_ref59.query,panel=_ref59.panel;if(!panel||!query.spec.valid)return view.Decoration.none;var view$1=this.view;var builder=new rangeset.RangeSetBuilder();for(var _i92=0,ranges=view$1.visibleRanges,l=ranges.length;_i92<l;_i92++){var _ranges$_i2=ranges[_i92],from=_ranges$_i2.from,to=_ranges$_i2.to;while(_i92<l-1&&to>ranges[_i92+1].from-2*250/* HighlightMargin */){to=ranges[++_i92].to;}query.highlight(view$1.state.doc,from,to,function(from,to){var selected=view$1.state.selection.ranges.some(function(r){return r.from==from&&r.to==to;});builder.add(from,to,selected?selectedMatchMark:matchMark);});}return builder.finish();}}]);return _class18;}(),{decorations:function decorations(v){return v.decorations;}});function searchCommand(f){return function(view){var state=view.state.field(searchState,false);return state&&state.query.spec.valid?f(view,state):openSearchPanel(view);};}/**
27302730+Open the search panel if it isn't already open, and move the
27312731+selection to the first match after the current main selection.
27322732+Will wrap around to the start of the document when it reaches the
27332733+end.
27342734+*/var findNext=searchCommand(function(view,_ref60){var query=_ref60.query;var _view$state$selection=view.state.selection.main,from=_view$state$selection.from,to=_view$state$selection.to;var next=query.nextMatch(view.state.doc,from,to);if(!next||next.from==from&&next.to==to)return false;view.dispatch({selection:{anchor:next.from,head:next.to},scrollIntoView:true,effects:announceMatch(view,next),userEvent:"select.search"});return true;});/**
27352735+Move the selection to the previous instance of the search query,
27362736+before the current main selection. Will wrap past the start
27372737+of the document to start searching at the end again.
27382738+*/var findPrevious=searchCommand(function(view,_ref61){var query=_ref61.query;var state=view.state,_state$selection$main=state.selection.main,from=_state$selection$main.from,to=_state$selection$main.to;var range=query.prevMatch(state.doc,from,to);if(!range)return false;view.dispatch({selection:{anchor:range.from,head:range.to},scrollIntoView:true,effects:announceMatch(view,range),userEvent:"select.search"});return true;});/**
27392739+Select all instances of the search query.
27402740+*/var selectMatches=searchCommand(function(view,_ref62){var query=_ref62.query;var ranges=query.matchAll(view.state.doc,1000);if(!ranges||!ranges.length)return false;view.dispatch({selection:state.EditorSelection.create(ranges.map(function(r){return state.EditorSelection.range(r.from,r.to);})),userEvent:"select.search.matches"});return true;});/**
27412741+Select all instances of the currently selected text.
27422742+*/var selectSelectionMatches=function selectSelectionMatches(_ref63){var state$1=_ref63.state,dispatch=_ref63.dispatch;var sel=state$1.selection;if(sel.ranges.length>1||sel.main.empty)return false;var _sel$main=sel.main,from=_sel$main.from,to=_sel$main.to;var ranges=[],main=0;for(var cur=new SearchCursor(state$1.doc,state$1.sliceDoc(from,to));!cur.next().done;){if(ranges.length>1000)return false;if(cur.value.from==from)main=ranges.length;ranges.push(state.EditorSelection.range(cur.value.from,cur.value.to));}dispatch(state$1.update({selection:state.EditorSelection.create(ranges,main),userEvent:"select.search.matches"}));return true;};/**
27432743+Replace the current match of the search query.
27442744+*/var replaceNext=searchCommand(function(view,_ref64){var query=_ref64.query;var state=view.state,_state$selection$main2=state.selection.main,from=_state$selection$main2.from,to=_state$selection$main2.to;if(state.readOnly)return false;var next=query.nextMatch(state.doc,from,from);if(!next)return false;var changes=[],selection,replacement;if(next.from==from&&next.to==to){replacement=state.toText(query.getReplacement(next));changes.push({from:next.from,to:next.to,insert:replacement});next=query.nextMatch(state.doc,next.from,next.to);}if(next){var off=changes.length==0||changes[0].from>=next.to?0:next.to-next.from-replacement.length;selection={anchor:next.from-off,head:next.to-off};}view.dispatch({changes:changes,selection:selection,scrollIntoView:!!selection,effects:next?announceMatch(view,next):undefined,userEvent:"input.replace"});return true;});/**
27452745+Replace all instances of the search query with the given
27462746+replacement.
27472747+*/var replaceAll=searchCommand(function(view,_ref65){var query=_ref65.query;if(view.state.readOnly)return false;var changes=query.matchAll(view.state.doc,1e9).map(function(match){var from=match.from,to=match.to;return{from:from,to:to,insert:query.getReplacement(match)};});if(!changes.length)return false;view.dispatch({changes:changes,userEvent:"input.replace.all"});return true;});function createSearchPanel(view){return view.state.facet(searchConfigFacet).createPanel(view);}function defaultQuery(state,fallback){var _a;var sel=state.selection.main;var selText=sel.empty||sel.to>sel.from+100?"":state.sliceDoc(sel.from,sel.to);var caseSensitive=(_a=fallback===null||fallback===void 0?void 0:fallback.caseSensitive)!==null&&_a!==void 0?_a:state.facet(searchConfigFacet).caseSensitive;return fallback&&!selText?fallback:new SearchQuery({search:selText.replace(/\n/g,"\\n"),caseSensitive:caseSensitive});}/**
27482748+Make sure the search panel is open and focused.
27492749+*/var openSearchPanel=function openSearchPanel(view){var state$1=view.state.field(searchState,false);if(state$1&&state$1.panel){var panel$1=panel.getPanel(view,createSearchPanel);if(!panel$1)return false;var searchInput=panel$1.dom.querySelector("[name=search]");if(searchInput!=view.root.activeElement){var query=defaultQuery(view.state,state$1.query.spec);if(query.valid)view.dispatch({effects:setSearchQuery.of(query)});searchInput.focus();searchInput.select();}}else{view.dispatch({effects:[togglePanel.of(true),state$1?setSearchQuery.of(defaultQuery(view.state,state$1.query.spec)):state.StateEffect.appendConfig.of(searchExtensions)]});}return true;};/**
27502750+Close the search panel.
27512751+*/var closeSearchPanel=function closeSearchPanel(view){var state=view.state.field(searchState,false);if(!state||!state.panel)return false;var panel$1=panel.getPanel(view,createSearchPanel);if(panel$1&&panel$1.dom.contains(view.root.activeElement))view.focus();view.dispatch({effects:togglePanel.of(false)});return true;};/**
27522752+Default search-related key bindings.
27532753+27542754+ - Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)
27552755+ - F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)
27562756+ - Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)
27572757+ - Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)
27582758+ - Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)
27592759+*/var searchKeymap=[{key:"Mod-f",run:openSearchPanel,scope:"editor search-panel"},{key:"F3",run:findNext,shift:findPrevious,scope:"editor search-panel",preventDefault:true},{key:"Mod-g",run:findNext,shift:findPrevious,scope:"editor search-panel",preventDefault:true},{key:"Escape",run:closeSearchPanel,scope:"editor search-panel"},{key:"Mod-Shift-l",run:selectSelectionMatches},{key:"Alt-g",run:gotoLine},{key:"Mod-d",run:selectNextOccurrence,preventDefault:true}];var SearchPanel=/*#__PURE__*/function(){function SearchPanel(view){var _this78=this;_classCallCheck(this,SearchPanel);this.view=view;var query=this.query=view.state.field(searchState).query.spec;this.commit=this.commit.bind(this);this.searchField=elt__default["default"]("input",{value:query.search,placeholder:phrase(view,"Find"),"aria-label":phrase(view,"Find"),"class":"cm-textfield",name:"search",onchange:this.commit,onkeyup:this.commit});this.replaceField=elt__default["default"]("input",{value:query.replace,placeholder:phrase(view,"Replace"),"aria-label":phrase(view,"Replace"),"class":"cm-textfield",name:"replace",onchange:this.commit,onkeyup:this.commit});this.caseField=elt__default["default"]("input",{type:"checkbox",name:"case",checked:query.caseSensitive,onchange:this.commit});this.reField=elt__default["default"]("input",{type:"checkbox",name:"re",checked:query.regexp,onchange:this.commit});function button(name,onclick,content){return elt__default["default"]("button",{"class":"cm-button",name:name,onclick:onclick,type:"button"},content);}this.dom=elt__default["default"]("div",{onkeydown:function onkeydown(e){return _this78.keydown(e);},"class":"cm-search"},[this.searchField,button("next",function(){return findNext(view);},[phrase(view,"next")]),button("prev",function(){return findPrevious(view);},[phrase(view,"previous")]),button("select",function(){return selectMatches(view);},[phrase(view,"all")]),elt__default["default"]("label",null,[this.caseField,phrase(view,"match case")]),elt__default["default"]("label",null,[this.reField,phrase(view,"regexp")])].concat(_toConsumableArray(view.state.readOnly?[]:[elt__default["default"]("br"),this.replaceField,button("replace",function(){return replaceNext(view);},[phrase(view,"replace")]),button("replaceAll",function(){return replaceAll(view);},[phrase(view,"replace all")]),elt__default["default"]("button",{name:"close",onclick:function onclick(){return closeSearchPanel(view);},"aria-label":phrase(view,"close"),type:"button"},["×"])])));}_createClass(SearchPanel,[{key:"commit",value:function commit(){var query=new SearchQuery({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,replace:this.replaceField.value});if(!query.eq(this.query)){this.query=query;this.view.dispatch({effects:setSearchQuery.of(query)});}}},{key:"keydown",value:function keydown(e){if(view.runScopeHandlers(this.view,e,"search-panel")){e.preventDefault();}else if(e.keyCode==13&&e.target==this.searchField){e.preventDefault();(e.shiftKey?findPrevious:findNext)(this.view);}else if(e.keyCode==13&&e.target==this.replaceField){e.preventDefault();replaceNext(this.view);}}},{key:"update",value:function update(_update23){var _iterator166=_createForOfIteratorHelper(_update23.transactions),_step166;try{for(_iterator166.s();!(_step166=_iterator166.n()).done;){var tr=_step166.value;var _iterator167=_createForOfIteratorHelper(tr.effects),_step167;try{for(_iterator167.s();!(_step167=_iterator167.n()).done;){var effect=_step167.value;if(effect.is(setSearchQuery)&&!effect.value.eq(this.query))this.setQuery(effect.value);}}catch(err){_iterator167.e(err);}finally{_iterator167.f();}}}catch(err){_iterator166.e(err);}finally{_iterator166.f();}}},{key:"setQuery",value:function setQuery(query){this.query=query;this.searchField.value=query.search;this.replaceField.value=query.replace;this.caseField.checked=query.caseSensitive;this.reField.checked=query.regexp;}},{key:"mount",value:function mount(){this.searchField.select();}},{key:"pos",get:function get(){return 80;}},{key:"top",get:function get(){return this.view.state.facet(searchConfigFacet).top;}}]);return SearchPanel;}();function phrase(view,phrase){return view.state.phrase(phrase);}var AnnounceMargin=30;var Break=/[\s\.,:;?!]/;function announceMatch(view$1,_ref66){var from=_ref66.from,to=_ref66.to;var lineStart=view$1.state.doc.lineAt(from).from,lineEnd=view$1.state.doc.lineAt(to).to;var start=Math.max(lineStart,from-AnnounceMargin),end=Math.min(lineEnd,to+AnnounceMargin);var text=view$1.state.sliceDoc(start,end);if(start!=lineStart){for(var _i93=0;_i93<AnnounceMargin;_i93++){if(!Break.test(text[_i93+1])&&Break.test(text[_i93])){text=text.slice(_i93);break;}}}if(end!=lineEnd){for(var _i94=text.length-1;_i94>text.length-AnnounceMargin;_i94--){if(!Break.test(text[_i94-1])&&Break.test(text[_i94])){text=text.slice(0,_i94);break;}}}return view.EditorView.announce.of("".concat(view$1.state.phrase("current match"),". ").concat(text," ").concat(view$1.state.phrase("on line")," ").concat(view$1.state.doc.lineAt(from).number));}var baseTheme=view.EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}});var searchExtensions=[searchState,state.Prec.lowest(searchHighlighter),baseTheme];exports.RegExpCursor=RegExpCursor;exports.SearchCursor=SearchCursor;exports.SearchQuery=SearchQuery;exports.closeSearchPanel=closeSearchPanel;exports.findNext=findNext;exports.findPrevious=findPrevious;exports.getSearchQuery=getSearchQuery;exports.gotoLine=gotoLine;exports.highlightSelectionMatches=highlightSelectionMatches;exports.openSearchPanel=openSearchPanel;exports.replaceAll=replaceAll;exports.replaceNext=replaceNext;exports.searchConfig=searchConfig;exports.searchKeymap=searchKeymap;exports.selectMatches=selectMatches;exports.selectNextOccurrence=selectNextOccurrence;exports.selectSelectionMatches=selectSelectionMatches;exports.setSearchQuery=setSearchQuery;},{"@codemirror/panel":17,"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/text":24,"@codemirror/view":21,"crelt":29}],21:[function(require,module,exports){arguments[4][5][0].apply(exports,arguments);},{"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/text":24,"dup":5,"style-mod":30,"w3c-keyname":31}],22:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var text=require('@codemirror/text');var DefaultSplit=/\r\n?|\n/;/**
27602760+Distinguishes different ways in which positions can be mapped.
27612761+*/exports.MapMode=void 0;(function(MapMode){/**
27622762+ Map a position to a valid new position, even when its context
27632763+ was deleted.
27642764+ */MapMode[MapMode["Simple"]=0]="Simple";/**
27652765+ Return null if deletion happens across the position.
27662766+ */MapMode[MapMode["TrackDel"]=1]="TrackDel";/**
27672767+ Return null if the character _before_ the position is deleted.
27682768+ */MapMode[MapMode["TrackBefore"]=2]="TrackBefore";/**
27692769+ Return null if the character _after_ the position is deleted.
27702770+ */MapMode[MapMode["TrackAfter"]=3]="TrackAfter";})(exports.MapMode||(exports.MapMode={}));/**
27712771+A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
27722772+that doesn't store the inserted text. As such, it can't be
27732773+applied, but is cheaper to store and manipulate.
27742774+*/var ChangeDesc=/*#__PURE__*/function(){// Sections are encoded as pairs of integers. The first is the
27752775+// length in the current document, and the second is -1 for
27762776+// unaffected sections, and the length of the replacement content
27772777+// otherwise. So an insertion would be (0, n>0), a deletion (n>0,
27782778+// 0), and a replacement two positive numbers.
27792779+/**
27802780+ @internal
27812781+ */function ChangeDesc(/**
27822782+ @internal
27832783+ */sections){_classCallCheck(this,ChangeDesc);this.sections=sections;}/**
27842784+ The length of the document before the change.
27852785+ */_createClass(ChangeDesc,[{key:"length",get:function get(){var result=0;for(var _i95=0;_i95<this.sections.length;_i95+=2){result+=this.sections[_i95];}return result;}/**
27862786+ The length of the document after the change.
27872787+ */},{key:"newLength",get:function get(){var result=0;for(var _i96=0;_i96<this.sections.length;_i96+=2){var ins=this.sections[_i96+1];result+=ins<0?this.sections[_i96]:ins;}return result;}/**
27882788+ False when there are actual changes in this set.
27892789+ */},{key:"empty",get:function get(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0;}/**
27902790+ Iterate over the unchanged parts left by these changes.
27912791+ */},{key:"iterGaps",value:function iterGaps(f){for(var _i97=0,posA=0,posB=0;_i97<this.sections.length;){var len=this.sections[_i97++],ins=this.sections[_i97++];if(ins<0){f(posA,posB,len);posB+=len;}else{posB+=ins;}posA+=len;}}/**
27922792+ Iterate over the ranges changed by these changes. (See
27932793+ [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
27942794+ variant that also provides you with the inserted text.)
27952795+27962796+ When `individual` is true, adjacent changes (which are kept
27972797+ separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
27982798+ reported separately.
27992799+ */},{key:"iterChangedRanges",value:function iterChangedRanges(f){var individual=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;_iterChanges(this,f,individual);}/**
28002800+ Get a description of the inverted form of these changes.
28012801+ */},{key:"invertedDesc",get:function get(){var sections=[];for(var _i98=0;_i98<this.sections.length;){var len=this.sections[_i98++],ins=this.sections[_i98++];if(ins<0)sections.push(len,ins);else sections.push(ins,len);}return new ChangeDesc(sections);}/**
28022802+ Compute the combined effect of applying another set of changes
28032803+ after this one. The length of the document after this set should
28042804+ match the length before `other`.
28052805+ */},{key:"composeDesc",value:function composeDesc(other){return this.empty?other:other.empty?this:composeSets(this,other);}/**
28062806+ Map this description, which should start with the same document
28072807+ as `other`, over another set of changes, so that it can be
28082808+ applied after it. When `before` is true, map as if the changes
28092809+ in `other` happened before the ones in `this`.
28102810+ */},{key:"mapDesc",value:function mapDesc(other){var before=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return other.empty?this:mapSet(this,other,before);}},{key:"mapPos",value:function mapPos(pos){var assoc=arguments.length>1&&arguments[1]!==undefined?arguments[1]:-1;var mode=arguments.length>2&&arguments[2]!==undefined?arguments[2]:exports.MapMode.Simple;var posA=0,posB=0;for(var _i99=0;_i99<this.sections.length;){var len=this.sections[_i99++],ins=this.sections[_i99++],endA=posA+len;if(ins<0){if(endA>pos)return posB+(pos-posA);posB+=len;}else{if(mode!=exports.MapMode.Simple&&endA>=pos&&(mode==exports.MapMode.TrackDel&&posA<pos&&endA>pos||mode==exports.MapMode.TrackBefore&&posA<pos||mode==exports.MapMode.TrackAfter&&endA>pos))return null;if(endA>pos||endA==pos&&assoc<0&&!len)return pos==posA||assoc<0?posB:posB+ins;posB+=ins;}posA=endA;}if(pos>posA)throw new RangeError("Position ".concat(pos," is out of range for changeset of length ").concat(posA));return posB;}/**
28112811+ Check whether these changes touch a given range. When one of the
28122812+ changes entirely covers the range, the string `"cover"` is
28132813+ returned.
28142814+ */},{key:"touchesRange",value:function touchesRange(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:from;for(var _i100=0,pos=0;_i100<this.sections.length&&pos<=to;){var len=this.sections[_i100++],ins=this.sections[_i100++],end=pos+len;if(ins>=0&&pos<=to&&end>=from)return pos<from&&end>to?"cover":true;pos=end;}return false;}/**
28152815+ @internal
28162816+ */},{key:"toString",value:function toString(){var result="";for(var _i101=0;_i101<this.sections.length;){var len=this.sections[_i101++],ins=this.sections[_i101++];result+=(result?" ":"")+len+(ins>=0?":"+ins:"");}return result;}/**
28172817+ Serialize this change desc to a JSON-representable value.
28182818+ */},{key:"toJSON",value:function toJSON(){return this.sections;}/**
28192819+ Create a change desc from its JSON representation (as produced
28202820+ by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
28212821+ */}],[{key:"fromJSON",value:function fromJSON(json){if(!Array.isArray(json)||json.length%2||json.some(function(a){return typeof a!="number";}))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ChangeDesc(json);}}]);return ChangeDesc;}();/**
28222822+A change set represents a group of modifications to a document. It
28232823+stores the document length, and can only be applied to documents
28242824+with exactly that length.
28252825+*/var ChangeSet=/*#__PURE__*/function(_ChangeDesc){_inherits(ChangeSet,_ChangeDesc);var _super39=_createSuper(ChangeSet);/**
28262826+ @internal
28272827+ */function ChangeSet(sections,/**
28282828+ @internal
28292829+ */inserted){var _this79;_classCallCheck(this,ChangeSet);_this79=_super39.call(this,sections);_this79.inserted=inserted;return _this79;}/**
28302830+ Apply the changes to a document, returning the modified
28312831+ document.
28322832+ */_createClass(ChangeSet,[{key:"apply",value:function apply(doc){if(this.length!=doc.length)throw new RangeError("Applying change set to a document with the wrong length");_iterChanges(this,function(fromA,toA,fromB,_toB,text){return doc=doc.replace(fromB,fromB+(toA-fromA),text);},false);return doc;}},{key:"mapDesc",value:function mapDesc(other){var before=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return mapSet(this,other,before,true);}/**
28332833+ Given the document as it existed _before_ the changes, return a
28342834+ change set that represents the inverse of this set, which could
28352835+ be used to go from the document created by the changes back to
28362836+ the document as it existed before the changes.
28372837+ */},{key:"invert",value:function invert(doc){var sections=this.sections.slice(),inserted=[];for(var _i102=0,pos=0;_i102<sections.length;_i102+=2){var len=sections[_i102],ins=sections[_i102+1];if(ins>=0){sections[_i102]=ins;sections[_i102+1]=len;var index=_i102>>1;while(inserted.length<index){inserted.push(text.Text.empty);}inserted.push(len?doc.slice(pos,pos+len):text.Text.empty);}pos+=len;}return new ChangeSet(sections,inserted);}/**
28382838+ Combine two subsequent change sets into a single set. `other`
28392839+ must start in the document produced by `this`. If `this` goes
28402840+ `docA` → `docB` and `other` represents `docB` → `docC`, the
28412841+ returned value will represent the change `docA` → `docC`.
28422842+ */},{key:"compose",value:function compose(other){return this.empty?other:other.empty?this:composeSets(this,other,true);}/**
28432843+ Given another change set starting in the same document, maps this
28442844+ change set over the other, producing a new change set that can be
28452845+ applied to the document produced by applying `other`. When
28462846+ `before` is `true`, order changes as if `this` comes before
28472847+ `other`, otherwise (the default) treat `other` as coming first.
28482848+28492849+ Given two changes `A` and `B`, `A.compose(B.map(A))` and
28502850+ `B.compose(A.map(B, true))` will produce the same document. This
28512851+ provides a basic form of [operational
28522852+ transformation](https://en.wikipedia.org/wiki/Operational_transformation),
28532853+ and can be used for collaborative editing.
28542854+ */},{key:"map",value:function map(other){var before=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return other.empty?this:mapSet(this,other,before,true);}/**
28552855+ Iterate over the changed ranges in the document, calling `f` for
28562856+ each.
28572857+28582858+ When `individual` is true, adjacent changes are reported
28592859+ separately.
28602860+ */},{key:"iterChanges",value:function iterChanges(f){var individual=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;_iterChanges(this,f,individual);}/**
28612861+ Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
28622862+ set.
28632863+ */},{key:"desc",get:function get(){return new ChangeDesc(this.sections);}/**
28642864+ @internal
28652865+ */},{key:"filter",value:function filter(ranges){var resultSections=[],resultInserted=[],filteredSections=[];var iter=new SectionIter(this);done:for(var _i103=0,pos=0;;){var next=_i103==ranges.length?1e9:ranges[_i103++];while(pos<next||pos==next&&iter.len==0){if(iter.done)break done;var len=Math.min(iter.len,next-pos);addSection(filteredSections,len,-1);var ins=iter.ins==-1?-1:iter.off==0?iter.ins:0;addSection(resultSections,len,ins);if(ins>0)addInsert(resultInserted,resultSections,iter.text);iter.forward(len);pos+=len;}var end=ranges[_i103++];while(pos<end){if(iter.done)break done;var _len=Math.min(iter.len,end-pos);addSection(resultSections,_len,-1);addSection(filteredSections,_len,iter.ins==-1?-1:iter.off==0?iter.ins:0);iter.forward(_len);pos+=_len;}}return{changes:new ChangeSet(resultSections,resultInserted),filtered:new ChangeDesc(filteredSections)};}/**
28662866+ Serialize this change set to a JSON-representable value.
28672867+ */},{key:"toJSON",value:function toJSON(){var parts=[];for(var _i104=0;_i104<this.sections.length;_i104+=2){var len=this.sections[_i104],ins=this.sections[_i104+1];if(ins<0)parts.push(len);else if(ins==0)parts.push([len]);else parts.push([len].concat(this.inserted[_i104>>1].toJSON()));}return parts;}/**
28682868+ Create a change set for the given changes, for a document of the
28692869+ given length, using `lineSep` as line separator.
28702870+ */}],[{key:"of",value:function of(changes,length,lineSep){var sections=[],inserted=[],pos=0;var total=null;function flush(){var force=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(!force&&!sections.length)return;if(pos<length)addSection(sections,length-pos,-1);var set=new ChangeSet(sections,inserted);total=total?total.compose(set.map(total)):set;sections=[];inserted=[];pos=0;}function process(spec){if(Array.isArray(spec)){var _iterator168=_createForOfIteratorHelper(spec),_step168;try{for(_iterator168.s();!(_step168=_iterator168.n()).done;){var sub=_step168.value;process(sub);}}catch(err){_iterator168.e(err);}finally{_iterator168.f();}}else if(spec instanceof ChangeSet){if(spec.length!=length)throw new RangeError("Mismatched change set length (got ".concat(spec.length,", expected ").concat(length,")"));flush();total=total?total.compose(spec.map(total)):spec;}else{var from=spec.from,_spec$to=spec.to,to=_spec$to===void 0?from:_spec$to,insert=spec.insert;if(from>to||from<0||to>length)throw new RangeError("Invalid change range ".concat(from," to ").concat(to," (in doc of length ").concat(length,")"));var insText=!insert?text.Text.empty:typeof insert=="string"?text.Text.of(insert.split(lineSep||DefaultSplit)):insert;var insLen=insText.length;if(from==to&&insLen==0)return;if(from<pos)flush();if(from>pos)addSection(sections,from-pos,-1);addSection(sections,to-from,insLen);addInsert(inserted,sections,insText);pos=to;}}process(changes);flush(!total);return total;}/**
28712871+ Create an empty changeset of the given length.
28722872+ */},{key:"empty",value:function empty(length){return new ChangeSet(length?[length,-1]:[],[]);}/**
28732873+ Create a changeset from its JSON representation (as produced by
28742874+ [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
28752875+ */},{key:"fromJSON",value:function fromJSON(json){if(!Array.isArray(json))throw new RangeError("Invalid JSON representation of ChangeSet");var sections=[],inserted=[];for(var _i105=0;_i105<json.length;_i105++){var part=json[_i105];if(typeof part=="number"){sections.push(part,-1);}else if(!Array.isArray(part)||typeof part[0]!="number"||part.some(function(e,i){return i&&typeof e!="string";})){throw new RangeError("Invalid JSON representation of ChangeSet");}else if(part.length==1){sections.push(part[0],0);}else{while(inserted.length<_i105){inserted.push(text.Text.empty);}inserted[_i105]=text.Text.of(part.slice(1));sections.push(part[0],inserted[_i105].length);}}return new ChangeSet(sections,inserted);}}]);return ChangeSet;}(ChangeDesc);function addSection(sections,len,ins){var forceJoin=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;if(len==0&&ins<=0)return;var last=sections.length-2;if(last>=0&&ins<=0&&ins==sections[last+1])sections[last]+=len;else if(len==0&§ions[last]==0)sections[last+1]+=ins;else if(forceJoin){sections[last]+=len;sections[last+1]+=ins;}else sections.push(len,ins);}function addInsert(values,sections,value){if(value.length==0)return;var index=sections.length-2>>1;if(index<values.length){values[values.length-1]=values[values.length-1].append(value);}else{while(values.length<index){values.push(text.Text.empty);}values.push(value);}}function _iterChanges(desc,f,individual){var inserted=desc.inserted;for(var posA=0,posB=0,_i106=0;_i106<desc.sections.length;){var len=desc.sections[_i106++],ins=desc.sections[_i106++];if(ins<0){posA+=len;posB+=len;}else{var endA=posA,endB=posB,text$1=text.Text.empty;for(;;){endA+=len;endB+=ins;if(ins&&inserted)text$1=text$1.append(inserted[_i106-2>>1]);if(individual||_i106==desc.sections.length||desc.sections[_i106+1]<0)break;len=desc.sections[_i106++];ins=desc.sections[_i106++];}f(posA,endA,posB,endB,text$1);posA=endA;posB=endB;}}}function mapSet(setA,setB,before){var mkSet=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var sections=[],insert=mkSet?[]:null;var a=new SectionIter(setA),b=new SectionIter(setB);for(var posA=0,posB=0;;){if(a.ins==-1){posA+=a.len;a.next();}else if(b.ins==-1&&posB<posA){var skip=Math.min(b.len,posA-posB);b.forward(skip);addSection(sections,skip,-1);posB+=skip;}else if(b.ins>=0&&(a.done||posB<posA||posB==posA&&(b.len<a.len||b.len==a.len&&!before))){addSection(sections,b.ins,-1);while(posA>posB&&!a.done&&posA+a.len<posB+b.len){posA+=a.len;a.next();}posB+=b.len;b.next();}else if(a.ins>=0){var len=0,end=posA+a.len;for(;;){if(b.ins>=0&&posB>posA&&posB+b.len<end){len+=b.ins;posB+=b.len;b.next();}else if(b.ins==-1&&posB<end){var _skip=Math.min(b.len,end-posB);len+=_skip;b.forward(_skip);posB+=_skip;}else{break;}}addSection(sections,len,a.ins);if(insert)addInsert(insert,sections,a.text);posA=end;a.next();}else if(a.done&&b.done){return insert?new ChangeSet(sections,insert):new ChangeDesc(sections);}else{throw new Error("Mismatched change set lengths");}}}function composeSets(setA,setB){var mkSet=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var sections=[];var insert=mkSet?[]:null;var a=new SectionIter(setA),b=new SectionIter(setB);for(var open=false;;){if(a.done&&b.done){return insert?new ChangeSet(sections,insert):new ChangeDesc(sections);}else if(a.ins==0){// Deletion in A
28762876+addSection(sections,a.len,0,open);a.next();}else if(b.len==0&&!b.done){// Insertion in B
28772877+addSection(sections,0,b.ins,open);if(insert)addInsert(insert,sections,b.text);b.next();}else if(a.done||b.done){throw new Error("Mismatched change set lengths");}else{var len=Math.min(a.len2,b.len),sectionLen=sections.length;if(a.ins==-1){var insB=b.ins==-1?-1:b.off?0:b.ins;addSection(sections,len,insB,open);if(insert&&insB)addInsert(insert,sections,b.text);}else if(b.ins==-1){addSection(sections,a.off?0:a.len,len,open);if(insert)addInsert(insert,sections,a.textBit(len));}else{addSection(sections,a.off?0:a.len,b.off?0:b.ins,open);if(insert&&!b.off)addInsert(insert,sections,b.text);}open=(a.ins>len||b.ins>=0&&b.len>len)&&(open||sections.length>sectionLen);a.forward2(len);b.forward(len);}}}var SectionIter=/*#__PURE__*/function(){function SectionIter(set){_classCallCheck(this,SectionIter);this.set=set;this.i=0;this.next();}_createClass(SectionIter,[{key:"next",value:function next(){var sections=this.set.sections;if(this.i<sections.length){this.len=sections[this.i++];this.ins=sections[this.i++];}else{this.len=0;this.ins=-2;}this.off=0;}},{key:"done",get:function get(){return this.ins==-2;}},{key:"len2",get:function get(){return this.ins<0?this.len:this.ins;}},{key:"text",get:function get(){var inserted=this.set.inserted,index=this.i-2>>1;return index>=inserted.length?text.Text.empty:inserted[index];}},{key:"textBit",value:function textBit(len){var inserted=this.set.inserted,index=this.i-2>>1;return index>=inserted.length&&!len?text.Text.empty:inserted[index].slice(this.off,len==null?undefined:this.off+len);}},{key:"forward",value:function forward(len){if(len==this.len)this.next();else{this.len-=len;this.off+=len;}}},{key:"forward2",value:function forward2(len){if(this.ins==-1)this.forward(len);else if(len==this.ins)this.next();else{this.ins-=len;this.off+=len;}}}]);return SectionIter;}();/**
28782878+A single selection range. When
28792879+[`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
28802880+is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
28812881+multiple ranges. By default, selections hold exactly one range.
28822882+*/var SelectionRange=/*#__PURE__*/function(){/**
28832883+ @internal
28842884+ */function SelectionRange(/**
28852885+ The lower boundary of the range.
28862886+ */from,/**
28872887+ The upper boundary of the range.
28882888+ */to,flags){_classCallCheck(this,SelectionRange);this.from=from;this.to=to;this.flags=flags;}/**
28892889+ The anchor of the range—the side that doesn't move when you
28902890+ extend it.
28912891+ */_createClass(SelectionRange,[{key:"anchor",get:function get(){return this.flags&16/* Inverted */?this.to:this.from;}/**
28922892+ The head of the range, which is moved when the range is
28932893+ [extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
28942894+ */},{key:"head",get:function get(){return this.flags&16/* Inverted */?this.from:this.to;}/**
28952895+ True when `anchor` and `head` are at the same position.
28962896+ */},{key:"empty",get:function get(){return this.from==this.to;}/**
28972897+ If this is a cursor that is explicitly associated with the
28982898+ character on one of its sides, this returns the side. -1 means
28992899+ the character before its position, 1 the character after, and 0
29002900+ means no association.
29012901+ */},{key:"assoc",get:function get(){return this.flags&4/* AssocBefore */?-1:this.flags&8/* AssocAfter */?1:0;}/**
29022902+ The bidirectional text level associated with this cursor, if
29032903+ any.
29042904+ */},{key:"bidiLevel",get:function get(){var level=this.flags&3/* BidiLevelMask */;return level==3?null:level;}/**
29052905+ The goal column (stored vertical offset) associated with a
29062906+ cursor. This is used to preserve the vertical position when
29072907+ [moving](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) across
29082908+ lines of different length.
29092909+ */},{key:"goalColumn",get:function get(){var value=this.flags>>5/* GoalColumnOffset */;return value==33554431/* NoGoalColumn */?undefined:value;}/**
29102910+ Map this range through a change, producing a valid range in the
29112911+ updated document.
29122912+ */},{key:"map",value:function map(change){var assoc=arguments.length>1&&arguments[1]!==undefined?arguments[1]:-1;var from=change.mapPos(this.from,assoc),to=change.mapPos(this.to,assoc);return from==this.from&&to==this.to?this:new SelectionRange(from,to,this.flags);}/**
29132913+ Extend this range to cover at least `from` to `to`.
29142914+ */},{key:"extend",value:function extend(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:from;if(from<=this.anchor&&to>=this.anchor)return EditorSelection.range(from,to);var head=Math.abs(from-this.anchor)>Math.abs(to-this.anchor)?from:to;return EditorSelection.range(this.anchor,head);}/**
29152915+ Compare this range to another range.
29162916+ */},{key:"eq",value:function eq(other){return this.anchor==other.anchor&&this.head==other.head;}/**
29172917+ Return a JSON-serializable object representing the range.
29182918+ */},{key:"toJSON",value:function toJSON(){return{anchor:this.anchor,head:this.head};}/**
29192919+ Convert a JSON representation of a range to a `SelectionRange`
29202920+ instance.
29212921+ */}],[{key:"fromJSON",value:function fromJSON(json){if(!json||typeof json.anchor!="number"||typeof json.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return EditorSelection.range(json.anchor,json.head);}}]);return SelectionRange;}();/**
29222922+An editor selection holds one or more selection ranges.
29232923+*/var EditorSelection=/*#__PURE__*/function(){/**
29242924+ @internal
29252925+ */function EditorSelection(/**
29262926+ The ranges in the selection, sorted by position. Ranges cannot
29272927+ overlap (but they may touch, if they aren't empty).
29282928+ */ranges){var mainIndex=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;_classCallCheck(this,EditorSelection);this.ranges=ranges;this.mainIndex=mainIndex;}/**
29292929+ Map a selection through a change. Used to adjust the selection
29302930+ position for changes.
29312931+ */_createClass(EditorSelection,[{key:"map",value:function map(change){var assoc=arguments.length>1&&arguments[1]!==undefined?arguments[1]:-1;if(change.empty)return this;return EditorSelection.create(this.ranges.map(function(r){return r.map(change,assoc);}),this.mainIndex);}/**
29322932+ Compare this selection to another selection.
29332933+ */},{key:"eq",value:function eq(other){if(this.ranges.length!=other.ranges.length||this.mainIndex!=other.mainIndex)return false;for(var _i107=0;_i107<this.ranges.length;_i107++){if(!this.ranges[_i107].eq(other.ranges[_i107]))return false;}return true;}/**
29342934+ Get the primary selection range. Usually, you should make sure
29352935+ your code applies to _all_ ranges, by using methods like
29362936+ [`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).
29372937+ */},{key:"main",get:function get(){return this.ranges[this.mainIndex];}/**
29382938+ Make sure the selection only has one range. Returns a selection
29392939+ holding only the main range from this selection.
29402940+ */},{key:"asSingle",value:function asSingle(){return this.ranges.length==1?this:new EditorSelection([this.main]);}/**
29412941+ Extend this selection with an extra range.
29422942+ */},{key:"addRange",value:function addRange(range){var main=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;return EditorSelection.create([range].concat(this.ranges),main?0:this.mainIndex+1);}/**
29432943+ Replace a given range with another range, and then normalize the
29442944+ selection to merge and sort ranges if necessary.
29452945+ */},{key:"replaceRange",value:function replaceRange(range){var which=arguments.length>1&&arguments[1]!==undefined?arguments[1]:this.mainIndex;var ranges=this.ranges.slice();ranges[which]=range;return EditorSelection.create(ranges,this.mainIndex);}/**
29462946+ Convert this selection to an object that can be serialized to
29472947+ JSON.
29482948+ */},{key:"toJSON",value:function toJSON(){return{ranges:this.ranges.map(function(r){return r.toJSON();}),main:this.mainIndex};}/**
29492949+ Create a selection from a JSON representation.
29502950+ */}],[{key:"fromJSON",value:function fromJSON(json){if(!json||!Array.isArray(json.ranges)||typeof json.main!="number"||json.main>=json.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new EditorSelection(json.ranges.map(function(r){return SelectionRange.fromJSON(r);}),json.main);}/**
29512951+ Create a selection holding a single range.
29522952+ */},{key:"single",value:function single(anchor){var head=arguments.length>1&&arguments[1]!==undefined?arguments[1]:anchor;return new EditorSelection([EditorSelection.range(anchor,head)],0);}/**
29532953+ Sort and merge the given set of ranges, creating a valid
29542954+ selection.
29552955+ */},{key:"create",value:function create(ranges){var mainIndex=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;if(ranges.length==0)throw new RangeError("A selection needs at least one range");for(var pos=0,_i108=0;_i108<ranges.length;_i108++){var range=ranges[_i108];if(range.empty?range.from<=pos:range.from<pos)return normalized(ranges.slice(),mainIndex);pos=range.to;}return new EditorSelection(ranges,mainIndex);}/**
29562956+ Create a cursor selection range at the given position. You can
29572957+ safely ignore the optional arguments in most situations.
29582958+ */},{key:"cursor",value:function cursor(pos){var assoc=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var bidiLevel=arguments.length>2?arguments[2]:undefined;var goalColumn=arguments.length>3?arguments[3]:undefined;return new SelectionRange(pos,pos,(assoc==0?0:assoc<0?4/* AssocBefore */:8/* AssocAfter */)|(bidiLevel==null?3:Math.min(2,bidiLevel))|(goalColumn!==null&&goalColumn!==void 0?goalColumn:33554431/* NoGoalColumn */)<<5/* GoalColumnOffset */);}/**
29592959+ Create a selection range.
29602960+ */},{key:"range",value:function range(anchor,head,goalColumn){var goal=(goalColumn!==null&&goalColumn!==void 0?goalColumn:33554431/* NoGoalColumn */)<<5/* GoalColumnOffset */;return head<anchor?new SelectionRange(head,anchor,16/* Inverted */|goal):new SelectionRange(anchor,head,goal);}}]);return EditorSelection;}();function normalized(ranges){var mainIndex=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var main=ranges[mainIndex];ranges.sort(function(a,b){return a.from-b.from;});mainIndex=ranges.indexOf(main);for(var _i109=1;_i109<ranges.length;_i109++){var range=ranges[_i109],prev=ranges[_i109-1];if(range.empty?range.from<=prev.to:range.from<prev.to){var from=prev.from,to=Math.max(range.to,prev.to);if(_i109<=mainIndex)mainIndex--;ranges.splice(--_i109,2,range.anchor>range.head?EditorSelection.range(to,from):EditorSelection.range(from,to));}}return new EditorSelection(ranges,mainIndex);}function checkSelection(selection,docLength){var _iterator169=_createForOfIteratorHelper(selection.ranges),_step169;try{for(_iterator169.s();!(_step169=_iterator169.n()).done;){var range=_step169.value;if(range.to>docLength)throw new RangeError("Selection points outside of document");}}catch(err){_iterator169.e(err);}finally{_iterator169.f();}}var nextID=0;/**
29612961+A facet is a labeled value that is associated with an editor
29622962+state. It takes inputs from any number of extensions, and combines
29632963+those into a single output value.
29642964+29652965+Examples of facets are the [theme](https://codemirror.net/6/docs/ref/#view.EditorView^theme) styles
29662966+associated with an editor or the [tab
29672967+size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) (which is reduced to a single
29682968+value, using the input with the hightest precedence).
29692969+*/var Facet=/*#__PURE__*/function(){function Facet(/**
29702970+ @internal
29712971+ */combine,/**
29722972+ @internal
29732973+ */compareInput,/**
29742974+ @internal
29752975+ */compare,isStatic,/**
29762976+ @internal
29772977+ */extensions){_classCallCheck(this,Facet);this.combine=combine;this.compareInput=compareInput;this.compare=compare;this.isStatic=isStatic;this.extensions=extensions;/**
29782978+ @internal
29792979+ */this.id=nextID++;this["default"]=combine([]);}/**
29802980+ Define a new facet.
29812981+ */_createClass(Facet,[{key:"of",value:/**
29822982+ Returns an extension that adds the given value for this facet.
29832983+ */function of(value){return new FacetProvider([],this,0/* Static */,value);}/**
29842984+ Create an extension that computes a value for the facet from a
29852985+ state. You must take care to declare the parts of the state that
29862986+ this value depends on, since your function is only called again
29872987+ for a new state when one of those parts changed.
29882988+29892989+ In most cases, you'll want to use the
29902990+ [`provide`](https://codemirror.net/6/docs/ref/#state.StateField^define^config.provide) option when
29912991+ defining a field instead.
29922992+ */},{key:"compute",value:function compute(deps,get){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(deps,this,1/* Single */,get);}/**
29932993+ Create an extension that computes zero or more values for this
29942994+ facet from a state.
29952995+ */},{key:"computeN",value:function computeN(deps,get){if(this.isStatic)throw new Error("Can't compute a static facet");return new FacetProvider(deps,this,2/* Multi */,get);}},{key:"from",value:function from(field,get){if(!get)get=function get(x){return x;};return this.compute([field],function(state){return get(state.field(field));});}}],[{key:"define",value:function define(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return new Facet(config.combine||function(a){return a;},config.compareInput||function(a,b){return a===b;},config.compare||(!config.combine?sameArray:function(a,b){return a===b;}),!!config["static"],config.enables);}}]);return Facet;}();function sameArray(a,b){return a==b||a.length==b.length&&a.every(function(e,i){return e===b[i];});}var FacetProvider=/*#__PURE__*/function(){function FacetProvider(dependencies,facet,type,value){_classCallCheck(this,FacetProvider);this.dependencies=dependencies;this.facet=facet;this.type=type;this.value=value;this.id=nextID++;}_createClass(FacetProvider,[{key:"dynamicSlot",value:function dynamicSlot(addresses){var _a;var getter=this.value;var compare=this.facet.compareInput;var idx=addresses[this.id]>>1,multi=this.type==2/* Multi */;var depDoc=false,depSel=false,depAddrs=[];var _iterator170=_createForOfIteratorHelper(this.dependencies),_step170;try{for(_iterator170.s();!(_step170=_iterator170.n()).done;){var dep=_step170.value;if(dep=="doc")depDoc=true;else if(dep=="selection")depSel=true;else if((((_a=addresses[dep.id])!==null&&_a!==void 0?_a:1)&1)==0)depAddrs.push(addresses[dep.id]);}}catch(err){_iterator170.e(err);}finally{_iterator170.f();}return function(state,tr){var oldVal=state.values[idx];if(oldVal===Uninitialized){state.values[idx]=getter(state);return 1/* Changed */;}if(tr){var depChanged=depDoc&&tr.docChanged||depSel&&(tr.docChanged||tr.selection)||depAddrs.some(function(addr){return(ensureAddr(state,addr)&1/* Changed */)>0;});if(depChanged){var newVal=getter(state);if(multi?!compareArray(newVal,oldVal,compare):!compare(newVal,oldVal)){state.values[idx]=newVal;return 1/* Changed */;}}}return 0;};}}]);return FacetProvider;}();function compareArray(a,b,compare){if(a.length!=b.length)return false;for(var _i110=0;_i110<a.length;_i110++){if(!compare(a[_i110],b[_i110]))return false;}return true;}function dynamicFacetSlot(addresses,facet,providers){var providerAddrs=providers.map(function(p){return addresses[p.id];});var providerTypes=providers.map(function(p){return p.type;});var dynamic=providerAddrs.filter(function(p){return!(p&1);});var idx=addresses[facet.id]>>1;return function(state,tr){var oldVal=state.values[idx],changed=oldVal===Uninitialized||!tr;var _iterator171=_createForOfIteratorHelper(dynamic),_step171;try{for(_iterator171.s();!(_step171=_iterator171.n()).done;){var dynAddr=_step171.value;if(ensureAddr(state,dynAddr)&1/* Changed */)changed=true;}}catch(err){_iterator171.e(err);}finally{_iterator171.f();}if(!changed)return 0;var values=[];for(var _i111=0;_i111<providerAddrs.length;_i111++){var _value2=getAddr(state,providerAddrs[_i111]);if(providerTypes[_i111]==2/* Multi */){var _iterator172=_createForOfIteratorHelper(_value2),_step172;try{for(_iterator172.s();!(_step172=_iterator172.n()).done;){var val=_step172.value;values.push(val);}}catch(err){_iterator172.e(err);}finally{_iterator172.f();}}else values.push(_value2);}var value=facet.combine(values);if(facet.compare(value,oldVal))return 0;state.values[idx]=value;return 1/* Changed */;};}var initField=Facet.define({"static":true});/**
29962996+Fields can store additional information in an editor state, and
29972997+keep it in sync with the rest of the state.
29982998+*/var StateField=/*#__PURE__*/function(){function StateField(/**
29992999+ @internal
30003000+ */id,createF,updateF,compareF,/**
30013001+ @internal
30023002+ */spec){_classCallCheck(this,StateField);this.id=id;this.createF=createF;this.updateF=updateF;this.compareF=compareF;this.spec=spec;/**
30033003+ @internal
30043004+ */this.provides=undefined;}/**
30053005+ Define a state field.
30063006+ */_createClass(StateField,[{key:"create",value:function create(state){var _this80=this;var init=state.facet(initField).find(function(i){return i.field==_this80;});return((init===null||init===void 0?void 0:init.create)||this.createF)(state);}/**
30073007+ @internal
30083008+ */},{key:"slot",value:function slot(addresses){var _this81=this;var idx=addresses[this.id]>>1;return function(state,tr){var oldVal=state.values[idx];if(oldVal===Uninitialized){state.values[idx]=_this81.create(state);return 1/* Changed */;}if(tr){var value=_this81.updateF(oldVal,tr);if(!_this81.compareF(oldVal,value)){state.values[idx]=value;return 1/* Changed */;}}return 0;};}/**
30093009+ Returns an extension that enables this field and overrides the
30103010+ way it is initialized. Can be useful when you need to provide a
30113011+ non-default starting value for the field.
30123012+ */},{key:"init",value:function init(create){return[this,initField.of({field:this,create:create})];}/**
30133013+ State field instances can be used as
30143014+ [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
30153015+ given state.
30163016+ */},{key:"extension",get:function get(){return this;}}],[{key:"define",value:function define(config){var field=new StateField(nextID++,config.create,config.update,config.compare||function(a,b){return a===b;},config);if(config.provide)field.provides=config.provide(field);return field;}}]);return StateField;}();var Prec_={lowest:4,low:3,"default":2,high:1,highest:0};function prec(value){return function(ext){return new PrecExtension(ext,value);};}/**
30173017+By default extensions are registered in the order they are found
30183018+in the flattened form of nested array that was provided.
30193019+Individual extension values can be assigned a precedence to
30203020+override this. Extensions that do not have a precedence set get
30213021+the precedence of the nearest parent with a precedence, or
30223022+[`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
30233023+final ordering of extensions is determined by first sorting by
30243024+precedence and then by order within each precedence.
30253025+*/var Prec={/**
30263026+ The lowest precedence level. Meant for things that should end up
30273027+ near the end of the extension order.
30283028+ */lowest:prec(Prec_.lowest),/**
30293029+ A lower-than-default precedence, for extensions.
30303030+ */low:prec(Prec_.low),/**
30313031+ The default precedence, which is also used for extensions
30323032+ without an explicit precedence.
30333033+ */"default":prec(Prec_["default"]),/**
30343034+ A higher-than-default precedence, for extensions that should
30353035+ come before those with default precedence.
30363036+ */high:prec(Prec_.high),/**
30373037+ The highest precedence level, for extensions that should end up
30383038+ near the start of the precedence ordering.
30393039+ */highest:prec(Prec_.highest),// FIXME Drop these in some future breaking version
30403040+/**
30413041+ Backwards-compatible synonym for `Prec.lowest`.
30423042+ */fallback:prec(Prec_.lowest),/**
30433043+ Backwards-compatible synonym for `Prec.high`.
30443044+ */extend:prec(Prec_.high),/**
30453045+ Backwards-compatible synonym for `Prec.highest`.
30463046+ */override:prec(Prec_.highest)};var PrecExtension=/*#__PURE__*/_createClass(function PrecExtension(inner,prec){_classCallCheck(this,PrecExtension);this.inner=inner;this.prec=prec;});/**
30473047+Extension compartments can be used to make a configuration
30483048+dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
30493049+configuration in a compartment, you can later
30503050+[replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
30513051+transaction.
30523052+*/var Compartment=/*#__PURE__*/function(){function Compartment(){_classCallCheck(this,Compartment);}_createClass(Compartment,[{key:"of",value:/**
30533053+ Create an instance of this compartment to add to your [state
30543054+ configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
30553055+ */function of(ext){return new CompartmentInstance(this,ext);}/**
30563056+ Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
30573057+ reconfigures this compartment.
30583058+ */},{key:"reconfigure",value:function reconfigure(content){return Compartment.reconfigure.of({compartment:this,extension:content});}/**
30593059+ Get the current content of the compartment in the state, or
30603060+ `undefined` if it isn't present.
30613061+ */},{key:"get",value:function get(state){return state.config.compartments.get(this);}}]);return Compartment;}();var CompartmentInstance=/*#__PURE__*/_createClass(function CompartmentInstance(compartment,inner){_classCallCheck(this,CompartmentInstance);this.compartment=compartment;this.inner=inner;});var Configuration=/*#__PURE__*/function(){function Configuration(base,compartments,dynamicSlots,address,staticValues){_classCallCheck(this,Configuration);this.base=base;this.compartments=compartments;this.dynamicSlots=dynamicSlots;this.address=address;this.staticValues=staticValues;this.statusTemplate=[];while(this.statusTemplate.length<dynamicSlots.length){this.statusTemplate.push(0/* Unresolved */);}}_createClass(Configuration,[{key:"staticFacet",value:function staticFacet(facet){var addr=this.address[facet.id];return addr==null?facet["default"]:this.staticValues[addr>>1];}}],[{key:"resolve",value:function resolve(base,compartments,oldState){var fields=[];var facets=Object.create(null);var newCompartments=new Map();var _iterator173=_createForOfIteratorHelper(flatten(base,compartments,newCompartments)),_step173;try{for(_iterator173.s();!(_step173=_iterator173.n()).done;){var ext=_step173.value;if(ext instanceof StateField)fields.push(ext);else(facets[ext.facet.id]||(facets[ext.facet.id]=[])).push(ext);}}catch(err){_iterator173.e(err);}finally{_iterator173.f();}var address=Object.create(null);var staticValues=[];var dynamicSlots=[];var _loop17=function _loop17(){var field=_fields[_i112];address[field.id]=dynamicSlots.length<<1;dynamicSlots.push(function(a){return field.slot(a);});};for(var _i112=0,_fields=fields;_i112<_fields.length;_i112++){_loop17();}var _loop18=function _loop18(id){var providers=facets[id],facet=providers[0].facet;if(providers.every(function(p){return p.type==0;}/* Static */)){address[facet.id]=staticValues.length<<1|1;var value=facet.combine(providers.map(function(p){return p.value;}));var oldAddr=oldState?oldState.config.address[facet.id]:null;if(oldAddr!=null){var oldVal=getAddr(oldState,oldAddr);if(facet.compare(value,oldVal))value=oldVal;}staticValues.push(value);}else{var _iterator174=_createForOfIteratorHelper(providers),_step174;try{var _loop19=function _loop19(){var p=_step174.value;if(p.type==0/* Static */){address[p.id]=staticValues.length<<1|1;staticValues.push(p.value);}else{address[p.id]=dynamicSlots.length<<1;dynamicSlots.push(function(a){return p.dynamicSlot(a);});}};for(_iterator174.s();!(_step174=_iterator174.n()).done;){_loop19();}}catch(err){_iterator174.e(err);}finally{_iterator174.f();}address[facet.id]=dynamicSlots.length<<1;dynamicSlots.push(function(a){return dynamicFacetSlot(a,facet,providers);});}};for(var id in facets){_loop18(id);}return new Configuration(base,newCompartments,dynamicSlots.map(function(f){return f(address);}),address,staticValues);}}]);return Configuration;}();function flatten(extension,compartments,newCompartments){var result=[[],[],[],[],[]];var seen=new Map();function inner(ext,prec){var known=seen.get(ext);if(known!=null){if(known>=prec)return;var found=result[known].indexOf(ext);if(found>-1)result[known].splice(found,1);if(ext instanceof CompartmentInstance)newCompartments["delete"](ext.compartment);}seen.set(ext,prec);if(Array.isArray(ext)){var _iterator175=_createForOfIteratorHelper(ext),_step175;try{for(_iterator175.s();!(_step175=_iterator175.n()).done;){var e=_step175.value;inner(e,prec);}}catch(err){_iterator175.e(err);}finally{_iterator175.f();}}else if(ext instanceof CompartmentInstance){if(newCompartments.has(ext.compartment))throw new RangeError("Duplicate use of compartment in extensions");var content=compartments.get(ext.compartment)||ext.inner;newCompartments.set(ext.compartment,content);inner(content,prec);}else if(ext instanceof PrecExtension){inner(ext.inner,ext.prec);}else if(ext instanceof StateField){result[prec].push(ext);if(ext.provides)inner(ext.provides,prec);}else if(ext instanceof FacetProvider){result[prec].push(ext);if(ext.facet.extensions)inner(ext.facet.extensions,prec);}else{var _content=ext.extension;if(!_content)throw new Error("Unrecognized extension value in extension set (".concat(ext,"). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks."));inner(_content,prec);}}inner(extension,Prec_["default"]);return result.reduce(function(a,b){return a.concat(b);});}var Uninitialized={};function ensureAddr(state,addr){if(addr&1)return 2/* Computed */;var idx=addr>>1;var status=state.status[idx];if(status==4/* Computing */)throw new Error("Cyclic dependency between fields and/or facets");if(status&2/* Computed */)return status;state.status[idx]=4/* Computing */;var changed=state.config.dynamicSlots[idx](state,state.applying);return state.status[idx]=2/* Computed */|changed;}function getAddr(state,addr){return addr&1?state.config.staticValues[addr>>1]:state.values[addr>>1];}var languageData=Facet.define();var allowMultipleSelections=Facet.define({combine:function combine(values){return values.some(function(v){return v;});},"static":true});var lineSeparator=Facet.define({combine:function combine(values){return values.length?values[0]:undefined;},"static":true});var changeFilter=Facet.define();var transactionFilter=Facet.define();var transactionExtender=Facet.define();var readOnly=Facet.define({combine:function combine(values){return values.length?values[0]:false;}});/**
30623062+Annotations are tagged values that are used to add metadata to
30633063+transactions in an extensible way. They should be used to model
30643064+things that effect the entire transaction (such as its [time
30653065+stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
30663066+[origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
30673067+_alongside_ the other changes made by the transaction, [state
30683068+effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
30693069+*/var Annotation=/*#__PURE__*/function(){/**
30703070+ @internal
30713071+ */function Annotation(/**
30723072+ The annotation type.
30733073+ */type,/**
30743074+ The value of this annotation.
30753075+ */value){_classCallCheck(this,Annotation);this.type=type;this.value=value;}/**
30763076+ Define a new type of annotation.
30773077+ */_createClass(Annotation,null,[{key:"define",value:function define(){return new AnnotationType();}}]);return Annotation;}();/**
30783078+Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
30793079+*/var AnnotationType=/*#__PURE__*/function(){function AnnotationType(){_classCallCheck(this,AnnotationType);}_createClass(AnnotationType,[{key:"of",value:/**
30803080+ Create an instance of this annotation.
30813081+ */function of(value){return new Annotation(this,value);}}]);return AnnotationType;}();/**
30823082+Representation of a type of state effect. Defined with
30833083+[`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
30843084+*/var StateEffectType=/*#__PURE__*/function(){/**
30853085+ @internal
30863086+ */function StateEffectType(// The `any` types in these function types are there to work
30873087+// around TypeScript issue #37631, where the type guard on
30883088+// `StateEffect.is` mysteriously stops working when these properly
30893089+// have type `Value`.
30903090+/**
30913091+ @internal
30923092+ */map){_classCallCheck(this,StateEffectType);this.map=map;}/**
30933093+ Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
30943094+ type.
30953095+ */_createClass(StateEffectType,[{key:"of",value:function of(value){return new StateEffect(this,value);}}]);return StateEffectType;}();/**
30963096+State effects can be used to represent additional effects
30973097+associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
30983098+are often useful to model changes to custom [state
30993099+fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
31003100+document or selection changes.
31013101+*/var StateEffect=/*#__PURE__*/function(){/**
31023102+ @internal
31033103+ */function StateEffect(/**
31043104+ @internal
31053105+ */type,/**
31063106+ The value of this effect.
31073107+ */value){_classCallCheck(this,StateEffect);this.type=type;this.value=value;}/**
31083108+ Map this effect through a position mapping. Will return
31093109+ `undefined` when that ends up deleting the effect.
31103110+ */_createClass(StateEffect,[{key:"map",value:function map(mapping){var mapped=this.type.map(this.value,mapping);return mapped===undefined?undefined:mapped==this.value?this:new StateEffect(this.type,mapped);}/**
31113111+ Tells you whether this effect object is of a given
31123112+ [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
31133113+ */},{key:"is",value:function is(type){return this.type==type;}/**
31143114+ Define a new effect type. The type parameter indicates the type
31153115+ of values that his effect holds.
31163116+ */}],[{key:"define",value:function define(){var spec=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return new StateEffectType(spec.map||function(v){return v;});}/**
31173117+ Map an array of effects through a change set.
31183118+ */},{key:"mapEffects",value:function mapEffects(effects,mapping){if(!effects.length)return effects;var result=[];var _iterator176=_createForOfIteratorHelper(effects),_step176;try{for(_iterator176.s();!(_step176=_iterator176.n()).done;){var effect=_step176.value;var mapped=effect.map(mapping);if(mapped)result.push(mapped);}}catch(err){_iterator176.e(err);}finally{_iterator176.f();}return result;}}]);return StateEffect;}();/**
31193119+This effect can be used to reconfigure the root extensions of
31203120+the editor. Doing this will discard any extensions
31213121+[appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
31223122+the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
31233123+compartments.
31243124+*/StateEffect.reconfigure=StateEffect.define();/**
31253125+Append extensions to the top-level configuration of the editor.
31263126+*/StateEffect.appendConfig=StateEffect.define();/**
31273127+Changes to the editor state are grouped into transactions.
31283128+Typically, a user action creates a single transaction, which may
31293129+contain any number of document changes, may change the selection,
31303130+or have other effects. Create a transaction by calling
31313131+[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
31323132+*/var Transaction=/*#__PURE__*/function(){/**
31333133+ @internal
31343134+ */function Transaction(/**
31353135+ The state from which the transaction starts.
31363136+ */startState,/**
31373137+ The document changes made by this transaction.
31383138+ */changes,/**
31393139+ The selection set by this transaction, or undefined if it
31403140+ doesn't explicitly set a selection.
31413141+ */selection,/**
31423142+ The effects added to the transaction.
31433143+ */effects,/**
31443144+ @internal
31453145+ */annotations,/**
31463146+ Whether the selection should be scrolled into view after this
31473147+ transaction is dispatched.
31483148+ */scrollIntoView){_classCallCheck(this,Transaction);this.startState=startState;this.changes=changes;this.selection=selection;this.effects=effects;this.annotations=annotations;this.scrollIntoView=scrollIntoView;/**
31493149+ @internal
31503150+ */this._doc=null;/**
31513151+ @internal
31523152+ */this._state=null;if(selection)checkSelection(selection,changes.newLength);if(!annotations.some(function(a){return a.type==Transaction.time;}))this.annotations=annotations.concat(Transaction.time.of(Date.now()));}/**
31533153+ The new document produced by the transaction. Contrary to
31543154+ [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
31553155+ force the entire new state to be computed right away, so it is
31563156+ recommended that [transaction
31573157+ filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
31583158+ when they need to look at the new document.
31593159+ */_createClass(Transaction,[{key:"newDoc",get:function get(){return this._doc||(this._doc=this.changes.apply(this.startState.doc));}/**
31603160+ The new selection produced by the transaction. If
31613161+ [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
31623162+ this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
31633163+ current selection through the changes made by the transaction.
31643164+ */},{key:"newSelection",get:function get(){return this.selection||this.startState.selection.map(this.changes);}/**
31653165+ The new state created by the transaction. Computed on demand
31663166+ (but retained for subsequent access), so itis recommended not to
31673167+ access it in [transaction
31683168+ filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
31693169+ */},{key:"state",get:function get(){if(!this._state)this.startState.applyTransaction(this);return this._state;}/**
31703170+ Get the value of the given annotation type, if any.
31713171+ */},{key:"annotation",value:function annotation(type){var _iterator177=_createForOfIteratorHelper(this.annotations),_step177;try{for(_iterator177.s();!(_step177=_iterator177.n()).done;){var ann=_step177.value;if(ann.type==type)return ann.value;}}catch(err){_iterator177.e(err);}finally{_iterator177.f();}return undefined;}/**
31723172+ Indicates whether the transaction changed the document.
31733173+ */},{key:"docChanged",get:function get(){return!this.changes.empty;}/**
31743174+ Indicates whether this transaction reconfigures the state
31753175+ (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
31763176+ with a top-level configuration
31773177+ [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
31783178+ */},{key:"reconfigured",get:function get(){return this.startState.config!=this.state.config;}/**
31793179+ Returns true if the transaction has a [user
31803180+ event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
31813181+ or more specific than `event`. For example, if the transaction
31823182+ has `"select.pointer"` as user event, `"select"` and
31833183+ `"select.pointer"` will match it.
31843184+ */},{key:"isUserEvent",value:function isUserEvent(event){var e=this.annotation(Transaction.userEvent);return!!(e&&(e==event||e.length>event.length&&e.slice(0,event.length)==event&&e[event.length]=="."));}}]);return Transaction;}();/**
31853185+Annotation used to store transaction timestamps.
31863186+*/Transaction.time=Annotation.define();/**
31873187+Annotation used to associate a transaction with a user interface
31883188+event. Holds a string identifying the event, using a
31893189+dot-separated format to support attaching more specific
31903190+information. The events used by the core libraries are:
31913191+31923192+ - `"input"` when content is entered
31933193+ - `"input.type"` for typed input
31943194+ - `"input.type.compose"` for composition
31953195+ - `"input.paste"` for pasted input
31963196+ - `"input.drop"` when adding content with drag-and-drop
31973197+ - `"input.complete"` when autocompleting
31983198+ - `"delete"` when the user deletes content
31993199+ - `"delete.selection"` when deleting the selection
32003200+ - `"delete.forward"` when deleting forward from the selection
32013201+ - `"delete.backward"` when deleting backward from the selection
32023202+ - `"delete.cut"` when cutting to the clipboard
32033203+ - `"move"` when content is moved
32043204+ - `"move.drop"` when content is moved within the editor through drag-and-drop
32053205+ - `"select"` when explicitly changing the selection
32063206+ - `"select.pointer"` when selecting with a mouse or other pointing device
32073207+ - `"undo"` and `"redo"` for history actions
32083208+32093209+Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
32103210+whether the annotation matches a given event.
32113211+*/Transaction.userEvent=Annotation.define();/**
32123212+Annotation indicating whether a transaction should be added to
32133213+the undo history or not.
32143214+*/Transaction.addToHistory=Annotation.define();/**
32153215+Annotation indicating (when present and true) that a transaction
32163216+represents a change made by some other actor, not the user. This
32173217+is used, for example, to tag other people's changes in
32183218+collaborative editing.
32193219+*/Transaction.remote=Annotation.define();function joinRanges(a,b){var result=[];for(var iA=0,iB=0;;){var from=void 0,to=void 0;if(iA<a.length&&(iB==b.length||b[iB]>=a[iA])){from=a[iA++];to=a[iA++];}else if(iB<b.length){from=b[iB++];to=b[iB++];}else return result;if(!result.length||result[result.length-1]<from)result.push(from,to);else if(result[result.length-1]<to)result[result.length-1]=to;}}function mergeTransaction(a,b,sequential){var _a;var mapForA,mapForB,changes;if(sequential){mapForA=b.changes;mapForB=ChangeSet.empty(b.changes.length);changes=a.changes.compose(b.changes);}else{mapForA=b.changes.map(a.changes);mapForB=a.changes.mapDesc(b.changes,true);changes=a.changes.compose(mapForA);}return{changes:changes,selection:b.selection?b.selection.map(mapForB):(_a=a.selection)===null||_a===void 0?void 0:_a.map(mapForA),effects:StateEffect.mapEffects(a.effects,mapForA).concat(StateEffect.mapEffects(b.effects,mapForB)),annotations:a.annotations.length?a.annotations.concat(b.annotations):b.annotations,scrollIntoView:a.scrollIntoView||b.scrollIntoView};}function resolveTransactionInner(state,spec,docSize){var sel=spec.selection,annotations=asArray(spec.annotations);if(spec.userEvent)annotations=annotations.concat(Transaction.userEvent.of(spec.userEvent));return{changes:spec.changes instanceof ChangeSet?spec.changes:ChangeSet.of(spec.changes||[],docSize,state.facet(lineSeparator)),selection:sel&&(sel instanceof EditorSelection?sel:EditorSelection.single(sel.anchor,sel.head)),effects:asArray(spec.effects),annotations:annotations,scrollIntoView:!!spec.scrollIntoView};}function resolveTransaction(state,specs,filter){var s=resolveTransactionInner(state,specs.length?specs[0]:{},state.doc.length);if(specs.length&&specs[0].filter===false)filter=false;for(var _i113=1;_i113<specs.length;_i113++){if(specs[_i113].filter===false)filter=false;var seq=!!specs[_i113].sequential;s=mergeTransaction(s,resolveTransactionInner(state,specs[_i113],seq?s.changes.newLength:state.doc.length),seq);}var tr=new Transaction(state,s.changes,s.selection,s.effects,s.annotations,s.scrollIntoView);return extendTransaction(filter?filterTransaction(tr):tr);}// Finish a transaction by applying filters if necessary.
32203220+function filterTransaction(tr){var state=tr.startState;// Change filters
32213221+var result=true;var _iterator178=_createForOfIteratorHelper(state.facet(changeFilter)),_step178;try{for(_iterator178.s();!(_step178=_iterator178.n()).done;){var filter=_step178.value;var value=filter(tr);if(value===false){result=false;break;}if(Array.isArray(value))result=result===true?value:joinRanges(result,value);}}catch(err){_iterator178.e(err);}finally{_iterator178.f();}if(result!==true){var changes,back;if(result===false){back=tr.changes.invertedDesc;changes=ChangeSet.empty(state.doc.length);}else{var filtered=tr.changes.filter(result);changes=filtered.changes;back=filtered.filtered.invertedDesc;}tr=new Transaction(state,changes,tr.selection&&tr.selection.map(back),StateEffect.mapEffects(tr.effects,back),tr.annotations,tr.scrollIntoView);}// Transaction filters
32223222+var filters=state.facet(transactionFilter);for(var _i114=filters.length-1;_i114>=0;_i114--){var _filtered=filters[_i114](tr);if(_filtered instanceof Transaction)tr=_filtered;else if(Array.isArray(_filtered)&&_filtered.length==1&&_filtered[0]instanceof Transaction)tr=_filtered[0];else tr=resolveTransaction(state,asArray(_filtered),false);}return tr;}function extendTransaction(tr){var state=tr.startState,extenders=state.facet(transactionExtender),spec=tr;for(var _i115=extenders.length-1;_i115>=0;_i115--){var extension=extenders[_i115](tr);if(extension&&Object.keys(extension).length)spec=mergeTransaction(tr,resolveTransactionInner(state,extension,tr.changes.newLength),true);}return spec==tr?tr:new Transaction(state,tr.changes,tr.selection,spec.effects,spec.annotations,spec.scrollIntoView);}var none=[];function asArray(value){return value==null?none:Array.isArray(value)?value:[value];}/**
32233223+The categories produced by a [character
32243224+categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
32253225+do things like selecting by word.
32263226+*/exports.CharCategory=void 0;(function(CharCategory){/**
32273227+ Word characters.
32283228+ */CharCategory[CharCategory["Word"]=0]="Word";/**
32293229+ Whitespace.
32303230+ */CharCategory[CharCategory["Space"]=1]="Space";/**
32313231+ Anything else.
32323232+ */CharCategory[CharCategory["Other"]=2]="Other";})(exports.CharCategory||(exports.CharCategory={}));var nonASCIISingleCaseWordChar=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;var wordChar;try{wordChar=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u");}catch(_){}function hasWordChar(str){if(wordChar)return wordChar.test(str);for(var _i116=0;_i116<str.length;_i116++){var ch=str[_i116];if(/\w/.test(ch)||ch>"\x80"&&(ch.toUpperCase()!=ch.toLowerCase()||nonASCIISingleCaseWordChar.test(ch)))return true;}return false;}function makeCategorizer(wordChars){return function(_char3){if(!/\S/.test(_char3))return exports.CharCategory.Space;if(hasWordChar(_char3))return exports.CharCategory.Word;for(var _i117=0;_i117<wordChars.length;_i117++){if(_char3.indexOf(wordChars[_i117])>-1)return exports.CharCategory.Word;}return exports.CharCategory.Other;};}/**
32333233+The editor state class is a persistent (immutable) data structure.
32343234+To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
32353235+[transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
32363236+instance, without modifying the original object.
32373237+32383238+As such, _never_ mutate properties of a state directly. That'll
32393239+just break things.
32403240+*/var EditorState=/*#__PURE__*/function(){/**
32413241+ @internal
32423242+ */function EditorState(/**
32433243+ @internal
32443244+ */config,/**
32453245+ The current document.
32463246+ */doc,/**
32473247+ The current selection.
32483248+ */selection,/**
32493249+ @internal
32503250+ */values){var tr=arguments.length>4&&arguments[4]!==undefined?arguments[4]:null;_classCallCheck(this,EditorState);this.config=config;this.doc=doc;this.selection=selection;this.values=values;/**
32513251+ @internal
32523252+ */this.applying=null;this.status=config.statusTemplate.slice();this.applying=tr;// Fill in the computed state immediately, so that further queries
32533253+// for it made during the update return this state
32543254+if(tr)tr._state=this;for(var _i118=0;_i118<this.config.dynamicSlots.length;_i118++){ensureAddr(this,_i118<<1);}this.applying=null;}_createClass(EditorState,[{key:"field",value:function field(_field){var require=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var addr=this.config.address[_field.id];if(addr==null){if(require)throw new RangeError("Field is not present in this state");return undefined;}ensureAddr(this,addr);return getAddr(this,addr);}/**
32553255+ Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
32563256+ state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
32573257+ can be passed. Unless
32583258+ [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
32593259+ [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
32603260+ are assumed to start in the _current_ document (not the document
32613261+ produced by previous specs), and its
32623262+ [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
32633263+ [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
32643264+ to the document created by its _own_ changes. The resulting
32653265+ transaction contains the combined effect of all the different
32663266+ specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
32673267+ specs take precedence over earlier ones.
32683268+ */},{key:"update",value:function update(){for(var _len2=arguments.length,specs=new Array(_len2),_key=0;_key<_len2;_key++){specs[_key]=arguments[_key];}return resolveTransaction(this,specs,true);}/**
32693269+ @internal
32703270+ */},{key:"applyTransaction",value:function applyTransaction(tr){var conf=this.config,_conf=conf,base=_conf.base,compartments=_conf.compartments;var _iterator179=_createForOfIteratorHelper(tr.effects),_step179;try{for(_iterator179.s();!(_step179=_iterator179.n()).done;){var effect=_step179.value;if(effect.is(Compartment.reconfigure)){if(conf){compartments=new Map();conf.compartments.forEach(function(val,key){return compartments.set(key,val);});conf=null;}compartments.set(effect.value.compartment,effect.value.extension);}else if(effect.is(StateEffect.reconfigure)){conf=null;base=effect.value;}else if(effect.is(StateEffect.appendConfig)){conf=null;base=asArray(base).concat(effect.value);}}}catch(err){_iterator179.e(err);}finally{_iterator179.f();}var startValues;if(!conf){conf=Configuration.resolve(base,compartments,this);var updatedValues=conf.dynamicSlots.map(function(_){return Uninitialized;});// Copy over old values for shared facets/fields
32713271+for(var id in conf.address){var cur=conf.address[id],prev=this.config.address[id];if(prev!=null&&(cur&1)==0)updatedValues[cur>>1]=getAddr(this,prev);}var intermediateState=new EditorState(conf,this.doc,this.selection,updatedValues,null);startValues=intermediateState.values;}else{startValues=tr.startState.values.slice();}new EditorState(conf,tr.newDoc,tr.newSelection,startValues,tr);}/**
32723272+ Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
32733273+ replaces every selection range with the given content.
32743274+ */},{key:"replaceSelection",value:function replaceSelection(text){if(typeof text=="string")text=this.toText(text);return this.changeByRange(function(range){return{changes:{from:range.from,to:range.to,insert:text},range:EditorSelection.cursor(range.from+text.length)};});}/**
32753275+ Create a set of changes and a new selection by running the given
32763276+ function for each range in the active selection. The function
32773277+ can return an optional set of changes (in the coordinate space
32783278+ of the start document), plus an updated range (in the coordinate
32793279+ space of the document produced by the call's own changes). This
32803280+ method will merge all the changes and ranges into a single
32813281+ changeset and selection, and return it as a [transaction
32823282+ spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
32833283+ [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
32843284+ */},{key:"changeByRange",value:function changeByRange(f){var sel=this.selection;var result1=f(sel.ranges[0]);var changes=this.changes(result1.changes),ranges=[result1.range];var effects=asArray(result1.effects);for(var _i119=1;_i119<sel.ranges.length;_i119++){var result=f(sel.ranges[_i119]);var newChanges=this.changes(result.changes),newMapped=newChanges.map(changes);for(var j=0;j<_i119;j++){ranges[j]=ranges[j].map(newMapped);}var mapBy=changes.mapDesc(newChanges,true);ranges.push(result.range.map(mapBy));changes=changes.compose(newMapped);effects=StateEffect.mapEffects(effects,newMapped).concat(StateEffect.mapEffects(asArray(result.effects),mapBy));}return{changes:changes,selection:EditorSelection.create(ranges,sel.mainIndex),effects:effects};}/**
32853285+ Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
32863286+ description, taking the state's document length and line
32873287+ separator into account.
32883288+ */},{key:"changes",value:function changes(){var spec=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];if(spec instanceof ChangeSet)return spec;return ChangeSet.of(spec,this.doc.length,this.facet(EditorState.lineSeparator));}/**
32893289+ Using the state's [line
32903290+ separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
32913291+ [`Text`](https://codemirror.net/6/docs/ref/#text.Text) instance from the given string.
32923292+ */},{key:"toText",value:function toText(string){return text.Text.of(string.split(this.facet(EditorState.lineSeparator)||DefaultSplit));}/**
32933293+ Return the given range of the document as a string.
32943294+ */},{key:"sliceDoc",value:function sliceDoc(){var from=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:this.doc.length;return this.doc.sliceString(from,to,this.lineBreak);}/**
32953295+ Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
32963296+ */},{key:"facet",value:function facet(_facet){var addr=this.config.address[_facet.id];if(addr==null)return _facet["default"];ensureAddr(this,addr);return getAddr(this,addr);}/**
32973297+ Convert this state to a JSON-serializable object. When custom
32983298+ fields should be serialized, you can pass them in as an object
32993299+ mapping property names (in the resulting object, which should
33003300+ not use `doc` or `selection`) to fields.
33013301+ */},{key:"toJSON",value:function toJSON(fields){var result={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(fields)for(var prop in fields){var value=fields[prop];if(value instanceof StateField)result[prop]=value.spec.toJSON(this.field(fields[prop]),this);}return result;}/**
33023302+ Deserialize a state from its JSON representation. When custom
33033303+ fields should be deserialized, pass the same object you passed
33043304+ to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
33053305+ third argument.
33063306+ */},{key:"tabSize",get:/**
33073307+ The size (in columns) of a tab in the document, determined by
33083308+ the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
33093309+ */function get(){return this.facet(EditorState.tabSize);}/**
33103310+ Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
33113311+ string for this state.
33123312+ */},{key:"lineBreak",get:function get(){return this.facet(EditorState.lineSeparator)||"\n";}/**
33133313+ Returns true when the editor is
33143314+ [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
33153315+ */},{key:"readOnly",get:function get(){return this.facet(readOnly);}/**
33163316+ Look up a translation for the given phrase (via the
33173317+ [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
33183318+ original string if no translation is found.
33193319+ */},{key:"phrase",value:function phrase(_phrase){var _iterator180=_createForOfIteratorHelper(this.facet(EditorState.phrases)),_step180;try{for(_iterator180.s();!(_step180=_iterator180.n()).done;){var map=_step180.value;if(Object.prototype.hasOwnProperty.call(map,_phrase))return map[_phrase];}}catch(err){_iterator180.e(err);}finally{_iterator180.f();}return _phrase;}/**
33203320+ Find the values for a given language data field, provided by the
33213321+ the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
33223322+ */},{key:"languageDataAt",value:function languageDataAt(name,pos){var side=arguments.length>2&&arguments[2]!==undefined?arguments[2]:-1;var values=[];var _iterator181=_createForOfIteratorHelper(this.facet(languageData)),_step181;try{for(_iterator181.s();!(_step181=_iterator181.n()).done;){var provider=_step181.value;var _iterator182=_createForOfIteratorHelper(provider(this,pos,side)),_step182;try{for(_iterator182.s();!(_step182=_iterator182.n()).done;){var result=_step182.value;if(Object.prototype.hasOwnProperty.call(result,name))values.push(result[name]);}}catch(err){_iterator182.e(err);}finally{_iterator182.f();}}}catch(err){_iterator181.e(err);}finally{_iterator181.f();}return values;}/**
33233323+ Return a function that can categorize strings (expected to
33243324+ represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#text.findClusterBreak))
33253325+ into one of:
33263326+33273327+ - Word (contains an alphanumeric character or a character
33283328+ explicitly listed in the local language's `"wordChars"`
33293329+ language data, which should be a string)
33303330+ - Space (contains only whitespace)
33313331+ - Other (anything else)
33323332+ */},{key:"charCategorizer",value:function charCategorizer(at){return makeCategorizer(this.languageDataAt("wordChars",at).join(""));}/**
33333333+ Find the word at the given position, meaning the range
33343334+ containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
33353335+ around it. If no word characters are adjacent to the position,
33363336+ this returns null.
33373337+ */},{key:"wordAt",value:function wordAt(pos){var _this$doc$lineAt=this.doc.lineAt(pos),text$1=_this$doc$lineAt.text,from=_this$doc$lineAt.from,length=_this$doc$lineAt.length;var cat=this.charCategorizer(pos);var start=pos-from,end=pos-from;while(start>0){var prev=text.findClusterBreak(text$1,start,false);if(cat(text$1.slice(prev,start))!=exports.CharCategory.Word)break;start=prev;}while(end<length){var next=text.findClusterBreak(text$1,end);if(cat(text$1.slice(end,next))!=exports.CharCategory.Word)break;end=next;}return start==end?null:EditorSelection.range(start+from,end+from);}}],[{key:"fromJSON",value:function fromJSON(json){var config=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var fields=arguments.length>2?arguments[2]:undefined;if(!json||typeof json.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");var fieldInit=[];if(fields){var _loop20=function _loop20(prop){var field=fields[prop],value=json[prop];fieldInit.push(field.init(function(state){return field.spec.fromJSON(value,state);}));};for(var prop in fields){_loop20(prop);}}return EditorState.create({doc:json.doc,selection:EditorSelection.fromJSON(json.selection),extensions:config.extensions?fieldInit.concat([config.extensions]):fieldInit});}/**
33383338+ Create a new state. You'll usually only need this when
33393339+ initializing an editor—updated states are created by applying
33403340+ transactions.
33413341+ */},{key:"create",value:function create(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var configuration=Configuration.resolve(config.extensions||[],new Map());var doc=config.doc instanceof text.Text?config.doc:text.Text.of((config.doc||"").split(configuration.staticFacet(EditorState.lineSeparator)||DefaultSplit));var selection=!config.selection?EditorSelection.single(0):config.selection instanceof EditorSelection?config.selection:EditorSelection.single(config.selection.anchor,config.selection.head);checkSelection(selection,doc.length);if(!configuration.staticFacet(allowMultipleSelections))selection=selection.asSingle();return new EditorState(configuration,doc,selection,configuration.dynamicSlots.map(function(_){return Uninitialized;}));}}]);return EditorState;}();/**
33423342+A facet that, when enabled, causes the editor to allow multiple
33433343+ranges to be selected. Be careful though, because by default the
33443344+editor relies on the native DOM selection, which cannot handle
33453345+multiple selections. An extension like
33463346+[`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
33473347+secondary selections visible to the user.
33483348+*/EditorState.allowMultipleSelections=allowMultipleSelections;/**
33493349+Configures the tab size to use in this state. The first
33503350+(highest-precedence) value of the facet is used. If no value is
33513351+given, this defaults to 4.
33523352+*/EditorState.tabSize=Facet.define({combine:function combine(values){return values.length?values[0]:4;}});/**
33533353+The line separator to use. By default, any of `"\n"`, `"\r\n"`
33543354+and `"\r"` is treated as a separator when splitting lines, and
33553355+lines are joined with `"\n"`.
33563356+33573357+When you configure a value here, only that precise separator
33583358+will be used, allowing you to round-trip documents through the
33593359+editor without normalizing line separators.
33603360+*/EditorState.lineSeparator=lineSeparator;/**
33613361+This facet controls the value of the
33623362+[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
33633363+consulted by commands and extensions that implement editing
33643364+functionality to determine whether they should apply. It
33653365+defaults to false, but when its highest-precedence value is
33663366+`true`, such functionality disables itself.
33673367+33683368+Not to be confused with
33693369+[`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
33703370+controls whether the editor's DOM is set to be editable (and
33713371+thus focusable).
33723372+*/EditorState.readOnly=readOnly;/**
33733373+Registers translation phrases. The
33743374+[`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
33753375+all objects registered with this facet to find translations for
33763376+its argument.
33773377+*/EditorState.phrases=Facet.define();/**
33783378+A facet used to register [language
33793379+data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
33803380+*/EditorState.languageData=languageData;/**
33813381+Facet used to register change filters, which are called for each
33823382+transaction (unless explicitly
33833383+[disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
33843384+part of the transaction's changes.
33853385+33863386+Such a function can return `true` to indicate that it doesn't
33873387+want to do anything, `false` to completely stop the changes in
33883388+the transaction, or a set of ranges in which changes should be
33893389+suppressed. Such ranges are represented as an array of numbers,
33903390+with each pair of two number indicating the start and end of a
33913391+range. So for example `[10, 20, 100, 110]` suppresses changes
33923392+between 10 and 20, and between 100 and 110.
33933393+*/EditorState.changeFilter=changeFilter;/**
33943394+Facet used to register a hook that gets a chance to update or
33953395+replace transaction specs before they are applied. This will
33963396+only be applied for transactions that don't have
33973397+[`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
33983398+can either return a single transaction spec (possibly the input
33993399+transaction), or an array of specs (which will be combined in
34003400+the same way as the arguments to
34013401+[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).
34023402+34033403+When possible, it is recommended to avoid accessing
34043404+[`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
34053405+since it will force creation of a state that will then be
34063406+discarded again, if the transaction is actually filtered.
34073407+34083408+(This functionality should be used with care. Indiscriminately
34093409+modifying transaction is likely to break something or degrade
34103410+the user experience.)
34113411+*/EditorState.transactionFilter=transactionFilter;/**
34123412+This is a more limited form of
34133413+[`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
34143414+which can only add
34153415+[annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
34163416+[effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
34173417+of filter runs even the transaction has disabled regular
34183418+[filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
34193419+for effects that don't need to touch the changes or selection,
34203420+but do want to process every transaction.
34213421+34223422+Extenders run _after_ filters, when both are applied.
34233423+*/EditorState.transactionExtender=transactionExtender;Compartment.reconfigure=StateEffect.define();/**
34243424+Utility function for combining behaviors to fill in a config
34253425+object from an array of provided configs. Will, by default, error
34263426+when a field gets two values that aren't `===`-equal, but you can
34273427+provide combine functions per field to do something else.
34283428+*/function combineConfig(configs,defaults){var combine=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var result={};var _iterator183=_createForOfIteratorHelper(configs),_step183;try{for(_iterator183.s();!(_step183=_iterator183.n()).done;){var config=_step183.value;for(var _i120=0,_Object$keys=Object.keys(config);_i120<_Object$keys.length;_i120++){var _key2=_Object$keys[_i120];var value=config[_key2],current=result[_key2];if(current===undefined)result[_key2]=value;else if(current===value||value===undefined);// No conflict
34293429+else if(Object.hasOwnProperty.call(combine,_key2))result[_key2]=combine[_key2](current,value);else throw new Error("Config merge conflict for field "+_key2);}}}catch(err){_iterator183.e(err);}finally{_iterator183.f();}for(var key in defaults){if(result[key]===undefined)result[key]=defaults[key];}return result;}Object.defineProperty(exports,'Text',{enumerable:true,get:function get(){return text.Text;}});exports.Annotation=Annotation;exports.AnnotationType=AnnotationType;exports.ChangeDesc=ChangeDesc;exports.ChangeSet=ChangeSet;exports.Compartment=Compartment;exports.EditorSelection=EditorSelection;exports.EditorState=EditorState;exports.Facet=Facet;exports.Prec=Prec;exports.SelectionRange=SelectionRange;exports.StateEffect=StateEffect;exports.StateEffectType=StateEffectType;exports.StateField=StateField;exports.Transaction=Transaction;exports.combineConfig=combineConfig;},{"@codemirror/text":24}],23:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var common=require('@lezer/common');var highlight=require('@codemirror/highlight');var language=require('@codemirror/language');// Counts the column offset in a string, taking tabs into account.
34303430+// Used mostly to find indentation.
34313431+function countCol(string,end,tabSize){var startIndex=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;var startValue=arguments.length>4&&arguments[4]!==undefined?arguments[4]:0;if(end==null){end=string.search(/[^\s\u00a0]/);if(end==-1)end=string.length;}var n=startValue;for(var _i121=startIndex;_i121<end;_i121++){if(string.charCodeAt(_i121)==9)n+=tabSize-n%tabSize;else n++;}return n;}/**
34323432+Encapsulates a single line of input. Given to stream syntax code,
34333433+which uses it to tokenize the content.
34343434+*/var StringStream=/*#__PURE__*/function(){/**
34353435+ @internal
34363436+ */function StringStream(/**
34373437+ The line.
34383438+ */string,tabSize,/**
34393439+ The current indent unit size.
34403440+ */indentUnit){_classCallCheck(this,StringStream);this.string=string;this.tabSize=tabSize;this.indentUnit=indentUnit;/**
34413441+ The current position on the line.
34423442+ */this.pos=0;/**
34433443+ The start position of the current token.
34443444+ */this.start=0;this.lastColumnPos=0;this.lastColumnValue=0;}/**
34453445+ True if we are at the end of the line.
34463446+ */_createClass(StringStream,[{key:"eol",value:function eol(){return this.pos>=this.string.length;}/**
34473447+ True if we are at the start of the line.
34483448+ */},{key:"sol",value:function sol(){return this.pos==0;}/**
34493449+ Get the next code unit after the current position, or undefined
34503450+ if we're at the end of the line.
34513451+ */},{key:"peek",value:function peek(){return this.string.charAt(this.pos)||undefined;}/**
34523452+ Read the next code unit and advance `this.pos`.
34533453+ */},{key:"next",value:function next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++);}/**
34543454+ Match the next character against the given string, regular
34553455+ expression, or predicate. Consume and return it if it matches.
34563456+ */},{key:"eat",value:function eat(match){var ch=this.string.charAt(this.pos);var ok;if(typeof match=="string")ok=ch==match;else ok=ch&&(match instanceof RegExp?match.test(ch):match(ch));if(ok){++this.pos;return ch;}}/**
34573457+ Continue matching characters that match the given string,
34583458+ regular expression, or predicate function. Return true if any
34593459+ characters were consumed.
34603460+ */},{key:"eatWhile",value:function eatWhile(match){var start=this.pos;while(this.eat(match)){}return this.pos>start;}/**
34613461+ Consume whitespace ahead of `this.pos`. Return true if any was
34623462+ found.
34633463+ */},{key:"eatSpace",value:function eatSpace(){var start=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos))){++this.pos;}return this.pos>start;}/**
34643464+ Move to the end of the line.
34653465+ */},{key:"skipToEnd",value:function skipToEnd(){this.pos=this.string.length;}/**
34663466+ Move to directly before the given character, if found on the
34673467+ current line.
34683468+ */},{key:"skipTo",value:function skipTo(ch){var found=this.string.indexOf(ch,this.pos);if(found>-1){this.pos=found;return true;}}/**
34693469+ Move back `n` characters.
34703470+ */},{key:"backUp",value:function backUp(n){this.pos-=n;}/**
34713471+ Get the column position at `this.pos`.
34723472+ */},{key:"column",value:function column(){if(this.lastColumnPos<this.start){this.lastColumnValue=countCol(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue);this.lastColumnPos=this.start;}return this.lastColumnValue;}/**
34733473+ Get the indentation column of the current line.
34743474+ */},{key:"indentation",value:function indentation(){return countCol(this.string,null,this.tabSize);}/**
34753475+ Match the input against the given string or regular expression
34763476+ (which should start with a `^`). Return true or the regexp match
34773477+ if it matches.
34783478+34793479+ Unless `consume` is set to `false`, this will move `this.pos`
34803480+ past the matched text.
34813481+34823482+ When matching a string `caseInsensitive` can be set to true to
34833483+ make the match case-insensitive.
34843484+ */},{key:"match",value:function match(pattern,consume,caseInsensitive){if(typeof pattern=="string"){var cased=function cased(str){return caseInsensitive?str.toLowerCase():str;};var substr=this.string.substr(this.pos,pattern.length);if(cased(substr)==cased(pattern)){if(consume!==false)this.pos+=pattern.length;return true;}else return null;}else{var match=this.string.slice(this.pos).match(pattern);if(match&&match.index>0)return null;if(match&&consume!==false)this.pos+=match[0].length;return match;}}/**
34853485+ Get the current token.
34863486+ */},{key:"current",value:function current(){return this.string.slice(this.start,this.pos);}}]);return StringStream;}();function fullParser(spec){return{token:spec.token,blankLine:spec.blankLine||function(){},startState:spec.startState||function(){return true;},copyState:spec.copyState||defaultCopyState,indent:spec.indent||function(){return null;},languageData:spec.languageData||{}};}function defaultCopyState(state){if(_typeof(state)!="object")return state;var newState={};for(var prop in state){var val=state[prop];newState[prop]=val instanceof Array?val.slice():val;}return newState;}/**
34873487+A [language](https://codemirror.net/6/docs/ref/#language.Language) class based on a streaming
34883488+parser.
34893489+*/var StreamLanguage=/*#__PURE__*/function(_language$Language){_inherits(StreamLanguage,_language$Language);var _super40=_createSuper(StreamLanguage);function StreamLanguage(parser){var _this82;_classCallCheck(this,StreamLanguage);var data=language.defineLanguageFacet(parser.languageData);var p=fullParser(parser),self;var impl=new(/*#__PURE__*/function(_common$Parser2){_inherits(_class19,_common$Parser2);var _super41=_createSuper(_class19);function _class19(){_classCallCheck(this,_class19);return _super41.apply(this,arguments);}_createClass(_class19,[{key:"createParse",value:function createParse(input,fragments,ranges){return new Parse(self,input,fragments,ranges);}}]);return _class19;}(common.Parser))();_this82=_super40.call(this,data,impl,docID(data),[language.indentService.of(function(cx,pos){return _this82.getIndent(cx,pos);})]);self=_assertThisInitialized(_this82);_this82.streamParser=p;_this82.stateAfter=new common.NodeProp({perNode:true});return _this82;}_createClass(StreamLanguage,[{key:"getIndent",value:function getIndent(cx,pos){var tree=language.syntaxTree(cx.state),at=tree.resolve(pos);while(at&&at.type!=this.topNode){at=at.parent;}if(!at)return null;var start=findState(this,tree,0,at.from,pos),statePos,state;if(start){state=start.state;statePos=start.pos+1;}else{state=this.streamParser.startState(cx.unit);statePos=0;}if(pos-statePos>10000/* MaxIndentScanDist */)return null;while(statePos<pos){var line=cx.state.doc.lineAt(statePos),end=Math.min(pos,line.to);if(line.length){var stream=new StringStream(line.text,cx.state.tabSize,cx.unit);while(stream.pos<end-line.from){readToken(this.streamParser.token,stream,state);}}else{this.streamParser.blankLine(state,cx.unit);}if(end==pos)break;statePos=line.to+1;}var _cx$state$doc$lineAt=cx.state.doc.lineAt(pos),text=_cx$state$doc$lineAt.text;return this.streamParser.indent(state,/^\s*(.*)/.exec(text)[1],cx);}},{key:"allowsNesting",get:function get(){return false;}}],[{key:"define",value:function define(spec){return new StreamLanguage(spec);}}]);return StreamLanguage;}(language.Language);function findState(lang,tree,off,startPos,before){var state=off>=startPos&&off+tree.length<=before&&tree.prop(lang.stateAfter);if(state)return{state:lang.streamParser.copyState(state),pos:off+tree.length};for(var _i122=tree.children.length-1;_i122>=0;_i122--){var child=tree.children[_i122],pos=off+tree.positions[_i122];var found=child instanceof common.Tree&&pos<before&&findState(lang,child,pos,startPos,before);if(found)return found;}return null;}function cutTree(lang,tree,from,to,inside){if(inside&&from<=0&&to>=tree.length)return tree;if(!inside&&tree.type==lang.topNode)inside=true;for(var _i123=tree.children.length-1;_i123>=0;_i123--){var pos=tree.positions[_i123]+from,child=tree.children[_i123],inner=void 0;if(pos<to&&child instanceof common.Tree){if(!(inner=cutTree(lang,child,from-pos,to-pos,inside)))break;return!inside?inner:new common.Tree(tree.type,tree.children.slice(0,_i123).concat(inner),tree.positions.slice(0,_i123+1),pos+inner.length);}}return null;}function findStartInFragments(lang,fragments,startPos,editorState){var _iterator184=_createForOfIteratorHelper(fragments),_step184;try{for(_iterator184.s();!(_step184=_iterator184.n()).done;){var f=_step184.value;var from=f.from+(f.openStart?25:0),to=f.to-(f.openEnd?25:0);var found=from<=startPos&&to>startPos&&findState(lang,f.tree,0-f.offset,startPos,to),tree=void 0;if(found&&(tree=cutTree(lang,f.tree,startPos+f.offset,found.pos+f.offset,false)))return{state:found.state,tree:tree};}}catch(err){_iterator184.e(err);}finally{_iterator184.f();}return{state:lang.streamParser.startState(editorState?language.getIndentUnit(editorState):4),tree:common.Tree.empty};}var Parse=/*#__PURE__*/function(){function Parse(lang,input,fragments,ranges){_classCallCheck(this,Parse);this.lang=lang;this.input=input;this.fragments=fragments;this.ranges=ranges;this.stoppedAt=null;this.chunks=[];this.chunkPos=[];this.chunk=[];this.chunkReused=undefined;this.rangeIndex=0;this.to=ranges[ranges.length-1].to;var context=language.ParseContext.get(),from=ranges[0].from;var _findStartInFragments=findStartInFragments(lang,fragments,from,context===null||context===void 0?void 0:context.state),state=_findStartInFragments.state,tree=_findStartInFragments.tree;this.state=state;this.parsedPos=this.chunkStart=from+tree.length;if(tree.length){this.chunks.push(tree);this.chunkPos.push(0);}if(context&&this.parsedPos<context.viewport.from-100000/* MaxDistanceBeforeViewport */){this.state=this.lang.streamParser.startState(language.getIndentUnit(context.state));context.skipUntilInView(this.parsedPos,context.viewport.from);this.parsedPos=context.viewport.from;}}_createClass(Parse,[{key:"advance",value:function advance(){var context=language.ParseContext.get();var parseEnd=this.stoppedAt==null?this.to:this.stoppedAt;var end=Math.min(parseEnd,this.chunkStart+2048/* ChunkSize */);if(context)end=Math.min(end,context.viewport.to);while(this.parsedPos<end){this.parseLine(context);}if(this.chunkStart<this.parsedPos)this.finishChunk();if(this.parsedPos>=parseEnd)return this.finish();if(context&&this.parsedPos>context.viewport.to){context.skipUntilInView(this.parsedPos,parseEnd);return this.finish();}return null;}},{key:"stopAt",value:function stopAt(pos){this.stoppedAt=pos;}},{key:"lineAfter",value:function lineAfter(pos){var chunk=this.input.chunk(pos);if(!this.input.lineChunks){var eol=chunk.indexOf("\n");if(eol>-1)chunk=chunk.slice(0,eol);}else if(chunk=="\n"){chunk="";}return pos+chunk.length<=this.to?chunk:chunk.slice(0,this.to-pos);}},{key:"nextLine",value:function nextLine(){var from=this.parsedPos,line=this.lineAfter(from),end=from+line.length;for(var index=this.rangeIndex;;){var rangeEnd=this.ranges[index].to;if(rangeEnd>=end)break;line=line.slice(0,rangeEnd-(end-line.length));index++;if(index==this.ranges.length)break;var rangeStart=this.ranges[index].from;var after=this.lineAfter(rangeStart);line+=after;end=rangeStart+after.length;}return{line:line,end:end};}},{key:"skipGapsTo",value:function skipGapsTo(pos,offset,side){for(;;){var end=this.ranges[this.rangeIndex].to,offPos=pos+offset;if(side>0?end>offPos:end>=offPos)break;var start=this.ranges[++this.rangeIndex].from;offset+=start-end;}return offset;}},{key:"emitToken",value:function emitToken(id,from,to,size,offset){if(this.ranges.length>1){offset=this.skipGapsTo(from,offset,1);from+=offset;var len0=this.chunk.length;offset=this.skipGapsTo(to,offset,-1);to+=offset;size+=this.chunk.length-len0;}this.chunk.push(id,from,to,size);return offset;}},{key:"parseLine",value:function parseLine(context){var _this$nextLine=this.nextLine(),line=_this$nextLine.line,end=_this$nextLine.end,offset=0,streamParser=this.lang.streamParser;var stream=new StringStream(line,context?context.state.tabSize:4,context?language.getIndentUnit(context.state):2);if(stream.eol()){streamParser.blankLine(this.state,stream.indentUnit);}else{while(!stream.eol()){var token=readToken(streamParser.token,stream,this.state);if(token)offset=this.emitToken(tokenID(token),this.parsedPos+stream.start,this.parsedPos+stream.pos,4,offset);}}this.parsedPos=end;if(this.parsedPos<this.to)this.parsedPos++;}},{key:"finishChunk",value:function finishChunk(){var tree=common.Tree.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:nodeSet,topID:0,maxBufferLength:2048/* ChunkSize */,reused:this.chunkReused});tree=new common.Tree(tree.type,tree.children,tree.positions,tree.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]);this.chunks.push(tree);this.chunkPos.push(this.chunkStart-this.ranges[0].from);this.chunk=[];this.chunkReused=undefined;this.chunkStart=this.parsedPos;}},{key:"finish",value:function finish(){return new common.Tree(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance();}}]);return Parse;}();function readToken(token,stream,state){stream.start=stream.pos;for(var _i124=0;_i124<10;_i124++){var result=token(stream,state);if(stream.pos>stream.start)return result;}throw new Error("Stream parser failed to advance stream.");}var tokenTable=Object.create(null);var typeArray=[common.NodeType.none];var nodeSet=new common.NodeSet(typeArray);var warned=[];function tokenID(tag){return!tag?0:tokenTable[tag]||(tokenTable[tag]=createTokenType(tag));}for(var _i125=0,_arr3=[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","typeName"],["attribute","propertyName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]];_i125<_arr3.length;_i125++){var _arr3$_i=_slicedToArray(_arr3[_i125],2),legacyName=_arr3$_i[0],name=_arr3$_i[1];tokenTable[legacyName]=tokenID(name);}function warnForPart(part,msg){if(warned.indexOf(part)>-1)return;warned.push(part);console.warn(msg);}function createTokenType(tagStr){var tag=null;var _iterator185=_createForOfIteratorHelper(tagStr.split(".")),_step185;try{for(_iterator185.s();!(_step185=_iterator185.n()).done;){var part=_step185.value;var value=highlight.tags[part];if(!value){warnForPart(part,"Unknown highlighting tag ".concat(part));}else if(typeof value=="function"){if(!tag)warnForPart(part,"Modifier ".concat(part," used at start of tag"));else tag=value(tag);}else{if(tag)warnForPart(part,"Tag ".concat(part," used as modifier"));else tag=value;}}}catch(err){_iterator185.e(err);}finally{_iterator185.f();}if(!tag)return 0;var name=tagStr.replace(/ /g,"_"),type=common.NodeType.define({id:typeArray.length,name:name,props:[highlight.styleTags(_defineProperty({},name,tag))]});typeArray.push(type);return type.id;}function docID(data){var type=common.NodeType.define({id:typeArray.length,name:"Document",props:[language.languageDataProp.add(function(){return data;})]});typeArray.push(type);return type;}exports.StreamLanguage=StreamLanguage;exports.StringStream=StringStream;},{"@codemirror/highlight":11,"@codemirror/language":13,"@lezer/common":28}],24:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});// Compressed representation of the Grapheme_Cluster_Break=Extend
34903490+// information from
34913491+// http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
34923492+// Each pair of elements represents a range, as an offet from the
34933493+// previous range and a length. Numbers are in base-36, with the empty
34943494+// string being a shorthand for 1.
34953495+var extend="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(function(s){return s?parseInt(s,36):1;});// Convert offsets into absolute values
34963496+for(var _i126=1;_i126<extend.length;_i126++){extend[_i126]+=extend[_i126-1];}function isExtendingChar(code){for(var _i127=1;_i127<extend.length;_i127+=2){if(extend[_i127]>code)return extend[_i127-1]<=code;}return false;}function isRegionalIndicator(code){return code>=0x1F1E6&&code<=0x1F1FF;}var ZWJ=0x200d;/**
34973497+Returns a next grapheme cluster break _after_ (not equal to)
34983498+`pos`, if `forward` is true, or before otherwise. Returns `pos`
34993499+itself if no further cluster break is available in the string.
35003500+Moves across surrogate pairs, extending characters (when
35013501+`includeExtending` is true), characters joined with zero-width
35023502+joiners, and flag emoji.
35033503+*/function findClusterBreak(str,pos){var forward=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var includeExtending=arguments.length>3&&arguments[3]!==undefined?arguments[3]:true;return(forward?nextClusterBreak:prevClusterBreak)(str,pos,includeExtending);}function nextClusterBreak(str,pos,includeExtending){if(pos==str.length)return pos;// If pos is in the middle of a surrogate pair, move to its start
35043504+if(pos&&surrogateLow(str.charCodeAt(pos))&&surrogateHigh(str.charCodeAt(pos-1)))pos--;var prev=codePointAt(str,pos);pos+=codePointSize(prev);while(pos<str.length){var next=codePointAt(str,pos);if(prev==ZWJ||next==ZWJ||includeExtending&&isExtendingChar(next)){pos+=codePointSize(next);prev=next;}else if(isRegionalIndicator(next)){var countBefore=0,_i128=pos-2;while(_i128>=0&&isRegionalIndicator(codePointAt(str,_i128))){countBefore++;_i128-=2;}if(countBefore%2==0)break;else pos+=2;}else{break;}}return pos;}function prevClusterBreak(str,pos,includeExtending){while(pos>0){var found=nextClusterBreak(str,pos-2,includeExtending);if(found<pos)return found;pos--;}return 0;}function surrogateLow(ch){return ch>=0xDC00&&ch<0xE000;}function surrogateHigh(ch){return ch>=0xD800&&ch<0xDC00;}/**
35053505+Find the code point at the given position in a string (like the
35063506+[`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
35073507+string method).
35083508+*/function codePointAt(str,pos){var code0=str.charCodeAt(pos);if(!surrogateHigh(code0)||pos+1==str.length)return code0;var code1=str.charCodeAt(pos+1);if(!surrogateLow(code1))return code0;return(code0-0xd800<<10)+(code1-0xdc00)+0x10000;}/**
35093509+Given a Unicode codepoint, return the JavaScript string that
35103510+respresents it (like
35113511+[`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).
35123512+*/function fromCodePoint(code){if(code<=0xffff)return String.fromCharCode(code);code-=0x10000;return String.fromCharCode((code>>10)+0xd800,(code&1023)+0xdc00);}/**
35133513+The first character that takes up two positions in a JavaScript
35143514+string. It is often useful to compare with this after calling
35153515+`codePointAt`, to figure out whether your character takes up 1 or
35163516+2 index positions.
35173517+*/function codePointSize(code){return code<0x10000?1:2;}/**
35183518+Count the column position at the given offset into the string,
35193519+taking extending characters and tab size into account.
35203520+*/function countColumn(string,tabSize){var to=arguments.length>2&&arguments[2]!==undefined?arguments[2]:string.length;var n=0;for(var _i129=0;_i129<to;){if(string.charCodeAt(_i129)==9){n+=tabSize-n%tabSize;_i129++;}else{n++;_i129=findClusterBreak(string,_i129);}}return n;}/**
35213521+Find the offset that corresponds to the given column position in a
35223522+string, taking extending characters and tab size into account. By
35233523+default, the string length is returned when it is too short to
35243524+reach the column. Pass `strict` true to make it return -1 in that
35253525+situation.
35263526+*/function findColumn(string,col,tabSize,strict){for(var _i130=0,n=0;;){if(n>=col)return _i130;if(_i130==string.length)break;n+=string.charCodeAt(_i130)==9?tabSize-n%tabSize:1;_i130=findClusterBreak(string,_i130);}return strict===true?-1:string.length;}/**
35273527+The data structure for documents.
35283528+*/var Text=/*#__PURE__*/function(){/**
35293529+ @internal
35303530+ */function Text(){_classCallCheck(this,Text);}/**
35313531+ Get the line description around the given position.
35323532+ */_createClass(Text,[{key:"lineAt",value:function lineAt(pos){if(pos<0||pos>this.length)throw new RangeError("Invalid position ".concat(pos," in document of length ").concat(this.length));return this.lineInner(pos,false,1,0);}/**
35333533+ Get the description for the given (1-based) line number.
35343534+ */},{key:"line",value:function line(n){if(n<1||n>this.lines)throw new RangeError("Invalid line number ".concat(n," in ").concat(this.lines,"-line document"));return this.lineInner(n,true,1,0);}/**
35353535+ Replace a range of the text with the given content.
35363536+ */},{key:"replace",value:function replace(from,to,text){var parts=[];this.decompose(0,from,parts,2/* To */);if(text.length)text.decompose(0,text.length,parts,1/* From */|2/* To */);this.decompose(to,this.length,parts,1/* From */);return TextNode.from(parts,this.length-(to-from)+text.length);}/**
35373537+ Append another document to this one.
35383538+ */},{key:"append",value:function append(other){return this.replace(this.length,this.length,other);}/**
35393539+ Retrieve the text between the given points.
35403540+ */},{key:"slice",value:function slice(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:this.length;var parts=[];this.decompose(from,to,parts,0);return TextNode.from(parts,to-from);}/**
35413541+ Test whether this text is equal to another instance.
35423542+ */},{key:"eq",value:function eq(other){if(other==this)return true;if(other.length!=this.length||other.lines!=this.lines)return false;var start=this.scanIdentical(other,1),end=this.length-this.scanIdentical(other,-1);var a=new RawTextCursor(this),b=new RawTextCursor(other);for(var skip=start,pos=start;;){a.next(skip);b.next(skip);skip=0;if(a.lineBreak!=b.lineBreak||a.done!=b.done||a.value!=b.value)return false;pos+=a.value.length;if(a.done||pos>=end)return true;}}/**
35433543+ Iterate over the text. When `dir` is `-1`, iteration happens
35443544+ from end to start. This will return lines and the breaks between
35453545+ them as separate strings, and for long lines, might split lines
35463546+ themselves into multiple chunks as well.
35473547+ */},{key:"iter",value:function iter(){var dir=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;return new RawTextCursor(this,dir);}/**
35483548+ Iterate over a range of the text. When `from` > `to`, the
35493549+ iterator will run in reverse.
35503550+ */},{key:"iterRange",value:function iterRange(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:this.length;return new PartialTextCursor(this,from,to);}/**
35513551+ Return a cursor that iterates over the given range of lines,
35523552+ _without_ returning the line breaks between, and yielding empty
35533553+ strings for empty lines.
35543554+35553555+ When `from` and `to` are given, they should be 1-based line numbers.
35563556+ */},{key:"iterLines",value:function iterLines(from,to){var inner;if(from==null){inner=this.iter();}else{if(to==null)to=this.lines+1;var start=this.line(from).from;inner=this.iterRange(start,Math.max(start,to==this.lines+1?this.length:to<=1?0:this.line(to-1).to));}return new LineCursor(inner);}/**
35573557+ @internal
35583558+ */},{key:"toString",value:function toString(){return this.sliceString(0);}/**
35593559+ Convert the document to an array of lines (which can be
35603560+ deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#text.Text^of)).
35613561+ */},{key:"toJSON",value:function toJSON(){var lines=[];this.flatten(lines);return lines;}/**
35623562+ Create a `Text` instance for the given array of lines.
35633563+ */}],[{key:"of",value:function of(text){if(text.length==0)throw new RangeError("A document must have at least one line");if(text.length==1&&!text[0])return Text.empty;return text.length<=32/* Branch */?new TextLeaf(text):TextNode.from(TextLeaf.split(text,[]));}}]);return Text;}();// Leaves store an array of line strings. There are always line breaks
35643564+// between these strings. Leaves are limited in size and have to be
35653565+// contained in TextNode instances for bigger documents.
35663566+var TextLeaf=/*#__PURE__*/function(_Text){_inherits(TextLeaf,_Text);var _super42=_createSuper(TextLeaf);function TextLeaf(text){var _this83;var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:textLength(text);_classCallCheck(this,TextLeaf);_this83=_super42.call(this);_this83.text=text;_this83.length=length;return _this83;}_createClass(TextLeaf,[{key:"lines",get:function get(){return this.text.length;}},{key:"children",get:function get(){return null;}},{key:"lineInner",value:function lineInner(target,isLine,line,offset){for(var _i131=0;;_i131++){var string=this.text[_i131],end=offset+string.length;if((isLine?line:end)>=target)return new Line(offset,end,line,string);offset=end+1;line++;}}},{key:"decompose",value:function decompose(from,to,target,open){var text=from<=0&&to>=this.length?this:new TextLeaf(sliceText(this.text,from,to),Math.min(to,this.length)-Math.max(0,from));if(open&1/* From */){var prev=target.pop();var joined=appendText(text.text,prev.text.slice(),0,text.length);if(joined.length<=32/* Branch */){target.push(new TextLeaf(joined,prev.length+text.length));}else{var mid=joined.length>>1;target.push(new TextLeaf(joined.slice(0,mid)),new TextLeaf(joined.slice(mid)));}}else{target.push(text);}}},{key:"replace",value:function replace(from,to,text){if(!(text instanceof TextLeaf))return _get(_getPrototypeOf(TextLeaf.prototype),"replace",this).call(this,from,to,text);var lines=appendText(this.text,appendText(text.text,sliceText(this.text,0,from)),to);var newLen=this.length+text.length-(to-from);if(lines.length<=32/* Branch */)return new TextLeaf(lines,newLen);return TextNode.from(TextLeaf.split(lines,[]),newLen);}},{key:"sliceString",value:function sliceString(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:this.length;var lineSep=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"\n";var result="";for(var pos=0,_i132=0;pos<=to&&_i132<this.text.length;_i132++){var line=this.text[_i132],end=pos+line.length;if(pos>from&&_i132)result+=lineSep;if(from<end&&to>pos)result+=line.slice(Math.max(0,from-pos),to-pos);pos=end+1;}return result;}},{key:"flatten",value:function flatten(target){var _iterator186=_createForOfIteratorHelper(this.text),_step186;try{for(_iterator186.s();!(_step186=_iterator186.n()).done;){var line=_step186.value;target.push(line);}}catch(err){_iterator186.e(err);}finally{_iterator186.f();}}},{key:"scanIdentical",value:function scanIdentical(){return 0;}}],[{key:"split",value:function split(text,target){var part=[],len=-1;var _iterator187=_createForOfIteratorHelper(text),_step187;try{for(_iterator187.s();!(_step187=_iterator187.n()).done;){var line=_step187.value;part.push(line);len+=line.length+1;if(part.length==32/* Branch */){target.push(new TextLeaf(part,len));part=[];len=-1;}}}catch(err){_iterator187.e(err);}finally{_iterator187.f();}if(len>-1)target.push(new TextLeaf(part,len));return target;}}]);return TextLeaf;}(Text);// Nodes provide the tree structure of the `Text` type. They store a
35673567+// number of other nodes or leaves, taking care to balance themselves
35683568+// on changes. There are implied line breaks _between_ the children of
35693569+// a node (but not before the first or after the last child).
35703570+var TextNode=/*#__PURE__*/function(_Text2){_inherits(TextNode,_Text2);var _super43=_createSuper(TextNode);function TextNode(children,length){var _this84;_classCallCheck(this,TextNode);_this84=_super43.call(this);_this84.children=children;_this84.length=length;_this84.lines=0;var _iterator188=_createForOfIteratorHelper(children),_step188;try{for(_iterator188.s();!(_step188=_iterator188.n()).done;){var child=_step188.value;_this84.lines+=child.lines;}}catch(err){_iterator188.e(err);}finally{_iterator188.f();}return _this84;}_createClass(TextNode,[{key:"lineInner",value:function lineInner(target,isLine,line,offset){for(var _i133=0;;_i133++){var child=this.children[_i133],end=offset+child.length,endLine=line+child.lines-1;if((isLine?endLine:end)>=target)return child.lineInner(target,isLine,line,offset);offset=end+1;line=endLine+1;}}},{key:"decompose",value:function decompose(from,to,target,open){for(var _i134=0,pos=0;pos<=to&&_i134<this.children.length;_i134++){var child=this.children[_i134],end=pos+child.length;if(from<=end&&to>=pos){var childOpen=open&((pos<=from?1/* From */:0)|(end>=to?2/* To */:0));if(pos>=from&&end<=to&&!childOpen)target.push(child);else child.decompose(from-pos,to-pos,target,childOpen);}pos=end+1;}}},{key:"replace",value:function replace(from,to,text){if(text.lines<this.lines)for(var _i135=0,pos=0;_i135<this.children.length;_i135++){var child=this.children[_i135],end=pos+child.length;// Fast path: if the change only affects one child and the
35713571+// child's size remains in the acceptable range, only update
35723572+// that child
35733573+if(from>=pos&&to<=end){var updated=child.replace(from-pos,to-pos,text);var totalLines=this.lines-child.lines+updated.lines;if(updated.lines<totalLines>>5/* BranchShift */-1&&updated.lines>totalLines>>5/* BranchShift */+1){var copy=this.children.slice();copy[_i135]=updated;return new TextNode(copy,this.length-(to-from)+text.length);}return _get(_getPrototypeOf(TextNode.prototype),"replace",this).call(this,pos,end,updated);}pos=end+1;}return _get(_getPrototypeOf(TextNode.prototype),"replace",this).call(this,from,to,text);}},{key:"sliceString",value:function sliceString(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:this.length;var lineSep=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"\n";var result="";for(var _i136=0,pos=0;_i136<this.children.length&&pos<=to;_i136++){var child=this.children[_i136],end=pos+child.length;if(pos>from&&_i136)result+=lineSep;if(from<end&&to>pos)result+=child.sliceString(from-pos,to-pos,lineSep);pos=end+1;}return result;}},{key:"flatten",value:function flatten(target){var _iterator189=_createForOfIteratorHelper(this.children),_step189;try{for(_iterator189.s();!(_step189=_iterator189.n()).done;){var child=_step189.value;child.flatten(target);}}catch(err){_iterator189.e(err);}finally{_iterator189.f();}}},{key:"scanIdentical",value:function scanIdentical(other,dir){if(!(other instanceof TextNode))return 0;var length=0;var _ref67=dir>0?[0,0,this.children.length,other.children.length]:[this.children.length-1,other.children.length-1,-1,-1],_ref68=_slicedToArray(_ref67,4),iA=_ref68[0],iB=_ref68[1],eA=_ref68[2],eB=_ref68[3];for(;;iA+=dir,iB+=dir){if(iA==eA||iB==eB)return length;var chA=this.children[iA],chB=other.children[iB];if(chA!=chB)return length+chA.scanIdentical(chB,dir);length+=chA.length+1;}}}],[{key:"from",value:function from(children){var length=arguments.length>1&&arguments[1]!==undefined?arguments[1]:children.reduce(function(l,ch){return l+ch.length+1;},-1);var lines=0;var _iterator190=_createForOfIteratorHelper(children),_step190;try{for(_iterator190.s();!(_step190=_iterator190.n()).done;){var _ch=_step190.value;lines+=_ch.lines;}}catch(err){_iterator190.e(err);}finally{_iterator190.f();}if(lines<32/* Branch */){var flat=[];var _iterator191=_createForOfIteratorHelper(children),_step191;try{for(_iterator191.s();!(_step191=_iterator191.n()).done;){var ch=_step191.value;ch.flatten(flat);}}catch(err){_iterator191.e(err);}finally{_iterator191.f();}return new TextLeaf(flat,length);}var chunk=Math.max(32/* Branch */,lines>>5/* BranchShift */),maxChunk=chunk<<1,minChunk=chunk>>1;var chunked=[],currentLines=0,currentLen=-1,currentChunk=[];function add(child){var last;if(child.lines>maxChunk&&child instanceof TextNode){var _iterator192=_createForOfIteratorHelper(child.children),_step192;try{for(_iterator192.s();!(_step192=_iterator192.n()).done;){var node=_step192.value;add(node);}}catch(err){_iterator192.e(err);}finally{_iterator192.f();}}else if(child.lines>minChunk&&(currentLines>minChunk||!currentLines)){flush();chunked.push(child);}else if(child instanceof TextLeaf&¤tLines&&(last=currentChunk[currentChunk.length-1])instanceof TextLeaf&&child.lines+last.lines<=32/* Branch */){currentLines+=child.lines;currentLen+=child.length+1;currentChunk[currentChunk.length-1]=new TextLeaf(last.text.concat(child.text),last.length+1+child.length);}else{if(currentLines+child.lines>chunk)flush();currentLines+=child.lines;currentLen+=child.length+1;currentChunk.push(child);}}function flush(){if(currentLines==0)return;chunked.push(currentChunk.length==1?currentChunk[0]:TextNode.from(currentChunk,currentLen));currentLen=-1;currentLines=currentChunk.length=0;}var _iterator193=_createForOfIteratorHelper(children),_step193;try{for(_iterator193.s();!(_step193=_iterator193.n()).done;){var child=_step193.value;add(child);}}catch(err){_iterator193.e(err);}finally{_iterator193.f();}flush();return chunked.length==1?chunked[0]:new TextNode(chunked,length);}}]);return TextNode;}(Text);Text.empty=new TextLeaf([""],0);function textLength(text){var length=-1;var _iterator194=_createForOfIteratorHelper(text),_step194;try{for(_iterator194.s();!(_step194=_iterator194.n()).done;){var line=_step194.value;length+=line.length+1;}}catch(err){_iterator194.e(err);}finally{_iterator194.f();}return length;}function appendText(text,target){var from=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var to=arguments.length>3&&arguments[3]!==undefined?arguments[3]:1e9;for(var pos=0,_i137=0,first=true;_i137<text.length&&pos<=to;_i137++){var line=text[_i137],end=pos+line.length;if(end>=from){if(end>to)line=line.slice(0,to-pos);if(pos<from)line=line.slice(from-pos);if(first){target[target.length-1]+=line;first=false;}else target.push(line);}pos=end+1;}return target;}function sliceText(text,from,to){return appendText(text,[""],from,to);}var RawTextCursor=/*#__PURE__*/function(){function RawTextCursor(text){var dir=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;_classCallCheck(this,RawTextCursor);this.dir=dir;this.done=false;this.lineBreak=false;this.value="";this.nodes=[text];this.offsets=[dir>0?1:(text instanceof TextLeaf?text.text.length:text.children.length)<<1];}_createClass(RawTextCursor,[{key:"nextInner",value:function nextInner(skip,dir){this.done=this.lineBreak=false;for(;;){var last=this.nodes.length-1;var top=this.nodes[last],offsetValue=this.offsets[last],offset=offsetValue>>1;var size=top instanceof TextLeaf?top.text.length:top.children.length;if(offset==(dir>0?size:0)){if(last==0){this.done=true;this.value="";return this;}if(dir>0)this.offsets[last-1]++;this.nodes.pop();this.offsets.pop();}else if((offsetValue&1)==(dir>0?0:1)){this.offsets[last]+=dir;if(skip==0){this.lineBreak=true;this.value="\n";return this;}skip--;}else if(top instanceof TextLeaf){// Move to the next string
35743574+var next=top.text[offset+(dir<0?-1:0)];this.offsets[last]+=dir;if(next.length>Math.max(0,skip)){this.value=skip==0?next:dir>0?next.slice(skip):next.slice(0,next.length-skip);return this;}skip-=next.length;}else{var _next3=top.children[offset+(dir<0?-1:0)];if(skip>_next3.length){skip-=_next3.length;this.offsets[last]+=dir;}else{if(dir<0)this.offsets[last]--;this.nodes.push(_next3);this.offsets.push(dir>0?1:(_next3 instanceof TextLeaf?_next3.text.length:_next3.children.length)<<1);}}}}},{key:"next",value:function next(){var skip=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;if(skip<0){this.nextInner(-skip,-this.dir);skip=this.value.length;}return this.nextInner(skip,this.dir);}}]);return RawTextCursor;}();var PartialTextCursor=/*#__PURE__*/function(){function PartialTextCursor(text,start,end){_classCallCheck(this,PartialTextCursor);this.value="";this.done=false;this.cursor=new RawTextCursor(text,start>end?-1:1);this.pos=start>end?text.length:0;this.from=Math.min(start,end);this.to=Math.max(start,end);}_createClass(PartialTextCursor,[{key:"nextInner",value:function nextInner(skip,dir){if(dir<0?this.pos<=this.from:this.pos>=this.to){this.value="";this.done=true;return this;}skip+=Math.max(0,dir<0?this.pos-this.to:this.from-this.pos);var limit=dir<0?this.pos-this.from:this.to-this.pos;if(skip>limit)skip=limit;limit-=skip;var _this$cursor$next2=this.cursor.next(skip),value=_this$cursor$next2.value;this.pos+=(value.length+skip)*dir;this.value=value.length<=limit?value:dir<0?value.slice(value.length-limit):value.slice(0,limit);this.done=!this.value;return this;}},{key:"next",value:function next(){var skip=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;if(skip<0)skip=Math.max(skip,this.from-this.pos);else if(skip>0)skip=Math.min(skip,this.to-this.pos);return this.nextInner(skip,this.cursor.dir);}},{key:"lineBreak",get:function get(){return this.cursor.lineBreak&&this.value!="";}}]);return PartialTextCursor;}();var LineCursor=/*#__PURE__*/function(){function LineCursor(inner){_classCallCheck(this,LineCursor);this.inner=inner;this.afterBreak=true;this.value="";this.done=false;}_createClass(LineCursor,[{key:"next",value:function next(){var skip=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;var _this$inner$next=this.inner.next(skip),done=_this$inner$next.done,lineBreak=_this$inner$next.lineBreak,value=_this$inner$next.value;if(done){this.done=true;this.value="";}else if(lineBreak){if(this.afterBreak){this.value="";}else{this.afterBreak=true;this.next();}}else{this.value=value;this.afterBreak=false;}return this;}},{key:"lineBreak",get:function get(){return false;}}]);return LineCursor;}();if(typeof Symbol!="undefined"){Text.prototype[Symbol.iterator]=function(){return this.iter();};RawTextCursor.prototype[Symbol.iterator]=PartialTextCursor.prototype[Symbol.iterator]=LineCursor.prototype[Symbol.iterator]=function(){return this;};}/**
35753575+This type describes a line in the document. It is created
35763576+on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#text.Text.lineAt).
35773577+*/var Line=/*#__PURE__*/function(){/**
35783578+ @internal
35793579+ */function Line(/**
35803580+ The position of the start of the line.
35813581+ */from,/**
35823582+ The position at the end of the line (_before_ the line break,
35833583+ or at the end of document for the last line).
35843584+ */to,/**
35853585+ This line's line number (1-based).
35863586+ */number,/**
35873587+ The line's content.
35883588+ */text){_classCallCheck(this,Line);this.from=from;this.to=to;this.number=number;this.text=text;}/**
35893589+ The length of the line (not including any line break after it).
35903590+ */_createClass(Line,[{key:"length",get:function get(){return this.to-this.from;}}]);return Line;}();exports.Line=Line;exports.Text=Text;exports.codePointAt=codePointAt;exports.codePointSize=codePointSize;exports.countColumn=countColumn;exports.findClusterBreak=findClusterBreak;exports.findColumn=findColumn;exports.fromCodePoint=fromCodePoint;},{}],25:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var view=require('@codemirror/view');var highlight=require('@codemirror/highlight');// Using https://github.com/one-dark/vscode-one-dark-theme/ as reference for the colors
35913591+var chalky="#e5c07b",coral="#e06c75",cyan="#56b6c2",invalid="#ffffff",ivory="#abb2bf",stone="#7d8799",// Brightened compared to original to increase contrast
35923592+malibu="#61afef",sage="#98c379",whiskey="#d19a66",violet="#c678dd",darkBackground="#21252b",highlightBackground="#2c313a",background="#282c34",tooltipBackground="#353a42",selection="#3E4451",cursor="#528bff";/**
35933593+The editor theme styles for One Dark.
35943594+*/var oneDarkTheme=view.EditorView.theme({"&":{color:ivory,backgroundColor:background},".cm-content":{caretColor:cursor},"&.cm-focused .cm-cursor":{borderLeftColor:cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:selection},".cm-panels":{backgroundColor:darkBackground,color:ivory},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:highlightBackground},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847",outline:"1px solid #515a6b"},".cm-gutters":{backgroundColor:background,color:stone,border:"none"},".cm-activeLineGutter":{backgroundColor:highlightBackground},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:tooltipBackground},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:tooltipBackground,borderBottomColor:tooltipBackground},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:highlightBackground,color:ivory}}},{dark:true});/**
35953595+The highlighting style for code in the One Dark theme.
35963596+*/var oneDarkHighlightStyle=highlight.HighlightStyle.define([{tag:highlight.tags.keyword,color:violet},{tag:[highlight.tags.name,highlight.tags.deleted,highlight.tags.character,highlight.tags.propertyName,highlight.tags.macroName],color:coral},{tag:[highlight.tags["function"](highlight.tags.variableName),highlight.tags.labelName],color:malibu},{tag:[highlight.tags.color,highlight.tags.constant(highlight.tags.name),highlight.tags.standard(highlight.tags.name)],color:whiskey},{tag:[highlight.tags.definition(highlight.tags.name),highlight.tags.separator],color:ivory},{tag:[highlight.tags.typeName,highlight.tags.className,highlight.tags.number,highlight.tags.changed,highlight.tags.annotation,highlight.tags.modifier,highlight.tags.self,highlight.tags.namespace],color:chalky},{tag:[highlight.tags.operator,highlight.tags.operatorKeyword,highlight.tags.url,highlight.tags.escape,highlight.tags.regexp,highlight.tags.link,highlight.tags.special(highlight.tags.string)],color:cyan},{tag:[highlight.tags.meta,highlight.tags.comment],color:stone},{tag:highlight.tags.strong,fontWeight:"bold"},{tag:highlight.tags.emphasis,fontStyle:"italic"},{tag:highlight.tags.strikethrough,textDecoration:"line-through"},{tag:highlight.tags.link,color:stone,textDecoration:"underline"},{tag:highlight.tags.heading,fontWeight:"bold",color:coral},{tag:[highlight.tags.atom,highlight.tags.bool,highlight.tags.special(highlight.tags.variableName)],color:whiskey},{tag:[highlight.tags.processingInstruction,highlight.tags.string,highlight.tags.inserted],color:sage},{tag:highlight.tags.invalid,color:invalid}]);/**
35973597+Extension to enable the One Dark theme (both the editor theme and
35983598+the highlight style).
35993599+*/var oneDark=[oneDarkTheme,oneDarkHighlightStyle];exports.oneDark=oneDark;exports.oneDarkHighlightStyle=oneDarkHighlightStyle;exports.oneDarkTheme=oneDarkTheme;},{"@codemirror/highlight":11,"@codemirror/view":27}],26:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var view=require('@codemirror/view');var state=require('@codemirror/state');var ios=typeof navigator!="undefined"&&!/Edge\/(\d+)/.exec(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor)&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2);var Outside="-10000px";var TooltipViewManager=/*#__PURE__*/function(){function TooltipViewManager(view,facet,createTooltipView){_classCallCheck(this,TooltipViewManager);this.facet=facet;this.createTooltipView=createTooltipView;this.input=view.state.facet(facet);this.tooltips=this.input.filter(function(t){return t;});this.tooltipViews=this.tooltips.map(createTooltipView);}_createClass(TooltipViewManager,[{key:"update",value:function update(_update24){var input=_update24.state.facet(this.facet);var tooltips=input.filter(function(x){return x;});if(input===this.input){var _iterator195=_createForOfIteratorHelper(this.tooltipViews),_step195;try{for(_iterator195.s();!(_step195=_iterator195.n()).done;){var t=_step195.value;if(t.update)t.update(_update24);}}catch(err){_iterator195.e(err);}finally{_iterator195.f();}return false;}var tooltipViews=[];for(var _i138=0;_i138<tooltips.length;_i138++){var tip=tooltips[_i138],known=-1;if(!tip)continue;for(var _i139=0;_i139<this.tooltips.length;_i139++){var other=this.tooltips[_i139];if(other&&other.create==tip.create)known=_i139;}if(known<0){tooltipViews[_i138]=this.createTooltipView(tip);}else{var tooltipView=tooltipViews[_i138]=this.tooltipViews[known];if(tooltipView.update)tooltipView.update(_update24);}}var _iterator196=_createForOfIteratorHelper(this.tooltipViews),_step196;try{for(_iterator196.s();!(_step196=_iterator196.n()).done;){var _t4=_step196.value;if(tooltipViews.indexOf(_t4)<0)_t4.dom.remove();}}catch(err){_iterator196.e(err);}finally{_iterator196.f();}this.input=input;this.tooltips=tooltips;this.tooltipViews=tooltipViews;return true;}}]);return TooltipViewManager;}();/**
36003600+Return an extension that configures tooltip behavior.
36013601+*/function tooltips(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return tooltipConfig.of(config);}function windowSpace(){return{top:0,left:0,bottom:innerHeight,right:innerWidth};}var tooltipConfig=state.Facet.define({combine:function combine(values){var _a,_b,_c;return{position:ios?"absolute":((_a=values.find(function(conf){return conf.position;}))===null||_a===void 0?void 0:_a.position)||"fixed",parent:((_b=values.find(function(conf){return conf.parent;}))===null||_b===void 0?void 0:_b.parent)||null,tooltipSpace:((_c=values.find(function(conf){return conf.tooltipSpace;}))===null||_c===void 0?void 0:_c.tooltipSpace)||windowSpace};}});var tooltipPlugin=view.ViewPlugin.fromClass(/*#__PURE__*/function(){function _class20(view){var _this85=this;_classCallCheck(this,_class20);var _a;this.view=view;this.inView=true;this.lastTransaction=0;this.measureTimeout=-1;var config=view.state.facet(tooltipConfig);this.position=config.position;this.parent=config.parent;this.classes=view.themeClasses;this.createContainer();this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this};this.manager=new TooltipViewManager(view,showTooltip,function(t){return _this85.createTooltip(t);});this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(function(entries){if(Date.now()>_this85.lastTransaction-50&&entries.length>0&&entries[entries.length-1].intersectionRatio<1)_this85.measureSoon();},{threshold:[1]}):null;this.observeIntersection();(_a=view.dom.ownerDocument.defaultView)===null||_a===void 0?void 0:_a.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this));this.maybeMeasure();}_createClass(_class20,[{key:"createContainer",value:function 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;}}},{key:"observeIntersection",value:function observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();var _iterator197=_createForOfIteratorHelper(this.manager.tooltipViews),_step197;try{for(_iterator197.s();!(_step197=_iterator197.n()).done;){var tooltip=_step197.value;this.intersectionObserver.observe(tooltip.dom);}}catch(err){_iterator197.e(err);}finally{_iterator197.f();}}}},{key:"measureSoon",value:function measureSoon(){var _this86=this;if(this.measureTimeout<0)this.measureTimeout=setTimeout(function(){_this86.measureTimeout=-1;_this86.maybeMeasure();},50);}},{key:"update",value:function update(_update25){if(_update25.transactions.length)this.lastTransaction=Date.now();var updated=this.manager.update(_update25);if(updated)this.observeIntersection();var shouldMeasure=updated||_update25.geometryChanged;var newConfig=_update25.state.facet(tooltipConfig);if(newConfig.position!=this.position){this.position=newConfig.position;var _iterator198=_createForOfIteratorHelper(this.manager.tooltipViews),_step198;try{for(_iterator198.s();!(_step198=_iterator198.n()).done;){var t=_step198.value;t.dom.style.position=this.position;}}catch(err){_iterator198.e(err);}finally{_iterator198.f();}shouldMeasure=true;}if(newConfig.parent!=this.parent){if(this.parent)this.container.remove();this.parent=newConfig.parent;this.createContainer();var _iterator199=_createForOfIteratorHelper(this.manager.tooltipViews),_step199;try{for(_iterator199.s();!(_step199=_iterator199.n()).done;){var _t5=_step199.value;this.container.appendChild(_t5.dom);}}catch(err){_iterator199.e(err);}finally{_iterator199.f();}shouldMeasure=true;}else if(this.parent&&this.view.themeClasses!=this.classes){this.classes=this.container.className=this.view.themeClasses;}if(shouldMeasure)this.maybeMeasure();}},{key:"createTooltip",value:function createTooltip(tooltip){var tooltipView=tooltip.create(this.view);tooltipView.dom.classList.add("cm-tooltip");if(tooltip.arrow&&!tooltipView.dom.querySelector("cm-tooltip > cm-tooltip-arrow")){var arrow=document.createElement("div");arrow.className="cm-tooltip-arrow";tooltipView.dom.appendChild(arrow);}tooltipView.dom.style.position=this.position;tooltipView.dom.style.top=Outside;this.container.appendChild(tooltipView.dom);if(tooltipView.mount)tooltipView.mount(this.view);return tooltipView;}},{key:"destroy",value:function destroy(){var _a,_b;(_a=this.view.dom.ownerDocument.defaultView)===null||_a===void 0?void 0:_a.removeEventListener("resize",this.measureSoon);var _iterator200=_createForOfIteratorHelper(this.manager.tooltipViews),_step200;try{for(_iterator200.s();!(_step200=_iterator200.n()).done;){var dom=_step200.value.dom;dom.remove();}}catch(err){_iterator200.e(err);}finally{_iterator200.f();}(_b=this.intersectionObserver)===null||_b===void 0?void 0:_b.disconnect();clearTimeout(this.measureTimeout);}},{key:"readMeasure",value:function readMeasure(){var _this87=this;var editor=this.view.dom.getBoundingClientRect();return{editor:editor,parent:this.parent?this.container.getBoundingClientRect():editor,pos:this.manager.tooltips.map(function(t){return _this87.view.coordsAtPos(t.pos);}),size:this.manager.tooltipViews.map(function(_ref69){var dom=_ref69.dom;return dom.getBoundingClientRect();}),space:this.view.state.facet(tooltipConfig).tooltipSpace(this.view)};}},{key:"writeMeasure",value:function writeMeasure(measured){var editor=measured.editor,space=measured.space;var others=[];for(var _i140=0;_i140<this.manager.tooltips.length;_i140++){var tooltip=this.manager.tooltips[_i140],tView=this.manager.tooltipViews[_i140],dom=tView.dom;var pos=measured.pos[_i140],size=measured.size[_i140];// Hide tooltips that are outside of the editor.
36023602+if(!pos||pos.bottom<=Math.max(editor.top,space.top)||pos.top>=Math.min(editor.bottom,space.bottom)||pos.right<=Math.max(editor.left,space.left)||pos.left>=Math.min(editor.right,space.right)){dom.style.top=Outside;continue;}var arrow=tooltip.arrow?tView.dom.querySelector(".cm-tooltip-arrow"):null;var arrowHeight=arrow?7/* Size */:0;var width=size.right-size.left,height=size.bottom-size.top;var offset=tView.offset||noOffset,ltr=this.view.textDirection==view.Direction.LTR;var left=size.width>space.right-space.left?ltr?space.left:space.right-size.width:ltr?Math.min(pos.left-(arrow?14/* Offset */:0)+offset.x,space.right-width):Math.max(space.left,pos.left-width+(arrow?14/* Offset */:0)-offset.x);var above=!!tooltip.above;if(!tooltip.strictSide&&(above?pos.top-(size.bottom-size.top)-offset.y<space.top:pos.bottom+(size.bottom-size.top)+offset.y>space.bottom)&&above==space.bottom-pos.bottom>pos.top-space.top)above=!above;var top=above?pos.top-height-arrowHeight-offset.y:pos.bottom+arrowHeight+offset.y;var right=left+width;if(tView.overlap!==true){var _iterator201=_createForOfIteratorHelper(others),_step201;try{for(_iterator201.s();!(_step201=_iterator201.n()).done;){var r=_step201.value;if(r.left<right&&r.right>left&&r.top<top+height&&r.bottom>top)top=above?r.top-height-2-arrowHeight:r.bottom+arrowHeight+2;}}catch(err){_iterator201.e(err);}finally{_iterator201.f();}}if(this.position=="absolute"){dom.style.top=top-measured.parent.top+"px";dom.style.left=left-measured.parent.left+"px";}else{dom.style.top=top+"px";dom.style.left=left+"px";}if(arrow)arrow.style.left="".concat(pos.left+(ltr?offset.x:-offset.x)-(left+14/* Offset */-7/* Size */),"px");if(tView.overlap!==true)others.push({left:left,top:top,right:right,bottom:top+height});dom.classList.toggle("cm-tooltip-above",above);dom.classList.toggle("cm-tooltip-below",!above);if(tView.positioned)tView.positioned();}}},{key:"maybeMeasure",value:function maybeMeasure(){if(this.manager.tooltips.length){if(this.view.inView)this.view.requestMeasure(this.measureReq);if(this.inView!=this.view.inView){this.inView=this.view.inView;if(!this.inView){var _iterator202=_createForOfIteratorHelper(this.manager.tooltipViews),_step202;try{for(_iterator202.s();!(_step202=_iterator202.n()).done;){var tv=_step202.value;tv.dom.style.top=Outside;}}catch(err){_iterator202.e(err);}finally{_iterator202.f();}}}}}}]);return _class20;}(),{eventHandlers:{scroll:function scroll(){this.maybeMeasure();}}});var baseTheme=view.EditorView.baseTheme({".cm-tooltip":{zIndex:100},"&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:"".concat(7/* Size */,"px"),width:"".concat(7/* Size */*2,"px"),position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"".concat(7/* Size */,"px solid transparent"),borderRight:"".concat(7/* Size */,"px solid transparent")},".cm-tooltip-above &":{bottom:"-".concat(7/* Size */,"px"),"&:before":{borderTop:"".concat(7/* Size */,"px solid #bbb")},"&:after":{borderTop:"".concat(7/* Size */,"px solid #f5f5f5"),bottom:"1px"}},".cm-tooltip-below &":{top:"-".concat(7/* Size */,"px"),"&:before":{borderBottom:"".concat(7/* Size */,"px solid #bbb")},"&:after":{borderBottom:"".concat(7/* Size */,"px solid #f5f5f5"),top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});var noOffset={x:0,y:0};/**
36033603+Behavior by which an extension can provide a tooltip to be shown.
36043604+*/var showTooltip=state.Facet.define({enables:[tooltipPlugin,baseTheme]});var showHoverTooltip=state.Facet.define();var HoverTooltipHost=/*#__PURE__*/function(){function HoverTooltipHost(view){var _this88=this;_classCallCheck(this,HoverTooltipHost);this.view=view;this.mounted=false;this.dom=document.createElement("div");this.dom.classList.add("cm-tooltip-hover");this.manager=new TooltipViewManager(view,showHoverTooltip,function(t){return _this88.createHostedView(t);});}// Needs to be static so that host tooltip instances always match
36053605+_createClass(HoverTooltipHost,[{key:"createHostedView",value:function createHostedView(tooltip){var hostedView=tooltip.create(this.view);hostedView.dom.classList.add("cm-tooltip-section");this.dom.appendChild(hostedView.dom);if(this.mounted&&hostedView.mount)hostedView.mount(this.view);return hostedView;}},{key:"mount",value:function mount(view){var _iterator203=_createForOfIteratorHelper(this.manager.tooltipViews),_step203;try{for(_iterator203.s();!(_step203=_iterator203.n()).done;){var hostedView=_step203.value;if(hostedView.mount)hostedView.mount(view);}}catch(err){_iterator203.e(err);}finally{_iterator203.f();}this.mounted=true;}},{key:"positioned",value:function positioned(){var _iterator204=_createForOfIteratorHelper(this.manager.tooltipViews),_step204;try{for(_iterator204.s();!(_step204=_iterator204.n()).done;){var hostedView=_step204.value;if(hostedView.positioned)hostedView.positioned();}}catch(err){_iterator204.e(err);}finally{_iterator204.f();}}},{key:"update",value:function update(_update26){this.manager.update(_update26);}}],[{key:"create",value:function create(view){return new HoverTooltipHost(view);}}]);return HoverTooltipHost;}();var showHoverTooltipHost=showTooltip.compute([showHoverTooltip],function(state){var tooltips=state.facet(showHoverTooltip).filter(function(t){return t;});if(tooltips.length===0)return null;return{pos:Math.min.apply(Math,_toConsumableArray(tooltips.map(function(t){return t.pos;}))),end:Math.max.apply(Math,_toConsumableArray(tooltips.filter(function(t){return t.end!=null;}).map(function(t){return t.end;}))),create:HoverTooltipHost.create,above:tooltips[0].above,arrow:tooltips.some(function(t){return t.arrow;})};});var HoverPlugin=/*#__PURE__*/function(){function HoverPlugin(view,source,field,setHover,hoverTime){_classCallCheck(this,HoverPlugin);this.view=view;this.source=source;this.field=field;this.setHover=setHover;this.hoverTime=hoverTime;this.hoverTimeout=-1;this.restartTimeout=-1;this.pending=null;this.lastMove={x:0,y:0,target:view.dom,time:0};this.checkHover=this.checkHover.bind(this);view.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this));view.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this));}_createClass(HoverPlugin,[{key:"update",value:function update(){var _this89=this;if(this.pending){this.pending=null;clearTimeout(this.restartTimeout);this.restartTimeout=setTimeout(function(){return _this89.startHover();},20);}}},{key:"active",get:function get(){return this.view.state.field(this.field);}},{key:"checkHover",value:function checkHover(){this.hoverTimeout=-1;if(this.active)return;var hovered=Date.now()-this.lastMove.time;if(hovered<this.hoverTime)this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-hovered);else this.startHover();}},{key:"startHover",value:function startHover(){var _this90=this;var _a;clearTimeout(this.restartTimeout);var lastMove=this.lastMove;var pos=this.view.contentDOM.contains(lastMove.target)?this.view.posAtCoords(lastMove):null;if(pos==null)return;var posCoords=this.view.coordsAtPos(pos);if(posCoords==null||lastMove.y<posCoords.top||lastMove.y>posCoords.bottom||lastMove.x<posCoords.left-this.view.defaultCharacterWidth||lastMove.x>posCoords.right+this.view.defaultCharacterWidth)return;var bidi=this.view.bidiSpans(this.view.state.doc.lineAt(pos)).find(function(s){return s.from<=pos&&s.to>=pos;});var rtl=bidi&&bidi.dir==view.Direction.RTL?-1:1;var open=this.source(this.view,pos,lastMove.x<posCoords.left?-rtl:rtl);if((_a=open)===null||_a===void 0?void 0:_a.then){var pending=this.pending={pos:pos};open.then(function(result){if(_this90.pending==pending){_this90.pending=null;if(result)_this90.view.dispatch({effects:_this90.setHover.of(result)});}},function(e){return view.logException(_this90.view.state,e,"hover tooltip");});}else if(open){this.view.dispatch({effects:this.setHover.of(open)});}}},{key:"mousemove",value:function mousemove(event){var _a;this.lastMove={x:event.clientX,y:event.clientY,target:event.target,time:Date.now()};if(this.hoverTimeout<0)this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime);var tooltip=this.active;if(tooltip&&!isInTooltip(this.lastMove.target)||this.pending){var _ref70=tooltip||this.pending,pos=_ref70.pos,end=(_a=tooltip===null||tooltip===void 0?void 0:tooltip.end)!==null&&_a!==void 0?_a:pos;if(pos==end?this.view.posAtCoords(this.lastMove)!=pos:!isOverRange(this.view,pos,end,event.clientX,event.clientY,6/* MaxDist */)){this.view.dispatch({effects:this.setHover.of(null)});this.pending=null;}}}},{key:"mouseleave",value:function mouseleave(){clearTimeout(this.hoverTimeout);this.hoverTimeout=-1;if(this.active)this.view.dispatch({effects:this.setHover.of(null)});}},{key:"destroy",value:function destroy(){clearTimeout(this.hoverTimeout);this.view.dom.removeEventListener("mouseleave",this.mouseleave);this.view.dom.removeEventListener("mousemove",this.mousemove);}}]);return HoverPlugin;}();function isInTooltip(elt){for(var cur=elt;cur;cur=cur.parentNode){if(cur.nodeType==1&&cur.classList.contains("cm-tooltip"))return true;}return false;}function isOverRange(view,from,to,x,y,margin){var range=document.createRange();var fromDOM=view.domAtPos(from),toDOM=view.domAtPos(to);range.setEnd(toDOM.node,toDOM.offset);range.setStart(fromDOM.node,fromDOM.offset);var rects=range.getClientRects();range.detach();for(var _i141=0;_i141<rects.length;_i141++){var rect=rects[_i141];var dist=Math.max(rect.top-y,y-rect.bottom,rect.left-x,x-rect.right);if(dist<=margin)return true;}return false;}/**
36063606+Enable a hover tooltip, which shows up when the pointer hovers
36073607+over ranges of text. The callback is called when the mouse hovers
36083608+over the document text. It should, if there is a tooltip
36093609+associated with position `pos` return the tooltip description
36103610+(either directly or in a promise). The `side` argument indicates
36113611+on which side of the position the pointer is—it will be -1 if the
36123612+pointer is before the position, 1 if after the position.
36133613+36143614+Note that all hover tooltips are hosted within a single tooltip
36153615+container element. This allows multiple tooltips over the same
36163616+range to be "merged" together without overlapping.
36173617+*/function hoverTooltip(source){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var setHover=state.StateEffect.define();var hoverState=state.StateField.define({create:function create(){return null;},update:function update(value,tr){if(value&&options.hideOnChange&&(tr.docChanged||tr.selection))return null;var _iterator205=_createForOfIteratorHelper(tr.effects),_step205;try{for(_iterator205.s();!(_step205=_iterator205.n()).done;){var effect=_step205.value;if(effect.is(setHover))return effect.value;if(effect.is(closeHoverTooltipEffect))return null;}}catch(err){_iterator205.e(err);}finally{_iterator205.f();}if(value&&tr.docChanged){var newPos=tr.changes.mapPos(value.pos,-1,state.MapMode.TrackDel);if(newPos==null)return null;var copy=Object.assign(Object.create(null),value);copy.pos=newPos;if(value.end!=null)copy.end=tr.changes.mapPos(value.end);return copy;}return value;},provide:function provide(f){return showHoverTooltip.from(f);}});var hoverTime=options.hoverTime||600/* Time */;return[hoverState,view.ViewPlugin.define(function(view){return new HoverPlugin(view,source,hoverState,setHover,hoverTime);}),showHoverTooltipHost];}/**
36183618+Get the active tooltip view for a given tooltip, if available.
36193619+*/function getTooltip(view,tooltip){var plugin=view.plugin(tooltipPlugin);if(!plugin)return null;var found=plugin.manager.tooltips.indexOf(tooltip);return found<0?null:plugin.manager.tooltipViews[found];}/**
36203620+Returns true if any hover tooltips are currently active.
36213621+*/function hasHoverTooltips(state){return state.facet(showHoverTooltip).some(function(x){return x;});}var closeHoverTooltipEffect=state.StateEffect.define();/**
36223622+Transaction effect that closes all hover tooltips.
36233623+*/var closeHoverTooltips=closeHoverTooltipEffect.of(null);/**
36243624+Tell the tooltip extension to recompute the position of the active
36253625+tooltips. This can be useful when something happens (such as a
36263626+re-positioning or CSS change affecting the editor) that could
36273627+invalidate the existing tooltip positions.
36283628+*/function repositionTooltips(view){var _a;(_a=view.plugin(tooltipPlugin))===null||_a===void 0?void 0:_a.maybeMeasure();}exports.closeHoverTooltips=closeHoverTooltips;exports.getTooltip=getTooltip;exports.hasHoverTooltips=hasHoverTooltips;exports.hoverTooltip=hoverTooltip;exports.repositionTooltips=repositionTooltips;exports.showTooltip=showTooltip;exports.tooltips=tooltips;},{"@codemirror/state":22,"@codemirror/view":27}],27:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var state=require('@codemirror/state');var styleMod=require('style-mod');var rangeset=require('@codemirror/rangeset');var text=require('@codemirror/text');var w3cKeyname=require('w3c-keyname');function getSelection(root){var target;// Browsers differ on whether shadow roots have a getSelection
36293629+// method. If it exists, use that, otherwise, call it on the
36303630+// document.
36313631+if(root.nodeType==11){// Shadow root
36323632+target=root.getSelection?root:root.ownerDocument;}else{target=root;}return target.getSelection();}function contains(dom,node){return node?dom.contains(node.nodeType!=1?node.parentNode:node):false;}function deepActiveElement(){var elt=document.activeElement;while(elt&&elt.shadowRoot){elt=elt.shadowRoot.activeElement;}return elt;}function hasSelection(dom,selection){if(!selection.anchorNode)return false;try{// Firefox will raise 'permission denied' errors when accessing
36333633+// properties of `sel.anchorNode` when it's in a generated CSS
36343634+// element.
36353635+return contains(dom,selection.anchorNode);}catch(_){return false;}}function clientRectsFor(dom){if(dom.nodeType==3)return textRange(dom,0,dom.nodeValue.length).getClientRects();else if(dom.nodeType==1)return dom.getClientRects();else return[];}// Scans forward and backward through DOM positions equivalent to the
36363636+// given one to see if the two are in the same place (i.e. after a
36373637+// text node vs at the end of that text node)
36383638+function isEquivalentPosition(node,off,targetNode,targetOff){return targetNode?scanFor(node,off,targetNode,targetOff,-1)||scanFor(node,off,targetNode,targetOff,1):false;}function domIndex(node){for(var index=0;;index++){node=node.previousSibling;if(!node)return index;}}function scanFor(node,off,targetNode,targetOff,dir){for(;;){if(node==targetNode&&off==targetOff)return true;if(off==(dir<0?0:maxOffset(node))){if(node.nodeName=="DIV")return false;var parent=node.parentNode;if(!parent||parent.nodeType!=1)return false;off=domIndex(node)+(dir<0?0:1);node=parent;}else if(node.nodeType==1){node=node.childNodes[off+(dir<0?-1:0)];if(node.nodeType==1&&node.contentEditable=="false")return false;off=dir<0?maxOffset(node):0;}else{return false;}}}function maxOffset(node){return node.nodeType==3?node.nodeValue.length:node.childNodes.length;}var Rect0={left:0,right:0,top:0,bottom:0};function flattenRect(rect,left){var x=left?rect.left:rect.right;return{left:x,right:x,top:rect.top,bottom:rect.bottom};}function windowRect(win){return{left:0,right:win.innerWidth,top:0,bottom:win.innerHeight};}var ScrollSpace=5;function scrollRectIntoView(dom,rect,side,center){var doc=dom.ownerDocument,win=doc.defaultView;for(var cur=dom;cur;){if(cur.nodeType==1){// Element
36393639+var bounding=void 0,top=cur==doc.body;if(top){bounding=windowRect(win);}else{if(cur.scrollHeight<=cur.clientHeight&&cur.scrollWidth<=cur.clientWidth){cur=cur.parentNode;continue;}var _rect2=cur.getBoundingClientRect();// Make sure scrollbar width isn't included in the rectangle
36403640+bounding={left:_rect2.left,right:_rect2.left+cur.clientWidth,top:_rect2.top,bottom:_rect2.top+cur.clientHeight};}var moveX=0,moveY=0;if(center){var rectHeight=rect.bottom-rect.top,boundingHeight=bounding.bottom-bounding.top;var targetTop=void 0;if(rectHeight<=boundingHeight)targetTop=rect.top+rectHeight/2-boundingHeight/2;else if(side<0)targetTop=rect.top-ScrollSpace;else targetTop=rect.bottom+ScrollSpace-boundingHeight;moveY=targetTop-bounding.top;if(Math.abs(moveY)<=1)moveY=0;}else if(rect.top<bounding.top){moveY=-(bounding.top-rect.top+ScrollSpace);if(side>0&&rect.bottom>bounding.bottom+moveY)moveY=rect.bottom-bounding.bottom+moveY+ScrollSpace;}else if(rect.bottom>bounding.bottom){moveY=rect.bottom-bounding.bottom+ScrollSpace;if(side<0&&rect.top-moveY<bounding.top)moveY=-(bounding.top+moveY-rect.top+ScrollSpace);}if(rect.left<bounding.left){moveX=-(bounding.left-rect.left+ScrollSpace);if(side>0&&rect.right>bounding.right+moveX)moveX=rect.right-bounding.right+moveX+ScrollSpace;}else if(rect.right>bounding.right){moveX=rect.right-bounding.right+ScrollSpace;if(side<0&&rect.left<bounding.left+moveX)moveX=-(bounding.left+moveX-rect.left+ScrollSpace);}if(moveX||moveY){if(top){win.scrollBy(moveX,moveY);}else{if(moveY){var start=cur.scrollTop;cur.scrollTop+=moveY;moveY=cur.scrollTop-start;}if(moveX){var _start4=cur.scrollLeft;cur.scrollLeft+=moveX;moveX=cur.scrollLeft-_start4;}rect={left:rect.left-moveX,top:rect.top-moveY,right:rect.right-moveX,bottom:rect.bottom-moveY};}}if(top)break;cur=cur.assignedSlot||cur.parentNode;center=false;}else if(cur.nodeType==11){// A shadow root
36413641+cur=cur.host;}else{break;}}}var DOMSelection=/*#__PURE__*/function(){function DOMSelection(){_classCallCheck(this,DOMSelection);this.anchorNode=null;this.anchorOffset=0;this.focusNode=null;this.focusOffset=0;}_createClass(DOMSelection,[{key:"eq",value:function eq(domSel){return this.anchorNode==domSel.anchorNode&&this.anchorOffset==domSel.anchorOffset&&this.focusNode==domSel.focusNode&&this.focusOffset==domSel.focusOffset;}},{key:"set",value:function set(domSel){this.anchorNode=domSel.anchorNode;this.anchorOffset=domSel.anchorOffset;this.focusNode=domSel.focusNode;this.focusOffset=domSel.focusOffset;}}]);return DOMSelection;}();var preventScrollSupported=null;// Feature-detects support for .focus({preventScroll: true}), and uses
36423642+// a fallback kludge when not supported.
36433643+function focusPreventScroll(dom){if(dom.setActive)return dom.setActive();// in IE
36443644+if(preventScrollSupported)return dom.focus(preventScrollSupported);var stack=[];for(var cur=dom;cur;cur=cur.parentNode){stack.push(cur,cur.scrollTop,cur.scrollLeft);if(cur==cur.ownerDocument)break;}dom.focus(preventScrollSupported==null?Object.defineProperties({},{preventScroll:{get:function get(){preventScrollSupported={preventScroll:true};return true;},configurable:true,enumerable:true}}):undefined);if(!preventScrollSupported){preventScrollSupported=false;for(var _i142=0;_i142<stack.length;){var elt=stack[_i142++],top=stack[_i142++],left=stack[_i142++];if(elt.scrollTop!=top)elt.scrollTop=top;if(elt.scrollLeft!=left)elt.scrollLeft=left;}}}var scratchRange;function textRange(node,from){var to=arguments.length>2&&arguments[2]!==undefined?arguments[2]:from;var range=scratchRange||(scratchRange=document.createRange());range.setEnd(node,to);range.setStart(node,from);return range;}function dispatchKey(elt,name,code){var options={key:name,code:name,keyCode:code,which:code,cancelable:true};var down=new KeyboardEvent("keydown",options);down.synthetic=true;elt.dispatchEvent(down);var up=new KeyboardEvent("keyup",options);up.synthetic=true;elt.dispatchEvent(up);return down.defaultPrevented||up.defaultPrevented;}function getRoot(node){while(node){if(node&&(node.nodeType==9||node.nodeType==11&&node.host))return node;node=node.assignedSlot||node.parentNode;}return null;}var DOMPos=/*#__PURE__*/function(){function DOMPos(node,offset){var precise=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;_classCallCheck(this,DOMPos);this.node=node;this.offset=offset;this.precise=precise;}_createClass(DOMPos,null,[{key:"before",value:function before(dom,precise){return new DOMPos(dom.parentNode,domIndex(dom),precise);}},{key:"after",value:function after(dom,precise){return new DOMPos(dom.parentNode,domIndex(dom)+1,precise);}}]);return DOMPos;}();var none$3=[];var ContentView=/*#__PURE__*/function(){function ContentView(){_classCallCheck(this,ContentView);this.parent=null;this.dom=null;this.dirty=2/* Node */;}_createClass(ContentView,[{key:"editorView",get:function get(){if(!this.parent)throw new Error("Accessing view in orphan content view");return this.parent.editorView;}},{key:"overrideDOMText",get:function get(){return null;}},{key:"posAtStart",get:function get(){return this.parent?this.parent.posBefore(this):0;}},{key:"posAtEnd",get:function get(){return this.posAtStart+this.length;}},{key:"posBefore",value:function posBefore(view){var pos=this.posAtStart;var _iterator206=_createForOfIteratorHelper(this.children),_step206;try{for(_iterator206.s();!(_step206=_iterator206.n()).done;){var child=_step206.value;if(child==view)return pos;pos+=child.length+child.breakAfter;}}catch(err){_iterator206.e(err);}finally{_iterator206.f();}throw new RangeError("Invalid child in posBefore");}},{key:"posAfter",value:function posAfter(view){return this.posBefore(view)+view.length;}// Will return a rectangle directly before (when side < 0), after
36453645+// (side > 0) or directly on (when the browser supports it) the
36463646+// given position.
36473647+},{key:"coordsAt",value:function coordsAt(_pos,_side){return null;}},{key:"sync",value:function sync(track){var _a;if(this.dirty&2/* Node */){var parent=this.dom;var pos=parent.firstChild;var _iterator207=_createForOfIteratorHelper(this.children),_step207;try{for(_iterator207.s();!(_step207=_iterator207.n()).done;){var child=_step207.value;if(child.dirty){if(!child.dom&&pos&&!((_a=ContentView.get(pos))===null||_a===void 0?void 0:_a.parent))child.reuseDOM(pos);child.sync(track);child.dirty=0/* Not */;}if(track&&!track.written&&track.node==parent&&pos!=child.dom)track.written=true;if(child.dom.parentNode==parent){while(pos&&pos!=child.dom){pos=rm(pos);}pos=child.dom.nextSibling;}else{parent.insertBefore(child.dom,pos);}}}catch(err){_iterator207.e(err);}finally{_iterator207.f();}if(pos&&track&&track.node==parent)track.written=true;while(pos){pos=rm(pos);}}else if(this.dirty&1/* Child */){var _iterator208=_createForOfIteratorHelper(this.children),_step208;try{for(_iterator208.s();!(_step208=_iterator208.n()).done;){var _child2=_step208.value;if(_child2.dirty){_child2.sync(track);_child2.dirty=0/* Not */;}}}catch(err){_iterator208.e(err);}finally{_iterator208.f();}}}},{key:"reuseDOM",value:function reuseDOM(_dom){return false;}},{key:"localPosFromDOM",value:function localPosFromDOM(node,offset){var after;if(node==this.dom){after=this.dom.childNodes[offset];}else{var bias=maxOffset(node)==0?0:offset==0?-1:1;for(;;){var parent=node.parentNode;if(parent==this.dom)break;if(bias==0&&parent.firstChild!=parent.lastChild){if(node==parent.firstChild)bias=-1;else bias=1;}node=parent;}if(bias<0)after=node;else after=node.nextSibling;}if(after==this.dom.firstChild)return 0;while(after&&!ContentView.get(after)){after=after.nextSibling;}if(!after)return this.length;for(var _i143=0,pos=0;;_i143++){var child=this.children[_i143];if(child.dom==after)return pos;pos+=child.length+child.breakAfter;}}},{key:"domBoundsAround",value:function domBoundsAround(from,to){var offset=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var fromI=-1,fromStart=-1,toI=-1,toEnd=-1;for(var _i144=0,pos=offset,prevEnd=offset;_i144<this.children.length;_i144++){var child=this.children[_i144],end=pos+child.length;if(pos<from&&end>to)return child.domBoundsAround(from,to,pos);if(end>=from&&fromI==-1){fromI=_i144;fromStart=pos;}if(pos>to&&child.dom.parentNode==this.dom){toI=_i144;toEnd=prevEnd;break;}prevEnd=end;pos=end+child.breakAfter;}return{from:fromStart,to:toEnd<0?offset+this.length:toEnd,startDOM:(fromI?this.children[fromI-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:toI<this.children.length&&toI>=0?this.children[toI].dom:null};}},{key:"markDirty",value:function markDirty(){var andParent=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;this.dirty|=2/* Node */;this.markParentsDirty(andParent);}},{key:"markParentsDirty",value:function markParentsDirty(childList){for(var parent=this.parent;parent;parent=parent.parent){if(childList)parent.dirty|=2/* Node */;if(parent.dirty&1/* Child */)return;parent.dirty|=1/* Child */;childList=false;}}},{key:"setParent",value:function setParent(parent){if(this.parent!=parent){this.parent=parent;if(this.dirty)this.markParentsDirty(true);}}},{key:"setDOM",value:function setDOM(dom){if(this.dom)this.dom.cmView=null;this.dom=dom;dom.cmView=this;}},{key:"rootView",get:function get(){for(var v=this;;){var parent=v.parent;if(!parent)return v;v=parent;}}},{key:"replaceChildren",value:function replaceChildren(from,to){var _this$children2;var children=arguments.length>2&&arguments[2]!==undefined?arguments[2]:none$3;this.markDirty();for(var _i145=from;_i145<to;_i145++){var child=this.children[_i145];if(child.parent==this)child.parent=null;}(_this$children2=this.children).splice.apply(_this$children2,[from,to-from].concat(_toConsumableArray(children)));for(var _i146=0;_i146<children.length;_i146++){children[_i146].setParent(this);}}},{key:"ignoreMutation",value:function ignoreMutation(_rec){return false;}},{key:"ignoreEvent",value:function ignoreEvent(_event){return false;}},{key:"childCursor",value:function childCursor(){var pos=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.length;return new ChildCursor(this.children,pos,this.children.length);}},{key:"childPos",value:function childPos(pos){var bias=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;return this.childCursor().findPos(pos,bias);}},{key:"toString",value:function toString(){var name=this.constructor.name.replace("View","");return name+(this.children.length?"("+this.children.join()+")":this.length?"["+(name=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"");}},{key:"isEditable",get:function get(){return true;}}],[{key:"get",value:function get(node){return node.cmView;}}]);return ContentView;}();ContentView.prototype.breakAfter=0;// Remove a DOM node and return its next sibling.
36483648+function rm(dom){var next=dom.nextSibling;dom.parentNode.removeChild(dom);return next;}var ChildCursor=/*#__PURE__*/function(){function ChildCursor(children,pos,i){_classCallCheck(this,ChildCursor);this.children=children;this.pos=pos;this.i=i;this.off=0;}_createClass(ChildCursor,[{key:"findPos",value:function findPos(pos){var bias=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;for(;;){if(pos>this.pos||pos==this.pos&&(bias>0||this.i==0||this.children[this.i-1].breakAfter)){this.off=pos-this.pos;return this;}var next=this.children[--this.i];this.pos-=next.length+next.breakAfter;}}}]);return ChildCursor;}();var _ref71=typeof navigator!="undefined"?[navigator,document]:[{userAgent:"",vendor:"",platform:""},{documentElement:{style:{}}}],_ref72=_slicedToArray(_ref71,2),nav=_ref72[0],doc=_ref72[1];var ie_edge=/Edge\/(\d+)/.exec(nav.userAgent);var ie_upto10=/MSIE \d/.test(nav.userAgent);var ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);var ie=!!(ie_upto10||ie_11up||ie_edge);var gecko=!ie&&/gecko\/(\d+)/i.test(nav.userAgent);var chrome=!ie&&/Chrome\/(\d+)/.exec(nav.userAgent);var webkit=("webkitFontSmoothing"in doc.documentElement.style);var safari=!ie&&/Apple Computer/.test(nav.vendor);var ios=safari&&(/Mobile\/\w+/.test(nav.userAgent)||nav.maxTouchPoints>2);var browser={mac:ios||/Mac/.test(nav.platform),windows:/Win/.test(nav.platform),linux:/Linux|X11/.test(nav.platform),ie:ie,ie_version:ie_upto10?doc.documentMode||6:ie_11up?+ie_11up[1]:ie_edge?+ie_edge[1]:0,gecko:gecko,gecko_version:gecko?+(/Firefox\/(\d+)/.exec(nav.userAgent)||[0,0])[1]:0,chrome:!!chrome,chrome_version:chrome?+chrome[1]:0,ios:ios,android:/Android\b/.test(nav.userAgent),webkit:webkit,safari:safari,webkit_version:webkit?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:doc.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};var none$2=[];var InlineView=/*#__PURE__*/function(_ContentView8){_inherits(InlineView,_ContentView8);var _super44=_createSuper(InlineView);function InlineView(){_classCallCheck(this,InlineView);return _super44.apply(this,arguments);}_createClass(InlineView,[{key:"become",value:/**
36493649+ Return true when this view is equivalent to `other` and can take
36503650+ on its role.
36513651+ */function become(_other){return false;}// When this is a zero-length view with a side, this should return a
36523652+// negative number to indicate it is before its position, or a
36533653+// positive number when after its position.
36543654+},{key:"getSide",value:function getSide(){return 0;}}]);return InlineView;}(ContentView);InlineView.prototype.children=none$2;var MaxJoinLen=256;var TextView=/*#__PURE__*/function(_InlineView){_inherits(TextView,_InlineView);var _super45=_createSuper(TextView);function TextView(text){var _this91;_classCallCheck(this,TextView);_this91=_super45.call(this);_this91.text=text;return _this91;}_createClass(TextView,[{key:"length",get:function get(){return this.text.length;}},{key:"createDOM",value:function createDOM(textDOM){this.setDOM(textDOM||document.createTextNode(this.text));}},{key:"sync",value:function sync(track){if(!this.dom)this.createDOM();if(this.dom.nodeValue!=this.text){if(track&&track.node==this.dom)track.written=true;this.dom.nodeValue=this.text;}}},{key:"reuseDOM",value:function reuseDOM(dom){if(dom.nodeType!=3)return false;this.createDOM(dom);return true;}},{key:"merge",value:function merge(from,to,source){if(source&&(!(source instanceof TextView)||this.length-(to-from)+source.length>MaxJoinLen))return false;this.text=this.text.slice(0,from)+(source?source.text:"")+this.text.slice(to);this.markDirty();return true;}},{key:"slice",value:function slice(from){var result=new TextView(this.text.slice(from));this.text=this.text.slice(0,from);return result;}},{key:"localPosFromDOM",value:function localPosFromDOM(node,offset){return node==this.dom?offset:offset?this.text.length:0;}},{key:"domAtPos",value:function domAtPos(pos){return new DOMPos(this.dom,pos);}},{key:"domBoundsAround",value:function domBoundsAround(_from,_to,offset){return{from:offset,to:offset+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling};}},{key:"coordsAt",value:function coordsAt(pos,side){return textCoords(this.dom,pos,side);}}]);return TextView;}(InlineView);var MarkView=/*#__PURE__*/function(_InlineView2){_inherits(MarkView,_InlineView2);var _super46=_createSuper(MarkView);function MarkView(mark){var _this92;var children=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var length=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;_classCallCheck(this,MarkView);_this92=_super46.call(this);_this92.mark=mark;_this92.children=children;_this92.length=length;var _iterator209=_createForOfIteratorHelper(children),_step209;try{for(_iterator209.s();!(_step209=_iterator209.n()).done;){var ch=_step209.value;ch.setParent(_assertThisInitialized(_this92));}}catch(err){_iterator209.e(err);}finally{_iterator209.f();}return _this92;}_createClass(MarkView,[{key:"createDOM",value:function createDOM(){var dom=document.createElement(this.mark.tagName);if(this.mark["class"])dom.className=this.mark["class"];if(this.mark.attrs)for(var name in this.mark.attrs){dom.setAttribute(name,this.mark.attrs[name]);}this.setDOM(dom);}},{key:"sync",value:function sync(track){if(!this.dom||this.dirty&4/* Attrs */)this.createDOM();_get(_getPrototypeOf(MarkView.prototype),"sync",this).call(this,track);}},{key:"merge",value:function merge(from,to,source,openStart,openEnd){if(source&&(!(source instanceof MarkView&&source.mark.eq(this.mark))||from&&openStart<=0||to<this.length&&openEnd<=0))return false;mergeInlineChildren(this,from,to,source?source.children:none$2,openStart-1,openEnd-1);this.markDirty();return true;}},{key:"slice",value:function slice(from){var result=[],off=0,detachFrom=-1,i=0;var _iterator210=_createForOfIteratorHelper(this.children),_step210;try{for(_iterator210.s();!(_step210=_iterator210.n()).done;){var elt=_step210.value;var end=off+elt.length;if(end>from)result.push(off<from?elt.slice(from-off):elt);if(detachFrom<0&&off>=from)detachFrom=i;off=end;i++;}}catch(err){_iterator210.e(err);}finally{_iterator210.f();}var length=this.length-from;this.length=from;if(detachFrom>-1)this.replaceChildren(detachFrom,this.children.length);return new MarkView(this.mark,result,length);}},{key:"domAtPos",value:function domAtPos(pos){return inlineDOMAtPos(this.dom,this.children,pos);}},{key:"coordsAt",value:function coordsAt(pos,side){return coordsInChildren(this,pos,side);}}]);return MarkView;}(InlineView);function textCoords(text,pos,side){var length=text.nodeValue.length;if(pos>length)pos=length;var from=pos,to=pos,flatten=0;if(pos==0&&side<0||pos==length&&side>=0){if(!(browser.chrome||browser.gecko)){// These browsers reliably return valid rectangles for empty ranges
36553655+if(pos){from--;flatten=1;}// FIXME this is wrong in RTL text
36563656+else{to++;flatten=-1;}}}else{if(side<0)from--;else to++;}var rects=textRange(text,from,to).getClientRects();if(!rects.length)return Rect0;var rect=rects[(flatten?flatten<0:side>=0)?0:rects.length-1];if(browser.safari&&!flatten&&rect.width==0)rect=Array.prototype.find.call(rects,function(r){return r.width;})||rect;return flatten?flattenRect(rect,flatten<0):rect;}// Also used for collapsed ranges that don't have a placeholder widget!
36573657+var WidgetView=/*#__PURE__*/function(_InlineView3){_inherits(WidgetView,_InlineView3);var _super47=_createSuper(WidgetView);function WidgetView(widget,length,side){var _this93;_classCallCheck(this,WidgetView);_this93=_super47.call(this);_this93.widget=widget;_this93.length=length;_this93.side=side;return _this93;}_createClass(WidgetView,[{key:"slice",value:function slice(from){var result=WidgetView.create(this.widget,this.length-from,this.side);this.length-=from;return result;}},{key:"sync",value:function sync(){if(!this.dom||!this.widget.updateDOM(this.dom)){this.setDOM(this.widget.toDOM(this.editorView));this.dom.contentEditable="false";}}},{key:"getSide",value:function getSide(){return this.side;}},{key:"merge",value:function merge(from,to,source,openStart,openEnd){if(source&&(!(source instanceof WidgetView)||!this.widget.compare(source.widget)||from>0&&openStart<=0||to<this.length&&openEnd<=0))return false;this.length=from+(source?source.length:0)+(this.length-to);return true;}},{key:"become",value:function become(other){if(other.length==this.length&&other instanceof WidgetView&&other.side==this.side){if(this.widget.constructor==other.widget.constructor){if(!this.widget.eq(other.widget))this.markDirty(true);this.widget=other.widget;return true;}}return false;}},{key:"ignoreMutation",value:function ignoreMutation(){return true;}},{key:"ignoreEvent",value:function ignoreEvent(event){return this.widget.ignoreEvent(event);}},{key:"overrideDOMText",get:function get(){if(this.length==0)return text.Text.empty;var top=this;while(top.parent){top=top.parent;}var view=top.editorView,text$1=view&&view.state.doc,start=this.posAtStart;return text$1?text$1.slice(start,start+this.length):text.Text.empty;}},{key:"domAtPos",value:function domAtPos(pos){return pos==0?DOMPos.before(this.dom):DOMPos.after(this.dom,pos==this.length);}},{key:"domBoundsAround",value:function domBoundsAround(){return null;}},{key:"coordsAt",value:function coordsAt(pos,side){var rects=this.dom.getClientRects(),rect=null;if(!rects.length)return Rect0;for(var _i147=pos>0?rects.length-1:0;;_i147+=pos>0?-1:1){rect=rects[_i147];if(pos>0?_i147==0:_i147==rects.length-1||rect.top<rect.bottom)break;}return pos==0&&side>0||pos==this.length&&side<=0?rect:flattenRect(rect,pos==0);}},{key:"isEditable",get:function get(){return false;}}],[{key:"create",value:function create(widget,length,side){return new(widget.customView||WidgetView)(widget,length,side);}}]);return WidgetView;}(InlineView);var CompositionView=/*#__PURE__*/function(_WidgetView2){_inherits(CompositionView,_WidgetView2);var _super48=_createSuper(CompositionView);function CompositionView(){_classCallCheck(this,CompositionView);return _super48.apply(this,arguments);}_createClass(CompositionView,[{key:"domAtPos",value:function domAtPos(pos){return new DOMPos(this.widget.text,pos);}},{key:"sync",value:function sync(){if(!this.dom)this.setDOM(this.widget.toDOM());}},{key:"localPosFromDOM",value:function localPosFromDOM(node,offset){return!offset?0:node.nodeType==3?Math.min(offset,this.length):this.length;}},{key:"ignoreMutation",value:function ignoreMutation(){return false;}},{key:"overrideDOMText",get:function get(){return null;}},{key:"coordsAt",value:function coordsAt(pos,side){return textCoords(this.widget.text,pos,side);}},{key:"isEditable",get:function get(){return true;}}]);return CompositionView;}(WidgetView);// These are drawn around uneditable widgets to avoid a number of
36583658+// browser bugs that show up when the cursor is directly next to
36593659+// uneditable inline content.
36603660+var WidgetBufferView=/*#__PURE__*/function(_InlineView4){_inherits(WidgetBufferView,_InlineView4);var _super49=_createSuper(WidgetBufferView);function WidgetBufferView(side){var _this94;_classCallCheck(this,WidgetBufferView);_this94=_super49.call(this);_this94.side=side;return _this94;}_createClass(WidgetBufferView,[{key:"length",get:function get(){return 0;}},{key:"merge",value:function merge(){return false;}},{key:"become",value:function become(other){return other instanceof WidgetBufferView&&other.side==this.side;}},{key:"slice",value:function slice(){return new WidgetBufferView(this.side);}},{key:"sync",value:function sync(){if(!this.dom)this.setDOM(document.createTextNode("\u200B"));else if(this.dirty&&this.dom.nodeValue!="\u200B")this.dom.nodeValue="\u200B";}},{key:"getSide",value:function getSide(){return this.side;}},{key:"domAtPos",value:function domAtPos(pos){return DOMPos.before(this.dom);}},{key:"domBoundsAround",value:function domBoundsAround(){return null;}},{key:"coordsAt",value:function coordsAt(pos){var rects=clientRectsFor(this.dom);return rects[rects.length-1];}},{key:"overrideDOMText",get:function get(){return text.Text.of([this.dom.nodeValue.replace(/\u200b/g,"")]);}}]);return WidgetBufferView;}(InlineView);function mergeInlineChildren(parent,from,to,elts,openStart,openEnd){var cur=parent.childCursor();var _cur$findPos3=cur.findPos(to,1),toI=_cur$findPos3.i,toOff=_cur$findPos3.off;var _cur$findPos4=cur.findPos(from,-1),fromI=_cur$findPos4.i,fromOff=_cur$findPos4.off;var dLen=from-to;var _iterator211=_createForOfIteratorHelper(elts),_step211;try{for(_iterator211.s();!(_step211=_iterator211.n()).done;){var view=_step211.value;dLen+=view.length;}}catch(err){_iterator211.e(err);}finally{_iterator211.f();}parent.length+=dLen;var children=parent.children;// Both from and to point into the same child view
36613661+if(fromI==toI&&fromOff){var start=children[fromI];// Maybe just update that view and be done
36623662+if(elts.length==1&&start.merge(fromOff,toOff,elts[0],openStart,openEnd))return;if(elts.length==0){start.merge(fromOff,toOff,null,openStart,openEnd);return;}// Otherwise split it, so that we don't have to worry about aliasing front/end afterwards
36633663+var after=start.slice(toOff);if(after.merge(0,0,elts[elts.length-1],0,openEnd))elts[elts.length-1]=after;else elts.push(after);toI++;openEnd=toOff=0;}// Make sure start and end positions fall on node boundaries
36643664+// (fromOff/toOff are no longer used after this), and that if the
36653665+// start or end of the elts can be merged with adjacent nodes,
36663666+// this is done
36673667+if(toOff){var end=children[toI];if(elts.length&&end.merge(0,toOff,elts[elts.length-1],0,openEnd)){elts.pop();openEnd=elts.length?0:openStart;}else{end.merge(0,toOff,null,0,0);}}else if(toI<children.length&&elts.length&&children[toI].merge(0,0,elts[elts.length-1],0,openEnd)){elts.pop();openEnd=elts.length?0:openStart;}if(fromOff){var _start5=children[fromI];if(elts.length&&_start5.merge(fromOff,_start5.length,elts[0],openStart,0)){elts.shift();openStart=elts.length?0:openEnd;}else{_start5.merge(fromOff,_start5.length,null,0,0);}fromI++;}else if(fromI&&elts.length){var _end4=children[fromI-1];if(_end4.merge(_end4.length,_end4.length,elts[0],openStart,0)){elts.shift();openStart=elts.length?0:openEnd;}}// Then try to merge any mergeable nodes at the start and end of
36683668+// the changed range
36693669+while(fromI<toI&&elts.length&&children[toI-1].become(elts[elts.length-1])){elts.pop();toI--;openEnd=elts.length?0:openStart;}while(fromI<toI&&elts.length&&children[fromI].become(elts[0])){elts.shift();fromI++;openStart=elts.length?0:openEnd;}if(!elts.length&&fromI&&toI<children.length&&children[toI].merge(0,0,children[fromI-1],openStart,openEnd))fromI--;// And if anything remains, splice the child array to insert the new elts
36703670+if(elts.length||fromI!=toI)parent.replaceChildren(fromI,toI,elts);}function inlineDOMAtPos(dom,children,pos){var i=0;for(var off=0;i<children.length;i++){var child=children[i],end=off+child.length;if(end==off&&child.getSide()<=0)continue;if(pos>off&&pos<end&&child.dom.parentNode==dom)return child.domAtPos(pos-off);if(pos<=off)break;off=end;}for(;i>0;i--){var before=children[i-1].dom;if(before.parentNode==dom)return DOMPos.after(before);}return new DOMPos(dom,0);}// Assumes `view`, if a mark view, has precisely 1 child.
36713671+function joinInlineInto(parent,view,open){var last,children=parent.children;if(open>0&&view instanceof MarkView&&children.length&&(last=children[children.length-1])instanceof MarkView&&last.mark.eq(view.mark)){joinInlineInto(last,view.children[0],open-1);}else{children.push(view);view.setParent(parent);}parent.length+=view.length;}function coordsInChildren(view,pos,side){for(var off=0,_i148=0;_i148<view.children.length;_i148++){var child=view.children[_i148],end=off+child.length,next=void 0;if((side<=0||end==view.length||child.getSide()>0?end>=pos:end>pos)&&(pos<end||_i148+1==view.children.length||(next=view.children[_i148+1]).length||next.getSide()>0)){var flatten=0;if(end==off){if(child.getSide()<=0)continue;flatten=side=-child.getSide();}var rect=child.coordsAt(pos-off,side);return flatten&&rect?flattenRect(rect,side<0):rect;}off=end;}var last=view.dom.lastChild;if(!last)return view.dom.getBoundingClientRect();var rects=clientRectsFor(last);return rects[rects.length-1];}function combineAttrs(source,target){for(var name in source){if(name=="class"&&target["class"])target["class"]+=" "+source["class"];else if(name=="style"&&target.style)target.style+=";"+source.style;else target[name]=source[name];}return target;}function attrsEq(a,b){if(a==b)return true;if(!a||!b)return false;var keysA=Object.keys(a),keysB=Object.keys(b);if(keysA.length!=keysB.length)return false;for(var _i149=0,_keysA2=keysA;_i149<_keysA2.length;_i149++){var key=_keysA2[_i149];if(keysB.indexOf(key)==-1||a[key]!==b[key])return false;}return true;}function _updateAttrs2(dom,prev,attrs){if(prev)for(var name in prev){if(!(attrs&&name in attrs))dom.removeAttribute(name);}if(attrs)for(var _name2 in attrs){if(!(prev&&prev[_name2]==attrs[_name2]))dom.setAttribute(_name2,attrs[_name2]);}}/**
36723672+Widgets added to the content are described by subclasses of this
36733673+class. Using a description object like that makes it possible to
36743674+delay creating of the DOM structure for a widget until it is
36753675+needed, and to avoid redrawing widgets even when the decorations
36763676+that define them are recreated.
36773677+*/var WidgetType=/*#__PURE__*/function(){function WidgetType(){_classCallCheck(this,WidgetType);}_createClass(WidgetType,[{key:"eq",value:/**
36783678+ Compare this instance to another instance of the same type.
36793679+ (TypeScript can't express this, but only instances of the same
36803680+ specific class will be passed to this method.) This is used to
36813681+ avoid redrawing widgets when they are replaced by a new
36823682+ decoration of the same type. The default implementation just
36833683+ returns `false`, which will cause new instances of the widget to
36843684+ always be redrawn.
36853685+ */function eq(_widget){return false;}/**
36863686+ Update a DOM element created by a widget of the same type (but
36873687+ different, non-`eq` content) to reflect this widget. May return
36883688+ true to indicate that it could update, false to indicate it
36893689+ couldn't (in which case the widget will be redrawn). The default
36903690+ implementation just returns false.
36913691+ */},{key:"updateDOM",value:function updateDOM(_dom){return false;}/**
36923692+ @internal
36933693+ */},{key:"compare",value:function compare(other){return this==other||this.constructor==other.constructor&&this.eq(other);}/**
36943694+ The estimated height this widget will have, to be used when
36953695+ estimating the height of content that hasn't been drawn. May
36963696+ return -1 to indicate you don't know. The default implementation
36973697+ returns -1.
36983698+ */},{key:"estimatedHeight",get:function get(){return-1;}/**
36993699+ Can be used to configure which kinds of events inside the widget
37003700+ should be ignored by the editor. The default is to ignore all
37013701+ events.
37023702+ */},{key:"ignoreEvent",value:function ignoreEvent(_event){return true;}/**
37033703+ @internal
37043704+ */},{key:"customView",get:function get(){return null;}}]);return WidgetType;}();/**
37053705+The different types of blocks that can occur in an editor view.
37063706+*/exports.BlockType=void 0;(function(BlockType){/**
37073707+ A line of text.
37083708+ */BlockType[BlockType["Text"]=0]="Text";/**
37093709+ A block widget associated with the position after it.
37103710+ */BlockType[BlockType["WidgetBefore"]=1]="WidgetBefore";/**
37113711+ A block widget associated with the position before it.
37123712+ */BlockType[BlockType["WidgetAfter"]=2]="WidgetAfter";/**
37133713+ A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
37143714+ */BlockType[BlockType["WidgetRange"]=3]="WidgetRange";})(exports.BlockType||(exports.BlockType={}));/**
37153715+A decoration provides information on how to draw or style a piece
37163716+of content. You'll usually use it wrapped in a
37173717+[`Range`](https://codemirror.net/6/docs/ref/#rangeset.Range), which adds a start and end position.
37183718+*/var Decoration=/*#__PURE__*/function(_rangeset$RangeValue4){_inherits(Decoration,_rangeset$RangeValue4);var _super50=_createSuper(Decoration);/**
37193719+ @internal
37203720+ */function Decoration(/**
37213721+ @internal
37223722+ */startSide,/**
37233723+ @internal
37243724+ */endSide,/**
37253725+ @internal
37263726+ */widget,/**
37273727+ The config object used to create this decoration. You can
37283728+ include additional properties in there to store metadata about
37293729+ your decoration.
37303730+ */spec){var _this95;_classCallCheck(this,Decoration);_this95=_super50.call(this);_this95.startSide=startSide;_this95.endSide=endSide;_this95.widget=widget;_this95.spec=spec;return _this95;}/**
37313731+ @internal
37323732+ */_createClass(Decoration,[{key:"heightRelevant",get:function get(){return false;}/**
37333733+ Create a mark decoration, which influences the styling of the
37343734+ content in its range. Nested mark decorations will cause nested
37353735+ DOM elements to be created. Nesting order is determined by
37363736+ precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations) or
37373737+ (below the facet-provided decorations) [view
37383738+ plugin](https://codemirror.net/6/docs/ref/#view.PluginSpec.decorations). Such elements are split
37393739+ on line boundaries and on the boundaries of higher-precedence
37403740+ decorations.
37413741+ */},{key:"hasHeight",value:/**
37423742+ @internal
37433743+ */function hasHeight(){return this.widget?this.widget.estimatedHeight>-1:false;}}],[{key:"mark",value:function mark(spec){return new MarkDecoration(spec);}/**
37443744+ Create a widget decoration, which adds an element at the given
37453745+ position.
37463746+ */},{key:"widget",value:function widget(spec){var side=spec.side||0;return new PointDecoration(spec,side,side,!!spec.block,spec.widget||null,false);}/**
37473747+ Create a replace decoration which replaces the given range with
37483748+ a widget, or simply hides it.
37493749+ */},{key:"replace",value:function replace(spec){var block=!!spec.block;var _getInclusive3=getInclusive(spec,block),start=_getInclusive3.start,end=_getInclusive3.end;var startSide=100000000/* Big */*(start?-1:1)*(block?2:1);var endSide=100000000/* Big */*(end?1:-1)*(block?2:1);return new PointDecoration(spec,startSide,endSide,block,spec.widget||null,true);}/**
37503750+ Create a line decoration, which can add DOM attributes to the
37513751+ line starting at the given position.
37523752+ */},{key:"line",value:function line(spec){return new LineDecoration(spec);}/**
37533753+ Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
37543754+ decorated range or ranges. If the ranges aren't already sorted,
37553755+ pass `true` for `sort` to make the library sort them for you.
37563756+ */},{key:"set",value:function set(of){var sort=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return rangeset.RangeSet.of(of,sort);}}]);return Decoration;}(rangeset.RangeValue);/**
37573757+The empty set of decorations.
37583758+*/Decoration.none=rangeset.RangeSet.empty;var MarkDecoration=/*#__PURE__*/function(_Decoration4){_inherits(MarkDecoration,_Decoration4);var _super51=_createSuper(MarkDecoration);function MarkDecoration(spec){var _this96;_classCallCheck(this,MarkDecoration);var _getInclusive4=getInclusive(spec),start=_getInclusive4.start,end=_getInclusive4.end;_this96=_super51.call(this,100000000/* Big */*(start?-1:1),100000000/* Big */*(end?1:-1),null,spec);_this96.tagName=spec.tagName||"span";_this96["class"]=spec["class"]||"";_this96.attrs=spec.attributes||null;return _this96;}_createClass(MarkDecoration,[{key:"eq",value:function eq(other){return this==other||other instanceof MarkDecoration&&this.tagName==other.tagName&&this["class"]==other["class"]&&attrsEq(this.attrs,other.attrs);}},{key:"range",value:function range(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:from;if(from>=to)throw new RangeError("Mark decorations may not be empty");return _get(_getPrototypeOf(MarkDecoration.prototype),"range",this).call(this,from,to);}}]);return MarkDecoration;}(Decoration);MarkDecoration.prototype.point=false;var LineDecoration=/*#__PURE__*/function(_Decoration5){_inherits(LineDecoration,_Decoration5);var _super52=_createSuper(LineDecoration);function LineDecoration(spec){_classCallCheck(this,LineDecoration);return _super52.call(this,-100000000/* Big */,-100000000/* Big */,null,spec);}_createClass(LineDecoration,[{key:"eq",value:function eq(other){return other instanceof LineDecoration&&attrsEq(this.spec.attributes,other.spec.attributes);}},{key:"range",value:function range(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:from;if(to!=from)throw new RangeError("Line decoration ranges must be zero-length");return _get(_getPrototypeOf(LineDecoration.prototype),"range",this).call(this,from,to);}}]);return LineDecoration;}(Decoration);LineDecoration.prototype.mapMode=state.MapMode.TrackBefore;LineDecoration.prototype.point=true;var PointDecoration=/*#__PURE__*/function(_Decoration6){_inherits(PointDecoration,_Decoration6);var _super53=_createSuper(PointDecoration);function PointDecoration(spec,startSide,endSide,block,widget,isReplace){var _this97;_classCallCheck(this,PointDecoration);_this97=_super53.call(this,startSide,endSide,widget,spec);_this97.block=block;_this97.isReplace=isReplace;_this97.mapMode=!block?state.MapMode.TrackDel:startSide<0?state.MapMode.TrackBefore:state.MapMode.TrackAfter;return _this97;}// Only relevant when this.block == true
37593759+_createClass(PointDecoration,[{key:"type",get:function get(){return this.startSide<this.endSide?exports.BlockType.WidgetRange:this.startSide<0?exports.BlockType.WidgetBefore:exports.BlockType.WidgetAfter;}},{key:"heightRelevant",get:function get(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5;}},{key:"eq",value:function eq(other){return other instanceof PointDecoration&&widgetsEq(this.widget,other.widget)&&this.block==other.block&&this.startSide==other.startSide&&this.endSide==other.endSide;}},{key:"range",value:function range(from){var to=arguments.length>1&&arguments[1]!==undefined?arguments[1]:from;if(this.isReplace&&(from>to||from==to&&this.startSide>0&&this.endSide<0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&to!=from)throw new RangeError("Widget decorations can only have zero-length ranges");return _get(_getPrototypeOf(PointDecoration.prototype),"range",this).call(this,from,to);}}]);return PointDecoration;}(Decoration);PointDecoration.prototype.point=true;function getInclusive(spec){var block=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var start=spec.inclusiveStart,end=spec.inclusiveEnd;if(start==null)start=spec.inclusive;if(end==null)end=spec.inclusive;return{start:start!==null&&start!==void 0?start:block,end:end!==null&&end!==void 0?end:block};}function widgetsEq(a,b){return a==b||!!(a&&b&&a.compare(b));}function addRange(from,to,ranges){var margin=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;var last=ranges.length-1;if(last>=0&&ranges[last]+margin>from)ranges[last]=Math.max(ranges[last],to);else ranges.push(from,to);}var LineView=/*#__PURE__*/function(_ContentView9){_inherits(LineView,_ContentView9);var _super54=_createSuper(LineView);function LineView(){var _this98;_classCallCheck(this,LineView);_this98=_super54.apply(this,arguments);_this98.children=[];_this98.length=0;_this98.prevAttrs=undefined;_this98.attrs=null;_this98.breakAfter=0;return _this98;}// Consumes source
37603760+_createClass(LineView,[{key:"merge",value:function merge(from,to,source,takeDeco,openStart,openEnd){if(source){if(!(source instanceof LineView))return false;if(!this.dom)source.transferDOM(this);// Reuse source.dom when appropriate
37613761+}if(takeDeco)this.setDeco(source?source.attrs:null);mergeInlineChildren(this,from,to,source?source.children:none$1,openStart,openEnd);return true;}},{key:"split",value:function split(at){var end=new LineView();end.breakAfter=this.breakAfter;if(this.length==0)return end;var _this$childPos2=this.childPos(at),i=_this$childPos2.i,off=_this$childPos2.off;if(off){end.append(this.children[i].slice(off),0);this.children[i].merge(off,this.children[i].length,null,0,0);i++;}for(var j=i;j<this.children.length;j++){end.append(this.children[j],0);}while(i>0&&this.children[i-1].length==0){this.children[i-1].parent=null;i--;}this.children.length=i;this.markDirty();this.length=at;return end;}},{key:"transferDOM",value:function transferDOM(other){if(!this.dom)return;other.setDOM(this.dom);other.prevAttrs=this.prevAttrs===undefined?this.attrs:this.prevAttrs;this.prevAttrs=undefined;this.dom=null;}},{key:"setDeco",value:function setDeco(attrs){if(!attrsEq(this.attrs,attrs)){if(this.dom){this.prevAttrs=this.attrs;this.markDirty();}this.attrs=attrs;}}// Only called when building a line view in ContentBuilder
37623762+},{key:"append",value:function append(child,openStart){joinInlineInto(this,child,openStart);}// Only called when building a line view in ContentBuilder
37633763+},{key:"addLineDeco",value:function addLineDeco(deco){var attrs=deco.spec.attributes,cls=deco.spec["class"];if(attrs)this.attrs=combineAttrs(attrs,this.attrs||{});if(cls)this.attrs=combineAttrs(attrs,{"class":cls});}},{key:"domAtPos",value:function domAtPos(pos){return inlineDOMAtPos(this.dom,this.children,pos);}},{key:"sync",value:function sync(track){var _a;if(!this.dom||this.dirty&4/* Attrs */){this.setDOM(document.createElement("div"));this.dom.className="cm-line";this.prevAttrs=this.attrs?null:undefined;}if(this.prevAttrs!==undefined){_updateAttrs2(this.dom,this.prevAttrs,this.attrs);this.dom.classList.add("cm-line");this.prevAttrs=undefined;}_get(_getPrototypeOf(LineView.prototype),"sync",this).call(this,track);var last=this.dom.lastChild;while(last&&ContentView.get(last)instanceof MarkView){last=last.lastChild;}if(!last||last.nodeName!="BR"&&((_a=ContentView.get(last))===null||_a===void 0?void 0:_a.isEditable)==false&&(!browser.ios||!this.children.some(function(ch){return ch instanceof TextView;}))){var hack=document.createElement("BR");hack.cmIgnore=true;this.dom.appendChild(hack);}}},{key:"measureTextSize",value:function measureTextSize(){if(this.children.length==0||this.length>20)return null;var totalWidth=0;var _iterator212=_createForOfIteratorHelper(this.children),_step212;try{for(_iterator212.s();!(_step212=_iterator212.n()).done;){var child=_step212.value;if(!(child instanceof TextView))return null;var rects=clientRectsFor(child.dom);if(rects.length!=1)return null;totalWidth+=rects[0].width;}}catch(err){_iterator212.e(err);}finally{_iterator212.f();}return{lineHeight:this.dom.getBoundingClientRect().height,charWidth:totalWidth/this.length};}},{key:"coordsAt",value:function coordsAt(pos,side){return coordsInChildren(this,pos,side);}},{key:"match",value:function match(_other){return false;}},{key:"type",get:function get(){return exports.BlockType.Text;}}],[{key:"find",value:function find(docView,pos){for(var _i150=0,off=0;;_i150++){var block=docView.children[_i150],end=off+block.length;if(end>=pos){if(block instanceof LineView)return block;if(block.length)return null;}off=end+block.breakAfter;}}}]);return LineView;}(ContentView);var none$1=[];var BlockWidgetView=/*#__PURE__*/function(_ContentView10){_inherits(BlockWidgetView,_ContentView10);var _super55=_createSuper(BlockWidgetView);function BlockWidgetView(widget,length,type){var _this99;_classCallCheck(this,BlockWidgetView);_this99=_super55.call(this);_this99.widget=widget;_this99.length=length;_this99.type=type;_this99.breakAfter=0;return _this99;}_createClass(BlockWidgetView,[{key:"merge",value:function merge(from,to,source,_takeDeco,openStart,openEnd){if(source&&(!(source instanceof BlockWidgetView)||!this.widget.compare(source.widget)||from>0&&openStart<=0||to<this.length&&openEnd<=0))return false;this.length=from+(source?source.length:0)+(this.length-to);return true;}},{key:"domAtPos",value:function domAtPos(pos){return pos==0?DOMPos.before(this.dom):DOMPos.after(this.dom,pos==this.length);}},{key:"split",value:function split(at){var len=this.length-at;this.length=at;var end=new BlockWidgetView(this.widget,len,this.type);end.breakAfter=this.breakAfter;return end;}},{key:"children",get:function get(){return none$1;}},{key:"sync",value:function sync(){if(!this.dom||!this.widget.updateDOM(this.dom)){this.setDOM(this.widget.toDOM(this.editorView));this.dom.contentEditable="false";}}},{key:"overrideDOMText",get:function get(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):state.Text.empty;}},{key:"domBoundsAround",value:function domBoundsAround(){return null;}},{key:"match",value:function match(other){if(other instanceof BlockWidgetView&&other.type==this.type&&other.widget.constructor==this.widget.constructor){if(!other.widget.eq(this.widget))this.markDirty(true);this.widget=other.widget;this.length=other.length;this.breakAfter=other.breakAfter;return true;}return false;}},{key:"ignoreMutation",value:function ignoreMutation(){return true;}},{key:"ignoreEvent",value:function ignoreEvent(event){return this.widget.ignoreEvent(event);}}]);return BlockWidgetView;}(ContentView);var ContentBuilder=/*#__PURE__*/function(){function ContentBuilder(doc,pos,end){_classCallCheck(this,ContentBuilder);this.doc=doc;this.pos=pos;this.end=end;this.content=[];this.curLine=null;this.breakAtStart=0;this.pendingBuffer=0/* No */;// Set to false directly after a widget that covers the position after it
37643764+this.atCursorPos=true;this.openStart=-1;this.openEnd=-1;this.text="";this.textOff=0;this.cursor=doc.iter();this.skip=pos;}_createClass(ContentBuilder,[{key:"posCovered",value:function posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;var last=this.content[this.content.length-1];return!last.breakAfter&&!(last instanceof BlockWidgetView&&last.type==exports.BlockType.WidgetBefore);}},{key:"getLine",value:function getLine(){if(!this.curLine){this.content.push(this.curLine=new LineView());this.atCursorPos=true;}return this.curLine;}},{key:"flushBuffer",value:function flushBuffer(active){if(this.pendingBuffer){this.curLine.append(wrapMarks(new WidgetBufferView(-1),active),active.length);this.pendingBuffer=0/* No */;}}},{key:"addBlockWidget",value:function addBlockWidget(view){this.flushBuffer([]);this.curLine=null;this.content.push(view);}},{key:"finish",value:function finish(openEnd){if(!openEnd)this.flushBuffer([]);else this.pendingBuffer=0/* No */;if(!this.posCovered())this.getLine();}},{key:"buildText",value:function buildText(length,active,openStart){while(length>0){if(this.textOff==this.text.length){var _this$cursor$next3=this.cursor.next(this.skip),value=_this$cursor$next3.value,lineBreak=_this$cursor$next3.lineBreak,done=_this$cursor$next3.done;this.skip=0;if(done)throw new Error("Ran out of text content when drawing inline views");if(lineBreak){if(!this.posCovered())this.getLine();if(this.content.length)this.content[this.content.length-1].breakAfter=1;else this.breakAtStart=1;this.flushBuffer([]);this.curLine=null;length--;continue;}else{this.text=value;this.textOff=0;}}var take=Math.min(this.text.length-this.textOff,length,512/* Chunk */);this.flushBuffer(active);this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff,this.textOff+take)),active),openStart);this.atCursorPos=true;this.textOff+=take;length-=take;openStart=0;}}},{key:"span",value:function span(from,to,active,openStart){this.buildText(to-from,active,openStart);this.pos=to;if(this.openStart<0)this.openStart=openStart;}},{key:"point",value:function point(from,to,deco,active,openStart){var len=to-from;if(deco instanceof PointDecoration){if(deco.block){var type=deco.type;if(type==exports.BlockType.WidgetAfter&&!this.posCovered())this.getLine();this.addBlockWidget(new BlockWidgetView(deco.widget||new NullWidget("div"),len,type));}else{var view=WidgetView.create(deco.widget||new NullWidget("span"),len,deco.startSide);var cursorBefore=this.atCursorPos&&!view.isEditable&&openStart<=active.length&&(from<to||deco.startSide>0);var cursorAfter=!view.isEditable&&(from<to||deco.startSide<=0);var line=this.getLine();if(this.pendingBuffer==2/* IfCursor */&&!cursorBefore)this.pendingBuffer=0/* No */;this.flushBuffer(active);if(cursorBefore){line.append(wrapMarks(new WidgetBufferView(1),active),openStart);openStart=active.length+Math.max(0,openStart-active.length);}line.append(wrapMarks(view,active),openStart);this.atCursorPos=cursorAfter;this.pendingBuffer=!cursorAfter?0/* No */:from<to?1/* Yes */:2/* IfCursor */;}}else if(this.doc.lineAt(this.pos).from==this.pos){// Line decoration
37653765+this.getLine().addLineDeco(deco);}if(len){// Advance the iterator past the replaced content
37663766+if(this.textOff+len<=this.text.length){this.textOff+=len;}else{this.skip+=len-(this.text.length-this.textOff);this.text="";this.textOff=0;}this.pos=to;}if(this.openStart<0)this.openStart=openStart;}}],[{key:"build",value:function build(text,from,to,decorations){var builder=new ContentBuilder(text,from,to);builder.openEnd=rangeset.RangeSet.spans(decorations,from,to,builder);if(builder.openStart<0)builder.openStart=builder.openEnd;builder.finish(builder.openEnd);return builder;}}]);return ContentBuilder;}();function wrapMarks(view,active){var _iterator213=_createForOfIteratorHelper(active),_step213;try{for(_iterator213.s();!(_step213=_iterator213.n()).done;){var mark=_step213.value;view=new MarkView(mark,[view],view.length);}}catch(err){_iterator213.e(err);}finally{_iterator213.f();}return view;}var NullWidget=/*#__PURE__*/function(_WidgetType8){_inherits(NullWidget,_WidgetType8);var _super56=_createSuper(NullWidget);function NullWidget(tag){var _this100;_classCallCheck(this,NullWidget);_this100=_super56.call(this);_this100.tag=tag;return _this100;}_createClass(NullWidget,[{key:"eq",value:function eq(other){return other.tag==this.tag;}},{key:"toDOM",value:function toDOM(){return document.createElement(this.tag);}},{key:"updateDOM",value:function updateDOM(elt){return elt.nodeName.toLowerCase()==this.tag;}}]);return NullWidget;}(WidgetType);var none=[];var clickAddsSelectionRange=state.Facet.define();var dragMovesSelection$1=state.Facet.define();var mouseSelectionStyle=state.Facet.define();var exceptionSink=state.Facet.define();var updateListener=state.Facet.define();var inputHandler=state.Facet.define();var scrollTo=state.StateEffect.define({map:function map(range,changes){return range.map(changes);}});var centerOn=state.StateEffect.define({map:function map(range,changes){return range.map(changes);}});/**
37673767+Log or report an unhandled exception in client code. Should
37683768+probably only be used by extension code that allows client code to
37693769+provide functions, and calls those functions in a context where an
37703770+exception can't be propagated to calling code in a reasonable way
37713771+(for example when in an event handler).
37723772+37733773+Either calls a handler registered with
37743774+[`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
37753775+`window.onerror`, if defined, or `console.error` (in which case
37763776+it'll pass `context`, when given, as first argument).
37773777+*/function logException(state,exception,context){var handler=state.facet(exceptionSink);if(handler.length)handler[0](exception);else if(window.onerror)window.onerror(String(exception),context,undefined,undefined,exception);else if(context)console.error(context+":",exception);else console.error(exception);}var editable=state.Facet.define({combine:function combine(values){return values.length?values[0]:true;}});/**
37783778+Used to [declare](https://codemirror.net/6/docs/ref/#view.PluginSpec.provide) which
37793779+[fields](https://codemirror.net/6/docs/ref/#view.PluginValue) a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin)
37803780+provides.
37813781+*/var PluginFieldProvider=/*#__PURE__*/_createClass(/**
37823782+ @internal
37833783+ */function PluginFieldProvider(/**
37843784+ @internal
37853785+ */field,/**
37863786+ @internal
37873787+ */get){_classCallCheck(this,PluginFieldProvider);this.field=field;this.get=get;});/**
37883788+Plugin fields are a mechanism for allowing plugins to provide
37893789+values that can be retrieved through the
37903790+[`pluginField`](https://codemirror.net/6/docs/ref/#view.EditorView.pluginField) view method.
37913791+*/var PluginField=/*#__PURE__*/function(){function PluginField(){_classCallCheck(this,PluginField);}_createClass(PluginField,[{key:"from",value:/**
37923792+ Create a [provider](https://codemirror.net/6/docs/ref/#view.PluginFieldProvider) for this field,
37933793+ to use with a plugin's [provide](https://codemirror.net/6/docs/ref/#view.PluginSpec.provide)
37943794+ option.
37953795+ */function from(get){return new PluginFieldProvider(this,get);}/**
37963796+ Define a new plugin field.
37973797+ */}],[{key:"define",value:function define(){return new PluginField();}}]);return PluginField;}();/**
37983798+This field can be used by plugins to provide
37993799+[decorations](https://codemirror.net/6/docs/ref/#view.Decoration).
38003800+38013801+**Note**: For reasons of data flow (plugins are only updated
38023802+after the viewport is computed), decorations produced by plugins
38033803+are _not_ taken into account when predicting the vertical layout
38043804+structure of the editor. Thus, things like large widgets or big
38053805+replacements (i.e. code folding) should be provided through the
38063806+state-level [`decorations` facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations),
38073807+not this plugin field. Specifically, replacing decorations that
38083808+cross line boundaries will break if provided through a plugin.
38093809+*/PluginField.decorations=PluginField.define();/**
38103810+Used to provide ranges that should be treated as atoms as far as
38113811+cursor motion is concerned. This causes methods like
38123812+[`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
38133813+[`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
38143814+commands built on top of them) to skip across such regions when
38153815+a selection endpoint would enter them. This does _not_ prevent
38163816+direct programmatic [selection
38173817+updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
38183818+regions.
38193819+*/PluginField.atomicRanges=PluginField.define();/**
38203820+Plugins can provide additional scroll margins (space around the
38213821+sides of the scrolling element that should be considered
38223822+invisible) through this field. This can be useful when the
38233823+plugin introduces elements that cover part of that element (for
38243824+example a horizontally fixed gutter).
38253825+*/PluginField.scrollMargins=PluginField.define();var nextPluginID=0;var viewPlugin=state.Facet.define();/**
38263826+View plugins associate stateful values with a view. They can
38273827+influence the way the content is drawn, and are notified of things
38283828+that happen in the view.
38293829+*/var ViewPlugin=/*#__PURE__*/function(){function ViewPlugin(/**
38303830+ @internal
38313831+ */id,/**
38323832+ @internal
38333833+ */create,/**
38343834+ @internal
38353835+ */fields){_classCallCheck(this,ViewPlugin);this.id=id;this.create=create;this.fields=fields;this.extension=viewPlugin.of(this);}/**
38363836+ Define a plugin from a constructor function that creates the
38373837+ plugin's value, given an editor view.
38383838+ */_createClass(ViewPlugin,null,[{key:"define",value:function define(create,spec){var _ref73=spec||{},eventHandlers=_ref73.eventHandlers,provide=_ref73.provide,decorations=_ref73.decorations;var fields=[];if(provide){var _iterator214=_createForOfIteratorHelper(Array.isArray(provide)?provide:[provide]),_step214;try{for(_iterator214.s();!(_step214=_iterator214.n()).done;){var provider=_step214.value;fields.push(provider);}}catch(err){_iterator214.e(err);}finally{_iterator214.f();}}if(eventHandlers)fields.push(domEventHandlers.from(function(value){return{plugin:value,handlers:eventHandlers};}));if(decorations)fields.push(PluginField.decorations.from(decorations));return new ViewPlugin(nextPluginID++,create,fields);}/**
38393839+ Create a plugin for a class whose constructor takes a single
38403840+ editor view as argument.
38413841+ */},{key:"fromClass",value:function fromClass(cls,spec){return ViewPlugin.define(function(view){return new cls(view);},spec);}}]);return ViewPlugin;}();var domEventHandlers=PluginField.define();var PluginInstance=/*#__PURE__*/function(){function PluginInstance(spec){_classCallCheck(this,PluginInstance);this.spec=spec;// When starting an update, all plugins have this field set to the
38423842+// update object, indicating they need to be updated. When finished
38433843+// updating, it is set to `false`. Retrieving a plugin that needs to
38443844+// be updated with `view.plugin` forces an eager update.
38453845+this.mustUpdate=null;// This is null when the plugin is initially created, but
38463846+// initialized on the first update.
38473847+this.value=null;}_createClass(PluginInstance,[{key:"takeField",value:function takeField(type,target){var _iterator215=_createForOfIteratorHelper(this.spec.fields),_step215;try{for(_iterator215.s();!(_step215=_iterator215.n()).done;){var _step215$value=_step215.value,field=_step215$value.field,get=_step215$value.get;if(field==type)target.push(get(this.value));}}catch(err){_iterator215.e(err);}finally{_iterator215.f();}}},{key:"update",value:function update(view){if(!this.value){try{this.value=this.spec.create(view);}catch(e){logException(view.state,e,"CodeMirror plugin crashed");return PluginInstance.dummy;}}else if(this.mustUpdate){var update=this.mustUpdate;this.mustUpdate=null;if(!this.value.update)return this;try{this.value.update(update);}catch(e){logException(update.state,e,"CodeMirror plugin crashed");if(this.value.destroy)try{this.value.destroy();}catch(_){}return PluginInstance.dummy;}}return this;}},{key:"destroy",value:function destroy(view){var _a;if((_a=this.value)===null||_a===void 0?void 0:_a.destroy){try{this.value.destroy();}catch(e){logException(view.state,e,"CodeMirror plugin crashed");}}}}]);return PluginInstance;}();PluginInstance.dummy=new PluginInstance(ViewPlugin.define(function(){return{};}));var editorAttributes=state.Facet.define({combine:function combine(values){return values.reduce(function(a,b){return combineAttrs(b,a);},{});}});var contentAttributes=state.Facet.define({combine:function combine(values){return values.reduce(function(a,b){return combineAttrs(b,a);},{});}});// Provide decorations
38483848+var decorations=state.Facet.define();var styleModule=state.Facet.define();var ChangedRange=/*#__PURE__*/function(){function ChangedRange(fromA,toA,fromB,toB){_classCallCheck(this,ChangedRange);this.fromA=fromA;this.toA=toA;this.fromB=fromB;this.toB=toB;}_createClass(ChangedRange,[{key:"join",value:function join(other){return new ChangedRange(Math.min(this.fromA,other.fromA),Math.max(this.toA,other.toA),Math.min(this.fromB,other.fromB),Math.max(this.toB,other.toB));}},{key:"addToSet",value:function addToSet(set){var i=set.length,me=this;for(;i>0;i--){var range=set[i-1];if(range.fromA>me.toA)continue;if(range.toA<me.fromA)break;me=me.join(range);set.splice(i-1,1);}set.splice(i,0,me);return set;}}],[{key:"extendWithRanges",value:function extendWithRanges(diff,ranges){if(ranges.length==0)return diff;var result=[];for(var dI=0,rI=0,posA=0,posB=0;;dI++){var next=dI==diff.length?null:diff[dI],off=posA-posB;var end=next?next.fromB:1e9;while(rI<ranges.length&&ranges[rI]<end){var from=ranges[rI],to=ranges[rI+1];var fromB=Math.max(posB,from),toB=Math.min(end,to);if(fromB<=toB)new ChangedRange(fromB+off,toB+off,fromB,toB).addToSet(result);if(to>end)break;else rI+=2;}if(!next)return result;new ChangedRange(next.fromA,next.toA,next.fromB,next.toB).addToSet(result);posA=next.toA;posB=next.toB;}}}]);return ChangedRange;}();/**
38493849+View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
38503850+class, which describe what happened, whenever the view is updated.
38513851+*/var ViewUpdate=/*#__PURE__*/function(){/**
38523852+ @internal
38533853+ */function ViewUpdate(/**
38543854+ The editor view that the update is associated with.
38553855+ */view,/**
38563856+ The new editor state.
38573857+ */state$1){var transactions=arguments.length>2&&arguments[2]!==undefined?arguments[2]:none;_classCallCheck(this,ViewUpdate);this.view=view;this.state=state$1;this.transactions=transactions;/**
38583858+ @internal
38593859+ */this.flags=0;this.startState=view.state;this.changes=state.ChangeSet.empty(this.startState.doc.length);var _iterator216=_createForOfIteratorHelper(transactions),_step216;try{for(_iterator216.s();!(_step216=_iterator216.n()).done;){var tr=_step216.value;this.changes=this.changes.compose(tr.changes);}}catch(err){_iterator216.e(err);}finally{_iterator216.f();}var changedRanges=[];this.changes.iterChangedRanges(function(fromA,toA,fromB,toB){return changedRanges.push(new ChangedRange(fromA,toA,fromB,toB));});this.changedRanges=changedRanges;var focus=view.hasFocus;if(focus!=view.inputState.notifiedFocused){view.inputState.notifiedFocused=focus;this.flags|=1/* Focus */;}if(this.docChanged)this.flags|=2/* Height */;}/**
38603860+ Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
38613861+ [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
38623862+ update.
38633863+ */_createClass(ViewUpdate,[{key:"viewportChanged",get:function get(){return(this.flags&4/* Viewport */)>0;}/**
38643864+ Indicates whether the line height in the editor changed in this update.
38653865+ */},{key:"heightChanged",get:function get(){return(this.flags&2/* Height */)>0;}/**
38663866+ Returns true when the document changed or the size of the editor
38673867+ or the lines or characters within it has changed.
38683868+ */},{key:"geometryChanged",get:function get(){return this.docChanged||(this.flags&(8/* Geometry */|2/* Height */))>0;}/**
38693869+ True when this update indicates a focus change.
38703870+ */},{key:"focusChanged",get:function get(){return(this.flags&1/* Focus */)>0;}/**
38713871+ Whether the document changed in this update.
38723872+ */},{key:"docChanged",get:function get(){return this.transactions.some(function(tr){return tr.docChanged;});}/**
38733873+ Whether the selection was explicitly set in this update.
38743874+ */},{key:"selectionSet",get:function get(){return this.transactions.some(function(tr){return tr.selection;});}/**
38753875+ @internal
38763876+ */},{key:"empty",get:function get(){return this.flags==0&&this.transactions.length==0;}}]);return ViewUpdate;}();var DocView=/*#__PURE__*/function(_ContentView11){_inherits(DocView,_ContentView11);var _super57=_createSuper(DocView);function DocView(view){var _this101;_classCallCheck(this,DocView);_this101=_super57.call(this);_this101.view=view;_this101.compositionDeco=Decoration.none;_this101.decorations=[];// Track a minimum width for the editor. When measuring sizes in
38773877+// checkLayout, this is updated to point at the width of a given
38783878+// element and its extent in the document. When a change happens in
38793879+// that range, these are reset. That way, once we've seen a
38803880+// line/element of a given length, we keep the editor wide enough to
38813881+// fit at least that element, until it is changed, at which point we
38823882+// forget it again.
38833883+_this101.minWidth=0;_this101.minWidthFrom=0;_this101.minWidthTo=0;// Track whether the DOM selection was set in a lossy way, so that
38843884+// we don't mess it up when reading it back it
38853885+_this101.impreciseAnchor=null;_this101.impreciseHead=null;_this101.setDOM(view.contentDOM);_this101.children=[new LineView()];_this101.children[0].setParent(_assertThisInitialized(_this101));_this101.updateInner([new ChangedRange(0,0,0,view.state.doc.length)],_this101.updateDeco(),0);return _this101;}_createClass(DocView,[{key:"root",get:function get(){return this.view.root;}},{key:"editorView",get:function get(){return this.view;}},{key:"length",get:function get(){return this.view.state.doc.length;}// Update the document view to a given state. scrollIntoView can be
38863886+// used as a hint to compute a new viewport that includes that
38873887+// position, if we know the editor is going to scroll that position
38883888+// into view.
38893889+},{key:"update",value:function update(_update27){var _this102=this;var changedRanges=_update27.changedRanges;if(this.minWidth>0&&changedRanges.length){if(!changedRanges.every(function(_ref74){var fromA=_ref74.fromA,toA=_ref74.toA;return toA<_this102.minWidthFrom||fromA>_this102.minWidthTo;})){this.minWidth=0;}else{this.minWidthFrom=_update27.changes.mapPos(this.minWidthFrom,1);this.minWidthTo=_update27.changes.mapPos(this.minWidthTo,1);}}if(this.view.inputState.composing<0)this.compositionDeco=Decoration.none;else if(_update27.transactions.length)this.compositionDeco=computeCompositionDeco(this.view,_update27.changes);// When the DOM nodes around the selection are moved to another
38903890+// parent, Chrome sometimes reports a different selection through
38913891+// getSelection than the one that it actually shows to the user.
38923892+// This forces a selection update when lines are joined to work
38933893+// around that. Issue #54
38943894+var forceSelection=(browser.ie||browser.chrome)&&!this.compositionDeco.size&&_update27&&_update27.state.doc.lines!=_update27.startState.doc.lines;var prevDeco=this.decorations,deco=this.updateDeco();var decoDiff=findChangedDeco(prevDeco,deco,_update27.changes);changedRanges=ChangedRange.extendWithRanges(changedRanges,decoDiff);var pointerSel=_update27.transactions.some(function(tr){return tr.isUserEvent("select.pointer");});if(this.dirty==0/* Not */&&changedRanges.length==0&&!(_update27.flags&4/* Viewport */)&&_update27.state.selection.main.from>=this.view.viewport.from&&_update27.state.selection.main.to<=this.view.viewport.to){this.updateSelection(forceSelection,pointerSel);return false;}else{this.updateInner(changedRanges,deco,_update27.startState.doc.length,forceSelection,pointerSel);return true;}}},{key:"reset",value:function reset(sel){var _this103=this;if(this.dirty){this.view.observer.ignore(function(){return _this103.view.docView.sync();});this.dirty=0/* Not */;}if(sel)this.updateSelection();}// Used both by update and checkLayout do perform the actual DOM
38953895+// update
38963896+},{key:"updateInner",value:function updateInner(changes,deco,oldLength){var _this104=this;var forceSelection=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var pointerSel=arguments.length>4&&arguments[4]!==undefined?arguments[4]:false;this.updateChildren(changes,deco,oldLength);var observer=this.view.observer;observer.ignore(function(){// Lock the height during redrawing, since Chrome sometimes
38973897+// messes with the scroll position during DOM mutation (though
38983898+// no relayout is triggered and I cannot imagine how it can
38993899+// recompute the scroll position without a layout)
39003900+_this104.dom.style.height=_this104.view.viewState.domHeight+"px";_this104.dom.style.minWidth=_this104.minWidth?_this104.minWidth+"px":"";// Chrome will sometimes, when DOM mutations occur directly
39013901+// around the selection, get confused and report a different
39023902+// selection from the one it displays (issue #218). This tries
39033903+// to detect that situation.
39043904+var track=browser.chrome||browser.ios?{node:observer.selectionRange.focusNode,written:false}:undefined;_this104.sync(track);_this104.dirty=0/* Not */;if(track&&(track.written||observer.selectionRange.focusNode!=track.node))forceSelection=true;_this104.updateSelection(forceSelection,pointerSel);_this104.dom.style.height="";});var gaps=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length){var _iterator217=_createForOfIteratorHelper(this.children),_step217;try{for(_iterator217.s();!(_step217=_iterator217.n()).done;){var child=_step217.value;if(child instanceof BlockWidgetView&&child.widget instanceof BlockGapWidget)gaps.push(child.dom);}}catch(err){_iterator217.e(err);}finally{_iterator217.f();}}observer.updateGaps(gaps);}},{key:"updateChildren",value:function updateChildren(changes,deco,oldLength){var cursor=this.childCursor(oldLength);for(var _i151=changes.length-1;;_i151--){var next=_i151>=0?changes[_i151]:null;if(!next)break;var fromA=next.fromA,toA=next.toA,fromB=next.fromB,toB=next.toB;var _ContentBuilder$build2=ContentBuilder.build(this.view.state.doc,fromB,toB,deco),content=_ContentBuilder$build2.content,breakAtStart=_ContentBuilder$build2.breakAtStart,openStart=_ContentBuilder$build2.openStart,openEnd=_ContentBuilder$build2.openEnd;var _cursor$findPos3=cursor.findPos(toA,1),toI=_cursor$findPos3.i,toOff=_cursor$findPos3.off;var _cursor$findPos4=cursor.findPos(fromA,-1),fromI=_cursor$findPos4.i,fromOff=_cursor$findPos4.off;this.replaceRange(fromI,fromOff,toI,toOff,content,breakAtStart,openStart,openEnd);}}},{key:"replaceRange",value:function replaceRange(fromI,fromOff,toI,toOff,content,breakAtStart,openStart,openEnd){var before=this.children[fromI],last=content.length?content[content.length-1]:null;var breakAtEnd=last?last.breakAfter:breakAtStart;// Change within a single line
39053905+if(fromI==toI&&!breakAtStart&&!breakAtEnd&&content.length<2&&before.merge(fromOff,toOff,content.length?last:null,fromOff==0,openStart,openEnd))return;var after=this.children[toI];// Make sure the end of the line after the update is preserved in `after`
39063906+if(toOff<after.length){// If we're splitting a line, separate part of the start line to
39073907+// avoid that being mangled when updating the start line.
39083908+if(fromI==toI){after=after.split(toOff);toOff=0;}// If the element after the replacement should be merged with
39093909+// the last replacing element, update `content`
39103910+if(!breakAtEnd&&last&&after.merge(0,toOff,last,true,0,openEnd)){content[content.length-1]=after;}else{// Remove the start of the after element, if necessary, and
39113911+// add it to `content`.
39123912+if(toOff)after.merge(0,toOff,null,false,0,openEnd);content.push(after);}}else if(after.breakAfter){// The element at `toI` is entirely covered by this range.
39133913+// Preserve its line break, if any.
39143914+if(last)last.breakAfter=1;else breakAtStart=1;}// Since we've handled the next element from the current elements
39153915+// now, make sure `toI` points after that.
39163916+toI++;before.breakAfter=breakAtStart;if(fromOff>0){if(!breakAtStart&&content.length&&before.merge(fromOff,before.length,content[0],false,openStart,0)){before.breakAfter=content.shift().breakAfter;}else if(fromOff<before.length||before.children.length&&before.children[before.children.length-1].length==0){before.merge(fromOff,before.length,null,false,openStart,0);}fromI++;}// Try to merge widgets on the boundaries of the replacement
39173917+while(fromI<toI&&content.length){if(this.children[toI-1].match(content[content.length-1]))toI--,content.pop();else if(this.children[fromI].match(content[0]))fromI++,content.shift();else break;}if(fromI<toI||content.length)this.replaceChildren(fromI,toI,content);}// Sync the DOM selection to this.state.selection
39183918+},{key:"updateSelection",value:function updateSelection(){var _this105=this;var force=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var fromPointer=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!(fromPointer||this.mayControlSelection())||browser.ios&&this.view.inputState.rapidCompositionStart)return;var main=this.view.state.selection.main;// FIXME need to handle the case where the selection falls inside a block range
39193919+var anchor=this.domAtPos(main.anchor);var head=main.empty?anchor:this.domAtPos(main.head);// Always reset on Firefox when next to an uneditable node to
39203920+// avoid invisible cursor bugs (#111)
39213921+if(browser.gecko&&main.empty&&betweenUneditable(anchor)){var dummy=document.createTextNode("");this.view.observer.ignore(function(){return anchor.node.insertBefore(dummy,anchor.node.childNodes[anchor.offset]||null);});anchor=head=new DOMPos(dummy,0);force=true;}var domSel=this.view.observer.selectionRange;// If the selection is already here, or in an equivalent position, don't touch it
39223922+if(force||!domSel.focusNode||!isEquivalentPosition(anchor.node,anchor.offset,domSel.anchorNode,domSel.anchorOffset)||!isEquivalentPosition(head.node,head.offset,domSel.focusNode,domSel.focusOffset)){this.view.observer.ignore(function(){// Chrome Android will hide the virtual keyboard when tapping
39233923+// inside an uneditable node, and not bring it back when we
39243924+// move the cursor to its proper position. This tries to
39253925+// restore the keyboard by cycling focus.
39263926+if(browser.android&&browser.chrome&&_this105.dom.contains(domSel.focusNode)&&inUneditable(domSel.focusNode,_this105.dom)){_this105.dom.blur();_this105.dom.focus({preventScroll:true});}var rawSel=getSelection(_this105.root);if(main.empty){// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
39273927+if(browser.gecko){var nextTo=nextToUneditable(anchor.node,anchor.offset);if(nextTo&&nextTo!=(1/* Before */|2/* After */)){var _text3=nearbyTextNode(anchor.node,anchor.offset,nextTo==1/* Before */?1:-1);if(_text3)anchor=new DOMPos(_text3,nextTo==1/* Before */?0:_text3.nodeValue.length);}}rawSel.collapse(anchor.node,anchor.offset);if(main.bidiLevel!=null&&domSel.cursorBidiLevel!=null)domSel.cursorBidiLevel=main.bidiLevel;}else if(rawSel.extend){// Selection.extend can be used to create an 'inverted' selection
39283928+// (one where the focus is before the anchor), but not all
39293929+// browsers support it yet.
39303930+rawSel.collapse(anchor.node,anchor.offset);rawSel.extend(head.node,head.offset);}else{// Primitive (IE) way
39313931+var range=document.createRange();if(main.anchor>main.head){var _ref75=[head,anchor];anchor=_ref75[0];head=_ref75[1];}range.setEnd(head.node,head.offset);range.setStart(anchor.node,anchor.offset);rawSel.removeAllRanges();rawSel.addRange(range);}});this.view.observer.setSelectionRange(anchor,head);}this.impreciseAnchor=anchor.precise?null:new DOMPos(domSel.anchorNode,domSel.anchorOffset);this.impreciseHead=head.precise?null:new DOMPos(domSel.focusNode,domSel.focusOffset);}},{key:"enforceCursorAssoc",value:function enforceCursorAssoc(){if(this.view.composing)return;var cursor=this.view.state.selection.main;var sel=getSelection(this.root);if(!cursor.empty||!cursor.assoc||!sel.modify)return;var line=LineView.find(this,cursor.head);if(!line)return;var lineStart=line.posAtStart;if(cursor.head==lineStart||cursor.head==lineStart+line.length)return;var before=this.coordsAt(cursor.head,-1),after=this.coordsAt(cursor.head,1);if(!before||!after||before.bottom>after.top)return;var dom=this.domAtPos(cursor.head+cursor.assoc);sel.collapse(dom.node,dom.offset);sel.modify("move",cursor.assoc<0?"forward":"backward","lineboundary");}},{key:"mayControlSelection",value:function mayControlSelection(){return this.view.state.facet(editable)?this.root.activeElement==this.dom:hasSelection(this.dom,this.view.observer.selectionRange);}},{key:"nearest",value:function nearest(dom){for(var cur=dom;cur;){var domView=ContentView.get(cur);if(domView&&domView.rootView==this)return domView;cur=cur.parentNode;}return null;}},{key:"posFromDOM",value:function posFromDOM(node,offset){var view=this.nearest(node);if(!view)throw new RangeError("Trying to find position for a DOM position outside of the document");return view.localPosFromDOM(node,offset)+view.posAtStart;}},{key:"domAtPos",value:function domAtPos(pos){var _this$childCursor$fin2=this.childCursor().findPos(pos,-1),i=_this$childCursor$fin2.i,off=_this$childCursor$fin2.off;for(;i<this.children.length-1;){var child=this.children[i];if(off<child.length||child instanceof LineView)break;i++;off=0;}return this.children[i].domAtPos(off);}},{key:"coordsAt",value:function coordsAt(pos,side){for(var off=this.length,_i152=this.children.length-1;;_i152--){var child=this.children[_i152],start=off-child.breakAfter-child.length;if(pos>start||pos==start&&child.type!=exports.BlockType.WidgetBefore&&child.type!=exports.BlockType.WidgetAfter&&(!_i152||side==2||this.children[_i152-1].breakAfter||this.children[_i152-1].type==exports.BlockType.WidgetBefore&&side>-2))return child.coordsAt(pos-start,side);off=start;}}},{key:"measureVisibleLineHeights",value:function measureVisibleLineHeights(){var result=[],_this$view$viewState$2=this.view.viewState.viewport,from=_this$view$viewState$2.from,to=_this$view$viewState$2.to;var minWidth=Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1;for(var pos=0,_i153=0;_i153<this.children.length;_i153++){var child=this.children[_i153],end=pos+child.length;if(end>to)break;if(pos>=from){result.push(child.dom.getBoundingClientRect().height);var width=child.dom.scrollWidth;if(width>minWidth){this.minWidth=minWidth=width;this.minWidthFrom=pos;this.minWidthTo=end;}}pos=end+child.breakAfter;}return result;}},{key:"measureTextSize",value:function measureTextSize(){var _this106=this;var _iterator218=_createForOfIteratorHelper(this.children),_step218;try{for(_iterator218.s();!(_step218=_iterator218.n()).done;){var child=_step218.value;if(child instanceof LineView){var measure=child.measureTextSize();if(measure)return measure;}}// If no workable line exists, force a layout of a measurable element
39323932+}catch(err){_iterator218.e(err);}finally{_iterator218.f();}var dummy=document.createElement("div"),lineHeight,charWidth;dummy.className="cm-line";dummy.textContent="abc def ghi jkl mno pqr stu";this.view.observer.ignore(function(){_this106.dom.appendChild(dummy);var rect=clientRectsFor(dummy.firstChild)[0];lineHeight=dummy.getBoundingClientRect().height;charWidth=rect?rect.width/27:7;dummy.remove();});return{lineHeight:lineHeight,charWidth:charWidth};}},{key:"childCursor",value:function childCursor(){var pos=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.length;// Move back to start of last element when possible, so that
39333933+// `ChildCursor.findPos` doesn't have to deal with the edge case
39343934+// of being after the last element.
39353935+var i=this.children.length;if(i)pos-=this.children[--i].length;return new ChildCursor(this.children,pos,i);}},{key:"computeBlockGapDeco",value:function computeBlockGapDeco(){var deco=[],vs=this.view.viewState;for(var pos=0,_i154=0;;_i154++){var next=_i154==vs.viewports.length?null:vs.viewports[_i154];var end=next?next.from-1:this.length;if(end>pos){var height=vs.lineAt(end,0).bottom-vs.lineAt(pos,0).top;deco.push(Decoration.replace({widget:new BlockGapWidget(height),block:true,inclusive:true}).range(pos,end));}if(!next)break;pos=next.to+1;}return Decoration.set(deco);}},{key:"updateDeco",value:function updateDeco(){return this.decorations=[].concat(_toConsumableArray(this.view.pluginField(PluginField.decorations)),_toConsumableArray(this.view.state.facet(decorations)),[this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]);}},{key:"scrollIntoView",value:function scrollIntoView(_ref76){var range=_ref76.range,center=_ref76.center;var rect=this.coordsAt(range.head,range.empty?range.assoc:range.head>range.anchor?-1:1),other;if(!rect)return;if(!range.empty&&(other=this.coordsAt(range.anchor,range.anchor>range.head?-1:1)))rect={left:Math.min(rect.left,other.left),top:Math.min(rect.top,other.top),right:Math.max(rect.right,other.right),bottom:Math.max(rect.bottom,other.bottom)};var mLeft=0,mRight=0,mTop=0,mBottom=0;var _iterator219=_createForOfIteratorHelper(this.view.pluginField(PluginField.scrollMargins)),_step219;try{for(_iterator219.s();!(_step219=_iterator219.n()).done;){var margins=_step219.value;if(margins){var left=margins.left,right=margins.right,top=margins.top,bottom=margins.bottom;if(left!=null)mLeft=Math.max(mLeft,left);if(right!=null)mRight=Math.max(mRight,right);if(top!=null)mTop=Math.max(mTop,top);if(bottom!=null)mBottom=Math.max(mBottom,bottom);}}}catch(err){_iterator219.e(err);}finally{_iterator219.f();}scrollRectIntoView(this.view.scrollDOM,{left:rect.left-mLeft,top:rect.top-mTop,right:rect.right+mRight,bottom:rect.bottom+mBottom},range.head<range.anchor?-1:1,center);}}]);return DocView;}(ContentView);function betweenUneditable(pos){return pos.node.nodeType==1&&pos.node.firstChild&&(pos.offset==0||pos.node.childNodes[pos.offset-1].contentEditable=="false")&&(pos.offset==pos.node.childNodes.length||pos.node.childNodes[pos.offset].contentEditable=="false");}var BlockGapWidget=/*#__PURE__*/function(_WidgetType9){_inherits(BlockGapWidget,_WidgetType9);var _super58=_createSuper(BlockGapWidget);function BlockGapWidget(height){var _this107;_classCallCheck(this,BlockGapWidget);_this107=_super58.call(this);_this107.height=height;return _this107;}_createClass(BlockGapWidget,[{key:"toDOM",value:function toDOM(){var elt=document.createElement("div");this.updateDOM(elt);return elt;}},{key:"eq",value:function eq(other){return other.height==this.height;}},{key:"updateDOM",value:function updateDOM(elt){elt.style.height=this.height+"px";return true;}},{key:"estimatedHeight",get:function get(){return this.height;}}]);return BlockGapWidget;}(WidgetType);function computeCompositionDeco(view,changes){var sel=view.observer.selectionRange;var textNode=sel.focusNode&&nearbyTextNode(sel.focusNode,sel.focusOffset,0);if(!textNode)return Decoration.none;var cView=view.docView.nearest(textNode);var from,to,topNode=textNode;if(cView instanceof InlineView){while(cView.parent instanceof InlineView){cView=cView.parent;}from=cView.posAtStart;to=from+cView.length;topNode=cView.dom;}else if(cView instanceof LineView){while(topNode.parentNode!=cView.dom){topNode=topNode.parentNode;}var prev=topNode.previousSibling;while(prev&&!ContentView.get(prev)){prev=prev.previousSibling;}from=to=prev?ContentView.get(prev).posAtEnd:cView.posAtStart;}else{return Decoration.none;}var newFrom=changes.mapPos(from,1),newTo=Math.max(newFrom,changes.mapPos(to,-1));var text=textNode.nodeValue,state=view.state;if(newTo-newFrom<text.length){if(state.sliceDoc(newFrom,Math.min(state.doc.length,newFrom+text.length))==text)newTo=newFrom+text.length;else if(state.sliceDoc(Math.max(0,newTo-text.length),newTo)==text)newFrom=newTo-text.length;else return Decoration.none;}else if(state.sliceDoc(newFrom,newTo)!=text){return Decoration.none;}return Decoration.set(Decoration.replace({widget:new CompositionWidget(topNode,textNode)}).range(newFrom,newTo));}var CompositionWidget=/*#__PURE__*/function(_WidgetType10){_inherits(CompositionWidget,_WidgetType10);var _super59=_createSuper(CompositionWidget);function CompositionWidget(top,text){var _this108;_classCallCheck(this,CompositionWidget);_this108=_super59.call(this);_this108.top=top;_this108.text=text;return _this108;}_createClass(CompositionWidget,[{key:"eq",value:function eq(other){return this.top==other.top&&this.text==other.text;}},{key:"toDOM",value:function toDOM(){return this.top;}},{key:"ignoreEvent",value:function ignoreEvent(){return false;}},{key:"customView",get:function get(){return CompositionView;}}]);return CompositionWidget;}(WidgetType);function nearbyTextNode(node,offset,side){for(;;){if(node.nodeType==3)return node;if(node.nodeType==1&&offset>0&&side<=0){node=node.childNodes[offset-1];offset=maxOffset(node);}else if(node.nodeType==1&&offset<node.childNodes.length&&side>=0){node=node.childNodes[offset];offset=0;}else{return null;}}}function nextToUneditable(node,offset){if(node.nodeType!=1)return 0;return(offset&&node.childNodes[offset-1].contentEditable=="false"?1/* Before */:0)|(offset<node.childNodes.length&&node.childNodes[offset].contentEditable=="false"?2/* After */:0);}var DecorationComparator$1=/*#__PURE__*/function(){function DecorationComparator$1(){_classCallCheck(this,DecorationComparator$1);this.changes=[];}_createClass(DecorationComparator$1,[{key:"compareRange",value:function compareRange(from,to){addRange(from,to,this.changes);}},{key:"comparePoint",value:function comparePoint(from,to){addRange(from,to,this.changes);}}]);return DecorationComparator$1;}();function findChangedDeco(a,b,diff){var comp=new DecorationComparator$1();rangeset.RangeSet.compare(a,b,diff,comp);return comp.changes;}function inUneditable(node,inside){for(var cur=node;cur&&cur!=inside;cur=cur.assignedSlot||cur.parentNode){if(cur.nodeType==1&&cur.contentEditable=='false'){return true;}}return false;}/**
39363936+Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
39373937+*/exports.Direction=void 0;(function(Direction){// (These are chosen to match the base levels, in bidi algorithm
39383938+// terms, of spans in that direction.)
39393939+/**
39403940+ Left-to-right.
39413941+ */Direction[Direction["LTR"]=0]="LTR";/**
39423942+ Right-to-left.
39433943+ */Direction[Direction["RTL"]=1]="RTL";})(exports.Direction||(exports.Direction={}));var LTR=exports.Direction.LTR,RTL=exports.Direction.RTL;// Decode a string with each type encoded as log2(type)
39443944+function dec(str){var result=[];for(var _i155=0;_i155<str.length;_i155++){result.push(1<<+str[_i155]);}return result;}// Character types for codepoints 0 to 0xf8
39453945+var LowTypes=dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");// Character types for codepoints 0x600 to 0x6f9
39463946+var ArabicTypes=dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");var Brackets=Object.create(null),BracketStack=[];// There's a lot more in
39473947+// https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
39483948+// which are left out to keep code size down.
39493949+for(var _i156=0,_arr4=["()","[]","{}"];_i156<_arr4.length;_i156++){var p=_arr4[_i156];var l=p.charCodeAt(0),r=p.charCodeAt(1);Brackets[l]=r;Brackets[r]=-l;}function charType(ch){return ch<=0xf7?LowTypes[ch]:0x590<=ch&&ch<=0x5f4?2/* R */:0x600<=ch&&ch<=0x6f9?ArabicTypes[ch-0x600]:0x6ee<=ch&&ch<=0x8ac?4/* AL */:0x2000<=ch&&ch<=0x200b?256/* NI */:ch==0x200c?256/* NI */:1/* L */;}var BidiRE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;/**
39503950+Represents a contiguous range of text that has a single direction
39513951+(as in left-to-right or right-to-left).
39523952+*/var BidiSpan=/*#__PURE__*/function(){/**
39533953+ @internal
39543954+ */function BidiSpan(/**
39553955+ The start of the span (relative to the start of the line).
39563956+ */from,/**
39573957+ The end of the span.
39583958+ */to,/**
39593959+ The ["bidi
39603960+ level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
39613961+ of the span (in this context, 0 means
39623962+ left-to-right, 1 means right-to-left, 2 means left-to-right
39633963+ number inside right-to-left text).
39643964+ */level){_classCallCheck(this,BidiSpan);this.from=from;this.to=to;this.level=level;}/**
39653965+ The direction of this span.
39663966+ */_createClass(BidiSpan,[{key:"dir",get:function get(){return this.level%2?RTL:LTR;}/**
39673967+ @internal
39683968+ */},{key:"side",value:function side(end,dir){return this.dir==dir==end?this.to:this.from;}/**
39693969+ @internal
39703970+ */}],[{key:"find",value:function find(order,index,level,assoc){var maybe=-1;for(var _i157=0;_i157<order.length;_i157++){var span=order[_i157];if(span.from<=index&&span.to>=index){if(span.level==level)return _i157;// When multiple spans match, if assoc != 0, take the one that
39713971+// covers that side, otherwise take the one with the minimum
39723972+// level.
39733973+if(maybe<0||(assoc!=0?assoc<0?span.from<index:span.to>index:order[maybe].level>span.level))maybe=_i157;}}if(maybe<0)throw new RangeError("Index out of range");return maybe;}}]);return BidiSpan;}();// Reused array of character types
39743974+var types=[];function computeOrder(line,direction){var len=line.length,outerType=direction==LTR?1/* L */:2/* R */,oppositeType=direction==LTR?2/* R */:1/* L */;if(!line||outerType==1/* L */&&!BidiRE.test(line))return trivialOrder(len);// W1. Examine each non-spacing mark (NSM) in the level run, and
39753975+// change the type of the NSM to the type of the previous
39763976+// character. If the NSM is at the start of the level run, it will
39773977+// get the type of sor.
39783978+// W2. Search backwards from each instance of a European number
39793979+// until the first strong type (R, L, AL, or sor) is found. If an
39803980+// AL is found, change the type of the European number to Arabic
39813981+// number.
39823982+// W3. Change all ALs to R.
39833983+// (Left after this: L, R, EN, AN, ET, CS, NI)
39843984+for(var _i158=0,prev=outerType,prevStrong=outerType;_i158<len;_i158++){var type=charType(line.charCodeAt(_i158));if(type==512/* NSM */)type=prev;else if(type==8/* EN */&&prevStrong==4/* AL */)type=16/* AN */;types[_i158]=type==4/* AL */?2/* R */:type;if(type&7/* Strong */)prevStrong=type;prev=type;}// W5. A sequence of European terminators adjacent to European
39853985+// numbers changes to all European numbers.
39863986+// W6. Otherwise, separators and terminators change to Other
39873987+// Neutral.
39883988+// W7. Search backwards from each instance of a European number
39893989+// until the first strong type (R, L, or sor) is found. If an L is
39903990+// found, then change the type of the European number to L.
39913991+// (Left after this: L, R, EN+AN, NI)
39923992+for(var _i159=0,_prev2=outerType,_prevStrong2=outerType;_i159<len;_i159++){var _type5=types[_i159];if(_type5==128/* CS */){if(_i159<len-1&&_prev2==types[_i159+1]&&_prev2&24/* Num */)_type5=types[_i159]=_prev2;else types[_i159]=256/* NI */;}else if(_type5==64/* ET */){var end=_i159+1;while(end<len&&types[end]==64/* ET */){end++;}var replace=_i159&&_prev2==8/* EN */||end<len&&types[end]==8/* EN */?_prevStrong2==1/* L */?1/* L */:8/* EN */:256/* NI */;for(var j=_i159;j<end;j++){types[j]=replace;}_i159=end-1;}else if(_type5==8/* EN */&&_prevStrong2==1/* L */){types[_i159]=1/* L */;}_prev2=_type5;if(_type5&7/* Strong */)_prevStrong2=_type5;}// N0. Process bracket pairs in an isolating run sequence
39933993+// sequentially in the logical order of the text positions of the
39943994+// opening paired brackets using the logic given below. Within this
39953995+// scope, bidirectional types EN and AN are treated as R.
39963996+for(var _i160=0,sI=0,context=0,ch,br,_type6;_i160<len;_i160++){// Keeps [startIndex, type, strongSeen] triples for each open
39973997+// bracket on BracketStack.
39983998+if(br=Brackets[ch=line.charCodeAt(_i160)]){if(br<0){// Closing bracket
39993999+for(var sJ=sI-3;sJ>=0;sJ-=3){if(BracketStack[sJ+1]==-br){var flags=BracketStack[sJ+2];var _type7=flags&2/* EmbedInside */?outerType:!(flags&4/* OppositeInside */)?0:flags&1/* OppositeBefore */?oppositeType:outerType;if(_type7)types[_i160]=types[BracketStack[sJ]]=_type7;sI=sJ;break;}}}else if(BracketStack.length==189/* MaxDepth */){break;}else{BracketStack[sI++]=_i160;BracketStack[sI++]=ch;BracketStack[sI++]=context;}}else if((_type6=types[_i160])==2/* R */||_type6==1/* L */){var embed=_type6==outerType;context=embed?0:1/* OppositeBefore */;for(var _sJ2=sI-3;_sJ2>=0;_sJ2-=3){var cur=BracketStack[_sJ2+2];if(cur&2/* EmbedInside */)break;if(embed){BracketStack[_sJ2+2]|=2/* EmbedInside */;}else{if(cur&4/* OppositeInside */)break;BracketStack[_sJ2+2]|=4/* OppositeInside */;}}}}// N1. A sequence of neutrals takes the direction of the
40004000+// surrounding strong text if the text on both sides has the same
40014001+// direction. European and Arabic numbers act as if they were R in
40024002+// terms of their influence on neutrals. Start-of-level-run (sor)
40034003+// and end-of-level-run (eor) are used at level run boundaries.
40044004+// N2. Any remaining neutrals take the embedding direction.
40054005+// (Left after this: L, R, EN+AN)
40064006+for(var _i161=0;_i161<len;_i161++){if(types[_i161]==256/* NI */){var _end5=_i161+1;while(_end5<len&&types[_end5]==256/* NI */){_end5++;}var beforeL=(_i161?types[_i161-1]:outerType)==1/* L */;var afterL=(_end5<len?types[_end5]:outerType)==1/* L */;var _replace2=beforeL==afterL?beforeL?1/* L */:2/* R */:outerType;for(var _j3=_i161;_j3<_end5;_j3++){types[_j3]=_replace2;}_i161=_end5-1;}}// Here we depart from the documented algorithm, in order to avoid
40074007+// building up an actual levels array. Since there are only three
40084008+// levels (0, 1, 2) in an implementation that doesn't take
40094009+// explicit embedding into account, we can build up the order on
40104010+// the fly, without following the level-based algorithm.
40114011+var order=[];if(outerType==1/* L */){for(var _i162=0;_i162<len;){var start=_i162,rtl=types[_i162++]!=1/* L */;while(_i162<len&&rtl==(types[_i162]!=1/* L */)){_i162++;}if(rtl){for(var _j4=_i162;_j4>start;){var _end6=_j4,_l3=types[--_j4]!=2/* R */;while(_j4>start&&_l3==(types[_j4-1]!=2/* R */)){_j4--;}order.push(new BidiSpan(_j4,_end6,_l3?2:1));}}else{order.push(new BidiSpan(start,_i162,0));}}}else{for(var _i163=0;_i163<len;){var _start6=_i163,_rtl2=types[_i163++]==2/* R */;while(_i163<len&&_rtl2==(types[_i163]==2/* R */)){_i163++;}order.push(new BidiSpan(_start6,_i163,_rtl2?1:2));}}return order;}function trivialOrder(length){return[new BidiSpan(0,length,0)];}var movedOver="";function moveVisually(line,order,dir,start,forward){var _a;var startIndex=start.head-line.from,spanI=-1;if(startIndex==0){if(!forward||!line.length)return null;if(order[0].level!=dir){startIndex=order[0].side(false,dir);spanI=0;}}else if(startIndex==line.length){if(forward)return null;var last=order[order.length-1];if(last.level!=dir){startIndex=last.side(true,dir);spanI=order.length-1;}}if(spanI<0)spanI=BidiSpan.find(order,startIndex,(_a=start.bidiLevel)!==null&&_a!==void 0?_a:-1,start.assoc);var span=order[spanI];// End of span. (But not end of line--that was checked for above.)
40124012+if(startIndex==span.side(forward,dir)){span=order[spanI+=forward?1:-1];startIndex=span.side(!forward,dir);}var indexForward=forward==(span.dir==dir);var nextIndex=text.findClusterBreak(line.text,startIndex,indexForward);movedOver=line.text.slice(Math.min(startIndex,nextIndex),Math.max(startIndex,nextIndex));if(nextIndex!=span.side(forward,dir))return state.EditorSelection.cursor(nextIndex+line.from,indexForward?-1:1,span.level);var nextSpan=spanI==(forward?order.length-1:0)?null:order[spanI+(forward?1:-1)];if(!nextSpan&&span.level!=dir)return state.EditorSelection.cursor(forward?line.to:line.from,forward?-1:1,dir);if(nextSpan&&nextSpan.level<span.level)return state.EditorSelection.cursor(nextSpan.side(!forward,dir)+line.from,forward?1:-1,nextSpan.level);return state.EditorSelection.cursor(nextIndex+line.from,forward?-1:1,span.level);}function groupAt(state$1,pos){var bias=arguments.length>2&&arguments[2]!==undefined?arguments[2]:1;var categorize=state$1.charCategorizer(pos);var line=state$1.doc.lineAt(pos),linePos=pos-line.from;if(line.length==0)return state.EditorSelection.cursor(pos);if(linePos==0)bias=1;else if(linePos==line.length)bias=-1;var from=linePos,to=linePos;if(bias<0)from=text.findClusterBreak(line.text,linePos,false);else to=text.findClusterBreak(line.text,linePos);var cat=categorize(line.text.slice(from,to));while(from>0){var prev=text.findClusterBreak(line.text,from,false);if(categorize(line.text.slice(prev,from))!=cat)break;from=prev;}while(to<line.length){var next=text.findClusterBreak(line.text,to);if(categorize(line.text.slice(to,next))!=cat)break;to=next;}return state.EditorSelection.range(from+line.from,to+line.from);}// Search the DOM for the {node, offset} position closest to the given
40134013+// coordinates. Very inefficient and crude, but can usually be avoided
40144014+// by calling caret(Position|Range)FromPoint instead.
40154015+function getdx(x,rect){return rect.left>x?rect.left-x:Math.max(0,x-rect.right);}function getdy(y,rect){return rect.top>y?rect.top-y:Math.max(0,y-rect.bottom);}function yOverlap(a,b){return a.top<b.bottom-1&&a.bottom>b.top+1;}function upTop(rect,top){return top<rect.top?{top:top,left:rect.left,right:rect.right,bottom:rect.bottom}:rect;}function upBot(rect,bottom){return bottom>rect.bottom?{top:rect.top,left:rect.left,right:rect.right,bottom:bottom}:rect;}function domPosAtCoords(parent,x,y){var closest,closestRect,closestX,closestY;var above,below,aboveRect,belowRect;for(var child=parent.firstChild;child;child=child.nextSibling){var rects=clientRectsFor(child);for(var _i164=0;_i164<rects.length;_i164++){var rect=rects[_i164];if(closestRect&&yOverlap(closestRect,rect))rect=upTop(upBot(rect,closestRect.bottom),closestRect.top);var dx=getdx(x,rect),dy=getdy(y,rect);if(dx==0&&dy==0)return child.nodeType==3?domPosInText(child,x,y):domPosAtCoords(child,x,y);if(!closest||closestY>dy||closestY==dy&&closestX>dx){closest=child;closestRect=rect;closestX=dx;closestY=dy;}if(dx==0){if(y>rect.bottom&&(!aboveRect||aboveRect.bottom<rect.bottom)){above=child;aboveRect=rect;}else if(y<rect.top&&(!belowRect||belowRect.top>rect.top)){below=child;belowRect=rect;}}else if(aboveRect&&yOverlap(aboveRect,rect)){aboveRect=upBot(aboveRect,rect.bottom);}else if(belowRect&&yOverlap(belowRect,rect)){belowRect=upTop(belowRect,rect.top);}}}if(aboveRect&&aboveRect.bottom>=y){closest=above;closestRect=aboveRect;}else if(belowRect&&belowRect.top<=y){closest=below;closestRect=belowRect;}if(!closest)return{node:parent,offset:0};var clipX=Math.max(closestRect.left,Math.min(closestRect.right,x));if(closest.nodeType==3)return domPosInText(closest,clipX,y);if(!closestX&&closest.contentEditable=="true")return domPosAtCoords(closest,clipX,y);var offset=Array.prototype.indexOf.call(parent.childNodes,closest)+(x>=(closestRect.left+closestRect.right)/2?1:0);return{node:parent,offset:offset};}function domPosInText(node,x,y){var len=node.nodeValue.length;var closestOffset=-1,closestDY=1e9,generalSide=0;for(var _i165=0;_i165<len;_i165++){var rects=textRange(node,_i165,_i165+1).getClientRects();for(var j=0;j<rects.length;j++){var rect=rects[j];if(rect.top==rect.bottom)continue;if(!generalSide)generalSide=x-rect.left;var dy=(rect.top>y?rect.top-y:y-rect.bottom)-1;if(rect.left-1<=x&&rect.right+1>=x&&dy<closestDY){var right=x>=(rect.left+rect.right)/2,after=right;if(browser.chrome||browser.gecko){// Check for RTL on browsers that support getting client
40164016+// rects for empty ranges.
40174017+var rectBefore=textRange(node,_i165).getBoundingClientRect();if(rectBefore.left==rect.right)after=!right;}if(dy<=0)return{node:node,offset:_i165+(after?1:0)};closestOffset=_i165+(after?1:0);closestDY=dy;}}}return{node:node,offset:closestOffset>-1?closestOffset:generalSide>0?node.nodeValue.length:0};}function _posAtCoords2(view,_ref77,precise){var x=_ref77.x,y=_ref77.y;var bias=arguments.length>3&&arguments[3]!==undefined?arguments[3]:-1;var _a;var content=view.contentDOM.getBoundingClientRect(),block;var halfLine=view.defaultLineHeight/2;for(var bounced=false;;){block=view.blockAtHeight(y,content.top);if(block.top>y||block.bottom<y){bias=block.top>y?-1:1;y=Math.min(block.bottom-halfLine,Math.max(block.top+halfLine,y));if(bounced)return precise?null:0;else bounced=true;}if(block.type==exports.BlockType.Text)break;y=bias>0?block.bottom+halfLine:block.top-halfLine;}var lineStart=block.from;// Clip x to the viewport sides
40184018+x=Math.max(content.left+1,Math.min(content.right-1,x));// If this is outside of the rendered viewport, we can't determine a position
40194019+if(lineStart<view.viewport.from)return view.viewport.from==0?0:posAtCoordsImprecise(view,content,block,x,y);if(lineStart>view.viewport.to)return view.viewport.to==view.state.doc.length?view.state.doc.length:posAtCoordsImprecise(view,content,block,x,y);// Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
40204020+var doc=view.dom.ownerDocument;var element=(view.root.elementFromPoint?view.root:doc).elementFromPoint(x,y);// There's visible editor content under the point, so we can try
40214021+// using caret(Position|Range)FromPoint as a shortcut
40224022+var node,offset=-1;if(element&&view.contentDOM.contains(element)&&((_a=view.docView.nearest(element))===null||_a===void 0?void 0:_a.isEditable)!=false){if(doc.caretPositionFromPoint){var pos=doc.caretPositionFromPoint(x,y);if(pos){node=pos.offsetNode;offset=pos.offset;}}else if(doc.caretRangeFromPoint){var range=doc.caretRangeFromPoint(x,y);if(range){node=range.startContainer;offset=range.startOffset;if(browser.safari&&isSuspiciousCaretResult(node,offset,x))node=undefined;}}}// No luck, do our own (potentially expensive) search
40234023+if(!node||!view.docView.dom.contains(node)){var line=LineView.find(view.docView,lineStart);var _domPosAtCoords2=domPosAtCoords(line.dom,x,y);node=_domPosAtCoords2.node;offset=_domPosAtCoords2.offset;}return view.docView.posFromDOM(node,offset);}function posAtCoordsImprecise(view,contentRect,block,x,y){var into=Math.round((x-contentRect.left)*view.defaultCharacterWidth);if(view.lineWrapping&&block.height>view.defaultLineHeight*1.5){var line=Math.floor((y-block.top)/view.defaultLineHeight);into+=line*view.viewState.heightOracle.lineLength;}var content=view.state.sliceDoc(block.from,block.to);return block.from+text.findColumn(content,into,view.state.tabSize);}// In case of a high line height, Safari's caretRangeFromPoint treats
40244024+// the space between lines as belonging to the last character of the
40254025+// line before. This is used to detect such a result so that it can be
40264026+// ignored (issue #401).
40274027+function isSuspiciousCaretResult(node,offset,x){var len;if(node.nodeType!=3||offset!=(len=node.nodeValue.length))return false;for(var next=node.nextSibling;next;next=next.nextSibling){if(next.nodeType!=1||next.nodeName!="BR")return false;}return textRange(node,len-1,len).getBoundingClientRect().left>x;}function _moveToLineBoundary2(view,start,forward,includeWrap){var line=view.state.doc.lineAt(start.head);var coords=!includeWrap||!view.lineWrapping?null:view.coordsAtPos(start.assoc<0&&start.head>line.from?start.head-1:start.head);if(coords){var editorRect=view.dom.getBoundingClientRect();var pos=view.posAtCoords({x:forward==(view.textDirection==exports.Direction.LTR)?editorRect.right-1:editorRect.left+1,y:(coords.top+coords.bottom)/2});if(pos!=null)return state.EditorSelection.cursor(pos,forward?-1:1);}var lineView=LineView.find(view.docView,start.head);var end=lineView?forward?lineView.posAtEnd:lineView.posAtStart:forward?line.to:line.from;return state.EditorSelection.cursor(end,forward?-1:1);}function _moveByChar2(view,start,forward,by){var line=view.state.doc.lineAt(start.head),spans=view.bidiSpans(line);for(var cur=start,check=null;;){var next=moveVisually(line,spans,view.textDirection,cur,forward),_char4=movedOver;if(!next){if(line.number==(forward?view.state.doc.lines:1))return cur;_char4="\n";line=view.state.doc.line(line.number+(forward?1:-1));spans=view.bidiSpans(line);next=state.EditorSelection.cursor(forward?line.from:line.to);}if(!check){if(!by)return next;check=by(_char4);}else if(!check(_char4)){return cur;}cur=next;}}function byGroup(view,pos,start){var categorize=view.state.charCategorizer(pos);var cat=categorize(start);return function(next){var nextCat=categorize(next);if(cat==state.CharCategory.Space)cat=nextCat;return cat==nextCat;};}function _moveVertically2(view,start,forward,distance){var startPos=start.head,dir=forward?1:-1;if(startPos==(forward?view.state.doc.length:0))return state.EditorSelection.cursor(startPos);var goal=start.goalColumn,startY;var rect=view.contentDOM.getBoundingClientRect();var startCoords=view.coordsAtPos(startPos);if(startCoords){if(goal==null)goal=startCoords.left-rect.left;startY=dir<0?startCoords.top:startCoords.bottom;}else{var line=view.viewState.lineAt(startPos,view.dom.getBoundingClientRect().top);if(goal==null)goal=Math.min(rect.right-rect.left,view.defaultCharacterWidth*(startPos-line.from));startY=dir<0?line.top:line.bottom;}var resolvedGoal=rect.left+goal;var dist=distance!==null&&distance!==void 0?distance:view.defaultLineHeight>>1;for(var extra=0;;extra+=10){var curY=startY+(dist+extra)*dir;var pos=_posAtCoords2(view,{x:resolvedGoal,y:curY},false,dir);if(curY<rect.top||curY>rect.bottom||(dir<0?pos<startPos:pos>startPos))return state.EditorSelection.cursor(pos,undefined,undefined,goal);}}function skipAtoms(view,oldPos,pos){var atoms=view.pluginField(PluginField.atomicRanges);for(;;){var moved=false;var _iterator220=_createForOfIteratorHelper(atoms),_step220;try{for(_iterator220.s();!(_step220=_iterator220.n()).done;){var set=_step220.value;set.between(pos.from-1,pos.from+1,function(from,to,value){if(pos.from>from&&pos.from<to){pos=oldPos.from>pos.from?state.EditorSelection.cursor(from,1):state.EditorSelection.cursor(to,-1);moved=true;}});}}catch(err){_iterator220.e(err);}finally{_iterator220.f();}if(!moved)return pos;}}// This will also be where dragging info and such goes
40284028+var InputState=/*#__PURE__*/function(){function InputState(view){var _this109=this;_classCallCheck(this,InputState);this.lastKeyCode=0;this.lastKeyTime=0;// On Chrome Android, backspace near widgets is just completely
40294029+// broken, and there are no key events, so we need to handle the
40304030+// beforeinput event. Deleting stuff will often create a flurry of
40314031+// events, and interrupting it before it is done just makes
40324032+// subsequent events even more broken, so again, we hold off doing
40334033+// anything until the browser is finished with whatever it is trying
40344034+// to do.
40354035+this.pendingAndroidKey=undefined;// On iOS, some keys need to have their default behavior happen
40364036+// (after which we retroactively handle them and reset the DOM) to
40374037+// avoid messing up the virtual keyboard state.
40384038+this.pendingIOSKey=undefined;this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastEscPress=0;this.lastContextMenu=0;this.scrollHandlers=[];this.registeredEvents=[];this.customHandlers=[];// -1 means not in a composition. Otherwise, this counts the number
40394039+// of changes made during the composition. The count is used to
40404040+// avoid treating the start state of the composition, before any
40414041+// changes have been made, as part of the composition.
40424042+this.composing=-1;// Tracks whether the next change should be marked as starting the
40434043+// composition (null means no composition, true means next is the
40444044+// first, false means first has already been marked for this
40454045+// composition)
40464046+this.compositionFirstChange=null;this.compositionEndedAt=0;this.rapidCompositionStart=false;this.mouseSelection=null;var _loop21=function _loop21(type){var handler=handlers[type];view.contentDOM.addEventListener(type,function(event){if(type=="keydown"&&_this109.keydown(view,event))return;if(!eventBelongsToEditor(view,event)||_this109.ignoreDuringComposition(event))return;if(_this109.mustFlushObserver(event))view.observer.forceFlush();if(_this109.runCustomHandlers(type,view,event))event.preventDefault();else handler(view,event);});_this109.registeredEvents.push(type);};for(var type in handlers){_loop21(type);}this.notifiedFocused=view.hasFocus;this.ensureHandlers(view);// On Safari adding an input event handler somehow prevents an
40474047+// issue where the composition vanishes when you press enter.
40484048+if(browser.safari)view.contentDOM.addEventListener("input",function(){return null;});}_createClass(InputState,[{key:"setSelectionOrigin",value:function setSelectionOrigin(origin){this.lastSelectionOrigin=origin;this.lastSelectionTime=Date.now();}},{key:"ensureHandlers",value:function ensureHandlers(view){var _this110=this;var handlers=this.customHandlers=view.pluginField(domEventHandlers);var _iterator221=_createForOfIteratorHelper(handlers),_step221;try{for(_iterator221.s();!(_step221=_iterator221.n()).done;){var set=_step221.value;var _loop22=function _loop22(type){if(_this110.registeredEvents.indexOf(type)<0&&type!="scroll"){_this110.registeredEvents.push(type);view.contentDOM.addEventListener(type,function(event){if(!eventBelongsToEditor(view,event))return;if(_this110.runCustomHandlers(type,view,event))event.preventDefault();});}};for(var type in set.handlers){_loop22(type);}}}catch(err){_iterator221.e(err);}finally{_iterator221.f();}}},{key:"runCustomHandlers",value:function runCustomHandlers(type,view,event){var _iterator222=_createForOfIteratorHelper(this.customHandlers),_step222;try{for(_iterator222.s();!(_step222=_iterator222.n()).done;){var set=_step222.value;var handler=set.handlers[type],handled=false;if(handler){try{handled=handler.call(set.plugin,event,view);}catch(e){logException(view.state,e);}if(handled||event.defaultPrevented){// Chrome for Android often applies a bunch of nonsensical
40494049+// DOM changes after an enter press, even when
40504050+// preventDefault-ed. This tries to ignore those.
40514051+if(browser.android&&type=="keydown"&&event.keyCode==13)view.observer.flushSoon();return true;}}}}catch(err){_iterator222.e(err);}finally{_iterator222.f();}return false;}},{key:"runScrollHandlers",value:function runScrollHandlers(view,event){var _iterator223=_createForOfIteratorHelper(this.customHandlers),_step223;try{for(_iterator223.s();!(_step223=_iterator223.n()).done;){var set=_step223.value;var handler=set.handlers.scroll;if(handler){try{handler.call(set.plugin,event,view);}catch(e){logException(view.state,e);}}}}catch(err){_iterator223.e(err);}finally{_iterator223.f();}}},{key:"keydown",value:function keydown(view,event){var _this111=this;// Must always run, even if a custom handler handled the event
40524052+this.lastKeyCode=event.keyCode;this.lastKeyTime=Date.now();if(this.screenKeyEvent(view,event))return true;// Prevent the default behavior of Enter on iOS makes the
40534053+// virtual keyboard get stuck in the wrong (lowercase)
40544054+// state. So we let it go through, and then, in
40554055+// applyDOMChange, notify key handlers of it and reset to
40564056+// the state they produce.
40574057+var pending;if(browser.ios&&(pending=PendingKeys.find(function(key){return key.keyCode==event.keyCode;}))&&!(event.ctrlKey||event.altKey||event.metaKey)&&!event.synthetic){this.pendingIOSKey=pending;setTimeout(function(){return _this111.flushIOSKey(view);},250);return true;}return false;}},{key:"flushIOSKey",value:function flushIOSKey(view){var key=this.pendingIOSKey;if(!key)return false;this.pendingIOSKey=undefined;return dispatchKey(view.contentDOM,key.key,key.keyCode);}// This causes the DOM observer to pause for a bit, and sets an
40584058+// animation frame (which seems the most reliable way to detect
40594059+// 'Chrome is done flailing about messing with the DOM') to fire a
40604060+// fake key event and re-sync the view again.
40614061+},{key:"setPendingAndroidKey",value:function setPendingAndroidKey(view,pending){var _this112=this;this.pendingAndroidKey=pending;requestAnimationFrame(function(){var key=_this112.pendingAndroidKey;if(!key)return;_this112.pendingAndroidKey=undefined;view.observer.processRecords();var startState=view.state;dispatchKey(view.contentDOM,key.key,key.keyCode);if(view.state==startState)view.docView.reset(true);});}},{key:"ignoreDuringComposition",value:function ignoreDuringComposition(event){if(!/^key/.test(event.type))return false;if(this.composing>0)return true;// See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
40624062+// On some input method editors (IMEs), the Enter key is used to
40634063+// confirm character selection. On Safari, when Enter is pressed,
40644064+// compositionend and keydown events are sometimes emitted in the
40654065+// wrong order. The key event should still be ignored, even when
40664066+// it happens after the compositionend event.
40674067+if(browser.safari&&Date.now()-this.compositionEndedAt<500){this.compositionEndedAt=0;return true;}return false;}},{key:"screenKeyEvent",value:function screenKeyEvent(view,event){var protectedTab=event.keyCode==9&&Date.now()<this.lastEscPress+2000;if(event.keyCode==27)this.lastEscPress=Date.now();else if(modifierCodes.indexOf(event.keyCode)<0)this.lastEscPress=0;return protectedTab;}},{key:"mustFlushObserver",value:function mustFlushObserver(event){return event.type=="keydown"&&event.keyCode!=229||event.type=="compositionend"&&!browser.ios;}},{key:"startMouseSelection",value:function startMouseSelection(view,event,style){if(this.mouseSelection)this.mouseSelection.destroy();this.mouseSelection=new MouseSelection(this,view,event,style);}},{key:"update",value:function update(_update28){if(this.mouseSelection)this.mouseSelection.update(_update28);if(_update28.transactions.length)this.lastKeyCode=this.lastSelectionTime=0;}},{key:"destroy",value:function destroy(){if(this.mouseSelection)this.mouseSelection.destroy();}}]);return InputState;}();var PendingKeys=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}];// Key codes for modifier keys
40684068+var modifierCodes=[16,17,18,20,91,92,224,225];var MouseSelection=/*#__PURE__*/function(){function MouseSelection(inputState,view,startEvent,style){_classCallCheck(this,MouseSelection);this.inputState=inputState;this.view=view;this.style=style;this.lastEvent=startEvent;var doc=view.contentDOM.ownerDocument;doc.addEventListener("mousemove",this.move=this.move.bind(this));doc.addEventListener("mouseup",this.up=this.up.bind(this));this.extend=startEvent.shiftKey;this.multiple=view.state.facet(state.EditorState.allowMultipleSelections)&&addsSelectionRange(view,startEvent);this.dragMove=dragMovesSelection(view,startEvent);this.dragging=isInPrimarySelection(view,startEvent)?null:false;// When clicking outside of the selection, immediately apply the
40694069+// effect of starting the selection
40704070+if(this.dragging===false){startEvent.preventDefault();this.select(startEvent);}}_createClass(MouseSelection,[{key:"move",value:function move(event){if(event.buttons==0)return this.destroy();if(this.dragging!==false)return;this.select(this.lastEvent=event);}},{key:"up",value:function up(event){if(this.dragging==null)this.select(this.lastEvent);if(!this.dragging)event.preventDefault();this.destroy();}},{key:"destroy",value:function destroy(){var doc=this.view.contentDOM.ownerDocument;doc.removeEventListener("mousemove",this.move);doc.removeEventListener("mouseup",this.up);this.inputState.mouseSelection=null;}},{key:"select",value:function select(event){var selection=this.style.get(event,this.extend,this.multiple);if(!selection.eq(this.view.state.selection)||selection.main.assoc!=this.view.state.selection.main.assoc)this.view.dispatch({selection:selection,userEvent:"select.pointer",scrollIntoView:true});}},{key:"update",value:function update(_update29){var _this113=this;if(_update29.docChanged&&this.dragging)this.dragging=this.dragging.map(_update29.changes);if(this.style.update(_update29))setTimeout(function(){return _this113.select(_this113.lastEvent);},20);}}]);return MouseSelection;}();function addsSelectionRange(view,event){var facet=view.state.facet(clickAddsSelectionRange);return facet.length?facet[0](event):browser.mac?event.metaKey:event.ctrlKey;}function dragMovesSelection(view,event){var facet=view.state.facet(dragMovesSelection$1);return facet.length?facet[0](event):browser.mac?!event.altKey:!event.ctrlKey;}function isInPrimarySelection(view,event){var main=view.state.selection.main;if(main.empty)return false;// On boundary clicks, check whether the coordinates are inside the
40714071+// selection's client rectangles
40724072+var sel=getSelection(view.root);if(sel.rangeCount==0)return true;var rects=sel.getRangeAt(0).getClientRects();for(var _i166=0;_i166<rects.length;_i166++){var rect=rects[_i166];if(rect.left<=event.clientX&&rect.right>=event.clientX&&rect.top<=event.clientY&&rect.bottom>=event.clientY)return true;}return false;}function eventBelongsToEditor(view,event){if(!event.bubbles)return true;if(event.defaultPrevented)return false;for(var node=event.target,cView;node!=view.contentDOM;node=node.parentNode){if(!node||node.nodeType==11||(cView=ContentView.get(node))&&cView.ignoreEvent(event))return false;}return true;}var handlers=Object.create(null);// This is very crude, but unfortunately both these browsers _pretend_
40734073+// that they have a clipboard API—all the objects and methods are
40744074+// there, they just don't work, and they are hard to test.
40754075+var brokenClipboardAPI=browser.ie&&browser.ie_version<15||browser.ios&&browser.webkit_version<604;function capturePaste(view){var parent=view.dom.parentNode;if(!parent)return;var target=parent.appendChild(document.createElement("textarea"));target.style.cssText="position: fixed; left: -10000px; top: 10px";target.focus();setTimeout(function(){view.focus();target.remove();doPaste(view,target.value);},50);}function doPaste(view,input){var state$1=view.state,changes,i=1,text=state$1.toText(input);var byLine=text.lines==state$1.selection.ranges.length;var linewise=lastLinewiseCopy!=null&&state$1.selection.ranges.every(function(r){return r.empty;})&&lastLinewiseCopy==text.toString();if(linewise){var lastLine=-1;changes=state$1.changeByRange(function(range){var line=state$1.doc.lineAt(range.from);if(line.from==lastLine)return{range:range};lastLine=line.from;var insert=state$1.toText((byLine?text.line(i++).text:input)+state$1.lineBreak);return{changes:{from:line.from,insert:insert},range:state.EditorSelection.cursor(range.from+insert.length)};});}else if(byLine){changes=state$1.changeByRange(function(range){var line=text.line(i++);return{changes:{from:range.from,to:range.to,insert:line.text},range:state.EditorSelection.cursor(range.from+line.length)};});}else{changes=state$1.replaceSelection(text);}view.dispatch(changes,{userEvent:"input.paste",scrollIntoView:true});}handlers.keydown=function(view,event){view.inputState.setSelectionOrigin("select");};var lastTouch=0;handlers.touchstart=function(view,e){lastTouch=Date.now();view.inputState.setSelectionOrigin("select.pointer");};handlers.touchmove=function(view){view.inputState.setSelectionOrigin("select.pointer");};handlers.mousedown=function(view,event){view.observer.flush();if(lastTouch>Date.now()-2000)return;// Ignore touch interaction
40764076+var style=null;var _iterator224=_createForOfIteratorHelper(view.state.facet(mouseSelectionStyle)),_step224;try{for(_iterator224.s();!(_step224=_iterator224.n()).done;){var makeStyle=_step224.value;style=makeStyle(view,event);if(style)break;}}catch(err){_iterator224.e(err);}finally{_iterator224.f();}if(!style&&event.button==0)style=basicMouseSelection(view,event);if(style){if(view.root.activeElement!=view.contentDOM)view.observer.ignore(function(){return focusPreventScroll(view.contentDOM);});view.inputState.startMouseSelection(view,event,style);}};function rangeForClick(view,pos,bias,type){if(type==1){// Single click
40774077+return state.EditorSelection.cursor(pos,bias);}else if(type==2){// Double click
40784078+return groupAt(view.state,pos,bias);}else{// Triple click
40794079+var visual=LineView.find(view.docView,pos),line=view.state.doc.lineAt(visual?visual.posAtEnd:pos);var from=visual?visual.posAtStart:line.from,to=visual?visual.posAtEnd:line.to;if(to<view.state.doc.length&&to==line.to)to++;return state.EditorSelection.range(from,to);}}var insideY=function insideY(y,rect){return y>=rect.top&&y<=rect.bottom;};var inside=function inside(x,y,rect){return insideY(y,rect)&&x>=rect.left&&x<=rect.right;};// Try to determine, for the given coordinates, associated with the
40804080+// given position, whether they are related to the element before or
40814081+// the element after the position.
40824082+function findPositionSide(view,pos,x,y){var line=LineView.find(view.docView,pos);if(!line)return 1;var off=pos-line.posAtStart;// Line boundaries point into the line
40834083+if(off==0)return 1;if(off==line.length)return-1;// Positions on top of an element point at that element
40844084+var before=line.coordsAt(off,-1);if(before&&inside(x,y,before))return-1;var after=line.coordsAt(off,1);if(after&&inside(x,y,after))return 1;// This is probably a line wrap point. Pick before if the point is
40854085+// beside it.
40864086+return before&&insideY(y,before)?-1:1;}function queryPos(view,event){var pos=view.posAtCoords({x:event.clientX,y:event.clientY},false);return{pos:pos,bias:findPositionSide(view,pos,event.clientX,event.clientY)};}var BadMouseDetail=browser.ie&&browser.ie_version<=11;var lastMouseDown=null,lastMouseDownCount=0,lastMouseDownTime=0;function getClickType(event){if(!BadMouseDetail)return event.detail;var last=lastMouseDown,lastTime=lastMouseDownTime;lastMouseDown=event;lastMouseDownTime=Date.now();return lastMouseDownCount=!last||lastTime>Date.now()-400&&Math.abs(last.clientX-event.clientX)<2&&Math.abs(last.clientY-event.clientY)<2?(lastMouseDownCount+1)%3:1;}function basicMouseSelection(view,event){var start=queryPos(view,event),type=getClickType(event);var startSel=view.state.selection;var last=start,lastEvent=event;return{update:function update(_update30){if(_update30.changes){if(start)start.pos=_update30.changes.mapPos(start.pos);startSel=startSel.map(_update30.changes);lastEvent=null;}},get:function get(event,extend,multiple){var cur;if(lastEvent&&event.clientX==lastEvent.clientX&&event.clientY==lastEvent.clientY)cur=last;else{cur=last=queryPos(view,event);lastEvent=event;}if(!cur||!start)return startSel;var range=rangeForClick(view,cur.pos,cur.bias,type);if(start.pos!=cur.pos&&!extend){var startRange=rangeForClick(view,start.pos,start.bias,type);var from=Math.min(startRange.from,range.from),to=Math.max(startRange.to,range.to);range=from<range.from?state.EditorSelection.range(from,to):state.EditorSelection.range(to,from);}if(extend)return startSel.replaceRange(startSel.main.extend(range.from,range.to));else if(multiple)return startSel.addRange(range);else return state.EditorSelection.create([range]);}};}handlers.dragstart=function(view,event){var main=view.state.selection.main;var mouseSelection=view.inputState.mouseSelection;if(mouseSelection)mouseSelection.dragging=main;if(event.dataTransfer){event.dataTransfer.setData("Text",view.state.sliceDoc(main.from,main.to));event.dataTransfer.effectAllowed="copyMove";}};function dropText(view,event,text,direct){var dropPos=view.posAtCoords({x:event.clientX,y:event.clientY});if(dropPos==null||!text)return;event.preventDefault();var mouseSelection=view.inputState.mouseSelection;var del=direct&&mouseSelection&&mouseSelection.dragging&&mouseSelection.dragMove?{from:mouseSelection.dragging.from,to:mouseSelection.dragging.to}:null;var ins={from:dropPos,insert:text};var changes=view.state.changes(del?[del,ins]:ins);view.focus();view.dispatch({changes:changes,selection:{anchor:changes.mapPos(dropPos,-1),head:changes.mapPos(dropPos,1)},userEvent:del?"move.drop":"input.drop"});}handlers.drop=function(view,event){if(!event.dataTransfer)return;if(view.state.readOnly)return event.preventDefault();var files=event.dataTransfer.files;if(files&&files.length){(function(){// For a file drop, read the file's text.
40874087+event.preventDefault();var text=Array(files.length),read=0;var finishFile=function finishFile(){if(++read==files.length)dropText(view,event,text.filter(function(s){return s!=null;}).join(view.state.lineBreak),false);};var _loop23=function _loop23(_i167){var reader=new FileReader();reader.onerror=finishFile;reader.onload=function(){if(!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))text[_i167]=reader.result;finishFile();};reader.readAsText(files[_i167]);};for(var _i167=0;_i167<files.length;_i167++){_loop23(_i167);}})();}else{dropText(view,event,event.dataTransfer.getData("Text"),true);}};handlers.paste=function(view,event){if(view.state.readOnly)return event.preventDefault();view.observer.flush();var data=brokenClipboardAPI?null:event.clipboardData;if(data){doPaste(view,data.getData("text/plain"));event.preventDefault();}else{capturePaste(view);}};function captureCopy(view,text){// The extra wrapper is somehow necessary on IE/Edge to prevent the
40884088+// content from being mangled when it is put onto the clipboard
40894089+var parent=view.dom.parentNode;if(!parent)return;var target=parent.appendChild(document.createElement("textarea"));target.style.cssText="position: fixed; left: -10000px; top: 10px";target.value=text;target.focus();target.selectionEnd=text.length;target.selectionStart=0;setTimeout(function(){target.remove();view.focus();},50);}function copiedRange(state){var content=[],ranges=[],linewise=false;var _iterator225=_createForOfIteratorHelper(state.selection.ranges),_step225;try{for(_iterator225.s();!(_step225=_iterator225.n()).done;){var range=_step225.value;if(!range.empty){content.push(state.sliceDoc(range.from,range.to));ranges.push(range);}}}catch(err){_iterator225.e(err);}finally{_iterator225.f();}if(!content.length){// Nothing selected, do a line-wise copy
40904090+var upto=-1;var _iterator226=_createForOfIteratorHelper(state.selection.ranges),_step226;try{for(_iterator226.s();!(_step226=_iterator226.n()).done;){var from=_step226.value.from;var line=state.doc.lineAt(from);if(line.number>upto){content.push(line.text);ranges.push({from:line.from,to:Math.min(state.doc.length,line.to+1)});}upto=line.number;}}catch(err){_iterator226.e(err);}finally{_iterator226.f();}linewise=true;}return{text:content.join(state.lineBreak),ranges:ranges,linewise:linewise};}var lastLinewiseCopy=null;handlers.copy=handlers.cut=function(view,event){var _copiedRange2=copiedRange(view.state),text=_copiedRange2.text,ranges=_copiedRange2.ranges,linewise=_copiedRange2.linewise;if(!text&&!linewise)return;lastLinewiseCopy=linewise?text:null;var data=brokenClipboardAPI?null:event.clipboardData;if(data){event.preventDefault();data.clearData();data.setData("text/plain",text);}else{captureCopy(view,text);}if(event.type=="cut"&&!view.state.readOnly)view.dispatch({changes:ranges,scrollIntoView:true,userEvent:"delete.cut"});};handlers.focus=handlers.blur=function(view){setTimeout(function(){if(view.hasFocus!=view.inputState.notifiedFocused)view.update([]);},10);};handlers.beforeprint=function(view){view.viewState.printing=true;view.requestMeasure();setTimeout(function(){view.viewState.printing=false;view.requestMeasure();},2000);};function forceClearComposition(view,rapid){if(view.docView.compositionDeco.size){view.inputState.rapidCompositionStart=rapid;try{view.update([]);}finally{view.inputState.rapidCompositionStart=false;}}}handlers.compositionstart=handlers.compositionupdate=function(view){if(view.inputState.compositionFirstChange==null)view.inputState.compositionFirstChange=true;if(view.inputState.composing<0){if(view.docView.compositionDeco.size){view.observer.flush();forceClearComposition(view,true);}// FIXME possibly set a timeout to clear it again on Android
40914091+view.inputState.composing=0;}};handlers.compositionend=function(view){view.inputState.composing=-1;view.inputState.compositionEndedAt=Date.now();view.inputState.compositionFirstChange=null;setTimeout(function(){if(view.inputState.composing<0)forceClearComposition(view,false);},50);};handlers.contextmenu=function(view){view.inputState.lastContextMenu=Date.now();};handlers.beforeinput=function(view,event){var _a;// Because Chrome Android doesn't fire useful key events, use
40924092+// beforeinput to detect backspace (and possibly enter and delete,
40934093+// but those usually don't even seem to fire beforeinput events at
40944094+// the moment) and fake a key event for it.
40954095+//
40964096+// (preventDefault on beforeinput, though supported in the spec,
40974097+// seems to do nothing at all on Chrome).
40984098+var pending;if(browser.chrome&&browser.android&&(pending=PendingKeys.find(function(key){return key.inputType==event.inputType;}))){view.inputState.setPendingAndroidKey(view,pending);if(pending.key=="Backspace"||pending.key=="Delete"){var startViewHeight=((_a=window.visualViewport)===null||_a===void 0?void 0:_a.height)||0;setTimeout(function(){var _a;// Backspacing near uneditable nodes on Chrome Android sometimes
40994099+// closes the virtual keyboard. This tries to crudely detect
41004100+// that and refocus to get it back.
41014101+if((((_a=window.visualViewport)===null||_a===void 0?void 0:_a.height)||0)>startViewHeight+10&&view.hasFocus){view.contentDOM.blur();view.focus();}},100);}}};var wrappingWhiteSpace=["pre-wrap","normal","pre-line"];var HeightOracle=/*#__PURE__*/function(){function HeightOracle(){_classCallCheck(this,HeightOracle);this.doc=text.Text.empty;this.lineWrapping=false;this.direction=exports.Direction.LTR;this.heightSamples={};this.lineHeight=14;this.charWidth=7;this.lineLength=30;// Used to track, during updateHeight, if any actual heights changed
41024102+this.heightChanged=false;}_createClass(HeightOracle,[{key:"heightForGap",value:function heightForGap(from,to){var lines=this.doc.lineAt(to).number-this.doc.lineAt(from).number+1;if(this.lineWrapping)lines+=Math.ceil((to-from-lines*this.lineLength*0.5)/this.lineLength);return this.lineHeight*lines;}},{key:"heightForLine",value:function heightForLine(length){if(!this.lineWrapping)return this.lineHeight;var lines=1+Math.max(0,Math.ceil((length-this.lineLength)/(this.lineLength-5)));return lines*this.lineHeight;}},{key:"setDoc",value:function setDoc(doc){this.doc=doc;return this;}},{key:"mustRefresh",value:function mustRefresh(lineHeights,whiteSpace,direction){var newHeight=false;for(var _i168=0;_i168<lineHeights.length;_i168++){var h=lineHeights[_i168];if(h<0){_i168++;}else if(!this.heightSamples[Math.floor(h*10)]){// Round to .1 pixels
41034103+newHeight=true;this.heightSamples[Math.floor(h*10)]=true;}}return newHeight||wrappingWhiteSpace.indexOf(whiteSpace)>-1!=this.lineWrapping||this.direction!=direction;}},{key:"refresh",value:function refresh(whiteSpace,direction,lineHeight,charWidth,lineLength,knownHeights){var lineWrapping=wrappingWhiteSpace.indexOf(whiteSpace)>-1;var changed=Math.round(lineHeight)!=Math.round(this.lineHeight)||this.lineWrapping!=lineWrapping||this.direction!=direction;this.lineWrapping=lineWrapping;this.direction=direction;this.lineHeight=lineHeight;this.charWidth=charWidth;this.lineLength=lineLength;if(changed){this.heightSamples={};for(var _i169=0;_i169<knownHeights.length;_i169++){var h=knownHeights[_i169];if(h<0)_i169++;else this.heightSamples[Math.floor(h*10)]=true;}}return changed;}}]);return HeightOracle;}();// This object is used by `updateHeight` to make DOM measurements
41044104+// arrive at the right nides. The `heights` array is a sequence of
41054105+// block heights, starting from position `from`.
41064106+var MeasuredHeights=/*#__PURE__*/function(){function MeasuredHeights(from,heights){_classCallCheck(this,MeasuredHeights);this.from=from;this.heights=heights;this.index=0;}_createClass(MeasuredHeights,[{key:"more",get:function get(){return this.index<this.heights.length;}}]);return MeasuredHeights;}();/**
41074107+Record used to represent information about a block-level element
41084108+in the editor view.
41094109+*/var BlockInfo=/*#__PURE__*/function(){/**
41104110+ @internal
41114111+ */function BlockInfo(/**
41124112+ The start of the element in the document.
41134113+ */from,/**
41144114+ The length of the element.
41154115+ */length,/**
41164116+ The top position of the element.
41174117+ */top,/**
41184118+ Its height.
41194119+ */height,/**
41204120+ The type of element this is. When querying lines, this may be
41214121+ an array of all the blocks that make up the line.
41224122+ */type){_classCallCheck(this,BlockInfo);this.from=from;this.length=length;this.top=top;this.height=height;this.type=type;}/**
41234123+ The end of the element as a document position.
41244124+ */_createClass(BlockInfo,[{key:"to",get:function get(){return this.from+this.length;}/**
41254125+ The bottom position of the element.
41264126+ */},{key:"bottom",get:function get(){return this.top+this.height;}/**
41274127+ @internal
41284128+ */},{key:"join",value:function join(other){var detail=(Array.isArray(this.type)?this.type:[this]).concat(Array.isArray(other.type)?other.type:[other]);return new BlockInfo(this.from,this.length+other.length,this.top,this.height+other.height,detail);}}]);return BlockInfo;}();var QueryType;(function(QueryType){QueryType[QueryType["ByPos"]=0]="ByPos";QueryType[QueryType["ByHeight"]=1]="ByHeight";QueryType[QueryType["ByPosNoHeight"]=2]="ByPosNoHeight";})(QueryType||(QueryType={}));var Epsilon=1e-4;var HeightMap=/*#__PURE__*/function(){function HeightMap(length,// The number of characters covered
41294129+height){var flags=arguments.length>2&&arguments[2]!==undefined?arguments[2]:2;_classCallCheck(this,HeightMap);this.length=length;this.height=height;this.flags=flags;}_createClass(HeightMap,[{key:"outdated",get:function get(){return(this.flags&2/* Outdated */)>0;},set:function set(value){this.flags=(value?2/* Outdated */:0)|this.flags&~2/* Outdated */;}},{key:"setHeight",value:function setHeight(oracle,height){if(this.height!=height){if(Math.abs(this.height-height)>Epsilon)oracle.heightChanged=true;this.height=height;}}// Base case is to replace a leaf node, which simply builds a tree
41304130+// from the new nodes and returns that (HeightMapBranch and
41314131+// HeightMapGap override this to actually use from/to)
41324132+},{key:"replace",value:function replace(_from,_to,nodes){return HeightMap.of(nodes);}// Again, these are base cases, and are overridden for branch and gap nodes.
41334133+},{key:"decomposeLeft",value:function decomposeLeft(_to,result){result.push(this);}},{key:"decomposeRight",value:function decomposeRight(_from,result){result.push(this);}},{key:"applyChanges",value:function applyChanges(decorations,oldDoc,oracle,changes){var me=this;for(var _i170=changes.length-1;_i170>=0;_i170--){var _changes$_i2=changes[_i170],fromA=_changes$_i2.fromA,toA=_changes$_i2.toA,fromB=_changes$_i2.fromB,toB=_changes$_i2.toB;var start=me.lineAt(fromA,QueryType.ByPosNoHeight,oldDoc,0,0);var end=start.to>=toA?start:me.lineAt(toA,QueryType.ByPosNoHeight,oldDoc,0,0);toB+=end.to-toA;toA=end.to;while(_i170>0&&start.from<=changes[_i170-1].toA){fromA=changes[_i170-1].fromA;fromB=changes[_i170-1].fromB;_i170--;if(fromA<start.from)start=me.lineAt(fromA,QueryType.ByPosNoHeight,oldDoc,0,0);}fromB+=start.from-fromA;fromA=start.from;var nodes=NodeBuilder.build(oracle,decorations,fromB,toB);me=me.replace(fromA,toA,nodes);}return me.updateHeight(oracle,0);}}],[{key:"empty",value:function empty(){return new HeightMapText(0,0);}// nodes uses null values to indicate the position of line breaks.
41344134+// There are never line breaks at the start or end of the array, or
41354135+// two line breaks next to each other, and the array isn't allowed
41364136+// to be empty (same restrictions as return value from the builder).
41374137+},{key:"of",value:function of(nodes){if(nodes.length==1)return nodes[0];var i=0,j=nodes.length,before=0,after=0;for(;;){if(i==j){if(before>after*2){var split=nodes[i-1];if(split["break"])nodes.splice(--i,1,split.left,null,split.right);else nodes.splice(--i,1,split.left,split.right);j+=1+split["break"];before-=split.size;}else if(after>before*2){var _split2=nodes[j];if(_split2["break"])nodes.splice(j,1,_split2.left,null,_split2.right);else nodes.splice(j,1,_split2.left,_split2.right);j+=2+_split2["break"];after-=_split2.size;}else{break;}}else if(before<after){var next=nodes[i++];if(next)before+=next.size;}else{var _next4=nodes[--j];if(_next4)after+=_next4.size;}}var brk=0;if(nodes[i-1]==null){brk=1;i--;}else if(nodes[i]==null){brk=1;j++;}return new HeightMapBranch(HeightMap.of(nodes.slice(0,i)),brk,HeightMap.of(nodes.slice(j)));}}]);return HeightMap;}();HeightMap.prototype.size=1;var HeightMapBlock=/*#__PURE__*/function(_HeightMap4){_inherits(HeightMapBlock,_HeightMap4);var _super60=_createSuper(HeightMapBlock);function HeightMapBlock(length,height,type){var _this114;_classCallCheck(this,HeightMapBlock);_this114=_super60.call(this,length,height);_this114.type=type;return _this114;}_createClass(HeightMapBlock,[{key:"blockAt",value:function blockAt(_height,_doc,top,offset){return new BlockInfo(offset,this.length,top,this.height,this.type);}},{key:"lineAt",value:function lineAt(_value,_type,doc,top,offset){return this.blockAt(0,doc,top,offset);}},{key:"forEachLine",value:function forEachLine(_from,_to,doc,top,offset,f){f(this.blockAt(0,doc,top,offset));}},{key:"updateHeight",value:function updateHeight(oracle){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var _force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var measured=arguments.length>3?arguments[3]:undefined;if(measured&&measured.from<=offset&&measured.more)this.setHeight(oracle,measured.heights[measured.index++]);this.outdated=false;return this;}},{key:"toString",value:function toString(){return"block(".concat(this.length,")");}}]);return HeightMapBlock;}(HeightMap);var HeightMapText=/*#__PURE__*/function(_HeightMapBlock2){_inherits(HeightMapText,_HeightMapBlock2);var _super61=_createSuper(HeightMapText);function HeightMapText(length,height){var _this115;_classCallCheck(this,HeightMapText);_this115=_super61.call(this,length,height,exports.BlockType.Text);_this115.collapsed=0;// Amount of collapsed content in the line
41384138+_this115.widgetHeight=0;// Maximum inline widget height
41394139+return _this115;}_createClass(HeightMapText,[{key:"replace",value:function replace(_from,_to,nodes){var node=nodes[0];if(nodes.length==1&&(node instanceof HeightMapText||node instanceof HeightMapGap&&node.flags&4/* SingleLine */)&&Math.abs(this.length-node.length)<10){if(node instanceof HeightMapGap)node=new HeightMapText(node.length,this.height);else node.height=this.height;if(!this.outdated)node.outdated=false;return node;}else{return HeightMap.of(nodes);}}},{key:"updateHeight",value:function updateHeight(oracle){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var measured=arguments.length>3?arguments[3]:undefined;if(measured&&measured.from<=offset&&measured.more)this.setHeight(oracle,measured.heights[measured.index++]);else if(force||this.outdated)this.setHeight(oracle,Math.max(this.widgetHeight,oracle.heightForLine(this.length-this.collapsed)));this.outdated=false;return this;}},{key:"toString",value:function toString(){return"line(".concat(this.length).concat(this.collapsed?-this.collapsed:"").concat(this.widgetHeight?":"+this.widgetHeight:"",")");}}]);return HeightMapText;}(HeightMapBlock);var HeightMapGap=/*#__PURE__*/function(_HeightMap5){_inherits(HeightMapGap,_HeightMap5);var _super62=_createSuper(HeightMapGap);function HeightMapGap(length){_classCallCheck(this,HeightMapGap);return _super62.call(this,length,0);}_createClass(HeightMapGap,[{key:"lines",value:function lines(doc,offset){var firstLine=doc.lineAt(offset).number,lastLine=doc.lineAt(offset+this.length).number;return{firstLine:firstLine,lastLine:lastLine,lineHeight:this.height/(lastLine-firstLine+1)};}},{key:"blockAt",value:function blockAt(height,doc,top,offset){var _this$lines4=this.lines(doc,offset),firstLine=_this$lines4.firstLine,lastLine=_this$lines4.lastLine,lineHeight=_this$lines4.lineHeight;var line=Math.max(0,Math.min(lastLine-firstLine,Math.floor((height-top)/lineHeight)));var _doc$line2=doc.line(firstLine+line),from=_doc$line2.from,length=_doc$line2.length;return new BlockInfo(from,length,top+lineHeight*line,lineHeight,exports.BlockType.Text);}},{key:"lineAt",value:function lineAt(value,type,doc,top,offset){if(type==QueryType.ByHeight)return this.blockAt(value,doc,top,offset);if(type==QueryType.ByPosNoHeight){var _doc$lineAt3=doc.lineAt(value),_from4=_doc$lineAt3.from,to=_doc$lineAt3.to;return new BlockInfo(_from4,to-_from4,0,0,exports.BlockType.Text);}var _this$lines5=this.lines(doc,offset),firstLine=_this$lines5.firstLine,lineHeight=_this$lines5.lineHeight;var _doc$lineAt4=doc.lineAt(value),from=_doc$lineAt4.from,length=_doc$lineAt4.length,number=_doc$lineAt4.number;return new BlockInfo(from,length,top+lineHeight*(number-firstLine),lineHeight,exports.BlockType.Text);}},{key:"forEachLine",value:function forEachLine(from,to,doc,top,offset,f){var _this$lines6=this.lines(doc,offset),firstLine=_this$lines6.firstLine,lineHeight=_this$lines6.lineHeight;for(var pos=Math.max(from,offset),end=Math.min(offset+this.length,to);pos<=end;){var line=doc.lineAt(pos);if(pos==from)top+=lineHeight*(line.number-firstLine);f(new BlockInfo(line.from,line.length,top,lineHeight,exports.BlockType.Text));top+=lineHeight;pos=line.to+1;}}},{key:"replace",value:function replace(from,to,nodes){var after=this.length-to;if(after>0){var last=nodes[nodes.length-1];if(last instanceof HeightMapGap)nodes[nodes.length-1]=new HeightMapGap(last.length+after);else nodes.push(null,new HeightMapGap(after-1));}if(from>0){var first=nodes[0];if(first instanceof HeightMapGap)nodes[0]=new HeightMapGap(from+first.length);else nodes.unshift(new HeightMapGap(from-1),null);}return HeightMap.of(nodes);}},{key:"decomposeLeft",value:function decomposeLeft(to,result){result.push(new HeightMapGap(to-1),null);}},{key:"decomposeRight",value:function decomposeRight(from,result){result.push(null,new HeightMapGap(this.length-from-1));}},{key:"updateHeight",value:function updateHeight(oracle){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var measured=arguments.length>3?arguments[3]:undefined;var end=offset+this.length;if(measured&&measured.from<=offset+this.length&&measured.more){// Fill in part of this gap with measured lines. We know there
41404140+// can't be widgets or collapsed ranges in those lines, because
41414141+// they would already have been added to the heightmap (gaps
41424142+// only contain plain text).
41434143+var nodes=[],pos=Math.max(offset,measured.from);if(measured.from>offset)nodes.push(new HeightMapGap(measured.from-offset-1).updateHeight(oracle,offset));while(pos<=end&&measured.more){var len=oracle.doc.lineAt(pos).length;if(nodes.length)nodes.push(null);var line=new HeightMapText(len,measured.heights[measured.index++]);line.outdated=false;nodes.push(line);pos+=len+1;}if(pos<=end)nodes.push(null,new HeightMapGap(end-pos).updateHeight(oracle,pos));oracle.heightChanged=true;return HeightMap.of(nodes);}else if(force||this.outdated){this.setHeight(oracle,oracle.heightForGap(offset,offset+this.length));this.outdated=false;}return this;}},{key:"toString",value:function toString(){return"gap(".concat(this.length,")");}}]);return HeightMapGap;}(HeightMap);var HeightMapBranch=/*#__PURE__*/function(_HeightMap6){_inherits(HeightMapBranch,_HeightMap6);var _super63=_createSuper(HeightMapBranch);function HeightMapBranch(left,brk,right){var _this116;_classCallCheck(this,HeightMapBranch);_this116=_super63.call(this,left.length+brk+right.length,left.height+right.height,brk|(left.outdated||right.outdated?2/* Outdated */:0));_this116.left=left;_this116.right=right;_this116.size=left.size+right.size;return _this116;}_createClass(HeightMapBranch,[{key:"break",get:function get(){return this.flags&1/* Break */;}},{key:"blockAt",value:function blockAt(height,doc,top,offset){var mid=top+this.left.height;return height<mid||this.right.height==0?this.left.blockAt(height,doc,top,offset):this.right.blockAt(height,doc,mid,offset+this.left.length+this["break"]);}},{key:"lineAt",value:function lineAt(value,type,doc,top,offset){var rightTop=top+this.left.height,rightOffset=offset+this.left.length+this["break"];var left=type==QueryType.ByHeight?value<rightTop||this.right.height==0:value<rightOffset;var base=left?this.left.lineAt(value,type,doc,top,offset):this.right.lineAt(value,type,doc,rightTop,rightOffset);if(this["break"]||(left?base.to<rightOffset:base.from>rightOffset))return base;var subQuery=type==QueryType.ByPosNoHeight?QueryType.ByPosNoHeight:QueryType.ByPos;if(left)return base.join(this.right.lineAt(rightOffset,subQuery,doc,rightTop,rightOffset));else return this.left.lineAt(rightOffset,subQuery,doc,top,offset).join(base);}},{key:"forEachLine",value:function forEachLine(from,to,doc,top,offset,f){var rightTop=top+this.left.height,rightOffset=offset+this.left.length+this["break"];if(this["break"]){if(from<rightOffset)this.left.forEachLine(from,to,doc,top,offset,f);if(to>=rightOffset)this.right.forEachLine(from,to,doc,rightTop,rightOffset,f);}else{var mid=this.lineAt(rightOffset,QueryType.ByPos,doc,top,offset);if(from<mid.from)this.left.forEachLine(from,mid.from-1,doc,top,offset,f);if(mid.to>=from&&mid.from<=to)f(mid);if(to>mid.to)this.right.forEachLine(mid.to+1,to,doc,rightTop,rightOffset,f);}}},{key:"replace",value:function replace(from,to,nodes){var rightStart=this.left.length+this["break"];if(to<rightStart)return this.balanced(this.left.replace(from,to,nodes),this.right);if(from>this.left.length)return this.balanced(this.left,this.right.replace(from-rightStart,to-rightStart,nodes));var result=[];if(from>0)this.decomposeLeft(from,result);var left=result.length;var _iterator227=_createForOfIteratorHelper(nodes),_step227;try{for(_iterator227.s();!(_step227=_iterator227.n()).done;){var node=_step227.value;result.push(node);}}catch(err){_iterator227.e(err);}finally{_iterator227.f();}if(from>0)mergeGaps(result,left-1);if(to<this.length){var right=result.length;this.decomposeRight(to,result);mergeGaps(result,right);}return HeightMap.of(result);}},{key:"decomposeLeft",value:function decomposeLeft(to,result){var left=this.left.length;if(to<=left)return this.left.decomposeLeft(to,result);result.push(this.left);if(this["break"]){left++;if(to>=left)result.push(null);}if(to>left)this.right.decomposeLeft(to-left,result);}},{key:"decomposeRight",value:function decomposeRight(from,result){var left=this.left.length,right=left+this["break"];if(from>=right)return this.right.decomposeRight(from-right,result);if(from<left)this.left.decomposeRight(from,result);if(this["break"]&&from<right)result.push(null);result.push(this.right);}},{key:"balanced",value:function balanced(left,right){if(left.size>2*right.size||right.size>2*left.size)return HeightMap.of(this["break"]?[left,null,right]:[left,right]);this.left=left;this.right=right;this.height=left.height+right.height;this.outdated=left.outdated||right.outdated;this.size=left.size+right.size;this.length=left.length+this["break"]+right.length;return this;}},{key:"updateHeight",value:function updateHeight(oracle){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var force=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var measured=arguments.length>3?arguments[3]:undefined;var left=this.left,right=this.right,rightStart=offset+left.length+this["break"],rebalance=null;if(measured&&measured.from<=offset+left.length&&measured.more)rebalance=left=left.updateHeight(oracle,offset,force,measured);else left.updateHeight(oracle,offset,force);if(measured&&measured.from<=rightStart+right.length&&measured.more)rebalance=right=right.updateHeight(oracle,rightStart,force,measured);else right.updateHeight(oracle,rightStart,force);if(rebalance)return this.balanced(left,right);this.height=this.left.height+this.right.height;this.outdated=false;return this;}},{key:"toString",value:function toString(){return this.left+(this["break"]?" ":"-")+this.right;}}]);return HeightMapBranch;}(HeightMap);function mergeGaps(nodes,around){var before,after;if(nodes[around]==null&&(before=nodes[around-1])instanceof HeightMapGap&&(after=nodes[around+1])instanceof HeightMapGap)nodes.splice(around-1,3,new HeightMapGap(before.length+1+after.length));}var relevantWidgetHeight=5;var NodeBuilder=/*#__PURE__*/function(){function NodeBuilder(pos,oracle){_classCallCheck(this,NodeBuilder);this.pos=pos;this.oracle=oracle;this.nodes=[];this.lineStart=-1;this.lineEnd=-1;this.covering=null;this.writtenTo=pos;}_createClass(NodeBuilder,[{key:"isCovered",get:function get(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering;}},{key:"span",value:function span(_from,to){if(this.lineStart>-1){var end=Math.min(to,this.lineEnd),last=this.nodes[this.nodes.length-1];if(last instanceof HeightMapText)last.length+=end-this.pos;else if(end>this.pos||!this.isCovered)this.nodes.push(new HeightMapText(end-this.pos,-1));this.writtenTo=end;if(to>end){this.nodes.push(null);this.writtenTo++;this.lineStart=-1;}}this.pos=to;}},{key:"point",value:function point(from,to,deco){if(from<to||deco.heightRelevant){var height=deco.widget?Math.max(0,deco.widget.estimatedHeight):0;var len=to-from;if(deco.block){this.addBlock(new HeightMapBlock(len,height,deco.type));}else if(len||height>=relevantWidgetHeight){this.addLineDeco(height,len);}}else if(to>from){this.span(from,to);}if(this.lineEnd>-1&&this.lineEnd<this.pos)this.lineEnd=this.oracle.doc.lineAt(this.pos).to;}},{key:"enterLine",value:function enterLine(){if(this.lineStart>-1)return;var _this$oracle$doc$line2=this.oracle.doc.lineAt(this.pos),from=_this$oracle$doc$line2.from,to=_this$oracle$doc$line2.to;this.lineStart=from;this.lineEnd=to;if(this.writtenTo<from){if(this.writtenTo<from-1||this.nodes[this.nodes.length-1]==null)this.nodes.push(this.blankContent(this.writtenTo,from-1));this.nodes.push(null);}if(this.pos>from)this.nodes.push(new HeightMapText(this.pos-from,-1));this.writtenTo=this.pos;}},{key:"blankContent",value:function blankContent(from,to){var gap=new HeightMapGap(to-from);if(this.oracle.doc.lineAt(from).to==to)gap.flags|=4/* SingleLine */;return gap;}},{key:"ensureLine",value:function ensureLine(){this.enterLine();var last=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(last instanceof HeightMapText)return last;var line=new HeightMapText(0,-1);this.nodes.push(line);return line;}},{key:"addBlock",value:function addBlock(block){this.enterLine();if(block.type==exports.BlockType.WidgetAfter&&!this.isCovered)this.ensureLine();this.nodes.push(block);this.writtenTo=this.pos=this.pos+block.length;if(block.type!=exports.BlockType.WidgetBefore)this.covering=block;}},{key:"addLineDeco",value:function addLineDeco(height,length){var line=this.ensureLine();line.length+=length;line.collapsed+=length;line.widgetHeight=Math.max(line.widgetHeight,height);this.writtenTo=this.pos=this.pos+length;}},{key:"finish",value:function finish(from){var last=this.nodes.length==0?null:this.nodes[this.nodes.length-1];if(this.lineStart>-1&&!(last instanceof HeightMapText)&&!this.isCovered)this.nodes.push(new HeightMapText(0,-1));else if(this.writtenTo<this.pos||last==null)this.nodes.push(this.blankContent(this.writtenTo,this.pos));var pos=from;var _iterator228=_createForOfIteratorHelper(this.nodes),_step228;try{for(_iterator228.s();!(_step228=_iterator228.n()).done;){var node=_step228.value;if(node instanceof HeightMapText)node.updateHeight(this.oracle,pos);pos+=node?node.length:1;}}catch(err){_iterator228.e(err);}finally{_iterator228.f();}return this.nodes;}// Always called with a region that on both sides either stretches
41444144+// to a line break or the end of the document.
41454145+// The returned array uses null to indicate line breaks, but never
41464146+// starts or ends in a line break, or has multiple line breaks next
41474147+// to each other.
41484148+}],[{key:"build",value:function build(oracle,decorations,from,to){var builder=new NodeBuilder(from,oracle);rangeset.RangeSet.spans(decorations,from,to,builder,0);return builder.finish(from);}}]);return NodeBuilder;}();function heightRelevantDecoChanges(a,b,diff){var comp=new DecorationComparator();rangeset.RangeSet.compare(a,b,diff,comp,0);return comp.changes;}var DecorationComparator=/*#__PURE__*/function(){function DecorationComparator(){_classCallCheck(this,DecorationComparator);this.changes=[];}_createClass(DecorationComparator,[{key:"compareRange",value:function compareRange(){}},{key:"comparePoint",value:function comparePoint(from,to,a,b){if(from<to||a&&a.heightRelevant||b&&b.heightRelevant)addRange(from,to,this.changes,5);}}]);return DecorationComparator;}();function visiblePixelRange(dom,paddingTop){var rect=dom.getBoundingClientRect();var left=Math.max(0,rect.left),right=Math.min(innerWidth,rect.right);var top=Math.max(0,rect.top),bottom=Math.min(innerHeight,rect.bottom);var body=dom.ownerDocument.body;for(var parent=dom.parentNode;parent&&parent!=body;){if(parent.nodeType==1){var elt=parent;var style=window.getComputedStyle(elt);if((elt.scrollHeight>elt.clientHeight||elt.scrollWidth>elt.clientWidth)&&style.overflow!="visible"){var parentRect=elt.getBoundingClientRect();left=Math.max(left,parentRect.left);right=Math.min(right,parentRect.right);top=Math.max(top,parentRect.top);bottom=Math.min(bottom,parentRect.bottom);}parent=style.position=="absolute"||style.position=="fixed"?elt.offsetParent:elt.parentNode;}else if(parent.nodeType==11){// Shadow root
41494149+parent=parent.host;}else{break;}}return{left:left-rect.left,right:right-rect.left,top:top-(rect.top+paddingTop),bottom:bottom-(rect.top+paddingTop)};}// Line gaps are placeholder widgets used to hide pieces of overlong
41504150+// lines within the viewport, as a kludge to keep the editor
41514151+// responsive when a ridiculously long line is loaded into it.
41524152+var LineGap=/*#__PURE__*/function(){function LineGap(from,to,size){_classCallCheck(this,LineGap);this.from=from;this.to=to;this.size=size;}_createClass(LineGap,[{key:"draw",value:function draw(wrapping){return Decoration.replace({widget:new LineGapWidget(this.size,wrapping)}).range(this.from,this.to);}}],[{key:"same",value:function same(a,b){if(a.length!=b.length)return false;for(var _i171=0;_i171<a.length;_i171++){var gA=a[_i171],gB=b[_i171];if(gA.from!=gB.from||gA.to!=gB.to||gA.size!=gB.size)return false;}return true;}}]);return LineGap;}();var LineGapWidget=/*#__PURE__*/function(_WidgetType11){_inherits(LineGapWidget,_WidgetType11);var _super64=_createSuper(LineGapWidget);function LineGapWidget(size,vertical){var _this117;_classCallCheck(this,LineGapWidget);_this117=_super64.call(this);_this117.size=size;_this117.vertical=vertical;return _this117;}_createClass(LineGapWidget,[{key:"eq",value:function eq(other){return other.size==this.size&&other.vertical==this.vertical;}},{key:"toDOM",value:function toDOM(){var elt=document.createElement("div");if(this.vertical){elt.style.height=this.size+"px";}else{elt.style.width=this.size+"px";elt.style.height="2px";elt.style.display="inline-block";}return elt;}},{key:"estimatedHeight",get:function get(){return this.vertical?this.size:-1;}}]);return LineGapWidget;}(WidgetType);var ScrollTarget=/*#__PURE__*/function(){function ScrollTarget(range){var center=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;_classCallCheck(this,ScrollTarget);this.range=range;this.center=center;}_createClass(ScrollTarget,[{key:"map",value:function map(changes){return changes.empty?this:new ScrollTarget(this.range.map(changes),this.center);}}]);return ScrollTarget;}();var ViewState=/*#__PURE__*/function(){function ViewState(state){_classCallCheck(this,ViewState);this.state=state;// These are contentDOM-local coordinates
41534153+this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0};this.inView=true;this.paddingTop=0;this.paddingBottom=0;this.contentWidth=0;this.heightOracle=new HeightOracle();// See VP.MaxDOMHeight
41544154+this.scaler=IdScaler;this.scrollTarget=null;// Briefly set to true when printing, to disable viewport limiting
41554155+this.printing=false;this.visibleRanges=[];// Cursor 'assoc' is only significant when the cursor is on a line
41564156+// wrap point, where it must stick to the character that it is
41574157+// associated with. Since browsers don't provide a reasonable
41584158+// interface to set or query this, when a selection is set that
41594159+// might cause this to be significant, this flag is set. The next
41604160+// measure phase will check whether the cursor is on a line-wrapping
41614161+// boundary and, if so, reset it to make sure it is positioned in
41624162+// the right place.
41634163+this.mustEnforceCursorAssoc=false;this.heightMap=HeightMap.empty().applyChanges(state.facet(decorations),text.Text.empty,this.heightOracle.setDoc(state.doc),[new ChangedRange(0,0,0,state.doc.length)]);this.viewport=this.getViewport(0,null);this.updateForViewport();this.lineGaps=this.ensureLineGaps([]);this.lineGapDeco=Decoration.set(this.lineGaps.map(function(gap){return gap.draw(false);}));this.computeVisibleRanges();}_createClass(ViewState,[{key:"updateForViewport",value:function updateForViewport(){var _this118=this;var viewports=[this.viewport],main=this.state.selection.main;var _loop24=function _loop24(_i172){var pos=_i172?main.head:main.anchor;if(!viewports.some(function(_ref78){var from=_ref78.from,to=_ref78.to;return pos>=from&&pos<=to;})){var _this118$lineAt=_this118.lineAt(pos,0),from=_this118$lineAt.from,to=_this118$lineAt.to;viewports.push(new Viewport(from,to));}};for(var _i172=0;_i172<=1;_i172++){_loop24(_i172);}this.viewports=viewports.sort(function(a,b){return a.from-b.from;});this.scaler=this.heightMap.height<=7000000/* MaxDOMHeight */?IdScaler:new BigScaler(this.heightOracle.doc,this.heightMap,this.viewports);}},{key:"update",value:function update(_update31){var scrollTarget=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var prev=this.state;this.state=_update31.state;var newDeco=this.state.facet(decorations);var contentChanges=_update31.changedRanges;var heightChanges=ChangedRange.extendWithRanges(contentChanges,heightRelevantDecoChanges(_update31.startState.facet(decorations),newDeco,_update31?_update31.changes:state.ChangeSet.empty(this.state.doc.length)));var prevHeight=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(newDeco,prev.doc,this.heightOracle.setDoc(this.state.doc),heightChanges);if(this.heightMap.height!=prevHeight)_update31.flags|=2/* Height */;var viewport=heightChanges.length?this.mapViewport(this.viewport,_update31.changes):this.viewport;if(scrollTarget&&(scrollTarget.range.head<viewport.from||scrollTarget.range.head>viewport.to)||!this.viewportIsAppropriate(viewport))viewport=this.getViewport(0,scrollTarget);this.viewport=viewport;this.updateForViewport();if(this.lineGaps.length||this.viewport.to-this.viewport.from>4000/* DoubleMargin */)this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,_update31.changes)));_update31.flags|=this.computeVisibleRanges();if(scrollTarget)this.scrollTarget=scrollTarget;if(!this.mustEnforceCursorAssoc&&_update31.selectionSet&&_update31.view.lineWrapping&&_update31.state.selection.main.empty&&_update31.state.selection.main.assoc)this.mustEnforceCursorAssoc=true;}},{key:"measure",value:function measure(docView,repeated){var dom=docView.dom,whiteSpace="",direction=exports.Direction.LTR;var result=0;if(!repeated){// Vertical padding
41644164+var style=window.getComputedStyle(dom);whiteSpace=style.whiteSpace,direction=style.direction=="rtl"?exports.Direction.RTL:exports.Direction.LTR;var paddingTop=parseInt(style.paddingTop)||0,paddingBottom=parseInt(style.paddingBottom)||0;if(this.paddingTop!=paddingTop||this.paddingBottom!=paddingBottom){result|=8/* Geometry */;this.paddingTop=paddingTop;this.paddingBottom=paddingBottom;}}// Pixel viewport
41654165+var pixelViewport=this.printing?{top:-1e8,bottom:1e8,left:-1e8,right:1e8}:visiblePixelRange(dom,this.paddingTop);var dTop=pixelViewport.top-this.pixelViewport.top,dBottom=pixelViewport.bottom-this.pixelViewport.bottom;this.pixelViewport=pixelViewport;this.inView=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(!this.inView)return 0;var lineHeights=docView.measureVisibleLineHeights();var refresh=false,bias=0,oracle=this.heightOracle;if(!repeated){var contentWidth=docView.dom.clientWidth;if(oracle.mustRefresh(lineHeights,whiteSpace,direction)||oracle.lineWrapping&&Math.abs(contentWidth-this.contentWidth)>oracle.charWidth){var _docView$measureTextS=docView.measureTextSize(),lineHeight=_docView$measureTextS.lineHeight,charWidth=_docView$measureTextS.charWidth;refresh=oracle.refresh(whiteSpace,direction,lineHeight,charWidth,contentWidth/charWidth,lineHeights);if(refresh){docView.minWidth=0;result|=8/* Geometry */;}}if(this.contentWidth!=contentWidth){this.contentWidth=contentWidth;result|=8/* Geometry */;}if(dTop>0&&dBottom>0)bias=Math.max(dTop,dBottom);else if(dTop<0&&dBottom<0)bias=Math.min(dTop,dBottom);}oracle.heightChanged=false;this.heightMap=this.heightMap.updateHeight(oracle,0,refresh,new MeasuredHeights(this.viewport.from,lineHeights));if(oracle.heightChanged)result|=2/* Height */;if(!this.viewportIsAppropriate(this.viewport,bias)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to))this.viewport=this.getViewport(bias,this.scrollTarget);this.updateForViewport();if(this.lineGaps.length||this.viewport.to-this.viewport.from>4000/* DoubleMargin */)this.updateLineGaps(this.ensureLineGaps(refresh?[]:this.lineGaps));result|=this.computeVisibleRanges();if(this.mustEnforceCursorAssoc){this.mustEnforceCursorAssoc=false;// This is done in the read stage, because moving the selection
41664166+// to a line end is going to trigger a layout anyway, so it
41674167+// can't be a pure write. It should be rare that it does any
41684168+// writing.
41694169+docView.enforceCursorAssoc();}return result;}},{key:"visibleTop",get:function get(){return this.scaler.fromDOM(this.pixelViewport.top,0);}},{key:"visibleBottom",get:function get(){return this.scaler.fromDOM(this.pixelViewport.bottom,0);}},{key:"getViewport",value:function getViewport(bias,scrollTarget){// This will divide VP.Margin between the top and the
41704170+// bottom, depending on the bias (the change in viewport position
41714171+// since the last update). It'll hold a number between 0 and 1
41724172+var marginTop=0.5-Math.max(-0.5,Math.min(0.5,bias/1000/* Margin *//2));var map=this.heightMap,doc=this.state.doc,visibleTop=this.visibleTop,visibleBottom=this.visibleBottom;var viewport=new Viewport(map.lineAt(visibleTop-marginTop*1000/* Margin */,QueryType.ByHeight,doc,0,0).from,map.lineAt(visibleBottom+(1-marginTop)*1000/* Margin */,QueryType.ByHeight,doc,0,0).to);// If scrollTarget is given, make sure the viewport includes that position
41734173+if(scrollTarget){var head=scrollTarget.range.head,viewHeight=visibleBottom-visibleTop;if(head<viewport.from||head>viewport.to){var block=map.lineAt(head,QueryType.ByPos,doc,0,0),topPos;if(scrollTarget.center)topPos=(block.top+block.bottom)/2-viewHeight/2;else if(head<viewport.from)topPos=block.top;else topPos=block.bottom-viewHeight;viewport=new Viewport(map.lineAt(topPos-1000/* Margin *//2,QueryType.ByHeight,doc,0,0).from,map.lineAt(topPos+viewHeight+1000/* Margin *//2,QueryType.ByHeight,doc,0,0).to);}}return viewport;}},{key:"mapViewport",value:function mapViewport(viewport,changes){var from=changes.mapPos(viewport.from,-1),to=changes.mapPos(viewport.to,1);return new Viewport(this.heightMap.lineAt(from,QueryType.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(to,QueryType.ByPos,this.state.doc,0,0).to);}// Checks if a given viewport covers the visible part of the
41744174+// document and not too much beyond that.
41754175+},{key:"viewportIsAppropriate",value:function viewportIsAppropriate(_ref79){var from=_ref79.from,to=_ref79.to;var bias=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var _this$heightMap$lineA3=this.heightMap.lineAt(from,QueryType.ByPos,this.state.doc,0,0),top=_this$heightMap$lineA3.top;var _this$heightMap$lineA4=this.heightMap.lineAt(to,QueryType.ByPos,this.state.doc,0,0),bottom=_this$heightMap$lineA4.bottom;var visibleTop=this.visibleTop,visibleBottom=this.visibleBottom;return(from==0||top<=visibleTop-Math.max(10/* MinCoverMargin */,Math.min(-bias,250/* MaxCoverMargin */)))&&(to==this.state.doc.length||bottom>=visibleBottom+Math.max(10/* MinCoverMargin */,Math.min(bias,250/* MaxCoverMargin */)))&&top>visibleTop-2*1000/* Margin */&&bottom<visibleBottom+2*1000/* Margin */;}},{key:"mapLineGaps",value:function mapLineGaps(gaps,changes){if(!gaps.length||changes.empty)return gaps;var mapped=[];var _iterator229=_createForOfIteratorHelper(gaps),_step229;try{for(_iterator229.s();!(_step229=_iterator229.n()).done;){var gap=_step229.value;if(!changes.touchesRange(gap.from,gap.to))mapped.push(new LineGap(changes.mapPos(gap.from),changes.mapPos(gap.to),gap.size));}}catch(err){_iterator229.e(err);}finally{_iterator229.f();}return mapped;}// Computes positions in the viewport where the start or end of a
41764176+// line should be hidden, trying to reuse existing line gaps when
41774177+// appropriate to avoid unneccesary redraws.
41784178+// Uses crude character-counting for the positioning and sizing,
41794179+// since actual DOM coordinates aren't always available and
41804180+// predictable. Relies on generous margins (see LG.Margin) to hide
41814181+// the artifacts this might produce from the user.
41824182+},{key:"ensureLineGaps",value:function ensureLineGaps(current){var _this119=this;var gaps=[];// This won't work at all in predominantly right-to-left text.
41834183+if(this.heightOracle.direction!=exports.Direction.LTR)return gaps;this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,function(line){if(line.length<4000/* DoubleMargin */)return;var structure=lineStructure(line.from,line.to,_this119.state);if(structure.total<4000/* DoubleMargin */)return;var viewFrom,viewTo;if(_this119.heightOracle.lineWrapping){var marginHeight=2000/* Margin *//_this119.heightOracle.lineLength*_this119.heightOracle.lineHeight;viewFrom=findPosition(structure,(_this119.visibleTop-line.top-marginHeight)/line.height);viewTo=findPosition(structure,(_this119.visibleBottom-line.top+marginHeight)/line.height);}else{var totalWidth=structure.total*_this119.heightOracle.charWidth;var marginWidth=2000/* Margin */*_this119.heightOracle.charWidth;viewFrom=findPosition(structure,(_this119.pixelViewport.left-marginWidth)/totalWidth);viewTo=findPosition(structure,(_this119.pixelViewport.right+marginWidth)/totalWidth);}var outside=[];if(viewFrom>line.from)outside.push({from:line.from,to:viewFrom});if(viewTo<line.to)outside.push({from:viewTo,to:line.to});var sel=_this119.state.selection.main;// Make sure the gaps don't cover a selection end
41844184+if(sel.from>=line.from&&sel.from<=line.to)cutRange(outside,sel.from-10/* SelectionMargin */,sel.from+10/* SelectionMargin */);if(!sel.empty&&sel.to>=line.from&&sel.to<=line.to)cutRange(outside,sel.to-10/* SelectionMargin */,sel.to+10/* SelectionMargin */);var _loop25=function _loop25(){var _outside2$_i=_outside2[_i173],from=_outside2$_i.from,to=_outside2$_i.to;if(to-from>1000/* HalfMargin */){gaps.push(find(current,function(gap){return gap.from>=line.from&&gap.to<=line.to&&Math.abs(gap.from-from)<1000/* HalfMargin */&&Math.abs(gap.to-to)<1000;}/* HalfMargin */)||new LineGap(from,to,_this119.gapSize(line,from,to,structure)));}};for(var _i173=0,_outside2=outside;_i173<_outside2.length;_i173++){_loop25();}});return gaps;}},{key:"gapSize",value:function gapSize(line,from,to,structure){var fraction=findFraction(structure,to)-findFraction(structure,from);if(this.heightOracle.lineWrapping){return line.height*fraction;}else{return structure.total*this.heightOracle.charWidth*fraction;}}},{key:"updateLineGaps",value:function updateLineGaps(gaps){var _this120=this;if(!LineGap.same(gaps,this.lineGaps)){this.lineGaps=gaps;this.lineGapDeco=Decoration.set(gaps.map(function(gap){return gap.draw(_this120.heightOracle.lineWrapping);}));}}},{key:"computeVisibleRanges",value:function computeVisibleRanges(){var deco=this.state.facet(decorations);if(this.lineGaps.length)deco=deco.concat(this.lineGapDeco);var ranges=[];rangeset.RangeSet.spans(deco,this.viewport.from,this.viewport.to,{span:function span(from,to){ranges.push({from:from,to:to});},point:function point(){}},20);var changed=ranges.length!=this.visibleRanges.length||this.visibleRanges.some(function(r,i){return r.from!=ranges[i].from||r.to!=ranges[i].to;});this.visibleRanges=ranges;return changed?4/* Viewport */:0;}},{key:"lineAt",value:function lineAt(pos,editorTop){editorTop+=this.paddingTop;return scaleBlock(this.heightMap.lineAt(pos,QueryType.ByPos,this.state.doc,editorTop,0),this.scaler,editorTop);}},{key:"lineAtHeight",value:function lineAtHeight(height,editorTop){editorTop+=this.paddingTop;return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height,editorTop),QueryType.ByHeight,this.state.doc,editorTop,0),this.scaler,editorTop);}},{key:"blockAtHeight",value:function blockAtHeight(height,editorTop){editorTop+=this.paddingTop;return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height,editorTop),this.state.doc,editorTop,0),this.scaler,editorTop);}},{key:"forEachLine",value:function forEachLine(from,to,f,editorTop){var _this121=this;editorTop+=this.paddingTop;return this.heightMap.forEachLine(from,to,this.state.doc,editorTop,0,this.scaler.scale==1?f:function(b){return f(scaleBlock(b,_this121.scaler,editorTop));});}},{key:"contentHeight",get:function get(){return this.domHeight+this.paddingTop+this.paddingBottom;}},{key:"domHeight",get:function get(){return this.scaler.toDOM(this.heightMap.height,this.paddingTop);}}]);return ViewState;}();var Viewport=/*#__PURE__*/_createClass(function Viewport(from,to){_classCallCheck(this,Viewport);this.from=from;this.to=to;});function lineStructure(from,to,state){var ranges=[],pos=from,total=0;rangeset.RangeSet.spans(state.facet(decorations),from,to,{span:function span(){},point:function point(from,to){if(from>pos){ranges.push({from:pos,to:from});total+=from-pos;}pos=to;}},20);// We're only interested in collapsed ranges of a significant size
41854185+if(pos<to){ranges.push({from:pos,to:to});total+=to-pos;}return{total:total,ranges:ranges};}function findPosition(_ref80,ratio){var total=_ref80.total,ranges=_ref80.ranges;if(ratio<=0)return ranges[0].from;if(ratio>=1)return ranges[ranges.length-1].to;var dist=Math.floor(total*ratio);for(var _i174=0;;_i174++){var _ranges$_i3=ranges[_i174],from=_ranges$_i3.from,to=_ranges$_i3.to,size=to-from;if(dist<=size)return from+dist;dist-=size;}}function findFraction(structure,pos){var counted=0;var _iterator230=_createForOfIteratorHelper(structure.ranges),_step230;try{for(_iterator230.s();!(_step230=_iterator230.n()).done;){var _step230$value=_step230.value,from=_step230$value.from,to=_step230$value.to;if(pos<=to){counted+=pos-from;break;}counted+=to-from;}}catch(err){_iterator230.e(err);}finally{_iterator230.f();}return counted/structure.total;}function cutRange(ranges,from,to){for(var _i175=0;_i175<ranges.length;_i175++){var _r7=ranges[_i175];if(_r7.from<to&&_r7.to>from){var pieces=[];if(_r7.from<from)pieces.push({from:_r7.from,to:from});if(_r7.to>to)pieces.push({from:to,to:_r7.to});ranges.splice.apply(ranges,[_i175,1].concat(pieces));_i175+=pieces.length-1;}}}function find(array,f){var _iterator231=_createForOfIteratorHelper(array),_step231;try{for(_iterator231.s();!(_step231=_iterator231.n()).done;){var val=_step231.value;if(f(val))return val;}}catch(err){_iterator231.e(err);}finally{_iterator231.f();}return undefined;}// Don't scale when the document height is within the range of what
41864186+// the DOM can handle.
41874187+var IdScaler={toDOM:function toDOM(n){return n;},fromDOM:function fromDOM(n){return n;},scale:1};// When the height is too big (> VP.MaxDOMHeight), scale down the
41884188+// regions outside the viewports so that the total height is
41894189+// VP.MaxDOMHeight.
41904190+var BigScaler=/*#__PURE__*/function(){function BigScaler(doc,heightMap,viewports){_classCallCheck(this,BigScaler);var vpHeight=0,base=0,domBase=0;this.viewports=viewports.map(function(_ref81){var from=_ref81.from,to=_ref81.to;var top=heightMap.lineAt(from,QueryType.ByPos,doc,0,0).top;var bottom=heightMap.lineAt(to,QueryType.ByPos,doc,0,0).bottom;vpHeight+=bottom-top;return{from:from,to:to,top:top,bottom:bottom,domTop:0,domBottom:0};});this.scale=(7000000/* MaxDOMHeight */-vpHeight)/(heightMap.height-vpHeight);var _iterator232=_createForOfIteratorHelper(this.viewports),_step232;try{for(_iterator232.s();!(_step232=_iterator232.n()).done;){var obj=_step232.value;obj.domTop=domBase+(obj.top-base)*this.scale;domBase=obj.domBottom=obj.domTop+(obj.bottom-obj.top);base=obj.bottom;}}catch(err){_iterator232.e(err);}finally{_iterator232.f();}}_createClass(BigScaler,[{key:"toDOM",value:function toDOM(n,top){n-=top;for(var _i176=0,base=0,domBase=0;;_i176++){var vp=_i176<this.viewports.length?this.viewports[_i176]:null;if(!vp||n<vp.top)return domBase+(n-base)*this.scale+top;if(n<=vp.bottom)return vp.domTop+(n-vp.top)+top;base=vp.bottom;domBase=vp.domBottom;}}},{key:"fromDOM",value:function fromDOM(n,top){n-=top;for(var _i177=0,base=0,domBase=0;;_i177++){var vp=_i177<this.viewports.length?this.viewports[_i177]:null;if(!vp||n<vp.domTop)return base+(n-domBase)/this.scale+top;if(n<=vp.domBottom)return vp.top+(n-vp.domTop)+top;base=vp.bottom;domBase=vp.domBottom;}}}]);return BigScaler;}();function scaleBlock(block,scaler,top){if(scaler.scale==1)return block;var bTop=scaler.toDOM(block.top,top),bBottom=scaler.toDOM(block.bottom,top);return new BlockInfo(block.from,block.length,bTop,bBottom-bTop,Array.isArray(block.type)?block.type.map(function(b){return scaleBlock(b,scaler,top);}):block.type);}var _theme2=state.Facet.define({combine:function combine(strs){return strs.join(" ");}});var darkTheme=state.Facet.define({combine:function combine(values){return values.indexOf(true)>-1;}});var baseThemeID=styleMod.StyleModule.newName(),baseLightID=styleMod.StyleModule.newName(),baseDarkID=styleMod.StyleModule.newName();var lightDarkIDs={"&light":"."+baseLightID,"&dark":"."+baseDarkID};function buildTheme(main,spec,scopes){return new styleMod.StyleModule(spec,{finish:function finish(sel){return /&/.test(sel)?sel.replace(/&\w*/,function(m){if(m=="&")return main;if(!scopes||!scopes[m])throw new RangeError("Unsupported selector: ".concat(m));return scopes[m];}):main+" "+sel;}});}var baseTheme=buildTheme("."+baseThemeID,{"&.cm-editor":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{// Provide a simple default outline to make sure a focused
41914191+// editor is visually distinct. Can't leave the default behavior
41924192+// because that will apply to the content element, which is
41934193+// inside the scrollable container and doesn't include the
41944194+// gutters. We also can't use an 'auto' outline, since those
41954195+// are, for some reason, drawn behind the element content, which
41964196+// will cause things like the active line background to cover
41974197+// the outline (#297).
41984198+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,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace:"pre-wrap",wordBreak:"break-word",overflowWrap:"anywhere"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},// Two animations defined so that we can switch between them to
41994199+// restart the animation without forcing another style
42004200+// recomputation.
42014201+"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none",display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-placeholder":{color:"#888",display:"inline-block"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"3px"},"&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"}},lightDarkIDs);var observeOptions={childList:true,characterData:true,subtree:true,attributes:true,characterDataOldValue:true};// IE11 has very broken mutation observers, so we also listen to
42024202+// DOMCharacterDataModified there
42034203+var useCharData=browser.ie&&browser.ie_version<=11;var DOMObserver=/*#__PURE__*/function(){function DOMObserver(view,onChange,onScrollChanged){var _this122=this;_classCallCheck(this,DOMObserver);this.view=view;this.onChange=onChange;this.onScrollChanged=onScrollChanged;this.active=false;this.ignoreSelection=new DOMSelection();this.delayedFlush=-1;this.queue=[];this.lastFlush=0;this.scrollTargets=[];this.intersection=null;this.intersecting=false;this.gapIntersection=null;this.gaps=[];// Used to work around a Safari Selection/shadow DOM bug (#414)
42044204+this._selectionRange=null;// Timeout for scheduling check of the parents that need scroll handlers
42054205+this.parentCheck=-1;this.dom=view.contentDOM;this.observer=new MutationObserver(function(mutations){var _iterator233=_createForOfIteratorHelper(mutations),_step233;try{for(_iterator233.s();!(_step233=_iterator233.n()).done;){var mut=_step233.value;_this122.queue.push(mut);}}catch(err){_iterator233.e(err);}finally{_iterator233.f();}_this122._selectionRange=null;// IE11 will sometimes (on typing over a selection or
42064206+// backspacing out a single character text node) call the
42074207+// observer callback before actually updating the DOM.
42084208+//
42094209+// Unrelatedly, iOS Safari will, when ending a composition,
42104210+// sometimes first clear it, deliver the mutations, and then
42114211+// reinsert the finished text. CodeMirror's handling of the
42124212+// deletion will prevent the reinsertion from happening,
42134213+// breaking composition.
42144214+if((browser.ie&&browser.ie_version<=11||browser.ios&&view.composing)&&mutations.some(function(m){return m.type=="childList"&&m.removedNodes.length||m.type=="characterData"&&m.oldValue.length>m.target.nodeValue.length;}))_this122.flushSoon();else _this122.flush();});if(useCharData)this.onCharData=function(event){_this122.queue.push({target:event.target,type:"characterData",oldValue:event.prevValue});_this122.flushSoon();};this.onSelectionChange=this.onSelectionChange.bind(this);this.start();this.onScroll=this.onScroll.bind(this);window.addEventListener("scroll",this.onScroll);if(typeof IntersectionObserver=="function"){this.intersection=new IntersectionObserver(function(entries){if(_this122.parentCheck<0)_this122.parentCheck=setTimeout(_this122.listenForScroll.bind(_this122),1000);if(entries.length>0&&entries[entries.length-1].intersectionRatio>0!=_this122.intersecting){_this122.intersecting=!_this122.intersecting;if(_this122.intersecting!=_this122.view.inView)_this122.onScrollChanged(document.createEvent("Event"));}},{});this.intersection.observe(this.dom);this.gapIntersection=new IntersectionObserver(function(entries){if(entries.length>0&&entries[entries.length-1].intersectionRatio>0)_this122.onScrollChanged(document.createEvent("Event"));},{});}this.listenForScroll();}_createClass(DOMObserver,[{key:"onScroll",value:function onScroll(e){if(this.intersecting)this.flush();this.onScrollChanged(e);}},{key:"updateGaps",value:function updateGaps(gaps){if(this.gapIntersection&&(gaps.length!=this.gaps.length||this.gaps.some(function(g,i){return g!=gaps[i];}))){this.gapIntersection.disconnect();var _iterator234=_createForOfIteratorHelper(gaps),_step234;try{for(_iterator234.s();!(_step234=_iterator234.n()).done;){var gap=_step234.value;this.gapIntersection.observe(gap);}}catch(err){_iterator234.e(err);}finally{_iterator234.f();}this.gaps=gaps;}}},{key:"onSelectionChange",value:function onSelectionChange(event){if(this.lastFlush<Date.now()-50)this._selectionRange=null;var view=this.view,sel=this.selectionRange;if(view.state.facet(editable)?view.root.activeElement!=this.dom:!hasSelection(view.dom,sel))return;var context=sel.anchorNode&&view.docView.nearest(sel.anchorNode);if(context&&context.ignoreEvent(event))return;// Deletions on IE11 fire their events in the wrong order, giving
42154215+// us a selection change event before the DOM changes are
42164216+// reported.
42174217+// (Selection.isCollapsed isn't reliable on IE)
42184218+if(browser.ie&&browser.ie_version<=11&&!view.state.selection.main.empty&&sel.focusNode&&isEquivalentPosition(sel.focusNode,sel.focusOffset,sel.anchorNode,sel.anchorOffset))this.flushSoon();else this.flush();}},{key:"selectionRange",get:function get(){if(!this._selectionRange){var root=this.view.root,sel=getSelection(root);// The Selection object is broken in shadow roots in Safari. See
42194219+// https://github.com/codemirror/codemirror.next/issues/414
42204220+if(browser.safari&&root.nodeType==11&&deepActiveElement()==this.view.contentDOM)sel=safariSelectionRangeHack(this.view)||sel;this._selectionRange=sel;}return this._selectionRange;}},{key:"setSelectionRange",value:function setSelectionRange(anchor,head){var _a;if(!((_a=this._selectionRange)===null||_a===void 0?void 0:_a.type))this._selectionRange={anchorNode:anchor.node,anchorOffset:anchor.offset,focusNode:head.node,focusOffset:head.offset};}},{key:"listenForScroll",value:function listenForScroll(){this.parentCheck=-1;var i=0,changed=null;for(var dom=this.dom;dom;){if(dom.nodeType==1){if(!changed&&i<this.scrollTargets.length&&this.scrollTargets[i]==dom)i++;else if(!changed)changed=this.scrollTargets.slice(0,i);if(changed)changed.push(dom);dom=dom.assignedSlot||dom.parentNode;}else if(dom.nodeType==11){// Shadow root
42214221+dom=dom.host;}else{break;}}if(i<this.scrollTargets.length&&!changed)changed=this.scrollTargets.slice(0,i);if(changed){var _iterator235=_createForOfIteratorHelper(this.scrollTargets),_step235;try{for(_iterator235.s();!(_step235=_iterator235.n()).done;){var _dom4=_step235.value;_dom4.removeEventListener("scroll",this.onScroll);}}catch(err){_iterator235.e(err);}finally{_iterator235.f();}var _iterator236=_createForOfIteratorHelper(this.scrollTargets=changed),_step236;try{for(_iterator236.s();!(_step236=_iterator236.n()).done;){var _dom5=_step236.value;_dom5.addEventListener("scroll",this.onScroll);}}catch(err){_iterator236.e(err);}finally{_iterator236.f();}}}},{key:"ignore",value:function ignore(f){if(!this.active)return f();try{this.stop();return f();}finally{this.start();this.clear();}}},{key:"start",value:function start(){if(this.active)return;this.observer.observe(this.dom,observeOptions);this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange);if(useCharData)this.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.active=true;}},{key:"stop",value:function stop(){if(!this.active)return;this.active=false;this.observer.disconnect();this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange);if(useCharData)this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData);}},{key:"clearSelection",value:function clearSelection(){this.ignoreSelection.set(this.selectionRange);}// Throw away any pending changes
42224222+},{key:"clear",value:function clear(){this.observer.takeRecords();this.queue.length=0;this.clearSelection();}},{key:"flushSoon",value:function flushSoon(){var _this123=this;if(this.delayedFlush<0)this.delayedFlush=window.setTimeout(function(){_this123.delayedFlush=-1;_this123.flush();},20);}},{key:"forceFlush",value:function forceFlush(){if(this.delayedFlush>=0){window.clearTimeout(this.delayedFlush);this.delayedFlush=-1;this.flush();}}},{key:"processRecords",value:function processRecords(){var records=this.queue;var _iterator237=_createForOfIteratorHelper(this.observer.takeRecords()),_step237;try{for(_iterator237.s();!(_step237=_iterator237.n()).done;){var mut=_step237.value;records.push(mut);}}catch(err){_iterator237.e(err);}finally{_iterator237.f();}if(records.length)this.queue=[];var from=-1,to=-1,typeOver=false;var _iterator238=_createForOfIteratorHelper(records),_step238;try{for(_iterator238.s();!(_step238=_iterator238.n()).done;){var record=_step238.value;var range=this.readMutation(record);if(!range)continue;if(range.typeOver)typeOver=true;if(from==-1){from=range.from;to=range.to;}else{from=Math.min(range.from,from);to=Math.max(range.to,to);}}}catch(err){_iterator238.e(err);}finally{_iterator238.f();}return{from:from,to:to,typeOver:typeOver};}// Apply pending changes, if any
42234223+},{key:"flush",value:function flush(){// Completely hold off flushing when pending keys are set—the code
42244224+// managing those will make sure processRecords is called and the
42254225+// view is resynchronized after
42264226+if(this.delayedFlush>=0||this.view.inputState.pendingAndroidKey)return;this.lastFlush=Date.now();var _this$processRecords2=this.processRecords(),from=_this$processRecords2.from,to=_this$processRecords2.to,typeOver=_this$processRecords2.typeOver;var selection=this.selectionRange;var newSel=!this.ignoreSelection.eq(selection)&&hasSelection(this.dom,selection);if(from<0&&!newSel)return;var startState=this.view.state;this.onChange(from,to,typeOver);// The view wasn't updated
42274227+if(this.view.state==startState)this.view.docView.reset(newSel);this.clearSelection();}},{key:"readMutation",value:function readMutation(rec){var cView=this.view.docView.nearest(rec.target);if(!cView||cView.ignoreMutation(rec))return null;cView.markDirty(rec.type=="attributes");if(rec.type=="attributes")cView.dirty|=4/* Attrs */;if(rec.type=="childList"){var childBefore=findChild(cView,rec.previousSibling||rec.target.previousSibling,-1);var childAfter=findChild(cView,rec.nextSibling||rec.target.nextSibling,1);return{from:childBefore?cView.posAfter(childBefore):cView.posAtStart,to:childAfter?cView.posBefore(childAfter):cView.posAtEnd,typeOver:false};}else if(rec.type=="characterData"){return{from:cView.posAtStart,to:cView.posAtEnd,typeOver:rec.target.nodeValue==rec.oldValue};}else{return null;}}},{key:"destroy",value:function destroy(){this.stop();if(this.intersection)this.intersection.disconnect();if(this.gapIntersection)this.gapIntersection.disconnect();var _iterator239=_createForOfIteratorHelper(this.scrollTargets),_step239;try{for(_iterator239.s();!(_step239=_iterator239.n()).done;){var dom=_step239.value;dom.removeEventListener("scroll",this.onScroll);}}catch(err){_iterator239.e(err);}finally{_iterator239.f();}window.removeEventListener("scroll",this.onScroll);clearTimeout(this.parentCheck);}}]);return DOMObserver;}();function findChild(cView,dom,dir){while(dom){var curView=ContentView.get(dom);if(curView&&curView.parent==cView)return curView;var parent=dom.parentNode;dom=parent!=cView.dom?parent:dir>0?dom.nextSibling:dom.previousSibling;}return null;}function safariSelectionRangeHack(view){var found=null;// Because Safari (at least in 2018-2021) doesn't provide regular
42284228+// access to the selection inside a shadowroot, we have to perform a
42294229+// ridiculous hack to get at it—using `execCommand` to trigger a
42304230+// `beforeInput` event so that we can read the target range from the
42314231+// event.
42324232+function read(event){event.preventDefault();event.stopImmediatePropagation();found=event.getTargetRanges()[0];}view.contentDOM.addEventListener("beforeinput",read,true);document.execCommand("indent");view.contentDOM.removeEventListener("beforeinput",read,true);if(!found)return null;var anchorNode=found.startContainer,anchorOffset=found.startOffset;var focusNode=found.endContainer,focusOffset=found.endOffset;var curAnchor=view.docView.domAtPos(view.state.selection.main.anchor);// Since such a range doesn't distinguish between anchor and head,
42334233+// use a heuristic that flips it around if its end matches the
42344234+// current anchor.
42354235+if(isEquivalentPosition(curAnchor.node,curAnchor.offset,focusNode,focusOffset)){var _ref82=[focusNode,focusOffset,anchorNode,anchorOffset];anchorNode=_ref82[0];anchorOffset=_ref82[1];focusNode=_ref82[2];focusOffset=_ref82[3];}return{anchorNode:anchorNode,anchorOffset:anchorOffset,focusNode:focusNode,focusOffset:focusOffset};}function applyDOMChange(view,start,end,typeOver){var change,newSel;var sel=view.state.selection.main;if(start>-1){var bounds=view.docView.domBoundsAround(start,end,0);if(!bounds||view.state.readOnly)return;var from=bounds.from,to=bounds.to;var selPoints=view.docView.impreciseHead||view.docView.impreciseAnchor?[]:selectionPoints(view);var reader=new DOMReader(selPoints,view);reader.readRange(bounds.startDOM,bounds.endDOM);newSel=selectionFromPoints(selPoints,from);var preferredPos=sel.from,preferredSide=null;// Prefer anchoring to end when Backspace is pressed (or, on
42364236+// Android, when something was deleted)
42374237+if(view.inputState.lastKeyCode===8&&view.inputState.lastKeyTime>Date.now()-100||browser.android&&reader.text.length<to-from){preferredPos=sel.to;preferredSide="end";}var diff=findDiff(view.state.sliceDoc(from,to),reader.text,preferredPos-from,preferredSide);if(diff)change={from:from+diff.from,to:from+diff.toA,insert:view.state.toText(reader.text.slice(diff.from,diff.toB))};}else if(view.hasFocus||!view.state.facet(editable)){var domSel=view.observer.selectionRange;var _view$docView2=view.docView,iHead=_view$docView2.impreciseHead,iAnchor=_view$docView2.impreciseAnchor;var head=iHead&&iHead.node==domSel.focusNode&&iHead.offset==domSel.focusOffset||!contains(view.contentDOM,domSel.focusNode)?view.state.selection.main.head:view.docView.posFromDOM(domSel.focusNode,domSel.focusOffset);var anchor=iAnchor&&iAnchor.node==domSel.anchorNode&&iAnchor.offset==domSel.anchorOffset||!contains(view.contentDOM,domSel.anchorNode)?view.state.selection.main.anchor:view.docView.posFromDOM(domSel.anchorNode,domSel.anchorOffset);if(head!=sel.head||anchor!=sel.anchor)newSel=state.EditorSelection.single(anchor,head);}if(!change&&!newSel)return;// Heuristic to notice typing over a selected character
42384238+if(!change&&typeOver&&!sel.empty&&newSel&&newSel.main.empty)change={from:sel.from,to:sel.to,insert:view.state.doc.slice(sel.from,sel.to)};// If the change is inside the selection and covers most of it,
42394239+// assume it is a selection replace (with identical characters at
42404240+// the start/end not included in the diff)
42414241+else if(change&&change.from>=sel.from&&change.to<=sel.to&&(change.from!=sel.from||change.to!=sel.to)&&sel.to-sel.from-(change.to-change.from)<=4)change={from:sel.from,to:sel.to,insert:view.state.doc.slice(sel.from,change.from).append(change.insert).append(view.state.doc.slice(change.to,sel.to))};if(change){var startState=view.state;// Android browsers don't fire reasonable key events for enter,
42424242+// backspace, or delete. So this detects changes that look like
42434243+// they're caused by those keys, and reinterprets them as key
42444244+// events.
42454245+if(browser.ios&&view.inputState.flushIOSKey(view))return;var _text4=change.insert.toString();if(view.state.facet(inputHandler).some(function(h){return h(view,change.from,change.to,_text4);}))return;if(view.inputState.composing>=0)view.inputState.composing++;var tr;if(change.from>=sel.from&&change.to<=sel.to&&change.to-change.from>=(sel.to-sel.from)/3&&(!newSel||newSel.main.empty&&newSel.main.from==change.from+change.insert.length)){var before=sel.from<change.from?startState.sliceDoc(sel.from,change.from):"";var after=sel.to>change.to?startState.sliceDoc(change.to,sel.to):"";tr=startState.replaceSelection(view.state.toText(before+change.insert.sliceString(0,undefined,view.state.lineBreak)+after));}else{var changes=startState.changes(change);tr={changes:changes,selection:newSel&&!startState.selection.main.eq(newSel.main)&&newSel.main.to<=changes.newLength?startState.selection.replaceRange(newSel.main):undefined};}var userEvent="input.type";if(view.composing){userEvent+=".compose";if(view.inputState.compositionFirstChange){userEvent+=".start";view.inputState.compositionFirstChange=false;}}view.dispatch(tr,{scrollIntoView:true,userEvent:userEvent});}else if(newSel&&!newSel.main.eq(sel)){var scrollIntoView=false,_userEvent2="select";if(view.inputState.lastSelectionTime>Date.now()-50){if(view.inputState.lastSelectionOrigin=="select")scrollIntoView=true;_userEvent2=view.inputState.lastSelectionOrigin;}view.dispatch({selection:newSel,scrollIntoView:scrollIntoView,userEvent:_userEvent2});}}function findDiff(a,b,preferredPos,preferredSide){var minLen=Math.min(a.length,b.length);var from=0;while(from<minLen&&a.charCodeAt(from)==b.charCodeAt(from)){from++;}if(from==minLen&&a.length==b.length)return null;var toA=a.length,toB=b.length;while(toA>0&&toB>0&&a.charCodeAt(toA-1)==b.charCodeAt(toB-1)){toA--;toB--;}if(preferredSide=="end"){var adjust=Math.max(0,from-Math.min(toA,toB));preferredPos-=toA+adjust-from;}if(toA<from&&a.length<b.length){var move=preferredPos<=from&&preferredPos>=toA?from-preferredPos:0;from-=move;toB=from+(toB-toA);toA=from;}else if(toB<from){var _move2=preferredPos<=from&&preferredPos>=toB?from-preferredPos:0;from-=_move2;toA=from+(toA-toB);toB=from;}return{from:from,toA:toA,toB:toB};}var DOMReader=/*#__PURE__*/function(){function DOMReader(points,view){_classCallCheck(this,DOMReader);this.points=points;this.view=view;this.text="";this.lineBreak=view.state.lineBreak;}_createClass(DOMReader,[{key:"readRange",value:function readRange(start,end){if(!start)return;var parent=start.parentNode;for(var cur=start;;){this.findPointBefore(parent,cur);this.readNode(cur);var next=cur.nextSibling;if(next==end)break;var view=ContentView.get(cur),nextView=ContentView.get(next);if(view&&nextView?view.breakAfter:(view?view.breakAfter:isBlockElement(cur))||isBlockElement(next)&&(cur.nodeName!="BR"||cur.cmIgnore))this.text+=this.lineBreak;cur=next;}this.findPointBefore(parent,end);}},{key:"readNode",value:function readNode(node){if(node.cmIgnore)return;var view=ContentView.get(node);var fromView=view&&view.overrideDOMText;var text;if(fromView!=null)text=fromView.sliceString(0,undefined,this.lineBreak);else if(node.nodeType==3)text=node.nodeValue;else if(node.nodeName=="BR")text=node.nextSibling?this.lineBreak:"";else if(node.nodeType==1)this.readRange(node.firstChild,null);if(text!=null){this.findPointIn(node,text.length);this.text+=text;// Chrome inserts two newlines when pressing shift-enter at the
42464246+// end of a line. This drops one of those.
42474247+if(browser.chrome&&this.view.inputState.lastKeyCode==13&&!node.nextSibling&&/\n\n$/.test(this.text))this.text=this.text.slice(0,-1);}}},{key:"findPointBefore",value:function findPointBefore(node,next){var _iterator240=_createForOfIteratorHelper(this.points),_step240;try{for(_iterator240.s();!(_step240=_iterator240.n()).done;){var point=_step240.value;if(point.node==node&&node.childNodes[point.offset]==next)point.pos=this.text.length;}}catch(err){_iterator240.e(err);}finally{_iterator240.f();}}},{key:"findPointIn",value:function findPointIn(node,maxLen){var _iterator241=_createForOfIteratorHelper(this.points),_step241;try{for(_iterator241.s();!(_step241=_iterator241.n()).done;){var point=_step241.value;if(point.node==node)point.pos=this.text.length+Math.min(point.offset,maxLen);}}catch(err){_iterator241.e(err);}finally{_iterator241.f();}}}]);return DOMReader;}();function isBlockElement(node){return node.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);}var DOMPoint=/*#__PURE__*/_createClass(function DOMPoint(node,offset){_classCallCheck(this,DOMPoint);this.node=node;this.offset=offset;this.pos=-1;});function selectionPoints(view){var result=[];if(view.root.activeElement!=view.contentDOM)return result;var _view$observer$select2=view.observer.selectionRange,anchorNode=_view$observer$select2.anchorNode,anchorOffset=_view$observer$select2.anchorOffset,focusNode=_view$observer$select2.focusNode,focusOffset=_view$observer$select2.focusOffset;if(anchorNode){result.push(new DOMPoint(anchorNode,anchorOffset));if(focusNode!=anchorNode||focusOffset!=anchorOffset)result.push(new DOMPoint(focusNode,focusOffset));}return result;}function selectionFromPoints(points,base){if(points.length==0)return null;var anchor=points[0].pos,head=points.length==2?points[1].pos:anchor;return anchor>-1&&head>-1?state.EditorSelection.single(anchor+base,head+base):null;}// The editor's update state machine looks something like this:
42484248+//
42494249+// Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
42504250+// ↑ ↓
42514251+// Updating (measure)
42524252+//
42534253+// The difference between 'Idle' and 'Idle (unchecked)' lies in
42544254+// whether a layout check has been scheduled. A regular update through
42554255+// the `update` method updates the DOM in a write-only fashion, and
42564256+// relies on a check (scheduled with `requestAnimationFrame`) to make
42574257+// sure everything is where it should be and the viewport covers the
42584258+// visible code. That check continues to measure and then optionally
42594259+// update until it reaches a coherent state.
42604260+/**
42614261+An editor view represents the editor's user interface. It holds
42624262+the editable DOM surface, and possibly other elements such as the
42634263+line number gutter. It handles events and dispatches state
42644264+transactions for editing actions.
42654265+*/var EditorView=/*#__PURE__*/function(){/**
42664266+ Construct a new view. You'll usually want to put `view.dom` into
42674267+ your document after creating a view, so that the user can see
42684268+ it.
42694269+ */function EditorView(){var _this124=this;var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,EditorView);this.plugins=[];this.editorAttrs={};this.contentAttrs={};this.bidiCache=[];this.destroyed=false;/**
42704270+ @internal
42714271+ */this.updateState=2/* Updating */;/**
42724272+ @internal
42734273+ */this.measureScheduled=-1;/**
42744274+ @internal
42754275+ */this.measureRequests=[];this.contentDOM=document.createElement("div");this.scrollDOM=document.createElement("div");this.scrollDOM.tabIndex=-1;this.scrollDOM.className="cm-scroller";this.scrollDOM.appendChild(this.contentDOM);this.announceDOM=document.createElement("div");this.announceDOM.style.cssText="position: absolute; top: -10000px";this.announceDOM.setAttribute("aria-live","polite");this.dom=document.createElement("div");this.dom.appendChild(this.announceDOM);this.dom.appendChild(this.scrollDOM);this._dispatch=config.dispatch||function(tr){return _this124.update([tr]);};this.dispatch=this.dispatch.bind(this);this.root=config.root||getRoot(config.parent)||document;this.viewState=new ViewState(config.state||state.EditorState.create());this.plugins=this.state.facet(viewPlugin).map(function(spec){return new PluginInstance(spec).update(_this124);});this.observer=new DOMObserver(this,function(from,to,typeOver){applyDOMChange(_this124,from,to,typeOver);},function(event){_this124.inputState.runScrollHandlers(_this124,event);if(_this124.observer.intersecting)_this124.measure();});this.inputState=new InputState(this);this.docView=new DocView(this);this.mountStyles();this.updateAttrs();this.updateState=0/* Idle */;ensureGlobalHandler();this.requestMeasure();if(config.parent)config.parent.appendChild(this.dom);}/**
42764276+ The current editor state.
42774277+ */_createClass(EditorView,[{key:"state",get:function get(){return this.viewState.state;}/**
42784278+ To be able to display large documents without consuming too much
42794279+ memory or overloading the browser, CodeMirror only draws the
42804280+ code that is visible (plus a margin around it) to the DOM. This
42814281+ property tells you the extent of the current drawn viewport, in
42824282+ document positions.
42834283+ */},{key:"viewport",get:function get(){return this.viewState.viewport;}/**
42844284+ When there are, for example, large collapsed ranges in the
42854285+ viewport, its size can be a lot bigger than the actual visible
42864286+ content. Thus, if you are doing something like styling the
42874287+ content in the viewport, it is preferable to only do so for
42884288+ these ranges, which are the subset of the viewport that is
42894289+ actually drawn.
42904290+ */},{key:"visibleRanges",get:function get(){return this.viewState.visibleRanges;}/**
42914291+ Returns false when the editor is entirely scrolled out of view
42924292+ or otherwise hidden.
42934293+ */},{key:"inView",get:function get(){return this.viewState.inView;}/**
42944294+ Indicates whether the user is currently composing text via
42954295+ [IME](https://en.wikipedia.org/wiki/Input_method).
42964296+ */},{key:"composing",get:function get(){return this.inputState.composing>0;}},{key:"dispatch",value:function dispatch(){var _this$state2;this._dispatch(arguments.length==1&&(arguments.length<=0?undefined:arguments[0])instanceof state.Transaction?arguments.length<=0?undefined:arguments[0]:(_this$state2=this.state).update.apply(_this$state2,arguments));}/**
42974297+ Update the view for the given array of transactions. This will
42984298+ update the visible document and selection to match the state
42994299+ produced by the transactions, and notify view plugins of the
43004300+ change. You should usually call
43014301+ [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
43024302+ as a primitive.
43034303+ */},{key:"update",value:function update(transactions){if(this.updateState!=0/* Idle */)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");var redrawn=false,update;var state$1=this.state;var _iterator242=_createForOfIteratorHelper(transactions),_step242;try{for(_iterator242.s();!(_step242=_iterator242.n()).done;){var _tr3=_step242.value;if(_tr3.startState!=state$1)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");state$1=_tr3.state;}}catch(err){_iterator242.e(err);}finally{_iterator242.f();}if(this.destroyed){this.viewState.state=state$1;return;}// When the phrases change, redraw the editor
43044304+if(state$1.facet(state.EditorState.phrases)!=this.state.facet(state.EditorState.phrases))return this.setState(state$1);update=new ViewUpdate(this,state$1,transactions);var scrollTarget=null;try{this.updateState=2/* Updating */;var _iterator243=_createForOfIteratorHelper(transactions),_step243;try{for(_iterator243.s();!(_step243=_iterator243.n()).done;){var tr=_step243.value;if(scrollTarget)scrollTarget=scrollTarget.map(tr.changes);if(tr.scrollIntoView){var main=tr.state.selection.main;scrollTarget=new ScrollTarget(main.empty?main:state.EditorSelection.cursor(main.head,main.head>main.anchor?-1:1));}var _iterator244=_createForOfIteratorHelper(tr.effects),_step244;try{for(_iterator244.s();!(_step244=_iterator244.n()).done;){var e=_step244.value;if(e.is(scrollTo))scrollTarget=new ScrollTarget(e.value);else if(e.is(centerOn))scrollTarget=new ScrollTarget(e.value,true);}}catch(err){_iterator244.e(err);}finally{_iterator244.f();}}}catch(err){_iterator243.e(err);}finally{_iterator243.f();}this.viewState.update(update,scrollTarget);this.bidiCache=CachedOrder.update(this.bidiCache,update.changes);if(!update.empty){this.updatePlugins(update);this.inputState.update(update);}redrawn=this.docView.update(update);if(this.state.facet(styleModule)!=this.styleModules)this.mountStyles();this.updateAttrs();this.showAnnouncements(transactions);}finally{this.updateState=0/* Idle */;}if(redrawn||scrollTarget||this.viewState.mustEnforceCursorAssoc)this.requestMeasure();if(!update.empty){var _iterator245=_createForOfIteratorHelper(this.state.facet(updateListener)),_step245;try{for(_iterator245.s();!(_step245=_iterator245.n()).done;){var listener=_step245.value;listener(update);}}catch(err){_iterator245.e(err);}finally{_iterator245.f();}}}/**
43054305+ Reset the view to the given state. (This will cause the entire
43064306+ document to be redrawn and all view plugins to be reinitialized,
43074307+ so you should probably only use it when the new state isn't
43084308+ derived from the old state. Otherwise, use
43094309+ [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
43104310+ */},{key:"setState",value:function setState(newState){var _this125=this;if(this.updateState!=0/* Idle */)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=newState;return;}this.updateState=2/* Updating */;try{var _iterator246=_createForOfIteratorHelper(this.plugins),_step246;try{for(_iterator246.s();!(_step246=_iterator246.n()).done;){var _plugin11=_step246.value;_plugin11.destroy(this);}}catch(err){_iterator246.e(err);}finally{_iterator246.f();}this.viewState=new ViewState(newState);this.plugins=newState.facet(viewPlugin).map(function(spec){return new PluginInstance(spec).update(_this125);});this.docView=new DocView(this);this.inputState.ensureHandlers(this);this.mountStyles();this.updateAttrs();this.bidiCache=[];}finally{this.updateState=0/* Idle */;}this.requestMeasure();}},{key:"updatePlugins",value:function updatePlugins(update){var prevSpecs=update.startState.facet(viewPlugin),specs=update.state.facet(viewPlugin);if(prevSpecs!=specs){var newPlugins=[];var _iterator247=_createForOfIteratorHelper(specs),_step247;try{for(_iterator247.s();!(_step247=_iterator247.n()).done;){var spec=_step247.value;var found=prevSpecs.indexOf(spec);if(found<0){newPlugins.push(new PluginInstance(spec));}else{var _plugin12=this.plugins[found];_plugin12.mustUpdate=update;newPlugins.push(_plugin12);}}}catch(err){_iterator247.e(err);}finally{_iterator247.f();}var _iterator248=_createForOfIteratorHelper(this.plugins),_step248;try{for(_iterator248.s();!(_step248=_iterator248.n()).done;){var _plugin13=_step248.value;if(_plugin13.mustUpdate!=update)_plugin13.destroy(this);}}catch(err){_iterator248.e(err);}finally{_iterator248.f();}this.plugins=newPlugins;this.inputState.ensureHandlers(this);}else{var _iterator249=_createForOfIteratorHelper(this.plugins),_step249;try{for(_iterator249.s();!(_step249=_iterator249.n()).done;){var _p4=_step249.value;_p4.mustUpdate=update;}}catch(err){_iterator249.e(err);}finally{_iterator249.f();}}for(var _i178=0;_i178<this.plugins.length;_i178++){this.plugins[_i178]=this.plugins[_i178].update(this);}}/**
43114311+ @internal
43124312+ */},{key:"measure",value:function measure(){var _this126=this;var flush=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;if(this.destroyed)return;if(this.measureScheduled>-1)cancelAnimationFrame(this.measureScheduled);this.measureScheduled=-1;// Prevent requestMeasure calls from scheduling another animation frame
43134313+if(flush)this.observer.flush();var updated=null;try{for(var _i179=0;;_i179++){this.updateState=1/* Measuring */;var oldViewport=this.viewport;var changed=this.viewState.measure(this.docView,_i179>0);if(!changed&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(_i179>5){console.warn("Viewport failed to stabilize");break;}var measuring=[];// Only run measure requests in this cycle when the viewport didn't change
43144314+if(!(changed&4/* Viewport */)){var _ref83=[measuring,this.measureRequests];this.measureRequests=_ref83[0];measuring=_ref83[1];}var measured=measuring.map(function(m){try{return m.read(_this126);}catch(e){logException(_this126.state,e);return BadMeasure;}});var update=new ViewUpdate(this,this.state);update.flags|=changed;if(!updated)updated=update;else updated.flags|=changed;this.updateState=2/* Updating */;if(!update.empty){this.updatePlugins(update);this.inputState.update(update);}this.updateAttrs();if(changed)this.docView.update(update);for(var _i180=0;_i180<measuring.length;_i180++){if(measured[_i180]!=BadMeasure){try{measuring[_i180].write(measured[_i180],this);}catch(e){logException(this.state,e);}}}if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget);this.viewState.scrollTarget=null;}if(this.viewport.from==oldViewport.from&&this.viewport.to==oldViewport.to&&this.measureRequests.length==0)break;}}finally{this.updateState=0/* Idle */;}this.measureScheduled=-1;if(updated&&!updated.empty){var _iterator250=_createForOfIteratorHelper(this.state.facet(updateListener)),_step250;try{for(_iterator250.s();!(_step250=_iterator250.n()).done;){var listener=_step250.value;listener(updated);}}catch(err){_iterator250.e(err);}finally{_iterator250.f();}}}/**
43154315+ Get the CSS classes for the currently active editor themes.
43164316+ */},{key:"themeClasses",get:function get(){return baseThemeID+" "+(this.state.facet(darkTheme)?baseDarkID:baseLightID)+" "+this.state.facet(_theme2);}},{key:"updateAttrs",value:function updateAttrs(){var editorAttrs=combineAttrs(this.state.facet(editorAttributes),{"class":"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses});_updateAttrs2(this.dom,this.editorAttrs,editorAttrs);this.editorAttrs=editorAttrs;var contentAttrs={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:!this.state.facet(editable)?"false":"true","class":"cm-content",style:"".concat(browser.tabSize,": ").concat(this.state.tabSize),role:"textbox","aria-multiline":"true"};if(this.state.readOnly)contentAttrs["aria-readonly"]="true";combineAttrs(this.state.facet(contentAttributes),contentAttrs);_updateAttrs2(this.contentDOM,this.contentAttrs,contentAttrs);this.contentAttrs=contentAttrs;}},{key:"showAnnouncements",value:function showAnnouncements(trs){var first=true;var _iterator251=_createForOfIteratorHelper(trs),_step251;try{for(_iterator251.s();!(_step251=_iterator251.n()).done;){var tr=_step251.value;var _iterator252=_createForOfIteratorHelper(tr.effects),_step252;try{for(_iterator252.s();!(_step252=_iterator252.n()).done;){var effect=_step252.value;if(effect.is(EditorView.announce)){if(first)this.announceDOM.textContent="";first=false;var div=this.announceDOM.appendChild(document.createElement("div"));div.textContent=effect.value;}}}catch(err){_iterator252.e(err);}finally{_iterator252.f();}}}catch(err){_iterator251.e(err);}finally{_iterator251.f();}}},{key:"mountStyles",value:function mountStyles(){this.styleModules=this.state.facet(styleModule);styleMod.StyleModule.mount(this.root,this.styleModules.concat(baseTheme).reverse());}},{key:"readMeasured",value:function readMeasured(){if(this.updateState==2/* Updating */)throw new Error("Reading the editor layout isn't allowed during an update");if(this.updateState==0/* Idle */&&this.measureScheduled>-1)this.measure(false);}/**
43174317+ Schedule a layout measurement, optionally providing callbacks to
43184318+ do custom DOM measuring followed by a DOM write phase. Using
43194319+ this is preferable reading DOM layout directly from, for
43204320+ example, an event handler, because it'll make sure measuring and
43214321+ drawing done by other components is synchronized, avoiding
43224322+ unnecessary DOM layout computations.
43234323+ */},{key:"requestMeasure",value:function requestMeasure(request){var _this127=this;if(this.measureScheduled<0)this.measureScheduled=requestAnimationFrame(function(){return _this127.measure();});if(request){if(request.key!=null)for(var _i181=0;_i181<this.measureRequests.length;_i181++){if(this.measureRequests[_i181].key===request.key){this.measureRequests[_i181]=request;return;}}this.measureRequests.push(request);}}/**
43244324+ Collect all values provided by the active plugins for a given
43254325+ field.
43264326+ */},{key:"pluginField",value:function pluginField(field){var result=[];var _iterator253=_createForOfIteratorHelper(this.plugins),_step253;try{for(_iterator253.s();!(_step253=_iterator253.n()).done;){var _plugin14=_step253.value;_plugin14.update(this).takeField(field,result);}}catch(err){_iterator253.e(err);}finally{_iterator253.f();}return result;}/**
43274327+ Get the value of a specific plugin, if present. Note that
43284328+ plugins that crash can be dropped from a view, so even when you
43294329+ know you registered a given plugin, it is recommended to check
43304330+ the return value of this method.
43314331+ */},{key:"plugin",value:function plugin(_plugin10){var _iterator254=_createForOfIteratorHelper(this.plugins),_step254;try{for(_iterator254.s();!(_step254=_iterator254.n()).done;){var inst=_step254.value;if(inst.spec==_plugin10)return inst.update(this).value;}}catch(err){_iterator254.e(err);}finally{_iterator254.f();}return null;}/**
43324332+ Find the line or block widget at the given vertical position.
43334333+43344334+ By default, this position is interpreted as a screen position,
43354335+ meaning `docTop` is set to the DOM top position of the editor
43364336+ content (forcing a layout). You can pass a different `docTop`
43374337+ value—for example 0 to interpret `height` as a document-relative
43384338+ position, or a precomputed document top
43394339+ (`view.contentDOM.getBoundingClientRect().top`) to limit layout
43404340+ queries.
43414341+ */},{key:"blockAtHeight",value:function blockAtHeight(height,docTop){this.readMeasured();return this.viewState.blockAtHeight(height,ensureTop(docTop,this.contentDOM));}/**
43424342+ Find information for the visual line (see
43434343+ [`visualLineAt`](https://codemirror.net/6/docs/ref/#view.EditorView.visualLineAt)) at the given
43444344+ vertical position. The resulting block info might hold another
43454345+ array of block info structs in its `type` field if this line
43464346+ consists of more than one block.
43474347+43484348+ Defaults to treating `height` as a screen position. See
43494349+ [`blockAtHeight`](https://codemirror.net/6/docs/ref/#view.EditorView.blockAtHeight) for the
43504350+ interpretation of the `docTop` parameter.
43514351+ */},{key:"visualLineAtHeight",value:function visualLineAtHeight(height,docTop){this.readMeasured();return this.viewState.lineAtHeight(height,ensureTop(docTop,this.contentDOM));}/**
43524352+ Iterate over the height information of the visual lines in the
43534353+ viewport. The heights of lines are reported relative to the
43544354+ given document top, which defaults to the screen position of the
43554355+ document (forcing a layout).
43564356+ */},{key:"viewportLines",value:function viewportLines(f,docTop){var _this$viewport=this.viewport,from=_this$viewport.from,to=_this$viewport.to;this.viewState.forEachLine(from,to,f,ensureTop(docTop,this.contentDOM));}/**
43574357+ Find the extent and height of the visual line (a range delimited
43584358+ on both sides by either non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^range)
43594359+ line breaks, or the start/end of the document) at the given position.
43604360+43614361+ Vertical positions are computed relative to the `docTop`
43624362+ argument, which defaults to 0 for this method. You can pass
43634363+ `view.contentDOM.getBoundingClientRect().top` here to get screen
43644364+ coordinates.
43654365+ */},{key:"visualLineAt",value:function visualLineAt(pos){var docTop=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return this.viewState.lineAt(pos,docTop);}/**
43664366+ The editor's total content height.
43674367+ */},{key:"contentHeight",get:function get(){return this.viewState.contentHeight;}/**
43684368+ Move a cursor position by [grapheme
43694369+ cluster](https://codemirror.net/6/docs/ref/#text.findClusterBreak). `forward` determines whether
43704370+ the motion is away from the line start, or towards it. Motion in
43714371+ bidirectional text is in visual order, in the editor's [text
43724372+ direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). When the start
43734373+ position was the last one on the line, the returned position
43744374+ will be across the line break. If there is no further line, the
43754375+ original position is returned.
43764376+43774377+ By default, this method moves over a single cluster. The
43784378+ optional `by` argument can be used to move across more. It will
43794379+ be called with the first cluster as argument, and should return
43804380+ a predicate that determines, for each subsequent cluster,
43814381+ whether it should also be moved over.
43824382+ */},{key:"moveByChar",value:function moveByChar(start,forward,by){return skipAtoms(this,start,_moveByChar2(this,start,forward,by));}/**
43834383+ Move a cursor position across the next group of either
43844384+ [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
43854385+ non-whitespace characters.
43864386+ */},{key:"moveByGroup",value:function moveByGroup(start,forward){var _this128=this;return skipAtoms(this,start,_moveByChar2(this,start,forward,function(initial){return byGroup(_this128,start.head,initial);}));}/**
43874387+ Move to the next line boundary in the given direction. If
43884388+ `includeWrap` is true, line wrapping is on, and there is a
43894389+ further wrap point on the current line, the wrap point will be
43904390+ returned. Otherwise this function will return the start or end
43914391+ of the line.
43924392+ */},{key:"moveToLineBoundary",value:function moveToLineBoundary(start,forward){var includeWrap=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return _moveToLineBoundary2(this,start,forward,includeWrap);}/**
43934393+ Move a cursor position vertically. When `distance` isn't given,
43944394+ it defaults to moving to the next line (including wrapped
43954395+ lines). Otherwise, `distance` should provide a positive distance
43964396+ in pixels.
43974397+43984398+ When `start` has a
43994399+ [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
44004400+ motion will use that as a target horizontal position. Otherwise,
44014401+ the cursor's own horizontal position is used. The returned
44024402+ cursor will have its goal column set to whichever column was
44034403+ used.
44044404+ */},{key:"moveVertically",value:function moveVertically(start,forward,distance){return skipAtoms(this,start,_moveVertically2(this,start,forward,distance));}// FIXME remove on next major version
44054405+},{key:"scrollPosIntoView",value:function scrollPosIntoView(pos){this.dispatch({effects:scrollTo.of(state.EditorSelection.cursor(pos))});}/**
44064406+ Find the DOM parent node and offset (child offset if `node` is
44074407+ an element, character offset when it is a text node) at the
44084408+ given document position.
44094409+ */},{key:"domAtPos",value:function domAtPos(pos){return this.docView.domAtPos(pos);}/**
44104410+ Find the document position at the given DOM node. Can be useful
44114411+ for associating positions with DOM events. Will raise an error
44124412+ when `node` isn't part of the editor content.
44134413+ */},{key:"posAtDOM",value:function posAtDOM(node){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return this.docView.posFromDOM(node,offset);}},{key:"posAtCoords",value:function posAtCoords(coords){var precise=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;this.readMeasured();return _posAtCoords2(this,coords,precise);}/**
44144414+ Get the screen coordinates at the given document position.
44154415+ `side` determines whether the coordinates are based on the
44164416+ element before (-1) or after (1) the position (if no element is
44174417+ available on the given side, the method will transparently use
44184418+ another strategy to get reasonable coordinates).
44194419+ */},{key:"coordsAtPos",value:function coordsAtPos(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;this.readMeasured();var rect=this.docView.coordsAt(pos,side);if(!rect||rect.left==rect.right)return rect;var line=this.state.doc.lineAt(pos),order=this.bidiSpans(line);var span=order[BidiSpan.find(order,pos-line.from,-1,side)];return flattenRect(rect,span.dir==exports.Direction.LTR==side>0);}/**
44204420+ The default width of a character in the editor. May not
44214421+ accurately reflect the width of all characters (given variable
44224422+ width fonts or styling of invididual ranges).
44234423+ */},{key:"defaultCharacterWidth",get:function get(){return this.viewState.heightOracle.charWidth;}/**
44244424+ The default height of a line in the editor. May not be accurate
44254425+ for all lines.
44264426+ */},{key:"defaultLineHeight",get:function get(){return this.viewState.heightOracle.lineHeight;}/**
44274427+ The text direction
44284428+ ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
44294429+ CSS property) of the editor.
44304430+ */},{key:"textDirection",get:function get(){return this.viewState.heightOracle.direction;}/**
44314431+ Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
44324432+ (as determined by the
44334433+ [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
44344434+ CSS property of its content element).
44354435+ */},{key:"lineWrapping",get:function get(){return this.viewState.heightOracle.lineWrapping;}/**
44364436+ Returns the bidirectional text structure of the given line
44374437+ (which should be in the current document) as an array of span
44384438+ objects. The order of these spans matches the [text
44394439+ direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
44404440+ left-to-right, the leftmost spans come first, otherwise the
44414441+ rightmost spans come first.
44424442+ */},{key:"bidiSpans",value:function bidiSpans(line){if(line.length>MaxBidiLine)return trivialOrder(line.length);var dir=this.textDirection;var _iterator255=_createForOfIteratorHelper(this.bidiCache),_step255;try{for(_iterator255.s();!(_step255=_iterator255.n()).done;){var entry=_step255.value;if(entry.from==line.from&&entry.dir==dir)return entry.order;}}catch(err){_iterator255.e(err);}finally{_iterator255.f();}var order=computeOrder(line.text,this.textDirection);this.bidiCache.push(new CachedOrder(line.from,line.to,dir,order));return order;}/**
44434443+ Check whether the editor has focus.
44444444+ */},{key:"hasFocus",get:function get(){var _a;// Safari return false for hasFocus when the context menu is open
44454445+// or closing, which leads us to ignore selection changes from the
44464446+// context menu because it looks like the editor isn't focused.
44474447+// This kludges around that.
44484448+return(document.hasFocus()||browser.safari&&((_a=this.inputState)===null||_a===void 0?void 0:_a.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM;}/**
44494449+ Put focus on the editor.
44504450+ */},{key:"focus",value:function focus(){var _this129=this;this.observer.ignore(function(){focusPreventScroll(_this129.contentDOM);_this129.docView.updateSelection();});}/**
44514451+ Clean up this editor view, removing its element from the
44524452+ document, unregistering event handlers, and notifying
44534453+ plugins. The view instance can no longer be used after
44544454+ calling this.
44554455+ */},{key:"destroy",value:function destroy(){var _iterator256=_createForOfIteratorHelper(this.plugins),_step256;try{for(_iterator256.s();!(_step256=_iterator256.n()).done;){var _plugin15=_step256.value;_plugin15.destroy(this);}}catch(err){_iterator256.e(err);}finally{_iterator256.f();}this.plugins=[];this.inputState.destroy();this.dom.remove();this.observer.destroy();if(this.measureScheduled>-1)cancelAnimationFrame(this.measureScheduled);this.destroyed=true;}/**
44564456+ Facet that can be used to add DOM event handlers. The value
44574457+ should be an object mapping event names to handler functions. The
44584458+ first such function to return true will be assumed to have handled
44594459+ that event, and no other handlers or built-in behavior will be
44604460+ activated for it.
44614461+ These are registered on the [content
44624462+ element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except for `scroll`
44634463+ handlers, which will be called any time the editor's [scroll
44644464+ element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of its parent nodes
44654465+ is scrolled.
44664466+ */}],[{key:"domEventHandlers",value:function domEventHandlers(handlers){return ViewPlugin.define(function(){return{};},{eventHandlers:handlers});}/**
44674467+ Create a theme extension. The first argument can be a
44684468+ [`style-mod`](https://github.com/marijnh/style-mod#documentation)
44694469+ style spec providing the styles for the theme. These will be
44704470+ prefixed with a generated class for the style.
44714471+44724472+ Because the selectors will be prefixed with a scope class, rule
44734473+ that directly match the editor's [wrapper
44744474+ element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
44754475+ added—need to be explicitly differentiated by adding an `&` to
44764476+ the selector for that element—for example
44774477+ `&.cm-focused`.
44784478+44794479+ When `dark` is set to true, the theme will be marked as dark,
44804480+ which will cause the `&dark` rules from [base
44814481+ themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
44824482+ `&light` when a light theme is active).
44834483+ */},{key:"theme",value:function theme(spec,options){var prefix=styleMod.StyleModule.newName();var result=[_theme2.of(prefix),styleModule.of(buildTheme(".".concat(prefix),spec))];if(options&&options.dark)result.push(darkTheme.of(true));return result;}/**
44844484+ Create an extension that adds styles to the base theme. Like
44854485+ with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
44864486+ place of the editor wrapper element when directly targeting
44874487+ that. You can also use `&dark` or `&light` instead to only
44884488+ target editors with a dark or light theme.
44894489+ */},{key:"baseTheme",value:function baseTheme(spec){return state.Prec.lowest(styleModule.of(buildTheme("."+baseThemeID,spec,lightDarkIDs)));}}]);return EditorView;}();/**
44904490+Effect that can be [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a
44914491+transaction to make it scroll the given range into view.
44924492+*/EditorView.scrollTo=scrollTo;/**
44934493+Effect that makes the editor scroll the given range to the
44944494+center of the visible view.
44954495+*/EditorView.centerOn=centerOn;/**
44964496+Facet to add a [style
44974497+module](https://github.com/marijnh/style-mod#documentation) to
44984498+an editor view. The view will ensure that the module is
44994499+mounted in its [document
45004500+root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
45014501+*/EditorView.styleModule=styleModule;/**
45024502+An input handler can override the way changes to the editable
45034503+DOM content are handled. Handlers are passed the document
45044504+positions between which the change was found, and the new
45054505+content. When one returns true, no further input handlers are
45064506+called and the default behavior is prevented.
45074507+*/EditorView.inputHandler=inputHandler;/**
45084508+Allows you to provide a function that should be called when the
45094509+library catches an exception from an extension (mostly from view
45104510+plugins, but may be used by other extensions to route exceptions
45114511+from user-code-provided callbacks). This is mostly useful for
45124512+debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
45134513+*/EditorView.exceptionSink=exceptionSink;/**
45144514+A facet that can be used to register a function to be called
45154515+every time the view updates.
45164516+*/EditorView.updateListener=updateListener;/**
45174517+Facet that controls whether the editor content DOM is editable.
45184518+When its highest-precedence value is `false`, the element will
45194519+not longer have its `contenteditable` attribute set. (Note that
45204520+this doesn't affect API calls that change the editor content,
45214521+even when those are bound to keys or buttons. See the
45224522+[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
45234523+*/EditorView.editable=editable;/**
45244524+Allows you to influence the way mouse selection happens. The
45254525+functions in this facet will be called for a `mousedown` event
45264526+on the editor, and can return an object that overrides the way a
45274527+selection is computed from that mouse click or drag.
45284528+*/EditorView.mouseSelectionStyle=mouseSelectionStyle;/**
45294529+Facet used to configure whether a given selection drag event
45304530+should move or copy the selection. The given predicate will be
45314531+called with the `mousedown` event, and can return `true` when
45324532+the drag should move the content.
45334533+*/EditorView.dragMovesSelection=dragMovesSelection$1;/**
45344534+Facet used to configure whether a given selecting click adds
45354535+a new range to the existing selection or replaces it entirely.
45364536+*/EditorView.clickAddsSelectionRange=clickAddsSelectionRange;/**
45374537+A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
45384538+are shown in the view. See also [view
45394539+plugins](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), which have a separate
45404540+mechanism for providing decorations.
45414541+*/EditorView.decorations=decorations;/**
45424542+Facet that provides additional DOM attributes for the editor's
45434543+editable DOM element.
45444544+*/EditorView.contentAttributes=contentAttributes;/**
45454545+Facet that provides DOM attributes for the editor's outer
45464546+element.
45474547+*/EditorView.editorAttributes=editorAttributes;/**
45484548+An extension that enables line wrapping in the editor (by
45494549+setting CSS `white-space` to `pre-wrap` in the content).
45504550+*/EditorView.lineWrapping=EditorView.contentAttributes.of({"class":"cm-lineWrapping"});/**
45514551+State effect used to include screen reader announcements in a
45524552+transaction. These will be added to the DOM in a visually hidden
45534553+element with `aria-live="polite"` set, and should be used to
45544554+describe effects that are visually obvious but may not be
45554555+noticed by screen reader users (such as moving to the next
45564556+search match).
45574557+*/EditorView.announce=state.StateEffect.define();// Maximum line length for which we compute accurate bidi info
45584558+var MaxBidiLine=4096;function ensureTop(given,dom){return given==null?dom.getBoundingClientRect().top:given;}var resizeDebounce=-1;function ensureGlobalHandler(){window.addEventListener("resize",function(){if(resizeDebounce==-1)resizeDebounce=setTimeout(handleResize,50);});}function handleResize(){resizeDebounce=-1;var found=document.querySelectorAll(".cm-content");for(var _i182=0;_i182<found.length;_i182++){var docView=ContentView.get(found[_i182]);if(docView)docView.editorView.requestMeasure();}}var BadMeasure={};var CachedOrder=/*#__PURE__*/function(){function CachedOrder(from,to,dir,order){_classCallCheck(this,CachedOrder);this.from=from;this.to=to;this.dir=dir;this.order=order;}_createClass(CachedOrder,null,[{key:"update",value:function update(cache,changes){if(changes.empty)return cache;var result=[],lastDir=cache.length?cache[cache.length-1].dir:exports.Direction.LTR;for(var _i183=Math.max(0,cache.length-10);_i183<cache.length;_i183++){var entry=cache[_i183];if(entry.dir==lastDir&&!changes.touchesRange(entry.from,entry.to))result.push(new CachedOrder(changes.mapPos(entry.from,1),changes.mapPos(entry.to,-1),entry.dir,entry.order));}return result;}}]);return CachedOrder;}();var currentPlatform=browser.mac?"mac":browser.windows?"win":browser.linux?"linux":"key";function normalizeKeyName(name,platform){var parts=name.split(/-(?!$)/);var result=parts[parts.length-1];if(result=="Space")result=" ";var alt,ctrl,shift,meta;for(var _i184=0;_i184<parts.length-1;++_i184){var mod=parts[_i184];if(/^(cmd|meta|m)$/i.test(mod))meta=true;else if(/^a(lt)?$/i.test(mod))alt=true;else if(/^(c|ctrl|control)$/i.test(mod))ctrl=true;else if(/^s(hift)?$/i.test(mod))shift=true;else if(/^mod$/i.test(mod)){if(platform=="mac")meta=true;else ctrl=true;}else throw new Error("Unrecognized modifier name: "+mod);}if(alt)result="Alt-"+result;if(ctrl)result="Ctrl-"+result;if(meta)result="Meta-"+result;if(shift)result="Shift-"+result;return result;}function modifiers(name,event,shift){if(event.altKey)name="Alt-"+name;if(event.ctrlKey)name="Ctrl-"+name;if(event.metaKey)name="Meta-"+name;if(shift!==false&&event.shiftKey)name="Shift-"+name;return name;}var handleKeyEvents=EditorView.domEventHandlers({keydown:function keydown(event,view){return runHandlers(getKeymap(view.state),event,view,"editor");}});/**
45594559+Facet used for registering keymaps.
45604560+45614561+You can add multiple keymaps to an editor. Their priorities
45624562+determine their precedence (the ones specified early or with high
45634563+priority get checked first). When a handler has returned `true`
45644564+for a given key, no further handlers are called.
45654565+*/var keymap=state.Facet.define({enables:handleKeyEvents});var Keymaps=new WeakMap();// This is hidden behind an indirection, rather than directly computed
45664566+// by the facet, to keep internal types out of the facet's type.
45674567+function getKeymap(state){var bindings=state.facet(keymap);var map=Keymaps.get(bindings);if(!map)Keymaps.set(bindings,map=buildKeymap(bindings.reduce(function(a,b){return a.concat(b);},[])));return map;}/**
45684568+Run the key handlers registered for a given scope. The event
45694569+object should be `"keydown"` event. Returns true if any of the
45704570+handlers handled it.
45714571+*/function runScopeHandlers(view,event,scope){return runHandlers(getKeymap(view.state),event,view,scope);}var storedPrefix=null;var PrefixTimeout=4000;function buildKeymap(bindings){var platform=arguments.length>1&&arguments[1]!==undefined?arguments[1]:currentPlatform;var bound=Object.create(null);var isPrefix=Object.create(null);var checkPrefix=function checkPrefix(name,is){var current=isPrefix[name];if(current==null)isPrefix[name]=is;else if(current!=is)throw new Error("Key binding "+name+" is used both as a regular binding and as a multi-stroke prefix");};var add=function add(scope,key,command,preventDefault){var scopeObj=bound[scope]||(bound[scope]=Object.create(null));var parts=key.split(/ (?!$)/).map(function(k){return normalizeKeyName(k,platform);});var _loop26=function _loop26(_i185){var prefix=parts.slice(0,_i185).join(" ");checkPrefix(prefix,true);if(!scopeObj[prefix])scopeObj[prefix]={preventDefault:true,commands:[function(view){var ourObj=storedPrefix={view:view,prefix:prefix,scope:scope};setTimeout(function(){if(storedPrefix==ourObj)storedPrefix=null;},PrefixTimeout);return true;}]};};for(var _i185=1;_i185<parts.length;_i185++){_loop26(_i185);}var full=parts.join(" ");checkPrefix(full,false);var binding=scopeObj[full]||(scopeObj[full]={preventDefault:false,commands:[]});binding.commands.push(command);if(preventDefault)binding.preventDefault=true;};var _iterator257=_createForOfIteratorHelper(bindings),_step257;try{for(_iterator257.s();!(_step257=_iterator257.n()).done;){var b=_step257.value;var name=b[platform]||b.key;if(!name)continue;var _iterator258=_createForOfIteratorHelper(b.scope?b.scope.split(" "):["editor"]),_step258;try{for(_iterator258.s();!(_step258=_iterator258.n()).done;){var scope=_step258.value;add(scope,name,b.run,b.preventDefault);if(b.shift)add(scope,"Shift-"+name,b.shift,b.preventDefault);}}catch(err){_iterator258.e(err);}finally{_iterator258.f();}}}catch(err){_iterator257.e(err);}finally{_iterator257.f();}return bound;}function runHandlers(map,event,view,scope){var name=w3cKeyname.keyName(event),isChar=name.length==1&&name!=" ";var prefix="",fallthrough=false;if(storedPrefix&&storedPrefix.view==view&&storedPrefix.scope==scope){prefix=storedPrefix.prefix+" ";if(fallthrough=modifierCodes.indexOf(event.keyCode)<0)storedPrefix=null;}var runFor=function runFor(binding){if(binding){var _iterator259=_createForOfIteratorHelper(binding.commands),_step259;try{for(_iterator259.s();!(_step259=_iterator259.n()).done;){var cmd=_step259.value;if(cmd(view))return true;}}catch(err){_iterator259.e(err);}finally{_iterator259.f();}if(binding.preventDefault)fallthrough=true;}return false;};var scopeObj=map[scope],baseName;if(scopeObj){if(runFor(scopeObj[prefix+modifiers(name,event,!isChar)]))return true;if(isChar&&(event.shiftKey||event.altKey||event.metaKey)&&(baseName=w3cKeyname.base[event.keyCode])&&baseName!=name){if(runFor(scopeObj[prefix+modifiers(baseName,event,true)]))return true;}else if(isChar&&event.shiftKey){if(runFor(scopeObj[prefix+modifiers(name,event,true)]))return true;}}return fallthrough;}var CanHidePrimary=!browser.ios;// FIXME test IE
45724572+var selectionConfig=state.Facet.define({combine:function combine(configs){return state.combineConfig(configs,{cursorBlinkRate:1200,drawRangeCursor:true},{cursorBlinkRate:function cursorBlinkRate(a,b){return Math.min(a,b);},drawRangeCursor:function drawRangeCursor(a,b){return a||b;}});}});/**
45734573+Returns an extension that hides the browser's native selection and
45744574+cursor, replacing the selection with a background behind the text
45754575+(with the `cm-selectionBackground` class), and the
45764576+cursors with elements overlaid over the code (using
45774577+`cm-cursor-primary` and `cm-cursor-secondary`).
45784578+45794579+This allows the editor to display secondary selection ranges, and
45804580+tends to produce a type of selection more in line with that users
45814581+expect in a text editor (the native selection styling will often
45824582+leave gaps between lines and won't fill the horizontal space after
45834583+a line when the selection continues past it).
45844584+45854585+It does have a performance cost, in that it requires an extra DOM
45864586+layout cycle for many updates (the selection is drawn based on DOM
45874587+layout information that's only available after laying out the
45884588+content).
45894589+*/function drawSelection(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return[selectionConfig.of(config),drawSelectionPlugin,hideNativeSelection];}var Piece=/*#__PURE__*/function(){function Piece(left,top,width,height,className){_classCallCheck(this,Piece);this.left=left;this.top=top;this.width=width;this.height=height;this.className=className;}_createClass(Piece,[{key:"draw",value:function draw(){var elt=document.createElement("div");elt.className=this.className;this.adjust(elt);return elt;}},{key:"adjust",value:function adjust(elt){elt.style.left=this.left+"px";elt.style.top=this.top+"px";if(this.width>=0)elt.style.width=this.width+"px";elt.style.height=this.height+"px";}},{key:"eq",value:function eq(p){return this.left==p.left&&this.top==p.top&&this.width==p.width&&this.height==p.height&&this.className==p.className;}}]);return Piece;}();var drawSelectionPlugin=ViewPlugin.fromClass(/*#__PURE__*/function(){function _class21(view){_classCallCheck(this,_class21);this.view=view;this.rangePieces=[];this.cursors=[];this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)};this.selectionLayer=view.scrollDOM.appendChild(document.createElement("div"));this.selectionLayer.className="cm-selectionLayer";this.selectionLayer.setAttribute("aria-hidden","true");this.cursorLayer=view.scrollDOM.appendChild(document.createElement("div"));this.cursorLayer.className="cm-cursorLayer";this.cursorLayer.setAttribute("aria-hidden","true");view.requestMeasure(this.measureReq);this.setBlinkRate();}_createClass(_class21,[{key:"setBlinkRate",value:function setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(selectionConfig).cursorBlinkRate+"ms";}},{key:"update",value:function update(_update32){var confChanged=_update32.startState.facet(selectionConfig)!=_update32.state.facet(selectionConfig);if(confChanged||_update32.selectionSet||_update32.geometryChanged||_update32.viewportChanged)this.view.requestMeasure(this.measureReq);if(_update32.transactions.some(function(tr){return tr.scrollIntoView;}))this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink";if(confChanged)this.setBlinkRate();}},{key:"readPos",value:function readPos(){var _this130=this;var state=this.view.state,conf=state.facet(selectionConfig);var rangePieces=state.selection.ranges.map(function(r){return r.empty?[]:measureRange(_this130.view,r);}).reduce(function(a,b){return a.concat(b);});var cursors=[];var _iterator260=_createForOfIteratorHelper(state.selection.ranges),_step260;try{for(_iterator260.s();!(_step260=_iterator260.n()).done;){var _r8=_step260.value;var prim=_r8==state.selection.main;if(_r8.empty?!prim||CanHidePrimary:conf.drawRangeCursor){var piece=measureCursor(this.view,_r8,prim);if(piece)cursors.push(piece);}}}catch(err){_iterator260.e(err);}finally{_iterator260.f();}return{rangePieces:rangePieces,cursors:cursors};}},{key:"drawSel",value:function drawSel(_ref84){var _this131=this;var rangePieces=_ref84.rangePieces,cursors=_ref84.cursors;if(rangePieces.length!=this.rangePieces.length||rangePieces.some(function(p,i){return!p.eq(_this131.rangePieces[i]);})){this.selectionLayer.textContent="";var _iterator261=_createForOfIteratorHelper(rangePieces),_step261;try{for(_iterator261.s();!(_step261=_iterator261.n()).done;){var _p5=_step261.value;this.selectionLayer.appendChild(_p5.draw());}}catch(err){_iterator261.e(err);}finally{_iterator261.f();}this.rangePieces=rangePieces;}if(cursors.length!=this.cursors.length||cursors.some(function(c,i){return!c.eq(_this131.cursors[i]);})){var oldCursors=this.cursorLayer.children;if(oldCursors.length!==cursors.length){this.cursorLayer.textContent="";var _iterator262=_createForOfIteratorHelper(cursors),_step262;try{for(_iterator262.s();!(_step262=_iterator262.n()).done;){var c=_step262.value;this.cursorLayer.appendChild(c.draw());}}catch(err){_iterator262.e(err);}finally{_iterator262.f();}}else{cursors.forEach(function(c,idx){return c.adjust(oldCursors[idx]);});}this.cursors=cursors;}}},{key:"destroy",value:function destroy(){this.selectionLayer.remove();this.cursorLayer.remove();}}]);return _class21;}());var themeSpec={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};if(CanHidePrimary)themeSpec[".cm-line"].caretColor="transparent !important";var hideNativeSelection=state.Prec.highest(EditorView.theme(themeSpec));function getBase(view){var rect=view.scrollDOM.getBoundingClientRect();var left=view.textDirection==exports.Direction.LTR?rect.left:rect.right-view.scrollDOM.clientWidth;return{left:left-view.scrollDOM.scrollLeft,top:rect.top-view.scrollDOM.scrollTop};}function wrappedLine(view,pos,inside){var range=state.EditorSelection.cursor(pos);return{from:Math.max(inside.from,view.moveToLineBoundary(range,false,true).from),to:Math.min(inside.to,view.moveToLineBoundary(range,true,true).from),type:exports.BlockType.Text};}function blockAt(view,pos){var line=view.visualLineAt(pos);if(Array.isArray(line.type)){var _iterator263=_createForOfIteratorHelper(line.type),_step263;try{for(_iterator263.s();!(_step263=_iterator263.n()).done;){var _l4=_step263.value;if(_l4.to>pos||_l4.to==pos&&(_l4.to==line.to||_l4.type==exports.BlockType.Text))return _l4;}}catch(err){_iterator263.e(err);}finally{_iterator263.f();}}return line;}function measureRange(view,range){if(range.to<=view.viewport.from||range.from>=view.viewport.to)return[];var from=Math.max(range.from,view.viewport.from),to=Math.min(range.to,view.viewport.to);var ltr=view.textDirection==exports.Direction.LTR;var content=view.contentDOM,contentRect=content.getBoundingClientRect(),base=getBase(view);var lineStyle=window.getComputedStyle(content.firstChild);var leftSide=contentRect.left+parseInt(lineStyle.paddingLeft);var rightSide=contentRect.right-parseInt(lineStyle.paddingRight);var startBlock=blockAt(view,from),endBlock=blockAt(view,to);var visualStart=startBlock.type==exports.BlockType.Text?startBlock:null;var visualEnd=endBlock.type==exports.BlockType.Text?endBlock:null;if(view.lineWrapping){if(visualStart)visualStart=wrappedLine(view,from,visualStart);if(visualEnd)visualEnd=wrappedLine(view,to,visualEnd);}if(visualStart&&visualEnd&&visualStart.from==visualEnd.from){return pieces(drawForLine(range.from,range.to,visualStart));}else{var top=visualStart?drawForLine(range.from,null,visualStart):drawForWidget(startBlock,false);var bottom=visualEnd?drawForLine(null,range.to,visualEnd):drawForWidget(endBlock,true);var between=[];if((visualStart||startBlock).to<(visualEnd||endBlock).from-1)between.push(piece(leftSide,top.bottom,rightSide,bottom.top));else if(top.bottom<bottom.top&&blockAt(view,(top.bottom+bottom.top)/2).type==exports.BlockType.Text)top.bottom=bottom.top=(top.bottom+bottom.top)/2;return pieces(top).concat(between).concat(pieces(bottom));}function piece(left,top,right,bottom){return new Piece(left-base.left,top-base.top,right-left,bottom-top,"cm-selectionBackground");}function pieces(_ref85){var top=_ref85.top,bottom=_ref85.bottom,horizontal=_ref85.horizontal;var pieces=[];for(var _i186=0;_i186<horizontal.length;_i186+=2){pieces.push(piece(horizontal[_i186],top,horizontal[_i186+1],bottom));}return pieces;}// Gets passed from/to in line-local positions
45904590+function drawForLine(from,to,line){var top=1e9,bottom=-1e9,horizontal=[];function addSpan(from,fromOpen,to,toOpen,dir){// Passing 2/-2 is a kludge to force the view to return
45914591+// coordinates on the proper side of block widgets, since
45924592+// normalizing the side there, though appropriate for most
45934593+// coordsAtPos queries, would break selection drawing.
45944594+var fromCoords=view.coordsAtPos(from,from==line.to?-2:2);var toCoords=view.coordsAtPos(to,to==line.from?2:-2);top=Math.min(fromCoords.top,toCoords.top,top);bottom=Math.max(fromCoords.bottom,toCoords.bottom,bottom);if(dir==exports.Direction.LTR)horizontal.push(ltr&&fromOpen?leftSide:fromCoords.left,ltr&&toOpen?rightSide:toCoords.right);else horizontal.push(!ltr&&toOpen?leftSide:toCoords.left,!ltr&&fromOpen?rightSide:fromCoords.right);}var start=from!==null&&from!==void 0?from:line.from,end=to!==null&&to!==void 0?to:line.to;// Split the range by visible range and document line
45954595+var _iterator264=_createForOfIteratorHelper(view.visibleRanges),_step264;try{for(_iterator264.s();!(_step264=_iterator264.n()).done;){var _r9=_step264.value;if(_r9.to>start&&_r9.from<end){for(var pos=Math.max(_r9.from,start),endPos=Math.min(_r9.to,end);;){var docLine=view.state.doc.lineAt(pos);var _iterator265=_createForOfIteratorHelper(view.bidiSpans(docLine)),_step265;try{for(_iterator265.s();!(_step265=_iterator265.n()).done;){var span=_step265.value;var spanFrom=span.from+docLine.from,spanTo=span.to+docLine.from;if(spanFrom>=endPos)break;if(spanTo>pos)addSpan(Math.max(spanFrom,pos),from==null&&spanFrom<=start,Math.min(spanTo,endPos),to==null&&spanTo>=end,span.dir);}}catch(err){_iterator265.e(err);}finally{_iterator265.f();}pos=docLine.to+1;if(pos>=endPos)break;}}}}catch(err){_iterator264.e(err);}finally{_iterator264.f();}if(horizontal.length==0)addSpan(start,from==null,end,to==null,view.textDirection);return{top:top,bottom:bottom,horizontal:horizontal};}function drawForWidget(block,top){var y=contentRect.top+(top?block.top:block.bottom);return{top:y,bottom:y,horizontal:[]};}}function measureCursor(view,cursor,primary){var pos=view.coordsAtPos(cursor.head,cursor.assoc||1);if(!pos)return null;var base=getBase(view);return new Piece(pos.left-base.left,pos.top-base.top,-1,pos.bottom-pos.top,primary?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary");}function iterMatches(doc,re,from,to,f){re.lastIndex=0;for(var _cursor4=doc.iterRange(from,to),pos=from,m;!_cursor4.next().done;pos+=_cursor4.value.length){if(!_cursor4.lineBreak)while(m=re.exec(_cursor4.value)){f(pos+m.index,pos+m.index+m[0].length,m);}}}/**
45964596+Helper class used to make it easier to maintain decorations on
45974597+visible code that matches a given regular expression. To be used
45984598+in a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object
45994599+represent a matching configuration.
46004600+*/var MatchDecorator=/*#__PURE__*/function(){/**
46014601+ Create a decorator.
46024602+ */function MatchDecorator(config){_classCallCheck(this,MatchDecorator);var regexp=config.regexp,decoration=config.decoration,boundary=config.boundary;if(!regexp.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=regexp;this.getDeco=typeof decoration=="function"?decoration:function(){return decoration;};this.boundary=boundary;}/**
46034603+ Compute the full set of decorations for matches in the given
46044604+ view's viewport. You'll want to call this when initializing your
46054605+ plugin.
46064606+ */_createClass(MatchDecorator,[{key:"createDeco",value:function createDeco(view){var _this132=this;var build=new rangeset.RangeSetBuilder();var _iterator266=_createForOfIteratorHelper(view.visibleRanges),_step266;try{for(_iterator266.s();!(_step266=_iterator266.n()).done;){var _step266$value=_step266.value,from=_step266$value.from,to=_step266$value.to;iterMatches(view.state.doc,this.regexp,from,to,function(a,b,m){return build.add(a,b,_this132.getDeco(m,view,a));});}}catch(err){_iterator266.e(err);}finally{_iterator266.f();}return build.finish();}/**
46074607+ Update a set of decorations for a view update. `deco` _must_ be
46084608+ the set of decorations produced by _this_ `MatchDecorator` for
46094609+ the view state before the update.
46104610+ */},{key:"updateDeco",value:function updateDeco(update,deco){var changeFrom=1e9,changeTo=-1;if(update.docChanged)update.changes.iterChanges(function(_f,_t,from,to){if(to>update.view.viewport.from&&from<update.view.viewport.to){changeFrom=Math.min(from,changeFrom);changeTo=Math.max(to,changeTo);}});if(update.viewportChanged||changeTo-changeFrom>1000)return this.createDeco(update.view);if(changeTo>-1)return this.updateRange(update.view,deco.map(update.changes),changeFrom,changeTo);return deco;}},{key:"updateRange",value:function updateRange(view,deco,updateFrom,updateTo){var _this133=this;var _iterator267=_createForOfIteratorHelper(view.visibleRanges),_step267;try{for(_iterator267.s();!(_step267=_iterator267.n()).done;){var _r10=_step267.value;var from=Math.max(_r10.from,updateFrom),to=Math.min(_r10.to,updateTo);if(to>from){(function(){var fromLine=view.state.doc.lineAt(from),toLine=fromLine.to<to?view.state.doc.lineAt(to):fromLine;var start=Math.max(_r10.from,fromLine.from),end=Math.min(_r10.to,toLine.to);if(_this133.boundary){for(;from>fromLine.from;from--){if(_this133.boundary.test(fromLine.text[from-1-fromLine.from])){start=from;break;}}for(;to<toLine.to;to++){if(_this133.boundary.test(toLine.text[to-toLine.from])){end=to;break;}}}var ranges=[],m=void 0;if(fromLine==toLine){_this133.regexp.lastIndex=start-fromLine.from;while((m=_this133.regexp.exec(fromLine.text))&&m.index<end-fromLine.from){var pos=m.index+fromLine.from;ranges.push(_this133.getDeco(m,view,pos).range(pos,pos+m[0].length));}}else{iterMatches(view.state.doc,_this133.regexp,start,end,function(from,to,m){return ranges.push(_this133.getDeco(m,view,from).range(from,to));});}deco=deco.update({filterFrom:start,filterTo:end,filter:function filter(from,to){return from<start||to>end;},add:ranges});})();}}}catch(err){_iterator267.e(err);}finally{_iterator267.f();}return deco;}}]);return MatchDecorator;}();var UnicodeRegexpSupport=/x/.unicode!=null?"gu":"g";var Specials=new RegExp("[\0-\b\n-\x1F\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\uFEFF\uFFF9-\uFFFC]",UnicodeRegexpSupport);var Names={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",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};var _supportsTabSize=null;function supportsTabSize(){var _a;if(_supportsTabSize==null&&typeof document!="undefined"&&document.body){var styles=document.body.style;_supportsTabSize=((_a=styles.tabSize)!==null&&_a!==void 0?_a:styles.MozTabSize)!=null;}return _supportsTabSize||false;}var specialCharConfig=state.Facet.define({combine:function combine(configs){var config=state.combineConfig(configs,{render:null,specialChars:Specials,addSpecialChars:null});if(config.replaceTabs=!supportsTabSize())config.specialChars=new RegExp("\t|"+config.specialChars.source,UnicodeRegexpSupport);if(config.addSpecialChars)config.specialChars=new RegExp(config.specialChars.source+"|"+config.addSpecialChars.source,UnicodeRegexpSupport);return config;}});/**
46114611+Returns an extension that installs highlighting of special
46124612+characters.
46134613+*/function highlightSpecialChars(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return[specialCharConfig.of(config),specialCharPlugin()];}var _plugin=null;function specialCharPlugin(){return _plugin||(_plugin=ViewPlugin.fromClass(/*#__PURE__*/function(){function _class22(view){_classCallCheck(this,_class22);this.view=view;this.decorations=Decoration.none;this.decorationCache=Object.create(null);this.decorator=this.makeDecorator(view.state.facet(specialCharConfig));this.decorations=this.decorator.createDeco(view);}_createClass(_class22,[{key:"makeDecorator",value:function makeDecorator(conf){var _this134=this;return new MatchDecorator({regexp:conf.specialChars,decoration:function decoration(m,view,pos){var doc=view.state.doc;var code=text.codePointAt(m[0],0);if(code==9){var line=doc.lineAt(pos);var size=view.state.tabSize,col=text.countColumn(line.text,size,pos-line.from);return Decoration.replace({widget:new TabWidget((size-col%size)*_this134.view.defaultCharacterWidth)});}return _this134.decorationCache[code]||(_this134.decorationCache[code]=Decoration.replace({widget:new SpecialCharWidget(conf,code)}));},boundary:conf.replaceTabs?undefined:/[^]/});}},{key:"update",value:function update(_update33){var conf=_update33.state.facet(specialCharConfig);if(_update33.startState.facet(specialCharConfig)!=conf){this.decorator=this.makeDecorator(conf);this.decorations=this.decorator.createDeco(_update33.view);}else{this.decorations=this.decorator.updateDeco(_update33,this.decorations);}}}]);return _class22;}(),{decorations:function decorations(v){return v.decorations;}}));}var DefaultPlaceholder="\u2022";// Assigns placeholder characters from the Control Pictures block to
46144614+// ASCII control characters
46154615+function placeholder$1(code){if(code>=32)return DefaultPlaceholder;if(code==10)return"\u2424";return String.fromCharCode(9216+code);}var SpecialCharWidget=/*#__PURE__*/function(_WidgetType12){_inherits(SpecialCharWidget,_WidgetType12);var _super65=_createSuper(SpecialCharWidget);function SpecialCharWidget(options,code){var _this135;_classCallCheck(this,SpecialCharWidget);_this135=_super65.call(this);_this135.options=options;_this135.code=code;return _this135;}_createClass(SpecialCharWidget,[{key:"eq",value:function eq(other){return other.code==this.code;}},{key:"toDOM",value:function toDOM(view){var ph=placeholder$1(this.code);var desc=view.state.phrase("Control character")+" "+(Names[this.code]||"0x"+this.code.toString(16));var custom=this.options.render&&this.options.render(this.code,desc,ph);if(custom)return custom;var span=document.createElement("span");span.textContent=ph;span.title=desc;span.setAttribute("aria-label",desc);span.className="cm-specialChar";return span;}},{key:"ignoreEvent",value:function ignoreEvent(){return false;}}]);return SpecialCharWidget;}(WidgetType);var TabWidget=/*#__PURE__*/function(_WidgetType13){_inherits(TabWidget,_WidgetType13);var _super66=_createSuper(TabWidget);function TabWidget(width){var _this136;_classCallCheck(this,TabWidget);_this136=_super66.call(this);_this136.width=width;return _this136;}_createClass(TabWidget,[{key:"eq",value:function eq(other){return other.width==this.width;}},{key:"toDOM",value:function toDOM(){var span=document.createElement("span");span.textContent="\t";span.className="cm-tab";span.style.width=this.width+"px";return span;}},{key:"ignoreEvent",value:function ignoreEvent(){return false;}}]);return TabWidget;}(WidgetType);var plugin=ViewPlugin.fromClass(/*#__PURE__*/function(){function _class23(view){var _this137=this;_classCallCheck(this,_class23);this.height=-1;this.measure={read:function read(view){return Math.max(0,view.scrollDOM.clientHeight-view.defaultLineHeight);},write:function write(value,view){if(Math.abs(value-_this137.height)>1){_this137.height=value;view.contentDOM.style.paddingBottom=value+"px";}}};view.requestMeasure(this.measure);}_createClass(_class23,[{key:"update",value:function update(_update34){if(_update34.geometryChanged)_update34.view.requestMeasure(this.measure);}}]);return _class23;}());/**
46164616+Returns a plugin that makes sure the content has a bottom margin
46174617+equivalent to the height of the editor, minus one line height, so
46184618+that every line in the document can be scrolled to the top of the
46194619+editor.
46204620+46214621+This is only meaningful when the editor is scrollable, and should
46224622+not be enabled in editors that take the size of their content.
46234623+*/function scrollPastEnd(){return plugin;}/**
46244624+Mark lines that have a cursor on them with the `"cm-activeLine"`
46254625+DOM class.
46264626+*/function highlightActiveLine(){return activeLineHighlighter;}var lineDeco=Decoration.line({"class":"cm-activeLine"});var activeLineHighlighter=ViewPlugin.fromClass(/*#__PURE__*/function(){function _class24(view){_classCallCheck(this,_class24);this.decorations=this.getDeco(view);}_createClass(_class24,[{key:"update",value:function update(_update35){if(_update35.docChanged||_update35.selectionSet)this.decorations=this.getDeco(_update35.view);}},{key:"getDeco",value:function getDeco(view){var lastLineStart=-1,deco=[];var _iterator268=_createForOfIteratorHelper(view.state.selection.ranges),_step268;try{for(_iterator268.s();!(_step268=_iterator268.n()).done;){var _r11=_step268.value;if(!_r11.empty)return Decoration.none;var line=view.visualLineAt(_r11.head);if(line.from>lastLineStart){deco.push(lineDeco.range(line.from));lastLineStart=line.from;}}}catch(err){_iterator268.e(err);}finally{_iterator268.f();}return Decoration.set(deco);}}]);return _class24;}(),{decorations:function decorations(v){return v.decorations;}});var Placeholder=/*#__PURE__*/function(_WidgetType14){_inherits(Placeholder,_WidgetType14);var _super67=_createSuper(Placeholder);function Placeholder(content){var _this138;_classCallCheck(this,Placeholder);_this138=_super67.call(this);_this138.content=content;return _this138;}_createClass(Placeholder,[{key:"toDOM",value:function toDOM(){var wrap=document.createElement("span");wrap.className="cm-placeholder";wrap.style.pointerEvents="none";wrap.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content);if(typeof this.content=="string")wrap.setAttribute("aria-label","placeholder "+this.content);else wrap.setAttribute("aria-hidden","true");return wrap;}},{key:"ignoreEvent",value:function ignoreEvent(){return false;}}]);return Placeholder;}(WidgetType);/**
46274627+Extension that enables a placeholder—a piece of example content
46284628+to show when the editor is empty.
46294629+*/function placeholder(content){return ViewPlugin.fromClass(/*#__PURE__*/function(){function _class25(view){_classCallCheck(this,_class25);this.view=view;this.placeholder=Decoration.set([Decoration.widget({widget:new Placeholder(content),side:1}).range(0)]);}_createClass(_class25,[{key:"decorations",get:function get(){return this.view.state.doc.length?Decoration.none:this.placeholder;}}]);return _class25;}(),{decorations:function decorations(v){return v.decorations;}});}/**
46304630+@internal
46314631+*/var __test={HeightMap:HeightMap,HeightOracle:HeightOracle,MeasuredHeights:MeasuredHeights,QueryType:QueryType,ChangedRange:ChangedRange,computeOrder:computeOrder,moveVisually:moveVisually};Object.defineProperty(exports,'Range',{enumerable:true,get:function get(){return rangeset.Range;}});exports.BidiSpan=BidiSpan;exports.BlockInfo=BlockInfo;exports.Decoration=Decoration;exports.EditorView=EditorView;exports.MatchDecorator=MatchDecorator;exports.PluginField=PluginField;exports.PluginFieldProvider=PluginFieldProvider;exports.ViewPlugin=ViewPlugin;exports.ViewUpdate=ViewUpdate;exports.WidgetType=WidgetType;exports.__test=__test;exports.drawSelection=drawSelection;exports.highlightActiveLine=highlightActiveLine;exports.highlightSpecialChars=highlightSpecialChars;exports.keymap=keymap;exports.logException=logException;exports.placeholder=placeholder;exports.runScopeHandlers=runScopeHandlers;exports.scrollPastEnd=scrollPastEnd;},{"@codemirror/rangeset":18,"@codemirror/state":22,"@codemirror/text":24,"style-mod":30,"w3c-keyname":31}],28:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});// FIXME profile adding a per-Tree TreeNode cache, validating it by
46324632+// parent pointer
46334633+/// The default maximum length of a `TreeBuffer` node (1024).
46344634+var DefaultBufferLength=1024;var nextPropID=0;var Range=/*#__PURE__*/_createClass(function Range(from,to){_classCallCheck(this,Range);this.from=from;this.to=to;});/// Each [node type](#common.NodeType) or [individual tree](#common.Tree)
46354635+/// can have metadata associated with it in props. Instances of this
46364636+/// class represent prop names.
46374637+var NodeProp=/*#__PURE__*/function(){/// Create a new node prop type.
46384638+function NodeProp(){var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,NodeProp);this.id=nextPropID++;this.perNode=!!config.perNode;this.deserialize=config.deserialize||function(){throw new Error("This node type doesn't define a deserialize function");};}/// This is meant to be used with
46394639+/// [`NodeSet.extend`](#common.NodeSet.extend) or
46404640+/// [`LRParser.configure`](#lr.ParserConfig.props) to compute
46414641+/// prop values for each node type in the set. Takes a [match
46424642+/// object](#common.NodeType^match) or function that returns undefined
46434643+/// if the node type doesn't get this prop, and the prop's value if
46444644+/// it does.
46454645+_createClass(NodeProp,[{key:"add",value:function add(match){var _this139=this;if(this.perNode)throw new RangeError("Can't add per-node props to node types");if(typeof match!="function")match=NodeType.match(match);return function(type){var result=match(type);return result===undefined?null:[_this139,result];};}}]);return NodeProp;}();/// Prop that is used to describe matching delimiters. For opening
46464646+/// delimiters, this holds an array of node names (written as a
46474647+/// space-separated string when declaring this prop in a grammar)
46484648+/// for the node types of closing delimiters that match it.
46494649+NodeProp.closedBy=new NodeProp({deserialize:function deserialize(str){return str.split(" ");}});/// The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
46504650+/// attached to closing delimiters, holding an array of node names
46514651+/// of types of matching opening delimiters.
46524652+NodeProp.openedBy=new NodeProp({deserialize:function deserialize(str){return str.split(" ");}});/// Used to assign node types to groups (for example, all node
46534653+/// types that represent an expression could be tagged with an
46544654+/// `"Expression"` group).
46554655+NodeProp.group=new NodeProp({deserialize:function deserialize(str){return str.split(" ");}});/// The hash of the [context](#lr.ContextTracker.constructor)
46564656+/// that the node was parsed in, if any. Used to limit reuse of
46574657+/// contextual nodes.
46584658+NodeProp.contextHash=new NodeProp({perNode:true});/// The distance beyond the end of the node that the tokenizer
46594659+/// looked ahead for any of the tokens inside the node. (The LR
46604660+/// parser only stores this when it is larger than 25, for
46614661+/// efficiency reasons.)
46624662+NodeProp.lookAhead=new NodeProp({perNode:true});/// This per-node prop is used to replace a given node, or part of a
46634663+/// node, with another tree. This is useful to include trees from
46644664+/// different languages.
46654665+NodeProp.mounted=new NodeProp({perNode:true});/// A mounted tree, which can be [stored](#common.NodeProp^mounted) on
46664666+/// a tree node to indicate that parts of its content are
46674667+/// represented by another tree.
46684668+var MountedTree=/*#__PURE__*/_createClass(function MountedTree(/// The inner tree.
46694669+tree,/// If this is null, this tree replaces the entire node (it will
46704670+/// be included in the regular iteration instead of its host
46714671+/// node). If not, only the given ranges are considered to be
46724672+/// covered by this tree. This is used for trees that are mixed in
46734673+/// a way that isn't strictly hierarchical. Such mounted trees are
46744674+/// only entered by [`resolveInner`](#common.Tree.resolveInner)
46754675+/// and [`enter`](#common.SyntaxNode.enter).
46764676+overlay,/// The parser used to create this subtree.
46774677+parser){_classCallCheck(this,MountedTree);this.tree=tree;this.overlay=overlay;this.parser=parser;});var noProps=Object.create(null);/// Each node in a syntax tree has a node type associated with it.
46784678+var NodeType=/*#__PURE__*/function(){/// @internal
46794679+function NodeType(/// The name of the node type. Not necessarily unique, but if the
46804680+/// grammar was written properly, different node types with the
46814681+/// same name within a node set should play the same semantic
46824682+/// role.
46834683+name,/// @internal
46844684+props,/// The id of this node in its set. Corresponds to the term ids
46854685+/// used in the parser.
46864686+id){var flags=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;_classCallCheck(this,NodeType);this.name=name;this.props=props;this.id=id;this.flags=flags;}_createClass(NodeType,[{key:"prop",value:/// Retrieves a node prop for this type. Will return `undefined` if
46874687+/// the prop isn't present on this node.
46884688+function prop(_prop){return this.props[_prop.id];}/// True when this is the top node of a grammar.
46894689+},{key:"isTop",get:function get(){return(this.flags&1/* Top */)>0;}/// True when this node is produced by a skip rule.
46904690+},{key:"isSkipped",get:function get(){return(this.flags&2/* Skipped */)>0;}/// Indicates whether this is an error node.
46914691+},{key:"isError",get:function get(){return(this.flags&4/* Error */)>0;}/// When true, this node type doesn't correspond to a user-declared
46924692+/// named node, for example because it is used to cache repetition.
46934693+},{key:"isAnonymous",get:function get(){return(this.flags&8/* Anonymous */)>0;}/// Returns true when this node's name or one of its
46944694+/// [groups](#common.NodeProp^group) matches the given string.
46954695+},{key:"is",value:function is(name){if(typeof name=='string'){if(this.name==name)return true;var group=this.prop(NodeProp.group);return group?group.indexOf(name)>-1:false;}return this.id==name;}/// Create a function from node types to arbitrary values by
46964696+/// specifying an object whose property names are node or
46974697+/// [group](#common.NodeProp^group) names. Often useful with
46984698+/// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
46994699+/// names, separated by spaces, in a single property name to map
47004700+/// multiple node names to a single value.
47014701+}],[{key:"define",value:function define(spec){var props=spec.props&&spec.props.length?Object.create(null):noProps;var flags=(spec.top?1/* Top */:0)|(spec.skipped?2/* Skipped */:0)|(spec.error?4/* Error */:0)|(spec.name==null?8/* Anonymous */:0);var type=new NodeType(spec.name||"",props,spec.id,flags);if(spec.props){var _iterator269=_createForOfIteratorHelper(spec.props),_step269;try{for(_iterator269.s();!(_step269=_iterator269.n()).done;){var src=_step269.value;if(!Array.isArray(src))src=src(type);if(src){if(src[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");props[src[0].id]=src[1];}}}catch(err){_iterator269.e(err);}finally{_iterator269.f();}}return type;}},{key:"match",value:function match(map){var direct=Object.create(null);for(var prop in map){var _iterator270=_createForOfIteratorHelper(prop.split(" ")),_step270;try{for(_iterator270.s();!(_step270=_iterator270.n()).done;){var name=_step270.value;direct[name]=map[prop];}}catch(err){_iterator270.e(err);}finally{_iterator270.f();}}return function(node){for(var groups=node.prop(NodeProp.group),_i187=-1;_i187<(groups?groups.length:0);_i187++){var found=direct[_i187<0?node.name:groups[_i187]];if(found)return found;}};}}]);return NodeType;}();/// An empty dummy node type to use when no actual type is available.
47024702+NodeType.none=new NodeType("",Object.create(null),0,8/* Anonymous */);/// A node set holds a collection of node types. It is used to
47034703+/// compactly represent trees by storing their type ids, rather than a
47044704+/// full pointer to the type object, in a numeric array. Each parser
47054705+/// [has](#lr.LRParser.nodeSet) a node set, and [tree
47064706+/// buffers](#common.TreeBuffer) can only store collections of nodes
47074707+/// from the same set. A set can have a maximum of 2**16 (65536) node
47084708+/// types in it, so that the ids fit into 16-bit typed array slots.
47094709+var NodeSet=/*#__PURE__*/function(){/// Create a set with the given types. The `id` property of each
47104710+/// type should correspond to its position within the array.
47114711+function NodeSet(/// The node types in this set, by id.
47124712+types){_classCallCheck(this,NodeSet);this.types=types;for(var _i188=0;_i188<types.length;_i188++){if(types[_i188].id!=_i188)throw new RangeError("Node type ids should correspond to array positions when creating a node set");}}/// Create a copy of this set with some node properties added. The
47134713+/// arguments to this method should be created with
47144714+/// [`NodeProp.add`](#common.NodeProp.add).
47154715+_createClass(NodeSet,[{key:"extend",value:function extend(){var newTypes=[];for(var _len3=arguments.length,props=new Array(_len3),_key3=0;_key3<_len3;_key3++){props[_key3]=arguments[_key3];}var _iterator271=_createForOfIteratorHelper(this.types),_step271;try{for(_iterator271.s();!(_step271=_iterator271.n()).done;){var type=_step271.value;var newProps=null;var _iterator272=_createForOfIteratorHelper(props),_step272;try{for(_iterator272.s();!(_step272=_iterator272.n()).done;){var source=_step272.value;var add=source(type);if(add){if(!newProps)newProps=Object.assign({},type.props);newProps[add[0].id]=add[1];}}}catch(err){_iterator272.e(err);}finally{_iterator272.f();}newTypes.push(newProps?new NodeType(type.name,newProps,type.id,type.flags):type);}}catch(err){_iterator271.e(err);}finally{_iterator271.f();}return new NodeSet(newTypes);}}]);return NodeSet;}();var CachedNode=new WeakMap(),CachedInnerNode=new WeakMap();/// A piece of syntax tree. There are two ways to approach these
47164716+/// trees: the way they are actually stored in memory, and the
47174717+/// convenient way.
47184718+///
47194719+/// Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
47204720+/// objects. By packing detail information into `TreeBuffer` leaf
47214721+/// nodes, the representation is made a lot more memory-efficient.
47224722+///
47234723+/// However, when you want to actually work with tree nodes, this
47244724+/// representation is very awkward, so most client code will want to
47254725+/// use the [`TreeCursor`](#common.TreeCursor) or
47264726+/// [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
47274727+/// a view on some part of this data structure, and can be used to
47284728+/// move around to adjacent nodes.
47294729+var Tree=/*#__PURE__*/function(){/// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
47304730+function Tree(/// The type of the top node.
47314731+type,/// This node's child nodes.
47324732+children,/// The positions (offsets relative to the start of this tree) of
47334733+/// the children.
47344734+positions,/// The total length of this tree
47354735+length,/// Per-node [node props](#common.NodeProp) to associate with this node.
47364736+props){_classCallCheck(this,Tree);this.type=type;this.children=children;this.positions=positions;this.length=length;/// @internal
47374737+this.props=null;if(props&&props.length){this.props=Object.create(null);var _iterator273=_createForOfIteratorHelper(props),_step273;try{for(_iterator273.s();!(_step273=_iterator273.n()).done;){var _step273$value=_slicedToArray(_step273.value,2),prop=_step273$value[0],value=_step273$value[1];this.props[typeof prop=="number"?prop:prop.id]=value;}}catch(err){_iterator273.e(err);}finally{_iterator273.f();}}}/// @internal
47384738+_createClass(Tree,[{key:"toString",value:function toString(){var mounted=this.prop(NodeProp.mounted);if(mounted&&!mounted.overlay)return mounted.tree.toString();var children="";var _iterator274=_createForOfIteratorHelper(this.children),_step274;try{for(_iterator274.s();!(_step274=_iterator274.n()).done;){var ch=_step274.value;var str=ch.toString();if(str){if(children)children+=",";children+=str;}}}catch(err){_iterator274.e(err);}finally{_iterator274.f();}return!this.type.name?children:(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(children.length?"("+children+")":"");}/// Get a [tree cursor](#common.TreeCursor) rooted at this tree. When
47394739+/// `pos` is given, the cursor is [moved](#common.TreeCursor.moveTo)
47404740+/// to the given position and side.
47414741+},{key:"cursor",value:function cursor(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var scope=pos!=null&&CachedNode.get(this)||this.topNode;var cursor=new TreeCursor(scope);if(pos!=null){cursor.moveTo(pos,side);CachedNode.set(this,cursor._tree);}return cursor;}/// Get a [tree cursor](#common.TreeCursor) that, unlike regular
47424742+/// cursors, doesn't skip through
47434743+/// [anonymous](#common.NodeType.isAnonymous) nodes and doesn't
47444744+/// automatically enter mounted nodes.
47454745+},{key:"fullCursor",value:function fullCursor(){return new TreeCursor(this.topNode,1/* Full */);}/// Get a [syntax node](#common.SyntaxNode) object for the top of the
47464746+/// tree.
47474747+},{key:"topNode",get:function get(){return new TreeNode(this,0,0,null);}/// Get the [syntax node](#common.SyntaxNode) at the given position.
47484748+/// If `side` is -1, this will move into nodes that end at the
47494749+/// position. If 1, it'll move into nodes that start at the
47504750+/// position. With 0, it'll only enter nodes that cover the position
47514751+/// from both sides.
47524752+},{key:"resolve",value:function resolve(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var node=resolveNode(CachedNode.get(this)||this.topNode,pos,side,false);CachedNode.set(this,node);return node;}/// Like [`resolve`](#common.Tree.resolve), but will enter
47534753+/// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
47544754+/// pointing into the innermost overlaid tree at the given position
47554755+/// (with parent links going through all parent structure, including
47564756+/// the host trees).
47574757+},{key:"resolveInner",value:function resolveInner(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var node=resolveNode(CachedInnerNode.get(this)||this.topNode,pos,side,true);CachedInnerNode.set(this,node);return node;}/// Iterate over the tree and its children, calling `enter` for any
47584758+/// node that touches the `from`/`to` region (if given) before
47594759+/// running over such a node's children, and `leave` (if given) when
47604760+/// leaving the node. When `enter` returns `false`, that node will
47614761+/// not have its children iterated over (or `leave` called).
47624762+},{key:"iterate",value:function iterate(spec){var enter=spec.enter,leave=spec.leave,_spec$from=spec.from,from=_spec$from===void 0?0:_spec$from,_spec$to2=spec.to,to=_spec$to2===void 0?this.length:_spec$to2;for(var c=this.cursor(),get=function get(){return c.node;};;){var mustLeave=false;if(c.from<=to&&c.to>=from&&(c.type.isAnonymous||enter(c.type,c.from,c.to,get)!==false)){if(c.firstChild())continue;if(!c.type.isAnonymous)mustLeave=true;}for(;;){if(mustLeave&&leave)leave(c.type,c.from,c.to,get);mustLeave=c.type.isAnonymous;if(c.nextSibling())break;if(!c.parent())return;mustLeave=true;}}}/// Get the value of the given [node prop](#common.NodeProp) for this
47634763+/// node. Works with both per-node and per-type props.
47644764+},{key:"prop",value:function prop(_prop2){return!_prop2.perNode?this.type.prop(_prop2):this.props?this.props[_prop2.id]:undefined;}/// Returns the node's [per-node props](#common.NodeProp.perNode) in a
47654765+/// format that can be passed to the [`Tree`](#common.Tree)
47664766+/// constructor.
47674767+},{key:"propValues",get:function get(){var result=[];if(this.props)for(var id in this.props){result.push([+id,this.props[id]]);}return result;}/// Balance the direct children of this tree, producing a copy of
47684768+/// which may have children grouped into subtrees with type
47694769+/// [`NodeType.none`](#common.NodeType^none).
47704770+},{key:"balance",value:function balance(){var _this140=this;var config=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return this.children.length<=8/* BranchFactor */?this:balanceRange(NodeType.none,this.children,this.positions,0,this.children.length,0,this.length,function(children,positions,length){return new Tree(_this140.type,children,positions,length,_this140.propValues);},config.makeTree||function(children,positions,length){return new Tree(NodeType.none,children,positions,length);});}/// Build a tree from a postfix-ordered buffer of node information,
47714771+/// or a cursor over such a buffer.
47724772+}],[{key:"build",value:function build(data){return buildTree(data);}}]);return Tree;}();/// The empty tree
47734773+Tree.empty=new Tree(NodeType.none,[],[],0);var FlatBufferCursor=/*#__PURE__*/function(){function FlatBufferCursor(buffer,index){_classCallCheck(this,FlatBufferCursor);this.buffer=buffer;this.index=index;}_createClass(FlatBufferCursor,[{key:"id",get:function get(){return this.buffer[this.index-4];}},{key:"start",get:function get(){return this.buffer[this.index-3];}},{key:"end",get:function get(){return this.buffer[this.index-2];}},{key:"size",get:function get(){return this.buffer[this.index-1];}},{key:"pos",get:function get(){return this.index;}},{key:"next",value:function next(){this.index-=4;}},{key:"fork",value:function fork(){return new FlatBufferCursor(this.buffer,this.index);}}]);return FlatBufferCursor;}();/// Tree buffers contain (type, start, end, endIndex) quads for each
47744774+/// node. In such a buffer, nodes are stored in prefix order (parents
47754775+/// before children, with the endIndex of the parent indicating which
47764776+/// children belong to it)
47774777+var TreeBuffer=/*#__PURE__*/function(){/// Create a tree buffer.
47784778+function TreeBuffer(/// The buffer's content.
47794779+buffer,/// The total length of the group of nodes in the buffer.
47804780+length,/// The node set used in this buffer.
47814781+set){_classCallCheck(this,TreeBuffer);this.buffer=buffer;this.length=length;this.set=set;}/// @internal
47824782+_createClass(TreeBuffer,[{key:"type",get:function get(){return NodeType.none;}/// @internal
47834783+},{key:"toString",value:function toString(){var result=[];for(var index=0;index<this.buffer.length;){result.push(this.childString(index));index=this.buffer[index+3];}return result.join(",");}/// @internal
47844784+},{key:"childString",value:function childString(index){var id=this.buffer[index],endIndex=this.buffer[index+3];var type=this.set.types[id],result=type.name;if(/\W/.test(result)&&!type.isError)result=JSON.stringify(result);index+=4;if(endIndex==index)return result;var children=[];while(index<endIndex){children.push(this.childString(index));index=this.buffer[index+3];}return result+"("+children.join(",")+")";}/// @internal
47854785+},{key:"findChild",value:function findChild(startIndex,endIndex,dir,pos,side){var buffer=this.buffer,pick=-1;for(var _i189=startIndex;_i189!=endIndex;_i189=buffer[_i189+3]){if(checkSide(side,pos,buffer[_i189+1],buffer[_i189+2])){pick=_i189;if(dir>0)break;}}return pick;}/// @internal
47864786+},{key:"slice",value:function slice(startI,endI,from,to){var b=this.buffer;var copy=new Uint16Array(endI-startI);for(var _i190=startI,j=0;_i190<endI;){copy[j++]=b[_i190++];copy[j++]=b[_i190++]-from;copy[j++]=b[_i190++]-from;copy[j++]=b[_i190++]-startI;}return new TreeBuffer(copy,to-from,this.set);}}]);return TreeBuffer;}();function checkSide(side,pos,from,to){switch(side){case-2/* Before */:return from<pos;case-1/* AtOrBefore */:return to>=pos&&from<pos;case 0/* Around */:return from<pos&&to>pos;case 1/* AtOrAfter */:return from<=pos&&to>pos;case 2/* After */:return to>pos;case 4/* DontCare */:return true;}}function _enterUnfinishedNodesBefore(node,pos){var scan=node.childBefore(pos);while(scan){var last=scan.lastChild;if(!last||last.to!=scan.to)break;if(last.type.isError&&last.from==last.to){node=scan;scan=last.prevSibling;}else{scan=last;}}return node;}function resolveNode(node,pos,side,overlays){var _a;// Move up to a node that actually holds the position, if possible
47874787+while(node.from==node.to||(side<1?node.from>=pos:node.from>pos)||(side>-1?node.to<=pos:node.to<pos)){var parent=!overlays&&node instanceof TreeNode&&node.index<0?null:node.parent;if(!parent)return node;node=parent;}// Must go up out of overlays when those do not overlap with pos
47884788+if(overlays)for(var scan=node,_parent2=scan.parent;_parent2;scan=_parent2,_parent2=scan.parent){if(scan instanceof TreeNode&&scan.index<0&&((_a=_parent2.enter(pos,side,true))===null||_a===void 0?void 0:_a.from)!=scan.from)node=_parent2;}for(;;){var inner=node.enter(pos,side,overlays);if(!inner)return node;node=inner;}}var TreeNode=/*#__PURE__*/function(){function TreeNode(node,_from,// Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
47894789+index,_parent){_classCallCheck(this,TreeNode);this.node=node;this._from=_from;this.index=index;this._parent=_parent;}_createClass(TreeNode,[{key:"type",get:function get(){return this.node.type;}},{key:"name",get:function get(){return this.node.type.name;}},{key:"from",get:function get(){return this._from;}},{key:"to",get:function get(){return this._from+this.node.length;}},{key:"nextChild",value:function nextChild(i,dir,pos,side){var mode=arguments.length>4&&arguments[4]!==undefined?arguments[4]:0;for(var parent=this;;){for(var _parent$node=parent.node,children=_parent$node.children,positions=_parent$node.positions,e=dir>0?children.length:-1;i!=e;i+=dir){var next=children[i],start=positions[i]+parent._from;if(!checkSide(side,pos,start,start+next.length))continue;if(next instanceof TreeBuffer){if(mode&2/* NoEnterBuffer */)continue;var index=next.findChild(0,next.buffer.length,dir,pos-start,side);if(index>-1)return new BufferNode(new BufferContext(parent,next,i,start),null,index);}else if(mode&1/* Full */||!next.type.isAnonymous||hasChild(next)){var mounted=void 0;if(!(mode&1/* Full */)&&next.props&&(mounted=next.prop(NodeProp.mounted))&&!mounted.overlay)return new TreeNode(mounted.tree,start,i,parent);var inner=new TreeNode(next,start,i,parent);return mode&1/* Full */||!inner.type.isAnonymous?inner:inner.nextChild(dir<0?next.children.length-1:0,dir,pos,side);}}if(mode&1/* Full */||!parent.type.isAnonymous)return null;if(parent.index>=0)i=parent.index+dir;else i=dir<0?-1:parent._parent.node.children.length;parent=parent._parent;if(!parent)return null;}}},{key:"firstChild",get:function get(){return this.nextChild(0,1,0,4/* DontCare */);}},{key:"lastChild",get:function get(){return this.nextChild(this.node.children.length-1,-1,0,4/* DontCare */);}},{key:"childAfter",value:function childAfter(pos){return this.nextChild(0,1,pos,2/* After */);}},{key:"childBefore",value:function childBefore(pos){return this.nextChild(this.node.children.length-1,-1,pos,-2/* Before */);}},{key:"enter",value:function enter(pos,side){var overlays=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var buffers=arguments.length>3&&arguments[3]!==undefined?arguments[3]:true;var mounted;if(overlays&&(mounted=this.node.prop(NodeProp.mounted))&&mounted.overlay){var rPos=pos-this.from;var _iterator275=_createForOfIteratorHelper(mounted.overlay),_step275;try{for(_iterator275.s();!(_step275=_iterator275.n()).done;){var _step275$value=_step275.value,from=_step275$value.from,to=_step275$value.to;if((side>0?from<=rPos:from<rPos)&&(side<0?to>=rPos:to>rPos))return new TreeNode(mounted.tree,mounted.overlay[0].from+this.from,-1,this);}}catch(err){_iterator275.e(err);}finally{_iterator275.f();}}return this.nextChild(0,1,pos,side,buffers?0:2/* NoEnterBuffer */);}},{key:"nextSignificantParent",value:function nextSignificantParent(){var val=this;while(val.type.isAnonymous&&val._parent){val=val._parent;}return val;}},{key:"parent",get:function get(){return this._parent?this._parent.nextSignificantParent():null;}},{key:"nextSibling",get:function get(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4/* DontCare */):null;}},{key:"prevSibling",get:function get(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4/* DontCare */):null;}},{key:"cursor",get:function get(){return new TreeCursor(this);}},{key:"tree",get:function get(){return this.node;}},{key:"toTree",value:function toTree(){return this.node;}},{key:"resolve",value:function resolve(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return resolveNode(this,pos,side,false);}},{key:"resolveInner",value:function resolveInner(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return resolveNode(this,pos,side,true);}},{key:"enterUnfinishedNodesBefore",value:function enterUnfinishedNodesBefore(pos){return _enterUnfinishedNodesBefore(this,pos);}},{key:"getChild",value:function getChild(type){var before=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var after=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var r=_getChildren(this,type,before,after);return r.length?r[0]:null;}},{key:"getChildren",value:function getChildren(type){var before=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var after=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return _getChildren(this,type,before,after);}/// @internal
47904790+},{key:"toString",value:function toString(){return this.node.toString();}}]);return TreeNode;}();function _getChildren(node,type,before,after){var cur=node.cursor,result=[];if(!cur.firstChild())return result;if(before!=null)while(!cur.type.is(before)){if(!cur.nextSibling())return result;}for(;;){if(after!=null&&cur.type.is(after))return result;if(cur.type.is(type))result.push(cur.node);if(!cur.nextSibling())return after==null?result:[];}}var BufferContext=/*#__PURE__*/_createClass(function BufferContext(parent,buffer,index,start){_classCallCheck(this,BufferContext);this.parent=parent;this.buffer=buffer;this.index=index;this.start=start;});var BufferNode=/*#__PURE__*/function(){function BufferNode(context,_parent,index){_classCallCheck(this,BufferNode);this.context=context;this._parent=_parent;this.index=index;this.type=context.buffer.set.types[context.buffer.buffer[index]];}_createClass(BufferNode,[{key:"name",get:function get(){return this.type.name;}},{key:"from",get:function get(){return this.context.start+this.context.buffer.buffer[this.index+1];}},{key:"to",get:function get(){return this.context.start+this.context.buffer.buffer[this.index+2];}},{key:"child",value:function child(dir,pos,side){var buffer=this.context.buffer;var index=buffer.findChild(this.index+4,buffer.buffer[this.index+3],dir,pos-this.context.start,side);return index<0?null:new BufferNode(this.context,this,index);}},{key:"firstChild",get:function get(){return this.child(1,0,4/* DontCare */);}},{key:"lastChild",get:function get(){return this.child(-1,0,4/* DontCare */);}},{key:"childAfter",value:function childAfter(pos){return this.child(1,pos,2/* After */);}},{key:"childBefore",value:function childBefore(pos){return this.child(-1,pos,-2/* Before */);}},{key:"enter",value:function enter(pos,side,overlays){var buffers=arguments.length>3&&arguments[3]!==undefined?arguments[3]:true;if(!buffers)return null;var buffer=this.context.buffer;var index=buffer.findChild(this.index+4,buffer.buffer[this.index+3],side>0?1:-1,pos-this.context.start,side);return index<0?null:new BufferNode(this.context,this,index);}},{key:"parent",get:function get(){return this._parent||this.context.parent.nextSignificantParent();}},{key:"externalSibling",value:function externalSibling(dir){return this._parent?null:this.context.parent.nextChild(this.context.index+dir,dir,0,4/* DontCare */);}},{key:"nextSibling",get:function get(){var buffer=this.context.buffer;var after=buffer.buffer[this.index+3];if(after<(this._parent?buffer.buffer[this._parent.index+3]:buffer.buffer.length))return new BufferNode(this.context,this._parent,after);return this.externalSibling(1);}},{key:"prevSibling",get:function get(){var buffer=this.context.buffer;var parentStart=this._parent?this._parent.index+4:0;if(this.index==parentStart)return this.externalSibling(-1);return new BufferNode(this.context,this._parent,buffer.findChild(parentStart,this.index,-1,0,4/* DontCare */));}},{key:"cursor",get:function get(){return new TreeCursor(this);}},{key:"tree",get:function get(){return null;}},{key:"toTree",value:function toTree(){var children=[],positions=[];var buffer=this.context.buffer;var startI=this.index+4,endI=buffer.buffer[this.index+3];if(endI>startI){var from=buffer.buffer[this.index+1],to=buffer.buffer[this.index+2];children.push(buffer.slice(startI,endI,from,to));positions.push(0);}return new Tree(this.type,children,positions,this.to-this.from);}},{key:"resolve",value:function resolve(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return resolveNode(this,pos,side,false);}},{key:"resolveInner",value:function resolveInner(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return resolveNode(this,pos,side,true);}},{key:"enterUnfinishedNodesBefore",value:function enterUnfinishedNodesBefore(pos){return _enterUnfinishedNodesBefore(this,pos);}/// @internal
47914791+},{key:"toString",value:function toString(){return this.context.buffer.childString(this.index);}},{key:"getChild",value:function getChild(type){var before=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var after=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var r=_getChildren(this,type,before,after);return r.length?r[0]:null;}},{key:"getChildren",value:function getChildren(type){var before=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var after=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return _getChildren(this,type,before,after);}}]);return BufferNode;}();/// A tree cursor object focuses on a given node in a syntax tree, and
47924792+/// allows you to move to adjacent nodes.
47934793+var TreeCursor=/*#__PURE__*/function(){/// @internal
47944794+function TreeCursor(node){var mode=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;_classCallCheck(this,TreeCursor);this.mode=mode;this.buffer=null;this.stack=[];this.index=0;this.bufferNode=null;if(node instanceof TreeNode){this.yieldNode(node);}else{this._tree=node.context.parent;this.buffer=node.context;for(var n=node._parent;n;n=n._parent){this.stack.unshift(n.index);}this.bufferNode=node;this.yieldBuf(node.index);}}/// Shorthand for `.type.name`.
47954795+_createClass(TreeCursor,[{key:"name",get:function get(){return this.type.name;}},{key:"yieldNode",value:function yieldNode(node){if(!node)return false;this._tree=node;this.type=node.type;this.from=node.from;this.to=node.to;return true;}},{key:"yieldBuf",value:function yieldBuf(index,type){this.index=index;var _this$buffer=this.buffer,start=_this$buffer.start,buffer=_this$buffer.buffer;this.type=type||buffer.set.types[buffer.buffer[index]];this.from=start+buffer.buffer[index+1];this.to=start+buffer.buffer[index+2];return true;}},{key:"yield",value:function _yield(node){if(!node)return false;if(node instanceof TreeNode){this.buffer=null;return this.yieldNode(node);}this.buffer=node.context;return this.yieldBuf(node.index,node.type);}/// @internal
47964796+},{key:"toString",value:function toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString();}/// @internal
47974797+},{key:"enterChild",value:function enterChild(dir,pos,side){if(!this.buffer)return this["yield"](this._tree.nextChild(dir<0?this._tree.node.children.length-1:0,dir,pos,side,this.mode));var buffer=this.buffer.buffer;var index=buffer.findChild(this.index+4,buffer.buffer[this.index+3],dir,pos-this.buffer.start,side);if(index<0)return false;this.stack.push(this.index);return this.yieldBuf(index);}/// Move the cursor to this node's first child. When this returns
47984798+/// false, the node has no child, and the cursor has not been moved.
47994799+},{key:"firstChild",value:function firstChild(){return this.enterChild(1,0,4/* DontCare */);}/// Move the cursor to this node's last child.
48004800+},{key:"lastChild",value:function lastChild(){return this.enterChild(-1,0,4/* DontCare */);}/// Move the cursor to the first child that ends after `pos`.
48014801+},{key:"childAfter",value:function childAfter(pos){return this.enterChild(1,pos,2/* After */);}/// Move to the last child that starts before `pos`.
48024802+},{key:"childBefore",value:function childBefore(pos){return this.enterChild(-1,pos,-2/* Before */);}/// Move the cursor to the child around `pos`. If side is -1 the
48034803+/// child may end at that position, when 1 it may start there. This
48044804+/// will also enter [overlaid](#common.MountedTree.overlay)
48054805+/// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
48064806+/// set to false.
48074807+},{key:"enter",value:function enter(pos,side){var overlays=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var buffers=arguments.length>3&&arguments[3]!==undefined?arguments[3]:true;if(!this.buffer)return this["yield"](this._tree.enter(pos,side,overlays&&!(this.mode&1/* Full */),buffers));return buffers?this.enterChild(1,pos,side):false;}/// Move to the node's parent node, if this isn't the top node.
48084808+},{key:"parent",value:function parent(){if(!this.buffer)return this.yieldNode(this.mode&1/* Full */?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());var parent=this.mode&1/* Full */?this.buffer.parent:this.buffer.parent.nextSignificantParent();this.buffer=null;return this.yieldNode(parent);}/// @internal
48094809+},{key:"sibling",value:function sibling(dir){if(!this.buffer)return!this._tree._parent?false:this["yield"](this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+dir,dir,0,4/* DontCare */,this.mode));var buffer=this.buffer.buffer,d=this.stack.length-1;if(dir<0){var parentStart=d<0?0:this.stack[d]+4;if(this.index!=parentStart)return this.yieldBuf(buffer.findChild(parentStart,this.index,-1,0,4/* DontCare */));}else{var after=buffer.buffer[this.index+3];if(after<(d<0?buffer.buffer.length:buffer.buffer[this.stack[d]+3]))return this.yieldBuf(after);}return d<0?this["yield"](this.buffer.parent.nextChild(this.buffer.index+dir,dir,0,4/* DontCare */,this.mode)):false;}/// Move to this node's next sibling, if any.
48104810+},{key:"nextSibling",value:function nextSibling(){return this.sibling(1);}/// Move to this node's previous sibling, if any.
48114811+},{key:"prevSibling",value:function prevSibling(){return this.sibling(-1);}},{key:"atLastNode",value:function atLastNode(dir){var index,parent,buffer=this.buffer;if(buffer){if(dir>0){if(this.index<buffer.buffer.buffer.length)return false;}else{for(var _i191=0;_i191<this.index;_i191++){if(buffer.buffer.buffer[_i191+3]<this.index)return false;}}index=buffer.index;parent=buffer.parent;}else{var _this$_tree=this._tree;index=_this$_tree.index;parent=_this$_tree._parent;}for(;parent;_parent3=parent,index=_parent3.index,parent=_parent3._parent,_parent3){var _parent3;if(index>-1)for(var _i192=index+dir,e=dir<0?-1:parent.node.children.length;_i192!=e;_i192+=dir){var child=parent.node.children[_i192];if(this.mode&1/* Full */||child instanceof TreeBuffer||!child.type.isAnonymous||hasChild(child))return false;}}return true;}},{key:"move",value:function move(dir,enter){if(enter&&this.enterChild(dir,0,4/* DontCare */))return true;for(;;){if(this.sibling(dir))return true;if(this.atLastNode(dir)||!this.parent())return false;}}/// Move to the next node in a
48124812+/// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR))
48134813+/// traversal, going from a node to its first child or, if the
48144814+/// current node is empty or `enter` is false, its next sibling or
48154815+/// the next sibling of the first parent node that has one.
48164816+},{key:"next",value:function next(){var enter=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;return this.move(1,enter);}/// Move to the next node in a last-to-first pre-order traveral. A
48174817+/// node is followed by its last child or, if it has none, its
48184818+/// previous sibling or the previous sibling of the first parent
48194819+/// node that has one.
48204820+},{key:"prev",value:function prev(){var enter=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;return this.move(-1,enter);}/// Move the cursor to the innermost node that covers `pos`. If
48214821+/// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
48224822+/// it will enter nodes that start at `pos`.
48234823+},{key:"moveTo",value:function moveTo(pos){var side=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;// Move up to a node that actually holds the position, if possible
48244824+while(this.from==this.to||(side<1?this.from>=pos:this.from>pos)||(side>-1?this.to<=pos:this.to<pos)){if(!this.parent())break;}// Then scan down into child nodes as far as possible
48254825+while(this.enterChild(1,pos,side)){}return this;}/// Get a [syntax node](#common.SyntaxNode) at the cursor's current
48264826+/// position.
48274827+},{key:"node",get:function get(){if(!this.buffer)return this._tree;var cache=this.bufferNode,result=null,depth=0;if(cache&&cache.context==this.buffer){scan:for(var index=this.index,d=this.stack.length;d>=0;){for(var c=cache;c;c=c._parent){if(c.index==index){if(index==this.index)return c;result=c;depth=d+1;break scan;}}index=this.stack[--d];}}for(var _i193=depth;_i193<this.stack.length;_i193++){result=new BufferNode(this.buffer,result,this.stack[_i193]);}return this.bufferNode=new BufferNode(this.buffer,result,this.index);}/// Get the [tree](#common.Tree) that represents the current node, if
48284828+/// any. Will return null when the node is in a [tree
48294829+/// buffer](#common.TreeBuffer).
48304830+},{key:"tree",get:function get(){return this.buffer?null:this._tree.node;}}]);return TreeCursor;}();function hasChild(tree){return tree.children.some(function(ch){return ch instanceof TreeBuffer||!ch.type.isAnonymous||hasChild(ch);});}function buildTree(data){var _a;var buffer=data.buffer,nodeSet=data.nodeSet,_data$maxBufferLength=data.maxBufferLength,maxBufferLength=_data$maxBufferLength===void 0?DefaultBufferLength:_data$maxBufferLength,_data$reused=data.reused,reused=_data$reused===void 0?[]:_data$reused,_data$minRepeatType=data.minRepeatType,minRepeatType=_data$minRepeatType===void 0?nodeSet.types.length:_data$minRepeatType;var cursor=Array.isArray(buffer)?new FlatBufferCursor(buffer,buffer.length):buffer;var types=nodeSet.types;var contextHash=0,lookAhead=0;function takeNode(parentStart,minPos,children,positions,inRepeat){var id=cursor.id,start=cursor.start,end=cursor.end,size=cursor.size;var lookAheadAtStart=lookAhead;while(size<0){cursor.next();if(size==-1/* Reuse */){var _node=reused[id];children.push(_node);positions.push(start-parentStart);return;}else if(size==-3/* ContextChange */){// Context change
48314831+contextHash=id;return;}else if(size==-4/* LookAhead */){lookAhead=id;return;}else{throw new RangeError("Unrecognized record size: ".concat(size));}}var type=types[id],node,buffer;var startPos=start-parentStart;if(end-start<=maxBufferLength&&(buffer=findBufferSize(cursor.pos-minPos,inRepeat))){// Small enough for a buffer, and no reused nodes inside
48324832+var _data=new Uint16Array(buffer.size-buffer.skip);var endPos=cursor.pos-buffer.size,index=_data.length;while(cursor.pos>endPos){index=copyToBuffer(buffer.start,_data,index);}node=new TreeBuffer(_data,end-buffer.start,nodeSet);startPos=buffer.start-parentStart;}else{// Make it a node
48334833+var _endPos=cursor.pos-size;cursor.next();var localChildren=[],localPositions=[];var localInRepeat=id>=minRepeatType?id:-1;var lastGroup=0,lastEnd=end;while(cursor.pos>_endPos){if(localInRepeat>=0&&cursor.id==localInRepeat&&cursor.size>=0){if(cursor.end<=lastEnd-maxBufferLength){makeRepeatLeaf(localChildren,localPositions,start,lastGroup,cursor.end,lastEnd,localInRepeat,lookAheadAtStart);lastGroup=localChildren.length;lastEnd=cursor.end;}cursor.next();}else{takeNode(start,_endPos,localChildren,localPositions,localInRepeat);}}if(localInRepeat>=0&&lastGroup>0&&lastGroup<localChildren.length)makeRepeatLeaf(localChildren,localPositions,start,lastGroup,start,lastEnd,localInRepeat,lookAheadAtStart);localChildren.reverse();localPositions.reverse();if(localInRepeat>-1&&lastGroup>0){var make=makeBalanced(type);node=balanceRange(type,localChildren,localPositions,0,localChildren.length,0,end-start,make,make);}else{node=makeTree(type,localChildren,localPositions,end-start,lookAheadAtStart-end);}}children.push(node);positions.push(startPos);}function makeBalanced(type){return function(children,positions,length){var lookAhead=0,lastI=children.length-1,last,lookAheadProp;if(lastI>=0&&(last=children[lastI])instanceof Tree){if(!lastI&&last.type==type&&last.length==length)return last;if(lookAheadProp=last.prop(NodeProp.lookAhead))lookAhead=positions[lastI]+last.length+lookAheadProp;}return makeTree(type,children,positions,length,lookAhead);};}function makeRepeatLeaf(children,positions,base,i,from,to,type,lookAhead){var localChildren=[],localPositions=[];while(children.length>i){localChildren.push(children.pop());localPositions.push(positions.pop()+base-from);}children.push(makeTree(nodeSet.types[type],localChildren,localPositions,to-from,lookAhead-to));positions.push(from-base);}function makeTree(type,children,positions,length){var lookAhead=arguments.length>4&&arguments[4]!==undefined?arguments[4]:0;var props=arguments.length>5?arguments[5]:undefined;if(contextHash){var pair=[NodeProp.contextHash,contextHash];props=props?[pair].concat(props):[pair];}if(lookAhead>25){var _pair=[NodeProp.lookAhead,lookAhead];props=props?[_pair].concat(props):[_pair];}return new Tree(type,children,positions,length,props);}function findBufferSize(maxSize,inRepeat){// Scan through the buffer to find previous siblings that fit
48344834+// together in a TreeBuffer, and don't contain any reused nodes
48354835+// (which can't be stored in a buffer).
48364836+// If `inRepeat` is > -1, ignore node boundaries of that type for
48374837+// nesting, but make sure the end falls either at the start
48384838+// (`maxSize`) or before such a node.
48394839+var fork=cursor.fork();var size=0,start=0,skip=0,minStart=fork.end-maxBufferLength;var result={size:0,start:0,skip:0};scan:for(var minPos=fork.pos-maxSize;fork.pos>minPos;){var _nodeSize=fork.size;// Pretend nested repeat nodes of the same type don't exist
48404840+if(fork.id==inRepeat&&_nodeSize>=0){// Except that we store the current state as a valid return
48414841+// value.
48424842+result.size=size;result.start=start;result.skip=skip;skip+=4;size+=4;fork.next();continue;}var startPos=fork.pos-_nodeSize;if(_nodeSize<0||startPos<minPos||fork.start<minStart)break;var localSkipped=fork.id>=minRepeatType?4:0;var nodeStart=fork.start;fork.next();while(fork.pos>startPos){if(fork.size<0){if(fork.size==-3/* ContextChange */)localSkipped+=4;else break scan;}else if(fork.id>=minRepeatType){localSkipped+=4;}fork.next();}start=nodeStart;size+=_nodeSize;skip+=localSkipped;}if(inRepeat<0||size==maxSize){result.size=size;result.start=start;result.skip=skip;}return result.size>4?result:undefined;}function copyToBuffer(bufferStart,buffer,index){var id=cursor.id,start=cursor.start,end=cursor.end,size=cursor.size;cursor.next();if(size>=0&&id<minRepeatType){var startIndex=index;if(size>4){var endPos=cursor.pos-(size-4);while(cursor.pos>endPos){index=copyToBuffer(bufferStart,buffer,index);}}buffer[--index]=startIndex;buffer[--index]=end-bufferStart;buffer[--index]=start-bufferStart;buffer[--index]=id;}else if(size==-3/* ContextChange */){contextHash=id;}else if(size==-4/* LookAhead */){lookAhead=id;}return index;}var children=[],positions=[];while(cursor.pos>0){takeNode(data.start||0,data.bufferStart||0,children,positions,-1);}var length=(_a=data.length)!==null&&_a!==void 0?_a:children.length?positions[0]+children[0].length:0;return new Tree(types[data.topID],children.reverse(),positions.reverse(),length);}var nodeSizeCache=new WeakMap();function nodeSize(balanceType,node){if(!balanceType.isAnonymous||node instanceof TreeBuffer||node.type!=balanceType)return 1;var size=nodeSizeCache.get(node);if(size==null){size=1;var _iterator276=_createForOfIteratorHelper(node.children),_step276;try{for(_iterator276.s();!(_step276=_iterator276.n()).done;){var child=_step276.value;if(child.type!=balanceType||!(child instanceof Tree)){size=1;break;}size+=nodeSize(balanceType,child);}}catch(err){_iterator276.e(err);}finally{_iterator276.f();}nodeSizeCache.set(node,size);}return size;}function balanceRange(// The type the balanced tree's inner nodes.
48434843+balanceType,// The direct children and their positions
48444844+children,positions,// The index range in children/positions to use
48454845+from,to,// The start position of the nodes, relative to their parent.
48464846+start,// Length of the outer node
48474847+length,// Function to build the top node of the balanced tree
48484848+mkTop,// Function to build internal nodes for the balanced tree
48494849+mkTree){var total=0;for(var _i194=from;_i194<to;_i194++){total+=nodeSize(balanceType,children[_i194]);}var maxChild=Math.ceil(total*1.5/8/* BranchFactor */);var localChildren=[],localPositions=[];function divide(children,positions,from,to,offset){for(var _i195=from;_i195<to;){var groupFrom=_i195,groupStart=positions[_i195],groupSize=nodeSize(balanceType,children[_i195]);_i195++;for(;_i195<to;_i195++){var nextSize=nodeSize(balanceType,children[_i195]);if(groupSize+nextSize>=maxChild)break;groupSize+=nextSize;}if(_i195==groupFrom+1){if(groupSize>maxChild){var only=children[groupFrom];// Only trees can have a size > 1
48504850+divide(only.children,only.positions,0,only.children.length,positions[groupFrom]+offset);continue;}localChildren.push(children[groupFrom]);}else{var _length=positions[_i195-1]+children[_i195-1].length-groupStart;localChildren.push(balanceRange(balanceType,children,positions,groupFrom,_i195,groupStart,_length,null,mkTree));}localPositions.push(groupStart+offset-start);}}divide(children,positions,from,to,0);return(mkTop||mkTree)(localChildren,localPositions,length);}/// Tree fragments are used during [incremental
48514851+/// parsing](#common.Parser.startParse) to track parts of old trees
48524852+/// that can be reused in a new parse. An array of fragments is used
48534853+/// to track regions of an old tree whose nodes might be reused in new
48544854+/// parses. Use the static
48554855+/// [`applyChanges`](#common.TreeFragment^applyChanges) method to
48564856+/// update fragments for document changes.
48574857+var TreeFragment=/*#__PURE__*/function(){/// Construct a tree fragment.
48584858+function TreeFragment(/// The start of the unchanged range pointed to by this fragment.
48594859+/// This refers to an offset in the _updated_ document (as opposed
48604860+/// to the original tree).
48614861+from,/// The end of the unchanged range.
48624862+to,/// The tree that this fragment is based on.
48634863+tree,/// The offset between the fragment's tree and the document that
48644864+/// this fragment can be used against. Add this when going from
48654865+/// document to tree positions, subtract it to go from tree to
48664866+/// document positions.
48674867+offset){var openStart=arguments.length>4&&arguments[4]!==undefined?arguments[4]:false;var openEnd=arguments.length>5&&arguments[5]!==undefined?arguments[5]:false;_classCallCheck(this,TreeFragment);this.from=from;this.to=to;this.tree=tree;this.offset=offset;this.open=(openStart?1/* Start */:0)|(openEnd?2/* End */:0);}/// Whether the start of the fragment represents the start of a
48684868+/// parse, or the end of a change. (In the second case, it may not
48694869+/// be safe to reuse some nodes at the start, depending on the
48704870+/// parsing algorithm.)
48714871+_createClass(TreeFragment,[{key:"openStart",get:function get(){return(this.open&1/* Start */)>0;}/// Whether the end of the fragment represents the end of a
48724872+/// full-document parse, or the start of a change.
48734873+},{key:"openEnd",get:function get(){return(this.open&2/* End */)>0;}/// Create a set of fragments from a freshly parsed tree, or update
48744874+/// an existing set of fragments by replacing the ones that overlap
48754875+/// with a tree with content from the new tree. When `partial` is
48764876+/// true, the parse is treated as incomplete, and the resulting
48774877+/// fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
48784878+/// true.
48794879+}],[{key:"addTree",value:function addTree(tree){var fragments=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var partial=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var result=[new TreeFragment(0,tree.length,tree,0,false,partial)];var _iterator277=_createForOfIteratorHelper(fragments),_step277;try{for(_iterator277.s();!(_step277=_iterator277.n()).done;){var f=_step277.value;if(f.to>tree.length)result.push(f);}}catch(err){_iterator277.e(err);}finally{_iterator277.f();}return result;}/// Apply a set of edits to an array of fragments, removing or
48804880+/// splitting fragments as necessary to remove edited ranges, and
48814881+/// adjusting offsets for fragments that moved.
48824882+},{key:"applyChanges",value:function applyChanges(fragments,changes){var minGap=arguments.length>2&&arguments[2]!==undefined?arguments[2]:128;if(!changes.length)return fragments;var result=[];var fI=1,nextF=fragments.length?fragments[0]:null;for(var cI=0,pos=0,off=0;;cI++){var nextC=cI<changes.length?changes[cI]:null;var nextPos=nextC?nextC.fromA:1e9;if(nextPos-pos>=minGap)while(nextF&&nextF.from<nextPos){var cut=nextF;if(pos>=cut.from||nextPos<=cut.to||off){var fFrom=Math.max(cut.from,pos)-off,fTo=Math.min(cut.to,nextPos)-off;cut=fFrom>=fTo?null:new TreeFragment(fFrom,fTo,cut.tree,cut.offset+off,cI>0,!!nextC);}if(cut)result.push(cut);if(nextF.to>nextPos)break;nextF=fI<fragments.length?fragments[fI++]:null;}if(!nextC)break;pos=nextC.toA;off=nextC.toA-nextC.toB;}return result;}}]);return TreeFragment;}();/// A superclass that parsers should extend.
48834883+var Parser=/*#__PURE__*/function(){function Parser(){_classCallCheck(this,Parser);}_createClass(Parser,[{key:"startParse",value:/// Start a parse, returning a [partial parse](#common.PartialParse)
48844884+/// object. [`fragments`](#common.TreeFragment) can be passed in to
48854885+/// make the parse incremental.
48864886+///
48874887+/// By default, the entire input is parsed. You can pass `ranges`,
48884888+/// which should be a sorted array of non-empty, non-overlapping
48894889+/// ranges, to parse only those ranges. The tree returned in that
48904890+/// case will start at `ranges[0].from`.
48914891+function startParse(input,fragments,ranges){if(typeof input=="string")input=new StringInput(input);ranges=!ranges?[new Range(0,input.length)]:ranges.length?ranges.map(function(r){return new Range(r.from,r.to);}):[new Range(0,0)];return this.createParse(input,fragments||[],ranges);}/// Run a full parse, returning the resulting tree.
48924892+},{key:"parse",value:function parse(input,fragments,ranges){var parse=this.startParse(input,fragments,ranges);for(;;){var done=parse.advance();if(done)return done;}}}]);return Parser;}();var StringInput=/*#__PURE__*/function(){function StringInput(string){_classCallCheck(this,StringInput);this.string=string;}_createClass(StringInput,[{key:"length",get:function get(){return this.string.length;}},{key:"chunk",value:function chunk(from){return this.string.slice(from);}},{key:"lineChunks",get:function get(){return false;}},{key:"read",value:function read(from,to){return this.string.slice(from,to);}}]);return StringInput;}();/// Create a parse wrapper that, after the inner parse completes,
48934893+/// scans its tree for mixed language regions with the `nest`
48944894+/// function, runs the resulting [inner parses](#common.NestedParse),
48954895+/// and then [mounts](#common.NodeProp^mounted) their results onto the
48964896+/// tree.
48974897+///
48984898+/// The nesting function is passed a cursor to provide context for a
48994899+/// node, but _should not_ move that cursor, only inspect its
49004900+/// properties and optionally access its
49014901+/// [node object](#common.TreeCursor.node).
49024902+function parseMixed(nest){return function(parse,input,fragments,ranges){return new MixedParse(parse,nest,input,fragments,ranges);};}var InnerParse=/*#__PURE__*/_createClass(function InnerParse(parser,parse,overlay,target,ranges){_classCallCheck(this,InnerParse);this.parser=parser;this.parse=parse;this.overlay=overlay;this.target=target;this.ranges=ranges;});var ActiveOverlay=/*#__PURE__*/_createClass(function ActiveOverlay(parser,predicate,mounts,index,start,target,prev){_classCallCheck(this,ActiveOverlay);this.parser=parser;this.predicate=predicate;this.mounts=mounts;this.index=index;this.start=start;this.target=target;this.prev=prev;this.depth=0;this.ranges=[];});var stoppedInner=new NodeProp({perNode:true});var MixedParse=/*#__PURE__*/function(){function MixedParse(base,nest,input,fragments,ranges){_classCallCheck(this,MixedParse);this.nest=nest;this.input=input;this.fragments=fragments;this.ranges=ranges;this.inner=[];this.innerDone=0;this.baseTree=null;this.stoppedAt=null;this.baseParse=base;}_createClass(MixedParse,[{key:"advance",value:function advance(){if(this.baseParse){var _done=this.baseParse.advance();if(!_done)return null;this.baseParse=null;this.baseTree=_done;this.startInner();if(this.stoppedAt!=null){var _iterator278=_createForOfIteratorHelper(this.inner),_step278;try{for(_iterator278.s();!(_step278=_iterator278.n()).done;){var _inner=_step278.value;_inner.parse.stopAt(this.stoppedAt);}}catch(err){_iterator278.e(err);}finally{_iterator278.f();}}}if(this.innerDone==this.inner.length){var result=this.baseTree;if(this.stoppedAt!=null)result=new Tree(result.type,result.children,result.positions,result.length,result.propValues.concat([[stoppedInner,this.stoppedAt]]));return result;}var inner=this.inner[this.innerDone],done=inner.parse.advance();if(done){this.innerDone++;// This is a somewhat dodgy but super helpful hack where we
49034903+// patch up nodes created by the inner parse (and thus
49044904+// presumably not aliased anywhere else) to hold the information
49054905+// about the inner parse.
49064906+var props=Object.assign(Object.create(null),inner.target.props);props[NodeProp.mounted.id]=new MountedTree(done,inner.overlay,inner.parser);inner.target.props=props;}return null;}},{key:"parsedPos",get:function get(){if(this.baseParse)return 0;var pos=this.input.length;for(var _i196=this.innerDone;_i196<this.inner.length;_i196++){if(this.inner[_i196].ranges[0].from<pos)pos=Math.min(pos,this.inner[_i196].parse.parsedPos);}return pos;}},{key:"stopAt",value:function stopAt(pos){this.stoppedAt=pos;if(this.baseParse)this.baseParse.stopAt(pos);else for(var _i197=this.innerDone;_i197<this.inner.length;_i197++){this.inner[_i197].parse.stopAt(pos);}}},{key:"startInner",value:function startInner(){var fragmentCursor=new FragmentCursor(this.fragments);var overlay=null;var covered=null;var cursor=new TreeCursor(new TreeNode(this.baseTree,this.ranges[0].from,0,null),1/* Full */);scan:for(var nest,isCovered;this.stoppedAt==null||cursor.from<this.stoppedAt;){var enter=true,range=void 0;if(fragmentCursor.hasNode(cursor)){if(overlay){var match=overlay.mounts.find(function(m){return m.frag.from<=cursor.from&&m.frag.to>=cursor.to&&m.mount.overlay;});if(match){var _iterator279=_createForOfIteratorHelper(match.mount.overlay),_step279;try{for(_iterator279.s();!(_step279=_iterator279.n()).done;){var r=_step279.value;var from=r.from+match.pos,to=r.to+match.pos;if(from>=cursor.from&&to<=cursor.to)overlay.ranges.push({from:from,to:to});}}catch(err){_iterator279.e(err);}finally{_iterator279.f();}}}enter=false;}else if(covered&&(isCovered=checkCover(covered.ranges,cursor.from,cursor.to))){enter=isCovered!=2/* Full */;}else if(!cursor.type.isAnonymous&&cursor.from<cursor.to&&(nest=this.nest(cursor,this.input))){if(!cursor.tree)materialize(cursor);var oldMounts=fragmentCursor.findMounts(cursor.from,nest.parser);if(typeof nest.overlay=="function"){overlay=new ActiveOverlay(nest.parser,nest.overlay,oldMounts,this.inner.length,cursor.from,cursor.tree,overlay);}else{var ranges=punchRanges(this.ranges,nest.overlay||[new Range(cursor.from,cursor.to)]);if(ranges.length)this.inner.push(new InnerParse(nest.parser,nest.parser.startParse(this.input,enterFragments(oldMounts,ranges),ranges),nest.overlay?nest.overlay.map(function(r){return new Range(r.from-cursor.from,r.to-cursor.from);}):null,cursor.tree,ranges));if(!nest.overlay)enter=false;else if(ranges.length)covered={ranges:ranges,depth:0,prev:covered};}}else if(overlay&&(range=overlay.predicate(cursor))){if(range===true)range=new Range(cursor.from,cursor.to);if(range.from<range.to)overlay.ranges.push(range);}if(enter&&cursor.firstChild()){if(overlay)overlay.depth++;if(covered)covered.depth++;}else{for(;;){if(cursor.nextSibling())break;if(!cursor.parent())break scan;if(overlay&&! --overlay.depth){var _ranges=punchRanges(this.ranges,overlay.ranges);if(_ranges.length)this.inner.splice(overlay.index,0,new InnerParse(overlay.parser,overlay.parser.startParse(this.input,enterFragments(overlay.mounts,_ranges),_ranges),overlay.ranges.map(function(r){return new Range(r.from-overlay.start,r.to-overlay.start);}),overlay.target,_ranges));overlay=overlay.prev;}if(covered&&! --covered.depth)covered=covered.prev;}}}}}]);return MixedParse;}();function checkCover(covered,from,to){var _iterator280=_createForOfIteratorHelper(covered),_step280;try{for(_iterator280.s();!(_step280=_iterator280.n()).done;){var range=_step280.value;if(range.from>=to)break;if(range.to>from)return range.from<=from&&range.to>=to?2/* Full */:1/* Partial */;}}catch(err){_iterator280.e(err);}finally{_iterator280.f();}return 0/* None */;}// Take a piece of buffer and convert it into a stand-alone
49074907+// TreeBuffer.
49084908+function sliceBuf(buf,startI,endI,nodes,positions,off){if(startI<endI){var from=buf.buffer[startI+1],to=buf.buffer[endI-2];nodes.push(buf.slice(startI,endI,from,to));positions.push(from-off);}}// This function takes a node that's in a buffer, and converts it, and
49094909+// its parent buffer nodes, into a Tree. This is again acting on the
49104910+// assumption that the trees and buffers have been constructed by the
49114911+// parse that was ran via the mix parser, and thus aren't shared with
49124912+// any other code, making violations of the immutability safe.
49134913+function materialize(cursor){var node=cursor.node,depth=0;// Scan up to the nearest tree
49144914+do{cursor.parent();depth++;}while(!cursor.tree);// Find the index of the buffer in that tree
49154915+var i=0,base=cursor.tree,off=0;for(;;i++){off=base.positions[i]+cursor.from;if(off<=node.from&&off+base.children[i].length>=node.to)break;}var buf=base.children[i],b=buf.buffer;// Split a level in the buffer, putting the nodes before and after
49164916+// the child that contains `node` into new buffers.
49174917+function split(startI,endI,type,innerOffset,length){var i=startI;while(b[i+2]+off<=node.from){i=b[i+3];}var children=[],positions=[];sliceBuf(buf,startI,i,children,positions,innerOffset);var from=b[i+1],to=b[i+2];var isTarget=from+off==node.from&&to+off==node.to&&b[i]==node.type.id;children.push(isTarget?node.toTree():split(i+4,b[i+3],buf.set.types[b[i]],from,to-from));positions.push(from-innerOffset);sliceBuf(buf,b[i+3],endI,children,positions,innerOffset);return new Tree(type,children,positions,length);}base.children[i]=split(0,b.length,NodeType.none,0,buf.length);// Move the cursor back to the target node
49184918+for(var d=0;d<=depth;d++){cursor.childAfter(node.from);}}var StructureCursor=/*#__PURE__*/function(){function StructureCursor(root,offset){_classCallCheck(this,StructureCursor);this.offset=offset;this.done=false;this.cursor=root.fullCursor();}// Move to the first node (in pre-order) that starts at or after `pos`.
49194919+_createClass(StructureCursor,[{key:"moveTo",value:function moveTo(pos){var cursor=this.cursor,p=pos-this.offset;while(!this.done&&cursor.from<p){if(cursor.to>=pos&&cursor.enter(p,1,false,false));else if(!cursor.next(false))this.done=true;}}},{key:"hasNode",value:function hasNode(cursor){this.moveTo(cursor.from);if(!this.done&&this.cursor.from+this.offset==cursor.from&&this.cursor.tree){for(var tree=this.cursor.tree;;){if(tree==cursor.tree)return true;if(tree.children.length&&tree.positions[0]==0&&tree.children[0]instanceof Tree)tree=tree.children[0];else break;}}return false;}}]);return StructureCursor;}();var FragmentCursor=/*#__PURE__*/function(){function FragmentCursor(fragments){_classCallCheck(this,FragmentCursor);var _a;this.fragments=fragments;this.curTo=0;this.fragI=0;if(fragments.length){var first=this.curFrag=fragments[0];this.curTo=(_a=first.tree.prop(stoppedInner))!==null&&_a!==void 0?_a:first.to;this.inner=new StructureCursor(first.tree,-first.offset);}else{this.curFrag=this.inner=null;}}_createClass(FragmentCursor,[{key:"hasNode",value:function hasNode(node){while(this.curFrag&&node.from>=this.curTo){this.nextFrag();}return this.curFrag&&this.curFrag.from<=node.from&&this.curTo>=node.to&&this.inner.hasNode(node);}},{key:"nextFrag",value:function nextFrag(){var _a;this.fragI++;if(this.fragI==this.fragments.length){this.curFrag=this.inner=null;}else{var frag=this.curFrag=this.fragments[this.fragI];this.curTo=(_a=frag.tree.prop(stoppedInner))!==null&&_a!==void 0?_a:frag.to;this.inner=new StructureCursor(frag.tree,-frag.offset);}}},{key:"findMounts",value:function findMounts(pos,parser){var _a;var result=[];if(this.inner){this.inner.cursor.moveTo(pos,1);for(var _pos3=this.inner.cursor.node;_pos3;_pos3=_pos3.parent){var mount=(_a=_pos3.tree)===null||_a===void 0?void 0:_a.prop(NodeProp.mounted);if(mount&&mount.parser==parser){for(var _i198=this.fragI;_i198<this.fragments.length;_i198++){var frag=this.fragments[_i198];if(frag.from>=_pos3.to)break;if(frag.tree==this.curFrag.tree)result.push({frag:frag,pos:_pos3.from-frag.offset,mount:mount});}}}}return result;}}]);return FragmentCursor;}();function punchRanges(outer,ranges){var copy=null,current=ranges;for(var _i199=1,j=0;_i199<outer.length;_i199++){var gapFrom=outer[_i199-1].to,gapTo=outer[_i199].from;for(;j<current.length;j++){var r=current[j];if(r.from>=gapTo)break;if(r.to<=gapFrom)continue;if(!copy)current=copy=ranges.slice();if(r.from<gapFrom){copy[j]=new Range(r.from,gapFrom);if(r.to>gapTo)copy.splice(j+1,0,new Range(gapTo,r.to));}else if(r.to>gapTo){copy[j--]=new Range(gapTo,r.to);}else{copy.splice(j--,1);}}}return current;}function findCoverChanges(a,b,from,to){var iA=0,iB=0,inA=false,inB=false,pos=-1e9;var result=[];for(;;){var nextA=iA==a.length?1e9:inA?a[iA].to:a[iA].from;var nextB=iB==b.length?1e9:inB?b[iB].to:b[iB].from;if(inA!=inB){var start=Math.max(pos,from),end=Math.min(nextA,nextB,to);if(start<end)result.push(new Range(start,end));}pos=Math.min(nextA,nextB);if(pos==1e9)break;if(nextA==pos){if(!inA)inA=true;else{inA=false;iA++;}}if(nextB==pos){if(!inB)inB=true;else{inB=false;iB++;}}}return result;}// Given a number of fragments for the outer tree, and a set of ranges
49204920+// to parse, find fragments for inner trees mounted around those
49214921+// ranges, if any.
49224922+function enterFragments(mounts,ranges){var result=[];var _iterator281=_createForOfIteratorHelper(mounts),_step281;try{var _loop27=function _loop27(){var _step281$value=_step281.value,pos=_step281$value.pos,mount=_step281$value.mount,frag=_step281$value.frag;var startPos=pos+(mount.overlay?mount.overlay[0].from:0),endPos=startPos+mount.tree.length;var from=Math.max(frag.from,startPos),to=Math.min(frag.to,endPos);if(mount.overlay){var overlay=mount.overlay.map(function(r){return new Range(r.from+pos,r.to+pos);});var changes=findCoverChanges(ranges,overlay,from,to);for(var _i200=0,_pos4=from;;_i200++){var last=_i200==changes.length,end=last?to:changes[_i200].from;if(end>_pos4)result.push(new TreeFragment(_pos4,end,mount.tree,-startPos,frag.from>=_pos4,frag.to<=end));if(last)break;_pos4=changes[_i200].to;}}else{result.push(new TreeFragment(from,to,mount.tree,-startPos,frag.from>=startPos,frag.to<=endPos));}};for(_iterator281.s();!(_step281=_iterator281.n()).done;){_loop27();}}catch(err){_iterator281.e(err);}finally{_iterator281.f();}return result;}exports.DefaultBufferLength=DefaultBufferLength;exports.MountedTree=MountedTree;exports.NodeProp=NodeProp;exports.NodeSet=NodeSet;exports.NodeType=NodeType;exports.Parser=Parser;exports.Tree=Tree;exports.TreeBuffer=TreeBuffer;exports.TreeCursor=TreeCursor;exports.TreeFragment=TreeFragment;exports.parseMixed=parseMixed;},{}],29:[function(require,module,exports){'use strict';function crelt(){var elt=arguments[0];if(typeof elt=="string")elt=document.createElement(elt);var i=1,next=arguments[1];if(next&&_typeof(next)=="object"&&next.nodeType==null&&!Array.isArray(next)){for(var name in next){if(Object.prototype.hasOwnProperty.call(next,name)){var value=next[name];if(typeof value=="string")elt.setAttribute(name,value);else if(value!=null)elt[name]=value;}}i++;}for(;i<arguments.length;i++){add(elt,arguments[i]);}return elt;}function add(elt,child){if(typeof child=="string"){elt.appendChild(document.createTextNode(child));}else if(child==null);else if(child.nodeType!=null){elt.appendChild(child);}else if(Array.isArray(child)){for(var i=0;i<child.length;i++){add(elt,child[i]);}}else{throw new RangeError("Unsupported child node: "+child);}}module.exports=crelt;},{}],30:[function(require,module,exports){var C="\u037C";var COUNT=typeof Symbol=="undefined"?"__"+C:Symbol["for"](C);var SET=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet");var top=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{};// :: - Style modules encapsulate a set of CSS rules defined from
49234923+// JavaScript. Their definitions are only available in a given DOM
49244924+// root after it has been _mounted_ there with `StyleModule.mount`.
49254925+//
49264926+// Style modules should be created once and stored somewhere, as
49274927+// opposed to re-creating them every time you need them. The amount of
49284928+// CSS rules generated for a given DOM root is bounded by the amount
49294929+// of style modules that were used. So to avoid leaking rules, don't
49304930+// create these dynamically, but treat them as one-time allocations.
49314931+var StyleModule=exports.StyleModule=function StyleModule(spec,options){this.rules=[];var ref=options||{};var finish=ref.finish;function splitSelector(selector){return /^@/.test(selector)?[selector]:selector.split(/,\s*/);}function render(selectors,spec,target,isKeyframes){var local=[],isAt=/^@(\w+)\b/.exec(selectors[0]),keyframes=isAt&&isAt[1]=="keyframes";if(isAt&&spec==null){return target.push(selectors[0]+";");}for(var prop in spec){var value=spec[prop];if(/&/.test(prop)){render(prop.split(/,\s*/).map(function(part){return selectors.map(function(sel){return part.replace(/&/,sel);});}).reduce(function(a,b){return a.concat(b);}),value,target);}else if(value&&_typeof(value)=="object"){if(!isAt){throw new RangeError("The value of a property ("+prop+") should be a primitive value.");}render(splitSelector(prop),value,local,keyframes);}else if(value!=null){local.push(prop.replace(/_.*/,"").replace(/[A-Z]/g,function(l){return"-"+l.toLowerCase();})+": "+value+";");}}if(local.length||keyframes){target.push((finish&&!isAt&&!isKeyframes?selectors.map(finish):selectors).join(", ")+" {"+local.join(" ")+"}");}}for(var prop in spec){render(splitSelector(prop),spec[prop],this.rules);}};// :: () → string
49324932+// Returns a string containing the module's CSS rules.
49334933+StyleModule.prototype.getRules=function getRules(){return this.rules.join("\n");};// :: () → string
49344934+// Generate a new unique CSS class name.
49354935+StyleModule.newName=function newName(){var id=top[COUNT]||1;top[COUNT]=id+1;return C+id.toString(36);};// :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>)
49364936+//
49374937+// Mount the given set of modules in the given DOM root, which ensures
49384938+// that the CSS rules defined by the module are available in that
49394939+// context.
49404940+//
49414941+// Rules are only added to the document once per root.
49424942+//
49434943+// Rule order will follow the order of the modules, so that rules from
49444944+// modules later in the array take precedence of those from earlier
49454945+// modules. If you call this function multiple times for the same root
49464946+// in a way that changes the order of already mounted modules, the old
49474947+// order will be changed.
49484948+StyleModule.mount=function mount(root,modules){(root[SET]||new StyleSet(root)).mount(Array.isArray(modules)?modules:[modules]);};var adoptedSet=null;var StyleSet=function StyleSet(root){if(!root.head&&root.adoptedStyleSheets&&typeof CSSStyleSheet!="undefined"){if(adoptedSet){root.adoptedStyleSheets=[adoptedSet.sheet].concat(root.adoptedStyleSheets);return root[SET]=adoptedSet;}this.sheet=new CSSStyleSheet();root.adoptedStyleSheets=[this.sheet].concat(root.adoptedStyleSheets);adoptedSet=this;}else{this.styleTag=(root.ownerDocument||root).createElement("style");var target=root.head||root;target.insertBefore(this.styleTag,target.firstChild);}this.modules=[];root[SET]=this;};StyleSet.prototype.mount=function mount(modules){var sheet=this.sheet;var pos=0/* Current rule offset */,j=0;/* Index into this.modules */for(var i=0;i<modules.length;i++){var mod=modules[i],index=this.modules.indexOf(mod);if(index<j&&index>-1){// Ordering conflict
49494949+this.modules.splice(index,1);j--;index=-1;}if(index==-1){this.modules.splice(j++,0,mod);if(sheet){for(var k=0;k<mod.rules.length;k++){sheet.insertRule(mod.rules[k],pos++);}}}else{while(j<index){pos+=this.modules[j++].rules.length;}pos+=mod.rules.length;j++;}}if(!sheet){var text="";for(var i$1=0;i$1<this.modules.length;i$1++){text+=this.modules[i$1].getRules()+"\n";}this.styleTag.textContent=text;}};// Style::Object<union<Style,string>>
49504950+//
49514951+// A style is an object that, in the simple case, maps CSS property
49524952+// names to strings holding their values, as in `{color: "red",
49534953+// fontWeight: "bold"}`. The property names can be given in
49544954+// camel-case—the library will insert a dash before capital letters
49554955+// when converting them to CSS.
49564956+//
49574957+// If you include an underscore in a property name, it and everything
49584958+// after it will be removed from the output, which can be useful when
49594959+// providing a property multiple times, for browser compatibility
49604960+// reasons.
49614961+//
49624962+// A property in a style object can also be a sub-selector, which
49634963+// extends the current context to add a pseudo-selector or a child
49644964+// selector. Such a property should contain a `&` character, which
49654965+// will be replaced by the current selector. For example `{"&:before":
49664966+// {content: '"hi"'}}`. Sub-selectors and regular properties can
49674967+// freely be mixed in a given object. Any property containing a `&` is
49684968+// assumed to be a sub-selector.
49694969+//
49704970+// Finally, a property can specify an @-block to be wrapped around the
49714971+// styles defined inside the object that's the property's value. For
49724972+// example to create a media query you can do `{"@media screen and
49734973+// (min-width: 400px)": {...}}`.
49744974+},{}],31:[function(require,module,exports){'use strict';Object.defineProperty(exports,'__esModule',{value:true});var base={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",229:"q"};var shift={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:"\"",229:"Q"};var chrome=typeof navigator!="undefined"&&/Chrome\/(\d+)/.exec(navigator.userAgent);var safari=typeof navigator!="undefined"&&/Apple Computer/.test(navigator.vendor);var gecko=typeof navigator!="undefined"&&/Gecko\/\d+/.test(navigator.userAgent);var mac=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var ie=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);var brokenModifierNames=chrome&&(mac||+chrome[1]<57)||gecko&&mac;// Fill in the digit keys
49754975+for(var i=0;i<10;i++){base[48+i]=base[96+i]=String(i);}// The function keys
49764976+for(var i=1;i<=24;i++){base[i+111]="F"+i;}// And the alphabetic keys
49774977+for(var i=65;i<=90;i++){base[i]=String.fromCharCode(i+32);shift[i]=String.fromCharCode(i);}// For each code that doesn't have a shift-equivalent, copy the base name
49784978+for(var code in base){if(!shift.hasOwnProperty(code))shift[code]=base[code];}function keyName(event){// Don't trust event.key in Chrome when there are modifiers until
49794979+// they fix https://bugs.chromium.org/p/chromium/issues/detail?id=633838
49804980+var ignoreKey=brokenModifierNames&&(event.ctrlKey||event.altKey||event.metaKey)||(safari||ie)&&event.shiftKey&&event.key&&event.key.length==1;var name=!ignoreKey&&event.key||(event.shiftKey?shift:base)[event.keyCode]||event.key||"Unidentified";// Edge sometimes produces wrong names (Issue #3)
49814981+if(name=="Esc")name="Escape";if(name=="Del")name="Delete";// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/
49824982+if(name=="Left")name="ArrowLeft";if(name=="Up")name="ArrowUp";if(name=="Right")name="ArrowRight";if(name=="Down")name="ArrowDown";return name;}exports.base=base;exports.keyName=keyName;exports.shift=shift;},{}],32:[function(require,module,exports){(function(global){(function(){var cm={View:require('@codemirror/basic-setup').EditorView,State:require('@codemirror/basic-setup').EditorState,lint:require('@codemirror/lint'),autocomplete:require('@codemirror/autocomplete'),basicSetup:require('@codemirror/basic-setup').basicSetup,dark:require('@codemirror/theme-one-dark'),streamParser:require('@codemirror/stream-parser'),OCaml:require('@codemirror/legacy-modes/mode/mllike.cjs').oCaml};global.CodeMirror=cm;module.exports=cm;}).call(this);}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{});},{"@codemirror/autocomplete":1,"@codemirror/basic-setup":2,"@codemirror/legacy-modes/mode/mllike.cjs":14,"@codemirror/lint":15,"@codemirror/stream-parser":23,"@codemirror/theme-one-dark":25}]},{},[32])(32);});