@uiw/react-codemirror 4.21.13 → 4.21.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see codemirror.min.js.LICENSE.txt */
2
- !function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,],t):"object"===typeof exports?exports["@uiw/codemirror"]=t(require("react"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):e["@uiw/codemirror"]=t(e.React,e.CM["@codemirror/state"],e.CM["@codemirror/theme-one-dark"],e.CM["@codemirror/view"])}(self,((e,t,n,r)=>(()=>{"use strict";var i={736:(e,t,n)=>{n.r(t),n.d(t,{defaultLightThemeOption:()=>a.d,getDefaultExtensions:()=>h});var r=n(79),i=n(141),o=n(105),s=n(362),l=n(242),a=n(259),c={};for(const u in s)["default","getDefaultExtensions"].indexOf(u)<0&&(c[u]=()=>s[u]);n.d(t,c);var h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.indentWithTab,n=void 0===t||t,c=e.editable,h=void 0===c||c,u=e.readOnly,f=void 0!==u&&u,d=e.theme,p=void 0===d?"light":d,m=e.placeholder,g=void 0===m?"":m,y=e.basicSetup,v=void 0===y||y,b=[];switch(n&&b.unshift(o.keymap.of([r.oc])),v&&("boolean"===typeof v?b.unshift((0,i.X)()):b.unshift((0,i.X)(v))),g&&b.unshift((0,o.placeholder)(g)),p){case"light":b.push(a.d);break;case"dark":b.push(s.oneDark);break;case"none":break;default:b.push(p)}return!1===h&&b.push(o.EditorView.editable.of(!1)),f&&b.push(l.EditorState.readOnly.of(!0)),[].concat(b)}},259:(e,t,n)=>{n.d(t,{d:()=>i});var r=n(105),i=r.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1})},128:(e,t,n)=>{function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function i(e,t){if(e){if("string"===typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}function o(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||i(e)||function(){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 s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,s,l=[],a=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;a=!1}else for(;!(a=(r=o.call(n)).done)&&(l.push(r.value),l.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{if(!a&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return l}}(e,t)||i(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}n.d(t,{U:()=>p});var l=n(787),a=n(242),c=n(105),h=n(736),u=n(742),f=a.Annotation.define(),d=[];function p(e){var t=e.value,n=e.selection,r=e.onChange,i=e.onStatistics,p=e.onCreateEditor,m=e.onUpdate,g=e.extensions,y=void 0===g?d:g,v=e.autoFocus,b=e.theme,w=void 0===b?"light":b,x=e.height,k=void 0===x?null:x,S=e.minHeight,C=void 0===S?null:S,A=e.maxHeight,E=void 0===A?null:A,M=e.width,O=void 0===M?null:M,D=e.minWidth,I=void 0===D?null:D,P=e.maxWidth,T=void 0===P?null:P,B=e.placeholder,N=void 0===B?"":B,R=e.editable,L=void 0===R||R,_=e.readOnly,q=void 0!==_&&_,F=e.indentWithTab,j=void 0===F||F,V=e.basicSetup,W=void 0===V||V,z=e.root,U=e.initialState,$=s((0,l.useState)(),2),H=$[0],J=$[1],K=s((0,l.useState)(),2),G=K[0],Q=K[1],Z=s((0,l.useState)(),2),X=Z[0],Y=Z[1],ee=c.EditorView.theme({"&":{height:k,minHeight:C,maxHeight:E,width:O,minWidth:I,maxWidth:T},"& .cm-scroller":{height:"100% !important"}}),te=c.EditorView.updateListener.of((function(e){if(e.docChanged&&"function"===typeof r&&!e.transactions.some((function(e){return e.annotation(f)}))){var t=e.state.doc.toString();r(t,e)}i&&i((0,u.a)(e))})),ne=(0,h.getDefaultExtensions)({theme:w,editable:L,readOnly:q,placeholder:N,indentWithTab:j,basicSetup:W}),re=[te,ee].concat(o(ne));return m&&"function"===typeof m&&re.push(c.EditorView.updateListener.of(m)),re=re.concat(y),(0,l.useEffect)((function(){if(H&&!X){var e={doc:t,selection:n,extensions:re},r=U?a.EditorState.fromJSON(U.json,e,U.fields):a.EditorState.create(e);if(Y(r),!G){var i=new c.EditorView({state:r,parent:H,root:z});Q(i),p&&p(i,r)}}return function(){G&&(Y(void 0),Q(void 0))}}),[H,X]),(0,l.useEffect)((function(){return J(e.container)}),[e.container]),(0,l.useEffect)((function(){return function(){G&&(G.destroy(),Q(void 0))}}),[G]),(0,l.useEffect)((function(){v&&G&&G.focus()}),[v,G]),(0,l.useEffect)((function(){G&&G.dispatch({effects:a.StateEffect.reconfigure.of(re)})}),[w,y,k,C,E,O,I,T,N,L,q,j,W,r,m]),(0,l.useEffect)((function(){if(void 0!==t){var e=G?G.state.doc.toString():"";G&&t!==e&&G.dispatch({changes:{from:0,to:e.length,insert:t||""},annotations:[f.of(!0)]})}}),[t,G]),{state:X,setState:Y,view:G,setView:Q,container:H,setContainer:J}}},742:(e,t,n)=>{n.d(t,{a:()=>r});var r=function(e){return{line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map((function(t){return e.state.sliceDoc(t.from,t.to)})),selectedText:e.state.selection.ranges.some((function(e){return!e.empty}))}}},141:(e,t,n)=>{n.d(t,{X:()=>Rt,w:()=>Lt});var r=n(105),i=n(242),o=n(79);function s(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];"string"==typeof i?e.setAttribute(r,i):null!=i&&(e[r]=i)}t++}for(;t<arguments.length;t++)l(e,arguments[t]);return e}function l(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)l(e,t[n])}}const a="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class c{constructor(e,t,n=0,r=e.length,i,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(a(e)):a,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return(0,i.codePointAt)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=(0,i.fromCodePoint)(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,i.codePointSize)(e);let r=this.normalize(t);for(let i=0,o=n;;i++){let e=r.charCodeAt(i),s=this.match(e,o);if(i==r.length-1){if(s)return this.value=s,this;break}o==n&&i<t.length&&t.charCodeAt(i)==e&&o++}}}match(e,t){let n=null;for(let r=0;r<this.matches.length;r+=2){let i=this.matches[r],o=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?n={from:this.matches[r+1],to:t+1}:(this.matches[r]++,o=!0)),o||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?n={from:t,to:t+1}:this.matches.push(1,t)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferPos)&&(n=null),n}}"undefined"!=typeof Symbol&&(c.prototype[Symbol.iterator]=function(){return this});const h={from:-1,to:-1,match:/.*/.exec("")},u="gm"+(null==/x/.unicode?"":"u");class f{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=h,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new m(e,t,n,r,i);this.re=new RegExp(t,u+((null===n||void 0===n?void 0:n.ignoreCase)?"i":"")),this.test=null===n||void 0===n?void 0:n.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=g(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=g(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const d=new WeakMap;class p{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=d.get(e);if(!r||r.from>=n||r.to<=t){let r=new p(t,e.sliceString(t,n));return d.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:i,from:o}=r;return o>t&&(i=e.sliceString(t,o)+i,o=t),r.to<n&&(i+=e.sliceString(r.to,n)),d.set(e,new p(o,i)),new p(t,i.slice(t-o,n-o))}}class m{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=h,this.matchPos=g(e,r),this.re=new RegExp(t,u+((null===n||void 0===n?void 0:n.ignoreCase)?"i":"")),this.test=null===n||void 0===n?void 0:n.test,this.flat=p.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=g(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=p.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function g(e,t){if(t>=e.length)return t;let n,r=e.lineAt(t);for(;t<r.to&&(n=r.text.charCodeAt(t-r.from))>=56320&&n<57344;)t++;return t}function y(e){let t=s("input",{class:"cm-textfield",name:"line"});function n(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!n)return;let{state:o}=e,s=o.doc.lineAt(o.selection.main.head),[,l,a,c,h]=n,u=c?+c.slice(1):0,f=a?+a:s.number;if(a&&h){let e=f/100;l&&(e=e*("-"==l?-1:1)+s.number/o.doc.lines),f=Math.round(o.doc.lines*e)}else a&&l&&(f=f*("-"==l?-1:1)+s.number);let d=o.doc.line(Math.max(1,Math.min(o.doc.lines,f))),p=i.EditorSelection.cursor(d.from+Math.max(0,Math.min(u,d.length)));e.dispatch({effects:[v.of(!1),r.EditorView.scrollIntoView(p.from,{y:"center"})],selection:p}),e.focus()}return{dom:s("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:v.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),n())},onsubmit:e=>{e.preventDefault(),n()}},s("label",e.state.phrase("Go to line"),": ",t)," ",s("button",{class:"cm-button",type:"submit"},e.state.phrase("go")))}}"undefined"!=typeof Symbol&&(f.prototype[Symbol.iterator]=m.prototype[Symbol.iterator]=function(){return this});const v=i.StateEffect.define(),b=i.StateField.define({create:()=>!0,update(e,t){for(let n of t.effects)n.is(v)&&(e=n.value);return e},provide:e=>r.showPanel.from(e,(e=>e?y:null))}),w=r.EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),x={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},k=i.Facet.define({combine:e=>(0,i.combineConfig)(e,x,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const S=r.Decoration.mark({class:"cm-selectionMatch"}),C=r.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function A(e,t,n,r){return(0==n||e(t.sliceDoc(n-1,n))!=i.CharCategory.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=i.CharCategory.Word)}const E=r.ViewPlugin.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(k),{state:n}=e,o=n.selection;if(o.ranges.length>1)return r.Decoration.none;let s,l=o.main,a=null;if(l.empty){if(!t.highlightWordAroundCursor)return r.Decoration.none;let e=n.wordAt(l.head);if(!e)return r.Decoration.none;a=n.charCategorizer(l.head),s=n.sliceDoc(e.from,e.to)}else{let e=l.to-l.from;if(e<t.minSelectionLength||e>200)return r.Decoration.none;if(t.wholeWords){if(s=n.sliceDoc(l.from,l.to),a=n.charCategorizer(l.head),!A(a,n,l.from,l.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==i.CharCategory.Word&&e(t.sliceDoc(r-1,r))==i.CharCategory.Word}(a,n,l.from,l.to))return r.Decoration.none}else if(s=n.sliceDoc(l.from,l.to).trim(),!s)return r.Decoration.none}let h=[];for(let i of e.visibleRanges){let e=new c(n.doc,s,i.from,i.to);for(;!e.next().done;){let{from:i,to:o}=e.value;if((!a||A(a,n,i,o))&&(l.empty&&i<=l.from&&o>=l.to?h.push(C.range(i,o)):(i>=l.to||o<=l.from)&&h.push(S.range(i,o)),h.length>t.maxMatches))return r.Decoration.none}}return r.Decoration.set(h)}},{decorations:e=>e.decorations}),M=r.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const O=i.Facet.define({combine:e=>(0,i.combineConfig)(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new re(e),scrollToMatch:e=>r.EditorView.scrollIntoView(e)})});class D{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,u),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,((e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\"))}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new L(this):new T(this)}getCursor(e,t=0,n){let r=e.doc?e:i.EditorState.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?B(this,r,t,n):P(this,r,t,n)}}class I{constructor(e){this.spec=e}}function P(e,t,n,r){return new c(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(o=t.doc,s=t.charCategorizer(t.selection.main.head),(e,t,n,r)=>((r>e||r+n.length<t)&&(r=Math.max(0,e-2),n=o.sliceString(r,Math.min(o.length,t+2))),(s(N(n,e-r))!=i.CharCategory.Word||s(R(n,e-r))!=i.CharCategory.Word)&&(s(R(n,t-r))!=i.CharCategory.Word||s(N(n,t-r))!=i.CharCategory.Word))):void 0);var o,s}class T extends I{constructor(e){super(e)}nextMatch(e,t,n){let r=P(this.spec,e,n,e.doc.length).nextOverlapping();return r.done&&(r=P(this.spec,e,0,t).nextOverlapping()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=P(this.spec,e,n,r),o=null;for(;!i.nextOverlapping().done;)o=i.value;if(o)return o;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=P(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=P(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function B(e,t,n,r){return new f(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(o=t.charCategorizer(t.selection.main.head),(e,t,n)=>!n[0].length||(o(N(n.input,n.index))!=i.CharCategory.Word||o(R(n.input,n.index))!=i.CharCategory.Word)&&(o(R(n.input,n.index+n[0].length))!=i.CharCategory.Word||o(N(n.input,n.index+n[0].length))!=i.CharCategory.Word)):void 0},n,r);var o}function N(e,t){return e.slice((0,i.findClusterBreak)(e,t,!1),t)}function R(e,t){return e.slice(t,(0,i.findClusterBreak)(e,t))}class L extends I{nextMatch(e,t,n){let r=B(this.spec,e,n,e.doc.length).next();return r.done&&(r=B(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-1e4*r),o=B(this.spec,e,i,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==t||s.from>i+10))return s;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,((t,n)=>"$"==n?"$":"&"==n?e.match[0]:"0"!=n&&+n<e.match.length?e.match[n]:t)))}matchAll(e,t){let n=B(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=B(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const _=i.StateEffect.define(),q=i.StateEffect.define(),F=i.StateField.define({create:e=>new j(Z(e).create(),null),update(e,t){for(let n of t.effects)n.is(_)?e=new j(n.value.create(),e.panel):n.is(q)&&(e=new j(e.query,n.value?Q:null));return e},provide:e=>r.showPanel.from(e,(e=>e.panel))});class j{constructor(e,t){this.query=e,this.panel=t}}const V=r.Decoration.mark({class:"cm-searchMatch"}),W=r.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),z=r.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(F))}update(e){let t=e.state.field(F);(t!=e.startState.field(F)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return r.Decoration.none;let{view:n}=this,o=new i.RangeSetBuilder;for(let r=0,i=n.visibleRanges,s=i.length;r<s;r++){let{from:t,to:l}=i[r];for(;r<s-1&&l>i[r+1].from-500;)l=i[++r].to;e.highlight(n.state,t,l,((e,t)=>{let r=n.state.selection.ranges.some((n=>n.from==e&&n.to==t));o.add(e,t,r?W:V)}))}return o.finish()}},{decorations:e=>e.decorations});function U(e){return t=>{let n=t.state.field(F,!1);return n&&n.query.spec.valid?e(t,n):ee(t)}}const $=U(((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let o=i.EditorSelection.single(r.from,r.to),s=e.state.facet(O);return e.dispatch({selection:o,effects:[le(e,r),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),Y(e),!0})),H=U(((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,o=t.prevMatch(n,r,r);if(!o)return!1;let s=i.EditorSelection.single(o.from,o.to),l=e.state.facet(O);return e.dispatch({selection:s,effects:[le(e,o),l.scrollToMatch(s.main,e)],userEvent:"select.search"}),Y(e),!0})),J=U(((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:i.EditorSelection.create(n.map((e=>i.EditorSelection.range(e.from,e.to)))),userEvent:"select.search.matches"}),!0)})),K=U(((e,{query:t})=>{let{state:n}=e,{from:o,to:s}=n.selection.main;if(n.readOnly)return!1;let l=t.nextMatch(n,o,o);if(!l)return!1;let a,c,h=[],u=[];if(l.from==o&&l.to==s&&(c=n.toText(t.getReplacement(l)),h.push({from:l.from,to:l.to,insert:c}),l=t.nextMatch(n,l.from,l.to),u.push(r.EditorView.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(o).number)+"."))),l){let t=0==h.length||h[0].from>=l.to?0:l.to-l.from-c.length;a=i.EditorSelection.single(l.from-t,l.to-t),u.push(le(e,l)),u.push(n.facet(O).scrollToMatch(a.main,e))}return e.dispatch({changes:h,selection:a,effects:u,userEvent:"input.replace"}),!0})),G=U(((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map((e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}}));if(!n.length)return!1;let i=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:r.EditorView.announce.of(i),userEvent:"input.replace.all"}),!0}));function Q(e){return e.state.facet(O).createPanel(e)}function Z(e,t){var n,r,i,o,s;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let c=e.facet(O);return new D({search:(null!==(n=null===t||void 0===t?void 0:t.literal)&&void 0!==n?n:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(r=null===t||void 0===t?void 0:t.caseSensitive)&&void 0!==r?r:c.caseSensitive,literal:null!==(i=null===t||void 0===t?void 0:t.literal)&&void 0!==i?i:c.literal,regexp:null!==(o=null===t||void 0===t?void 0:t.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(s=null===t||void 0===t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function X(e){let t=(0,r.getPanel)(e,Q);return t&&t.dom.querySelector("[main-field]")}function Y(e){let t=X(e);t&&t==e.root.activeElement&&t.select()}const ee=e=>{let t=e.state.field(F,!1);if(t&&t.panel){let n=X(e);if(n&&n!=e.root.activeElement){let r=Z(e.state,t.query.spec);r.valid&&e.dispatch({effects:_.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[q.of(!0),t?_.of(Z(e.state,t.query.spec)):i.StateEffect.appendConfig.of(ce)]});return!0},te=e=>{let t=e.state.field(F,!1);if(!t||!t.panel)return!1;let n=(0,r.getPanel)(e,Q);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:q.of(!1)}),!0},ne=[{key:"Mod-f",run:ee,scope:"editor search-panel"},{key:"F3",run:$,shift:H,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:$,shift:H,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:te,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:o}=n.main,s=[],l=0;for(let a=new c(e.doc,e.sliceDoc(r,o));!a.next().done;){if(s.length>1e3)return!1;a.value.from==r&&(l=s.length),s.push(i.EditorSelection.range(a.value.from,a.value.to))}return t(e.update({selection:i.EditorSelection.create(s,l),userEvent:"select.search.matches"})),!0}},{key:"Alt-g",run:e=>{let t=(0,r.getPanel)(e,y);if(!t){let n=[v.of(!0)];null==e.state.field(b,!1)&&n.push(i.StateEffect.appendConfig.of([b,w])),e.dispatch({effects:n}),t=(0,r.getPanel)(e,y)}return t&&t.dom.querySelector("input").focus(),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((e=>e.from===e.to)))return(({state:e,dispatch:t})=>{let{selection:n}=e,r=i.EditorSelection.create(n.ranges.map((t=>e.wordAt(t.head)||i.EditorSelection.cursor(t.head))),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let o=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=o)))return!1;let s=function(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),o=i&&i.from==n.from&&i.to==n.to;for(let s=!1,l=new c(e.doc,t,r[r.length-1].to);;){if(l.next(),!l.done){if(s&&r.some((e=>e.from==l.value.from)))continue;if(o){let t=e.wordAt(l.value.from);if(!t||t.from!=l.value.from||t.to!=l.value.to)continue}return l.value}if(s)return null;l=new c(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}}(e,o);return!!s&&(t(e.update({selection:e.selection.addRange(i.EditorSelection.range(s.from,s.to),!1),effects:r.EditorView.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class re{constructor(e){this.view=e;let t=this.query=e.state.field(F).query.spec;function n(e,t,n){return s("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=s("input",{value:t.search,placeholder:ie(e,"Find"),"aria-label":ie(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=s("input",{value:t.replace,placeholder:ie(e,"Replace"),"aria-label":ie(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=s("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=s("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=s("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=s("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",(()=>$(e)),[ie(e,"next")]),n("prev",(()=>H(e)),[ie(e,"previous")]),n("select",(()=>J(e)),[ie(e,"all")]),s("label",null,[this.caseField,ie(e,"match case")]),s("label",null,[this.reField,ie(e,"regexp")]),s("label",null,[this.wordField,ie(e,"by word")]),...e.state.readOnly?[]:[s("br"),this.replaceField,n("replace",(()=>K(e)),[ie(e,"replace")]),n("replaceAll",(()=>G(e)),[ie(e,"replace all")])],s("button",{name:"close",onclick:()=>te(e),"aria-label":ie(e,"close"),type:"button"},["\xd7"])])}commit(){let e=new D({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:_.of(e)}))}keydown(e){(0,r.runScopeHandlers)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?H:$)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),K(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(_)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(O).top}}function ie(e,t){return e.state.phrase(t)}const oe=30,se=/[\s\.,:;?!]/;function le(e,{from:t,to:n}){let i=e.state.doc.lineAt(t),o=e.state.doc.lineAt(n).to,s=Math.max(i.from,t-oe),l=Math.min(o,n+oe),a=e.state.sliceDoc(s,l);if(s!=i.from)for(let r=0;r<oe;r++)if(!se.test(a[r+1])&&se.test(a[r])){a=a.slice(r);break}if(l!=o)for(let r=a.length-1;r>a.length-oe;r--)if(!se.test(a[r-1])&&se.test(a[r])){a=a.slice(0,r);break}return r.EditorView.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${i.number}.`)}const ae=r.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"}}),ce=[F,i.Prec.low(z),ae];var he=n(434);class ue{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=(0,he.qz)(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(ge(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(e,t){"abort"==e&&this.abortListeners&&this.abortListeners.push(t)}}function fe(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function de(e){let t=e.map((e=>"string"==typeof e?{label:e}:e)),[n,r]=t.every((e=>/^\w+$/.test(e.label)))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let e=1;e<i.length;e++)n[i[e]]=!0}let r=fe(t)+fe(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}class pe{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}}function me(e){return e.selection.main.from}function ge(e,t){var n;let{source:r}=e,i=t&&"^"!=r[0],o="$"!=r[r.length-1];return i||o?new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const ye=i.Annotation.define();const ve=new WeakMap;function be(e){if(!Array.isArray(e))return e;let t=ve.get(e);return t||ve.set(e,t=de(e)),t}const we=i.StateEffect.define(),xe=i.StateEffect.define();class ke{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=(0,i.codePointAt)(e,t),r=(0,i.codePointSize)(n);this.chars.push(n);let o=e.slice(t,t+r),s=o.toUpperCase();this.folded.push((0,i.codePointAt)(s==o?o.toLowerCase():s,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,!0}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return!1;let{chars:t,folded:n,any:r,precise:o,byWord:s}=this;if(1==t.length){let r=(0,i.codePointAt)(e,0),o=(0,i.codePointSize)(r),s=o==e.length?0:-100;if(r==t[0]);else{if(r!=n[0])return!1;s+=-200}return this.ret(s,[0,o])}let l=e.indexOf(this.pattern);if(0==l)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,c=0;if(l<0){for(let o=0,s=Math.min(e.length,200);o<s&&c<a;){let s=(0,i.codePointAt)(e,o);s!=t[c]&&s!=n[c]||(r[c++]=o),o+=(0,i.codePointSize)(s)}if(c<a)return!1}let h=0,u=0,f=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),y=!0;for(let v=0,b=Math.min(e.length,200),w=0;v<b&&u<a;){let r=(0,i.codePointAt)(e,v);l<0&&(h<a&&r==t[h]&&(o[h++]=v),d<a&&(r==t[d]||r==n[d]?(0==d&&(p=v),m=v+1,d++):d=0));let c,b=r<255?r>=48&&r<=57||r>=97&&r<=122?2:r>=65&&r<=90?1:0:(c=(0,i.fromCodePoint)(r))!=c.toLowerCase()?1:c!=c.toUpperCase()?2:0;(!v||1==b&&g||0==w&&0!=b)&&(t[u]==r||n[u]==r&&(f=!0)?s[u++]=v:s.length&&(y=!1)),w=b,v+=(0,i.codePointSize)(r)}return u==a&&0==s[0]&&y?this.result((f?-200:0)-100,s,e):d==a&&0==p?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,m]):u==a?this.result((f?-200:0)-100-700+(y?0:-1100),s,e):2!=t.length&&this.result((r[0]?-700:0)-200-1100,r,e)}result(e,t,n){let r=[],o=0;for(let s of t){let e=s+(this.astral?(0,i.codePointSize)((0,i.codePointAt)(n,s)):1);o&&r[o-1]==s?r[o-1]=e:(r[o++]=s,r[o++]=e)}return this.ret(e-n.length,r)}}const Se=i.Facet.define({combine:e=>(0,i.combineConfig)(e,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Ae,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>Ce(e(n),t(n)),optionClass:(e,t)=>n=>Ce(e(n),t(n)),addToOptions:(e,t)=>e.concat(t)})});function Ce(e,t){return e?t?e+" "+t:e:t}function Ae(e,t,n,i,o){let s,l,a=e.textDirection==r.Direction.RTL,c=a,h=!1,u="top",f=t.left-o.left,d=o.right-t.right,p=i.right-i.left,m=i.bottom-i.top;if(c&&f<Math.min(p,d)?c=!1:!c&&d<Math.min(p,f)&&(c=!0),p<=(c?f:d))s=Math.max(o.top,Math.min(n.top,o.bottom-m))-t.top,l=Math.min(400,c?f:d);else{h=!0,l=Math.min(400,(a?t.right:o.right-t.left)-30);let e=o.bottom-t.bottom;e>=m||e>t.top?s=n.bottom-t.top:(u="bottom",s=t.bottom-n.top)}return{style:`${u}: ${s}px; max-width: ${l}px`,class:"cm-completionInfo-"+(h?a?"left-narrow":"right-narrow":c?"left":"right")}}function Ee(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class Me{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:i,selected:o}=r.open,s=e.state.facet(Se);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map((e=>"cm-completionIcon-"+e))),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n){let r=document.createElement("span");r.className="cm-completionLabel";let i=e.displayLabel||e.label,o=0;for(let s=0;s<n.length;){let e=n[s++],t=n[s++];e>o&&r.appendChild(document.createTextNode(i.slice(o,e)));let l=r.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(i.slice(e,t))),l.className="cm-completionMatchedText",o=t}return o<i.length&&r.appendChild(document.createTextNode(i.slice(o))),r},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort(((e,t)=>e.position-t.position)).map((e=>e.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=Ee(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",(t=>{for(let n,r=t.target;r&&r!=this.dom;r=r.parentNode)if("LI"==r.nodeName&&(n=/-(\d+)$/.exec(r.id))&&+n[1]<i.length)return this.applyCompletion(e,i[+n[1]]),void t.preventDefault()})),this.dom.addEventListener("focusout",(t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(Se).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:xe.of(null)})})),this.list=this.dom.appendChild(this.createListBox(i,r.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}mount(){this.updateSel()}update(e){var t,n,r;let i=e.state.field(this.stateField),o=e.startState.field(this.stateField);this.updateTooltipClass(e.state),i!=o&&(this.updateSel(),(null===(t=i.open)||void 0===t?void 0:t.disabled)!=(null===(n=o.open)||void 0===n?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!(null===(r=i.open)||void 0===r?void 0:r.disabled)))}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Ee(t.options.length,t.selected,this.view.state.facet(Se).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:i}=n;if(!i)return;let o="string"===typeof i?document.createTextNode(i):i(n);if(!o)return;"then"in o?o.then((t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,n)})).catch((e=>(0,r.logException)(this.view.state,e,"completion info"))):this.addInfoPane(o,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)"LI"==n.nodeName&&n.id?r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected"):r--;return t&&function(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();r.top<n.top?e.scrollTop-=n.top-r.top:r.bottom>n.bottom&&(e.scrollTop+=r.bottom-n.bottom)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.defaultView||window;i={left:0,top:0,right:e.innerWidth,bottom:e.innerHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(Se).positionInfo(this.view,t,r,n,i)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions"));let i=null;for(let o=n.from;o<n.to;o++){let{completion:s,match:l}=e[o],{section:a}=s;if(a){let e="string"==typeof a?a:a.name;if(e!=i&&(o>n.from||0==n.from))if(i=e,"string"!=typeof a&&a.header)r.appendChild(a.header(a));else{r.appendChild(document.createElement("completion-section")).textContent=e}}const c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let h=this.optionClass(s);h&&(c.className=h);for(let e of this.optionContent){let t=e(s,this.view.state,l);t&&c.appendChild(t)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Oe(e,t){return n=>new Me(n,e,t)}function De(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class Ie{constructor(e,t,n,r,i,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ie(this.options,Be(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,i){let o=function(e,t){let n=[],r=null,i=e=>{n.push(e);let{section:t}=e.completion;if(t){r||(r=[]);let e="string"==typeof t?t:t.name;r.some((t=>t.name==e))||r.push("string"==typeof t?{name:e}:t)}};for(let a of e)if(a.hasResult()){let e=a.result.getMatch;if(!1===a.result.filter)for(let t of a.result.options)i(new pe(t,a.source,e?e(t):[],1e9-n.length));else{let n=new ke(t.sliceDoc(a.from,a.to));for(let t of a.result.options)if(n.match(t.label)){let r=t.displayLabel?e?e(t,n.matched):[]:n.matched;i(new pe(t,a.source,r,n.score+(t.boost||0)))}}}if(r){let e=Object.create(null),t=0,i=(e,t)=>{var n,r;return(null!==(n=e.rank)&&void 0!==n?n:1e9)-(null!==(r=t.rank)&&void 0!==r?r:1e9)||(e.name<t.name?-1:1)};for(let n of r.sort(i))t-=1e5,e[n.name]=t;for(let r of n){let{section:t}=r.completion;t&&(r.score+=e["string"==typeof t?t:t.name])}}let o=[],s=null,l=t.facet(Se).compareCompletions;for(let a of n.sort(((e,t)=>t.score-e.score||l(e.completion,t.completion)))){let e=a.completion;!s||s.label!=e.label||s.detail!=e.detail||null!=s.type&&null!=e.type&&s.type!=e.type||s.apply!=e.apply||s.boost!=e.boost?o.push(a):De(a.completion)>De(s)&&(o[o.length-1]=a),s=a.completion}return o}(e,t);if(!o.length)return r&&e.some((e=>1==e.state))?new Ie(r.options,r.attrs,r.tooltip,r.timestamp,r.selected,!0):null;let s=t.facet(Se).selectOnOpen?0:-1;if(r&&r.selected!=s&&-1!=r.selected){let e=r.options[r.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){s=t;break}}return new Ie(o,Be(n,s),{pos:e.reduce(((e,t)=>t.hasResult()?Math.min(e,t.from):e),1e8),create:Oe(je,Ve),above:i.aboveCursor},r?r.timestamp:Date.now(),s,!1)}map(e){return new Ie(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class Pe{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new Pe(Ne,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(Se),r=(n.override||t.languageDataAt("autocomplete",me(t)).map(be)).map((t=>(this.active.find((e=>e.source==t))||new Le(t,this.active.some((e=>0!=e.state))?1:0)).update(e,n)));r.length==this.active.length&&r.every(((e,t)=>e==this.active[t]))&&(r=this.active);let i=this.open;i&&e.docChanged&&(i=i.map(e.changes)),e.selection||r.some((t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to)))||!function(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult;)n++;for(;r<t.length&&!t[r].hasResult;)r++;let i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}(r,this.active)?i=Ie.build(r,t,this.id,i,n):i&&i.disabled&&!r.some((e=>1==e.state))&&(i=null),!i&&r.every((e=>1!=e.state))&&r.some((e=>e.hasResult()))&&(r=r.map((e=>e.hasResult()?new Le(e.source,0):e)));for(let o of e.effects)o.is(Fe)&&(i=i&&i.setSelected(o.value,this.id));return r==this.active&&i==this.open?this:new Pe(r,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:Te}}const Te={"aria-autocomplete":"list"};function Be(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Ne=[];function Re(e){return e.isUserEvent("input.type")?"input":e.isUserEvent("delete.backward")?"delete":null}class Le{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=Re(e),r=this;n?r=r.handleUserEvent(e,n,t):e.docChanged?r=r.handleChange(e):e.selection&&0!=r.state&&(r=new Le(r.source,0));for(let i of e.effects)if(i.is(we))r=new Le(r.source,1,i.value?me(e.state):-1);else if(i.is(xe))r=new Le(r.source,0);else if(i.is(qe))for(let e of i.value)e.source==r.source&&(r=e);return r}handleUserEvent(e,t,n){return"delete"!=t&&n.activateOnTyping?new Le(this.source,1):this.map(e.changes)}handleChange(e){return e.changes.touchesRange(me(e.startState))?new Le(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Le(this.source,this.state,e.mapPos(this.explicitPos))}}class _e extends Le{constructor(e,t,n,r,i){super(e,2,t),this.result=n,this.from=r,this.to=i}hasResult(){return!0}handleUserEvent(e,t,n){var r;let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=me(e.state);if((this.explicitPos<0?s<=i:s<this.from)||s>o||"delete"==t&&me(e.startState)==this.from)return new Le(this.source,"input"==t&&n.activateOnTyping?1:0);let l,a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return function(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return"function"==typeof e?e(i,n,r,t):ge(e,!0).test(i)}(this.result.validFor,e.state,i,o)?new _e(this.source,a,this.result,i,o):this.result.update&&(l=this.result.update(this.result,i,o,new ue(e.state,s,a>=0)))?new _e(this.source,a,l,l.from,null!==(r=l.to)&&void 0!==r?r:me(e.state)):new Le(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Le(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new _e(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}const qe=i.StateEffect.define({map:(e,t)=>e.map((e=>e.map(t)))}),Fe=i.StateEffect.define(),je=i.StateField.define({create:()=>Pe.start(),update:(e,t)=>e.update(t),provide:e=>[r.showTooltip.from(e,(e=>e.tooltip)),r.EditorView.contentAttributes.from(e,(e=>e.attrs))]});function Ve(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(je).active.find((e=>e.source==t.source));return r instanceof _e&&("string"==typeof n?e.dispatch(Object.assign(Object.assign({},function(e,t,n,r){let{main:o}=e.selection,s=n-o.from,l=r-o.from;return Object.assign(Object.assign({},e.changeByRange((a=>a!=o&&n!=r&&e.sliceDoc(a.from+s,a.from+l)!=e.sliceDoc(n,r)?{range:a}:{changes:{from:a.from+s,to:r==o.from?a.to:a.from+l,insert:t},range:i.EditorSelection.cursor(a.from+s+t.length)}))),{userEvent:"input.complete"})}(e.state,n,r.from,r.to)),{annotations:ye.of(t.completion)})):n(e,t.completion,r.from,r.to),!0)}function We(e,t="option"){return n=>{let i=n.state.field(je,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(Se).interactionDelay)return!1;let o,s=1;"page"==t&&(o=(0,r.getTooltip)(n,i.open.tooltip))&&(s=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:l}=i.open.options,a=i.open.selected>-1?i.open.selected+s*(e?1:-1):e?0:l-1;return a<0?a="page"==t?0:l-1:a>=l&&(a="page"==t?l-1:0),n.dispatch({effects:Fe.of(a)}),!0}}class ze{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ue=r.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let t of e.state.field(je).active)1==t.state&&this.startQuery(t)}update(e){let t=e.state.field(je);if(!e.selectionSet&&!e.docChanged&&e.startState.field(je)==t)return;let n=e.transactions.some((e=>(e.selection||e.docChanged)&&!Re(e)));for(let o=0;o<this.running.length;o++){let t=this.running[o];if(n||t.updates.length+e.transactions.length>50&&Date.now()-t.time>1e3){for(let e of t.context.abortListeners)try{e()}catch(i){(0,r.logException)(this.view.state,i)}t.context.abortListeners=null,this.running.splice(o--,1)}else t.updates.push(...e.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=t.active.some((e=>1==e.state&&!this.running.some((t=>t.active.source==e.source))))?setTimeout((()=>this.startUpdate()),50):-1,0!=this.composing)for(let r of e.transactions)"input"==Re(r)?this.composing=2:2==this.composing&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:e}=this.view,t=e.field(je);for(let n of t.active)1!=n.state||this.running.some((e=>e.active.source==n.source))||this.startQuery(n)}startQuery(e){let{state:t}=this.view,n=me(t),i=new ue(t,n,e.explicitPos==n),o=new ze(e,i);this.running.push(o),Promise.resolve(e.source(i)).then((e=>{o.context.aborted||(o.done=e||null,this.scheduleAccept())}),(e=>{this.view.dispatch({effects:xe.of(null)}),(0,r.logException)(this.view.state,e)}))}scheduleAccept(){this.running.every((e=>void 0!==e.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),50))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Se);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(void 0===i.done)continue;if(this.running.splice(r--,1),i.done){let r=new _e(i.active.source,i.active.explicitPos,i.done,i.done.from,null!==(e=i.done.to)&&void 0!==e?e:me(i.updates.length?i.updates[0].startState:this.view.state));for(let e of i.updates)r=r.update(e,n);if(r.hasResult()){t.push(r);continue}}let o=this.view.state.field(je).active.find((e=>e.source==i.active.source));if(o&&1==o.state)if(null==i.done){let e=new Le(i.active.source,0);for(let t of i.updates)e=e.update(t,n);1!=e.state&&t.push(e)}else this.startQuery(o)}t.length&&this.view.dispatch({effects:qe.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(je,!1);if(t&&t.tooltip&&this.view.state.facet(Se).closeOnBlur){let n=t.open&&(0,r.getTooltip)(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||this.view.dispatch({effects:xe.of(null)})}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:we.of(!1)})),20),this.composing=0}}}),$e=r.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",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xb7\xb7\xb7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",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",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25cb'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25cc'"}},".cm-completionIcon-variable":{"&:after":{content:"'\ud835\udc65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\ud835\udc36'"}},".cm-completionIcon-type":{"&:after":{content:"'\ud835\udc61'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222a'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25a1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\ud83d\udd11\ufe0e'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25a2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});const He={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Je=i.StateEffect.define({map(e,t){let n=t.mapPos(e,-1,i.MapMode.TrackAfter);return null==n?void 0:n}}),Ke=new class extends i.RangeValue{};Ke.startSide=1,Ke.endSide=-1;const Ge=i.StateField.define({create:()=>i.RangeSet.empty,update(e,t){if(t.selection){let n=t.state.doc.lineAt(t.selection.main.head).from,r=t.startState.doc.lineAt(t.startState.selection.main.head).from;n!=t.changes.mapPos(r,-1)&&(e=i.RangeSet.empty)}e=e.map(t.changes);for(let n of t.effects)n.is(Je)&&(e=e.update({add:[Ke.range(n.value,n.value+1)]}));return e}});const Qe="()[]{}<>";function Ze(e){for(let t=0;t<Qe.length;t+=2)if(Qe.charCodeAt(t)==e)return Qe.charAt(t+1);return(0,i.fromCodePoint)(e<128?e:e+1)}function Xe(e,t){return e.languageDataAt("closeBrackets",t)[0]||He}const Ye="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),et=r.EditorView.inputHandler.of(((e,t,n,r)=>{if((Ye?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let o=e.state.selection.main;if(r.length>2||2==r.length&&1==(0,i.codePointSize)((0,i.codePointAt)(r,0))||t!=o.from||n!=o.to)return!1;let s=function(e,t){let n=Xe(e,e.selection.main.head),r=n.brackets||He.brackets;for(let o of r){let s=Ze((0,i.codePointAt)(o,0));if(t==o)return s==o?st(e,o,r.indexOf(o+o+o)>-1,n):it(e,o,s,n.before||He.before);if(t==s&&nt(e,e.selection.main.from))return ot(e,o,s)}return null}(e.state,r);return!!s&&(e.dispatch(s),!0)})),tt=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Xe(e,e.selection.main.head).brackets||He.brackets,r=null,o=e.changeByRange((t=>{if(t.empty){let r=function(e,t){let n=e.sliceString(t-2,t);return(0,i.codePointSize)((0,i.codePointAt)(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let o of n)if(o==r&&rt(e.doc,t.head)==Ze((0,i.codePointAt)(o,0)))return{changes:{from:t.head-o.length,to:t.head+o.length},range:i.EditorSelection.cursor(t.head-o.length)}}return{range:r=t}}));return r||t(e.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function nt(e,t){let n=!1;return e.field(Ge).between(0,e.doc.length,(e=>{e==t&&(n=!0)})),n}function rt(e,t){let n=e.sliceString(t,t+2);return n.slice(0,(0,i.codePointSize)((0,i.codePointAt)(n,0)))}function it(e,t,n,r){let o=null,s=e.changeByRange((s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:n,from:s.to}],effects:Je.of(s.to+t.length),range:i.EditorSelection.range(s.anchor+t.length,s.head+t.length)};let l=rt(e.doc,s.head);return!l||/\s/.test(l)||r.indexOf(l)>-1?{changes:{insert:t+n,from:s.head},effects:Je.of(s.head+t.length),range:i.EditorSelection.cursor(s.head+t.length)}:{range:o=s}}));return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ot(e,t,n){let r=null,o=e.changeByRange((t=>t.empty&&rt(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:i.EditorSelection.cursor(t.head+n.length)}:r={range:t}));return r?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function st(e,t,n,r){let o=r.stringPrefixes||He.stringPrefixes,s=null,l=e.changeByRange((r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:Je.of(r.to+t.length),range:i.EditorSelection.range(r.anchor+t.length,r.head+t.length)};let l,a=r.head,c=rt(e.doc,a);if(c==t){if(lt(e,a))return{changes:{insert:t+t,from:a},effects:Je.of(a+t.length),range:i.EditorSelection.cursor(a+t.length)};if(nt(e,a)){let r=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+r.length,insert:r},range:i.EditorSelection.cursor(a+r.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(l=at(e,a-2*t.length,o))>-1&&lt(e,l))return{changes:{insert:t+t+t+t,from:a},effects:Je.of(a+t.length),range:i.EditorSelection.cursor(a+t.length)};if(e.charCategorizer(a)(c)!=i.CharCategory.Word&&at(e,a,o)>-1&&!function(e,t,n,r){let i=(0,he.qz)(e).resolveInner(t,-1),o=r.reduce(((e,t)=>Math.max(e,t.length)),0);for(let s=0;s<5;s++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+o)),l=s.indexOf(n);if(!l||l>-1&&r.indexOf(s.slice(0,l))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+l;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let a=i.to==t&&i.parent;if(!a)break;i=a}return!1}(e,a,t,o))return{changes:{insert:t+t,from:a},effects:Je.of(a+t.length),range:i.EditorSelection.cursor(a+t.length)}}return{range:s=r}}));return s?null:e.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function lt(e,t){let n=(0,he.qz)(e).resolveInner(t+1);return n.parent&&n.from==t}function at(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=i.CharCategory.Word)return t;for(let o of n){let n=t-o.length;if(e.sliceDoc(n,t)==o&&r(e.sliceDoc(n-1,n))!=i.CharCategory.Word)return n}return-1}const ct=[{key:"Ctrl-Space",run:e=>!!e.state.field(je,!1)&&(e.dispatch({effects:we.of(!0)}),!0)},{key:"Escape",run:e=>{let t=e.state.field(je,!1);return!(!t||!t.active.some((e=>0!=e.state)))&&(e.dispatch({effects:xe.of(null)}),!0)}},{key:"ArrowDown",run:We(!0)},{key:"ArrowUp",run:We(!1)},{key:"PageDown",run:We(!0,"page")},{key:"PageUp",run:We(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(je,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Se).interactionDelay)&&Ve(e,t.open.options[t.open.selected])}}],ht=i.Prec.highest(r.keymap.computeN([Se],(e=>e.facet(Se).defaultKeymap?[ct]:[])));class ut{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class ft{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let i=e,o=n.facet(At).markerFilter;o&&(i=o(i));let s=r.Decoration.set(i.map((e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from?r.Decoration.widget({widget:new Ot(e),diagnostic:e}).range(e.from):r.Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+e.severity+(e.markClass?" "+e.markClass:"")},diagnostic:e}).range(e.from,e.to))),!0);return new ft(s,t,dt(s))}}function dt(e,t=null,n=0){let r=null;return e.between(n,1e9,((e,n,{spec:i})=>{if(!t||i.diagnostic==t)return r=new ut(e,n,i.diagnostic),!1})),r}function pt(e,t){let n=e.startState.doc.lineAt(t.pos);return!(!e.effects.some((e=>e.is(gt)))&&!e.changes.touchesRange(n.from,n.to))}function mt(e,t){return e.field(bt,!1)?t:t.concat(i.StateEffect.appendConfig.of(Nt))}const gt=i.StateEffect.define(),yt=i.StateEffect.define(),vt=i.StateEffect.define(),bt=i.StateField.define({create:()=>new ft(r.Decoration.none,null,null),update(e,t){if(t.docChanged){let n=e.diagnostics.map(t.changes),r=null;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=dt(n,e.selected.diagnostic,i)||dt(n,null,i)}e=new ft(n,e.panel,r)}for(let n of t.effects)n.is(gt)?e=ft.init(n.value,e.panel,t.state):n.is(yt)?e=new ft(e.diagnostics,n.value?It.open:null,e.selected):n.is(vt)&&(e=new ft(e.diagnostics,e.panel,n.value));return e},provide:e=>[r.showPanel.from(e,(e=>e.panel)),r.EditorView.decorations.from(e,(e=>e.diagnostics))]});const wt=r.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function xt(e,t,n){let{diagnostics:r}=e.state.field(bt),i=[],o=2e8,s=0;r.between(t-(n<0?1:0),t+(n>0?1:0),((e,r,{spec:l})=>{t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0))&&(i.push(l.diagnostic),o=Math.min(e,o),s=Math.max(r,s))}));let l=e.state.facet(At).tooltipFilter;return l&&(i=l(i)),i.length?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:kt(e,i)})}:null}function kt(e,t){return s("ul",{class:"cm-tooltip-lint"},t.map((t=>Mt(e,t,!1))))}const St=e=>{let t=e.state.field(bt,!1);return!(!t||!t.panel)&&(e.dispatch({effects:yt.of(!1)}),!0)},Ct=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(bt,!1);t&&t.panel||e.dispatch({effects:mt(e.state,[yt.of(!0)])});let n=(0,r.getPanel)(e,It.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(bt,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!(!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],At=i.Facet.define({combine:e=>Object.assign({sources:e.map((e=>e.source))},(0,i.combineConfig)(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))});function Et(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some((e=>e.toLowerCase()==r.toLowerCase()))){t.push(r);continue e}}t.push("")}return t}function Mt(e,t,n){var r;let i=n?Et(t.actions):[];return s("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},s("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage():t.message),null===(r=t.actions)||void 0===r?void 0:r.map(((n,r)=>{let o=!1,l=r=>{if(r.preventDefault(),o)return;o=!0;let i=dt(e.state.field(bt).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:a}=n,c=i[r]?a.indexOf(i[r]):-1,h=c<0?a:[a.slice(0,c),s("u",a.slice(c,c+1)),a.slice(c+1)];return s("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${a}${c<0?"":` (access key "${i[r]})"`}.`},h)})),t.source&&s("div",{class:"cm-diagnosticSource"},t.source))}class Ot extends r.WidgetType{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return s("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Dt{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=Mt(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class It{constructor(e){this.view=e,this.items=[];this.list=s("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)St(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],r=Et(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=dt(this.view.state.field(bt).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=s("div",{class:"cm-panel-lint"},this.list,s("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>St(this.view)},"\xd7")),this.update()}get selectedIndex(){let e=this.view.state.field(bt).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(bt),n=0,r=!1,i=null;for(e.between(0,this.view.state.doc.length,((e,o,{spec:s})=>{let l,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==s.diagnostic){a=t;break}a<0?(l=new Dt(this.view,s.diagnostic),this.items.splice(n,0,l),r=!0):(l=this.items[a],a>n&&(this.items.splice(n,a-n),r=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),i=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}));n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();0==this.items.length&&(this.items.push(new Dt(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{e.top<t.top?this.list.scrollTop-=t.top-e.top:e.bottom>t.bottom&&(this.list.scrollTop+=e.bottom-t.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=dt(this.view.state.field(bt).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:vt.of(t)})}static open(e){return new It(e)}}function Pt(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Tt(e){return Pt(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Bt=r.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-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Tt("#d11")},".cm-lintRange-warning":{backgroundImage:Tt("orange")},".cm-lintRange-info":{backgroundImage:Tt("#999")},".cm-lintRange-hint":{backgroundImage:Tt("#66d")},".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-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".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}}});r.GutterMarker;const Nt=[bt,r.EditorView.decorations.compute([bt],(e=>{let{selected:t,panel:n}=e.field(bt);return t&&n&&t.from!=t.to?r.Decoration.set([wt.range(t.from,t.to)]):r.Decoration.none})),(0,r.hoverTooltip)(xt,{hideOn:pt}),Bt];var Rt=function(e){void 0===e&&(e={});var t=[];!1!==e.closeBracketsKeymap&&(t=t.concat(tt)),!1!==e.defaultKeymap&&(t=t.concat(o.wQ)),!1!==e.searchKeymap&&(t=t.concat(ne)),!1!==e.historyKeymap&&(t=t.concat(o.f$)),!1!==e.foldKeymap&&(t=t.concat(he.e7)),!1!==e.completionKeymap&&(t=t.concat(ct)),!1!==e.lintKeymap&&(t=t.concat(Ct));var n=[];return!1!==e.lineNumbers&&n.push((0,r.lineNumbers)()),!1!==e.highlightActiveLineGutter&&n.push((0,r.highlightActiveLineGutter)()),!1!==e.highlightSpecialChars&&n.push((0,r.highlightSpecialChars)()),!1!==e.history&&n.push((0,o.m8)()),!1!==e.foldGutter&&n.push((0,he.mi)()),!1!==e.drawSelection&&n.push((0,r.drawSelection)()),!1!==e.dropCursor&&n.push((0,r.dropCursor)()),!1!==e.allowMultipleSelections&&n.push(i.EditorState.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&n.push((0,he.nY)()),!1!==e.syntaxHighlighting&&n.push((0,he.nF)(he.R_,{fallback:!0})),!1!==e.bracketMatching&&n.push((0,he.n$)()),!1!==e.closeBrackets&&n.push([et,Ge]),!1!==e.autocompletion&&n.push(function(e={}){return[je,Se.of(e),Ue,ht,$e]}()),!1!==e.rectangularSelection&&n.push((0,r.rectangularSelection)()),!1!==e.crosshairCursor&&n.push((0,r.crosshairCursor)()),!1!==e.highlightActiveLine&&n.push((0,r.highlightActiveLine)()),!1!==e.highlightSelectionMatches&&n.push(function(e){let t=[M,E];return e&&t.push(k.of(e)),t}()),e.tabSize&&"number"===typeof e.tabSize&&n.push(he.c.of(" ".repeat(e.tabSize))),n.concat([r.keymap.of(t.flat())]).filter(Boolean)},Lt=function(e){void 0===e&&(e={});var t=[];!1!==e.defaultKeymap&&(t=t.concat(o.wQ)),!1!==e.historyKeymap&&(t=t.concat(o.f$));var n=[];return!1!==e.highlightSpecialChars&&n.push((0,r.highlightSpecialChars)()),!1!==e.history&&n.push((0,o.m8)()),!1!==e.drawSelection&&n.push((0,r.drawSelection)()),!1!==e.syntaxHighlighting&&n.push((0,he.nF)(he.R_,{fallback:!0})),n.concat([r.keymap.of(t.flat())]).filter(Boolean)}},349:(e,t,n)=>{var r=n(787),i=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,o={},c=null,h=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(h=t.ref),t)s.call(t,r)&&!a.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===o[r]&&(o[r]=t[r]);return{$$typeof:i,type:e,key:c,ref:h,props:o,_owner:l.current}}t.jsx=c},501:(e,t,n)=>{e.exports=n(349)},787:t=>{t.exports=e},242:e=>{e.exports=t},362:e=>{e.exports=n},105:e=>{e.exports=r},215:(e,t,n)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e){var t=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===r(t)?t:String(t)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){var r,o,s;r=e,o=t,s=n[t],(o=i(o))in r?Object.defineProperty(r,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[o]=s})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}n.d(t,{Z:()=>s})},808:(e,t,n)=>{function r(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}n.d(t,{Z:()=>r})},79:(e,t,n)=>{n.d(t,{f$:()=>_,m8:()=>w,oc:()=>Le,wQ:()=>Re});var r=n(242),i=n(105),o=n(434),s=n(857);function l(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(r(n.update(i)),!0)}}const a=l(p,0),c=l(d,0),h=l(((e,t)=>d(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to),o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}(t))),0);function u(e,t){let n=e.languageDataAt("commentTokens",t);return n.length?n[0]:{}}const f=50;function d(e,t,n=t.selection.ranges){let r=n.map((e=>u(t,e.from).block));if(!r.every((e=>e)))return null;let i=n.map(((e,n)=>function(e,{open:t,close:n},r,i){let o,s,l=e.sliceDoc(r-f,r),a=e.sliceDoc(i,i+f),c=/\s*$/.exec(l)[0].length,h=/^\s*/.exec(a)[0].length,u=l.length-c;if(l.slice(u-t.length,u)==t&&a.slice(h,h+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:i+h,margin:h&&1}};i-r<=2*f?o=s=e.sliceDoc(r,i):(o=e.sliceDoc(r,r+f),s=e.sliceDoc(i-f,i));let d=/^\s*/.exec(o)[0].length,p=/\s*$/.exec(s)[0].length,m=s.length-p-n.length;return o.slice(d,d+t.length)==t&&s.slice(m,m+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(o.charAt(d+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(s.charAt(m-1))?1:0}}:null}(t,r[n],e.from,e.to)));if(2!=e&&!i.every((e=>e)))return{changes:t.changes(n.map(((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}])))};if(1!=e&&i.some((e=>e))){let e=[];for(let t,n=0;n<i.length;n++)if(t=i[n]){let i=r[n],{open:o,close:s}=t;e.push({from:o.pos-i.open.length,to:o.pos+o.margin},{from:s.pos-s.margin,to:s.pos+i.close.length})}return{changes:e}}return null}function p(e,t,n=t.selection.ranges){let r=[],i=-1;for(let{from:o,to:s}of n){let e=r.length,n=1e9,l=u(t,o).line;if(l){for(let e=o;e<=s;){let a=t.doc.lineAt(e);if(a.from>i&&(o==s||s>a.from)){i=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,o=a.text.slice(e,e+l.length)==l?e:-1;e<a.text.length&&e<n&&(n=e),r.push({line:a,comment:o,token:l,indent:e,empty:t,single:!1})}e=a.to+1}if(n<1e9)for(let t=e;t<r.length;t++)r[t].indent<r[t].line.text.length&&(r[t].indent=n);r.length==e+1&&(r[e].single=!0)}}if(2!=e&&r.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:i,indent:o,empty:s,single:l}of r)!l&&s||e.push({from:t.from+o,insert:i+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,o=r+i.length;" "==t.text[o-t.from]&&o++,e.push({from:r,to:o})}return{changes:e}}return null}const m=r.Annotation.define(),g=r.Annotation.define(),y=r.Facet.define(),v=r.Facet.define({combine:e=>(0,r.combineConfig)(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})});const b=r.StateField.define({create:()=>L.empty,update(e,t){let n=t.state.facet(v),i=t.annotation(m);if(i){let o=t.docChanged?r.EditorSelection.single(function(e){let t=0;return e.iterChangedRanges(((e,n)=>t=n)),t}(t.changes)):void 0,s=E.fromTransaction(t,o),l=i.side,a=0==l?e.undone:e.done;return a=s?M(a,a.length,n.minDepth,s):P(a,t.startState.selection),new L(0==l?i.rest:a,0==l?a:i.rest)}let o=t.annotation(g);if("full"!=o&&"before"!=o||(e=e.isolate()),!1===t.annotation(r.Transaction.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=E.fromTransaction(t),l=t.annotation(r.Transaction.time),a=t.annotation(r.Transaction.userEvent);return s?e=e.addChanges(s,l,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,l,a,n.newGroupDelay)),"full"!=o&&"after"!=o||(e=e.isolate()),e},toJSON:e=>({done:e.done.map((e=>e.toJSON())),undone:e.undone.map((e=>e.toJSON()))}),fromJSON:e=>new L(e.done.map(E.fromJSON),e.undone.map(E.fromJSON))});function w(e={}){return[b,v.of(e),i.EditorView.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?k:"historyRedo"==e.inputType?S:null;return!!n&&(e.preventDefault(),n(t))}})]}function x(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(b,!1);if(!i)return!1;let o=i.pop(e,n,t);return!!o&&(r(o),!0)}}const k=x(0,!1),S=x(1,!1),C=x(0,!0),A=x(1,!0);class E{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new E(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((e=>e.toJSON()))}}static fromJSON(e){return new E(e.changes&&r.ChangeSet.fromJSON(e.changes),[],e.mapped&&r.ChangeDesc.fromJSON(e.mapped),e.startSelection&&r.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(r.EditorSelection.fromJSON))}static fromTransaction(e,t){let n=D;for(let r of e.startState.facet(y)){let t=r(e);t.length&&(n=n.concat(t))}return!n.length&&e.changes.empty?null:new E(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,D)}static selection(e){return new E(void 0,D,void 0,void 0,e)}}function M(e,t,n,r){let i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function O(e,t){return e.length?t.length?e.concat(t):e:t}const D=[],I=200;function P(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-I));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),M(e,e.length-1,1e9,n.setSelAfter(r)))}return[E.selection([t])]}function T(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function B(e,t){if(!e.length)return e;let n=e.length,r=D;for(;n;){let i=N(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[E.selection(r)]:D}function N(e,t,n){let i=O(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):D,n);if(!e.changes)return E.selection(i);let o=e.changes.map(t),s=t.mapDesc(e.changes,!0),l=e.mapped?e.mapped.composeDesc(s):s;return new E(o,r.StateEffect.mapEffects(e.effects,t),l,e.startSelection.map(s),i)}const R=/^(input\.type|delete)($|\.)/;class L{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new L(this.done,this.undone):this}addChanges(e,t,n,r,i){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||R.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,function(e,t){let n=[],r=!1;return e.iterChangedRanges(((e,t)=>n.push(e,t))),t.iterChangedRanges(((e,t,i,o)=>{for(let s=0;s<n.length;){let e=n[s++],t=n[s++];o>=e&&i<=t&&(r=!0)}})),r}(s.changes,e.changes))||"input.type.compose"==n)?M(o,o.length-1,r.minDepth,new E(e.changes.compose(s.changes),O(e.effects,s.effects),s.mapped,s.startSelection,D)):M(o,o.length,r.minDepth,e),new L(o,D,t,n)}addSelection(e,t,n,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:D;return i.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(o=i[i.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter(((e,t)=>e.empty!=s.ranges[t].empty)).length)?this:new L(P(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new L(B(this.done,e),B(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let i=r[r.length-1];if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:m.of({side:e,rest:T(r)}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let n=1==r.length?D:r.slice(0,r.length-1);return i.mapped&&(n=B(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:m.of({side:e,rest:n}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}L.empty=new L(D,D);const _=[{key:"Mod-z",run:k,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:S,preventDefault:!0},{linux:"Ctrl-Shift-z",run:S,preventDefault:!0},{key:"Mod-u",run:C,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:A,preventDefault:!0}];function q(e,t){return r.EditorSelection.create(e.ranges.map(t),e.mainIndex)}function F(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function j({state:e,dispatch:t},n){let r=q(e.selection,n);return!r.eq(e.selection)&&(t(F(e,r)),!0)}function V(e,t){return r.EditorSelection.cursor(t?e.to:e.from)}function W(e,t){return j(e,(n=>n.empty?e.moveByChar(n,t):V(n,t)))}function z(e){return e.textDirectionAt(e.state.selection.main.head)==i.Direction.LTR}const U=e=>W(e,!z(e)),$=e=>W(e,z(e));function H(e,t){return j(e,(n=>n.empty?e.moveByGroup(n,t):V(n,t)))}"undefined"!=typeof Intl&&Intl.Segmenter;function J(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function K(e,t,n){let i,l,a=(0,o.qz)(e).resolveInner(t.head),c=n?s.md.closedBy:s.md.openedBy;for(let r=t.head;;){let t=n?a.childAfter(r):a.childBefore(r);if(!t)break;J(e,t,c)?a=t:r=n?t.to:t.from}return l=a.type.prop(c)&&(i=n?(0,o.Um)(e,a.from,1):(0,o.Um)(e,a.to,-1))&&i.matched?n?i.end.to:i.end.from:n?a.to:a.from,r.EditorSelection.cursor(l,n?-1:1)}function G(e,t){return j(e,(n=>{if(!n.empty)return V(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)}))}const Q=e=>G(e,!1),Z=e=>G(e,!0);function X(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,o=0;if(n){for(let t of e.state.facet(i.EditorView.scrollMargins)){let n=t(e);(null===n||void 0===n?void 0:n.top)&&(r=Math.max(null===n||void 0===n?void 0:n.top,r)),(null===n||void 0===n?void 0:n.bottom)&&(o=Math.max(null===n||void 0===n?void 0:n.bottom,o))}t=e.scrollDOM.clientHeight-r-o}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:o,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function Y(e,t){let n,r=X(e),{state:o}=e,s=q(o.selection,(n=>n.empty?e.moveVertically(n,t,r.height):V(n,t)));if(s.eq(o.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(o.selection.main.head),l=e.scrollDOM.getBoundingClientRect(),a=l.top+r.marginTop,c=l.bottom-r.marginBottom;t&&t.top>a&&t.bottom<c&&(n=i.EditorView.scrollIntoView(s.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(F(o,s),{effects:n}),!0}const ee=e=>Y(e,!1),te=e=>Y(e,!0);function ne(e,t,n){let i=e.lineBlockAt(t.head),o=e.moveToLineBoundary(t,n);if(o.head==t.head&&o.head!=(n?i.to:i.from)&&(o=e.moveToLineBoundary(t,n,!1)),!n&&o.head==i.from&&i.length){let n=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(o=r.EditorSelection.cursor(i.from+n))}return o}function re(e,t,n){let i=!1,s=q(e.selection,(t=>{let s=(0,o.Um)(e,t.head,-1)||(0,o.Um)(e,t.head,1)||t.head>0&&(0,o.Um)(e,t.head-1,1)||t.head<e.doc.length&&(0,o.Um)(e,t.head+1,-1);if(!s||!s.end)return t;i=!0;let l=s.start.from==t.head?s.end.to:s.end.from;return n?r.EditorSelection.range(t.anchor,l):r.EditorSelection.cursor(l)}));return!!i&&(t(F(e,s)),!0)}function ie(e,t){let n=q(e.state.selection,(e=>{let n=t(e);return r.EditorSelection.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)}));return!n.eq(e.state.selection)&&(e.dispatch(F(e.state,n)),!0)}function oe(e,t){return ie(e,(n=>e.moveByChar(n,t)))}const se=e=>oe(e,!z(e)),le=e=>oe(e,z(e));function ae(e,t){return ie(e,(n=>e.moveByGroup(n,t)))}function ce(e,t){return ie(e,(n=>e.moveVertically(n,t)))}const he=e=>ce(e,!1),ue=e=>ce(e,!0);function fe(e,t){return ie(e,(n=>e.moveVertically(n,t,X(e).height)))}const de=e=>fe(e,!1),pe=e=>fe(e,!0),me=({state:e,dispatch:t})=>(t(F(e,{anchor:0})),!0),ge=({state:e,dispatch:t})=>(t(F(e,{anchor:e.doc.length})),!0),ye=({state:e,dispatch:t})=>(t(F(e,{anchor:e.selection.main.anchor,head:0})),!0),ve=({state:e,dispatch:t})=>(t(F(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function be(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:o}=e,s=o.changeByRange((i=>{let{from:o,to:s}=i;if(o==s){let r=t(o);r<o?(n="delete.backward",r=we(e,r,!1)):r>o&&(n="delete.forward",r=we(e,r,!0)),o=Math.min(o,r),s=Math.max(s,r)}else o=we(e,o,!1),s=we(e,s,!0);return o==s?{range:i}:{changes:{from:o,to:s},range:r.EditorSelection.cursor(o)}}));return!s.changes.empty&&(e.dispatch(o.update(s,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?i.EditorView.announce.of(o.phrase("Selection deleted")):void 0})),!0)}function we(e,t,n){if(e instanceof i.EditorView)for(let r of e.state.facet(i.EditorView.atomicRanges).map((t=>t(e))))r.between(t,t,((e,r)=>{e<t&&r>t&&(t=n?r:e)}));return t}const xe=(e,t)=>be(e,(n=>{let i,s,{state:l}=e,a=l.doc.lineAt(n);if(!t&&n>a.from&&n<a.from+200&&!/[^ \t]/.test(i=a.text.slice(0,n-a.from))){if("\t"==i[i.length-1])return n-1;let e=(0,r.countColumn)(i,l.tabSize)%(0,o.y1)(l)||(0,o.y1)(l);for(let t=0;t<e&&" "==i[i.length-1-t];t++)n--;s=n}else s=(0,r.findClusterBreak)(a.text,n-a.from,t,t)+a.from,s==n&&a.number!=(t?l.doc.lines:1)&&(s+=t?1:-1);return s})),ke=e=>xe(e,!1),Se=e=>xe(e,!0),Ce=(e,t)=>be(e,(n=>{let i=n,{state:o}=e,s=o.doc.lineAt(i),l=o.charCategorizer(i);for(let e=null;;){if(i==(t?s.to:s.from)){i==n&&s.number!=(t?o.doc.lines:1)&&(i+=t?1:-1);break}let a=(0,r.findClusterBreak)(s.text,i-s.from,t)+s.from,c=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),h=l(c);if(null!=e&&h!=e)break;" "==c&&i==n||(e=h),i=a}return i})),Ae=e=>Ce(e,!1),Ee=e=>be(e,(t=>{let n=e.lineBlockAt(t).to;return t<n?n:Math.min(e.state.doc.length,t+1)}));function Me(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(r.empty||r.to!=o.from||(o=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(r)}else t.push({from:i.from,to:o.to,ranges:[r]});n=o.number+1}return t}function Oe(e,t,n){if(e.readOnly)return!1;let i=[],o=[];for(let s of Me(e)){if(n?s.to==e.doc.length:0==s.from)continue;let t=e.doc.lineAt(n?s.to+1:s.from-1),l=t.length+1;if(n){i.push({from:s.to,to:t.to},{from:s.from,insert:t.text+e.lineBreak});for(let t of s.ranges)o.push(r.EditorSelection.range(Math.min(e.doc.length,t.anchor+l),Math.min(e.doc.length,t.head+l)))}else{i.push({from:t.from,to:s.from},{from:s.to,insert:e.lineBreak+t.text});for(let e of s.ranges)o.push(r.EditorSelection.range(e.anchor-l,e.head-l))}}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:r.EditorSelection.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0)}function De(e,t,n){if(e.readOnly)return!1;let r=[];for(let i of Me(e))n?r.push({from:i.from,insert:e.doc.slice(i.from,i.to)+e.lineBreak}):r.push({from:i.to,insert:e.lineBreak+e.doc.slice(i.from,i.to)});return t(e.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Ie=Pe(!1);function Pe(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let i=t.changeByRange((n=>{let{from:i,to:l}=n,a=t.doc.lineAt(i),c=!e&&i==l&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,r=(0,o.qz)(e).resolveInner(t),i=r.childBefore(t),l=r.childAfter(t);return i&&l&&i.to<=t&&l.from>=t&&(n=i.type.prop(s.md.closedBy))&&n.indexOf(l.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(i.to,l.from))?{from:i.to,to:l.from}:null}(t,i);e&&(i=l=(l<=a.to?a:t.doc.lineAt(l)).to);let h=new o.Gn(t,{simulateBreak:i,simulateDoubleBreak:!!c}),u=(0,o.K0)(h,i);for(null==u&&(u=(0,r.countColumn)(/^\s*/.exec(t.doc.lineAt(i).text)[0],t.tabSize));l<a.to&&/\s/.test(a.text[l-a.from]);)l++;c?({from:i,to:l}=c):i>a.from&&i<a.from+100&&!/\S/.test(a.text.slice(0,i))&&(i=a.from);let f=["",(0,o.SS)(t,u)];return c&&f.push((0,o.SS)(t,h.lineIndent(a.from,-1))),{changes:{from:i,to:l,insert:r.Text.of(f)},range:r.EditorSelection.cursor(i+1+f[1].length)}}));return n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Te(e,t){let n=-1;return e.changeByRange((i=>{let o=[];for(let r=i.from;r<=i.to;){let s=e.doc.lineAt(r);s.number>n&&(i.empty||i.to>s.from)&&(t(s,o,i),n=s.number),r=s.to+1}let s=e.changes(o);return{changes:o,range:r.EditorSelection.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}}))}const Be=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Te(e,((t,n)=>{n.push({from:t.from,insert:e.facet(o.c)})})),{userEvent:"input.indent"})),!0),Ne=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Te(e,((t,n)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let s=(0,r.countColumn)(i,e.tabSize),l=0,a=(0,o.SS)(e,Math.max(0,s-(0,o.y1)(e)));for(;l<i.length&&l<a.length&&i.charCodeAt(l)==a.charCodeAt(l);)l++;n.push({from:t.from+l,to:t.from+i.length,insert:a.slice(l)})})),{userEvent:"delete.dedent"})),!0),Re=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>j(e,(t=>K(e.state,t,!z(e)))),shift:e=>ie(e,(t=>K(e.state,t,!z(e))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>j(e,(t=>K(e.state,t,z(e)))),shift:e=>ie(e,(t=>K(e.state,t,z(e))))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>Oe(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>De(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>Oe(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>De(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,i=null;return n.ranges.length>1?i=r.EditorSelection.create([n.main]):n.main.empty||(i=r.EditorSelection.create([r.EditorSelection.cursor(n.main.head)])),!!i&&(t(F(e,i)),!0)}},{key:"Mod-Enter",run:Pe(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=Me(e).map((({from:t,to:n})=>r.EditorSelection.range(t,Math.min(n+1,e.doc.length))));return t(e.update({selection:r.EditorSelection.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=q(e.selection,(t=>{var n;let i=(0,o.qz)(e).resolveInner(t.head,1);for(;!(i.from<t.from&&i.to>=t.to||i.to>t.to&&i.from<=t.from)&&(null===(n=i.parent)||void 0===n?void 0:n.parent);)i=i.parent;return r.EditorSelection.range(i.to,i.from)}));return t(F(e,n)),!0},preventDefault:!0},{key:"Mod-[",run:Ne},{key:"Mod-]",run:Be},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new o.Gn(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=Te(e,((t,i,s)=>{let l=(0,o.K0)(r,t.from);if(null==l)return;/\S/.test(t.text)||(l=0);let a=/^\s*/.exec(t.text)[0],c=(0,o.SS)(e,l);(a!=c||s.from<t.from+a.length)&&(n[t.from]=l,i.push({from:t.from,to:t.from+a.length,insert:c}))}));return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Me(t).map((({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n})))),r=q(t.selection,(t=>e.moveVertically(t,!0))).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>re(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=u(e.state,n.from);return r.line?a(e):!!r.block&&h(e)}},{key:"Alt-A",run:c}].concat([{key:"ArrowLeft",run:U,shift:se,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>H(e,!z(e)),shift:e=>ae(e,!z(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>j(e,(t=>ne(e,t,!z(e)))),shift:e=>ie(e,(t=>ne(e,t,!z(e)))),preventDefault:!0},{key:"ArrowRight",run:$,shift:le,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>H(e,z(e)),shift:e=>ae(e,z(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>j(e,(t=>ne(e,t,z(e)))),shift:e=>ie(e,(t=>ne(e,t,z(e)))),preventDefault:!0},{key:"ArrowUp",run:Q,shift:he,preventDefault:!0},{mac:"Cmd-ArrowUp",run:me,shift:ye},{mac:"Ctrl-ArrowUp",run:ee,shift:de},{key:"ArrowDown",run:Z,shift:ue,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ge,shift:ve},{mac:"Ctrl-ArrowDown",run:te,shift:pe},{key:"PageUp",run:ee,shift:de},{key:"PageDown",run:te,shift:pe},{key:"Home",run:e=>j(e,(t=>ne(e,t,!1))),shift:e=>ie(e,(t=>ne(e,t,!1))),preventDefault:!0},{key:"Mod-Home",run:me,shift:ye},{key:"End",run:e=>j(e,(t=>ne(e,t,!0))),shift:e=>ie(e,(t=>ne(e,t,!0))),preventDefault:!0},{key:"Mod-End",run:ge,shift:ve},{key:"Enter",run:Ie},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:ke,shift:ke},{key:"Delete",run:Se},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ae},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>Ce(e,!0)},{mac:"Mod-Backspace",run:e=>be(e,(t=>{let n=e.lineBlockAt(t).from;return t>n?n:Math.max(0,t-1)}))},{mac:"Mod-Delete",run:Ee}].concat([{key:"Ctrl-b",run:U,shift:se,preventDefault:!0},{key:"Ctrl-f",run:$,shift:le},{key:"Ctrl-p",run:Q,shift:he},{key:"Ctrl-n",run:Z,shift:ue},{key:"Ctrl-a",run:e=>j(e,(t=>r.EditorSelection.cursor(e.lineBlockAt(t.head).from,1))),shift:e=>ie(e,(t=>r.EditorSelection.cursor(e.lineBlockAt(t.head).from)))},{key:"Ctrl-e",run:e=>j(e,(t=>r.EditorSelection.cursor(e.lineBlockAt(t.head).to,-1))),shift:e=>ie(e,(t=>r.EditorSelection.cursor(e.lineBlockAt(t.head).to)))},{key:"Ctrl-d",run:Se},{key:"Ctrl-h",run:ke},{key:"Ctrl-k",run:Ee},{key:"Ctrl-Alt-h",run:Ae},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:r.Text.of(["",""])},range:r.EditorSelection.cursor(e.from)})));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,i=e.doc.lineAt(n),o=n==i.from?n-1:(0,r.findClusterBreak)(i.text,n-i.from,!1)+i.from,s=n==i.to?n+1:(0,r.findClusterBreak)(i.text,n-i.from,!0)+i.from;return{changes:{from:o,to:s,insert:e.doc.slice(n,s).append(e.doc.slice(o,n))},range:r.EditorSelection.cursor(s)}}));return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:te}].map((e=>({mac:e.key,run:e.run,shift:e.shift}))))),Le={key:"Tab",run:Be,shift:Ne}},434:(e,t,n)=>{n.d(t,{Gn:()=>ie,n$:()=>et,R_:()=>$e,mi:()=>Le,e7:()=>Me,y1:()=>te,K0:()=>re,nY:()=>de,SS:()=>ne,c:()=>ee,Um:()=>it,nF:()=>We,qz:()=>z});var r=n(857),i=n(242),o=n(105);let s=0;class l{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=s++}static define(e){if(null===e||void 0===e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new l([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new c;return t=>t.modified.indexOf(e)>-1?t:c.get(t.base||t,t.modified.concat(e).sort(((e,t)=>e.id-t.id)))}}let a=0;class c{constructor(){this.instances=[],this.id=a++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find((n=>{return n.base==e&&(r=t,i=n.modified,r.length==i.length&&r.every(((e,t)=>e==i[t])));var r,i}));if(n)return n;let r=[],i=new l(r,e,t);for(let s of t)s.instances.push(i);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort(((e,t)=>t.length-e.length))}(t);for(let s of e.set)if(!s.modified.length)for(let e of o)r.push(c.get(s,e));return i}}function h(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(" "))if(e){let n=[],i=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!r)throw new RangeError("Invalid path: "+e);if(n.push("*"==r[0]?"":'"'==r[0][0]?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){i=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,l=n[s];if(!l)throw new RangeError("Invalid path: "+e);let a=new f(r,i,s>0?n.slice(0,s):null);t[l]=a.sort(t[l])}}return u.add(t)}const u=new r.md;class f{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function d(e,t){let n=Object.create(null);for(let o of e)if(Array.isArray(o.tag))for(let e of o.tag)n[e.id]=o.class;else n[o.tag.id]=o.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+" "+r:r;break}}return t},scope:r}}function p(e,t,n,r=0,i=e.length){let o=new m(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}f.empty=new f([],2,null);class m{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,o){let{type:s,from:l,to:a}=e;if(l>=n||a<=t)return;s.isTop&&(o=this.highlighters.filter((e=>!e.scope||e.scope(s))));let c=i,h=function(e){let t=e.type.prop(u);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||f.empty,d=function(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+" "+e:e)}return n}(o,h.tags);if(d&&(c&&(c+=" "),c+=d,1==h.mode&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(t,l),c),h.opaque)return;let p=e.tree&&e.tree.prop(r.md.mounted);if(p&&p.overlay){let r=e.node.enter(p.overlay[0].from+l,1),s=this.highlighters.filter((e=>!e.scope||e.scope(p.tree.type))),h=e.firstChild();for(let u=0,f=l;;u++){let d=u<p.overlay.length?p.overlay[u]:null,m=d?d.from+l:a,g=Math.max(t,f),y=Math.min(n,m);if(g<y&&h)for(;e.from<y&&(this.highlightRange(e,g,y,i,o),this.startSpan(Math.min(y,e.to),c),!(e.to>=m)&&e.nextSibling()););if(!d||m>n)break;f=d.to+l,f>t&&(this.highlightRange(r.cursor(),Math.max(t,d.from+l),Math.min(n,f),"",s),this.startSpan(Math.min(n,f),c))}h&&e.parent()}else if(e.firstChild()){p&&(i="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,o),this.startSpan(Math.min(n,e.to),c)}}while(e.nextSibling());e.parent()}}}const g=l.define,y=g(),v=g(),b=g(v),w=g(v),x=g(),k=g(x),S=g(x),C=g(),A=g(C),E=g(),M=g(),O=g(),D=g(O),I=g(),P={comment:y,lineComment:g(y),blockComment:g(y),docComment:g(y),name:v,variableName:g(v),typeName:b,tagName:g(b),propertyName:w,attributeName:g(w),className:g(v),labelName:g(v),namespace:g(v),macroName:g(v),literal:x,string:k,docString:g(k),character:g(k),attributeValue:g(k),number:S,integer:g(S),float:g(S),bool:g(x),regexp:g(x),escape:g(x),color:g(x),url:g(x),keyword:E,self:g(E),null:g(E),atom:g(E),unit:g(E),modifier:g(E),operatorKeyword:g(E),controlKeyword:g(E),definitionKeyword:g(E),moduleKeyword:g(E),operator:M,derefOperator:g(M),arithmeticOperator:g(M),logicOperator:g(M),bitwiseOperator:g(M),compareOperator:g(M),updateOperator:g(M),definitionOperator:g(M),typeOperator:g(M),controlOperator:g(M),punctuation:O,separator:g(O),bracket:D,angleBracket:g(D),squareBracket:g(D),paren:g(D),brace:g(D),content:C,heading:A,heading1:g(A),heading2:g(A),heading3:g(A),heading4:g(A),heading5:g(A),heading6:g(A),contentSeparator:g(C),list:g(C),quote:g(C),emphasis:g(C),strong:g(C),link:g(C),monospace:g(C),strikethrough:g(C),inserted:g(),deleted:g(),changed:g(),invalid:g(),meta:I,documentMeta:g(I),annotation:g(I),processingInstruction:g(I),definition:l.defineModifier(),constant:l.defineModifier(),function:l.defineModifier(),standard:l.defineModifier(),local:l.defineModifier(),special:l.defineModifier()},T=(d([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]),"undefined"==typeof Symbol?"__\u037c":Symbol.for("\u037c")),B="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),N="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class R{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,o,s){let l=[],a=/^@(\w+)\b/.exec(e[0]),c=a&&"keyframes"==a[1];if(a&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))i(n.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,o);else if(s&&"object"==typeof s){if(!a)throw new RangeError("The value of a property ("+n+") should be a primitive value.");i(r(n),s,l,c)}else null!=s&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(l.length||c)&&o.push((!n||a||s?e:e.map(n)).join(", ")+" {"+l.join(" ")+"}")}for(let o in e)i(r(o),e[o],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=N[T]||1;return N[T]=e+1,"\u037c"+e.toString(36)}static mount(e,t,n){let r=e[B],i=n&&n.nonce;r?i&&r.setNonce(i):r=new _(e,i),r.mount(Array.isArray(t)?t:[t])}}let L=new Map;class _{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=L.get(n);if(t)return e.adoptedStyleSheets=[t.sheet,...e.adoptedStyleSheets],e[B]=t;this.sheet=new r.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],L.set(n,this)}else{this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let r=e.head||e;r.insertBefore(this.styleTag,r.firstChild)}this.modules=[],e[B]=this}mount(e){let t=this.sheet,n=0,r=0;for(let i=0;i<e.length;i++){let o=e[i],s=this.modules.indexOf(o);if(s<r&&s>-1&&(this.modules.splice(s,1),r--,s=-1),-1==s){if(this.modules.splice(r++,0,o),t)for(let e=0;e<o.rules.length;e++)t.insertRule(o.rules[e],n++)}else{for(;r<s;)n+=this.modules[r++].rules.length;n+=o.rules.length,r++}}if(!t){let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var q;const F=new r.md;const j=new r.md;class V{constructor(e,t,n=[],r=""){this.data=e,this.name=r,i.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(i.EditorState.prototype,"tree",{get(){return z(this)}}),this.parser=t,this.extension=[X.of(this),i.EditorState.languageData.of(((e,t,n)=>{let r=W(e,t,n),i=r.type.prop(F);if(!i)return[];let o=e.facet(i),s=r.type.prop(j);if(s){let i=r.resolve(t-r.from,n);for(let t of s)if(t.test(i,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o}))].concat(n)}isActiveAt(e,t,n=-1){return W(e,t,n).type.prop(F)==this.data}findRegions(e){let t=e.facet(X);if((null===t||void 0===t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(F)==this.data)return void n.push({from:t,to:t+e.length});let o=e.prop(r.md.mounted);if(o){if(o.tree.prop(F)==this.data){if(o.overlay)for(let e of o.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(o.overlay){let e=n.length;if(i(o.tree,o.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let o=e.children[n];o instanceof r.mp&&i(o,e.positions[n]+t)}};return i(z(e),0),n}get allowsNesting(){return!0}}function W(e,t,n){let i=e.facet(X),o=z(e).topNode;if(!i||i.allowsNesting)for(let s=o;s;s=s.enter(t,n,r.vj.ExcludeBuffers))s.type.isTop&&(o=s);return o}V.setState=i.StateEffect.define();function z(e){let t=e.field(V.state,!1);return t?t.tree:r.mp.empty}class U{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let $=null;class H{constructor(e,t,n=[],r,i,o,s,l){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new H(e,t,[],r.mp.empty,0,n,[],null)}startParse(){return this.parser.startParse(new U(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=r.mp.empty&&this.isDone(null!==t&&void 0!==t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(r.i9.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!==t&&void 0!==t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((()=>{for(;!(t=this.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(r.i9.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=$;$=this;try{return e()}finally{$=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=J(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:o,viewport:s,skipped:l}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,n,r,i)=>t.push({fromA:e,toA:n,fromB:r,toB:i}))),n=r.i9.applyChanges(n,t),i=r.mp.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){l=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);n<r&&l.push({from:n,to:r})}}}return new H(this.parser,t,n,i,o,s,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:t,to:r}=this.skipped[n];t<e.to&&r>e.from&&(this.fragments=J(this.fragments,t,r),this.skipped.splice(n--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends r._b{createParse(t,n,i){let o=i[0].from,s=i[i.length-1].to;return{parsedPos:o,advance(){let t=$;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new r.mp(r.Jq.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return $}}function J(e,t,n){return r.i9.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class K{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new K(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=H.create(e.facet(X).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new K(n)}}V.state=i.StateField.define({create:K.init,update(e,t){for(let n of t.effects)if(n.is(V.setState))return n.value;return t.startState.facet(X)!=t.state.facet(X)?K.init(t.state):e.apply(t)}});let G=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(G=e=>{let t=-1,n=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const Q="undefined"!=typeof navigator&&(null===(q=navigator.scheduling)||void 0===q?void 0:q.isInputPending)?()=>navigator.scheduling.isInputPending():null,Z=o.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(V.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(V.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=G(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(V.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Q?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&n.doc.length>r+1e3,l=i.context.work((()=>Q&&Q()||Date.now()>o),r+(s?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:V.setState.of(new K(i.context))})),this.chunkBudget>0&&(!l||s)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>(0,o.logException)(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),X=i.Facet.define({combine:e=>e.length?e[0]:null,enables:e=>[V.state,Z,o.EditorView.contentAttributes.compute([e],(t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}}))]});const Y=i.Facet.define(),ee=i.Facet.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some((e=>e!=t[0])))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function te(e){let t=e.facet(ee);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function ne(e,t){let n="",r=e.tabSize,i=e.facet(ee)[0];if("\t"==i){for(;t>=r;)n+="\t",t-=r;i=" "}for(let o=0;o<t;o++)n+=i;return n}function re(e,t){e instanceof i.EditorState&&(e=new ie(e));for(let r of e.state.facet(Y)){let n=r(e,t);if(void 0!==n)return n}let n=z(e.state);return n.length>=t?function(e,t,n){return le(t.resolveInner(n).enterUnfinishedNodesBefore(n),n,e)}(e,n,t):null}class ie{constructor(e,t={}){this.state=e,this.options=t,this.unit=te(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return null!=r&&r>=n.from&&r<=n.to?i&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(i+=o-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return(0,i.countColumn)(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const oe=new r.md;function se(e){let t=e.type.prop(oe);if(t)return t;let n,i=e.firstChild;if(i&&(n=i.type.prop(r.md.closedBy))){let t=e.lastChild,r=t&&n.indexOf(t.name)>-1;return e=>ue(e,!0,1,void 0,r&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?ae:null}function le(e,t,n){for(;e;e=e.parent){let r=se(e);if(r)return r(ce.create(n,t,e))}return null}function ae(){return 0}class ce extends ie{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.node=n}static create(e,t,n){return new ce(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(he(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){let e=this.node.parent;return e?le(e,this.pos,this.base):0}}function he(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function ue(e,t,n,r,i){let o=e.textAfter,s=o.match(/^\s*/)[0].length,l=r&&o.slice(s,s+r.length)==r||i==e.pos+s,a=t?function(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==i||i<=o.from?o.to:Math.min(o.to,i);for(let l=n.to;;){let e=t.childAfter(l);if(!e||e==r)return null;if(!e.type.isSkipped)return e.from<s?n:null;l=e.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:e.unit*n)}const fe=200;function de(){return i.EditorState.transactionFilter.of((e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+fe)return e;let o=n.sliceString(i.from,r);if(!t.some((e=>e.test(o))))return e;let{state:s}=e,l=-1,a=[];for(let{head:c}of s.selection.ranges){let e=s.doc.lineAt(c);if(e.from==l)continue;l=e.from;let t=re(s,e.from);if(null==t)continue;let n=/^\s*/.exec(e.text)[0],r=ne(s,t);n!=r&&a.push({from:e.from,to:e.from+n.length,insert:r})}return a.length?[e,{changes:a,sequential:!0}]:e}))}const pe=i.Facet.define(),me=new r.md;function ge(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function ye(e,t,n){for(let r of e.facet(pe)){let i=r(e,t,n);if(i)return i}return function(e,t,n){let r=z(e);if(r.length<n)return null;let i=null;for(let o=r.resolveInner(n,1);o;o=o.parent){if(o.to<=n||o.from>n)continue;if(i&&o.from<t)break;let s=o.type.prop(me);if(s&&(o.to<r.length-50||r.length==e.doc.length||!ge(o))){let r=s(o,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(i=r)}}return i}(e,t,n)}function ve(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const be=i.StateEffect.define({map:ve}),we=i.StateEffect.define({map:ve});function xe(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some((e=>e.from<=n&&e.to>=n))||t.push(e.lineBlockAt(n));return t}const ke=i.StateField.define({create:()=>o.Decoration.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(be)&&!Ce(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(De),i=r?o.Decoration.replace({widget:new Be(r(t.state,n.value))}):Te;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(we)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:r}=t.selection.main;e.between(r,r,((e,t)=>{e<r&&t>r&&(n=!0)})),n&&(e=e.update({filterFrom:r,filterTo:r,filter:(e,t)=>t<=r||e>=r}))}return e},provide:e=>o.EditorView.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,((e,t)=>{n.push(e,t)})),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");t.push(Te.range(r,i))}return o.Decoration.set(t,!0)}});function Se(e,t,n){var r;let i=null;return null===(r=e.field(ke,!1))||void 0===r||r.between(t,n,((e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})})),i}function Ce(e,t,n){let r=!1;return e.between(t,t,((e,i)=>{e==t&&i==n&&(r=!0)})),r}function Ae(e,t){return e.field(ke,!1)?t:t.concat(i.StateEffect.appendConfig.of(Ie()))}function Ee(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return o.EditorView.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const Me=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of xe(e)){let n=ye(e.state,t.from,t.to);if(n)return e.dispatch({effects:Ae(e.state,[be.of(n),Ee(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(ke,!1))return!1;let t=[];for(let n of xe(e)){let r=Se(e.state,n.from,n.to);r&&t.push(we.of(r),Ee(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),o=ye(t,i.from,i.to);o&&n.push(be.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:Ae(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(ke,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,((e,t)=>{n.push(we.of({from:e,to:t}))})),e.dispatch({effects:n}),!0}}],Oe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},De=i.Facet.define({combine:e=>(0,i.combineConfig)(e,Oe)});function Ie(e){let t=[ke,_e];return e&&t.push(De.of(e)),t}function Pe(e,t){let{state:n}=e,r=n.facet(De),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=Se(e.state,n.from,n.to);r&&e.dispatch({effects:we.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}const Te=o.Decoration.replace({widget:new class extends o.WidgetType{toDOM(e){return Pe(e,null)}}});class Be extends o.WidgetType{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Pe(e,this.value)}}const Ne={openText:"\u2304",closedText:"\u203a",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Re extends o.GutterMarker{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Le(e={}){let t=Object.assign(Object.assign({},Ne),e),n=new Re(t,!0),r=new Re(t,!1),s=o.ViewPlugin.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(X)!=e.state.facet(X)||e.startState.field(ke,!1)!=e.state.field(ke,!1)||z(e.startState)!=z(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new i.RangeSetBuilder;for(let i of e.viewportLineBlocks){let o=Se(e.state,i.from,i.to)?r:ye(e.state,i.from,i.to)?n:null;o&&t.add(i.from,i.from,o)}return t.finish()}}),{domEventHandlers:l}=t;return[s,(0,o.gutter)({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(s))||void 0===t?void 0:t.markers)||i.RangeSet.empty},initialSpacer:()=>new Re(t,!1),domEventHandlers:Object.assign(Object.assign({},l),{click:(e,t,n)=>{if(l.click&&l.click(e,t,n))return!0;let r=Se(e.state,t.from,t.to);if(r)return e.dispatch({effects:we.of(r)}),!0;let i=ye(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:be.of(i)}),!0)}})}),Ie()]}const _e=o.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"}});class qe{constructor(e,t){let n;function r(e){let t=R.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const i="string"==typeof t.all?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof V?e=>e.prop(F)==o.data:o?e=>e==o:void 0,this.style=d(e.map((e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))}))),{all:i}).style,this.module=n?new R(n):null,this.themeType=t.themeType}static define(e,t){return new qe(e,t||{})}}const Fe=i.Facet.define(),je=i.Facet.define({combine:e=>e.length?[e[0]]:null});function Ve(e){let t=e.facet(Fe);return t.length?t:e.facet(je)}function We(e,t){let n,r=[Ue];return e instanceof qe&&(e.module&&r.push(o.EditorView.styleModule.of(e.module)),n=e.themeType),(null===t||void 0===t?void 0:t.fallback)?r.push(je.of(e)):n?r.push(Fe.computeN([o.EditorView.darkTheme],(t=>t.facet(o.EditorView.darkTheme)==("dark"==n)?[e]:[]))):r.push(Fe.of(e)),r}class ze{constructor(e){this.markCache=Object.create(null),this.tree=z(e.state),this.decorations=this.buildDeco(e,Ve(e.state))}update(e){let t=z(e.state),n=Ve(e.state),r=n!=Ve(e.startState);t.length<e.view.viewport.to&&!r&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n))}buildDeco(e,t){if(!t||!this.tree.length)return o.Decoration.none;let n=new i.RangeSetBuilder;for(let{from:r,to:i}of e.visibleRanges)p(this.tree,t,((e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=o.Decoration.mark({class:r})))}),r,i);return n.finish()}}const Ue=i.Prec.high(o.ViewPlugin.fromClass(ze,{decorations:e=>e.decorations})),$e=qe.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),He=o.EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Je=1e4,Ke="()[]{}",Ge=i.Facet.define({combine:e=>(0,i.combineConfig)(e,{afterCursor:!0,brackets:Ke,maxScanDistance:Je,renderMatch:Xe})}),Qe=o.Decoration.mark({class:"cm-matchingBracket"}),Ze=o.Decoration.mark({class:"cm-nonmatchingBracket"});function Xe(e){let t=[],n=e.matched?Qe:Ze;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const Ye=[i.StateField.define({create:()=>o.Decoration.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Ge);for(let i of t.state.selection.ranges){if(!i.empty)continue;let e=it(t.state,i.head,-1,r)||i.head>0&&it(t.state,i.head-1,1,r)||r.afterCursor&&(it(t.state,i.head,1,r)||i.head<t.state.doc.length&&it(t.state,i.head+1,-1,r));e&&(n=n.concat(r.renderMatch(e,t.state)))}return o.Decoration.set(n,!0)},provide:e=>o.EditorView.decorations.from(e)}),He];function et(e={}){return[Ge.of(e),Ye]}const tt=new r.md;function nt(e,t,n){let i=e.prop(t<0?r.md.openedBy:r.md.closedBy);if(i)return i;if(1==e.name.length){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function rt(e){let t=e.type.prop(tt);return t?t(e.node):e}function it(e,t,n,r={}){let i=r.maxScanDistance||Je,o=r.brackets||Ke,s=z(e),l=s.resolveInner(t,n);for(let a=l;a;a=a.parent){let r=nt(a.type,n,o);if(r&&a.from<a.to){let i=rt(a);if(i&&(n>0?t>=i.from&&t<i.to:t>i.from&&t<=i.to))return ot(e,t,n,a,i,r,o)}}return function(e,t,n,r,i,o,s){let l=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=s.indexOf(l);if(a<0||a%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=o;){let e=h.value;n<0&&(f+=e.length);let o=t+f*n;for(let t=n>0?0:e.length-1,l=n>0?e.length:-1;t!=l;t+=n){let l=s.indexOf(e[t]);if(!(l<0||r.resolveInner(o+t,1).type!=i))if(l%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:o+t,to:o+t+1},matched:l>>1==a>>1};u--}}n>0&&(f+=e.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,l.type,i,o)}function ot(e,t,n,r,i,o,s){let l=r.parent,a={from:i.from,to:i.to},c=0,h=null===l||void 0===l?void 0:l.cursor();if(h&&(n<0?h.childBefore(r.from):h.childAfter(r.to)))do{if(n<0?h.to<=r.from:h.from>=r.to){if(0==c&&o.indexOf(h.type.name)>-1&&h.from<h.to){let e=rt(h);return{start:a,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(nt(h.type,n,s))c++;else if(nt(h.type,-n,s)){if(0==c){let e=rt(h);return{start:a,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?h.prevSibling():h.nextSibling());return{start:a,matched:!1}}const st=Object.create(null),lt=[r.Jq.none],at=[],ct=Object.create(null);for(let[ft,dt]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])ct[ft]=ut(st,dt);function ht(e,t){at.indexOf(e)>-1||(at.push(e),console.warn(t))}function ut(e,t){let n=null;for(let r of t.split(".")){let t=e[r]||P[r];t?"function"==typeof t?n?n=t(n):ht(r,`Modifier ${r} used at start of tag`):n?ht(r,`Tag ${r} used as modifier`):n=t:ht(r,`Unknown highlighting tag ${r}`)}if(!n)return 0;let i=t.replace(/ /g,"_"),o=r.Jq.define({id:lt.length,name:i,props:[h({[i]:n})]});return lt.push(o),o.id}},857:(e,t,n)=>{n.d(t,{Jq:()=>a,Lj:()=>c,_b:()=>I,i9:()=>D,md:()=>s,mp:()=>d,vj:()=>f});const r=1024;let i=0;class o{constructor(e,t){this.from=e,this.to=t}}class s{constructor(e={}){this.id=i++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=a.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}s.closedBy=new s({deserialize:e=>e.split(" ")}),s.openedBy=new s({deserialize:e=>e.split(" ")}),s.group=new s({deserialize:e=>e.split(" ")}),s.contextHash=new s({perNode:!0}),s.lookAhead=new s({perNode:!0}),s.mounted=new s({perNode:!0});const l=Object.create(null);class a{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):l,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new a(e.name||"",t,e.id,n);if(e.props)for(let i of e.props)if(Array.isArray(i)||(i=i(r)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}return r}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(s.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return e=>{for(let n=e.prop(s.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}a.none=new a("",Object.create(null),0,8);class c{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let r=null;for(let t of e){let e=t(n);e&&(r||(r=Object.assign({},n.props)),r[e[0].id]=e[1])}t.push(r?new a(n.name,r,n.id,n.flags):n)}return new c(t)}}const h=new WeakMap,u=new WeakMap;var f;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(f||(f={}));class d{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=this.prop(s.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let e=n.toString();e&&(t&&(t+=","),t+=e)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new C(this.topNode,e)}cursorAt(e,t=0,n=0){let r=h.get(this)||this.topNode,i=new C(r);return i.moveTo(e,t),h.set(this,i._tree),i}get topNode(){return new b(this,0,0,null)}resolve(e,t=0){let n=v(h.get(this)||this.topNode,e,t,!1);return h.set(this,n),n}resolveInner(e,t=0){let n=v(u.get(this)||this.topNode,e,t,!0);return u.set(this,n),n}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,o=e.mode||0,s=(o&f.IncludeAnonymous)>0;for(let l=this.cursor(o|f.IncludeAnonymous);;){let e=!1;if(l.from<=i&&l.to>=r&&(!s&&l.type.isAnonymous||!1!==t(l))){if(l.firstChild())continue;e=!0}for(;e&&n&&(s||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;e=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:O(a.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new d(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new d(a.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:o=r,reused:l=[],minRepeatType:a=i.types.length}=e,c=Array.isArray(n)?new p(n,n.length):n,h=i.types,u=0,f=0;function g(e,t,n,r,s){let{id:d,start:p,end:k,size:S}=c,C=f;for(;S<0;){if(c.next(),-1==S){let t=l[d];return n.push(t),void r.push(p-e)}if(-3==S)return void(u=d);if(-4==S)return void(f=d);throw new RangeError(`Unrecognized record size: ${S}`)}let A,E,M=h[d],D=p-e;if(k-p<=o&&(E=w(c.pos-t,s))){let t=new Uint16Array(E.size-E.skip),n=c.pos-E.size,r=t.length;for(;c.pos>n;)r=x(E.start,t,r);A=new m(t,k-E.start,i),D=E.start-e}else{let e=c.pos-S;c.next();let t=[],n=[],r=d>=a?d:-1,i=0,s=k;for(;c.pos>e;)r>=0&&c.id==r&&c.size>=0?(c.end<=s-o&&(v(t,n,p,i,c.end,s,r,C),i=t.length,s=c.end),c.next()):g(p,e,t,n,r);if(r>=0&&i>0&&i<t.length&&v(t,n,p,i,p,s,r,C),t.reverse(),n.reverse(),r>-1&&i>0){let e=y(M);A=O(M,t,n,0,t.length,0,k-p,e,e)}else A=b(M,t,n,k-p,C-k)}n.push(A),r.push(D)}function y(e){return(t,n,r)=>{let i,o,l=0,a=t.length-1;if(a>=0&&(i=t[a])instanceof d){if(!a&&i.type==e&&i.length==r)return i;(o=i.prop(s.lookAhead))&&(l=n[a]+i.length+o)}return b(e,t,n,r,l)}}function v(e,t,n,r,o,s,l,a){let c=[],h=[];for(;e.length>r;)c.push(e.pop()),h.push(t.pop()+n-o);e.push(b(i.types[l],c,h,s-o,a-s)),t.push(o-n)}function b(e,t,n,r,i=0,o){if(u){let e=[s.contextHash,u];o=o?[e].concat(o):[e]}if(i>25){let e=[s.lookAhead,i];o=o?[e].concat(o):[e]}return new d(e,t,n,r,o)}function w(e,t){let n=c.fork(),r=0,i=0,s=0,l=n.end-o,h={size:0,start:0,skip:0};e:for(let o=n.pos-e;n.pos>o;){let e=n.size;if(n.id==t&&e>=0){h.size=r,h.start=i,h.skip=s,s+=4,r+=4,n.next();continue}let c=n.pos-e;if(e<0||c<o||n.start<l)break;let u=n.id>=a?4:0,f=n.start;for(n.next();n.pos>c;){if(n.size<0){if(-3!=n.size)break e;u+=4}else n.id>=a&&(u+=4);n.next()}i=f,r+=e,s+=u}return(t<0||r==e)&&(h.size=r,h.start=i,h.skip=s),h.size>4?h:void 0}function x(e,t,n){let{id:r,start:i,end:o,size:s}=c;if(c.next(),s>=0&&r<a){let l=n;if(s>4){let r=c.pos-(s-4);for(;c.pos>r;)n=x(e,t,n)}t[--n]=l,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==s?u=r:-4==s&&(f=r);return n}let k=[],S=[];for(;c.pos>0;)g(e.start||0,e.bufferStart||0,k,S,-1);let C=null!==(t=e.length)&&void 0!==t?t:k.length?S[0]+k[0].length:0;return new d(h[e.topID],k.reverse(),S.reverse(),C)}(e)}}d.empty=new d(a.none,[],[],0);class p{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new p(this.buffer,this.index)}}class m{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return a.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,t,n,r,i){let{buffer:o}=this,s=-1;for(let l=e;l!=t&&!(g(i,r,o[l+1],o[l+2])&&(s=l,n>0));l=o[l+3]);return s}slice(e,t,n){let r=this.buffer,i=new Uint16Array(t-e),o=0;for(let s=e,l=0;s<t;){i[l++]=r[s++],i[l++]=r[s++]-n;let t=i[l++]=r[s++]-n;i[l++]=r[s++]-e,o=Math.max(o,t)}return new m(i,o,this.set)}}function g(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function y(e,t){let n=e.childBefore(t);for(;n;){let t=n.lastChild;if(!t||t.to!=n.to)break;t.type.isError&&t.from==t.to?(e=n,n=t.prevSibling):n=t}return e}function v(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof b&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=r?0:f.IgnoreOverlays;if(r)for(let s=e,l=s.parent;l;s=l,l=s.parent)s instanceof b&&s.index<0&&(null===(i=l.enter(t,n,o))||void 0===i?void 0:i.from)!=s.from&&(e=l);for(;;){let r=e.enter(t,n,o);if(!r)return e;e=r}}class b{constructor(e,t,n,r){this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,r,i=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,c=t>0?l.length:-1;e!=c;e+=t){let c=l[e],h=a[e]+o.from;if(g(r,n,h,h+c.length))if(c instanceof m){if(i&f.ExcludeBuffers)continue;let s=c.findChild(0,c.buffer.length,t,n-h,r);if(s>-1)return new S(new k(o,c,e,h),null,s)}else if(i&f.IncludeAnonymous||!c.type.isAnonymous||A(c)){let l;if(!(i&f.IgnoreMounts)&&c.props&&(l=c.prop(s.mounted))&&!l.overlay)return new b(l.tree,h,e,o);let a=new b(c,h,e,o);return i&f.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?c.children.length-1:0,t,n,r)}}if(i&f.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let r;if(!(n&f.IgnoreOverlays)&&(r=this._tree.prop(s.mounted))&&r.overlay){let n=e-this.from;for(let{from:e,to:i}of r.overlay)if((t>0?e<=n:e<n)&&(t<0?i>=n:i>n))return new b(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new C(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return v(this,e,t,!1)}resolveInner(e,t=0){return v(this,e,t,!0)}enterUnfinishedNodesBefore(e){return y(this,e)}getChild(e,t=null,n=null){let r=w(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return w(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return x(this,e)}}function w(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(null!=n)for(;!i.type.is(n);)if(!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}function x(e,t,n=t.length-1){for(let r=e.parent;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class k{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class S{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new S(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&f.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new S(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new S(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new S(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new C(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let o=n.buffer[this.index+1];e.push(n.slice(r,i,o)),t.push(0)}return new d(this.type,e,t,this.to-this.from)}resolve(e,t=0){return v(this,e,t,!1)}resolveInner(e,t=0){return v(this,e,t,!0)}enterUnfinishedNodesBefore(e){return y(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let r=w(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return w(this,e,t,n)}get node(){return this}matchContext(e){return x(this,e)}}class C{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof b)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return!!e&&(e instanceof b?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&f.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&f.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&f.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&f.IncludeAnonymous||e instanceof m||!e.type.isAnonymous||A(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(let r=n;r<this.stack.length;r++)t=new S(this.buffer,t,this.stack[r]);return this.bufferNode=new S(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return x(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return x(this.node,e,r);let o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function A(e){return e.children.some((e=>e instanceof m||!e.type.isAnonymous||A(e)))}const E=new WeakMap;function M(e,t){if(!e.isAnonymous||t instanceof m||t.type!=e)return 1;let n=E.get(t);if(null==n){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof d)){n=1;break}n+=M(e,r)}E.set(t,n)}return n}function O(e,t,n,r,i,o,s,l,a){let c=0;for(let d=r;d<i;d++)c+=M(e,t[d]);let h=Math.ceil(1.5*c/8),u=[],f=[];return function t(n,r,i,s,l){for(let c=i;c<s;){let i=c,d=r[c],p=M(e,n[c]);for(c++;c<s;c++){let t=M(e,n[c]);if(p+t>=h)break;p+=t}if(c==i+1){if(p>h){let e=n[i];t(e.children,e.positions,0,e.children.length,r[i]+l);continue}u.push(n[i])}else{let t=r[c-1]+n[c-1].length-d;u.push(O(e,n,r,i,c,d,t,null,a))}f.push(d+l-o)}}(t,n,r,i,0),(l||a)(u,f,s)}class D{constructor(e,t,n,r,i=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let r=[new D(0,e.length,e,0,!1,n)];for(let i of t)i.to>e.length&&r.push(i);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],i=1,o=e.length?e[0]:null;for(let s=0,l=0,a=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-l>=n)for(;o&&o.from<h;){let t=o;if(l>=t.from||h<=t.to||a){let e=Math.max(t.from,l)-a,n=Math.min(t.to,h)-a;t=e>=n?null:new D(e,n,t.tree,t.offset+a,s>0,!!c)}if(t&&r.push(t),o.to>h)break;o=i<e.length?e[i++]:null}if(!c)break;l=c.toA,a=c.toA-c.toB}return r}}class I{startParse(e,t,n){return"string"==typeof e&&(e=new P(e)),n=n?n.length?n.map((e=>new o(e.from,e.to))):[new o(0,0)]:[new o(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}}class P{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new s({perNode:!0})}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return i[e](n,n.exports,s),n.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{s.r(l),s.d(l,{basicSetup:()=>h.X,default:()=>m,getStatistics:()=>f.a,minimalSetup:()=>h.w,useCodeMirror:()=>r.U});var e=s(215),t=s(808),n=s(787),r=s(128),i=s(501),o=s(105),a={};for(const s in o)"default"!==s&&(a[s]=()=>o[s]);s.d(l,a);var c=s(242);a={};for(const s in c)"default"!==s&&(a[s]=()=>c[s]);s.d(l,a);var h=s(141),u=s(736);a={};for(const s in u)["default","basicSetup","minimalSetup","useCodeMirror"].indexOf(s)<0&&(a[s]=()=>u[s]);s.d(l,a);var f=s(742),d=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],p=(0,n.forwardRef)((function(o,s){var l=o.className,a=o.value,c=void 0===a?"":a,h=o.selection,u=o.extensions,f=void 0===u?[]:u,p=o.onChange,m=o.onStatistics,g=o.onCreateEditor,y=o.onUpdate,v=o.autoFocus,b=o.theme,w=void 0===b?"light":b,x=o.height,k=o.minHeight,S=o.maxHeight,C=o.width,A=o.minWidth,E=o.maxWidth,M=o.basicSetup,O=o.placeholder,D=o.indentWithTab,I=o.editable,P=o.readOnly,T=o.root,B=o.initialState,N=(0,t.Z)(o,d),R=(0,n.useRef)(null),L=(0,r.U)({container:R.current,root:T,value:c,autoFocus:v,theme:w,height:x,minHeight:k,maxHeight:S,width:C,minWidth:A,maxWidth:E,basicSetup:M,placeholder:O,indentWithTab:D,editable:I,readOnly:P,selection:h,onChange:p,onStatistics:m,onCreateEditor:g,onUpdate:y,extensions:f,initialState:B}),_=L.state,q=L.view,F=L.container;if((0,n.useImperativeHandle)(s,(function(){return{editor:R.current,state:_,view:q}}),[R,F,_,q]),"string"!==typeof c)throw new Error("value must be typeof string but got ".concat(typeof c));var j="string"===typeof w?"cm-theme-".concat(w):"cm-theme";return(0,i.jsx)("div",(0,e.Z)({ref:R,className:"".concat(j).concat(l?" ".concat(l):"")},N))}));p.displayName="CodeMirror";const m=p})(),l})()));
2
+ !function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,],t):"object"===typeof exports?exports["@uiw/codemirror"]=t(require("react"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):e["@uiw/codemirror"]=t(e.React,e.CM["@codemirror/state"],e.CM["@codemirror/theme-one-dark"],e.CM["@codemirror/view"])}(self,((e,t,n,r)=>(()=>{"use strict";var i={736:(e,t,n)=>{n.r(t),n.d(t,{defaultLightThemeOption:()=>a.d,getDefaultExtensions:()=>h});var r=n(79),i=n(141),o=n(105),s=n(362),l=n(242),a=n(259),c={};for(const u in s)["default","getDefaultExtensions"].indexOf(u)<0&&(c[u]=()=>s[u]);n.d(t,c);var h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.indentWithTab,n=void 0===t||t,c=e.editable,h=void 0===c||c,u=e.readOnly,f=void 0!==u&&u,d=e.theme,p=void 0===d?"light":d,m=e.placeholder,g=void 0===m?"":m,y=e.basicSetup,v=void 0===y||y,b=[];switch(n&&b.unshift(o.keymap.of([r.oc])),v&&("boolean"===typeof v?b.unshift((0,i.X)()):b.unshift((0,i.X)(v))),g&&b.unshift((0,o.placeholder)(g)),p){case"light":b.push(a.d);break;case"dark":b.push(s.oneDark);break;case"none":break;default:b.push(p)}return!1===h&&b.push(o.EditorView.editable.of(!1)),f&&b.push(l.EditorState.readOnly.of(!0)),[].concat(b)}},259:(e,t,n)=>{n.d(t,{d:()=>i});var r=n(105),i=r.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1})},128:(e,t,n)=>{function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function i(e,t){if(e){if("string"===typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}function o(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||i(e)||function(){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 s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,s,l=[],a=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;a=!1}else for(;!(a=(r=o.call(n)).done)&&(l.push(r.value),l.length!==t);a=!0);}catch(e){c=!0,i=e}finally{try{if(!a&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return l}}(e,t)||i(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}n.d(t,{U:()=>p});var l=n(787),a=n(242),c=n(105),h=n(736),u=n(742),f=a.Annotation.define(),d=[];function p(e){var t=e.value,n=e.selection,r=e.onChange,i=e.onStatistics,p=e.onCreateEditor,m=e.onUpdate,g=e.extensions,y=void 0===g?d:g,v=e.autoFocus,b=e.theme,w=void 0===b?"light":b,x=e.height,k=void 0===x?null:x,S=e.minHeight,C=void 0===S?null:S,A=e.maxHeight,E=void 0===A?null:A,M=e.width,O=void 0===M?null:M,D=e.minWidth,I=void 0===D?null:D,P=e.maxWidth,T=void 0===P?null:P,B=e.placeholder,R=void 0===B?"":B,N=e.editable,L=void 0===N||N,_=e.readOnly,q=void 0!==_&&_,F=e.indentWithTab,j=void 0===F||F,V=e.basicSetup,W=void 0===V||V,z=e.root,U=e.initialState,$=s((0,l.useState)(),2),H=$[0],J=$[1],K=s((0,l.useState)(),2),G=K[0],Q=K[1],Z=s((0,l.useState)(),2),X=Z[0],Y=Z[1],ee=c.EditorView.theme({"&":{height:k,minHeight:C,maxHeight:E,width:O,minWidth:I,maxWidth:T},"& .cm-scroller":{height:"100% !important"}}),te=c.EditorView.updateListener.of((function(e){if(e.docChanged&&"function"===typeof r&&!e.transactions.some((function(e){return e.annotation(f)}))){var t=e.state.doc.toString();r(t,e)}i&&i((0,u.a)(e))})),ne=(0,h.getDefaultExtensions)({theme:w,editable:L,readOnly:q,placeholder:R,indentWithTab:j,basicSetup:W}),re=[te,ee].concat(o(ne));return m&&"function"===typeof m&&re.push(c.EditorView.updateListener.of(m)),re=re.concat(y),(0,l.useEffect)((function(){if(H&&!X){var e={doc:t,selection:n,extensions:re},r=U?a.EditorState.fromJSON(U.json,e,U.fields):a.EditorState.create(e);if(Y(r),!G){var i=new c.EditorView({state:r,parent:H,root:z});Q(i),p&&p(i,r)}}return function(){G&&(Y(void 0),Q(void 0))}}),[H,X]),(0,l.useEffect)((function(){return J(e.container)}),[e.container]),(0,l.useEffect)((function(){return function(){G&&(G.destroy(),Q(void 0))}}),[G]),(0,l.useEffect)((function(){v&&G&&G.focus()}),[v,G]),(0,l.useEffect)((function(){G&&G.dispatch({effects:a.StateEffect.reconfigure.of(re)})}),[w,y,k,C,E,O,I,T,R,L,q,j,W,r,m]),(0,l.useEffect)((function(){if(void 0!==t){var e=G?G.state.doc.toString():"";G&&t!==e&&G.dispatch({changes:{from:0,to:e.length,insert:t||""},annotations:[f.of(!0)]})}}),[t,G]),{state:X,setState:Y,view:G,setView:Q,container:H,setContainer:J}}},742:(e,t,n)=>{n.d(t,{a:()=>r});var r=function(e){return{line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map((function(t){return e.state.sliceDoc(t.from,t.to)})),selectedText:e.state.selection.ranges.some((function(e){return!e.empty}))}}},141:(e,t,n)=>{n.d(t,{X:()=>Nt,w:()=>Lt});var r=n(105),i=n(242),o=n(79);function s(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];"string"==typeof i?e.setAttribute(r,i):null!=i&&(e[r]=i)}t++}for(;t<arguments.length;t++)l(e,arguments[t]);return e}function l(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)l(e,t[n])}}const a="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class c{constructor(e,t,n=0,r=e.length,i,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(a(e)):a,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return(0,i.codePointAt)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=(0,i.fromCodePoint)(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,i.codePointSize)(e);let r=this.normalize(t);for(let i=0,o=n;;i++){let e=r.charCodeAt(i),s=this.match(e,o);if(i==r.length-1){if(s)return this.value=s,this;break}o==n&&i<t.length&&t.charCodeAt(i)==e&&o++}}}match(e,t){let n=null;for(let r=0;r<this.matches.length;r+=2){let i=this.matches[r],o=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?n={from:this.matches[r+1],to:t+1}:(this.matches[r]++,o=!0)),o||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?n={from:t,to:t+1}:this.matches.push(1,t)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}"undefined"!=typeof Symbol&&(c.prototype[Symbol.iterator]=function(){return this});const h={from:-1,to:-1,match:/.*/.exec("")},u="gm"+(null==/x/.unicode?"":"u");class f{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=h,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new m(e,t,n,r,i);this.re=new RegExp(t,u+((null===n||void 0===n?void 0:n.ignoreCase)?"i":"")),this.test=null===n||void 0===n?void 0:n.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=g(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=g(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const d=new WeakMap;class p{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=d.get(e);if(!r||r.from>=n||r.to<=t){let r=new p(t,e.sliceString(t,n));return d.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:i,from:o}=r;return o>t&&(i=e.sliceString(t,o)+i,o=t),r.to<n&&(i+=e.sliceString(r.to,n)),d.set(e,new p(o,i)),new p(t,i.slice(t-o,n-o))}}class m{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=h,this.matchPos=g(e,r),this.re=new RegExp(t,u+((null===n||void 0===n?void 0:n.ignoreCase)?"i":"")),this.test=null===n||void 0===n?void 0:n.test,this.flat=p.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=g(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=p.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function g(e,t){if(t>=e.length)return t;let n,r=e.lineAt(t);for(;t<r.to&&(n=r.text.charCodeAt(t-r.from))>=56320&&n<57344;)t++;return t}function y(e){let t=s("input",{class:"cm-textfield",name:"line",value:String(e.state.doc.lineAt(e.state.selection.main.head).number)});function n(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!n)return;let{state:o}=e,s=o.doc.lineAt(o.selection.main.head),[,l,a,c,h]=n,u=c?+c.slice(1):0,f=a?+a:s.number;if(a&&h){let e=f/100;l&&(e=e*("-"==l?-1:1)+s.number/o.doc.lines),f=Math.round(o.doc.lines*e)}else a&&l&&(f=f*("-"==l?-1:1)+s.number);let d=o.doc.line(Math.max(1,Math.min(o.doc.lines,f))),p=i.EditorSelection.cursor(d.from+Math.max(0,Math.min(u,d.length)));e.dispatch({effects:[v.of(!1),r.EditorView.scrollIntoView(p.from,{y:"center"})],selection:p}),e.focus()}return{dom:s("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:v.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),n())},onsubmit:e=>{e.preventDefault(),n()}},s("label",e.state.phrase("Go to line"),": ",t)," ",s("button",{class:"cm-button",type:"submit"},e.state.phrase("go")))}}"undefined"!=typeof Symbol&&(f.prototype[Symbol.iterator]=m.prototype[Symbol.iterator]=function(){return this});const v=i.StateEffect.define(),b=i.StateField.define({create:()=>!0,update(e,t){for(let n of t.effects)n.is(v)&&(e=n.value);return e},provide:e=>r.showPanel.from(e,(e=>e?y:null))}),w=r.EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),x={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},k=i.Facet.define({combine:e=>(0,i.combineConfig)(e,x,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const S=r.Decoration.mark({class:"cm-selectionMatch"}),C=r.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function A(e,t,n,r){return(0==n||e(t.sliceDoc(n-1,n))!=i.CharCategory.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=i.CharCategory.Word)}const E=r.ViewPlugin.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(k),{state:n}=e,o=n.selection;if(o.ranges.length>1)return r.Decoration.none;let s,l=o.main,a=null;if(l.empty){if(!t.highlightWordAroundCursor)return r.Decoration.none;let e=n.wordAt(l.head);if(!e)return r.Decoration.none;a=n.charCategorizer(l.head),s=n.sliceDoc(e.from,e.to)}else{let e=l.to-l.from;if(e<t.minSelectionLength||e>200)return r.Decoration.none;if(t.wholeWords){if(s=n.sliceDoc(l.from,l.to),a=n.charCategorizer(l.head),!A(a,n,l.from,l.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==i.CharCategory.Word&&e(t.sliceDoc(r-1,r))==i.CharCategory.Word}(a,n,l.from,l.to))return r.Decoration.none}else if(s=n.sliceDoc(l.from,l.to).trim(),!s)return r.Decoration.none}let h=[];for(let i of e.visibleRanges){let e=new c(n.doc,s,i.from,i.to);for(;!e.next().done;){let{from:i,to:o}=e.value;if((!a||A(a,n,i,o))&&(l.empty&&i<=l.from&&o>=l.to?h.push(C.range(i,o)):(i>=l.to||o<=l.from)&&h.push(S.range(i,o)),h.length>t.maxMatches))return r.Decoration.none}}return r.Decoration.set(h)}},{decorations:e=>e.decorations}),M=r.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const O=i.Facet.define({combine:e=>(0,i.combineConfig)(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new re(e),scrollToMatch:e=>r.EditorView.scrollIntoView(e)})});class D{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,u),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,((e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\"))}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new L(this):new T(this)}getCursor(e,t=0,n){let r=e.doc?e:i.EditorState.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?B(this,r,t,n):P(this,r,t,n)}}class I{constructor(e){this.spec=e}}function P(e,t,n,r){return new c(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(o=t.doc,s=t.charCategorizer(t.selection.main.head),(e,t,n,r)=>((r>e||r+n.length<t)&&(r=Math.max(0,e-2),n=o.sliceString(r,Math.min(o.length,t+2))),(s(R(n,e-r))!=i.CharCategory.Word||s(N(n,e-r))!=i.CharCategory.Word)&&(s(N(n,t-r))!=i.CharCategory.Word||s(R(n,t-r))!=i.CharCategory.Word))):void 0);var o,s}class T extends I{constructor(e){super(e)}nextMatch(e,t,n){let r=P(this.spec,e,n,e.doc.length).nextOverlapping();return r.done&&(r=P(this.spec,e,0,t).nextOverlapping()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=P(this.spec,e,n,r),o=null;for(;!i.nextOverlapping().done;)o=i.value;if(o)return o;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=P(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=P(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function B(e,t,n,r){return new f(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(o=t.charCategorizer(t.selection.main.head),(e,t,n)=>!n[0].length||(o(R(n.input,n.index))!=i.CharCategory.Word||o(N(n.input,n.index))!=i.CharCategory.Word)&&(o(N(n.input,n.index+n[0].length))!=i.CharCategory.Word||o(R(n.input,n.index+n[0].length))!=i.CharCategory.Word)):void 0},n,r);var o}function R(e,t){return e.slice((0,i.findClusterBreak)(e,t,!1),t)}function N(e,t){return e.slice(t,(0,i.findClusterBreak)(e,t))}class L extends I{nextMatch(e,t,n){let r=B(this.spec,e,n,e.doc.length).next();return r.done&&(r=B(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-1e4*r),o=B(this.spec,e,i,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==t||s.from>i+10))return s;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,((t,n)=>"$"==n?"$":"&"==n?e.match[0]:"0"!=n&&+n<e.match.length?e.match[n]:t)))}matchAll(e,t){let n=B(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=B(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const _=i.StateEffect.define(),q=i.StateEffect.define(),F=i.StateField.define({create:e=>new j(Z(e).create(),null),update(e,t){for(let n of t.effects)n.is(_)?e=new j(n.value.create(),e.panel):n.is(q)&&(e=new j(e.query,n.value?Q:null));return e},provide:e=>r.showPanel.from(e,(e=>e.panel))});class j{constructor(e,t){this.query=e,this.panel=t}}const V=r.Decoration.mark({class:"cm-searchMatch"}),W=r.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),z=r.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(F))}update(e){let t=e.state.field(F);(t!=e.startState.field(F)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return r.Decoration.none;let{view:n}=this,o=new i.RangeSetBuilder;for(let r=0,i=n.visibleRanges,s=i.length;r<s;r++){let{from:t,to:l}=i[r];for(;r<s-1&&l>i[r+1].from-500;)l=i[++r].to;e.highlight(n.state,t,l,((e,t)=>{let r=n.state.selection.ranges.some((n=>n.from==e&&n.to==t));o.add(e,t,r?W:V)}))}return o.finish()}},{decorations:e=>e.decorations});function U(e){return t=>{let n=t.state.field(F,!1);return n&&n.query.spec.valid?e(t,n):ee(t)}}const $=U(((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let o=i.EditorSelection.single(r.from,r.to),s=e.state.facet(O);return e.dispatch({selection:o,effects:[le(e,r),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),Y(e),!0})),H=U(((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,o=t.prevMatch(n,r,r);if(!o)return!1;let s=i.EditorSelection.single(o.from,o.to),l=e.state.facet(O);return e.dispatch({selection:s,effects:[le(e,o),l.scrollToMatch(s.main,e)],userEvent:"select.search"}),Y(e),!0})),J=U(((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:i.EditorSelection.create(n.map((e=>i.EditorSelection.range(e.from,e.to)))),userEvent:"select.search.matches"}),!0)})),K=U(((e,{query:t})=>{let{state:n}=e,{from:o,to:s}=n.selection.main;if(n.readOnly)return!1;let l=t.nextMatch(n,o,o);if(!l)return!1;let a,c,h=[],u=[];if(l.from==o&&l.to==s&&(c=n.toText(t.getReplacement(l)),h.push({from:l.from,to:l.to,insert:c}),l=t.nextMatch(n,l.from,l.to),u.push(r.EditorView.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(o).number)+"."))),l){let t=0==h.length||h[0].from>=l.to?0:l.to-l.from-c.length;a=i.EditorSelection.single(l.from-t,l.to-t),u.push(le(e,l)),u.push(n.facet(O).scrollToMatch(a.main,e))}return e.dispatch({changes:h,selection:a,effects:u,userEvent:"input.replace"}),!0})),G=U(((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map((e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}}));if(!n.length)return!1;let i=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:r.EditorView.announce.of(i),userEvent:"input.replace.all"}),!0}));function Q(e){return e.state.facet(O).createPanel(e)}function Z(e,t){var n,r,i,o,s;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let c=e.facet(O);return new D({search:(null!==(n=null===t||void 0===t?void 0:t.literal)&&void 0!==n?n:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(r=null===t||void 0===t?void 0:t.caseSensitive)&&void 0!==r?r:c.caseSensitive,literal:null!==(i=null===t||void 0===t?void 0:t.literal)&&void 0!==i?i:c.literal,regexp:null!==(o=null===t||void 0===t?void 0:t.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(s=null===t||void 0===t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function X(e){let t=(0,r.getPanel)(e,Q);return t&&t.dom.querySelector("[main-field]")}function Y(e){let t=X(e);t&&t==e.root.activeElement&&t.select()}const ee=e=>{let t=e.state.field(F,!1);if(t&&t.panel){let n=X(e);if(n&&n!=e.root.activeElement){let r=Z(e.state,t.query.spec);r.valid&&e.dispatch({effects:_.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[q.of(!0),t?_.of(Z(e.state,t.query.spec)):i.StateEffect.appendConfig.of(ce)]});return!0},te=e=>{let t=e.state.field(F,!1);if(!t||!t.panel)return!1;let n=(0,r.getPanel)(e,Q);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:q.of(!1)}),!0},ne=[{key:"Mod-f",run:ee,scope:"editor search-panel"},{key:"F3",run:$,shift:H,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:$,shift:H,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:te,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:o}=n.main,s=[],l=0;for(let a=new c(e.doc,e.sliceDoc(r,o));!a.next().done;){if(s.length>1e3)return!1;a.value.from==r&&(l=s.length),s.push(i.EditorSelection.range(a.value.from,a.value.to))}return t(e.update({selection:i.EditorSelection.create(s,l),userEvent:"select.search.matches"})),!0}},{key:"Alt-g",run:e=>{let t=(0,r.getPanel)(e,y);if(!t){let n=[v.of(!0)];null==e.state.field(b,!1)&&n.push(i.StateEffect.appendConfig.of([b,w])),e.dispatch({effects:n}),t=(0,r.getPanel)(e,y)}return t&&t.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((e=>e.from===e.to)))return(({state:e,dispatch:t})=>{let{selection:n}=e,r=i.EditorSelection.create(n.ranges.map((t=>e.wordAt(t.head)||i.EditorSelection.cursor(t.head))),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let o=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=o)))return!1;let s=function(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),o=i&&i.from==n.from&&i.to==n.to;for(let s=!1,l=new c(e.doc,t,r[r.length-1].to);;){if(l.next(),!l.done){if(s&&r.some((e=>e.from==l.value.from)))continue;if(o){let t=e.wordAt(l.value.from);if(!t||t.from!=l.value.from||t.to!=l.value.to)continue}return l.value}if(s)return null;l=new c(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}}(e,o);return!!s&&(t(e.update({selection:e.selection.addRange(i.EditorSelection.range(s.from,s.to),!1),effects:r.EditorView.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class re{constructor(e){this.view=e;let t=this.query=e.state.field(F).query.spec;function n(e,t,n){return s("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=s("input",{value:t.search,placeholder:ie(e,"Find"),"aria-label":ie(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=s("input",{value:t.replace,placeholder:ie(e,"Replace"),"aria-label":ie(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=s("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=s("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=s("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=s("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",(()=>$(e)),[ie(e,"next")]),n("prev",(()=>H(e)),[ie(e,"previous")]),n("select",(()=>J(e)),[ie(e,"all")]),s("label",null,[this.caseField,ie(e,"match case")]),s("label",null,[this.reField,ie(e,"regexp")]),s("label",null,[this.wordField,ie(e,"by word")]),...e.state.readOnly?[]:[s("br"),this.replaceField,n("replace",(()=>K(e)),[ie(e,"replace")]),n("replaceAll",(()=>G(e)),[ie(e,"replace all")])],s("button",{name:"close",onclick:()=>te(e),"aria-label":ie(e,"close"),type:"button"},["\xd7"])])}commit(){let e=new D({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:_.of(e)}))}keydown(e){(0,r.runScopeHandlers)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?H:$)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),K(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(_)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(O).top}}function ie(e,t){return e.state.phrase(t)}const oe=30,se=/[\s\.,:;?!]/;function le(e,{from:t,to:n}){let i=e.state.doc.lineAt(t),o=e.state.doc.lineAt(n).to,s=Math.max(i.from,t-oe),l=Math.min(o,n+oe),a=e.state.sliceDoc(s,l);if(s!=i.from)for(let r=0;r<oe;r++)if(!se.test(a[r+1])&&se.test(a[r])){a=a.slice(r);break}if(l!=o)for(let r=a.length-1;r>a.length-oe;r--)if(!se.test(a[r-1])&&se.test(a[r])){a=a.slice(0,r);break}return r.EditorView.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${i.number}.`)}const ae=r.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"}}),ce=[F,i.Prec.low(z),ae];var he=n(434);class ue{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=(0,he.qz)(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(ge(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(e,t){"abort"==e&&this.abortListeners&&this.abortListeners.push(t)}}function fe(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function de(e){let t=e.map((e=>"string"==typeof e?{label:e}:e)),[n,r]=t.every((e=>/^\w+$/.test(e.label)))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let e=1;e<i.length;e++)n[i[e]]=!0}let r=fe(t)+fe(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}class pe{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}}function me(e){return e.selection.main.from}function ge(e,t){var n;let{source:r}=e,i=t&&"^"!=r[0],o="$"!=r[r.length-1];return i||o?new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const ye=i.Annotation.define();const ve=new WeakMap;function be(e){if(!Array.isArray(e))return e;let t=ve.get(e);return t||ve.set(e,t=de(e)),t}const we=i.StateEffect.define(),xe=i.StateEffect.define();class ke{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=(0,i.codePointAt)(e,t),r=(0,i.codePointSize)(n);this.chars.push(n);let o=e.slice(t,t+r),s=o.toUpperCase();this.folded.push((0,i.codePointAt)(s==o?o.toLowerCase():s,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,!0}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return!1;let{chars:t,folded:n,any:r,precise:o,byWord:s}=this;if(1==t.length){let r=(0,i.codePointAt)(e,0),o=(0,i.codePointSize)(r),s=o==e.length?0:-100;if(r==t[0]);else{if(r!=n[0])return!1;s+=-200}return this.ret(s,[0,o])}let l=e.indexOf(this.pattern);if(0==l)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,c=0;if(l<0){for(let o=0,s=Math.min(e.length,200);o<s&&c<a;){let s=(0,i.codePointAt)(e,o);s!=t[c]&&s!=n[c]||(r[c++]=o),o+=(0,i.codePointSize)(s)}if(c<a)return!1}let h=0,u=0,f=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),y=!0;for(let v=0,b=Math.min(e.length,200),w=0;v<b&&u<a;){let r=(0,i.codePointAt)(e,v);l<0&&(h<a&&r==t[h]&&(o[h++]=v),d<a&&(r==t[d]||r==n[d]?(0==d&&(p=v),m=v+1,d++):d=0));let c,b=r<255?r>=48&&r<=57||r>=97&&r<=122?2:r>=65&&r<=90?1:0:(c=(0,i.fromCodePoint)(r))!=c.toLowerCase()?1:c!=c.toUpperCase()?2:0;(!v||1==b&&g||0==w&&0!=b)&&(t[u]==r||n[u]==r&&(f=!0)?s[u++]=v:s.length&&(y=!1)),w=b,v+=(0,i.codePointSize)(r)}return u==a&&0==s[0]&&y?this.result((f?-200:0)-100,s,e):d==a&&0==p?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,m]):u==a?this.result((f?-200:0)-100-700+(y?0:-1100),s,e):2!=t.length&&this.result((r[0]?-700:0)-200-1100,r,e)}result(e,t,n){let r=[],o=0;for(let s of t){let e=s+(this.astral?(0,i.codePointSize)((0,i.codePointAt)(n,s)):1);o&&r[o-1]==s?r[o-1]=e:(r[o++]=s,r[o++]=e)}return this.ret(e-n.length,r)}}const Se=i.Facet.define({combine:e=>(0,i.combineConfig)(e,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Ae,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>Ce(e(n),t(n)),optionClass:(e,t)=>n=>Ce(e(n),t(n)),addToOptions:(e,t)=>e.concat(t)})});function Ce(e,t){return e?t?e+" "+t:e:t}function Ae(e,t,n,i,o,s){let l,a,c=e.textDirection==r.Direction.RTL,h=c,u=!1,f="top",d=t.left-o.left,p=o.right-t.right,m=i.right-i.left,g=i.bottom-i.top;if(h&&d<Math.min(m,p)?h=!1:!h&&p<Math.min(m,d)&&(h=!0),m<=(h?d:p))l=Math.max(o.top,Math.min(n.top,o.bottom-g))-t.top,a=Math.min(400,h?d:p);else{u=!0,a=Math.min(400,(c?t.right:o.right-t.left)-30);let e=o.bottom-t.bottom;e>=g||e>t.top?l=n.bottom-t.top:(f="bottom",l=t.bottom-n.top)}return{style:`${f}: ${l/((t.bottom-t.top)/s.offsetHeight)}px; max-width: ${a/((t.right-t.left)/s.offsetWidth)}px`,class:"cm-completionInfo-"+(u?c?"left-narrow":"right-narrow":h?"left":"right")}}function Ee(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class Me{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:i,selected:o}=r.open,s=e.state.facet(Se);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map((e=>"cm-completionIcon-"+e))),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n){let r=document.createElement("span");r.className="cm-completionLabel";let i=e.displayLabel||e.label,o=0;for(let s=0;s<n.length;){let e=n[s++],t=n[s++];e>o&&r.appendChild(document.createTextNode(i.slice(o,e)));let l=r.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(i.slice(e,t))),l.className="cm-completionMatchedText",o=t}return o<i.length&&r.appendChild(document.createTextNode(i.slice(o))),r},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort(((e,t)=>e.position-t.position)).map((e=>e.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=Ee(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",(t=>{for(let n,r=t.target;r&&r!=this.dom;r=r.parentNode)if("LI"==r.nodeName&&(n=/-(\d+)$/.exec(r.id))&&+n[1]<i.length)return this.applyCompletion(e,i[+n[1]]),void t.preventDefault()})),this.dom.addEventListener("focusout",(t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(Se).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:xe.of(null)})})),this.list=this.dom.appendChild(this.createListBox(i,r.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}mount(){this.updateSel()}update(e){var t,n,r;let i=e.state.field(this.stateField),o=e.startState.field(this.stateField);this.updateTooltipClass(e.state),i!=o&&(this.updateSel(),(null===(t=i.open)||void 0===t?void 0:t.disabled)!=(null===(n=o.open)||void 0===n?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!(null===(r=i.open)||void 0===r?void 0:r.disabled)))}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Ee(t.options.length,t.selected,this.view.state.facet(Se).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:i}=n;if(!i)return;let o="string"===typeof i?document.createTextNode(i):i(n);if(!o)return;"then"in o?o.then((t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,n)})).catch((e=>(0,r.logException)(this.view.state,e,"completion info"))):this.addInfoPane(o,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)"LI"==n.nodeName&&n.id?r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected"):r--;return t&&function(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.defaultView||window;i={left:0,top:0,right:e.innerWidth,bottom:e.innerHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(Se).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions"));let i=null;for(let o=n.from;o<n.to;o++){let{completion:s,match:l}=e[o],{section:a}=s;if(a){let e="string"==typeof a?a:a.name;if(e!=i&&(o>n.from||0==n.from))if(i=e,"string"!=typeof a&&a.header)r.appendChild(a.header(a));else{r.appendChild(document.createElement("completion-section")).textContent=e}}const c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let h=this.optionClass(s);h&&(c.className=h);for(let e of this.optionContent){let t=e(s,this.view.state,l);t&&c.appendChild(t)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Oe(e,t){return n=>new Me(n,e,t)}function De(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class Ie{constructor(e,t,n,r,i,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ie(this.options,Be(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,i){let o=function(e,t){let n=[],r=null,i=e=>{n.push(e);let{section:t}=e.completion;if(t){r||(r=[]);let e="string"==typeof t?t:t.name;r.some((t=>t.name==e))||r.push("string"==typeof t?{name:e}:t)}};for(let a of e)if(a.hasResult()){let e=a.result.getMatch;if(!1===a.result.filter)for(let t of a.result.options)i(new pe(t,a.source,e?e(t):[],1e9-n.length));else{let n=new ke(t.sliceDoc(a.from,a.to));for(let t of a.result.options)if(n.match(t.label)){let r=t.displayLabel?e?e(t,n.matched):[]:n.matched;i(new pe(t,a.source,r,n.score+(t.boost||0)))}}}if(r){let e=Object.create(null),t=0,i=(e,t)=>{var n,r;return(null!==(n=e.rank)&&void 0!==n?n:1e9)-(null!==(r=t.rank)&&void 0!==r?r:1e9)||(e.name<t.name?-1:1)};for(let n of r.sort(i))t-=1e5,e[n.name]=t;for(let r of n){let{section:t}=r.completion;t&&(r.score+=e["string"==typeof t?t:t.name])}}let o=[],s=null,l=t.facet(Se).compareCompletions;for(let a of n.sort(((e,t)=>t.score-e.score||l(e.completion,t.completion)))){let e=a.completion;!s||s.label!=e.label||s.detail!=e.detail||null!=s.type&&null!=e.type&&s.type!=e.type||s.apply!=e.apply||s.boost!=e.boost?o.push(a):De(a.completion)>De(s)&&(o[o.length-1]=a),s=a.completion}return o}(e,t);if(!o.length)return r&&e.some((e=>1==e.state))?new Ie(r.options,r.attrs,r.tooltip,r.timestamp,r.selected,!0):null;let s=t.facet(Se).selectOnOpen?0:-1;if(r&&r.selected!=s&&-1!=r.selected){let e=r.options[r.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){s=t;break}}return new Ie(o,Be(n,s),{pos:e.reduce(((e,t)=>t.hasResult()?Math.min(e,t.from):e),1e8),create:Oe(je,Ve),above:i.aboveCursor},r?r.timestamp:Date.now(),s,!1)}map(e){return new Ie(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class Pe{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new Pe(Re,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(Se),r=(n.override||t.languageDataAt("autocomplete",me(t)).map(be)).map((t=>(this.active.find((e=>e.source==t))||new Le(t,this.active.some((e=>0!=e.state))?1:0)).update(e,n)));r.length==this.active.length&&r.every(((e,t)=>e==this.active[t]))&&(r=this.active);let i=this.open;i&&e.docChanged&&(i=i.map(e.changes)),e.selection||r.some((t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to)))||!function(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult;)n++;for(;r<t.length&&!t[r].hasResult;)r++;let i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}(r,this.active)?i=Ie.build(r,t,this.id,i,n):i&&i.disabled&&!r.some((e=>1==e.state))&&(i=null),!i&&r.every((e=>1!=e.state))&&r.some((e=>e.hasResult()))&&(r=r.map((e=>e.hasResult()?new Le(e.source,0):e)));for(let o of e.effects)o.is(Fe)&&(i=i&&i.setSelected(o.value,this.id));return r==this.active&&i==this.open?this:new Pe(r,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:Te}}const Te={"aria-autocomplete":"list"};function Be(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Re=[];function Ne(e){return e.isUserEvent("input.type")?"input":e.isUserEvent("delete.backward")?"delete":null}class Le{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=Ne(e),r=this;n?r=r.handleUserEvent(e,n,t):e.docChanged?r=r.handleChange(e):e.selection&&0!=r.state&&(r=new Le(r.source,0));for(let i of e.effects)if(i.is(we))r=new Le(r.source,1,i.value?me(e.state):-1);else if(i.is(xe))r=new Le(r.source,0);else if(i.is(qe))for(let e of i.value)e.source==r.source&&(r=e);return r}handleUserEvent(e,t,n){return"delete"!=t&&n.activateOnTyping?new Le(this.source,1):this.map(e.changes)}handleChange(e){return e.changes.touchesRange(me(e.startState))?new Le(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Le(this.source,this.state,e.mapPos(this.explicitPos))}}class _e extends Le{constructor(e,t,n,r,i){super(e,2,t),this.result=n,this.from=r,this.to=i}hasResult(){return!0}handleUserEvent(e,t,n){var r;let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=me(e.state);if((this.explicitPos<0?s<=i:s<this.from)||s>o||"delete"==t&&me(e.startState)==this.from)return new Le(this.source,"input"==t&&n.activateOnTyping?1:0);let l,a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return function(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return"function"==typeof e?e(i,n,r,t):ge(e,!0).test(i)}(this.result.validFor,e.state,i,o)?new _e(this.source,a,this.result,i,o):this.result.update&&(l=this.result.update(this.result,i,o,new ue(e.state,s,a>=0)))?new _e(this.source,a,l,l.from,null!==(r=l.to)&&void 0!==r?r:me(e.state)):new Le(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Le(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new _e(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}const qe=i.StateEffect.define({map:(e,t)=>e.map((e=>e.map(t)))}),Fe=i.StateEffect.define(),je=i.StateField.define({create:()=>Pe.start(),update:(e,t)=>e.update(t),provide:e=>[r.showTooltip.from(e,(e=>e.tooltip)),r.EditorView.contentAttributes.from(e,(e=>e.attrs))]});function Ve(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(je).active.find((e=>e.source==t.source));return r instanceof _e&&("string"==typeof n?e.dispatch(Object.assign(Object.assign({},function(e,t,n,r){let{main:o}=e.selection,s=n-o.from,l=r-o.from;return Object.assign(Object.assign({},e.changeByRange((a=>a!=o&&n!=r&&e.sliceDoc(a.from+s,a.from+l)!=e.sliceDoc(n,r)?{range:a}:{changes:{from:a.from+s,to:r==o.from?a.to:a.from+l,insert:t},range:i.EditorSelection.cursor(a.from+s+t.length)}))),{scrollIntoView:!0,userEvent:"input.complete"})}(e.state,n,r.from,r.to)),{annotations:ye.of(t.completion)})):n(e,t.completion,r.from,r.to),!0)}function We(e,t="option"){return n=>{let i=n.state.field(je,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(Se).interactionDelay)return!1;let o,s=1;"page"==t&&(o=(0,r.getTooltip)(n,i.open.tooltip))&&(s=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:l}=i.open.options,a=i.open.selected>-1?i.open.selected+s*(e?1:-1):e?0:l-1;return a<0?a="page"==t?0:l-1:a>=l&&(a="page"==t?l-1:0),n.dispatch({effects:Fe.of(a)}),!0}}class ze{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ue=r.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let t of e.state.field(je).active)1==t.state&&this.startQuery(t)}update(e){let t=e.state.field(je);if(!e.selectionSet&&!e.docChanged&&e.startState.field(je)==t)return;let n=e.transactions.some((e=>(e.selection||e.docChanged)&&!Ne(e)));for(let o=0;o<this.running.length;o++){let t=this.running[o];if(n||t.updates.length+e.transactions.length>50&&Date.now()-t.time>1e3){for(let e of t.context.abortListeners)try{e()}catch(i){(0,r.logException)(this.view.state,i)}t.context.abortListeners=null,this.running.splice(o--,1)}else t.updates.push(...e.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=t.active.some((e=>1==e.state&&!this.running.some((t=>t.active.source==e.source))))?setTimeout((()=>this.startUpdate()),50):-1,0!=this.composing)for(let r of e.transactions)"input"==Ne(r)?this.composing=2:2==this.composing&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:e}=this.view,t=e.field(je);for(let n of t.active)1!=n.state||this.running.some((e=>e.active.source==n.source))||this.startQuery(n)}startQuery(e){let{state:t}=this.view,n=me(t),i=new ue(t,n,e.explicitPos==n),o=new ze(e,i);this.running.push(o),Promise.resolve(e.source(i)).then((e=>{o.context.aborted||(o.done=e||null,this.scheduleAccept())}),(e=>{this.view.dispatch({effects:xe.of(null)}),(0,r.logException)(this.view.state,e)}))}scheduleAccept(){this.running.every((e=>void 0!==e.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),50))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Se);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(void 0===i.done)continue;if(this.running.splice(r--,1),i.done){let r=new _e(i.active.source,i.active.explicitPos,i.done,i.done.from,null!==(e=i.done.to)&&void 0!==e?e:me(i.updates.length?i.updates[0].startState:this.view.state));for(let e of i.updates)r=r.update(e,n);if(r.hasResult()){t.push(r);continue}}let o=this.view.state.field(je).active.find((e=>e.source==i.active.source));if(o&&1==o.state)if(null==i.done){let e=new Le(i.active.source,0);for(let t of i.updates)e=e.update(t,n);1!=e.state&&t.push(e)}else this.startQuery(o)}t.length&&this.view.dispatch({effects:qe.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(je,!1);if(t&&t.tooltip&&this.view.state.facet(Se).closeOnBlur){let n=t.open&&(0,r.getTooltip)(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||this.view.dispatch({effects:xe.of(null)})}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:we.of(!1)})),20),this.composing=0}}}),$e=r.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",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xb7\xb7\xb7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",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",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25cb'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25cc'"}},".cm-completionIcon-variable":{"&:after":{content:"'\ud835\udc65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\ud835\udc36'"}},".cm-completionIcon-type":{"&:after":{content:"'\ud835\udc61'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222a'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25a1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\ud83d\udd11\ufe0e'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25a2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});const He={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Je=i.StateEffect.define({map(e,t){let n=t.mapPos(e,-1,i.MapMode.TrackAfter);return null==n?void 0:n}}),Ke=new class extends i.RangeValue{};Ke.startSide=1,Ke.endSide=-1;const Ge=i.StateField.define({create:()=>i.RangeSet.empty,update(e,t){if(t.selection){let n=t.state.doc.lineAt(t.selection.main.head).from,r=t.startState.doc.lineAt(t.startState.selection.main.head).from;n!=t.changes.mapPos(r,-1)&&(e=i.RangeSet.empty)}e=e.map(t.changes);for(let n of t.effects)n.is(Je)&&(e=e.update({add:[Ke.range(n.value,n.value+1)]}));return e}});const Qe="()[]{}<>";function Ze(e){for(let t=0;t<Qe.length;t+=2)if(Qe.charCodeAt(t)==e)return Qe.charAt(t+1);return(0,i.fromCodePoint)(e<128?e:e+1)}function Xe(e,t){return e.languageDataAt("closeBrackets",t)[0]||He}const Ye="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),et=r.EditorView.inputHandler.of(((e,t,n,r)=>{if((Ye?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let o=e.state.selection.main;if(r.length>2||2==r.length&&1==(0,i.codePointSize)((0,i.codePointAt)(r,0))||t!=o.from||n!=o.to)return!1;let s=function(e,t){let n=Xe(e,e.selection.main.head),r=n.brackets||He.brackets;for(let o of r){let s=Ze((0,i.codePointAt)(o,0));if(t==o)return s==o?st(e,o,r.indexOf(o+o+o)>-1,n):it(e,o,s,n.before||He.before);if(t==s&&nt(e,e.selection.main.from))return ot(e,o,s)}return null}(e.state,r);return!!s&&(e.dispatch(s),!0)})),tt=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Xe(e,e.selection.main.head).brackets||He.brackets,r=null,o=e.changeByRange((t=>{if(t.empty){let r=function(e,t){let n=e.sliceString(t-2,t);return(0,i.codePointSize)((0,i.codePointAt)(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let o of n)if(o==r&&rt(e.doc,t.head)==Ze((0,i.codePointAt)(o,0)))return{changes:{from:t.head-o.length,to:t.head+o.length},range:i.EditorSelection.cursor(t.head-o.length)}}return{range:r=t}}));return r||t(e.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function nt(e,t){let n=!1;return e.field(Ge).between(0,e.doc.length,(e=>{e==t&&(n=!0)})),n}function rt(e,t){let n=e.sliceString(t,t+2);return n.slice(0,(0,i.codePointSize)((0,i.codePointAt)(n,0)))}function it(e,t,n,r){let o=null,s=e.changeByRange((s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:n,from:s.to}],effects:Je.of(s.to+t.length),range:i.EditorSelection.range(s.anchor+t.length,s.head+t.length)};let l=rt(e.doc,s.head);return!l||/\s/.test(l)||r.indexOf(l)>-1?{changes:{insert:t+n,from:s.head},effects:Je.of(s.head+t.length),range:i.EditorSelection.cursor(s.head+t.length)}:{range:o=s}}));return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ot(e,t,n){let r=null,o=e.changeByRange((t=>t.empty&&rt(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:i.EditorSelection.cursor(t.head+n.length)}:r={range:t}));return r?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function st(e,t,n,r){let o=r.stringPrefixes||He.stringPrefixes,s=null,l=e.changeByRange((r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:Je.of(r.to+t.length),range:i.EditorSelection.range(r.anchor+t.length,r.head+t.length)};let l,a=r.head,c=rt(e.doc,a);if(c==t){if(lt(e,a))return{changes:{insert:t+t,from:a},effects:Je.of(a+t.length),range:i.EditorSelection.cursor(a+t.length)};if(nt(e,a)){let r=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+r.length,insert:r},range:i.EditorSelection.cursor(a+r.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(l=at(e,a-2*t.length,o))>-1&&lt(e,l))return{changes:{insert:t+t+t+t,from:a},effects:Je.of(a+t.length),range:i.EditorSelection.cursor(a+t.length)};if(e.charCategorizer(a)(c)!=i.CharCategory.Word&&at(e,a,o)>-1&&!function(e,t,n,r){let i=(0,he.qz)(e).resolveInner(t,-1),o=r.reduce(((e,t)=>Math.max(e,t.length)),0);for(let s=0;s<5;s++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+o)),l=s.indexOf(n);if(!l||l>-1&&r.indexOf(s.slice(0,l))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+l;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let a=i.to==t&&i.parent;if(!a)break;i=a}return!1}(e,a,t,o))return{changes:{insert:t+t,from:a},effects:Je.of(a+t.length),range:i.EditorSelection.cursor(a+t.length)}}return{range:s=r}}));return s?null:e.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function lt(e,t){let n=(0,he.qz)(e).resolveInner(t+1);return n.parent&&n.from==t}function at(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=i.CharCategory.Word)return t;for(let o of n){let n=t-o.length;if(e.sliceDoc(n,t)==o&&r(e.sliceDoc(n-1,n))!=i.CharCategory.Word)return n}return-1}const ct=[{key:"Ctrl-Space",run:e=>!!e.state.field(je,!1)&&(e.dispatch({effects:we.of(!0)}),!0)},{key:"Escape",run:e=>{let t=e.state.field(je,!1);return!(!t||!t.active.some((e=>0!=e.state)))&&(e.dispatch({effects:xe.of(null)}),!0)}},{key:"ArrowDown",run:We(!0)},{key:"ArrowUp",run:We(!1)},{key:"PageDown",run:We(!0,"page")},{key:"PageUp",run:We(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(je,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Se).interactionDelay)&&Ve(e,t.open.options[t.open.selected])}}],ht=i.Prec.highest(r.keymap.computeN([Se],(e=>e.facet(Se).defaultKeymap?[ct]:[])));class ut{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class ft{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let i=e,o=n.facet(At).markerFilter;o&&(i=o(i));let s=r.Decoration.set(i.map((e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from?r.Decoration.widget({widget:new Ot(e),diagnostic:e}).range(e.from):r.Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+e.severity+(e.markClass?" "+e.markClass:"")},diagnostic:e}).range(e.from,e.to))),!0);return new ft(s,t,dt(s))}}function dt(e,t=null,n=0){let r=null;return e.between(n,1e9,((e,n,{spec:i})=>{if(!t||i.diagnostic==t)return r=new ut(e,n,i.diagnostic),!1})),r}function pt(e,t){let n=e.startState.doc.lineAt(t.pos);return!(!e.effects.some((e=>e.is(gt)))&&!e.changes.touchesRange(n.from,n.to))}function mt(e,t){return e.field(bt,!1)?t:t.concat(i.StateEffect.appendConfig.of(Rt))}const gt=i.StateEffect.define(),yt=i.StateEffect.define(),vt=i.StateEffect.define(),bt=i.StateField.define({create:()=>new ft(r.Decoration.none,null,null),update(e,t){if(t.docChanged){let n=e.diagnostics.map(t.changes),r=null;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=dt(n,e.selected.diagnostic,i)||dt(n,null,i)}e=new ft(n,e.panel,r)}for(let n of t.effects)n.is(gt)?e=ft.init(n.value,e.panel,t.state):n.is(yt)?e=new ft(e.diagnostics,n.value?It.open:null,e.selected):n.is(vt)&&(e=new ft(e.diagnostics,e.panel,n.value));return e},provide:e=>[r.showPanel.from(e,(e=>e.panel)),r.EditorView.decorations.from(e,(e=>e.diagnostics))]});const wt=r.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function xt(e,t,n){let{diagnostics:r}=e.state.field(bt),i=[],o=2e8,s=0;r.between(t-(n<0?1:0),t+(n>0?1:0),((e,r,{spec:l})=>{t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0))&&(i.push(l.diagnostic),o=Math.min(e,o),s=Math.max(r,s))}));let l=e.state.facet(At).tooltipFilter;return l&&(i=l(i)),i.length?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:kt(e,i)})}:null}function kt(e,t){return s("ul",{class:"cm-tooltip-lint"},t.map((t=>Mt(e,t,!1))))}const St=e=>{let t=e.state.field(bt,!1);return!(!t||!t.panel)&&(e.dispatch({effects:yt.of(!1)}),!0)},Ct=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(bt,!1);t&&t.panel||e.dispatch({effects:mt(e.state,[yt.of(!0)])});let n=(0,r.getPanel)(e,It.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(bt,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!(!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],At=i.Facet.define({combine:e=>Object.assign({sources:e.map((e=>e.source))},(0,i.combineConfig)(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))});function Et(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some((e=>e.toLowerCase()==r.toLowerCase()))){t.push(r);continue e}}t.push("")}return t}function Mt(e,t,n){var r;let i=n?Et(t.actions):[];return s("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},s("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage():t.message),null===(r=t.actions)||void 0===r?void 0:r.map(((n,r)=>{let o=!1,l=r=>{if(r.preventDefault(),o)return;o=!0;let i=dt(e.state.field(bt).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:a}=n,c=i[r]?a.indexOf(i[r]):-1,h=c<0?a:[a.slice(0,c),s("u",a.slice(c,c+1)),a.slice(c+1)];return s("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${a}${c<0?"":` (access key "${i[r]})"`}.`},h)})),t.source&&s("div",{class:"cm-diagnosticSource"},t.source))}class Ot extends r.WidgetType{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return s("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Dt{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=Mt(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class It{constructor(e){this.view=e,this.items=[];this.list=s("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)St(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],r=Et(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=dt(this.view.state.field(bt).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=s("div",{class:"cm-panel-lint"},this.list,s("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>St(this.view)},"\xd7")),this.update()}get selectedIndex(){let e=this.view.state.field(bt).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(bt),n=0,r=!1,i=null;for(e.between(0,this.view.state.doc.length,((e,o,{spec:s})=>{let l,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==s.diagnostic){a=t;break}a<0?(l=new Dt(this.view,s.diagnostic),this.items.splice(n,0,l),r=!0):(l=this.items[a],a>n&&(this.items.splice(n,a-n),r=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),i=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}));n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();0==this.items.length&&(this.items.push(new Dt(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=dt(this.view.state.field(bt).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:vt.of(t)})}static open(e){return new It(e)}}function Pt(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Tt(e){return Pt(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Bt=r.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-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Tt("#d11")},".cm-lintRange-warning":{backgroundImage:Tt("orange")},".cm-lintRange-info":{backgroundImage:Tt("#999")},".cm-lintRange-hint":{backgroundImage:Tt("#66d")},".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-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".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}}});r.GutterMarker;const Rt=[bt,r.EditorView.decorations.compute([bt],(e=>{let{selected:t,panel:n}=e.field(bt);return t&&n&&t.from!=t.to?r.Decoration.set([wt.range(t.from,t.to)]):r.Decoration.none})),(0,r.hoverTooltip)(xt,{hideOn:pt}),Bt];var Nt=function(e){void 0===e&&(e={});var{crosshairCursor:t=!1}=e,n=[];!1!==e.closeBracketsKeymap&&(n=n.concat(tt)),!1!==e.defaultKeymap&&(n=n.concat(o.wQ)),!1!==e.searchKeymap&&(n=n.concat(ne)),!1!==e.historyKeymap&&(n=n.concat(o.f$)),!1!==e.foldKeymap&&(n=n.concat(he.e7)),!1!==e.completionKeymap&&(n=n.concat(ct)),!1!==e.lintKeymap&&(n=n.concat(Ct));var s=[];return!1!==e.lineNumbers&&s.push((0,r.lineNumbers)()),!1!==e.highlightActiveLineGutter&&s.push((0,r.highlightActiveLineGutter)()),!1!==e.highlightSpecialChars&&s.push((0,r.highlightSpecialChars)()),!1!==e.history&&s.push((0,o.m8)()),!1!==e.foldGutter&&s.push((0,he.mi)()),!1!==e.drawSelection&&s.push((0,r.drawSelection)()),!1!==e.dropCursor&&s.push((0,r.dropCursor)()),!1!==e.allowMultipleSelections&&s.push(i.EditorState.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&s.push((0,he.nY)()),!1!==e.syntaxHighlighting&&s.push((0,he.nF)(he.R_,{fallback:!0})),!1!==e.bracketMatching&&s.push((0,he.n$)()),!1!==e.closeBrackets&&s.push([et,Ge]),!1!==e.autocompletion&&s.push(function(e={}){return[je,Se.of(e),Ue,ht,$e]}()),!1!==e.rectangularSelection&&s.push((0,r.rectangularSelection)()),!1!==t&&s.push((0,r.crosshairCursor)()),!1!==e.highlightActiveLine&&s.push((0,r.highlightActiveLine)()),!1!==e.highlightSelectionMatches&&s.push(function(e){let t=[M,E];return e&&t.push(k.of(e)),t}()),e.tabSize&&"number"===typeof e.tabSize&&s.push(he.c.of(" ".repeat(e.tabSize))),s.concat([r.keymap.of(n.flat())]).filter(Boolean)},Lt=function(e){void 0===e&&(e={});var t=[];!1!==e.defaultKeymap&&(t=t.concat(o.wQ)),!1!==e.historyKeymap&&(t=t.concat(o.f$));var n=[];return!1!==e.highlightSpecialChars&&n.push((0,r.highlightSpecialChars)()),!1!==e.history&&n.push((0,o.m8)()),!1!==e.drawSelection&&n.push((0,r.drawSelection)()),!1!==e.syntaxHighlighting&&n.push((0,he.nF)(he.R_,{fallback:!0})),n.concat([r.keymap.of(t.flat())]).filter(Boolean)}},349:(e,t,n)=>{var r=n(787),i=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,o={},c=null,h=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(h=t.ref),t)s.call(t,r)&&!a.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===o[r]&&(o[r]=t[r]);return{$$typeof:i,type:e,key:c,ref:h,props:o,_owner:l.current}}t.jsx=c},501:(e,t,n)=>{e.exports=n(349)},787:t=>{t.exports=e},242:e=>{e.exports=t},362:e=>{e.exports=n},105:e=>{e.exports=r},215:(e,t,n)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e){var t=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===r(t)?t:String(t)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){var r,o,s;r=e,o=t,s=n[t],(o=i(o))in r?Object.defineProperty(r,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[o]=s})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}n.d(t,{Z:()=>s})},808:(e,t,n)=>{function r(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}n.d(t,{Z:()=>r})},79:(e,t,n)=>{n.d(t,{f$:()=>_,m8:()=>w,oc:()=>Le,wQ:()=>Ne});var r=n(242),i=n(105),o=n(434),s=n(857);function l(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(r(n.update(i)),!0)}}const a=l(p,0),c=l(d,0),h=l(((e,t)=>d(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to),o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}(t))),0);function u(e,t){let n=e.languageDataAt("commentTokens",t);return n.length?n[0]:{}}const f=50;function d(e,t,n=t.selection.ranges){let r=n.map((e=>u(t,e.from).block));if(!r.every((e=>e)))return null;let i=n.map(((e,n)=>function(e,{open:t,close:n},r,i){let o,s,l=e.sliceDoc(r-f,r),a=e.sliceDoc(i,i+f),c=/\s*$/.exec(l)[0].length,h=/^\s*/.exec(a)[0].length,u=l.length-c;if(l.slice(u-t.length,u)==t&&a.slice(h,h+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:i+h,margin:h&&1}};i-r<=2*f?o=s=e.sliceDoc(r,i):(o=e.sliceDoc(r,r+f),s=e.sliceDoc(i-f,i));let d=/^\s*/.exec(o)[0].length,p=/\s*$/.exec(s)[0].length,m=s.length-p-n.length;return o.slice(d,d+t.length)==t&&s.slice(m,m+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(o.charAt(d+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(s.charAt(m-1))?1:0}}:null}(t,r[n],e.from,e.to)));if(2!=e&&!i.every((e=>e)))return{changes:t.changes(n.map(((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}])))};if(1!=e&&i.some((e=>e))){let e=[];for(let t,n=0;n<i.length;n++)if(t=i[n]){let i=r[n],{open:o,close:s}=t;e.push({from:o.pos-i.open.length,to:o.pos+o.margin},{from:s.pos-s.margin,to:s.pos+i.close.length})}return{changes:e}}return null}function p(e,t,n=t.selection.ranges){let r=[],i=-1;for(let{from:o,to:s}of n){let e=r.length,n=1e9,l=u(t,o).line;if(l){for(let e=o;e<=s;){let a=t.doc.lineAt(e);if(a.from>i&&(o==s||s>a.from)){i=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,o=a.text.slice(e,e+l.length)==l?e:-1;e<a.text.length&&e<n&&(n=e),r.push({line:a,comment:o,token:l,indent:e,empty:t,single:!1})}e=a.to+1}if(n<1e9)for(let t=e;t<r.length;t++)r[t].indent<r[t].line.text.length&&(r[t].indent=n);r.length==e+1&&(r[e].single=!0)}}if(2!=e&&r.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:i,indent:o,empty:s,single:l}of r)!l&&s||e.push({from:t.from+o,insert:i+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,o=r+i.length;" "==t.text[o-t.from]&&o++,e.push({from:r,to:o})}return{changes:e}}return null}const m=r.Annotation.define(),g=r.Annotation.define(),y=r.Facet.define(),v=r.Facet.define({combine:e=>(0,r.combineConfig)(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})});const b=r.StateField.define({create:()=>L.empty,update(e,t){let n=t.state.facet(v),i=t.annotation(m);if(i){let o=t.docChanged?r.EditorSelection.single(function(e){let t=0;return e.iterChangedRanges(((e,n)=>t=n)),t}(t.changes)):void 0,s=E.fromTransaction(t,o),l=i.side,a=0==l?e.undone:e.done;return a=s?M(a,a.length,n.minDepth,s):P(a,t.startState.selection),new L(0==l?i.rest:a,0==l?a:i.rest)}let o=t.annotation(g);if("full"!=o&&"before"!=o||(e=e.isolate()),!1===t.annotation(r.Transaction.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=E.fromTransaction(t),l=t.annotation(r.Transaction.time),a=t.annotation(r.Transaction.userEvent);return s?e=e.addChanges(s,l,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,l,a,n.newGroupDelay)),"full"!=o&&"after"!=o||(e=e.isolate()),e},toJSON:e=>({done:e.done.map((e=>e.toJSON())),undone:e.undone.map((e=>e.toJSON()))}),fromJSON:e=>new L(e.done.map(E.fromJSON),e.undone.map(E.fromJSON))});function w(e={}){return[b,v.of(e),i.EditorView.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?k:"historyRedo"==e.inputType?S:null;return!!n&&(e.preventDefault(),n(t))}})]}function x(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(b,!1);if(!i)return!1;let o=i.pop(e,n,t);return!!o&&(r(o),!0)}}const k=x(0,!1),S=x(1,!1),C=x(0,!0),A=x(1,!0);class E{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new E(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((e=>e.toJSON()))}}static fromJSON(e){return new E(e.changes&&r.ChangeSet.fromJSON(e.changes),[],e.mapped&&r.ChangeDesc.fromJSON(e.mapped),e.startSelection&&r.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(r.EditorSelection.fromJSON))}static fromTransaction(e,t){let n=D;for(let r of e.startState.facet(y)){let t=r(e);t.length&&(n=n.concat(t))}return!n.length&&e.changes.empty?null:new E(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,D)}static selection(e){return new E(void 0,D,void 0,void 0,e)}}function M(e,t,n,r){let i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function O(e,t){return e.length?t.length?e.concat(t):e:t}const D=[],I=200;function P(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-I));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),M(e,e.length-1,1e9,n.setSelAfter(r)))}return[E.selection([t])]}function T(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function B(e,t){if(!e.length)return e;let n=e.length,r=D;for(;n;){let i=R(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[E.selection(r)]:D}function R(e,t,n){let i=O(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):D,n);if(!e.changes)return E.selection(i);let o=e.changes.map(t),s=t.mapDesc(e.changes,!0),l=e.mapped?e.mapped.composeDesc(s):s;return new E(o,r.StateEffect.mapEffects(e.effects,t),l,e.startSelection.map(s),i)}const N=/^(input\.type|delete)($|\.)/;class L{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new L(this.done,this.undone):this}addChanges(e,t,n,r,i){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||N.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,function(e,t){let n=[],r=!1;return e.iterChangedRanges(((e,t)=>n.push(e,t))),t.iterChangedRanges(((e,t,i,o)=>{for(let s=0;s<n.length;){let e=n[s++],t=n[s++];o>=e&&i<=t&&(r=!0)}})),r}(s.changes,e.changes))||"input.type.compose"==n)?M(o,o.length-1,r.minDepth,new E(e.changes.compose(s.changes),O(e.effects,s.effects),s.mapped,s.startSelection,D)):M(o,o.length,r.minDepth,e),new L(o,D,t,n)}addSelection(e,t,n,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:D;return i.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(o=i[i.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter(((e,t)=>e.empty!=s.ranges[t].empty)).length)?this:new L(P(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new L(B(this.done,e),B(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let i=r[r.length-1];if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:m.of({side:e,rest:T(r)}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let n=1==r.length?D:r.slice(0,r.length-1);return i.mapped&&(n=B(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:m.of({side:e,rest:n}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}L.empty=new L(D,D);const _=[{key:"Mod-z",run:k,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:S,preventDefault:!0},{linux:"Ctrl-Shift-z",run:S,preventDefault:!0},{key:"Mod-u",run:C,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:A,preventDefault:!0}];function q(e,t){return r.EditorSelection.create(e.ranges.map(t),e.mainIndex)}function F(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function j({state:e,dispatch:t},n){let r=q(e.selection,n);return!r.eq(e.selection)&&(t(F(e,r)),!0)}function V(e,t){return r.EditorSelection.cursor(t?e.to:e.from)}function W(e,t){return j(e,(n=>n.empty?e.moveByChar(n,t):V(n,t)))}function z(e){return e.textDirectionAt(e.state.selection.main.head)==i.Direction.LTR}const U=e=>W(e,!z(e)),$=e=>W(e,z(e));function H(e,t){return j(e,(n=>n.empty?e.moveByGroup(n,t):V(n,t)))}"undefined"!=typeof Intl&&Intl.Segmenter;function J(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function K(e,t,n){let i,l,a=(0,o.qz)(e).resolveInner(t.head),c=n?s.md.closedBy:s.md.openedBy;for(let r=t.head;;){let t=n?a.childAfter(r):a.childBefore(r);if(!t)break;J(e,t,c)?a=t:r=n?t.to:t.from}return l=a.type.prop(c)&&(i=n?(0,o.Um)(e,a.from,1):(0,o.Um)(e,a.to,-1))&&i.matched?n?i.end.to:i.end.from:n?a.to:a.from,r.EditorSelection.cursor(l,n?-1:1)}function G(e,t){return j(e,(n=>{if(!n.empty)return V(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)}))}const Q=e=>G(e,!1),Z=e=>G(e,!0);function X(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,o=0;if(n){for(let t of e.state.facet(i.EditorView.scrollMargins)){let n=t(e);(null===n||void 0===n?void 0:n.top)&&(r=Math.max(null===n||void 0===n?void 0:n.top,r)),(null===n||void 0===n?void 0:n.bottom)&&(o=Math.max(null===n||void 0===n?void 0:n.bottom,o))}t=e.scrollDOM.clientHeight-r-o}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:o,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function Y(e,t){let n,r=X(e),{state:o}=e,s=q(o.selection,(n=>n.empty?e.moveVertically(n,t,r.height):V(n,t)));if(s.eq(o.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(o.selection.main.head),l=e.scrollDOM.getBoundingClientRect(),a=l.top+r.marginTop,c=l.bottom-r.marginBottom;t&&t.top>a&&t.bottom<c&&(n=i.EditorView.scrollIntoView(s.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(F(o,s),{effects:n}),!0}const ee=e=>Y(e,!1),te=e=>Y(e,!0);function ne(e,t,n){let i=e.lineBlockAt(t.head),o=e.moveToLineBoundary(t,n);if(o.head==t.head&&o.head!=(n?i.to:i.from)&&(o=e.moveToLineBoundary(t,n,!1)),!n&&o.head==i.from&&i.length){let n=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(o=r.EditorSelection.cursor(i.from+n))}return o}function re(e,t,n){let i=!1,s=q(e.selection,(t=>{let s=(0,o.Um)(e,t.head,-1)||(0,o.Um)(e,t.head,1)||t.head>0&&(0,o.Um)(e,t.head-1,1)||t.head<e.doc.length&&(0,o.Um)(e,t.head+1,-1);if(!s||!s.end)return t;i=!0;let l=s.start.from==t.head?s.end.to:s.end.from;return n?r.EditorSelection.range(t.anchor,l):r.EditorSelection.cursor(l)}));return!!i&&(t(F(e,s)),!0)}function ie(e,t){let n=q(e.state.selection,(e=>{let n=t(e);return r.EditorSelection.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)}));return!n.eq(e.state.selection)&&(e.dispatch(F(e.state,n)),!0)}function oe(e,t){return ie(e,(n=>e.moveByChar(n,t)))}const se=e=>oe(e,!z(e)),le=e=>oe(e,z(e));function ae(e,t){return ie(e,(n=>e.moveByGroup(n,t)))}function ce(e,t){return ie(e,(n=>e.moveVertically(n,t)))}const he=e=>ce(e,!1),ue=e=>ce(e,!0);function fe(e,t){return ie(e,(n=>e.moveVertically(n,t,X(e).height)))}const de=e=>fe(e,!1),pe=e=>fe(e,!0),me=({state:e,dispatch:t})=>(t(F(e,{anchor:0})),!0),ge=({state:e,dispatch:t})=>(t(F(e,{anchor:e.doc.length})),!0),ye=({state:e,dispatch:t})=>(t(F(e,{anchor:e.selection.main.anchor,head:0})),!0),ve=({state:e,dispatch:t})=>(t(F(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function be(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:o}=e,s=o.changeByRange((i=>{let{from:o,to:s}=i;if(o==s){let r=t(o);r<o?(n="delete.backward",r=we(e,r,!1)):r>o&&(n="delete.forward",r=we(e,r,!0)),o=Math.min(o,r),s=Math.max(s,r)}else o=we(e,o,!1),s=we(e,s,!0);return o==s?{range:i}:{changes:{from:o,to:s},range:r.EditorSelection.cursor(o)}}));return!s.changes.empty&&(e.dispatch(o.update(s,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?i.EditorView.announce.of(o.phrase("Selection deleted")):void 0})),!0)}function we(e,t,n){if(e instanceof i.EditorView)for(let r of e.state.facet(i.EditorView.atomicRanges).map((t=>t(e))))r.between(t,t,((e,r)=>{e<t&&r>t&&(t=n?r:e)}));return t}const xe=(e,t)=>be(e,(n=>{let i,s,{state:l}=e,a=l.doc.lineAt(n);if(!t&&n>a.from&&n<a.from+200&&!/[^ \t]/.test(i=a.text.slice(0,n-a.from))){if("\t"==i[i.length-1])return n-1;let e=(0,r.countColumn)(i,l.tabSize)%(0,o.y1)(l)||(0,o.y1)(l);for(let t=0;t<e&&" "==i[i.length-1-t];t++)n--;s=n}else s=(0,r.findClusterBreak)(a.text,n-a.from,t,t)+a.from,s==n&&a.number!=(t?l.doc.lines:1)&&(s+=t?1:-1);return s})),ke=e=>xe(e,!1),Se=e=>xe(e,!0),Ce=(e,t)=>be(e,(n=>{let i=n,{state:o}=e,s=o.doc.lineAt(i),l=o.charCategorizer(i);for(let e=null;;){if(i==(t?s.to:s.from)){i==n&&s.number!=(t?o.doc.lines:1)&&(i+=t?1:-1);break}let a=(0,r.findClusterBreak)(s.text,i-s.from,t)+s.from,c=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),h=l(c);if(null!=e&&h!=e)break;" "==c&&i==n||(e=h),i=a}return i})),Ae=e=>Ce(e,!1),Ee=e=>be(e,(t=>{let n=e.lineBlockAt(t).to;return t<n?n:Math.min(e.state.doc.length,t+1)}));function Me(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(r.empty||r.to!=o.from||(o=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(r)}else t.push({from:i.from,to:o.to,ranges:[r]});n=o.number+1}return t}function Oe(e,t,n){if(e.readOnly)return!1;let i=[],o=[];for(let s of Me(e)){if(n?s.to==e.doc.length:0==s.from)continue;let t=e.doc.lineAt(n?s.to+1:s.from-1),l=t.length+1;if(n){i.push({from:s.to,to:t.to},{from:s.from,insert:t.text+e.lineBreak});for(let t of s.ranges)o.push(r.EditorSelection.range(Math.min(e.doc.length,t.anchor+l),Math.min(e.doc.length,t.head+l)))}else{i.push({from:t.from,to:s.from},{from:s.to,insert:e.lineBreak+t.text});for(let e of s.ranges)o.push(r.EditorSelection.range(e.anchor-l,e.head-l))}}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:r.EditorSelection.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0)}function De(e,t,n){if(e.readOnly)return!1;let r=[];for(let i of Me(e))n?r.push({from:i.from,insert:e.doc.slice(i.from,i.to)+e.lineBreak}):r.push({from:i.to,insert:e.lineBreak+e.doc.slice(i.from,i.to)});return t(e.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Ie=Pe(!1);function Pe(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let i=t.changeByRange((n=>{let{from:i,to:l}=n,a=t.doc.lineAt(i),c=!e&&i==l&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,r=(0,o.qz)(e).resolveInner(t),i=r.childBefore(t),l=r.childAfter(t);return i&&l&&i.to<=t&&l.from>=t&&(n=i.type.prop(s.md.closedBy))&&n.indexOf(l.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(i.to,l.from))?{from:i.to,to:l.from}:null}(t,i);e&&(i=l=(l<=a.to?a:t.doc.lineAt(l)).to);let h=new o.Gn(t,{simulateBreak:i,simulateDoubleBreak:!!c}),u=(0,o.K0)(h,i);for(null==u&&(u=(0,r.countColumn)(/^\s*/.exec(t.doc.lineAt(i).text)[0],t.tabSize));l<a.to&&/\s/.test(a.text[l-a.from]);)l++;c?({from:i,to:l}=c):i>a.from&&i<a.from+100&&!/\S/.test(a.text.slice(0,i))&&(i=a.from);let f=["",(0,o.SS)(t,u)];return c&&f.push((0,o.SS)(t,h.lineIndent(a.from,-1))),{changes:{from:i,to:l,insert:r.Text.of(f)},range:r.EditorSelection.cursor(i+1+f[1].length)}}));return n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Te(e,t){let n=-1;return e.changeByRange((i=>{let o=[];for(let r=i.from;r<=i.to;){let s=e.doc.lineAt(r);s.number>n&&(i.empty||i.to>s.from)&&(t(s,o,i),n=s.number),r=s.to+1}let s=e.changes(o);return{changes:o,range:r.EditorSelection.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}}))}const Be=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Te(e,((t,n)=>{n.push({from:t.from,insert:e.facet(o.c)})})),{userEvent:"input.indent"})),!0),Re=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Te(e,((t,n)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let s=(0,r.countColumn)(i,e.tabSize),l=0,a=(0,o.SS)(e,Math.max(0,s-(0,o.y1)(e)));for(;l<i.length&&l<a.length&&i.charCodeAt(l)==a.charCodeAt(l);)l++;n.push({from:t.from+l,to:t.from+i.length,insert:a.slice(l)})})),{userEvent:"delete.dedent"})),!0),Ne=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>j(e,(t=>K(e.state,t,!z(e)))),shift:e=>ie(e,(t=>K(e.state,t,!z(e))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>j(e,(t=>K(e.state,t,z(e)))),shift:e=>ie(e,(t=>K(e.state,t,z(e))))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>Oe(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>De(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>Oe(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>De(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,i=null;return n.ranges.length>1?i=r.EditorSelection.create([n.main]):n.main.empty||(i=r.EditorSelection.create([r.EditorSelection.cursor(n.main.head)])),!!i&&(t(F(e,i)),!0)}},{key:"Mod-Enter",run:Pe(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=Me(e).map((({from:t,to:n})=>r.EditorSelection.range(t,Math.min(n+1,e.doc.length))));return t(e.update({selection:r.EditorSelection.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=q(e.selection,(t=>{var n;let i=(0,o.qz)(e).resolveInner(t.head,1);for(;!(i.from<t.from&&i.to>=t.to||i.to>t.to&&i.from<=t.from)&&(null===(n=i.parent)||void 0===n?void 0:n.parent);)i=i.parent;return r.EditorSelection.range(i.to,i.from)}));return t(F(e,n)),!0},preventDefault:!0},{key:"Mod-[",run:Re},{key:"Mod-]",run:Be},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new o.Gn(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=Te(e,((t,i,s)=>{let l=(0,o.K0)(r,t.from);if(null==l)return;/\S/.test(t.text)||(l=0);let a=/^\s*/.exec(t.text)[0],c=(0,o.SS)(e,l);(a!=c||s.from<t.from+a.length)&&(n[t.from]=l,i.push({from:t.from,to:t.from+a.length,insert:c}))}));return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Me(t).map((({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n})))),r=q(t.selection,(t=>e.moveVertically(t,!0))).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>re(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=u(e.state,n.from);return r.line?a(e):!!r.block&&h(e)}},{key:"Alt-A",run:c}].concat([{key:"ArrowLeft",run:U,shift:se,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>H(e,!z(e)),shift:e=>ae(e,!z(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>j(e,(t=>ne(e,t,!z(e)))),shift:e=>ie(e,(t=>ne(e,t,!z(e)))),preventDefault:!0},{key:"ArrowRight",run:$,shift:le,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>H(e,z(e)),shift:e=>ae(e,z(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>j(e,(t=>ne(e,t,z(e)))),shift:e=>ie(e,(t=>ne(e,t,z(e)))),preventDefault:!0},{key:"ArrowUp",run:Q,shift:he,preventDefault:!0},{mac:"Cmd-ArrowUp",run:me,shift:ye},{mac:"Ctrl-ArrowUp",run:ee,shift:de},{key:"ArrowDown",run:Z,shift:ue,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ge,shift:ve},{mac:"Ctrl-ArrowDown",run:te,shift:pe},{key:"PageUp",run:ee,shift:de},{key:"PageDown",run:te,shift:pe},{key:"Home",run:e=>j(e,(t=>ne(e,t,!1))),shift:e=>ie(e,(t=>ne(e,t,!1))),preventDefault:!0},{key:"Mod-Home",run:me,shift:ye},{key:"End",run:e=>j(e,(t=>ne(e,t,!0))),shift:e=>ie(e,(t=>ne(e,t,!0))),preventDefault:!0},{key:"Mod-End",run:ge,shift:ve},{key:"Enter",run:Ie},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:ke,shift:ke},{key:"Delete",run:Se},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ae},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>Ce(e,!0)},{mac:"Mod-Backspace",run:e=>be(e,(t=>{let n=e.lineBlockAt(t).from;return t>n?n:Math.max(0,t-1)}))},{mac:"Mod-Delete",run:Ee}].concat([{key:"Ctrl-b",run:U,shift:se,preventDefault:!0},{key:"Ctrl-f",run:$,shift:le},{key:"Ctrl-p",run:Q,shift:he},{key:"Ctrl-n",run:Z,shift:ue},{key:"Ctrl-a",run:e=>j(e,(t=>r.EditorSelection.cursor(e.lineBlockAt(t.head).from,1))),shift:e=>ie(e,(t=>r.EditorSelection.cursor(e.lineBlockAt(t.head).from)))},{key:"Ctrl-e",run:e=>j(e,(t=>r.EditorSelection.cursor(e.lineBlockAt(t.head).to,-1))),shift:e=>ie(e,(t=>r.EditorSelection.cursor(e.lineBlockAt(t.head).to)))},{key:"Ctrl-d",run:Se},{key:"Ctrl-h",run:ke},{key:"Ctrl-k",run:Ee},{key:"Ctrl-Alt-h",run:Ae},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:r.Text.of(["",""])},range:r.EditorSelection.cursor(e.from)})));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,i=e.doc.lineAt(n),o=n==i.from?n-1:(0,r.findClusterBreak)(i.text,n-i.from,!1)+i.from,s=n==i.to?n+1:(0,r.findClusterBreak)(i.text,n-i.from,!0)+i.from;return{changes:{from:o,to:s,insert:e.doc.slice(n,s).append(e.doc.slice(o,n))},range:r.EditorSelection.cursor(s)}}));return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:te}].map((e=>({mac:e.key,run:e.run,shift:e.shift}))))),Le={key:"Tab",run:Be,shift:Re}},434:(e,t,n)=>{n.d(t,{Gn:()=>ie,n$:()=>et,R_:()=>$e,mi:()=>Le,e7:()=>Me,y1:()=>te,K0:()=>re,nY:()=>de,SS:()=>ne,c:()=>ee,Um:()=>it,nF:()=>We,qz:()=>z});var r=n(857),i=n(242),o=n(105);let s=0;class l{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=s++}static define(e){if(null===e||void 0===e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new l([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new c;return t=>t.modified.indexOf(e)>-1?t:c.get(t.base||t,t.modified.concat(e).sort(((e,t)=>e.id-t.id)))}}let a=0;class c{constructor(){this.instances=[],this.id=a++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find((n=>{return n.base==e&&(r=t,i=n.modified,r.length==i.length&&r.every(((e,t)=>e==i[t])));var r,i}));if(n)return n;let r=[],i=new l(r,e,t);for(let s of t)s.instances.push(i);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort(((e,t)=>t.length-e.length))}(t);for(let s of e.set)if(!s.modified.length)for(let e of o)r.push(c.get(s,e));return i}}function h(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(" "))if(e){let n=[],i=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!r)throw new RangeError("Invalid path: "+e);if(n.push("*"==r[0]?"":'"'==r[0][0]?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){i=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,l=n[s];if(!l)throw new RangeError("Invalid path: "+e);let a=new f(r,i,s>0?n.slice(0,s):null);t[l]=a.sort(t[l])}}return u.add(t)}const u=new r.md;class f{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function d(e,t){let n=Object.create(null);for(let o of e)if(Array.isArray(o.tag))for(let e of o.tag)n[e.id]=o.class;else n[o.tag.id]=o.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+" "+r:r;break}}return t},scope:r}}function p(e,t,n,r=0,i=e.length){let o=new m(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}f.empty=new f([],2,null);class m{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,o){let{type:s,from:l,to:a}=e;if(l>=n||a<=t)return;s.isTop&&(o=this.highlighters.filter((e=>!e.scope||e.scope(s))));let c=i,h=function(e){let t=e.type.prop(u);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||f.empty,d=function(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+" "+e:e)}return n}(o,h.tags);if(d&&(c&&(c+=" "),c+=d,1==h.mode&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(t,l),c),h.opaque)return;let p=e.tree&&e.tree.prop(r.md.mounted);if(p&&p.overlay){let r=e.node.enter(p.overlay[0].from+l,1),s=this.highlighters.filter((e=>!e.scope||e.scope(p.tree.type))),h=e.firstChild();for(let u=0,f=l;;u++){let d=u<p.overlay.length?p.overlay[u]:null,m=d?d.from+l:a,g=Math.max(t,f),y=Math.min(n,m);if(g<y&&h)for(;e.from<y&&(this.highlightRange(e,g,y,i,o),this.startSpan(Math.min(y,e.to),c),!(e.to>=m)&&e.nextSibling()););if(!d||m>n)break;f=d.to+l,f>t&&(this.highlightRange(r.cursor(),Math.max(t,d.from+l),Math.min(n,f),"",s),this.startSpan(Math.min(n,f),c))}h&&e.parent()}else if(e.firstChild()){p&&(i="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,o),this.startSpan(Math.min(n,e.to),c)}}while(e.nextSibling());e.parent()}}}const g=l.define,y=g(),v=g(),b=g(v),w=g(v),x=g(),k=g(x),S=g(x),C=g(),A=g(C),E=g(),M=g(),O=g(),D=g(O),I=g(),P={comment:y,lineComment:g(y),blockComment:g(y),docComment:g(y),name:v,variableName:g(v),typeName:b,tagName:g(b),propertyName:w,attributeName:g(w),className:g(v),labelName:g(v),namespace:g(v),macroName:g(v),literal:x,string:k,docString:g(k),character:g(k),attributeValue:g(k),number:S,integer:g(S),float:g(S),bool:g(x),regexp:g(x),escape:g(x),color:g(x),url:g(x),keyword:E,self:g(E),null:g(E),atom:g(E),unit:g(E),modifier:g(E),operatorKeyword:g(E),controlKeyword:g(E),definitionKeyword:g(E),moduleKeyword:g(E),operator:M,derefOperator:g(M),arithmeticOperator:g(M),logicOperator:g(M),bitwiseOperator:g(M),compareOperator:g(M),updateOperator:g(M),definitionOperator:g(M),typeOperator:g(M),controlOperator:g(M),punctuation:O,separator:g(O),bracket:D,angleBracket:g(D),squareBracket:g(D),paren:g(D),brace:g(D),content:C,heading:A,heading1:g(A),heading2:g(A),heading3:g(A),heading4:g(A),heading5:g(A),heading6:g(A),contentSeparator:g(C),list:g(C),quote:g(C),emphasis:g(C),strong:g(C),link:g(C),monospace:g(C),strikethrough:g(C),inserted:g(),deleted:g(),changed:g(),invalid:g(),meta:I,documentMeta:g(I),annotation:g(I),processingInstruction:g(I),definition:l.defineModifier(),constant:l.defineModifier(),function:l.defineModifier(),standard:l.defineModifier(),local:l.defineModifier(),special:l.defineModifier()},T=(d([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]),"undefined"==typeof Symbol?"__\u037c":Symbol.for("\u037c")),B="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class N{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,o,s){let l=[],a=/^@(\w+)\b/.exec(e[0]),c=a&&"keyframes"==a[1];if(a&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))i(n.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,o);else if(s&&"object"==typeof s){if(!a)throw new RangeError("The value of a property ("+n+") should be a primitive value.");i(r(n),s,l,c)}else null!=s&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(l.length||c)&&o.push((!n||a||s?e:e.map(n)).join(", ")+" {"+l.join(" ")+"}")}for(let o in e)i(r(o),e[o],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=R[T]||1;return R[T]=e+1,"\u037c"+e.toString(36)}static mount(e,t,n){let r=e[B],i=n&&n.nonce;r?i&&r.setNonce(i):r=new _(e,i),r.mount(Array.isArray(t)?t:[t])}}let L=new Map;class _{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=L.get(n);if(t)return e.adoptedStyleSheets=[t.sheet,...e.adoptedStyleSheets],e[B]=t;this.sheet=new r.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],L.set(n,this)}else{this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let r=e.head||e;r.insertBefore(this.styleTag,r.firstChild)}this.modules=[],e[B]=this}mount(e){let t=this.sheet,n=0,r=0;for(let i=0;i<e.length;i++){let o=e[i],s=this.modules.indexOf(o);if(s<r&&s>-1&&(this.modules.splice(s,1),r--,s=-1),-1==s){if(this.modules.splice(r++,0,o),t)for(let e=0;e<o.rules.length;e++)t.insertRule(o.rules[e],n++)}else{for(;r<s;)n+=this.modules[r++].rules.length;n+=o.rules.length,r++}}if(!t){let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var q;const F=new r.md;const j=new r.md;class V{constructor(e,t,n=[],r=""){this.data=e,this.name=r,i.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(i.EditorState.prototype,"tree",{get(){return z(this)}}),this.parser=t,this.extension=[X.of(this),i.EditorState.languageData.of(((e,t,n)=>{let r=W(e,t,n),i=r.type.prop(F);if(!i)return[];let o=e.facet(i),s=r.type.prop(j);if(s){let i=r.resolve(t-r.from,n);for(let t of s)if(t.test(i,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o}))].concat(n)}isActiveAt(e,t,n=-1){return W(e,t,n).type.prop(F)==this.data}findRegions(e){let t=e.facet(X);if((null===t||void 0===t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(F)==this.data)return void n.push({from:t,to:t+e.length});let o=e.prop(r.md.mounted);if(o){if(o.tree.prop(F)==this.data){if(o.overlay)for(let e of o.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(o.overlay){let e=n.length;if(i(o.tree,o.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let o=e.children[n];o instanceof r.mp&&i(o,e.positions[n]+t)}};return i(z(e),0),n}get allowsNesting(){return!0}}function W(e,t,n){let i=e.facet(X),o=z(e).topNode;if(!i||i.allowsNesting)for(let s=o;s;s=s.enter(t,n,r.vj.ExcludeBuffers))s.type.isTop&&(o=s);return o}V.setState=i.StateEffect.define();function z(e){let t=e.field(V.state,!1);return t?t.tree:r.mp.empty}class U{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let $=null;class H{constructor(e,t,n=[],r,i,o,s,l){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new H(e,t,[],r.mp.empty,0,n,[],null)}startParse(){return this.parser.startParse(new U(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=r.mp.empty&&this.isDone(null!==t&&void 0!==t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(r.i9.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!==t&&void 0!==t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((()=>{for(;!(t=this.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(r.i9.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=$;$=this;try{return e()}finally{$=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=J(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:o,viewport:s,skipped:l}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,n,r,i)=>t.push({fromA:e,toA:n,fromB:r,toB:i}))),n=r.i9.applyChanges(n,t),i=r.mp.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){l=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);n<r&&l.push({from:n,to:r})}}}return new H(this.parser,t,n,i,o,s,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:t,to:r}=this.skipped[n];t<e.to&&r>e.from&&(this.fragments=J(this.fragments,t,r),this.skipped.splice(n--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends r._b{createParse(t,n,i){let o=i[0].from,s=i[i.length-1].to;return{parsedPos:o,advance(){let t=$;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new r.mp(r.Jq.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return $}}function J(e,t,n){return r.i9.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class K{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new K(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=H.create(e.facet(X).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new K(n)}}V.state=i.StateField.define({create:K.init,update(e,t){for(let n of t.effects)if(n.is(V.setState))return n.value;return t.startState.facet(X)!=t.state.facet(X)?K.init(t.state):e.apply(t)}});let G=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(G=e=>{let t=-1,n=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const Q="undefined"!=typeof navigator&&(null===(q=navigator.scheduling)||void 0===q?void 0:q.isInputPending)?()=>navigator.scheduling.isInputPending():null,Z=o.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(V.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(V.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=G(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(V.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Q?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&n.doc.length>r+1e3,l=i.context.work((()=>Q&&Q()||Date.now()>o),r+(s?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:V.setState.of(new K(i.context))})),this.chunkBudget>0&&(!l||s)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>(0,o.logException)(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),X=i.Facet.define({combine:e=>e.length?e[0]:null,enables:e=>[V.state,Z,o.EditorView.contentAttributes.compute([e],(t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}}))]});const Y=i.Facet.define(),ee=i.Facet.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some((e=>e!=t[0])))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function te(e){let t=e.facet(ee);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function ne(e,t){let n="",r=e.tabSize,i=e.facet(ee)[0];if("\t"==i){for(;t>=r;)n+="\t",t-=r;i=" "}for(let o=0;o<t;o++)n+=i;return n}function re(e,t){e instanceof i.EditorState&&(e=new ie(e));for(let r of e.state.facet(Y)){let n=r(e,t);if(void 0!==n)return n}let n=z(e.state);return n.length>=t?function(e,t,n){let r=t.resolveStack(n),i=r.node.enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t!=r.node;t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return se(r,e,n)}(e,n,t):null}class ie{constructor(e,t={}){this.state=e,this.options=t,this.unit=te(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return null!=r&&r>=n.from&&r<=n.to?i&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(i+=o-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return(0,i.countColumn)(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const oe=new r.md;function se(e,t,n){for(let r=e;r;r=r.next){let e=le(r.node);if(e)return e(ce.create(t,n,r))}return 0}function le(e){let t=e.type.prop(oe);if(t)return t;let n,i=e.firstChild;if(i&&(n=i.type.prop(r.md.closedBy))){let t=e.lastChild,r=t&&n.indexOf(t.name)>-1;return e=>ue(e,!0,1,void 0,r&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?ae:null}function ae(){return 0}class ce extends ie{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new ce(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(he(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return se(this.context.next,this.base,this.pos)}}function he(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function ue(e,t,n,r,i){let o=e.textAfter,s=o.match(/^\s*/)[0].length,l=r&&o.slice(s,s+r.length)==r||i==e.pos+s,a=t?function(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==i||i<=o.from?o.to:Math.min(o.to,i);for(let l=n.to;;){let e=t.childAfter(l);if(!e||e==r)return null;if(!e.type.isSkipped)return e.from<s?n:null;l=e.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:e.unit*n)}const fe=200;function de(){return i.EditorState.transactionFilter.of((e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+fe)return e;let o=n.sliceString(i.from,r);if(!t.some((e=>e.test(o))))return e;let{state:s}=e,l=-1,a=[];for(let{head:c}of s.selection.ranges){let e=s.doc.lineAt(c);if(e.from==l)continue;l=e.from;let t=re(s,e.from);if(null==t)continue;let n=/^\s*/.exec(e.text)[0],r=ne(s,t);n!=r&&a.push({from:e.from,to:e.from+n.length,insert:r})}return a.length?[e,{changes:a,sequential:!0}]:e}))}const pe=i.Facet.define(),me=new r.md;function ge(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function ye(e,t,n){for(let r of e.facet(pe)){let i=r(e,t,n);if(i)return i}return function(e,t,n){let r=z(e);if(r.length<n)return null;let i=null;for(let o=r.resolveStack(n,1);o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(i&&s.from<t)break;let l=s.type.prop(me);if(l&&(s.to<r.length-50||r.length==e.doc.length||!ge(s))){let r=l(s,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(i=r)}}return i}(e,t,n)}function ve(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const be=i.StateEffect.define({map:ve}),we=i.StateEffect.define({map:ve});function xe(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some((e=>e.from<=n&&e.to>=n))||t.push(e.lineBlockAt(n));return t}const ke=i.StateField.define({create:()=>o.Decoration.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(be)&&!Ce(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(De),i=r?o.Decoration.replace({widget:new Be(r(t.state,n.value))}):Te;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(we)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:r}=t.selection.main;e.between(r,r,((e,t)=>{e<r&&t>r&&(n=!0)})),n&&(e=e.update({filterFrom:r,filterTo:r,filter:(e,t)=>t<=r||e>=r}))}return e},provide:e=>o.EditorView.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,((e,t)=>{n.push(e,t)})),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");t.push(Te.range(r,i))}return o.Decoration.set(t,!0)}});function Se(e,t,n){var r;let i=null;return null===(r=e.field(ke,!1))||void 0===r||r.between(t,n,((e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})})),i}function Ce(e,t,n){let r=!1;return e.between(t,t,((e,i)=>{e==t&&i==n&&(r=!0)})),r}function Ae(e,t){return e.field(ke,!1)?t:t.concat(i.StateEffect.appendConfig.of(Ie()))}function Ee(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return o.EditorView.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const Me=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of xe(e)){let n=ye(e.state,t.from,t.to);if(n)return e.dispatch({effects:Ae(e.state,[be.of(n),Ee(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(ke,!1))return!1;let t=[];for(let n of xe(e)){let r=Se(e.state,n.from,n.to);r&&t.push(we.of(r),Ee(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),o=ye(t,i.from,i.to);o&&n.push(be.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:Ae(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(ke,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,((e,t)=>{n.push(we.of({from:e,to:t}))})),e.dispatch({effects:n}),!0}}],Oe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},De=i.Facet.define({combine:e=>(0,i.combineConfig)(e,Oe)});function Ie(e){let t=[ke,_e];return e&&t.push(De.of(e)),t}function Pe(e,t){let{state:n}=e,r=n.facet(De),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=Se(e.state,n.from,n.to);r&&e.dispatch({effects:we.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}const Te=o.Decoration.replace({widget:new class extends o.WidgetType{toDOM(e){return Pe(e,null)}}});class Be extends o.WidgetType{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Pe(e,this.value)}}const Re={openText:"\u2304",closedText:"\u203a",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Ne extends o.GutterMarker{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Le(e={}){let t=Object.assign(Object.assign({},Re),e),n=new Ne(t,!0),r=new Ne(t,!1),s=o.ViewPlugin.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(X)!=e.state.facet(X)||e.startState.field(ke,!1)!=e.state.field(ke,!1)||z(e.startState)!=z(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new i.RangeSetBuilder;for(let i of e.viewportLineBlocks){let o=Se(e.state,i.from,i.to)?r:ye(e.state,i.from,i.to)?n:null;o&&t.add(i.from,i.from,o)}return t.finish()}}),{domEventHandlers:l}=t;return[s,(0,o.gutter)({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(s))||void 0===t?void 0:t.markers)||i.RangeSet.empty},initialSpacer:()=>new Ne(t,!1),domEventHandlers:Object.assign(Object.assign({},l),{click:(e,t,n)=>{if(l.click&&l.click(e,t,n))return!0;let r=Se(e.state,t.from,t.to);if(r)return e.dispatch({effects:we.of(r)}),!0;let i=ye(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:be.of(i)}),!0)}})}),Ie()]}const _e=o.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"}});class qe{constructor(e,t){let n;function r(e){let t=N.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const i="string"==typeof t.all?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof V?e=>e.prop(F)==o.data:o?e=>e==o:void 0,this.style=d(e.map((e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))}))),{all:i}).style,this.module=n?new N(n):null,this.themeType=t.themeType}static define(e,t){return new qe(e,t||{})}}const Fe=i.Facet.define(),je=i.Facet.define({combine:e=>e.length?[e[0]]:null});function Ve(e){let t=e.facet(Fe);return t.length?t:e.facet(je)}function We(e,t){let n,r=[Ue];return e instanceof qe&&(e.module&&r.push(o.EditorView.styleModule.of(e.module)),n=e.themeType),(null===t||void 0===t?void 0:t.fallback)?r.push(je.of(e)):n?r.push(Fe.computeN([o.EditorView.darkTheme],(t=>t.facet(o.EditorView.darkTheme)==("dark"==n)?[e]:[]))):r.push(Fe.of(e)),r}class ze{constructor(e){this.markCache=Object.create(null),this.tree=z(e.state),this.decorations=this.buildDeco(e,Ve(e.state))}update(e){let t=z(e.state),n=Ve(e.state),r=n!=Ve(e.startState);t.length<e.view.viewport.to&&!r&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n))}buildDeco(e,t){if(!t||!this.tree.length)return o.Decoration.none;let n=new i.RangeSetBuilder;for(let{from:r,to:i}of e.visibleRanges)p(this.tree,t,((e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=o.Decoration.mark({class:r})))}),r,i);return n.finish()}}const Ue=i.Prec.high(o.ViewPlugin.fromClass(ze,{decorations:e=>e.decorations})),$e=qe.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),He=o.EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Je=1e4,Ke="()[]{}",Ge=i.Facet.define({combine:e=>(0,i.combineConfig)(e,{afterCursor:!0,brackets:Ke,maxScanDistance:Je,renderMatch:Xe})}),Qe=o.Decoration.mark({class:"cm-matchingBracket"}),Ze=o.Decoration.mark({class:"cm-nonmatchingBracket"});function Xe(e){let t=[],n=e.matched?Qe:Ze;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const Ye=[i.StateField.define({create:()=>o.Decoration.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Ge);for(let i of t.state.selection.ranges){if(!i.empty)continue;let e=it(t.state,i.head,-1,r)||i.head>0&&it(t.state,i.head-1,1,r)||r.afterCursor&&(it(t.state,i.head,1,r)||i.head<t.state.doc.length&&it(t.state,i.head+1,-1,r));e&&(n=n.concat(r.renderMatch(e,t.state)))}return o.Decoration.set(n,!0)},provide:e=>o.EditorView.decorations.from(e)}),He];function et(e={}){return[Ge.of(e),Ye]}const tt=new r.md;function nt(e,t,n){let i=e.prop(t<0?r.md.openedBy:r.md.closedBy);if(i)return i;if(1==e.name.length){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function rt(e){let t=e.type.prop(tt);return t?t(e.node):e}function it(e,t,n,r={}){let i=r.maxScanDistance||Je,o=r.brackets||Ke,s=z(e),l=s.resolveInner(t,n);for(let a=l;a;a=a.parent){let r=nt(a.type,n,o);if(r&&a.from<a.to){let i=rt(a);if(i&&(n>0?t>=i.from&&t<i.to:t>i.from&&t<=i.to))return ot(e,t,n,a,i,r,o)}}return function(e,t,n,r,i,o,s){let l=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=s.indexOf(l);if(a<0||a%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=o;){let e=h.value;n<0&&(f+=e.length);let o=t+f*n;for(let t=n>0?0:e.length-1,l=n>0?e.length:-1;t!=l;t+=n){let l=s.indexOf(e[t]);if(!(l<0||r.resolveInner(o+t,1).type!=i))if(l%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:o+t,to:o+t+1},matched:l>>1==a>>1};u--}}n>0&&(f+=e.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,l.type,i,o)}function ot(e,t,n,r,i,o,s){let l=r.parent,a={from:i.from,to:i.to},c=0,h=null===l||void 0===l?void 0:l.cursor();if(h&&(n<0?h.childBefore(r.from):h.childAfter(r.to)))do{if(n<0?h.to<=r.from:h.from>=r.to){if(0==c&&o.indexOf(h.type.name)>-1&&h.from<h.to){let e=rt(h);return{start:a,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(nt(h.type,n,s))c++;else if(nt(h.type,-n,s)){if(0==c){let e=rt(h);return{start:a,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?h.prevSibling():h.nextSibling());return{start:a,matched:!1}}const st=Object.create(null),lt=[r.Jq.none],at=[],ct=Object.create(null);for(let[ft,dt]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])ct[ft]=ut(st,dt);function ht(e,t){at.indexOf(e)>-1||(at.push(e),console.warn(t))}function ut(e,t){let n=null;for(let r of t.split(".")){let t=e[r]||P[r];t?"function"==typeof t?n?n=t(n):ht(r,`Modifier ${r} used at start of tag`):n?ht(r,`Tag ${r} used as modifier`):n=t:ht(r,`Unknown highlighting tag ${r}`)}if(!n)return 0;let i=t.replace(/ /g,"_"),o=r.Jq.define({id:lt.length,name:i,props:[h({[i]:n})]});return lt.push(o),o.id}},857:(e,t,n)=>{n.d(t,{Jq:()=>c,Lj:()=>h,_b:()=>B,i9:()=>T,md:()=>s,mp:()=>p,vj:()=>d});const r=1024;let i=0;class o{constructor(e,t){this.from=e,this.to=t}}class s{constructor(e={}){this.id=i++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=c.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}s.closedBy=new s({deserialize:e=>e.split(" ")}),s.openedBy=new s({deserialize:e=>e.split(" ")}),s.group=new s({deserialize:e=>e.split(" ")}),s.contextHash=new s({perNode:!0}),s.lookAhead=new s({perNode:!0}),s.mounted=new s({perNode:!0});class l{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[s.mounted.id]}}const a=Object.create(null);class c{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):a,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new c(e.name||"",t,e.id,n);if(e.props)for(let i of e.props)if(Array.isArray(i)||(i=i(r)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}return r}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(s.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return e=>{for(let n=e.prop(s.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}c.none=new c("",Object.create(null),0,8);class h{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let r=null;for(let t of e){let e=t(n);e&&(r||(r=Object.assign({},n.props)),r[e[0].id]=e[1])}t.push(r?new c(n.name,r,n.id,n.flags):n)}return new h(t)}}const u=new WeakMap,f=new WeakMap;var d;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(d||(d={}));class p{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=l.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let e=n.toString();e&&(t&&(t+=","),t+=e)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new M(this.topNode,e)}cursorAt(e,t=0,n=0){let r=u.get(this)||this.topNode,i=new M(r);return i.moveTo(e,t),u.set(this,i._tree),i}get topNode(){return new w(this,0,0,null)}resolve(e,t=0){let n=v(u.get(this)||this.topNode,e,t,!1);return u.set(this,n),n}resolveInner(e,t=0){let n=v(f.get(this)||this.topNode,e,t,!0);return f.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let r=e.resolveInner(t,n),i=null;for(let o=r instanceof w?r:r.context.parent;o;o=o.parent)if(o.index<0){let e=o.parent;(i||(i=[r])).push(e.resolve(t,n)),o=e}else{let e=l.get(o.tree);if(e&&e.overlay&&e.overlay[0].from<=t&&e.overlay[e.overlay.length-1].to>=t){let s=new w(e.tree,e.overlay[0].from+o.from,0,null);(i||(i=[r])).push(v(s,t,n,!1))}}return i?A(i):r}(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,o=e.mode||0,s=(o&d.IncludeAnonymous)>0;for(let l=this.cursor(o|d.IncludeAnonymous);;){let e=!1;if(l.from<=i&&l.to>=r&&(!s&&l.type.isAnonymous||!1!==t(l))){if(l.firstChild())continue;e=!0}for(;e&&n&&(s||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;e=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:P(c.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new p(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new p(c.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:o=r,reused:l=[],minRepeatType:a=i.types.length}=e,c=Array.isArray(n)?new m(n,n.length):n,h=i.types,u=0,f=0;function d(e,t,n,r,s){let{id:p,start:m,end:k,size:S}=c,C=f;for(;S<0;){if(c.next(),-1==S){let t=l[p];return n.push(t),void r.push(m-e)}if(-3==S)return void(u=p);if(-4==S)return void(f=p);throw new RangeError(`Unrecognized record size: ${S}`)}let A,E,M=h[p],O=m-e;if(k-m<=o&&(E=w(c.pos-t,s))){let t=new Uint16Array(E.size-E.skip),n=c.pos-E.size,r=t.length;for(;c.pos>n;)r=x(E.start,t,r);A=new g(t,k-E.start,i),O=E.start-e}else{let e=c.pos-S;c.next();let t=[],n=[],r=p>=a?p:-1,i=0,s=k;for(;c.pos>e;)r>=0&&c.id==r&&c.size>=0?(c.end<=s-o&&(v(t,n,m,i,c.end,s,r,C),i=t.length,s=c.end),c.next()):d(m,e,t,n,r);if(r>=0&&i>0&&i<t.length&&v(t,n,m,i,m,s,r,C),t.reverse(),n.reverse(),r>-1&&i>0){let e=y(M);A=P(M,t,n,0,t.length,0,k-m,e,e)}else A=b(M,t,n,k-m,C-k)}n.push(A),r.push(O)}function y(e){return(t,n,r)=>{let i,o,l=0,a=t.length-1;if(a>=0&&(i=t[a])instanceof p){if(!a&&i.type==e&&i.length==r)return i;(o=i.prop(s.lookAhead))&&(l=n[a]+i.length+o)}return b(e,t,n,r,l)}}function v(e,t,n,r,o,s,l,a){let c=[],h=[];for(;e.length>r;)c.push(e.pop()),h.push(t.pop()+n-o);e.push(b(i.types[l],c,h,s-o,a-s)),t.push(o-n)}function b(e,t,n,r,i=0,o){if(u){let e=[s.contextHash,u];o=o?[e].concat(o):[e]}if(i>25){let e=[s.lookAhead,i];o=o?[e].concat(o):[e]}return new p(e,t,n,r,o)}function w(e,t){let n=c.fork(),r=0,i=0,s=0,l=n.end-o,h={size:0,start:0,skip:0};e:for(let o=n.pos-e;n.pos>o;){let e=n.size;if(n.id==t&&e>=0){h.size=r,h.start=i,h.skip=s,s+=4,r+=4,n.next();continue}let c=n.pos-e;if(e<0||c<o||n.start<l)break;let u=n.id>=a?4:0,f=n.start;for(n.next();n.pos>c;){if(n.size<0){if(-3!=n.size)break e;u+=4}else n.id>=a&&(u+=4);n.next()}i=f,r+=e,s+=u}return(t<0||r==e)&&(h.size=r,h.start=i,h.skip=s),h.size>4?h:void 0}function x(e,t,n){let{id:r,start:i,end:o,size:s}=c;if(c.next(),s>=0&&r<a){let l=n;if(s>4){let r=c.pos-(s-4);for(;c.pos>r;)n=x(e,t,n)}t[--n]=l,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==s?u=r:-4==s&&(f=r);return n}let k=[],S=[];for(;c.pos>0;)d(e.start||0,e.bufferStart||0,k,S,-1);let C=null!==(t=e.length)&&void 0!==t?t:k.length?S[0]+k[0].length:0;return new p(h[e.topID],k.reverse(),S.reverse(),C)}(e)}}p.empty=new p(c.none,[],[],0);class m{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new m(this.buffer,this.index)}}class g{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return c.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,t,n,r,i){let{buffer:o}=this,s=-1;for(let l=e;l!=t&&!(y(i,r,o[l+1],o[l+2])&&(s=l,n>0));l=o[l+3]);return s}slice(e,t,n){let r=this.buffer,i=new Uint16Array(t-e),o=0;for(let s=e,l=0;s<t;){i[l++]=r[s++],i[l++]=r[s++]-n;let t=i[l++]=r[s++]-n;i[l++]=r[s++]-e,o=Math.max(o,t)}return new g(i,o,this.set)}}function y(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function v(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof w&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=r?0:d.IgnoreOverlays;if(r)for(let s=e,l=s.parent;l;s=l,l=s.parent)s instanceof w&&s.index<0&&(null===(i=l.enter(t,n,o))||void 0===i?void 0:i.from)!=s.from&&(e=l);for(;;){let r=e.enter(t,n,o);if(!r)return e;e=r}}class b{cursor(e=0){return new M(this,e)}getChild(e,t=null,n=null){let r=x(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return x(this,e,t,n)}resolve(e,t=0){return v(this,e,t,!1)}resolveInner(e,t=0){return v(this,e,t,!0)}matchContext(e){return k(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class w extends b{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,r,i=0){for(let o=this;;){for(let{children:s,positions:a}=o._tree,c=t>0?s.length:-1;e!=c;e+=t){let c=s[e],h=a[e]+o.from;if(y(r,n,h,h+c.length))if(c instanceof g){if(i&d.ExcludeBuffers)continue;let s=c.findChild(0,c.buffer.length,t,n-h,r);if(s>-1)return new C(new S(o,c,e,h),null,s)}else if(i&d.IncludeAnonymous||!c.type.isAnonymous||O(c)){let s;if(!(i&d.IgnoreMounts)&&(s=l.get(c))&&!s.overlay)return new w(s.tree,h,e,o);let a=new w(c,h,e,o);return i&d.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?c.children.length-1:0,t,n,r)}}if(i&d.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let r;if(!(n&d.IgnoreOverlays)&&(r=l.get(this._tree))&&r.overlay){let n=e-this.from;for(let{from:e,to:i}of r.overlay)if((t>0?e<=n:e<n)&&(t<0?i>=n:i>n))return new w(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function x(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(null!=n)for(;!i.type.is(n);)if(!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}function k(e,t,n=t.length-1){for(let r=e.parent;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class S{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class C extends b{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new C(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&d.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new C(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new C(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new C(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let o=n.buffer[this.index+1];e.push(n.slice(r,i,o)),t.push(0)}return new p(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function A(e){if(!e.length)return null;if(1==e.length)return e[0];let t=0,n=e[0];for(let o=1;o<e.length;o++){let r=e[o];(r.from>n.from||r.to<n.to)&&(n=r,t=o)}let r=n instanceof w&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new E(i,n)}class E{constructor(e,t){this.heads=e,this.node=t}get next(){return A(this.heads)}}class M{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof w)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return!!e&&(e instanceof w?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&d.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&d.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&d.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&d.IncludeAnonymous||e instanceof g||!e.type.isAnonymous||O(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(let r=n;r<this.stack.length;r++)t=new C(this.buffer,t,this.stack[r]);return this.bufferNode=new C(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return k(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return k(this.node,e,r);let o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function O(e){return e.children.some((e=>e instanceof g||!e.type.isAnonymous||O(e)))}const D=new WeakMap;function I(e,t){if(!e.isAnonymous||t instanceof g||t.type!=e)return 1;let n=D.get(t);if(null==n){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof p)){n=1;break}n+=I(e,r)}D.set(t,n)}return n}function P(e,t,n,r,i,o,s,l,a){let c=0;for(let d=r;d<i;d++)c+=I(e,t[d]);let h=Math.ceil(1.5*c/8),u=[],f=[];return function t(n,r,i,s,l){for(let c=i;c<s;){let i=c,d=r[c],p=I(e,n[c]);for(c++;c<s;c++){let t=I(e,n[c]);if(p+t>=h)break;p+=t}if(c==i+1){if(p>h){let e=n[i];t(e.children,e.positions,0,e.children.length,r[i]+l);continue}u.push(n[i])}else{let t=r[c-1]+n[c-1].length-d;u.push(P(e,n,r,i,c,d,t,null,a))}f.push(d+l-o)}}(t,n,r,i,0),(l||a)(u,f,s)}class T{constructor(e,t,n,r,i=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let r=[new T(0,e.length,e,0,!1,n)];for(let i of t)i.to>e.length&&r.push(i);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],i=1,o=e.length?e[0]:null;for(let s=0,l=0,a=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-l>=n)for(;o&&o.from<h;){let t=o;if(l>=t.from||h<=t.to||a){let e=Math.max(t.from,l)-a,n=Math.min(t.to,h)-a;t=e>=n?null:new T(e,n,t.tree,t.offset+a,s>0,!!c)}if(t&&r.push(t),o.to>h)break;o=i<e.length?e[i++]:null}if(!c)break;l=c.toA,a=c.toA-c.toB}return r}}class B{startParse(e,t,n){return"string"==typeof e&&(e=new R(e)),n=n?n.length?n.map((e=>new o(e.from,e.to))):[new o(0,0)]:[new o(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}}class R{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new s({perNode:!0})}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return i[e](n,n.exports,s),n.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{s.r(l),s.d(l,{basicSetup:()=>h.X,default:()=>m,getStatistics:()=>f.a,minimalSetup:()=>h.w,useCodeMirror:()=>r.U});var e=s(215),t=s(808),n=s(787),r=s(128),i=s(501),o=s(105),a={};for(const s in o)"default"!==s&&(a[s]=()=>o[s]);s.d(l,a);var c=s(242);a={};for(const s in c)"default"!==s&&(a[s]=()=>c[s]);s.d(l,a);var h=s(141),u=s(736);a={};for(const s in u)["default","basicSetup","minimalSetup","useCodeMirror"].indexOf(s)<0&&(a[s]=()=>u[s]);s.d(l,a);var f=s(742),d=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],p=(0,n.forwardRef)((function(o,s){var l=o.className,a=o.value,c=void 0===a?"":a,h=o.selection,u=o.extensions,f=void 0===u?[]:u,p=o.onChange,m=o.onStatistics,g=o.onCreateEditor,y=o.onUpdate,v=o.autoFocus,b=o.theme,w=void 0===b?"light":b,x=o.height,k=o.minHeight,S=o.maxHeight,C=o.width,A=o.minWidth,E=o.maxWidth,M=o.basicSetup,O=o.placeholder,D=o.indentWithTab,I=o.editable,P=o.readOnly,T=o.root,B=o.initialState,R=(0,t.Z)(o,d),N=(0,n.useRef)(null),L=(0,r.U)({container:N.current,root:T,value:c,autoFocus:v,theme:w,height:x,minHeight:k,maxHeight:S,width:C,minWidth:A,maxWidth:E,basicSetup:M,placeholder:O,indentWithTab:D,editable:I,readOnly:P,selection:h,onChange:p,onStatistics:m,onCreateEditor:g,onUpdate:y,extensions:f,initialState:B}),_=L.state,q=L.view,F=L.container;if((0,n.useImperativeHandle)(s,(function(){return{editor:N.current,state:_,view:q}}),[N,F,_,q]),"string"!==typeof c)throw new Error("value must be typeof string but got ".concat(typeof c));var j="string"===typeof w?"cm-theme-".concat(w):"cm-theme";return(0,i.jsx)("div",(0,e.Z)({ref:N,className:"".concat(j).concat(l?" ".concat(l):"")},R))}));p.displayName="CodeMirror";const m=p})(),l})()));