diff --git a/README.md b/README.md index 74e11e4..09bd661 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LITECANVAS PLAYGROUND -Online playground for [litecanvas](https://github.com/litecanvas/game-engine) game engine. +Online playground for [Litecanvas](https://github.com/litecanvas/game-engine) game engine. Try on https://litecanvas.js.org/ diff --git a/package-lock.json b/package-lock.json index a2f2c43..e948c71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,9 +41,9 @@ } }, "node_modules/@codemirror/commands": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.7.0.tgz", - "integrity": "sha512-+cduIZ2KbesDhbykV02K25A5xIVrquSPz4UxxYBemRlAT2aW8dhwUgLDwej7q/RJUHKk4nALYcR1puecDvbdqw==", + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.7.1.tgz", + "integrity": "sha512-llTrboQYw5H4THfhN4U3qCnSZ1SOJ60ohhz+SzU0ADGtwlc533DtklQP0vSFaQuCPDn3BPpOd1GbbnUtwNjsrw==", "dependencies": { "@codemirror/language": "^6.0.0", "@codemirror/state": "^6.4.0", @@ -602,9 +602,9 @@ "integrity": "sha512-y6b2CN2rVTNnc6tYspFt61thfS14E3TPUyxFWJGvPxqNdXXOOlGBI8rM8pTIWlVzUhnHpY9tglk7X14Rj3/yMg==" }, "node_modules/litecanvas": { - "version": "0.63.0", - "resolved": "https://registry.npmjs.org/litecanvas/-/litecanvas-0.63.0.tgz", - "integrity": "sha512-pbWfrcoxzAUCTG+ia88IQMd0MAjyjF9izSrVBWJE5RiRYxgxhEqkvAbLGF1NSMM3CCINPR5O76x6pd6AYWThMw==" + "version": "0.64.0", + "resolved": "https://registry.npmjs.org/litecanvas/-/litecanvas-0.64.0.tgz", + "integrity": "sha512-oz+nQ5O7oKKJj4yQnTixYtjSbyPpala9Urv8qfcpfQVox5Obm76ADnANf8SxJrgBbs0HIydh8nqouM7qGGceAw==" }, "node_modules/pako": { "version": "2.1.0", diff --git a/public/about.html b/public/about.html index 979ec6a..bede57d 100644 --- a/public/about.html +++ b/public/about.html @@ -149,14 +149,11 @@

LITECANVAS

- Lightweight HTML5 canvas engine suitable for small games and animations - for people who enjoy coding: there is no fancy interface, no visual - helpers, no gui tools... just coding. + Litecanvas is a lightweight HTML5 canvas engine suitable for small web games, prototypes, game jams, animations, creative programming, learning game programming and game design, etc. Just install our NPM package or load/download the CDN by adding it as a script tag in your HTML.

-

- NPM: - npm i litecanvas +

+ This project is still under development. All feedback is appreciated! For bugs, suggestions or contribuitions open a issue in our Github Repository.

@@ -166,6 +163,11 @@

LITECANVAS

>

+

+ NPM: + npm install litecanvas +

+

@@ -173,21 +175,20 @@

LITECANVAS

Basic boilerplate

litecanvas({
   loop: {
-    init, update, draw, resized, tap, tapping, untap, tapped
+    init, update, draw, resized,
+    tap, tapping, untap, tapped
   }
 })
 
@@ -206,7 +207,7 @@ 

Basic boilerplate

function resized() { // called when the browser was resized - // always called once before init() + // also called once before init() } function tap(x, y, tapId) { @@ -273,11 +274,12 @@

Game Configuration

settings.width = null settings.height = settings.width || null -// Determines whether the game loop should be paused -// when the "blur" event happens. +// Determines whether the game loop should +// be paused when the "blur" event happens. settings.pauseOnBlur = true -// scale the canvas +// Determines whether the canvas should +// scale to fill the canvas settings.autoscale = true // target FPS @@ -286,10 +288,12 @@

Game Configuration

// enable smooth drawing settings.antialias = false -// disables antialias and force integer scales +// disables antialias +// and force the autoscale to use integers settings.pixelart = false -// export all functions to global scope +// exposes all methods and properties (see below) +// in the global scope settings.global = true // set to `false` to disable the default tap handler @@ -300,6 +304,47 @@

Game Configuration

// useful to create your own keyboard handler settings.keyboardEvents = true
+

Global Variables

+ +
// the game canvas
+CANVAS: HTMLCanvasElement
+
+// the game screen width
+WIDTH: number
+
+// the game screen height
+HEIGHT: number
+
+// the center X of game screen
+CENTERX: number
+
+// the center Y of game screen
+CENTERY: number
+
+// the FPS meter
+FPS: number
+
+// the amount of time since the game started
+ELAPSED: number
+
+// the current mouse's X-position
+// or -1 (if the mouse was not used or detected)
+MOUSEX: number
+
+// the current mouse's Y-position
+// or -1 (if the mouse was not used or detected)
+MOUSEY: number
+
+// the default sound played in `sfx()`
+DEFAULT_SFX: number[]
+
+// Math constants
+PI: number // approximately 3.14 radians (180º)
+
+TWO_PI: number // approximately 6.28 radians (360º)
+
+HALF_PI: number // approximately 1.57 radians (90º)
+

Functions for Drawing

/**
@@ -338,16 +383,16 @@ 

Functions for Drawing

* TEXT DRAWING-RELATED FUNCTIONS */ -// draw a text +// Draw a text text(x, y, text, color? = 3): void -// set the text alignment and baseline +// Sets the text alignment and baseline // default values: align = 'start', baseline = 'top' // see: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign // see: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textBaseline textalign(align: string, baseline: string): void -// set the font family for texts +// Sets the font family for texts textfont(fontName: string): void // Sets the font size (default: 32) @@ -403,30 +448,30 @@

Functions for Drawing

// Adds a rotation to the transformation matrix rotate(radians: number): void -// update the transformation matrix +// Updates the transformation matrix // when `resetFirst = true` uses `context.setTransform()` // see: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform // when `resetFirst = false` uses `context.transform()` // see: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform transform(a, b, c, d, e, f, resetFirst = true): void -// set the alpha (opacity) value to apply when drawing new shapes and images +// Sets the alpha (opacity) value to apply when drawing new shapes and images // see: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalAlpha alpha(value: number): void -// fills the current path +// Fills the current path // see: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fill fill(color: number, path?: Path2D): void -// outlines the current path +// Outlines the current path // see: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/stroke stroke(color: number, path?: Path2D): void -// create (or clone) a Path2D instance +// Create (or clone) a Path2D instance // see: https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path2D path(arg?: Path2D | string): Path2D -// create a clipping region +// Create a clipping region // see: https://github.com/litecanvas/game-engine/blob/main/samples/clip/clip.js // note: before call `clip()` you must save the context using `push()` and `pop()` clipcirc(path: Path2D)
@@ -564,66 +609,9 @@

Math

// Check a collision between two circles. // All arguments are required and must be numbers. -colcirc(x1, y1, r1, x2, y2, r2): boolean +colcirc(x1, y1, r1, x2, y2, r2): boolean -// Sets the scale of the game's delta time (dt). -// By default is equal to 1. -// Values higher than 1 increase the speed of time, -// while values smaller than 1 decrease it. -// A value of 0 freezes time (equivalent to pausing). -timescale(value: number): void - -

Global Variables

- -
// the game canvas
-CANVAS: HTMLCanvasElement
-
-// the game screen width
-WIDTH: number
-
-// the game screen height
-HEIGHT: number
-
-// the center X of game screen
-CENTERX: number
-
-// the center Y of game screen
-CENTERY: number
-
-// the FPS meter
-FPS: number
-
-// the amount of time since the game started
-ELAPSED: number
-
-// the current mouse's X-position
-// or -1 (if the mouse was not used or detected)
-MOUSEX: number
-
-// the current mouse's Y-position
-// or -1 (if the mouse was not used or detected)
-MOUSEY: number
-
-// the default sound played in `sfx()`
-DEFAULT_SFX: number[]
-
-// Math constants
-PI: number // approximately 3.14159 radians (180º)
-
-TWO_PI: number // approximately 6.28318 radians (360º)
-
-HALF_PI: number // approximately 1.57079 radians (90º)
- -

Event Emitter

- -
// Registers a game event callback and
-// returns a function that unregister this callback.
-listen(event: string, callback: Function): Function
-
-// Triggers a game event and call its registered callbacks.
-emit(event: string, arg1?, arg2?, arg3?, arg4?): void
- -

Plugin API

+

Engine API

// Loads a plugin.
 // see: https://github.com/litecanvas/game-engine/blob/main/samples/plugin-basics/plugin-basics.js
@@ -636,9 +624,26 @@ 

Plugin API

// example: getcolor(0) returns "#111" getcolor(index: number): string +// Registers a game event callback and +// returns a function that unregister this callback. +listen(event: string, callback: Function): Function + +// Triggers a game event and call its registered callbacks. +emit(event: string, arg1?, arg2?, arg3?, arg4?): void + // Resizes the game canvas. // Also, emits the "resized" (use `listen` to observe this event). -resize(width: number, height: number): void
+resize(width: number, height: number): void + +// Sets the scale of the game's delta time (dt). +// By default is equal to 1. +// Values higher than 1 increase the speed of time, +// while values smaller than 1 decrease it. +// A value of 0 freezes time (equivalent to pausing). +timescale(value: number): void + +// Sets the target FPS at runtime +setfps(value: number): void

Playground Features

diff --git a/public/app.js b/public/app.js index 5c0027c..2cbc012 100644 --- a/public/app.js +++ b/public/app.js @@ -8,7 +8,7 @@ `,n=r.state.doc.line(n.number+(t?1:-1)),i=r.bidiSpans(n),u=r.visualLineSide(n,!t)}if(o){if(!o(c))return l}else{if(!s)return u;o=s(c)}l=u}}function C3(r,e,t){let s=r.state.charCategorizer(e),n=s(t);return i=>{let a=s(i);return n==zt.Space&&(n=a),n==a}}function w3(r,e,t,s){let n=e.head,i=t?1:-1;if(n==(t?r.state.doc.length:0))return Ze.cursor(n,e.assoc);let a=e.goalColumn,l,o=r.contentDOM.getBoundingClientRect(),u=r.coordsAtPos(n,e.assoc||-1),c=r.documentTop;if(u)a==null&&(a=u.left-o.left),l=i<0?u.top:u.bottom;else{let f=r.viewState.lineBlockAt(n);a==null&&(a=Math.min(o.right-o.left,r.defaultCharacterWidth*(n-f.from))),l=(i<0?f.top:f.bottom)+c}let p=o.left+a,h=s??r.viewState.heightOracle.textHeight>>1;for(let f=0;;f+=10){let d=l+(h+f)*i,m=dC(r,{x:p,y:d},!1,i);if(do.bottom||(i<0?mn)){let g=r.docView.coordsForChar(m),y=!g||d{if(e>i&&en(r)),t.from,e.head>t.from?-1:1);return s==t.from?t:Ze.cursor(s,si)&&this.lineBreak(),n=a}return this.findPointBefore(s,t),this}readTextNode(e){let t=e.nodeValue;for(let s of this.points)s.node==e&&(s.pos=this.text.length+Math.min(s.offset,t.length));for(let s=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,l;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,s),a=this.lineSeparator.length):(l=n.exec(t))&&(i=l.index,a=l[0].length),this.append(t.slice(s,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let o of this.points)o.node==e&&o.pos>this.text.length&&(o.pos-=a-1);s=i+a}}readNode(e){if(e.cmIgnore)return;let t=Xt.get(e),s=t&&t.overrideDOMText;if(s!=null){this.findPointInside(e,s.length);for(let n=s.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let s of this.points)s.node==e&&e.childNodes[s.offset]==t&&(s.pos=this.text.length)}findPointInside(e,t){for(let s of this.points)(e.nodeType==3?s.node==e:e.contains(s.node))&&(s.pos=this.text.length+(k3(e,s.node,s.offset)?t:0))}};function k3(r,e,t){for(;;){if(!e||t-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,s,0))){let l=i||a?[]:T3(e),o=new sp(l,e.state);o.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=o.text,this.newSel=D3(l,this.bounds.from)}else{let l=e.observer.selectionRange,o=i&&i.node==l.focusNode&&i.offset==l.focusOffset||!Uf(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),u=a&&a.node==l.anchorNode&&a.offset==l.anchorOffset||!Uf(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),c=e.viewport;if((ft.ios||ft.chrome)&&e.state.selection.main.empty&&o!=u&&(c.from>0||c.toDate.now()-100?r.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:l}=e.bounds,o=n.from,u=null;(i===8||ft.android&&e.text.length=n.from&&t.to<=n.to&&(t.from!=n.from||t.to!=n.to)&&n.to-n.from-(t.to-t.from)<=4?t={from:n.from,to:n.to,insert:r.state.doc.slice(n.from,t.from).append(t.insert).append(r.state.doc.slice(t.to,n.to))}:(ft.mac||ft.android)&&t&&t.from==t.to&&t.from==n.head-1&&/^\. ?$/.test(t.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(s&&t.insert.length==2&&(s=Ze.single(s.main.anchor-1,s.main.head-1)),t={from:n.from,to:n.to,insert:It.of([" "])}):ft.chrome&&t&&t.from==t.to&&t.from==n.head&&t.insert.toString()==` `&&r.lineWrapping&&(s&&(s=Ze.single(s.main.anchor-1,s.main.head-1)),t={from:n.from,to:n.to,insert:It.of([" "])}),t)return $p(r,t,s,i);if(s&&!s.main.eq(n)){let a=!1,l="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(a=!0),l=r.inputState.lastSelectionOrigin),r.dispatch({selection:s,scrollIntoView:a,userEvent:l}),!0}else return!1}function $p(r,e,t,s=-1){if(ft.ios&&r.inputState.flushIOSKey(e))return!0;let n=r.state.selection.main;if(ft.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&r.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Yi(r.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||s==8&&e.insert.lengthn.head)&&Yi(r.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&Yi(r.contentDOM,"Delete",46)))return!0;let i=e.insert.toString();r.inputState.composing>=0&&r.inputState.composing++;let a,l=()=>a||(a=A3(r,e,t));return r.state.facet(rC).some(o=>o(r,e.from,e.to,i,l))||r.dispatch(l()),!0}function A3(r,e,t){let s,n=r.state,i=n.selection.main;if(e.from>=i.from&&e.to<=i.to&&e.to-e.from>=(i.to-i.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&r.inputState.composing<0){let l=i.frome.to?n.sliceDoc(e.to,i.to):"";s=n.replaceSelection(r.state.toText(l+e.insert.sliceString(0,void 0,r.state.lineBreak)+o))}else{let l=n.changes(e),o=t&&t.main.to<=l.newLength?t.main:void 0;if(n.selection.ranges.length>1&&r.inputState.composing>=0&&e.to<=i.to&&e.to>=i.to-10){let u=r.state.sliceDoc(e.from,e.to),c,p=t&&hC(r,t.main.head);if(p){let d=e.insert.length-(e.to-e.from);c={from:p.from,to:p.to-d}}else c=r.state.doc.lineAt(i.head);let h=i.to-e.to,f=i.to-i.from;s=n.changeByRange(d=>{if(d.from==i.from&&d.to==i.to)return{changes:l,range:o||d.map(l)};let m=d.to-h,g=m-u.length;if(d.to-d.from!=f||r.state.sliceDoc(g,m)!=u||d.to>=c.from&&d.from<=c.to)return{range:d};let y=n.changes({from:g,to:m,insert:e.insert}),v=d.to-i.to;return{changes:y,range:o?Ze.range(Math.max(0,o.anchor+v),Math.max(0,o.head+v)):d.map(y)}})}else s={changes:l,selection:o&&n.selection.replaceRange(o)}}let a="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,a+=".compose",r.inputState.compositionFirstChange&&(a+=".start",r.inputState.compositionFirstChange=!1)),n.update(s,{userEvent:a,scrollIntoView:!0})}function P3(r,e,t,s){let n=Math.min(r.length,e.length),i=0;for(;i0&&l>0&&r.charCodeAt(a-1)==e.charCodeAt(l-1);)a--,l--;if(s=="end"){let o=Math.max(0,i-Math.min(a,l));t-=a+o-i}if(a=a?i-t:0;i-=o,l=i+(l-a),a=i}else if(l=l?i-t:0;i-=o,a=i+(a-l),l=i}return{from:i,toA:a,toB:l}}function T3(r){let e=[];if(r.root.activeElement!=r.contentDOM)return e;let{anchorNode:t,anchorOffset:s,focusNode:n,focusOffset:i}=r.observer.selectionRange;return t&&(e.push(new Zl(t,s)),(n!=t||i!=s)&&e.push(new Zl(n,i))),e}function D3(r,e){if(r.length==0)return null;let t=r[0].pos,s=r.length==2?r[1].pos:t;return t>-1&&s>-1?Ze.single(t+e,s+e):null}var ap=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,ft.safari&&e.contentDOM.addEventListener("input",()=>null),ft.gecko&&z3(e.contentDOM.ownerDocument)}handleEvent(e){!N3(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let s=this.handlers[e];if(s){for(let n of s.observers)n(this.view,t);for(let n of s.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=_3(e),s=this.handlers,n=this.view.contentDOM;for(let i in t)if(i!="scroll"){let a=!t[i].handlers.length,l=s[i];l&&a!=!l.handlers.length&&(n.removeEventListener(i,this.handleEvent),l=null),l||n.addEventListener(i,this.handleEvent,{passive:a})}for(let i in s)i!="scroll"&&!t[i]&&n.removeEventListener(i,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&yC.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),ft.android&&ft.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return ft.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=gC.find(s=>s.keyCode==e.keyCode))&&!e.ctrlKey||I3.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:ft.safari&&!ft.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function sE(r,e){return(t,s)=>{try{return e.call(r,s,t)}catch(n){yr(t.state,n)}}}function _3(r){let e=Object.create(null);function t(s){return e[s]||(e[s]={observers:[],handlers:[]})}for(let s of r){let n=s.spec;if(n&&n.domEventHandlers)for(let i in n.domEventHandlers){let a=n.domEventHandlers[i];a&&t(i).handlers.push(sE(s.value,a))}if(n&&n.domEventObservers)for(let i in n.domEventObservers){let a=n.domEventObservers[i];a&&t(i).observers.push(sE(s.value,a))}}for(let s in bn)t(s).handlers.push(bn[s]);for(let s in on)t(s).observers.push(on[s]);return e}var gC=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],I3="dthko",yC=[16,17,18,20,91,92,224,225],Pl=6;function Tl(r){return Math.max(0,r)*.7+8}function R3(r,e){return Math.max(Math.abs(r.clientX-e.clientX),Math.abs(r.clientY-e.clientY))}var op=class{constructor(e,t,s,n){this.view=e,this.startEvent=t,this.style=s,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=WM(e.contentDOM),this.atoms=e.state.facet(Np).map(a=>a(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Vt.allowMultipleSelections)&&F3(e,t),this.dragging=L3(e,t)&&xC(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&R3(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,s=0,n=0,i=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:l}=this.scrollParents.y.getBoundingClientRect());let o=pC(this.view);e.clientX-o.left<=n+Pl?t=-Tl(n-e.clientX):e.clientX+o.right>=a-Pl&&(t=Tl(e.clientX-a)),e.clientY-o.top<=i+Pl?s=-Tl(i-e.clientY):e.clientY+o.bottom>=l-Pl&&(s=Tl(e.clientY-l)),this.setScrollSpeed(t,s)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let s=0;st.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function F3(r,e){let t=r.state.facet(KE);return t.length?t[0](e):ft.mac?e.metaKey:e.ctrlKey}function B3(r,e){let t=r.state.facet(JE);return t.length?t[0](e):ft.mac?!e.altKey:!e.ctrlKey}function L3(r,e){let{main:t}=r.state.selection;if(t.empty)return!1;let s=po(r.root);if(!s||s.rangeCount==0)return!0;let n=s.getRangeAt(0).getClientRects();for(let i=0;i=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function N3(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,s;t!=r.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(s=Xt.get(t))&&s.ignoreEvent(e))return!1;return!0}var bn=Object.create(null),on=Object.create(null),bC=ft.ie&&ft.ie_version<15||ft.ios&&ft.webkit_version<604;function $3(r){let e=r.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{r.focus(),t.remove(),vC(r,t.value)},50)}function iu(r,e,t){for(let s of r.facet(e))t=s(t,r);return t}function vC(r,e){e=iu(r.state,Bp,e);let{state:t}=r,s,n=1,i=t.toText(e),a=i.lines==t.selection.ranges.length;if(lp!=null&&t.selection.ranges.every(o=>o.empty)&&lp==i.toString()){let o=-1;s=t.changeByRange(u=>{let c=t.doc.lineAt(u.from);if(c.from==o)return{range:u};o=c.from;let p=t.toText((a?i.line(n++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:p},range:Ze.cursor(u.from+p.length)}})}else a?s=t.changeByRange(o=>{let u=i.line(n++);return{changes:{from:o.from,to:o.to,insert:u.text},range:Ze.cursor(o.from+u.length)}}):s=t.replaceSelection(i);r.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}on.scroll=r=>{r.inputState.lastScrollTop=r.scrollDOM.scrollTop,r.inputState.lastScrollLeft=r.scrollDOM.scrollLeft};bn.keydown=(r,e)=>(r.inputState.setSelectionOrigin("select"),e.keyCode==27&&r.inputState.tabFocusMode!=0&&(r.inputState.tabFocusMode=Date.now()+2e3),!1);on.touchstart=(r,e)=>{r.inputState.lastTouchTime=Date.now(),r.inputState.setSelectionOrigin("select.pointer")};on.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};bn.mousedown=(r,e)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let s of r.state.facet(eC))if(t=s(r,e),t)break;if(!t&&e.button==0&&(t=q3(r,e)),t){let s=!r.hasFocus;r.inputState.startMouseSelection(new op(r,e,t,s)),s&&r.observer.ignore(()=>{FE(r.contentDOM);let i=r.root.activeElement;i&&!i.contains(r.contentDOM)&&i.blur()});let n=r.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}return!1};function iE(r,e,t,s){if(s==1)return Ze.cursor(e,t);if(s==2)return b3(r.state,e,t);{let n=Or.find(r.docView,e),i=r.state.doc.lineAt(n?n.posAtEnd:e),a=n?n.posAtStart:i.from,l=n?n.posAtEnd:i.to;return le>=t.top&&e<=t.bottom&&r>=t.left&&r<=t.right;function M3(r,e,t,s){let n=Or.find(r.docView,e);if(!n)return 1;let i=e-n.posAtStart;if(i==0)return 1;if(i==n.length)return-1;let a=n.coordsAt(i,-1);if(a&&aE(t,s,a))return-1;let l=n.coordsAt(i,1);return l&&aE(t,s,l)?1:a&&a.bottom>=s?-1:1}function oE(r,e){let t=r.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:M3(r,t,e.clientX,e.clientY)}}var j3=ft.ie&&ft.ie_version<=11,lE=null,uE=0,cE=0;function xC(r){if(!j3)return r.detail;let e=lE,t=cE;return lE=r,cE=Date.now(),uE=!e||t>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(uE+1)%3:1}function q3(r,e){let t=oE(r,e),s=xC(e),n=r.state.selection;return{update(i){i.docChanged&&(t.pos=i.changes.mapPos(t.pos),n=n.map(i.changes))},get(i,a,l){let o=oE(r,i),u,c=iE(r,o.pos,o.bias,s);if(t.pos!=o.pos&&!a){let p=iE(r,t.pos,t.bias,s),h=Math.min(p.from,c.from),f=Math.max(p.to,c.to);c=h1&&(u=Q3(n,o.pos))?u:l?n.addRange(c):Ze.create([c])}}}function Q3(r,e){for(let t=0;t=e)return Ze.create(r.ranges.slice(0,t).concat(r.ranges.slice(t+1)),r.mainIndex==t?0:r.mainIndex-(r.mainIndex>t?1:0))}return null}bn.dragstart=(r,e)=>{let{selection:{main:t}}=r.state;if(e.target.draggable){let n=r.docView.nearest(e.target);if(n&&n.isWidget){let i=n.posAtStart,a=i+n.length;(i>=t.to||a<=t.from)&&(t=Ze.range(i,a))}}let{inputState:s}=r;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",iu(r.state,Lp,r.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};bn.dragend=r=>(r.inputState.draggedContent=null,!1);function fE(r,e,t,s){if(t=iu(r.state,Bp,t),!t)return;let n=r.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:i}=r.inputState,a=s&&i&&B3(r,e)?{from:i.from,to:i.to}:null,l={from:n,insert:t},o=r.state.changes(a?[a,l]:l);r.focus(),r.dispatch({changes:o,selection:{anchor:o.mapPos(n,-1),head:o.mapPos(n,1)},userEvent:a?"move.drop":"input.drop"}),r.inputState.draggedContent=null}bn.drop=(r,e)=>{if(!e.dataTransfer)return!1;if(r.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let s=Array(t.length),n=0,i=()=>{++n==t.length&&fE(r,e,s.filter(a=>a!=null).join(r.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(s[a]=l.result),i()},l.readAsText(t[a])}return!0}else{let s=e.dataTransfer.getData("Text");if(s)return fE(r,e,s,!0),!0}return!1};bn.paste=(r,e)=>{if(r.state.readOnly)return!0;r.observer.flush();let t=bC?null:e.clipboardData;return t?(vC(r,t.getData("text/plain")||t.getData("text/uri-list")),!0):($3(r),!1)};function V3(r,e){let t=r.dom.parentNode;if(!t)return;let s=t.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=e,s.focus(),s.selectionEnd=e.length,s.selectionStart=0,setTimeout(()=>{s.remove(),r.focus()},50)}function U3(r){let e=[],t=[],s=!1;for(let n of r.selection.ranges)n.empty||(e.push(r.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:i}of r.selection.ranges){let a=r.doc.lineAt(i);a.number>n&&(e.push(a.text),t.push({from:a.from,to:Math.min(r.doc.length,a.to+1)})),n=a.number}s=!0}return{text:iu(r,Lp,e.join(r.lineBreak)),ranges:t,linewise:s}}var lp=null;bn.copy=bn.cut=(r,e)=>{let{text:t,ranges:s,linewise:n}=U3(r.state);if(!t&&!n)return!1;lp=n?t:null,e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let i=bC?null:e.clipboardData;return i?(i.clearData(),i.setData("text/plain",t),!0):(V3(r,t),!1)};var OC=Mr.define();function SC(r,e){let t=[];for(let s of r.facet(nC)){let n=s(r,e);n&&t.push(n)}return t?r.update({effects:t,annotations:OC.of(!0)}):null}function EC(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let t=SC(r.state,e);t?r.dispatch(t):r.update([])}},10)}on.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),EC(r)};on.blur=r=>{r.observer.clearSelectionRange(),EC(r)};on.compositionstart=on.compositionupdate=r=>{r.observer.editContext||(r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0&&(r.inputState.composing=0))};on.compositionend=r=>{r.observer.editContext||(r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,ft.chrome&&ft.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50))};on.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};bn.beforeinput=(r,e)=>{var t,s;if(e.inputType=="insertReplacementText"&&r.observer.editContext){let i=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),a=e.getTargetRanges();if(i&&a.length){let l=a[0],o=r.posAtDOM(l.startContainer,l.startOffset),u=r.posAtDOM(l.endContainer,l.endOffset);return $p(r,{from:o,to:u,insert:r.state.toText(i)},null),!0}}let n;if(ft.chrome&&ft.android&&(n=gC.find(i=>i.inputType==e.inputType))&&(r.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let i=((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>i+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}return ft.ios&&e.inputType=="deleteContentForward"&&r.observer.flushSoon(),ft.safari&&e.inputType=="insertText"&&r.inputState.composing>=0&&setTimeout(()=>on.compositionend(r,e),20),!1};var pE=new Set;function z3(r){pE.has(r)||(pE.add(r),r.addEventListener("copy",()=>{}),r.addEventListener("cut",()=>{}))}var hE=["pre-wrap","normal","pre-line","break-spaces"],Hi=!1;function dE(){Hi=!1}var up=class{constructor(e){this.lineWrapping=e,this.doc=It.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let s=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(s+=Math.max(0,Math.ceil((t-e-s*this.lineLength*.5)/this.lineLength))),this.lineHeight*s}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return hE.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let s=0;s-1,o=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=s,this.textHeight=n,this.lineLength=i,o){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Nl&&(Hi=!0),this.height=e)}replace(e,t,s){return r.of(s)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,s,n){let i=this,a=s.doc;for(let l=n.length-1;l>=0;l--){let{fromA:o,toA:u,fromB:c,toB:p}=n[l],h=i.lineAt(o,Ht.ByPosNoHeight,s.setDoc(t),0,0),f=h.to>=u?h:i.lineAt(u,Ht.ByPosNoHeight,s,0,0);for(p+=f.to-u,u=f.to;l>0&&h.from<=n[l-1].toA;)o=n[l-1].fromA,c=n[l-1].fromB,l--,oi*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),s+=1+l.break,n-=l.size}else if(i>n*2){let l=e[s];l.break?e.splice(s,1,l.left,null,l.right):e.splice(s,1,l.left,l.right),s+=2+l.break,i-=l.size}else break;else if(n=i&&a(this.blockAt(0,s,n,i))}updateHeight(e,t=0,s=!1,n){return n&&n.from<=t&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},sn=class r extends Gl{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,s,n){return new Ln(n,this.length,s,this.height,this.breaks)}replace(e,t,s){let n=s[0];return s.length==1&&(n instanceof r||n instanceof As&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof As?n=new r(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Gr.of(s)}updateHeight(e,t=0,s=!1,n){return n&&n.from<=t&&n.more?this.setHeight(n.heights[n.index++]):(s||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},As=class r extends Gr{constructor(e){super(e,0)}heightMetrics(e,t){let s=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,i=n-s+1,a,l=0;if(e.lineWrapping){let o=Math.min(this.height,e.lineHeight*i);a=o/i,this.length>i+1&&(l=(this.height-o)/(this.length-i-1))}else a=this.height/i;return{firstLine:s,lastLine:n,perLine:a,perChar:l}}blockAt(e,t,s,n){let{firstLine:i,lastLine:a,perLine:l,perChar:o}=this.heightMetrics(t,n);if(t.lineWrapping){let u=n+(e0){let i=s[s.length-1];i instanceof r?s[s.length-1]=new r(i.length+n):s.push(null,new r(n-1))}if(e>0){let i=s[0];i instanceof r?s[0]=new r(e+i.length):s.unshift(new r(e-1),null)}return Gr.of(s)}decomposeLeft(e,t){t.push(new r(e-1),null)}decomposeRight(e,t){t.push(null,new r(this.length-e-1))}updateHeight(e,t=0,s=!1,n){let i=t+this.length;if(n&&n.from<=t+this.length&&n.more){let a=[],l=Math.max(t,n.from),o=-1;for(n.from>t&&a.push(new r(n.from-t-1).updateHeight(e,t));l<=i&&n.more;){let c=e.doc.lineAt(l).length;a.length&&a.push(null);let p=n.heights[n.index++];o==-1?o=p:Math.abs(p-o)>=Nl&&(o=-2);let h=new sn(c,p);h.outdated=!1,a.push(h),l+=c+1}l<=i&&a.push(null,new r(i-l).updateHeight(e,l));let u=Gr.of(a);return(o<0||Math.abs(u.height-this.height)>=Nl||Math.abs(o-this.heightMetrics(e,t).perLine)>=Nl)&&(Hi=!0),Wl(this,u)}else(s||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},fp=class extends Gr{constructor(e,t,s){super(e.length+t+s.length,e.height+s.height,t|(e.outdated||s.outdated?2:0)),this.left=e,this.right=s,this.size=e.size+s.size}get break(){return this.flags&1}blockAt(e,t,s,n){let i=s+this.left.height;return el))return u;let c=t==Ht.ByPosNoHeight?Ht.ByPosNoHeight:Ht.ByPos;return o?u.join(this.right.lineAt(l,c,s,a,l)):this.left.lineAt(l,c,s,n,i).join(u)}forEachLine(e,t,s,n,i,a){let l=n+this.left.height,o=i+this.left.length+this.break;if(this.break)e=o&&this.right.forEachLine(e,t,s,l,o,a);else{let u=this.lineAt(o,Ht.ByPos,s,n,i);e=e&&u.from<=t&&a(u),t>u.to&&this.right.forEachLine(u.to+1,t,s,l,o,a)}}replace(e,t,s){let n=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,s));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let l of s)i.push(l);if(e>0&&mE(i,a-1),t=s&&t.push(null)),e>s&&this.right.decomposeLeft(e-s,t)}decomposeRight(e,t){let s=this.left.length,n=s+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e2*t.size||t.size>2*e.size?Gr.of(this.break?[e,null,t]:[e,t]):(this.left=Wl(this.left,e),this.right=Wl(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,s=!1,n){let{left:i,right:a}=this,l=t+i.length+this.break,o=null;return n&&n.from<=t+i.length&&n.more?o=i=i.updateHeight(e,t,s,n):i.updateHeight(e,t,s),n&&n.from<=l+a.length&&n.more?o=a=a.updateHeight(e,l,s,n):a.updateHeight(e,l,s),o?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function mE(r,e){let t,s;r[e]==null&&(t=r[e-1])instanceof As&&(s=r[e+1])instanceof As&&r.splice(e-1,3,new As(t.length+1+s.length))}var Z3=5,pp=class r{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let s=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof sn?n.length+=s-this.pos:(s>this.pos||!this.isCovered)&&this.nodes.push(new sn(s-this.pos,-1)),this.writtenTo=s,t>s&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,s){if(e=Z3)&&this.addLineDeco(n,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new sn(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let s=new As(t-e);return this.oracle.doc.lineAt(e).to==t&&(s.flags|=4),s}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof sn)return e;let t=new sn(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,s){let n=this.ensureLine();n.length+=s,n.collapsed+=s,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+s}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof sn)&&!this.isCovered?this.nodes.push(new sn(0,-1)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&p.overflow!="visible"){let h=c.getBoundingClientRect();i=Math.max(i,h.left),a=Math.min(a,h.right),l=Math.max(l,h.top),o=Math.min(u==r.parentNode?n.innerHeight:o,h.bottom)}u=p.position=="absolute"||p.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:i-t.left,right:Math.max(i,a)-t.left,top:l-(t.top+e),bottom:Math.max(l,o)-(t.top+e)}}function X3(r,e){let t=r.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var uo=class{constructor(e,t,s,n){this.from=e,this.to=t,this.size=s,this.displaySize=n}static same(e,t){if(e.length!=t.length)return!1;for(let s=0;stypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new up(t),this.stateDeco=e.facet(xo).filter(s=>typeof s!="function"),this.heightMap=Gr.empty().applyChanges(this.stateDeco,It.empty,this.heightOracle.setDoc(e.doc),[new $n(0,0,0,e.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=yt.set(this.lineGaps.map(s=>s.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let s=0;s<=1;s++){let n=s?t.head:t.anchor;if(!e.some(({from:i,to:a})=>n>=i&&n<=a)){let{from:i,to:a}=this.lineBlockAt(n);e.push(new Wi(i,a))}}return this.viewports=e.sort((s,n)=>s.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?gE:new mp(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(no(e,this.scaler))})}update(e,t=null){this.state=e.state;let s=this.stateDeco;this.stateDeco=this.state.facet(xo).filter(c=>typeof c!="function");let n=e.changedRanges,i=$n.extendWithRanges(n,W3(s,this.stateDeco,e?e.changes:Dr.empty(this.state.doc.length))),a=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);dE(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||Hi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let o=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heado.to)||!this.viewportIsAppropriate(o))&&(o=this.getViewport(0,t));let u=o.from!=this.viewport.from||o.to!=this.viewport.to;this.viewport=o,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(iC)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,s=window.getComputedStyle(t),n=this.heightOracle,i=s.whiteSpace;this.defaultTextDirection=s.direction=="rtl"?Zt.RTL:Zt.LTR;let a=this.heightOracle.mustRefreshForWrapping(i),l=t.getBoundingClientRect(),o=a||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:S,scaleY:C}=RE(t,l);(S>.005&&Math.abs(this.scaleX-S)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=S,this.scaleY=C,u|=8,a=o=!0)}let p=(parseInt(s.paddingTop)||0)*this.scaleY,h=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=p||this.paddingBottom!=h)&&(this.paddingTop=p,this.paddingBottom=h,u|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(o=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=8);let f=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=f&&(this.scrollAnchorHeight=-1,this.scrollTop=f),this.scrolledToBottom=LE(e.scrollDOM);let d=(this.printing?X3:G3)(t,this.paddingTop),m=d.top-this.pixelViewport.top,g=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(o=!0)),!this.inView&&!this.scrollTarget)return 0;let v=l.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=8),o){let S=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(S)&&(a=!0),a||n.lineWrapping&&Math.abs(v-this.contentDOMWidth)>n.charWidth){let{lineHeight:C,charWidth:O,textHeight:w}=e.docView.measureTextSize();a=C>0&&n.refresh(i,C,O,w,v/O,S),a&&(e.docView.minWidth=0,u|=8)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),dE();for(let C of this.viewports){let O=C.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(C);this.heightMap=(a?Gr.empty().applyChanges(this.stateDeco,It.empty,this.heightOracle,[new $n(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,a,new cp(C.from,O))}Hi&&(u|=2)}let x=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return x&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let s=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:l}=this,o=new Wi(n.lineAt(a-s*1e3,Ht.ByHeight,i,0,0).from,n.lineAt(l+(1-s)*1e3,Ht.ByHeight,i,0,0).to);if(t){let{head:u}=t.range;if(uo.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),p=n.lineAt(u,Ht.ByPos,i,0,0),h;t.y=="center"?h=(p.top+p.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&u=l+Math.max(10,Math.min(s,250)))&&n>a-2*1e3&&i>1,a=n<<1;if(this.defaultTextDirection!=Zt.LTR&&!s)return[];let l=[],o=(c,p,h,f)=>{if(p-cc&&yy.from>=h.from&&y.to<=h.to&&Math.abs(y.from-c)y.fromv));if(!g){if(px.from<=p&&x.to>=p)){let x=t.moveToLineBoundary(Ze.cursor(p),!1,!0).head;x>c&&(p=x)}let y=this.gapSize(h,c,p,f),v=s||y<2e6?y:2e6;g=new uo(c,p,y,v)}l.push(g)},u=c=>{if(c.length2e6)for(let O of e)O.from>=c.from&&O.fromc.from&&o(c.from,f,c,p),dt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];Mt.spans(e,this.viewport.from,this.viewport.to,{span(n,i){t.push({from:n,to:i})},point(){}},20);let s=t.length!=this.visibleRanges.length||this.visibleRanges.some((n,i)=>n.from!=t[i].from||n.to!=t[i].to);return this.visibleRanges=t,s?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||no(this.heightMap.lineAt(e,Ht.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||no(this.heightMap.lineAt(this.scaler.fromDOM(e),Ht.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return no(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Wi=class{constructor(e,t){this.from=e,this.to=t}};function Y3(r,e,t){let s=[],n=r,i=0;return Mt.spans(t,r,e,{span(){},point(a,l){a>n&&(s.push({from:n,to:a}),i+=a-n),n=l}},20),n=1)return e[e.length-1].to;let s=Math.floor(r*t);for(let n=0;;n++){let{from:i,to:a}=e[n],l=a-i;if(s<=l)return i+s;s-=l}}function _l(r,e){let t=0;for(let{from:s,to:n}of r.ranges){if(e<=n){t+=e-s;break}t+=n-s}return t/r.total}function H3(r,e){for(let t of r)if(e(t))return t}var gE={toDOM(r){return r},fromDOM(r){return r},scale:1,eq(r){return r==this}},mp=class r{constructor(e,t,s){let n=0,i=0,a=0;this.viewports=s.map(({from:l,to:o})=>{let u=t.lineAt(l,Ht.ByPos,e,0,0).top,c=t.lineAt(o,Ht.ByPos,e,0,0).bottom;return n+=c-u,{from:l,to:o,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let l of this.viewports)l.domTop=a+(l.top-i)*this.scale,a=l.domBottom=l.domTop+(l.bottom-l.top),i=l.bottom}toDOM(e){for(let t=0,s=0,n=0;;t++){let i=tt.from==e.viewports[s].from&&t.to==e.viewports[s].to):!1}};function no(r,e){if(e.scale==1)return r;let t=e.toDOM(r.top),s=e.toDOM(r.bottom);return new Ln(r.from,r.length,t,s-t,Array.isArray(r._content)?r._content.map(n=>no(n,e)):r._content)}var Il=ut.define({combine:r=>r.join(" ")}),gp=ut.define({combine:r=>r.indexOf(!0)>-1}),yp=nn.newName(),CC=nn.newName(),wC=nn.newName(),kC={"&light":"."+CC,"&dark":"."+wC};function bp(r,e,t){return new nn(e,{finish(s){return/&/.test(s)?s.replace(/&\w*/,n=>{if(n=="&")return r;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):r+" "+s}})}var K3=bp("."+yp,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},kC),J3={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},jf=ft.ie&&ft.ie_version<=11,vp=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new zf,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let s of t)this.queue.push(s);(ft.ie&&ft.ie_version<=11||ft.ios&&e.composing)&&t.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(ft.chrome&&ft.chrome_version<126)&&(this.editContext=new xp(e),e.state.facet(ws)&&(e.contentDOM.editContext=this.editContext.editContext)),jf&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,s)=>t!=e[s]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:s}=this,n=this.selectionRange;if(s.state.facet(ws)?s.root.activeElement!=this.dom:!Bl(this.dom,n))return;let i=n.anchorNode&&s.docView.nearest(n.anchorNode);if(i&&i.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(ft.ie&&ft.ie_version<=11||ft.android&&ft.chrome)&&!s.state.selection.main.empty&&n.focusNode&&io(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=po(e.root);if(!t)return!1;let s=ft.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&ej(this.view,t)||t;if(!s||this.selectionRange.eq(s))return!1;let n=Bl(this.dom,s);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let i=this.delayedAndroidKey;i&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=i.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&i.force&&Yi(this.dom,i.key,i.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,s=-1,n=!1;for(let i of e){let a=this.readMutation(i);a&&(a.typeOver&&(n=!0),t==-1?{from:t,to:s}=a:(t=Math.min(a.from,t),s=Math.max(a.to,s)))}return{from:t,to:s,typeOver:n}}readChange(){let{from:e,to:t,typeOver:s}=this.processRecords(),n=this.selectionChanged&&Bl(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new ip(this.view,e,t,s);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let s=this.view.state,n=mC(this.view,t);return this.view.state==s&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let s=yE(t,e.previousSibling||e.target.previousSibling,-1),n=yE(t,e.nextSibling||e.target.nextSibling,1);return{from:s?t.posAfter(s):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(ws)!=e.state.facet(ws)&&(e.view.contentDOM.editContext=e.state.facet(ws)?this.editContext.editContext:null))}destroy(){var e,t,s;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(s=this.resizeScroll)===null||s===void 0||s.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function yE(r,e,t){for(;e;){let s=Xt.get(e);if(s&&s.parent==r)return s;let n=e.parentNode;e=n!=r.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function bE(r,e){let t=e.startContainer,s=e.startOffset,n=e.endContainer,i=e.endOffset,a=r.docView.domAtPos(r.state.selection.main.anchor);return io(a.node,a.offset,n,i)&&([t,s,n,i]=[n,i,t,s]),{anchorNode:t,anchorOffset:s,focusNode:n,focusOffset:i}}function ej(r,e){if(e.getComposedRanges){let n=e.getComposedRanges(r.root)[0];if(n)return bE(r,n)}let t=null;function s(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return r.contentDOM.addEventListener("beforeinput",s,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",s,!0),t?bE(r,t):null}var xp=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=s=>{let{anchor:n}=e.state.selection.main,i={from:this.toEditorPos(s.updateRangeStart),to:this.toEditorPos(s.updateRangeEnd),insert:It.of(s.text.split(` `))};i.from==this.from&&nthis.to&&(i.to=n),!(i.from==i.to&&!i.insert.length)&&(this.pendingContextChange=i,e.state.readOnly||$p(e,i,Ze.single(this.toEditorPos(s.selectionStart),this.toEditorPos(s.selectionEnd))),this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)))},this.handlers.characterboundsupdate=s=>{let n=[],i=null;for(let a=this.toEditorPos(s.rangeStart),l=this.toEditorPos(s.rangeEnd);a{let n=[];for(let i of s.getTextFormats()){let a=i.underlineStyle,l=i.underlineThickness;if(a!="None"&&l!="None"){let o=`text-decoration: underline ${a=="Dashed"?"dashed ":a=="Squiggle"?"wavy ":""}${l=="Thin"?1:2}px`;n.push(yt.mark({attributes:{style:o}}).range(this.toEditorPos(i.rangeStart),this.toEditorPos(i.rangeEnd)))}}e.dispatch({effects:oC.of(yt.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null};for(let s in this.handlers)t.addEventListener(s,this.handlers[s]);this.measureReq={read:s=>{this.editContext.updateControlBounds(s.contentDOM.getBoundingClientRect());let n=po(s.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,s=!1,n=this.pendingContextChange;return e.changes.iterChanges((i,a,l,o,u)=>{if(s)return;let c=u.length-(a-i);if(n&&a>=n.to)if(n.from==i&&n.to==a&&n.insert.eq(u)){n=this.pendingContextChange=null,t+=c,this.to+=c;return}else n=null,this.revertPending(e.state);if(i+=t,a+=t,a<=this.from)this.from+=c,this.to+=c;else if(ithis.to||this.to-this.from+u.length>3e4){s=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),u.toString()),this.to+=c}t+=c}),n&&!s&&this.revertPending(e.state),!s}update(e){let t=this.pendingContextChange;!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,s=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=s||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(s,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},at=class r{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:s}=e;this.dispatchTransactions=e.dispatchTransactions||s&&(n=>n.forEach(i=>s(i,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||GM(e.parent)||document,this.viewState=new Xl(e.state||Vt.create(e)),e.scrollTo&&e.scrollTo.is(Al)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(eo).map(n=>new lo(n));for(let n of this.plugins)n.update(this);this.observer=new vp(this),this.inputState=new ap(this),this.inputState.ensureHandlers(this.plugins),this.docView=new zl(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof lr?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,s=!1,n,i=this.state;for(let h of e){if(h.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=h.state}if(this.destroyed){this.viewState.state=i;return}let a=this.hasFocus,l=0,o=null;e.some(h=>h.annotation(OC))?(this.inputState.notifiedFocused=a,l=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,o=SC(i,a),o||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(c=null)):this.observer.clear(),i.facet(Vt.phrases)!=this.state.facet(Vt.phrases))return this.setState(i);n=Ul.create(this,i,e),n.flags|=l;let p=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(p&&(p=p.map(h.changes)),h.scrollIntoView){let{main:f}=h.state.selection;p=new oo(f.empty?f:Ze.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of h.effects)f.is(Al)&&(p=f.value.clip(this.state))}this.viewState.update(n,p),this.bidiCache=Yl.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(to)!=this.styleModules&&this.mountStyles(),s=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(Il)!=n.state.facet(Il)&&(this.viewState.mustMeasureContent=!0),(t||s||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let h of this.state.facet(tp))try{h(n)}catch(f){yr(this.state,f,"update listener")}(o||c)&&Promise.resolve().then(()=>{o&&this.state==o.startState&&this.dispatch(o),c&&!mC(this,c)&&u.force&&Yi(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let s of this.plugins)s.destroy(this);this.viewState=new Xl(e),this.plugins=e.facet(eo).map(s=>new lo(s)),this.pluginMap.clear();for(let s of this.plugins)s.update(this);this.docView.destroy(),this.docView=new zl(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(eo),s=e.state.facet(eo);if(t!=s){let n=[];for(let i of s){let a=t.indexOf(i);if(a<0)n.push(new lo(i));else{let l=this.plugins[a];l.mustUpdate=e,n.push(l)}}for(let i of this.plugins)i.mustUpdate!=e&&i.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,s=this.scrollDOM,n=s.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(a<0)if(LE(s))i=-1,a=this.viewState.heightMap.height;else{let f=this.viewState.scrollAnchorAt(n);i=f.from,a=f.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];o&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(f=>{try{return f.read(this)}catch(d){return yr(this.state,d),vE}}),p=Ul.create(this,this.state,[]),h=!1;p.flags|=o,t?t.flags|=o:t=p,this.updateState=2,p.empty||(this.updatePlugins(p),this.inputState.update(p),this.updateAttrs(),h=this.docView.update(p),h&&this.docViewUpdate());for(let f=0;f1||d<-1){n=n+d,s.scrollTop=n/this.scaleY,a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(tp))l(t)}get themeClasses(){return yp+" "+(this.state.facet(gp)?wC:CC)+" "+this.state.facet(Il)}updateAttrs(){let e=xE(this,lC,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ws)?"true":"false",class:"cm-content",style:`${ft.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),xE(this,su,t);let s=this.observer.ignore(()=>{let n=Yf(this.contentDOM,this.contentAttrs,t),i=Yf(this.dom,this.editorAttrs,e);return n||i});return this.editorAttrs=e,this.contentAttrs=t,s}showAnnouncements(e){let t=!0;for(let s of e)for(let n of s.effects)if(n.is(r.announce)){t&&(this.announceDOM.textContent=""),t=!1;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(to);let e=this.state.facet(r.cspNonce);nn.mount(this.root,this.styleModules.concat(K3).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ts.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,s){return Mf(this,e,nE(this,e,t,s))}moveByGroup(e,t){return Mf(this,e,nE(this,e,t,s=>C3(this,e.head,s)))}visualLineSide(e,t){let s=this.bidiSpans(e),n=this.textDirectionAt(e.from),i=s[t?s.length-1:0];return Ze.cursor(i.side(t,n)+e.from,i.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,s=!0){return E3(this,e,t,s)}moveVertically(e,t,s){return Mf(this,e,w3(this,e,t,s))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),dC(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let s=this.docView.coordsAt(e,t);if(!s||s.left==s.right)return s;let n=this.state.doc.lineAt(e),i=this.bidiSpans(n),a=i[Nn.find(i,e-n.from,-1,t)];return ru(s,a.dir==Zt.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(sC)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>tj)return YE(e.length);let t=this.textDirectionAt(e.from),s;for(let i of this.bidiCache)if(i.from==e.from&&i.dir==t&&(i.fresh||XE(i.isolates,s=K1(this,e))))return i.order;s||(s=K1(this,e));let n=o3(e.text,t,s);return this.bidiCache.push(new Yl(e.from,e.to,t,s,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||ft.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{FE(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Al.of(new oo(typeof e=="number"?Ze.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,s=this.viewState.scrollAnchorAt(e);return Al.of(new oo(Ze.cursor(s.from),"start","start",s.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return rr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return rr.define(()=>({}),{eventObservers:e})}static theme(e,t){let s=nn.newName(),n=[Il.of(s),to.of(bp(`.${s}`,e))];return t&&t.dark&&n.push(gp.of(!0)),n}static baseTheme(e){return rn.lowest(to.of(bp("."+yp,e,kC)))}static findFromDOM(e){var t;let s=e.querySelector(".cm-content"),n=s&&Xt.get(s)||Xt.get(e);return((t=n?.rootView)===null||t===void 0?void 0:t.view)||null}};at.styleModule=to;at.inputHandler=rC;at.clipboardInputFilter=Bp;at.clipboardOutputFilter=Lp;at.scrollHandler=aC;at.focusChangeEffect=nC;at.perLineTextDirection=sC;at.exceptionSink=tC;at.updateListener=tp;at.editable=ws;at.mouseSelectionStyle=eC;at.dragMovesSelection=JE;at.clickAddsSelectionRange=KE;at.decorations=xo;at.outerDecorations=uC;at.atomicRanges=Np;at.bidiIsolatedRanges=cC;at.scrollMargins=fC;at.darkTheme=gp;at.cspNonce=ut.define({combine:r=>r.length?r[0]:""});at.contentAttributes=su;at.editorAttributes=lC;at.lineWrapping=at.contentAttributes.of({class:"cm-lineWrapping"});at.announce=Et.define();var tj=4096,vE={},Yl=class r{constructor(e,t,s,n,i,a){this.from=e,this.to=t,this.dir=s,this.isolates=n,this.fresh=i,this.order=a}static update(e,t){if(t.empty&&!e.some(i=>i.fresh))return e;let s=[],n=e.length?e[e.length-1].dir:Zt.LTR;for(let i=Math.max(0,e.length-10);i=0;n--){let i=s[n],a=typeof i=="function"?i(r):i;a&&Xf(a,t)}return t}var rj=ft.mac?"mac":ft.windows?"win":ft.linux?"linux":"key";function nj(r,e){let t=r.split(/-(?!$)/),s=t[t.length-1];s=="Space"&&(s=" ");let n,i,a,l;for(let o=0;os.concat(n),[]))),t}function PC(r,e,t){return TC(AC(r.state),e,r,t)}var ks=null,ij=4e3;function aj(r,e=rj){let t=Object.create(null),s=Object.create(null),n=(a,l)=>{let o=s[a];if(o==null)s[a]=l;else if(o!=l)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},i=(a,l,o,u,c)=>{var p,h;let f=t[a]||(t[a]=Object.create(null)),d=l.split(/ (?!$)/).map(y=>nj(y,e));for(let y=1;y{let S=ks={view:x,prefix:v,scope:a};return setTimeout(()=>{ks==S&&(ks=null)},ij),!0}]})}let m=d.join(" ");n(m,!1);let g=f[m]||(f[m]={preventDefault:!1,stopPropagation:!1,run:((h=(p=f._any)===null||p===void 0?void 0:p.run)===null||h===void 0?void 0:h.slice())||[]});o&&g.run.push(o),u&&(g.preventDefault=!0),c&&(g.stopPropagation=!0)};for(let a of r){let l=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let u of l){let c=t[u]||(t[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:p}=a;for(let h in c)c[h].run.push(f=>p(f,Op))}let o=a[e]||a.key;if(o)for(let u of l)i(u,o,a.run,a.preventDefault,a.stopPropagation),a.shift&&i(u,"Shift-"+o,a.shift,a.preventDefault,a.stopPropagation)}return t}var Op=null;function TC(r,e,t,s){Op=e;let n=U1(e),i=gr(n,0),a=$r(i)==n.length&&n!=" ",l="",o=!1,u=!1,c=!1;ks&&ks.view==t&&ks.scope==s&&(l=ks.prefix+" ",yC.indexOf(e.keyCode)<0&&(u=!0,ks=null));let p=new Set,h=g=>{if(g){for(let y of g.run)if(!p.has(y)&&(p.add(y),y(t)))return g.stopPropagation&&(c=!0),!0;g.preventDefault&&(g.stopPropagation&&(c=!0),u=!0)}return!1},f=r[s],d,m;return f&&(h(f[l+Rl(n,e,!a)])?o=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(ft.windows&&e.ctrlKey&&e.altKey)&&(d=ls[e.keyCode])&&d!=n?(h(f[l+Rl(d,e,!0)])||e.shiftKey&&(m=zi[e.keyCode])!=n&&m!=d&&h(f[l+Rl(m,e,!1)]))&&(o=!0):a&&e.shiftKey&&h(f[l+Rl(n,e,!0)])&&(o=!0),!o&&h(f._any)&&(o=!0)),u&&(o=!0),o&&c&&e.stopPropagation(),Op=null,o}var Oo=class r{constructor(e,t,s,n,i){this.className=e,this.left=t,this.top=s,this.width=n,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,s){if(s.empty){let n=e.coordsAtPos(s.head,s.assoc||1);if(!n)return[];let i=DC(e);return[new r(t,n.left-i.left,n.top-i.top,null,n.bottom-n.top)]}else return oj(e,t,s)}};function DC(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==Zt.LTR?e.left:e.right-r.scrollDOM.clientWidth*r.scaleX)-r.scrollDOM.scrollLeft*r.scaleX,top:e.top-r.scrollDOM.scrollTop*r.scaleY}}function SE(r,e,t,s){let n=r.coordsAtPos(e,t*2);if(!n)return s;let i=r.dom.getBoundingClientRect(),a=(n.top+n.bottom)/2,l=r.posAtCoords({x:i.left+1,y:a}),o=r.posAtCoords({x:i.right-1,y:a});return l==null||o==null?s:{from:Math.max(s.from,Math.min(l,o)),to:Math.min(s.to,Math.max(l,o))}}function oj(r,e,t){if(t.to<=r.viewport.from||t.from>=r.viewport.to)return[];let s=Math.max(t.from,r.viewport.from),n=Math.min(t.to,r.viewport.to),i=r.textDirection==Zt.LTR,a=r.contentDOM,l=a.getBoundingClientRect(),o=DC(r),u=a.querySelector(".cm-line"),c=u&&window.getComputedStyle(u),p=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),h=l.right-(c?parseInt(c.paddingRight):0),f=np(r,s),d=np(r,n),m=f.type==Ir.Text?f:null,g=d.type==Ir.Text?d:null;if(m&&(r.lineWrapping||f.widgetLineBreaks)&&(m=SE(r,s,1,m)),g&&(r.lineWrapping||d.widgetLineBreaks)&&(g=SE(r,n,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return v(x(t.from,t.to,m));{let C=m?x(t.from,null,m):S(f,!1),O=g?x(null,t.to,g):S(d,!0),w=[];return(m||f).to<(g||d).from-(m&&g?1:0)||f.widgetLineBreaks>1&&C.bottom+r.defaultLineHeight/2_&&T.from=j)break;B>R&&D(Math.max(L,R),C==null&&L<=_,Math.min(B,j),O==null&&B>=F,I.dir)}if(R=Q.to+1,R>=j)break}return A.length==0&&D(_,C==null,F,O==null,r.textDirection),{top:E,bottom:k,horizontal:A}}function S(C,O){let w=l.top+(O?C.top:C.bottom);return{top:w,bottom:w,horizontal:[]}}}function lj(r,e){return r.constructor==e.constructor&&r.eq(e)}var Sp=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet($l)!=e.state.facet($l)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,s=e.facet($l);for(;t!lj(t,this.drawn[s]))){let t=this.dom.firstChild,s=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[s].constructor&&n.update(t,this.drawn[s])?(t=t.nextSibling,s++):this.dom.insertBefore(n.draw(),t);for(;t;){let n=t.nextSibling;t.remove(),t=n}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},$l=ut.define();function _C(r){return[rr.define(e=>new Sp(e,r)),$l.of(r)]}var IC=!ft.ios,So=ut.define({combine(r){return kr(r,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function RC(r={}){return[So.of(r),uj,cj,fj,iC.of(!0)]}function FC(r){return r.startState.facet(So)!=r.state.facet(So)}var uj=_C({above:!0,markers(r){let{state:e}=r,t=e.facet(So),s=[];for(let n of e.selection.ranges){let i=n==e.selection.main;if(n.empty?!i||IC:t.drawRangeCursor){let a=i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=n.empty?n:Ze.cursor(n.head,n.head>n.anchor?-1:1);for(let o of Oo.forRange(r,a,l))s.push(o)}}return s},update(r,e){r.transactions.some(s=>s.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=FC(r);return t&&EE(r.state,e),r.docChanged||r.selectionSet||t},mount(r,e){EE(e.state,r)},class:"cm-cursorLayer"});function EE(r,e){e.style.animationDuration=r.facet(So).cursorBlinkRate+"ms"}var cj=_C({above:!1,markers(r){return r.state.selection.ranges.map(e=>e.empty?[]:Oo.forRange(r,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(r,e){return r.docChanged||r.selectionSet||r.viewportChanged||FC(r)},class:"cm-selectionLayer"}),Ep={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};IC&&(Ep[".cm-line"].caretColor=Ep[".cm-content"].caretColor="transparent !important");var fj=rn.highest(at.theme(Ep)),BC=Et.define({map(r,e){return r==null?null:e.mapPos(r)}}),so=Yt.define({create(){return null},update(r,e){return r!=null&&(r=e.changes.mapPos(r)),e.effects.reduce((t,s)=>s.is(BC)?s.value:t,r)}}),pj=rr.fromClass(class{constructor(r){this.view=r,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(r){var e;let t=r.state.field(so);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(r.startState.field(so)!=t||r.docChanged||r.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:r}=this,e=r.state.field(so),t=e!=null&&r.coordsAtPos(e);if(!t)return null;let s=r.scrollDOM.getBoundingClientRect();return{left:t.left-s.left+r.scrollDOM.scrollLeft*r.scaleX,top:t.top-s.top+r.scrollDOM.scrollTop*r.scaleY,height:t.bottom-t.top}}drawCursor(r){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;r?(this.cursor.style.left=r.left/e+"px",this.cursor.style.top=r.top/t+"px",this.cursor.style.height=r.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(r){this.view.state.field(so)!=r&&this.view.dispatch({effects:BC.of(r)})}},{eventObservers:{dragover(r){this.setDropPos(this.view.posAtCoords({x:r.clientX,y:r.clientY}))},dragleave(r){(r.target==this.view.contentDOM||!this.view.contentDOM.contains(r.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function LC(){return[so,pj]}function CE(r,e,t,s,n){e.lastIndex=0;for(let i=r.iterRange(t,s),a=t,l;!i.next().done;a+=i.value.length)if(!i.lineBreak)for(;l=e.exec(i.value);)n(a+l.index,l)}function hj(r,e){let t=r.visibleRanges;if(t.length==1&&t[0].from==r.viewport.from&&t[0].to==r.viewport.to)return t;let s=[];for(let{from:n,to:i}of t)n=Math.max(r.state.doc.lineAt(n).from,n-e),i=Math.min(r.state.doc.lineAt(i).to,i+e),s.length&&s[s.length-1].to>=n?s[s.length-1].to=i:s.push({from:n,to:i});return s}var Cp=class{constructor(e){let{regexp:t,decoration:s,decorate:n,boundary:i,maxLength:a=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,n)this.addMatch=(l,o,u,c)=>n(c,u,u+l[0].length,l,o);else if(typeof s=="function")this.addMatch=(l,o,u,c)=>{let p=s(l,o,u);p&&c(u,u+l[0].length,p)};else if(s)this.addMatch=(l,o,u,c)=>c(u,u+l[0].length,s);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=i,this.maxLength=a}createDeco(e){let t=new Fn,s=t.add.bind(t);for(let{from:n,to:i}of hj(e,this.maxLength))CE(e.state.doc,this.regexp,n,i,(a,l)=>this.addMatch(l,e,a,s));return t.finish()}updateDeco(e,t){let s=1e9,n=-1;return e.docChanged&&e.changes.iterChanges((i,a,l,o)=>{o>e.view.viewport.from&&l1e3?this.createDeco(e.view):n>-1?this.updateRange(e.view,t.map(e.changes),s,n):t}updateRange(e,t,s,n){for(let i of e.visibleRanges){let a=Math.max(i.from,s),l=Math.min(i.to,n);if(l>a){let o=e.state.doc.lineAt(a),u=o.too.from;a--)if(this.boundary.test(o.text[a-1-o.from])){c=a;break}for(;lh.push(y.range(m,g));if(o==u)for(this.regexp.lastIndex=c-o.from;(f=this.regexp.exec(o.text))&&f.indexthis.addMatch(g,e,m,d));t=t.update({filterFrom:c,filterTo:p,filter:(m,g)=>mp,add:h})}}return t}},wp=/x/.unicode!=null?"gu":"g",dj=new RegExp(`[\0-\b --\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,wp),mj={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},qf=null;function gj(){var r;if(qf==null&&typeof document<"u"&&document.body){let e=document.body.style;qf=((r=e.tabSize)!==null&&r!==void 0?r:e.MozTabSize)!=null}return qf||!1}var Ml=ut.define({combine(r){let e=kr(r,{render:null,specialChars:dj,addSpecialChars:null});return(e.replaceTabs=!gj())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,wp)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,wp)),e}});function NC(r={}){return[Ml.of(r),yj()]}var wE=null;function yj(){return wE||(wE=rr.fromClass(class{constructor(r){this.view=r,this.decorations=yt.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(r.state.facet(Ml)),this.decorations=this.decorator.createDeco(r)}makeDecorator(r){return new Cp({regexp:r.specialChars,decoration:(e,t,s)=>{let{doc:n}=t.state,i=gr(e[0],0);if(i==9){let a=n.lineAt(s),l=t.state.tabSize,o=os(a.text,l,s-a.from);return yt.replace({widget:new Ap((l-o%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[i]||(this.decorationCache[i]=yt.replace({widget:new kp(r,i)}))},boundary:r.replaceTabs?void 0:/[^]/})}update(r){let e=r.state.facet(Ml);r.startState.facet(Ml)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(r.view)):this.decorations=this.decorator.updateDeco(r,this.decorations)}},{decorations:r=>r.decorations}))}var bj="\u2022";function vj(r){return r>=32?bj:r==10?"\u2424":String.fromCharCode(9216+r)}var kp=class extends an{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=vj(this.code),s=e.state.phrase("Control character")+" "+(mj[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,s,t);if(n)return n;let i=document.createElement("span");return i.textContent=t,i.title=s,i.setAttribute("aria-label",s),i.className="cm-specialChar",i}ignoreEvent(){return!1}},Ap=class extends an{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}},kE=rr.fromClass(class{constructor(){this.height=1e3,this.attrs={style:"padding-bottom: 1000px"}}update(r){let{view:e}=r,t=e.viewState.editorHeight-e.defaultLineHeight-e.documentPadding.top-.5;t>=0&&t!=this.height&&(this.height=t,this.attrs={style:`padding-bottom: ${t}px`})}});function $C(){return[kE,su.of(r=>{var e;return((e=r.plugin(kE))===null||e===void 0?void 0:e.attrs)||null})]}function MC(){return Oj}var xj=yt.line({class:"cm-activeLine"}),Oj=rr.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.docChanged||r.selectionSet)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=-1,t=[];for(let s of r.state.selection.ranges){let n=r.lineBlockAt(s.head);n.from>e&&(t.push(xj.range(n.from)),e=n.from)}return yt.set(t)}},{decorations:r=>r.decorations});var Pp=2e3;function Sj(r,e,t){let s=Math.min(e.line,t.line),n=Math.max(e.line,t.line),i=[];if(e.off>Pp||t.off>Pp||e.col<0||t.col<0){let a=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let o=s;o<=n;o++){let u=r.doc.line(o);u.length<=l&&i.push(Ze.range(u.from+a,u.to+l))}}else{let a=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let o=s;o<=n;o++){let u=r.doc.line(o),c=Cl(u.text,a,r.tabSize,!0);if(c<0)i.push(Ze.cursor(u.to));else{let p=Cl(u.text,l,r.tabSize);i.push(Ze.range(u.from+c,u.from+p))}}}return i}function Ej(r,e){let t=r.coordsAtPos(r.viewport.from);return t?Math.round(Math.abs((t.left-e)/r.defaultCharacterWidth)):-1}function AE(r,e){let t=r.posAtCoords({x:e.clientX,y:e.clientY},!1),s=r.state.doc.lineAt(t),n=t-s.from,i=n>Pp?-1:n==s.length?Ej(r,e.clientX):os(s.text,r.state.tabSize,t-s.from);return{line:s.number,col:i,off:n}}function Cj(r,e){let t=AE(r,e),s=r.state.selection;return t?{update(n){if(n.docChanged){let i=n.changes.mapPos(n.startState.doc.line(t.line).from),a=n.state.doc.lineAt(i);t={line:a.number,col:t.col,off:Math.min(t.off,a.length)},s=s.map(n.changes)}},get(n,i,a){let l=AE(r,n);if(!l)return s;let o=Sj(r.state,t,l);return o.length?a?Ze.create(o.concat(s.ranges)):Ze.create(o):s}}:null}function jC(r){let e=r?.eventFilter||(t=>t.altKey&&t.button==0);return at.mouseSelectionStyle.of((t,s)=>e(s)?Cj(t,s):null)}var wj={Alt:[18,r=>!!r.altKey],Control:[17,r=>!!r.ctrlKey],Shift:[16,r=>!!r.shiftKey],Meta:[91,r=>!!r.metaKey]},kj={style:"cursor: crosshair"};function qC(r={}){let[e,t]=wj[r.key||"Alt"],s=rr.fromClass(class{constructor(n){this.view=n,this.isDown=!1}set(n){this.isDown!=n&&(this.isDown=n,this.view.update([]))}},{eventObservers:{keydown(n){this.set(n.keyCode==e||t(n))},keyup(n){(n.keyCode==e||!t(n))&&this.set(!1)},mousemove(n){this.set(t(n))}}});return[s,at.contentAttributes.of(n=>{var i;return!((i=n.plugin(s))===null||i===void 0)&&i.isDown?kj:null})]}var Ja="-10000px",Hl=class{constructor(e,t,s,n){this.facet=t,this.createTooltipView=s,this.removeTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter(a=>a);let i=null;this.tooltipViews=this.tooltips.map(a=>i=s(a,i))}update(e,t){var s;let n=e.state.facet(this.facet),i=n.filter(o=>o);if(n===this.input){for(let o of this.tooltipViews)o.update&&o.update(e);return!1}let a=[],l=t?[]:null;for(let o=0;ot[u]=o),t.length=l.length),this.input=n,this.tooltips=i,this.tooltipViews=a,!0}};function Aj(r){let{win:e}=r;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}var Qf=ut.define({combine:r=>{var e,t,s;return{position:ft.ios?"absolute":((e=r.find(n=>n.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=r.find(n=>n.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((s=r.find(n=>n.tooltipSpace))===null||s===void 0?void 0:s.tooltipSpace)||Aj}}}),PE=new WeakMap,Mp=rr.fromClass(class{constructor(r){this.view=r,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=r.state.facet(Qf);this.position=e.position,this.parent=e.parent,this.classes=r.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Hl(r,Ki,(t,s)=>this.createTooltip(t,s),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),r.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let r of this.manager.tooltipViews)this.intersectionObserver.observe(r.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(r){r.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(r,this.above);e&&this.observeIntersection();let t=e||r.geometryChanged,s=r.state.facet(Qf);if(s.position!=this.position&&!this.madeAbsolute){this.position=s.position;for(let n of this.manager.tooltipViews)n.dom.style.position=this.position;t=!0}if(s.parent!=this.parent){this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer();for(let n of this.manager.tooltipViews)this.container.appendChild(n.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(r,e){let t=r.create(this.view),s=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),r.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let n=document.createElement("div");n.className="cm-tooltip-arrow",t.dom.appendChild(n)}return t.dom.style.position=this.position,t.dom.style.top=Ja,t.dom.style.left="0px",this.container.insertBefore(t.dom,s),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var r,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let s of this.manager.tooltipViews)s.dom.remove(),(r=s.destroy)===null||r===void 0||r.call(s);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let r=this.view.dom.getBoundingClientRect(),e=1,t=1,s=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:n}=this.manager.tooltipViews[0];if(ft.gecko)s=n.offsetParent!=this.container.ownerDocument.body;else if(n.style.top==Ja&&n.style.left=="0px"){let i=n.getBoundingClientRect();s=Math.abs(i.top+1e4)>1||Math.abs(i.left)>1}}if(s||this.position=="absolute")if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:r,parent:this.parent?this.container.getBoundingClientRect():r,pos:this.manager.tooltips.map((n,i)=>{let a=this.manager.tooltipViews[i];return a.getCoords?a.getCoords(n.pos):this.view.coordsAtPos(n.pos)}),size:this.manager.tooltipViews.map(({dom:n})=>n.getBoundingClientRect()),space:this.view.state.facet(Qf).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:s}}writeMeasure(r){var e;if(r.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{editor:t,space:s,scaleX:n,scaleY:i}=r,a=[];for(let l=0;l=Math.min(t.bottom,s.bottom)||p.rightMath.min(t.right,s.right)+.1){c.style.top=Ja;continue}let f=o.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,d=f?7:0,m=h.right-h.left,g=(e=PE.get(u))!==null&&e!==void 0?e:h.bottom-h.top,y=u.offset||Tj,v=this.view.textDirection==Zt.LTR,x=h.width>s.right-s.left?v?s.left:s.right-h.width:v?Math.max(s.left,Math.min(p.left-(f?14:0)+y.x,s.right-m)):Math.min(Math.max(s.left,p.left-m+(f?14:0)-y.x),s.right-m),S=this.above[l];!o.strictSide&&(S?p.top-(h.bottom-h.top)-y.ys.bottom)&&S==s.bottom-p.bottom>p.top-s.top&&(S=this.above[l]=!S);let C=(S?p.top-s.top:s.bottom-p.bottom)-d;if(Cx&&E.topO&&(O=S?E.top-g-2-d:E.bottom+d+2);if(this.position=="absolute"?(c.style.top=(O-r.parent.top)/i+"px",c.style.left=(x-r.parent.left)/n+"px"):(c.style.top=O/i+"px",c.style.left=x/n+"px"),f){let E=p.left+(v?y.x:-y.x)-(x+14-7);f.style.left=E/n+"px"}u.overlap!==!0&&a.push({left:x,top:O,right:w,bottom:O+g}),c.classList.toggle("cm-tooltip-above",S),c.classList.toggle("cm-tooltip-below",!S),u.positioned&&u.positioned(r.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let r of this.manager.tooltipViews)r.dom.style.top=Ja}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Pj=at.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Tj={x:0,y:0},Ki=ut.define({enables:[Mp,Pj]}),Kl=ut.define({combine:r=>r.reduce((e,t)=>e.concat(t),[])}),Jl=class r{static create(e){return new r(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Hl(e,Kl,(t,s)=>this.createHostedView(t,s),t=>t.dom.remove())}createHostedView(e,t){let s=e.create(this.view);return s.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(s.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&s.mount&&s.mount(this.view),s}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let s of this.manager.tooltipViews){let n=s[e];if(n!==void 0){if(t===void 0)t=n;else if(t!==n)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},Dj=Ki.compute([Kl],r=>{let e=r.facet(Kl);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var s;return(s=t.end)!==null&&s!==void 0?s:t.pos})),create:Jl.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Tp=class{constructor(e,t,s,n,i){this.view=e,this.source=t,this.field=s,this.setHover=n,this.hoverTime=i,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;el.bottom||t.xl.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(n)).find(c=>c.from<=n&&c.to>=n),u=o&&o.dir==Zt.RTL?-1:1;i=t.x{this.pending==l&&(this.pending=null,o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])}))},o=>yr(e.state,o,"hover tooltip"))}else a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])})}get tooltip(){let e=this.view.plugin(Mp),t=e?e.manager.tooltips.findIndex(s=>s.create==Jl.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,s;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:i}=this;if(n.length&&i&&!_j(i.dom,e)||this.pending){let{pos:a}=n[0]||this.pending,l=(s=(t=n[0])===null||t===void 0?void 0:t.end)!==null&&s!==void 0?s:a;(a==l?this.view.posAtCoords(this.lastMove)!=a:!Ij(this.view,a,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:s}=this;s&&s.dom.contains(e.relatedTarget)?this.watchTooltipLeave(s.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=s=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(s.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},Fl=4;function _j(r,e){let{left:t,right:s,top:n,bottom:i}=r.getBoundingClientRect(),a;if(a=r.querySelector(".cm-tooltip-arrow")){let l=a.getBoundingClientRect();n=Math.min(l.top,n),i=Math.max(l.bottom,i)}return e.clientX>=t-Fl&&e.clientX<=s+Fl&&e.clientY>=n-Fl&&e.clientY<=i+Fl}function Ij(r,e,t,s,n,i){let a=r.scrollDOM.getBoundingClientRect(),l=r.documentTop+r.documentPadding.top+r.contentHeight;if(a.left>s||a.rightn||Math.min(a.bottom,l)=e&&o<=t}function QC(r,e={}){let t=Et.define(),s=Yt.define({create(){return[]},update(n,i){if(n.length&&(e.hideOnChange&&(i.docChanged||i.selection)?n=[]:e.hideOn&&(n=n.filter(a=>!e.hideOn(i,a))),i.docChanged)){let a=[];for(let l of n){let o=i.changes.mapPos(l.pos,-1,fr.TrackDel);if(o!=null){let u=Object.assign(Object.create(null),l);u.pos=o,u.end!=null&&(u.end=i.changes.mapPos(u.end)),a.push(u)}}n=a}for(let a of i.effects)a.is(t)&&(n=a.value),a.is(Rj)&&(n=[]);return n},provide:n=>Kl.from(n)});return{active:s,extension:[s,rr.define(n=>new Tp(n,r,s,t,e.hoverTime||300)),Dj]}}function jp(r,e){let t=r.plugin(Mp);if(!t)return null;let s=t.manager.tooltips.indexOf(e);return s<0?null:t.manager.tooltipViews[s]}var Rj=Et.define();var TE=ut.define({combine(r){let e,t;for(let s of r)e=e||s.topContainer,t=t||s.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Ji(r,e){let t=r.plugin(VC),s=t?t.specs.indexOf(e):-1;return s>-1?t.panels[s]:null}var VC=rr.fromClass(class{constructor(r){this.input=r.state.facet(ui),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(r));let e=r.state.facet(TE);this.top=new Gi(r,!0,e.topContainer),this.bottom=new Gi(r,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(r){let e=r.state.facet(TE);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Gi(r.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Gi(r.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=r.state.facet(ui);if(t!=this.input){let s=t.filter(o=>o),n=[],i=[],a=[],l=[];for(let o of s){let u=this.specs.indexOf(o),c;u<0?(c=o(r.view),l.push(c)):(c=this.panels[u],c.update&&c.update(r)),n.push(c),(c.top?i:a).push(c)}this.specs=s,this.panels=n,this.top.sync(i),this.bottom.sync(a);for(let o of l)o.dom.classList.add("cm-panel"),o.mount&&o.mount()}else for(let s of this.panels)s.update&&s.update(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>at.scrollMargins.of(e=>{let t=e.plugin(r);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Gi=class{constructor(e,t,s){this.view=e,this.top=t,this.container=s,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=DE(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=DE(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function DE(r){let e=r.nextSibling;return r.remove(),e}var ui=ut.define({enables:VC}),Xr=class extends yn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Xr.prototype.elementClass="";Xr.prototype.toDOM=void 0;Xr.prototype.mapMode=fr.TrackBefore;Xr.prototype.startSide=Xr.prototype.endSide=-1;Xr.prototype.point=!0;var jl=ut.define(),Fj=ut.define(),Bj={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Mt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},co=ut.define();function qp(r){return[UC(),co.of(Object.assign(Object.assign({},Bj),r))]}var Dp=ut.define({combine:r=>r.some(e=>e)});function UC(r){let e=[Lj];return r&&r.fixed===!1&&e.push(Dp.of(!0)),e}var Lj=rr.fromClass(class{constructor(r){this.view=r,this.prevViewport=r.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=r.state.facet(co).map(e=>new eu(r,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!r.state.facet(Dp),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.contentDOM)}update(r){if(this.updateGutters(r)){let e=this.prevViewport,t=r.view.viewport,s=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(s<(t.to-t.from)*.8)}r.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(Dp)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=r.view.viewport}syncGutters(r){let e=this.dom.nextSibling;r&&this.dom.remove();let t=Mt.iter(this.view.state.facet(jl),this.view.viewport.from),s=[],n=this.gutters.map(i=>new Ip(i,this.view.viewport,-this.view.documentPadding.top));for(let i of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(i.type)){let a=!0;for(let l of i.type)if(l.type==Ir.Text&&a){_p(t,s,l.from);for(let o of n)o.line(this.view,l,s);a=!1}else if(l.widget)for(let o of n)o.widget(this.view,l)}else if(i.type==Ir.Text){_p(t,s,i.from);for(let a of n)a.line(this.view,i,s)}else if(i.widget)for(let a of n)a.widget(this.view,i);for(let i of n)i.finish();r&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(r){let e=r.startState.facet(co),t=r.state.facet(co),s=r.docChanged||r.heightChanged||r.viewportChanged||!Mt.eq(r.startState.facet(jl),r.state.facet(jl),r.view.viewport.from,r.view.viewport.to);if(e==t)for(let n of this.gutters)n.update(r)&&(s=!0);else{s=!0;let n=[];for(let i of t){let a=e.indexOf(i);a<0?n.push(new eu(this.view,i)):(this.gutters[a].update(r),n.push(this.gutters[a]))}for(let i of this.gutters)i.dom.remove(),n.indexOf(i)<0&&i.destroy();for(let i of n)this.dom.appendChild(i.dom);this.gutters=n}return s}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove()}},{provide:r=>at.scrollMargins.of(e=>{let t=e.plugin(r);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==Zt.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function _E(r){return Array.isArray(r)?r:[r]}function _p(r,e,t){for(;r.value&&r.from<=t;)r.from==t&&e.push(r.value),r.next()}var Ip=class{constructor(e,t,s){this.gutter=e,this.height=s,this.i=0,this.cursor=Mt.iter(e.markers,t.from)}addElement(e,t,s){let{gutter:n}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==n.elements.length){let l=new tu(e,a,i,s);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(e,a,i,s);this.height=t.bottom,this.i++}line(e,t,s){let n=[];_p(this.cursor,n,t.from),s.length&&(n=n.concat(s));let i=this.gutter.config.lineMarker(e,t,n);i&&n.unshift(i);let a=this.gutter;n.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,n)}widget(e,t){let s=this.gutter.config.widgetMarker(e,t.widget,t),n=s?[s]:null;for(let i of e.state.facet(Fj)){let a=i(e,t.widget,t);a&&(n||(n=[])).push(a)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},eu=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let s in t.domEventHandlers)this.dom.addEventListener(s,n=>{let i=n.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let o=i.getBoundingClientRect();a=(o.top+o.bottom)/2}else a=n.clientY;let l=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[s](e,l,n)&&n.preventDefault()});this.markers=_E(t.markers(e)),t.initialSpacer&&(this.spacer=new tu(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=_E(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let s=e.view.viewport;return!Mt.eq(this.markers,t,s.from,s.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},tu=class{constructor(e,t,s,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,s,n)}update(e,t,s,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=s&&(this.dom.style.marginTop=(this.above=s)?s+"px":""),Nj(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let s="cm-gutterElement",n=this.dom.firstChild;for(let i=0,a=0;;){let l=a,o=ii(l,o,u)||a(l,o,u):a}return s}})}}),fo=class extends Xr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Vf(r,e){return r.state.facet(Xi).formatNumber(e,r.state)}var jj=co.compute([Xi],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet($j)},lineMarker(e,t,s){return s.some(n=>n.toDOM)?null:new fo(Vf(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,s)=>{for(let n of e.state.facet(Mj)){let i=n(e,t,s);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Xi)!=e.state.facet(Xi),initialSpacer(e){return new fo(Vf(e,IE(e.state.doc.lines)))},updateSpacer(e,t){let s=Vf(t.view,IE(t.view.state.doc.lines));return s==e.number?e:new fo(s)},domEventHandlers:r.facet(Xi).domEventHandlers}));function zC(r={}){return[Xi.of(r),UC(),jj]}function IE(r){let e=9;for(;e{let e=[],t=-1;for(let s of r.selection.ranges){let n=r.doc.lineAt(s.head).from;n>t&&(t=n,e.push(qj.range(n)))}return Mt.of(e)});function ZC(){return Qj}var Vj=0,Eo=class{constructor(e,t){this.from=e,this.to=t}},kt=class{constructor(e={}){this.id=Vj++,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 typeof e!="function"&&(e=Ar.match(e)),t=>{let s=e(t);return s===void 0?null:[this,s]}}};kt.closedBy=new kt({deserialize:r=>r.split(" ")});kt.openedBy=new kt({deserialize:r=>r.split(" ")});kt.group=new kt({deserialize:r=>r.split(" ")});kt.isolate=new kt({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});kt.contextHash=new kt({perNode:!0});kt.lookAhead=new kt({perNode:!0});kt.mounted=new kt({perNode:!0});var ea=class{constructor(e,t,s){this.tree=e,this.overlay=t,this.parser=s}static get(e){return e&&e.props&&e.props[kt.mounted.id]}},Uj=Object.create(null),Ar=class r{constructor(e,t,s,n=0){this.name=e,this.props=t,this.id=s,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):Uj,s=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new r(e.name||"",t,e.id,s);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(n)),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 n}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(kt.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let s in e)for(let n of s.split(" "))t[n]=e[s];return s=>{for(let n=s.prop(kt.group),i=-1;i<(n?n.length:0);i++){let a=t[i<0?s.name:n[i]];if(a)return a}}}};Ar.none=new Ar("",Object.create(null),0,8);var Co=class r{constructor(e){this.types=e;for(let t=0;t0;for(let o=this.cursor(a|nr.IncludeAnonymous);;){let u=!1;if(o.from<=i&&o.to>=n&&(!l&&o.type.isAnonymous||t(o)!==!1)){if(o.firstChild())continue;u=!0}for(;u&&s&&(l||!o.type.isAnonymous)&&s(o),!o.nextSibling();){if(!o.parent())return;u=!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:Gp(Ar.none,this.children,this.positions,0,this.children.length,0,this.length,(t,s,n)=>new r(this.type,t,s,n,this.propValues),e.makeTree||((t,s,n)=>new r(Ar.none,t,s,n)))}static build(e){return Zj(e)}};or.empty=new or(Ar.none,[],[],0);var Qp=class r{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 r(this.buffer,this.index)}},Is=class r{constructor(e,t,s){this.buffer=e,this.length=t,this.set=s}get type(){return Ar.none}toString(){let e=[];for(let t=0;t0));o=a[o+3]);return l}slice(e,t,s){let n=this.buffer,i=new Uint16Array(t-e),a=0;for(let l=e,o=0;l=e&&te;case 1:return t<=e&&s>e;case 2:return s>e;case 4:return!0}}function wo(r,e,t,s){for(var n;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to0?l.length:-1;e!=u;e+=t){let c=l[e],p=o[e]+a.from;if(YC(n,s,p,p+c.length)){if(c instanceof Is){if(i&nr.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,t,s-p,n);if(h>-1)return new ci(new Up(a,c,e,p),null,h)}else if(i&nr.IncludeAnonymous||!c.type.isAnonymous||Wp(c)){let h;if(!(i&nr.IgnoreMounts)&&(h=ea.get(c))&&!h.overlay)return new r(h.tree,p,e,a);let f=new r(c,p,e,a);return i&nr.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(t<0?c.children.length-1:0,t,s,n)}}}if(i&nr.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))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,s=0){let n;if(!(s&nr.IgnoreOverlays)&&(n=ea.get(this._tree))&&n.overlay){let i=e-this.from;for(let{from:a,to:l}of n.overlay)if((t>0?a<=i:a=i:l>i))return new r(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,s)}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 GC(r,e,t,s){let n=r.cursor(),i=[];if(!n.firstChild())return i;if(t!=null){for(let a=!1;!a;)if(a=n.type.is(t),!n.nextSibling())return i}for(;;){if(s!=null&&n.type.is(s))return i;if(n.type.is(e)&&i.push(n.node),!n.nextSibling())return s==null?i:[]}}function Vp(r,e,t=e.length-1){for(let s=r;t>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(e[t]&&e[t]!=s.name)return!1;t--}}return!0}var Up=class{constructor(e,t,s,n){this.parent=e,this.buffer=t,this.index=s,this.start=n}},ci=class r extends lu{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,s){super(),this.context=e,this._parent=t,this.index=s,this.type=e.buffer.set.types[e.buffer.buffer[s]]}child(e,t,s){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,s);return i<0?null:new r(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,s=0){if(s&nr.ExcludeBuffers)return null;let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new r(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 r(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 r(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:s}=this.context,n=this.index+4,i=s.buffer[this.index+3];if(i>n){let a=s.buffer[this.index+1];e.push(s.slice(n,i,a)),t.push(0)}return new or(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function HC(r){if(!r.length)return null;let e=0,t=r[0];for(let i=1;it.from||a.to=e){let l=new ln(a.tree,a.overlay[0].from+i.from,-1,i);(n||(n=[s])).push(wo(l,e,t,!1))}}return n?HC(n):s}var ko=class{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 ln)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let s=e._parent;s;s=s._parent)this.stack.unshift(s.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):!1}yieldBuf(e,t){this.index=e;let{start:s,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=s+n.buffer[e+1],this.to=s+n.buffer[e+2],!0}yield(e){return e?e instanceof ln?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,s){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,s,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,s);return i<0?!1:(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,s=this.mode){return this.buffer?s&nr.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,s))}parent(){if(!this.buffer)return this.yieldNode(this.mode&nr.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&nr.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)):!1;let{buffer:t}=this.buffer,s=this.stack.length-1;if(e<0){let n=s<0?0:this.stack[s]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(s<0?t.buffer.length:t.buffer[this.stack[s]+3]))return this.yieldBuf(n)}return s<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,s,{buffer:n}=this;if(n){if(e>0){if(this.index-1)for(let i=t+e,a=e<0?-1:s._tree.children.length;i!=a;i+=e){let l=s._tree.children[i];if(this.mode&nr.IncludeAnonymous||l instanceof Is||!l.type.isAnonymous||Wp(l))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=0;){for(let a=e;a;a=a._parent)if(a.index==n){if(n==this.index)return a;t=a,s=i+1;break e}n=this.stack[--i]}for(let n=s;n=0;i--){if(i<0)return Vp(this._tree,e,n);let a=s[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[n]&&e[n]!=a.name)return!1;n--}}return!0}};function Wp(r){return r.children.some(e=>e instanceof Is||!e.type.isAnonymous||Wp(e))}function Zj(r){var e;let{buffer:t,nodeSet:s,maxBufferLength:n=1024,reused:i=[],minRepeatType:a=s.types.length}=r,l=Array.isArray(t)?new Qp(t,t.length):t,o=s.types,u=0,c=0;function p(C,O,w,E,k,A){let{id:D,start:_,end:F,size:T}=l,R=c,j=u;for(;T<0;)if(l.next(),T==-1){let V=i[D];w.push(V),E.push(_-C);return}else if(T==-3){u=D;return}else if(T==-4){c=D;return}else throw new RangeError(`Unrecognized record size: ${T}`);let Q=o[D],I,L,B=_-C;if(F-_<=n&&(L=g(l.pos-O,k))){let V=new Uint16Array(L.size-L.skip),U=l.pos-L.size,ae=V.length;for(;l.pos>U;)ae=y(L.start,V,ae);I=new Is(V,F-L.start,s),B=L.start-C}else{let V=l.pos-T;l.next();let U=[],ae=[],se=D>=a?D:-1,xe=0,H=F;for(;l.pos>V;)se>=0&&l.id==se&&l.size>=0?(l.end<=H-n&&(d(U,ae,_,xe,l.end,H,se,R,j),xe=U.length,H=l.end),l.next()):A>2500?h(_,V,U,ae):p(_,V,U,ae,se,A+1);if(se>=0&&xe>0&&xe-1&&xe>0){let he=f(Q,j);I=Gp(Q,U,ae,0,U.length,0,F-_,he,he)}else I=m(Q,U,ae,F-_,R-F,j)}w.push(I),E.push(B)}function h(C,O,w,E){let k=[],A=0,D=-1;for(;l.pos>O;){let{id:_,start:F,end:T,size:R}=l;if(R>4)l.next();else{if(D>-1&&F=0;T-=3)_[R++]=k[T],_[R++]=k[T+1]-F,_[R++]=k[T+2]-F,_[R++]=R;w.push(new Is(_,k[2]-F,s)),E.push(F-C)}}function f(C,O){return(w,E,k)=>{let A=0,D=w.length-1,_,F;if(D>=0&&(_=w[D])instanceof or){if(!D&&_.type==C&&_.length==k)return _;(F=_.prop(kt.lookAhead))&&(A=E[D]+_.length+F)}return m(C,w,E,k,A,O)}}function d(C,O,w,E,k,A,D,_,F){let T=[],R=[];for(;C.length>E;)T.push(C.pop()),R.push(O.pop()+w-k);C.push(m(s.types[D],T,R,A-k,_-A,F)),O.push(k-w)}function m(C,O,w,E,k,A,D){if(A){let _=[kt.contextHash,A];D=D?[_].concat(D):[_]}if(k>25){let _=[kt.lookAhead,k];D=D?[_].concat(D):[_]}return new or(C,O,w,E,D)}function g(C,O){let w=l.fork(),E=0,k=0,A=0,D=w.end-n,_={size:0,start:0,skip:0};e:for(let F=w.pos-C;w.pos>F;){let T=w.size;if(w.id==O&&T>=0){_.size=E,_.start=k,_.skip=A,A+=4,E+=4,w.next();continue}let R=w.pos-T;if(T<0||R=a?4:0,Q=w.start;for(w.next();w.pos>R;){if(w.size<0)if(w.size==-3)j+=4;else break e;else w.id>=a&&(j+=4);w.next()}k=Q,E+=T,A+=j}return(O<0||E==C)&&(_.size=E,_.start=k,_.skip=A),_.size>4?_:void 0}function y(C,O,w){let{id:E,start:k,end:A,size:D}=l;if(l.next(),D>=0&&E4){let F=l.pos-(D-4);for(;l.pos>F;)w=y(C,O,w)}O[--w]=_,O[--w]=A-C,O[--w]=k-C,O[--w]=E}else D==-3?u=E:D==-4&&(c=E);return w}let v=[],x=[];for(;l.pos>0;)p(r.start||0,r.bufferStart||0,v,x,-1,0);let S=(e=r.length)!==null&&e!==void 0?e:v.length?x[0]+v[0].length:0;return new or(o[r.topID],v.reverse(),x.reverse(),S)}var XC=new WeakMap;function ou(r,e){if(!r.isAnonymous||e instanceof Is||e.type!=r)return 1;let t=XC.get(e);if(t==null){t=1;for(let s of e.children){if(s.type!=r||!(s instanceof or)){t=1;break}t+=ou(r,s)}XC.set(e,t)}return t}function Gp(r,e,t,s,n,i,a,l,o){let u=0;for(let d=s;d=c)break;O+=w}if(x==S+1){if(O>c){let w=d[S];f(w.children,w.positions,0,w.children.length,m[S]+v);continue}p.push(d[S])}else{let w=m[x-1]+d[x-1].length-C;p.push(Gp(r,d,m,S,x,C,w,null,o))}h.push(C+v-i)}}return f(e,t,s,n,0),(l||o)(p,h,a)}var uu=class{constructor(){this.map=new WeakMap}setBuffer(e,t,s){let n=this.map.get(e);n||this.map.set(e,n=new Map),n.set(t,s)}getBuffer(e,t){let s=this.map.get(e);return s&&s.get(t)}set(e,t){e instanceof ci?this.setBuffer(e.context.buffer,e.index,t):e instanceof ln&&this.map.set(e.tree,t)}get(e){return e instanceof ci?this.getBuffer(e.context.buffer,e.index):e instanceof ln?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},fi=class r{constructor(e,t,s,n,i=!1,a=!1){this.from=e,this.to=t,this.tree=s,this.offset=n,this.open=(i?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],s=!1){let n=[new r(0,e.length,e,0,!1,s)];for(let i of t)i.to>e.length&&n.push(i);return n}static applyChanges(e,t,s=128){if(!t.length)return e;let n=[],i=1,a=e.length?e[0]:null;for(let l=0,o=0,u=0;;l++){let c=l=s)for(;a&&a.from=h.from||p<=h.to||u){let f=Math.max(h.from,o)-u,d=Math.min(h.to,p)-u;h=f>=d?null:new r(f,d,h.tree,h.offset+u,l>0,!!c)}if(h&&n.push(h),a.to>p)break;a=inew Eo(n.from,n.to)):[new Eo(0,0)]:[new Eo(0,e.length)],this.createParse(e,t||[],s)}parse(e,t,s){let n=this.startParse(e,t,s);for(;;){let i=n.advance();if(i)return i}}},Zp=class{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)}};var YX=new kt({perNode:!0});var Wj=0,vn=class r{constructor(e,t,s,n){this.name=e,this.set=t,this.base=s,this.modified=n,this.id=Wj++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let s=typeof e=="string"?e:"?";if(e instanceof r&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let n=new r(s,[],null,[]);if(n.set.push(n),t)for(let i of t.set)n.set.push(i);return n}static defineModifier(e){let t=new hu(e);return s=>s.modified.indexOf(t)>-1?s:hu.get(s.base||s,s.modified.concat(t).sort((n,i)=>n.id-i.id))}},Gj=0,hu=class r{constructor(e){this.name=e,this.instances=[],this.id=Gj++}static get(e,t){if(!t.length)return e;let s=t[0].instances.find(l=>l.base==e&&Xj(t,l.modified));if(s)return s;let n=[],i=new vn(e.name,n,e,t);for(let l of t)l.instances.push(i);let a=Yj(t);for(let l of e.set)if(!l.modified.length)for(let o of a)n.push(r.get(l,o));return i}};function Xj(r,e){return r.length==e.length&&r.every((t,s)=>t==e[s])}function Yj(r){let e=[[]];for(let t=0;ts.length-t.length)}function du(r){let e=Object.create(null);for(let t in r){let s=r[t];Array.isArray(s)||(s=[s]);for(let n of t.split(" "))if(n){let i=[],a=2,l=n;for(let p=0;;){if(l=="..."&&p>0&&p+3==n.length){a=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!h)throw new RangeError("Invalid path: "+n);if(i.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),p+=h[0].length,p==n.length)break;let f=n[p++];if(p==n.length&&f=="!"){a=0;break}if(f!="/")throw new RangeError("Invalid path: "+n);l=n.slice(p)}let o=i.length-1,u=i[o];if(!u)throw new RangeError("Invalid path: "+n);let c=new ra(s,a,o>0?i.slice(0,o):null);e[u]=c.sort(e[u])}}return ew.add(e)}var ew=new kt,ra=class{constructor(e,t,s,n){this.tags=e,this.mode=t,this.context=s,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let a=n;for(let l of i)for(let o of l.set){let u=t[o.id];if(u){a=a?a+" "+u:u;break}}return a},scope:s}}function Hj(r,e){let t=null;for(let s of r){let n=s.style(e);n&&(t=t?t+" "+n:n)}return t}function tw(r,e,t,s=0,n=r.length){let i=new Yp(s,Array.isArray(e)?e:[e],t);i.highlightRange(r.cursor(),s,n,"",i.highlighters),i.flush(n)}var Yp=class{constructor(e,t,s){this.at=e,this.highlighters=t,this.span=s,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,s,n,i){let{type:a,from:l,to:o}=e;if(l>=s||o<=t)return;a.isTop&&(i=this.highlighters.filter(f=>!f.scope||f.scope(a)));let u=n,c=Kj(e)||ra.empty,p=Hj(i,c.tags);if(p&&(u&&(u+=" "),u+=p,c.mode==1&&(n+=(n?" ":"")+p)),this.startSpan(Math.max(t,l),u),c.opaque)return;let h=e.tree&&e.tree.prop(kt.mounted);if(h&&h.overlay){let f=e.node.enter(h.overlay[0].from+l,1),d=this.highlighters.filter(g=>!g.scope||g.scope(h.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let v=g=x||!e.nextSibling())););if(!v||x>s)break;y=v.to+l,y>t&&(this.highlightRange(f.cursor(),Math.max(t,v.from+l),Math.min(s,y),"",d),this.startSpan(Math.min(s,y),u))}m&&e.parent()}else if(e.firstChild()){h&&(n="");do if(!(e.to<=t)){if(e.from>=s)break;this.highlightRange(e,t,s,n,i),this.startSpan(Math.min(s,e.to),u)}while(e.nextSibling());e.parent()}}};function Kj(r){let e=r.type.prop(ew);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}var lt=vn.define,cu=lt(),Rs=lt(),KC=lt(Rs),JC=lt(Rs),Fs=lt(),fu=lt(Fs),Xp=lt(Fs),Vn=lt(),pi=lt(Vn),qn=lt(),Qn=lt(),Hp=lt(),Ao=lt(Hp),pu=lt(),we={comment:cu,lineComment:lt(cu),blockComment:lt(cu),docComment:lt(cu),name:Rs,variableName:lt(Rs),typeName:KC,tagName:lt(KC),propertyName:JC,attributeName:lt(JC),className:lt(Rs),labelName:lt(Rs),namespace:lt(Rs),macroName:lt(Rs),literal:Fs,string:fu,docString:lt(fu),character:lt(fu),attributeValue:lt(fu),number:Xp,integer:lt(Xp),float:lt(Xp),bool:lt(Fs),regexp:lt(Fs),escape:lt(Fs),color:lt(Fs),url:lt(Fs),keyword:qn,self:lt(qn),null:lt(qn),atom:lt(qn),unit:lt(qn),modifier:lt(qn),operatorKeyword:lt(qn),controlKeyword:lt(qn),definitionKeyword:lt(qn),moduleKeyword:lt(qn),operator:Qn,derefOperator:lt(Qn),arithmeticOperator:lt(Qn),logicOperator:lt(Qn),bitwiseOperator:lt(Qn),compareOperator:lt(Qn),updateOperator:lt(Qn),definitionOperator:lt(Qn),typeOperator:lt(Qn),controlOperator:lt(Qn),punctuation:Hp,separator:lt(Hp),bracket:Ao,angleBracket:lt(Ao),squareBracket:lt(Ao),paren:lt(Ao),brace:lt(Ao),content:Vn,heading:pi,heading1:lt(pi),heading2:lt(pi),heading3:lt(pi),heading4:lt(pi),heading5:lt(pi),heading6:lt(pi),contentSeparator:lt(Vn),list:lt(Vn),quote:lt(Vn),emphasis:lt(Vn),strong:lt(Vn),link:lt(Vn),monospace:lt(Vn),strikethrough:lt(Vn),inserted:lt(),deleted:lt(),changed:lt(),invalid:lt(),meta:pu,documentMeta:lt(pu),annotation:lt(pu),processingInstruction:lt(pu),definition:vn.defineModifier("definition"),constant:vn.defineModifier("constant"),function:vn.defineModifier("function"),standard:vn.defineModifier("standard"),local:vn.defineModifier("local"),special:vn.defineModifier("special")};for(let r in we){let e=we[r];e instanceof vn&&(e.name=r)}var JX=Kp([{tag:we.link,class:"tok-link"},{tag:we.heading,class:"tok-heading"},{tag:we.emphasis,class:"tok-emphasis"},{tag:we.strong,class:"tok-strong"},{tag:we.keyword,class:"tok-keyword"},{tag:we.atom,class:"tok-atom"},{tag:we.bool,class:"tok-bool"},{tag:we.url,class:"tok-url"},{tag:we.labelName,class:"tok-labelName"},{tag:we.inserted,class:"tok-inserted"},{tag:we.deleted,class:"tok-deleted"},{tag:we.literal,class:"tok-literal"},{tag:we.string,class:"tok-string"},{tag:we.number,class:"tok-number"},{tag:[we.regexp,we.escape,we.special(we.string)],class:"tok-string2"},{tag:we.variableName,class:"tok-variableName"},{tag:we.local(we.variableName),class:"tok-variableName tok-local"},{tag:we.definition(we.variableName),class:"tok-variableName tok-definition"},{tag:we.special(we.variableName),class:"tok-variableName2"},{tag:we.definition(we.propertyName),class:"tok-propertyName tok-definition"},{tag:we.typeName,class:"tok-typeName"},{tag:we.namespace,class:"tok-namespace"},{tag:we.className,class:"tok-className"},{tag:we.macroName,class:"tok-macroName"},{tag:we.propertyName,class:"tok-propertyName"},{tag:we.operator,class:"tok-operator"},{tag:we.comment,class:"tok-comment"},{tag:we.meta,class:"tok-meta"},{tag:we.invalid,class:"tok-invalid"},{tag:we.punctuation,class:"tok-punctuation"}]);var Jp,na=new kt;function ch(r){return ut.define({combine:r?e=>e.concat(r):void 0})}var yu=new kt,Yr=class{constructor(e,t,s=[],n=""){this.data=e,this.name=n,Vt.prototype.hasOwnProperty("tree")||Object.defineProperty(Vt.prototype,"tree",{get(){return pr(this)}}),this.parser=t,this.extension=[sa.of(this),Vt.languageData.of((i,a,l)=>{let o=rw(i,a,l),u=o.type.prop(na);if(!u)return[];let c=i.facet(u),p=o.type.prop(yu);if(p){let h=o.resolve(a-o.from,l);for(let f of p)if(f.test(h,i)){let d=i.facet(f.facet);return f.type=="replace"?d:d.concat(c)}}return c})].concat(s)}isActiveAt(e,t,s=-1){return rw(e,t,s).type.prop(na)==this.data}findRegions(e){let t=e.facet(sa);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let s=[],n=(i,a)=>{if(i.prop(na)==this.data){s.push({from:a,to:a+i.length});return}let l=i.prop(kt.mounted);if(l){if(l.tree.prop(na)==this.data){if(l.overlay)for(let o of l.overlay)s.push({from:o.from+a,to:o.to+a});else s.push({from:a,to:a+i.length});return}else if(l.overlay){let o=s.length;if(n(l.tree,l.overlay[0].from+a),s.length>o)return}}for(let o=0;os.isTop?t:void 0)]}),e.name)}configure(e,t){return new r(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function pr(r){let e=r.field(Yr.state,!1);return e?e.tree:or.empty}var nh=class{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 s=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-s,t-s)}},Po=null,sh=class r{constructor(e,t,s=[],n,i,a,l,o){this.parser=e,this.state=t,this.fragments=s,this.tree=n,this.treeLen=i,this.viewport=a,this.skipped=l,this.scheduleOn=o,this.parse=null,this.tempSkipped=[]}static create(e,t,s){return new r(e,t,[],or.empty,0,s,[],null)}startParse(){return this.parser.startParse(new nh(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=or.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var s;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||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(fi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Po;Po=this;try{return e()}finally{Po=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=nw(e,t.from,t.to);return e}changes(e,t){let{fragments:s,tree:n,treeLen:i,viewport:a,skipped:l}=this;if(this.takeTree(),!e.empty){let o=[];if(e.iterChangedRanges((u,c,p,h)=>o.push({fromA:u,toA:c,fromB:p,toB:h})),s=fi.applyChanges(s,o),n=or.empty,i=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),p=e.mapPos(u.to,-1);ce.from&&(this.fragments=nw(this.fragments,n,i),this.skipped.splice(s--,1))}return this.skipped.length>=t?!1:(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 ta{createParse(t,s,n){let i=n[0].from,a=n[n.length-1].to;return{parsedPos:i,advance(){let o=Po;if(o){for(let u of n)o.tempSkipped.push(u);e&&(o.scheduleOn=o.scheduleOn?Promise.all([o.scheduleOn,e]):e)}return this.parsedPos=a,new or(Ar.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Po}};function nw(r,e,t){return fi.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}var To=class r{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),s=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,s)||t.takeTree(),new r(t)}static init(e){let t=Math.min(3e3,e.doc.length),s=sh.create(e.facet(sa).parser,e,{from:0,to:t});return s.work(20,t)||s.takeTree(),new r(s)}};Yr.state=Yt.define({create:To.init,update(r,e){for(let t of e.effects)if(t.is(Yr.setState))return t.value;return e.startState.facet(sa)!=e.state.facet(sa)?To.init(e.state):r.apply(e)}});var ow=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(ow=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var eh=typeof navigator<"u"&&(!((Jp=navigator.scheduling)===null||Jp===void 0)&&Jp.isInputPending)?()=>navigator.scheduling.isInputPending():null,Jj=rr.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(Yr.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(Yr.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=ow(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,o=i.context.work(()=>eh&&eh()||Date.now()>a,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(o||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Yr.setState.of(new To(i.context))})),this.chunkBudget>0&&!(o&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>yr(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),sa=ut.define({combine(r){return r.length?r[0]:null},enables:r=>[Yr.state,Jj,at.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]}),gu=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var eq=ut.define(),aa=ut.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function Do(r){let e=r.facet(aa);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function oa(r,e){let t="",s=r.tabSize,n=r.facet(aa)[0];if(n==" "){for(;e>=s;)t+=" ",e-=s;n=" "}for(let i=0;i=e?tq(r,t,e):null}var hi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Do(e)}lineAt(e,t=1){let s=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:i}=this.options;return n!=null&&n>=s.from&&n<=s.to?i&&n==e?{text:"",from:e}:(t<0?n-1&&(i+=a-this.countColumn(s,s.search(/\S|$/))),i}countColumn(e,t=e.length){return os(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:s,from:n}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let a=i(n);if(a>-1)return a}return this.countColumn(s,s.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},fh=new kt;function tq(r,e,t){let s=e.resolveStack(t),n=s.node.enterUnfinishedNodesBefore(t);if(n!=s.node){let i=[];for(let a=n;a!=s.node;a=a.parent)i.push(a);for(let a=i.length-1;a>=0;a--)s={node:i[a],next:s}}return lw(s,r,t)}function lw(r,e,t){for(let s=r;s;s=s.next){let n=nq(s.node);if(n)return n(ih.create(e,t,s))}return 0}function rq(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function nq(r){let e=r.type.prop(fh);if(e)return e;let t=r.firstChild,s;if(t&&(s=t.type.prop(kt.closedBy))){let n=r.lastChild,i=n&&s.indexOf(n.name)>-1;return a=>cw(a,!0,1,void 0,i&&!rq(a)?n.from:void 0)}return r.parent==null?sq:null}function sq(){return 0}var ih=class r extends hi{constructor(e,t,s){super(e.state,e.options),this.base=e,this.pos=t,this.context=s}get node(){return this.context.node}static create(e,t,s){return new r(e,t,s)}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 s=e.resolve(t.from);for(;s.parent&&s.parent.from==s.from;)s=s.parent;if(iq(s,e))break;t=this.state.doc.lineAt(s.from)}return this.lineIndent(t.from)}continue(){return lw(this.context.next,this.base,this.pos)}};function iq(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function aq(r){let e=r.node,t=e.childAfter(e.from),s=e.lastChild;if(!t)return null;let n=r.options.simulateBreak,i=r.state.doc.lineAt(t.from),a=n==null||n<=i.from?i.to:Math.min(i.to,n);for(let l=t.to;;){let o=e.childAfter(l);if(!o||o==s)return null;if(!o.type.isSkipped){if(o.from>=a)return null;let u=/^ */.exec(i.text.slice(t.to-i.from))[0].length;return{from:t.from,to:t.to+u}}l=o.to}}function uw({closing:r,align:e=!0,units:t=1}){return s=>cw(s,e,t,r)}function cw(r,e,t,s,n){let i=r.textAfter,a=i.match(/^\s*/)[0].length,l=s&&i.slice(a,a+s.length)==s||n==r.pos+a,o=e?aq(r):null;return o?l?r.column(o.from):r.column(o.to):r.baseIndent+(l?0:r.unit*t)}var fw=r=>r.baseIndent;function vu({except:r,units:e=1}={}){return t=>{let s=r&&r.test(t.textAfter);return t.baseIndent+(s?0:e*t.unit)}}var oq=200;function pw(){return Vt.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let e=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!e.length)return r;let t=r.newDoc,{head:s}=r.newSelection.main,n=t.lineAt(s);if(s>n.from+oq)return r;let i=t.sliceString(n.from,s);if(!e.some(u=>u.test(i)))return r;let{state:a}=r,l=-1,o=[];for(let{head:u}of a.selection.ranges){let c=a.doc.lineAt(u);if(c.from==l)continue;l=c.from;let p=bu(a,c.from);if(p==null)continue;let h=/^\s*/.exec(c.text)[0],f=oa(a,p);h!=f&&o.push({from:c.from,to:c.from+h.length,insert:f})}return o.length?[r,{changes:o,sequential:!0}]:r})}var hw=new kt;function dw(r){let e=r.firstChild,t=r.lastChild;return e&&e.tol.prop(na)==a.data:a?l=>l==a:void 0,this.style=Kp(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:i}).style,this.module=s?new nn(s):null,this.themeType=t.themeType}static define(e,t){return new r(e,t||{})}},ah=ut.define(),mw=ut.define({combine(r){return r.length?[r[0]]:null}});function th(r){let e=r.facet(ah);return e.length?e:r.facet(mw)}function xu(r,e){let t=[lq],s;return r instanceof ia&&(r.module&&t.push(at.styleModule.of(r.module)),s=r.themeType),e?.fallback?t.push(mw.of(r)):s?t.push(ah.computeN([at.darkTheme],n=>n.facet(at.darkTheme)==(s=="dark")?[r]:[])):t.push(ah.of(r)),t}var oh=class{constructor(e){this.markCache=Object.create(null),this.tree=pr(e.state),this.decorations=this.buildDeco(e,th(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=pr(e.state),s=th(e.state),n=s!=th(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,s),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return yt.none;let s=new Fn;for(let{from:n,to:i}of e.visibleRanges)tw(this.tree,t,(a,l,o)=>{s.add(a,l,this.markCache[o]||(this.markCache[o]=yt.mark({class:o})))},n,i);return s.finish()}},lq=rn.high(rr.fromClass(oh,{decorations:r=>r.decorations})),gw=ia.define([{tag:we.meta,color:"#404740"},{tag:we.link,textDecoration:"underline"},{tag:we.heading,textDecoration:"underline",fontWeight:"bold"},{tag:we.emphasis,fontStyle:"italic"},{tag:we.strong,fontWeight:"bold"},{tag:we.strikethrough,textDecoration:"line-through"},{tag:we.keyword,color:"#708"},{tag:[we.atom,we.bool,we.url,we.contentSeparator,we.labelName],color:"#219"},{tag:[we.literal,we.inserted],color:"#164"},{tag:[we.string,we.deleted],color:"#a11"},{tag:[we.regexp,we.escape,we.special(we.string)],color:"#e40"},{tag:we.definition(we.variableName),color:"#00f"},{tag:we.local(we.variableName),color:"#30a"},{tag:[we.typeName,we.namespace],color:"#085"},{tag:we.className,color:"#167"},{tag:[we.special(we.variableName),we.macroName],color:"#256"},{tag:we.definition(we.propertyName),color:"#00c"},{tag:we.comment,color:"#940"},{tag:we.invalid,color:"#f00"}]),uq=at.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),yw=1e4,bw="()[]{}",vw=ut.define({combine(r){return kr(r,{afterCursor:!0,brackets:bw,maxScanDistance:yw,renderMatch:pq})}}),cq=yt.mark({class:"cm-matchingBracket"}),fq=yt.mark({class:"cm-nonmatchingBracket"});function pq(r){let e=[],t=r.matched?cq:fq;return e.push(t.range(r.start.from,r.start.to)),r.end&&e.push(t.range(r.end.from,r.end.to)),e}var hq=Yt.define({create(){return yt.none},update(r,e){if(!e.docChanged&&!e.selection)return r;let t=[],s=e.state.facet(vw);for(let n of e.state.selection.ranges){if(!n.empty)continue;let i=xn(e.state,n.head,-1,s)||n.head>0&&xn(e.state,n.head-1,1,s)||s.afterCursor&&(xn(e.state,n.head,1,s)||n.headat.decorations.from(r)}),dq=[hq,uq];function xw(r={}){return[vw.of(r),dq]}var mq=new kt;function lh(r,e,t){let s=r.prop(e<0?kt.openedBy:kt.closedBy);if(s)return s;if(r.name.length==1){let n=t.indexOf(r.name);if(n>-1&&n%2==(e<0?1:0))return[t[n+e]]}return null}function uh(r){let e=r.type.prop(mq);return e?e(r.node):r}function xn(r,e,t,s={}){let n=s.maxScanDistance||yw,i=s.brackets||bw,a=pr(r),l=a.resolveInner(e,t);for(let o=l;o;o=o.parent){let u=lh(o.type,t,i);if(u&&o.from0?e>=c.from&&ec.from&&e<=c.to))return gq(r,e,t,o,c,u,i)}}return yq(r,e,t,a,l.type,n,i)}function gq(r,e,t,s,n,i,a){let l=s.parent,o={from:n.from,to:n.to},u=0,c=l?.cursor();if(c&&(t<0?c.childBefore(s.from):c.childAfter(s.to)))do if(t<0?c.to<=s.from:c.from>=s.to){if(u==0&&i.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:t<0?e-1:e,to:t>0?e+1:e},c=r.doc.iterRange(e,t>0?r.doc.length:0),p=0;for(let h=0;!c.next().done&&h<=i;){let f=c.value;t<0&&(h+=f.length);let d=e+h*t;for(let m=t>0?0:f.length-1,g=t>0?f.length:-1;m!=g;m+=t){let y=a.indexOf(f[m]);if(!(y<0||s.resolveInner(d+m,1).type!=n))if(y%2==0==t>0)p++;else{if(p==1)return{start:u,end:{from:d+m,to:d+m+1},matched:y>>1==o>>1};p--}}t>0&&(h+=f.length)}return c.done?{start:u,matched:!1}:null}var bq=Object.create(null),sw=[Ar.none];var iw=[],aw=Object.create(null),vq=Object.create(null);for(let[r,e]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"]])vq[r]=xq(bq,e);function rh(r,e){iw.indexOf(r)>-1||(iw.push(r),console.warn(e))}function xq(r,e){let t=[];for(let l of e.split(" ")){let o=[];for(let u of l.split(".")){let c=r[u]||we[u];c?typeof c=="function"?o.length?o=o.map(c):rh(u,`Modifier ${u} used at start of tag`):o.length?rh(u,`Tag ${u} used as modifier`):o=Array.isArray(c)?c:[c]:rh(u,`Unknown highlighting tag ${u}`)}for(let u of o)t.push(u)}if(!t.length)return 0;let s=e.replace(/ /g,"_"),n=s+" "+t.map(l=>l.id),i=aw[n];if(i)return i.id;let a=aw[n]=Ar.define({id:sw.length,name:s,props:[du({[s]:t})]});return sw.push(a),a.id}var oY={rtl:yt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Zt.RTL}),ltr:yt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Zt.LTR}),auto:yt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var gh=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),s=bh(r.state,t.from);return s.line?Oq(r):s.block?Eq(r):!1};function yh(r,e){return({state:t,dispatch:s})=>{if(t.readOnly)return!1;let n=r(e,t);return n?(s(t.update(n)),!0):!1}}var Oq=yh(kq,0);var Sq=yh(Tw,0);var Eq=yh((r,e)=>Tw(r,e,wq(e)),0);function bh(r,e){let t=r.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var _o=50;function Cq(r,{open:e,close:t},s,n){let i=r.sliceDoc(s-_o,s),a=r.sliceDoc(n,n+_o),l=/\s*$/.exec(i)[0].length,o=/^\s*/.exec(a)[0].length,u=i.length-l;if(i.slice(u-e.length,u)==e&&a.slice(o,o+t.length)==t)return{open:{pos:s-l,margin:l&&1},close:{pos:n+o,margin:o&&1}};let c,p;n-s<=2*_o?c=p=r.sliceDoc(s,n):(c=r.sliceDoc(s,s+_o),p=r.sliceDoc(n-_o,n));let h=/^\s*/.exec(c)[0].length,f=/\s*$/.exec(p)[0].length,d=p.length-f-t.length;return c.slice(h,h+e.length)==e&&p.slice(d,d+t.length)==t?{open:{pos:s+h+e.length,margin:/\s/.test(c.charAt(h+e.length))?1:0},close:{pos:n-f-t.length,margin:/\s/.test(p.charAt(d-1))?1:0}}:null}function wq(r){let e=[];for(let t of r.selection.ranges){let s=r.doc.lineAt(t.from),n=t.to<=s.to?s:r.doc.lineAt(t.to),i=e.length-1;i>=0&&e[i].to>s.from?e[i].to=n.to:e.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:n.to})}return e}function Tw(r,e,t=e.selection.ranges){let s=t.map(i=>bh(e,i.from).block);if(!s.every(i=>i))return null;let n=t.map((i,a)=>Cq(e,s[a],i.from,i.to));if(r!=2&&!n.every(i=>i))return{changes:e.changes(t.map((i,a)=>n[a]?[]:[{from:i.from,insert:s[a].open+" "},{from:i.to,insert:" "+s[a].close}]))};if(r!=1&&n.some(i=>i)){let i=[];for(let a=0,l;an&&(i==a||a>p.from)){n=p.from;let h=/^\s*/.exec(p.text)[0].length,f=h==p.length,d=p.text.slice(h,h+u.length)==u?h:-1;hi.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:l,token:o,indent:u,empty:c,single:p}of s)(p||!c)&&i.push({from:l.from+u,insert:o+" "});let a=e.changes(i);return{changes:a,selection:e.selection.map(a,1)}}else if(r!=1&&s.some(i=>i.comment>=0)){let i=[];for(let{line:a,comment:l,token:o}of s)if(l>=0){let u=a.from+l,c=u+o.length;a.text[c-a.from]==" "&&c++,i.push({from:u,to:c})}return{changes:i}}return null}var hh=Mr.define(),Aq=Mr.define(),Pq=ut.define(),Dw=ut.define({combine(r){return kr(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(s,n)=>e(s,n)||t(s,n)})}}),_w=Yt.define({create(){return di.empty},update(r,e){let t=e.state.facet(Dw),s=e.annotation(hh);if(s){let o=On.fromTransaction(e,s.selection),u=s.side,c=u==0?r.undone:r.done;return o?c=Su(c,c.length,t.minDepth,o):c=Fw(c,e.startState.selection),new di(u==0?s.rest:c,u==0?c:s.rest)}let n=e.annotation(Aq);if((n=="full"||n=="before")&&(r=r.isolate()),e.annotation(lr.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let i=On.fromTransaction(e),a=e.annotation(lr.time),l=e.annotation(lr.userEvent);return i?r=r.addChanges(i,a,l,t,e):e.selection&&(r=r.addSelection(e.startState.selection,a,l,t.newGroupDelay)),(n=="full"||n=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new di(r.done.map(On.fromJSON),r.undone.map(On.fromJSON))}});function Iw(r={}){return[_w,Dw.of(r),at.domEventHandlers({beforeinput(e,t){let s=e.inputType=="historyUndo"?Cu:e.inputType=="historyRedo"?Io:null;return s?(e.preventDefault(),s(t)):!1}})]}function Eu(r,e){return function({state:t,dispatch:s}){if(!e&&t.readOnly)return!1;let n=t.field(_w,!1);if(!n)return!1;let i=n.pop(r,t,e);return i?(s(i),!0):!1}}var Cu=Eu(0,!1),Io=Eu(1,!1),Tq=Eu(0,!0),Dq=Eu(1,!0);var On=class r{constructor(e,t,s,n,i){this.changes=e,this.effects=t,this.mapped=s,this.startSelection=n,this.selectionsAfter=i}setSelAfter(e){return new r(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,s;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(s=this.startSelection)===null||s===void 0?void 0:s.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new r(e.changes&&Dr.fromJSON(e.changes),[],e.mapped&&as.fromJSON(e.mapped),e.startSelection&&Ze.fromJSON(e.startSelection),e.selectionsAfter.map(Ze.fromJSON))}static fromTransaction(e,t){let s=un;for(let n of e.startState.facet(Pq)){let i=n(e);i.length&&(s=s.concat(i))}return!s.length&&e.changes.empty?null:new r(e.changes.invert(e.startState.doc),s,void 0,t||e.startState.selection,un)}static selection(e){return new r(void 0,un,void 0,void 0,e)}};function Su(r,e,t,s){let n=e+1>t+20?e-t-1:0,i=r.slice(n,e);return i.push(s),i}function _q(r,e){let t=[],s=!1;return r.iterChangedRanges((n,i)=>t.push(n,i)),e.iterChangedRanges((n,i,a,l)=>{for(let o=0;o=u&&a<=c&&(s=!0)}}),s}function Iq(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((t,s)=>t.empty!=e.ranges[s].empty).length===0}function Rw(r,e){return r.length?e.length?r.concat(e):r:e}var un=[],Rq=200;function Fw(r,e){if(r.length){let t=r[r.length-1],s=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Rq));return s.length&&s[s.length-1].eq(e)?r:(s.push(e),Su(r,r.length-1,1e9,t.setSelAfter(s)))}else return[On.selection([e])]}function Fq(r){let e=r[r.length-1],t=r.slice();return t[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function ph(r,e){if(!r.length)return r;let t=r.length,s=un;for(;t;){let n=Bq(r[t-1],e,s);if(n.changes&&!n.changes.empty||n.effects.length){let i=r.slice(0,t);return i[t-1]=n,i}else e=n.mapped,t--,s=n.selectionsAfter}return s.length?[On.selection(s)]:un}function Bq(r,e,t){let s=Rw(r.selectionsAfter.length?r.selectionsAfter.map(l=>l.map(e)):un,t);if(!r.changes)return On.selection(s);let n=r.changes.map(e),i=e.mapDesc(r.changes,!0),a=r.mapped?r.mapped.composeDesc(i):i;return new On(n,Et.mapEffects(r.effects,e),a,r.startSelection.map(i),s)}var Lq=/^(input\.type|delete)($|\.)/,di=class r{constructor(e,t,s=0,n=void 0){this.done=e,this.undone=t,this.prevTime=s,this.prevUserEvent=n}isolate(){return this.prevTime?new r(this.done,this.undone):this}addChanges(e,t,s,n,i){let a=this.done,l=a[a.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!s||Lq.test(s))&&(!l.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?r.moveByChar(t,e):wu(t,e))}function Pr(r){return r.textDirectionAt(r.state.selection.main.head)==Zt.LTR}var Nw=r=>Lw(r,!Pr(r)),$w=r=>Lw(r,Pr(r));function Mw(r,e){return Sn(r,t=>t.empty?r.moveByGroup(t,e):wu(t,e))}var Nq=r=>Mw(r,!Pr(r)),$q=r=>Mw(r,Pr(r));var dY=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Mq(r,e,t){if(e.type.prop(t))return!0;let s=e.to-e.from;return s&&(s>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function ku(r,e,t){let s=pr(r).resolveInner(e.head),n=t?kt.closedBy:kt.openedBy;for(let o=e.head;;){let u=t?s.childAfter(o):s.childBefore(o);if(!u)break;Mq(r,u,n)?s=u:o=t?u.to:u.from}let i=s.type.prop(n),a,l;return i&&(a=t?xn(r,s.from,1):xn(r,s.to,-1))&&a.matched?l=t?a.end.to:a.end.from:l=t?s.to:s.from,Ze.cursor(l,t?-1:1)}var jq=r=>Sn(r,e=>ku(r.state,e,!Pr(r))),qq=r=>Sn(r,e=>ku(r.state,e,Pr(r)));function jw(r,e){return Sn(r,t=>{if(!t.empty)return wu(t,e);let s=r.moveVertically(t,e);return s.head!=t.head?s:r.moveToLineBoundary(t,e)})}var qw=r=>jw(r,!1),Qw=r=>jw(r,!0);function Vw(r){let e=r.scrollDOM.clientHeighta.empty?r.moveVertically(a,e,t.height):wu(a,e));if(n.eq(s.selection))return!1;let i;if(t.selfScroll){let a=r.coordsAtPos(s.selection.main.head),l=r.scrollDOM.getBoundingClientRect(),o=l.top+t.marginTop,u=l.bottom-t.marginBottom;a&&a.top>o&&a.bottomUw(r,!1),dh=r=>Uw(r,!0);function Bs(r,e,t){let s=r.lineBlockAt(e.head),n=r.moveToLineBoundary(e,t);if(n.head==e.head&&n.head!=(t?s.to:s.from)&&(n=r.moveToLineBoundary(e,t,!1)),!t&&n.head==s.from&&s.length){let i=/^\s*/.exec(r.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;i&&e.head!=s.from+i&&(n=Ze.cursor(s.from+i))}return n}var Qq=r=>Sn(r,e=>Bs(r,e,!0)),Vq=r=>Sn(r,e=>Bs(r,e,!1)),Uq=r=>Sn(r,e=>Bs(r,e,!Pr(r))),zq=r=>Sn(r,e=>Bs(r,e,Pr(r))),Zq=r=>Sn(r,e=>Ze.cursor(r.lineBlockAt(e.head).from,1)),Wq=r=>Sn(r,e=>Ze.cursor(r.lineBlockAt(e.head).to,-1));function Gq(r,e,t){let s=!1,n=la(r.selection,i=>{let a=xn(r,i.head,-1)||xn(r,i.head,1)||i.head>0&&xn(r,i.head-1,1)||i.headGq(r,e,!1);function cn(r,e){let t=la(r.state.selection,s=>{let n=e(s);return Ze.range(s.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return t.eq(r.state.selection)?!1:(r.dispatch(Un(r.state,t)),!0)}function zw(r,e){return cn(r,t=>r.moveByChar(t,e))}var Zw=r=>zw(r,!Pr(r)),Ww=r=>zw(r,Pr(r));function Gw(r,e){return cn(r,t=>r.moveByGroup(t,e))}var Yq=r=>Gw(r,!Pr(r)),Hq=r=>Gw(r,Pr(r));var Kq=r=>cn(r,e=>ku(r.state,e,!Pr(r))),Jq=r=>cn(r,e=>ku(r.state,e,Pr(r)));function Xw(r,e){return cn(r,t=>r.moveVertically(t,e))}var Yw=r=>Xw(r,!1),Hw=r=>Xw(r,!0);function Kw(r,e){return cn(r,t=>r.moveVertically(t,e,Vw(r).height))}var Sw=r=>Kw(r,!1),Ew=r=>Kw(r,!0),eQ=r=>cn(r,e=>Bs(r,e,!0)),tQ=r=>cn(r,e=>Bs(r,e,!1)),rQ=r=>cn(r,e=>Bs(r,e,!Pr(r))),nQ=r=>cn(r,e=>Bs(r,e,Pr(r))),sQ=r=>cn(r,e=>Ze.cursor(r.lineBlockAt(e.head).from)),iQ=r=>cn(r,e=>Ze.cursor(r.lineBlockAt(e.head).to)),Cw=({state:r,dispatch:e})=>(e(Un(r,{anchor:0})),!0),ww=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.doc.length})),!0),kw=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.selection.main.anchor,head:0})),!0),Aw=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),vh=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),aQ=({state:r,dispatch:e})=>{let t=Au(r).map(({from:s,to:n})=>Ze.range(s,Math.min(n+1,r.doc.length)));return e(r.update({selection:Ze.create(t),userEvent:"select"})),!0},oQ=({state:r,dispatch:e})=>{let t=la(r.selection,s=>{let n=pr(r),i=n.resolveStack(s.from,1);if(s.empty){let a=n.resolveStack(s.from,-1);a.node.from>=i.node.from&&a.node.to<=i.node.to&&(i=a)}for(let a=i;a;a=a.next){let{node:l}=a;if((l.from=s.to||l.to>s.to&&l.from<=s.from)&&a.next)return Ze.range(l.to,l.from)}return s});return t.eq(r.selection)?!1:(e(Un(r,t)),!0)},lQ=({state:r,dispatch:e})=>{let t=r.selection,s=null;return t.ranges.length>1?s=Ze.create([t.main]):t.main.empty||(s=Ze.create([Ze.cursor(t.main.head)])),s?(e(Un(r,s)),!0):!1};function Ro(r,e){if(r.state.readOnly)return!1;let t="delete.selection",{state:s}=r,n=s.changeByRange(i=>{let{from:a,to:l}=i;if(a==l){let o=e(i);oa&&(t="delete.forward",o=Ou(r,o,!0)),a=Math.min(a,o),l=Math.max(l,o)}else a=Ou(r,a,!1),l=Ou(r,l,!0);return a==l?{range:i}:{changes:{from:a,to:l},range:Ze.cursor(a,an(r)))s.between(e,e,(n,i)=>{ne&&(e=t?i:n)});return e}var Jw=(r,e,t)=>Ro(r,s=>{let n=s.from,{state:i}=r,a=i.doc.lineAt(n),l,o;if(t&&!e&&n>a.from&&nJw(r,!1,!0);var ek=r=>Jw(r,!0,!1),tk=(r,e)=>Ro(r,t=>{let s=t.head,{state:n}=r,i=n.doc.lineAt(s),a=n.charCategorizer(s);for(let l=null;;){if(s==(e?i.to:i.from)){s==t.head&&i.number!=(e?n.doc.lines:1)&&(s+=e?1:-1);break}let o=ur(i.text,s-i.from,e)+i.from,u=i.text.slice(Math.min(s,o)-i.from,Math.max(s,o)-i.from),c=a(u);if(l!=null&&c!=l)break;(u!=" "||s!=t.head)&&(l=c),s=o}return s}),rk=r=>tk(r,!1),uQ=r=>tk(r,!0),cQ=r=>Ro(r,e=>{let t=r.lineBlockAt(e.head).to;return e.headRo(r,e=>{let t=r.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),pQ=r=>Ro(r,e=>{let t=r.moveToLineBoundary(e,!0).head;return e.head{if(r.readOnly)return!1;let t=r.changeByRange(s=>({changes:{from:s.from,to:s.to,insert:It.of(["",""])},range:Ze.cursor(s.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},dQ=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(s=>{if(!s.empty||s.from==0||s.from==r.doc.length)return{range:s};let n=s.from,i=r.doc.lineAt(n),a=n==i.from?n-1:ur(i.text,n-i.from,!1)+i.from,l=n==i.to?n+1:ur(i.text,n-i.from,!0)+i.from;return{changes:{from:a,to:l,insert:r.doc.slice(n,l).append(r.doc.slice(a,n))},range:Ze.cursor(l)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Au(r){let e=[],t=-1;for(let s of r.selection.ranges){let n=r.doc.lineAt(s.from),i=r.doc.lineAt(s.to);if(!s.empty&&s.to==i.from&&(i=r.doc.lineAt(s.to-1)),t>=n.number){let a=e[e.length-1];a.to=i.to,a.ranges.push(s)}else e.push({from:n.from,to:i.to,ranges:[s]});t=i.number+1}return e}function nk(r,e,t){if(r.readOnly)return!1;let s=[],n=[];for(let i of Au(r)){if(t?i.to==r.doc.length:i.from==0)continue;let a=r.doc.lineAt(t?i.to+1:i.from-1),l=a.length+1;if(t){s.push({from:i.to,to:a.to},{from:i.from,insert:a.text+r.lineBreak});for(let o of i.ranges)n.push(Ze.range(Math.min(r.doc.length,o.anchor+l),Math.min(r.doc.length,o.head+l)))}else{s.push({from:a.from,to:i.from},{from:i.to,insert:r.lineBreak+a.text});for(let o of i.ranges)n.push(Ze.range(o.anchor-l,o.head-l))}}return s.length?(e(r.update({changes:s,scrollIntoView:!0,selection:Ze.create(n,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}var mQ=({state:r,dispatch:e})=>nk(r,e,!1),gQ=({state:r,dispatch:e})=>nk(r,e,!0);function sk(r,e,t){if(r.readOnly)return!1;let s=[];for(let n of Au(r))t?s.push({from:n.from,insert:r.doc.slice(n.from,n.to)+r.lineBreak}):s.push({from:n.to,insert:r.lineBreak+r.doc.slice(n.from,n.to)});return e(r.update({changes:s,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var yQ=({state:r,dispatch:e})=>sk(r,e,!1),bQ=({state:r,dispatch:e})=>sk(r,e,!0),vQ=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(Au(e).map(({from:n,to:i})=>(n>0?n--:i{let i;if(r.lineWrapping){let a=r.lineBlockAt(n.head),l=r.coordsAtPos(n.head,n.assoc||1);l&&(i=a.bottom+r.documentTop-l.bottom+r.defaultLineHeight/2)}return r.moveVertically(n,!0,i)}).map(t);return r.dispatch({changes:t,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0};function xQ(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=pr(r).resolveInner(e),s=t.childBefore(e),n=t.childAfter(e),i;return s&&n&&s.to<=e&&n.from>=e&&(i=s.type.prop(kt.closedBy))&&i.indexOf(n.name)>-1&&r.doc.lineAt(s.to).from==r.doc.lineAt(n.from).from&&!/\S/.test(r.sliceDoc(s.to,n.from))?{from:s.to,to:n.from}:null}var Pw=ik(!1),OQ=ik(!0);function ik(r){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=e.changeByRange(n=>{let{from:i,to:a}=n,l=e.doc.lineAt(i),o=!r&&i==a&&xQ(e,i);r&&(i=a=(a<=l.to?l:e.doc.lineAt(a)).to);let u=new hi(e,{simulateBreak:i,simulateDoubleBreak:!!o}),c=bu(u,i);for(c==null&&(c=os(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));al.from&&i{let n=[];for(let a=s.from;a<=s.to;){let l=r.doc.lineAt(a);l.number>t&&(s.empty||s.to>l.from)&&(e(l,n,s),t=l.number),a=l.to+1}let i=r.changes(n);return{changes:n,range:Ze.range(i.mapPos(s.anchor,1),i.mapPos(s.head,1))}})}var SQ=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=Object.create(null),s=new hi(r,{overrideIndentation:i=>{let a=t[i];return a??-1}}),n=xh(r,(i,a,l)=>{let o=bu(s,i.from);if(o==null)return;/\S/.test(i.text)||(o=0);let u=/^\s*/.exec(i.text)[0],c=oa(r,o);(u!=c||l.fromr.readOnly?!1:(e(r.update(xh(r,(t,s)=>{s.push({from:t.from,insert:r.facet(aa)})}),{userEvent:"input.indent"})),!0),ak=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(xh(r,(t,s)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let i=os(n,r.tabSize),a=0,l=oa(r,Math.max(0,i-Do(r)));for(;a(r.setTabFocusMode(),!0);var CQ=[{key:"Ctrl-b",run:Nw,shift:Zw,preventDefault:!0},{key:"Ctrl-f",run:$w,shift:Ww},{key:"Ctrl-p",run:qw,shift:Yw},{key:"Ctrl-n",run:Qw,shift:Hw},{key:"Ctrl-a",run:Zq,shift:sQ},{key:"Ctrl-e",run:Wq,shift:iQ},{key:"Ctrl-d",run:ek},{key:"Ctrl-h",run:mh},{key:"Ctrl-k",run:cQ},{key:"Ctrl-Alt-h",run:rk},{key:"Ctrl-o",run:hQ},{key:"Ctrl-t",run:dQ},{key:"Ctrl-v",run:dh}],wQ=[{key:"ArrowLeft",run:Nw,shift:Zw,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Nq,shift:Yq,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Uq,shift:rQ,preventDefault:!0},{key:"ArrowRight",run:$w,shift:Ww,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:$q,shift:Hq,preventDefault:!0},{mac:"Cmd-ArrowRight",run:zq,shift:nQ,preventDefault:!0},{key:"ArrowUp",run:qw,shift:Yw,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Cw,shift:kw},{mac:"Ctrl-ArrowUp",run:Ow,shift:Sw},{key:"ArrowDown",run:Qw,shift:Hw,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ww,shift:Aw},{mac:"Ctrl-ArrowDown",run:dh,shift:Ew},{key:"PageUp",run:Ow,shift:Sw},{key:"PageDown",run:dh,shift:Ew},{key:"Home",run:Vq,shift:tQ,preventDefault:!0},{key:"Mod-Home",run:Cw,shift:kw},{key:"End",run:Qq,shift:eQ,preventDefault:!0},{key:"Mod-End",run:ww,shift:Aw},{key:"Enter",run:Pw,shift:Pw},{key:"Mod-a",run:vh},{key:"Backspace",run:mh,shift:mh},{key:"Delete",run:ek},{key:"Mod-Backspace",mac:"Alt-Backspace",run:rk},{key:"Mod-Delete",mac:"Alt-Delete",run:uQ},{mac:"Mod-Backspace",run:fQ},{mac:"Mod-Delete",run:pQ}].concat(CQ.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),ok=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:jq,shift:Kq},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:qq,shift:Jq},{key:"Alt-ArrowUp",run:mQ},{key:"Shift-Alt-ArrowUp",run:yQ},{key:"Alt-ArrowDown",run:gQ},{key:"Shift-Alt-ArrowDown",run:bQ},{key:"Escape",run:lQ},{key:"Mod-Enter",run:OQ},{key:"Alt-l",mac:"Ctrl-l",run:aQ},{key:"Mod-i",run:oQ,preventDefault:!0},{key:"Mod-[",run:ak},{key:"Mod-]",run:Pu},{key:"Mod-Alt-\\",run:SQ},{key:"Shift-Mod-k",run:vQ},{key:"Shift-Mod-\\",run:Xq},{key:"Mod-/",run:gh},{key:"Alt-A",run:Sq},{key:"Ctrl-m",mac:"Shift-Alt-m",run:EQ}].concat(wQ),lk={key:"Tab",run:Pu,shift:ak};function Ut(){var r=arguments[0];typeof r=="string"&&(r=document.createElement(r));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){var n=t[s];typeof n=="string"?r.setAttribute(s,n):n!=null&&(r[s]=n)}e++}for(;er.normalize("NFKD"):r=>r,Ns=class{constructor(e,t,s=0,n=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(s,n),this.bufferStart=s,this.normalize=i?l=>i(ck(l)):ck,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 gr(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=Ka(e),s=this.bufferStart+this.bufferPos;this.bufferPos+=$r(e);let n=this.normalize(t);for(let i=0,a=s;;i++){let l=n.charCodeAt(i),o=this.match(l,a,this.bufferPos+this.bufferStart);if(i==n.length-1){if(o)return this.value=o,this;break}a==s&&ithis.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 s=this.curLineStart+t.index,n=s+t[0].length;if(this.matchPos=Fu(this.text,n+(s==n?1:0)),s==this.curLineStart+this.curLine.length&&this.nextLine(),(sthis.value.to)&&(!this.test||this.test(s,n,t)))return this.value={from:s,to:n,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=s||n.to<=t){let l=new r(t,e.sliceString(t,s));return Oh.set(e,l),l}if(n.from==t&&n.to==s)return n;let{text:i,from:a}=n;return a>t&&(i=e.sliceString(t,a)+i,a=t),n.to=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 s=this.flat.from+t.index,n=s+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(s,n,t)))return this.value={from:s,to:n,match:t},this.matchPos=Fu(this.text,n+(s==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Iu.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(_u.prototype[Symbol.iterator]=Ru.prototype[Symbol.iterator]=function(){return this});function kQ(r){try{return new RegExp(r,Ah),!0}catch{return!1}}function Fu(r,e){if(e>=r.length)return e;let t=r.lineAt(e),s;for(;e=56320&&s<57344;)e++;return e}function Sh(r){let e=String(r.state.doc.lineAt(r.state.selection.main.head).number),t=Ut("input",{class:"cm-textfield",name:"line",value:e}),s=Ut("form",{class:"cm-gotoLine",onkeydown:i=>{i.keyCode==27?(i.preventDefault(),r.dispatch({effects:Bu.of(!1)}),r.focus()):i.keyCode==13&&(i.preventDefault(),n())},onsubmit:i=>{i.preventDefault(),n()}},Ut("label",r.state.phrase("Go to line"),": ",t)," ",Ut("button",{class:"cm-button",type:"submit"},r.state.phrase("go")));function n(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!i)return;let{state:a}=r,l=a.doc.lineAt(a.selection.main.head),[,o,u,c,p]=i,h=c?+c.slice(1):0,f=u?+u:l.number;if(u&&p){let g=f/100;o&&(g=g*(o=="-"?-1:1)+l.number/a.doc.lines),f=Math.round(a.doc.lines*g)}else u&&o&&(f=f*(o=="-"?-1:1)+l.number);let d=a.doc.line(Math.max(1,Math.min(a.doc.lines,f))),m=Ze.cursor(d.from+Math.max(0,Math.min(h,d.length)));r.dispatch({effects:[Bu.of(!1),at.scrollIntoView(m.from,{y:"center"})],selection:m}),r.focus()}return{dom:s}}var Bu=Et.define(),fk=Yt.define({create(){return!0},update(r,e){for(let t of e.effects)t.is(Bu)&&(r=t.value);return r},provide:r=>ui.from(r,e=>e?Sh:null)}),AQ=r=>{let e=Ji(r,Sh);if(!e){let t=[Bu.of(!0)];r.state.field(fk,!1)==null&&t.push(Et.appendConfig.of([fk,PQ])),r.dispatch({effects:t}),e=Ji(r,Sh)}return e&&e.dom.querySelector("input").select(),!0},PQ=at.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),TQ={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},mk=ut.define({combine(r){return kr(r,TQ,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function gk(r){let e=[FQ,RQ];return r&&e.push(mk.of(r)),e}var DQ=yt.mark({class:"cm-selectionMatch"}),_Q=yt.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function pk(r,e,t,s){return(t==0||r(e.sliceDoc(t-1,t))!=zt.Word)&&(s==e.doc.length||r(e.sliceDoc(s,s+1))!=zt.Word)}function IQ(r,e,t,s){return r(e.sliceDoc(t,t+1))==zt.Word&&r(e.sliceDoc(s-1,s))==zt.Word}var RQ=rr.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.selectionSet||r.docChanged||r.viewportChanged)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=r.state.facet(mk),{state:t}=r,s=t.selection;if(s.ranges.length>1)return yt.none;let n=s.main,i,a=null;if(n.empty){if(!e.highlightWordAroundCursor)return yt.none;let o=t.wordAt(n.head);if(!o)return yt.none;a=t.charCategorizer(n.head),i=t.sliceDoc(o.from,o.to)}else{let o=n.to-n.from;if(o200)return yt.none;if(e.wholeWords){if(i=t.sliceDoc(n.from,n.to),a=t.charCategorizer(n.head),!(pk(a,t,n.from,n.to)&&IQ(a,t,n.from,n.to)))return yt.none}else if(i=t.sliceDoc(n.from,n.to),!i)return yt.none}let l=[];for(let o of r.visibleRanges){let u=new Ns(t.doc,i,o.from,o.to);for(;!u.next().done;){let{from:c,to:p}=u.value;if((!a||pk(a,t,c,p))&&(n.empty&&c<=n.from&&p>=n.to?l.push(_Q.range(c,p)):(c>=n.to||p<=n.from)&&l.push(DQ.range(c,p)),l.length>e.maxMatches))return yt.none}}return yt.set(l)}},{decorations:r=>r.decorations}),FQ=at.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),BQ=({state:r,dispatch:e})=>{let{selection:t}=r,s=Ze.create(t.ranges.map(n=>r.wordAt(n.head)||Ze.cursor(n.head)),t.mainIndex);return s.eq(t)?!1:(e(r.update({selection:s})),!0)};function LQ(r,e){let{main:t,ranges:s}=r.selection,n=r.wordAt(t.head),i=n&&n.from==t.from&&n.to==t.to;for(let a=!1,l=new Ns(r.doc,e,s[s.length-1].to);;)if(l.next(),l.done){if(a)return null;l=new Ns(r.doc,e,0,Math.max(0,s[s.length-1].from-1)),a=!0}else{if(a&&s.some(o=>o.from==l.value.from))continue;if(i){let o=r.wordAt(l.value.from);if(!o||o.from!=l.value.from||o.to!=l.value.to)continue}return l.value}}var NQ=({state:r,dispatch:e})=>{let{ranges:t}=r.selection;if(t.some(i=>i.from===i.to))return BQ({state:r,dispatch:e});let s=r.sliceDoc(t[0].from,t[0].to);if(r.selection.ranges.some(i=>r.sliceDoc(i.from,i.to)!=s))return!1;let n=LQ(r,s);return n?(e(r.update({selection:r.selection.addRange(Ze.range(n.from,n.to),!1),effects:at.scrollIntoView(n.to)})),!0):!1},fa=ut.define({combine(r){return kr(r,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new kh(e),scrollToMatch:e=>at.scrollIntoView(e)})}});var Lu=class{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||kQ(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,s)=>s=="n"?` +-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,wp),mj={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},qf=null;function gj(){var r;if(qf==null&&typeof document<"u"&&document.body){let e=document.body.style;qf=((r=e.tabSize)!==null&&r!==void 0?r:e.MozTabSize)!=null}return qf||!1}var Ml=ut.define({combine(r){let e=kr(r,{render:null,specialChars:dj,addSpecialChars:null});return(e.replaceTabs=!gj())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,wp)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,wp)),e}});function NC(r={}){return[Ml.of(r),yj()]}var wE=null;function yj(){return wE||(wE=rr.fromClass(class{constructor(r){this.view=r,this.decorations=yt.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(r.state.facet(Ml)),this.decorations=this.decorator.createDeco(r)}makeDecorator(r){return new Cp({regexp:r.specialChars,decoration:(e,t,s)=>{let{doc:n}=t.state,i=gr(e[0],0);if(i==9){let a=n.lineAt(s),l=t.state.tabSize,o=os(a.text,l,s-a.from);return yt.replace({widget:new Ap((l-o%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[i]||(this.decorationCache[i]=yt.replace({widget:new kp(r,i)}))},boundary:r.replaceTabs?void 0:/[^]/})}update(r){let e=r.state.facet(Ml);r.startState.facet(Ml)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(r.view)):this.decorations=this.decorator.updateDeco(r,this.decorations)}},{decorations:r=>r.decorations}))}var bj="\u2022";function vj(r){return r>=32?bj:r==10?"\u2424":String.fromCharCode(9216+r)}var kp=class extends an{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=vj(this.code),s=e.state.phrase("Control character")+" "+(mj[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,s,t);if(n)return n;let i=document.createElement("span");return i.textContent=t,i.title=s,i.setAttribute("aria-label",s),i.className="cm-specialChar",i}ignoreEvent(){return!1}},Ap=class extends an{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}},kE=rr.fromClass(class{constructor(){this.height=1e3,this.attrs={style:"padding-bottom: 1000px"}}update(r){let{view:e}=r,t=e.viewState.editorHeight-e.defaultLineHeight-e.documentPadding.top-.5;t>=0&&t!=this.height&&(this.height=t,this.attrs={style:`padding-bottom: ${t}px`})}});function $C(){return[kE,su.of(r=>{var e;return((e=r.plugin(kE))===null||e===void 0?void 0:e.attrs)||null})]}function MC(){return Oj}var xj=yt.line({class:"cm-activeLine"}),Oj=rr.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.docChanged||r.selectionSet)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=-1,t=[];for(let s of r.state.selection.ranges){let n=r.lineBlockAt(s.head);n.from>e&&(t.push(xj.range(n.from)),e=n.from)}return yt.set(t)}},{decorations:r=>r.decorations});var Pp=2e3;function Sj(r,e,t){let s=Math.min(e.line,t.line),n=Math.max(e.line,t.line),i=[];if(e.off>Pp||t.off>Pp||e.col<0||t.col<0){let a=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let o=s;o<=n;o++){let u=r.doc.line(o);u.length<=l&&i.push(Ze.range(u.from+a,u.to+l))}}else{let a=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let o=s;o<=n;o++){let u=r.doc.line(o),c=Cl(u.text,a,r.tabSize,!0);if(c<0)i.push(Ze.cursor(u.to));else{let p=Cl(u.text,l,r.tabSize);i.push(Ze.range(u.from+c,u.from+p))}}}return i}function Ej(r,e){let t=r.coordsAtPos(r.viewport.from);return t?Math.round(Math.abs((t.left-e)/r.defaultCharacterWidth)):-1}function AE(r,e){let t=r.posAtCoords({x:e.clientX,y:e.clientY},!1),s=r.state.doc.lineAt(t),n=t-s.from,i=n>Pp?-1:n==s.length?Ej(r,e.clientX):os(s.text,r.state.tabSize,t-s.from);return{line:s.number,col:i,off:n}}function Cj(r,e){let t=AE(r,e),s=r.state.selection;return t?{update(n){if(n.docChanged){let i=n.changes.mapPos(n.startState.doc.line(t.line).from),a=n.state.doc.lineAt(i);t={line:a.number,col:t.col,off:Math.min(t.off,a.length)},s=s.map(n.changes)}},get(n,i,a){let l=AE(r,n);if(!l)return s;let o=Sj(r.state,t,l);return o.length?a?Ze.create(o.concat(s.ranges)):Ze.create(o):s}}:null}function jC(r){let e=r?.eventFilter||(t=>t.altKey&&t.button==0);return at.mouseSelectionStyle.of((t,s)=>e(s)?Cj(t,s):null)}var wj={Alt:[18,r=>!!r.altKey],Control:[17,r=>!!r.ctrlKey],Shift:[16,r=>!!r.shiftKey],Meta:[91,r=>!!r.metaKey]},kj={style:"cursor: crosshair"};function qC(r={}){let[e,t]=wj[r.key||"Alt"],s=rr.fromClass(class{constructor(n){this.view=n,this.isDown=!1}set(n){this.isDown!=n&&(this.isDown=n,this.view.update([]))}},{eventObservers:{keydown(n){this.set(n.keyCode==e||t(n))},keyup(n){(n.keyCode==e||!t(n))&&this.set(!1)},mousemove(n){this.set(t(n))}}});return[s,at.contentAttributes.of(n=>{var i;return!((i=n.plugin(s))===null||i===void 0)&&i.isDown?kj:null})]}var Ja="-10000px",Hl=class{constructor(e,t,s,n){this.facet=t,this.createTooltipView=s,this.removeTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter(a=>a);let i=null;this.tooltipViews=this.tooltips.map(a=>i=s(a,i))}update(e,t){var s;let n=e.state.facet(this.facet),i=n.filter(o=>o);if(n===this.input){for(let o of this.tooltipViews)o.update&&o.update(e);return!1}let a=[],l=t?[]:null;for(let o=0;ot[u]=o),t.length=l.length),this.input=n,this.tooltips=i,this.tooltipViews=a,!0}};function Aj(r){let{win:e}=r;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}var Qf=ut.define({combine:r=>{var e,t,s;return{position:ft.ios?"absolute":((e=r.find(n=>n.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=r.find(n=>n.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((s=r.find(n=>n.tooltipSpace))===null||s===void 0?void 0:s.tooltipSpace)||Aj}}}),PE=new WeakMap,Mp=rr.fromClass(class{constructor(r){this.view=r,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=r.state.facet(Qf);this.position=e.position,this.parent=e.parent,this.classes=r.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Hl(r,Ki,(t,s)=>this.createTooltip(t,s),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),r.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let r of this.manager.tooltipViews)this.intersectionObserver.observe(r.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(r){r.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(r,this.above);e&&this.observeIntersection();let t=e||r.geometryChanged,s=r.state.facet(Qf);if(s.position!=this.position&&!this.madeAbsolute){this.position=s.position;for(let n of this.manager.tooltipViews)n.dom.style.position=this.position;t=!0}if(s.parent!=this.parent){this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer();for(let n of this.manager.tooltipViews)this.container.appendChild(n.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(r,e){let t=r.create(this.view),s=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),r.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let n=document.createElement("div");n.className="cm-tooltip-arrow",t.dom.appendChild(n)}return t.dom.style.position=this.position,t.dom.style.top=Ja,t.dom.style.left="0px",this.container.insertBefore(t.dom,s),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var r,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let s of this.manager.tooltipViews)s.dom.remove(),(r=s.destroy)===null||r===void 0||r.call(s);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let r=this.view.dom.getBoundingClientRect(),e=1,t=1,s=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:n}=this.manager.tooltipViews[0];if(ft.gecko)s=n.offsetParent!=this.container.ownerDocument.body;else if(n.style.top==Ja&&n.style.left=="0px"){let i=n.getBoundingClientRect();s=Math.abs(i.top+1e4)>1||Math.abs(i.left)>1}}if(s||this.position=="absolute")if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:r,parent:this.parent?this.container.getBoundingClientRect():r,pos:this.manager.tooltips.map((n,i)=>{let a=this.manager.tooltipViews[i];return a.getCoords?a.getCoords(n.pos):this.view.coordsAtPos(n.pos)}),size:this.manager.tooltipViews.map(({dom:n})=>n.getBoundingClientRect()),space:this.view.state.facet(Qf).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:s}}writeMeasure(r){var e;if(r.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{editor:t,space:s,scaleX:n,scaleY:i}=r,a=[];for(let l=0;l=Math.min(t.bottom,s.bottom)||p.rightMath.min(t.right,s.right)+.1){c.style.top=Ja;continue}let f=o.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,d=f?7:0,m=h.right-h.left,g=(e=PE.get(u))!==null&&e!==void 0?e:h.bottom-h.top,y=u.offset||Tj,v=this.view.textDirection==Zt.LTR,x=h.width>s.right-s.left?v?s.left:s.right-h.width:v?Math.max(s.left,Math.min(p.left-(f?14:0)+y.x,s.right-m)):Math.min(Math.max(s.left,p.left-m+(f?14:0)-y.x),s.right-m),S=this.above[l];!o.strictSide&&(S?p.top-(h.bottom-h.top)-y.ys.bottom)&&S==s.bottom-p.bottom>p.top-s.top&&(S=this.above[l]=!S);let C=(S?p.top-s.top:s.bottom-p.bottom)-d;if(Cx&&E.topO&&(O=S?E.top-g-2-d:E.bottom+d+2);if(this.position=="absolute"?(c.style.top=(O-r.parent.top)/i+"px",c.style.left=(x-r.parent.left)/n+"px"):(c.style.top=O/i+"px",c.style.left=x/n+"px"),f){let E=p.left+(v?y.x:-y.x)-(x+14-7);f.style.left=E/n+"px"}u.overlap!==!0&&a.push({left:x,top:O,right:w,bottom:O+g}),c.classList.toggle("cm-tooltip-above",S),c.classList.toggle("cm-tooltip-below",!S),u.positioned&&u.positioned(r.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let r of this.manager.tooltipViews)r.dom.style.top=Ja}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Pj=at.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Tj={x:0,y:0},Ki=ut.define({enables:[Mp,Pj]}),Kl=ut.define({combine:r=>r.reduce((e,t)=>e.concat(t),[])}),Jl=class r{static create(e){return new r(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Hl(e,Kl,(t,s)=>this.createHostedView(t,s),t=>t.dom.remove())}createHostedView(e,t){let s=e.create(this.view);return s.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(s.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&s.mount&&s.mount(this.view),s}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let s of this.manager.tooltipViews){let n=s[e];if(n!==void 0){if(t===void 0)t=n;else if(t!==n)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},Dj=Ki.compute([Kl],r=>{let e=r.facet(Kl);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var s;return(s=t.end)!==null&&s!==void 0?s:t.pos})),create:Jl.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Tp=class{constructor(e,t,s,n,i){this.view=e,this.source=t,this.field=s,this.setHover=n,this.hoverTime=i,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;el.bottom||t.xl.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(n)).find(c=>c.from<=n&&c.to>=n),u=o&&o.dir==Zt.RTL?-1:1;i=t.x{this.pending==l&&(this.pending=null,o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])}))},o=>yr(e.state,o,"hover tooltip"))}else a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])})}get tooltip(){let e=this.view.plugin(Mp),t=e?e.manager.tooltips.findIndex(s=>s.create==Jl.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,s;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:i}=this;if(n.length&&i&&!_j(i.dom,e)||this.pending){let{pos:a}=n[0]||this.pending,l=(s=(t=n[0])===null||t===void 0?void 0:t.end)!==null&&s!==void 0?s:a;(a==l?this.view.posAtCoords(this.lastMove)!=a:!Ij(this.view,a,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:s}=this;s&&s.dom.contains(e.relatedTarget)?this.watchTooltipLeave(s.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=s=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(s.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},Fl=4;function _j(r,e){let{left:t,right:s,top:n,bottom:i}=r.getBoundingClientRect(),a;if(a=r.querySelector(".cm-tooltip-arrow")){let l=a.getBoundingClientRect();n=Math.min(l.top,n),i=Math.max(l.bottom,i)}return e.clientX>=t-Fl&&e.clientX<=s+Fl&&e.clientY>=n-Fl&&e.clientY<=i+Fl}function Ij(r,e,t,s,n,i){let a=r.scrollDOM.getBoundingClientRect(),l=r.documentTop+r.documentPadding.top+r.contentHeight;if(a.left>s||a.rightn||Math.min(a.bottom,l)=e&&o<=t}function QC(r,e={}){let t=Et.define(),s=Yt.define({create(){return[]},update(n,i){if(n.length&&(e.hideOnChange&&(i.docChanged||i.selection)?n=[]:e.hideOn&&(n=n.filter(a=>!e.hideOn(i,a))),i.docChanged)){let a=[];for(let l of n){let o=i.changes.mapPos(l.pos,-1,fr.TrackDel);if(o!=null){let u=Object.assign(Object.create(null),l);u.pos=o,u.end!=null&&(u.end=i.changes.mapPos(u.end)),a.push(u)}}n=a}for(let a of i.effects)a.is(t)&&(n=a.value),a.is(Rj)&&(n=[]);return n},provide:n=>Kl.from(n)});return{active:s,extension:[s,rr.define(n=>new Tp(n,r,s,t,e.hoverTime||300)),Dj]}}function jp(r,e){let t=r.plugin(Mp);if(!t)return null;let s=t.manager.tooltips.indexOf(e);return s<0?null:t.manager.tooltipViews[s]}var Rj=Et.define();var TE=ut.define({combine(r){let e,t;for(let s of r)e=e||s.topContainer,t=t||s.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Ji(r,e){let t=r.plugin(VC),s=t?t.specs.indexOf(e):-1;return s>-1?t.panels[s]:null}var VC=rr.fromClass(class{constructor(r){this.input=r.state.facet(ui),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(r));let e=r.state.facet(TE);this.top=new Gi(r,!0,e.topContainer),this.bottom=new Gi(r,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(r){let e=r.state.facet(TE);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Gi(r.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Gi(r.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=r.state.facet(ui);if(t!=this.input){let s=t.filter(o=>o),n=[],i=[],a=[],l=[];for(let o of s){let u=this.specs.indexOf(o),c;u<0?(c=o(r.view),l.push(c)):(c=this.panels[u],c.update&&c.update(r)),n.push(c),(c.top?i:a).push(c)}this.specs=s,this.panels=n,this.top.sync(i),this.bottom.sync(a);for(let o of l)o.dom.classList.add("cm-panel"),o.mount&&o.mount()}else for(let s of this.panels)s.update&&s.update(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>at.scrollMargins.of(e=>{let t=e.plugin(r);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Gi=class{constructor(e,t,s){this.view=e,this.top=t,this.container=s,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=DE(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=DE(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function DE(r){let e=r.nextSibling;return r.remove(),e}var ui=ut.define({enables:VC}),Xr=class extends yn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Xr.prototype.elementClass="";Xr.prototype.toDOM=void 0;Xr.prototype.mapMode=fr.TrackBefore;Xr.prototype.startSide=Xr.prototype.endSide=-1;Xr.prototype.point=!0;var jl=ut.define(),Fj=ut.define(),Bj={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Mt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},co=ut.define();function qp(r){return[UC(),co.of(Object.assign(Object.assign({},Bj),r))]}var Dp=ut.define({combine:r=>r.some(e=>e)});function UC(r){let e=[Lj];return r&&r.fixed===!1&&e.push(Dp.of(!0)),e}var Lj=rr.fromClass(class{constructor(r){this.view=r,this.prevViewport=r.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=r.state.facet(co).map(e=>new eu(r,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!r.state.facet(Dp),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.contentDOM)}update(r){if(this.updateGutters(r)){let e=this.prevViewport,t=r.view.viewport,s=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(s<(t.to-t.from)*.8)}r.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(Dp)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=r.view.viewport}syncGutters(r){let e=this.dom.nextSibling;r&&this.dom.remove();let t=Mt.iter(this.view.state.facet(jl),this.view.viewport.from),s=[],n=this.gutters.map(i=>new Ip(i,this.view.viewport,-this.view.documentPadding.top));for(let i of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(i.type)){let a=!0;for(let l of i.type)if(l.type==Ir.Text&&a){_p(t,s,l.from);for(let o of n)o.line(this.view,l,s);a=!1}else if(l.widget)for(let o of n)o.widget(this.view,l)}else if(i.type==Ir.Text){_p(t,s,i.from);for(let a of n)a.line(this.view,i,s)}else if(i.widget)for(let a of n)a.widget(this.view,i);for(let i of n)i.finish();r&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(r){let e=r.startState.facet(co),t=r.state.facet(co),s=r.docChanged||r.heightChanged||r.viewportChanged||!Mt.eq(r.startState.facet(jl),r.state.facet(jl),r.view.viewport.from,r.view.viewport.to);if(e==t)for(let n of this.gutters)n.update(r)&&(s=!0);else{s=!0;let n=[];for(let i of t){let a=e.indexOf(i);a<0?n.push(new eu(this.view,i)):(this.gutters[a].update(r),n.push(this.gutters[a]))}for(let i of this.gutters)i.dom.remove(),n.indexOf(i)<0&&i.destroy();for(let i of n)this.dom.appendChild(i.dom);this.gutters=n}return s}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove()}},{provide:r=>at.scrollMargins.of(e=>{let t=e.plugin(r);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==Zt.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function _E(r){return Array.isArray(r)?r:[r]}function _p(r,e,t){for(;r.value&&r.from<=t;)r.from==t&&e.push(r.value),r.next()}var Ip=class{constructor(e,t,s){this.gutter=e,this.height=s,this.i=0,this.cursor=Mt.iter(e.markers,t.from)}addElement(e,t,s){let{gutter:n}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==n.elements.length){let l=new tu(e,a,i,s);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(e,a,i,s);this.height=t.bottom,this.i++}line(e,t,s){let n=[];_p(this.cursor,n,t.from),s.length&&(n=n.concat(s));let i=this.gutter.config.lineMarker(e,t,n);i&&n.unshift(i);let a=this.gutter;n.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,n)}widget(e,t){let s=this.gutter.config.widgetMarker(e,t.widget,t),n=s?[s]:null;for(let i of e.state.facet(Fj)){let a=i(e,t.widget,t);a&&(n||(n=[])).push(a)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},eu=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let s in t.domEventHandlers)this.dom.addEventListener(s,n=>{let i=n.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let o=i.getBoundingClientRect();a=(o.top+o.bottom)/2}else a=n.clientY;let l=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[s](e,l,n)&&n.preventDefault()});this.markers=_E(t.markers(e)),t.initialSpacer&&(this.spacer=new tu(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=_E(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let s=e.view.viewport;return!Mt.eq(this.markers,t,s.from,s.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},tu=class{constructor(e,t,s,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,s,n)}update(e,t,s,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=s&&(this.dom.style.marginTop=(this.above=s)?s+"px":""),Nj(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let s="cm-gutterElement",n=this.dom.firstChild;for(let i=0,a=0;;){let l=a,o=ii(l,o,u)||a(l,o,u):a}return s}})}}),fo=class extends Xr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Vf(r,e){return r.state.facet(Xi).formatNumber(e,r.state)}var jj=co.compute([Xi],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet($j)},lineMarker(e,t,s){return s.some(n=>n.toDOM)?null:new fo(Vf(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,s)=>{for(let n of e.state.facet(Mj)){let i=n(e,t,s);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Xi)!=e.state.facet(Xi),initialSpacer(e){return new fo(Vf(e,IE(e.state.doc.lines)))},updateSpacer(e,t){let s=Vf(t.view,IE(t.view.state.doc.lines));return s==e.number?e:new fo(s)},domEventHandlers:r.facet(Xi).domEventHandlers}));function zC(r={}){return[Xi.of(r),UC(),jj]}function IE(r){let e=9;for(;e{let e=[],t=-1;for(let s of r.selection.ranges){let n=r.doc.lineAt(s.head).from;n>t&&(t=n,e.push(qj.range(n)))}return Mt.of(e)});function ZC(){return Qj}var Vj=0,Eo=class{constructor(e,t){this.from=e,this.to=t}},kt=class{constructor(e={}){this.id=Vj++,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 typeof e!="function"&&(e=Ar.match(e)),t=>{let s=e(t);return s===void 0?null:[this,s]}}};kt.closedBy=new kt({deserialize:r=>r.split(" ")});kt.openedBy=new kt({deserialize:r=>r.split(" ")});kt.group=new kt({deserialize:r=>r.split(" ")});kt.isolate=new kt({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});kt.contextHash=new kt({perNode:!0});kt.lookAhead=new kt({perNode:!0});kt.mounted=new kt({perNode:!0});var ea=class{constructor(e,t,s){this.tree=e,this.overlay=t,this.parser=s}static get(e){return e&&e.props&&e.props[kt.mounted.id]}},Uj=Object.create(null),Ar=class r{constructor(e,t,s,n=0){this.name=e,this.props=t,this.id=s,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):Uj,s=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new r(e.name||"",t,e.id,s);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(n)),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 n}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(kt.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let s in e)for(let n of s.split(" "))t[n]=e[s];return s=>{for(let n=s.prop(kt.group),i=-1;i<(n?n.length:0);i++){let a=t[i<0?s.name:n[i]];if(a)return a}}}};Ar.none=new Ar("",Object.create(null),0,8);var Co=class r{constructor(e){this.types=e;for(let t=0;t0;for(let o=this.cursor(a|nr.IncludeAnonymous);;){let u=!1;if(o.from<=i&&o.to>=n&&(!l&&o.type.isAnonymous||t(o)!==!1)){if(o.firstChild())continue;u=!0}for(;u&&s&&(l||!o.type.isAnonymous)&&s(o),!o.nextSibling();){if(!o.parent())return;u=!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:Gp(Ar.none,this.children,this.positions,0,this.children.length,0,this.length,(t,s,n)=>new r(this.type,t,s,n,this.propValues),e.makeTree||((t,s,n)=>new r(Ar.none,t,s,n)))}static build(e){return Zj(e)}};or.empty=new or(Ar.none,[],[],0);var Qp=class r{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 r(this.buffer,this.index)}},Is=class r{constructor(e,t,s){this.buffer=e,this.length=t,this.set=s}get type(){return Ar.none}toString(){let e=[];for(let t=0;t0));o=a[o+3]);return l}slice(e,t,s){let n=this.buffer,i=new Uint16Array(t-e),a=0;for(let l=e,o=0;l=e&&te;case 1:return t<=e&&s>e;case 2:return s>e;case 4:return!0}}function wo(r,e,t,s){for(var n;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to0?l.length:-1;e!=u;e+=t){let c=l[e],p=o[e]+a.from;if(YC(n,s,p,p+c.length)){if(c instanceof Is){if(i&nr.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,t,s-p,n);if(h>-1)return new ci(new Up(a,c,e,p),null,h)}else if(i&nr.IncludeAnonymous||!c.type.isAnonymous||Wp(c)){let h;if(!(i&nr.IgnoreMounts)&&(h=ea.get(c))&&!h.overlay)return new r(h.tree,p,e,a);let f=new r(c,p,e,a);return i&nr.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(t<0?c.children.length-1:0,t,s,n)}}}if(i&nr.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))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,s=0){let n;if(!(s&nr.IgnoreOverlays)&&(n=ea.get(this._tree))&&n.overlay){let i=e-this.from;for(let{from:a,to:l}of n.overlay)if((t>0?a<=i:a=i:l>i))return new r(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,s)}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 GC(r,e,t,s){let n=r.cursor(),i=[];if(!n.firstChild())return i;if(t!=null){for(let a=!1;!a;)if(a=n.type.is(t),!n.nextSibling())return i}for(;;){if(s!=null&&n.type.is(s))return i;if(n.type.is(e)&&i.push(n.node),!n.nextSibling())return s==null?i:[]}}function Vp(r,e,t=e.length-1){for(let s=r;t>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(e[t]&&e[t]!=s.name)return!1;t--}}return!0}var Up=class{constructor(e,t,s,n){this.parent=e,this.buffer=t,this.index=s,this.start=n}},ci=class r extends lu{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,s){super(),this.context=e,this._parent=t,this.index=s,this.type=e.buffer.set.types[e.buffer.buffer[s]]}child(e,t,s){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,s);return i<0?null:new r(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,s=0){if(s&nr.ExcludeBuffers)return null;let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new r(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 r(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 r(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:s}=this.context,n=this.index+4,i=s.buffer[this.index+3];if(i>n){let a=s.buffer[this.index+1];e.push(s.slice(n,i,a)),t.push(0)}return new or(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function HC(r){if(!r.length)return null;let e=0,t=r[0];for(let i=1;it.from||a.to=e){let l=new ln(a.tree,a.overlay[0].from+i.from,-1,i);(n||(n=[s])).push(wo(l,e,t,!1))}}return n?HC(n):s}var ko=class{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 ln)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let s=e._parent;s;s=s._parent)this.stack.unshift(s.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):!1}yieldBuf(e,t){this.index=e;let{start:s,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=s+n.buffer[e+1],this.to=s+n.buffer[e+2],!0}yield(e){return e?e instanceof ln?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,s){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,s,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,s);return i<0?!1:(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,s=this.mode){return this.buffer?s&nr.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,s))}parent(){if(!this.buffer)return this.yieldNode(this.mode&nr.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&nr.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)):!1;let{buffer:t}=this.buffer,s=this.stack.length-1;if(e<0){let n=s<0?0:this.stack[s]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(s<0?t.buffer.length:t.buffer[this.stack[s]+3]))return this.yieldBuf(n)}return s<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,s,{buffer:n}=this;if(n){if(e>0){if(this.index-1)for(let i=t+e,a=e<0?-1:s._tree.children.length;i!=a;i+=e){let l=s._tree.children[i];if(this.mode&nr.IncludeAnonymous||l instanceof Is||!l.type.isAnonymous||Wp(l))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=0;){for(let a=e;a;a=a._parent)if(a.index==n){if(n==this.index)return a;t=a,s=i+1;break e}n=this.stack[--i]}for(let n=s;n=0;i--){if(i<0)return Vp(this._tree,e,n);let a=s[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[n]&&e[n]!=a.name)return!1;n--}}return!0}};function Wp(r){return r.children.some(e=>e instanceof Is||!e.type.isAnonymous||Wp(e))}function Zj(r){var e;let{buffer:t,nodeSet:s,maxBufferLength:n=1024,reused:i=[],minRepeatType:a=s.types.length}=r,l=Array.isArray(t)?new Qp(t,t.length):t,o=s.types,u=0,c=0;function p(C,O,w,E,k,A){let{id:D,start:_,end:F,size:T}=l,R=c,j=u;for(;T<0;)if(l.next(),T==-1){let V=i[D];w.push(V),E.push(_-C);return}else if(T==-3){u=D;return}else if(T==-4){c=D;return}else throw new RangeError(`Unrecognized record size: ${T}`);let Q=o[D],I,L,B=_-C;if(F-_<=n&&(L=g(l.pos-O,k))){let V=new Uint16Array(L.size-L.skip),U=l.pos-L.size,ae=V.length;for(;l.pos>U;)ae=y(L.start,V,ae);I=new Is(V,F-L.start,s),B=L.start-C}else{let V=l.pos-T;l.next();let U=[],ae=[],se=D>=a?D:-1,xe=0,H=F;for(;l.pos>V;)se>=0&&l.id==se&&l.size>=0?(l.end<=H-n&&(d(U,ae,_,xe,l.end,H,se,R,j),xe=U.length,H=l.end),l.next()):A>2500?h(_,V,U,ae):p(_,V,U,ae,se,A+1);if(se>=0&&xe>0&&xe-1&&xe>0){let he=f(Q,j);I=Gp(Q,U,ae,0,U.length,0,F-_,he,he)}else I=m(Q,U,ae,F-_,R-F,j)}w.push(I),E.push(B)}function h(C,O,w,E){let k=[],A=0,D=-1;for(;l.pos>O;){let{id:_,start:F,end:T,size:R}=l;if(R>4)l.next();else{if(D>-1&&F=0;T-=3)_[R++]=k[T],_[R++]=k[T+1]-F,_[R++]=k[T+2]-F,_[R++]=R;w.push(new Is(_,k[2]-F,s)),E.push(F-C)}}function f(C,O){return(w,E,k)=>{let A=0,D=w.length-1,_,F;if(D>=0&&(_=w[D])instanceof or){if(!D&&_.type==C&&_.length==k)return _;(F=_.prop(kt.lookAhead))&&(A=E[D]+_.length+F)}return m(C,w,E,k,A,O)}}function d(C,O,w,E,k,A,D,_,F){let T=[],R=[];for(;C.length>E;)T.push(C.pop()),R.push(O.pop()+w-k);C.push(m(s.types[D],T,R,A-k,_-A,F)),O.push(k-w)}function m(C,O,w,E,k,A,D){if(A){let _=[kt.contextHash,A];D=D?[_].concat(D):[_]}if(k>25){let _=[kt.lookAhead,k];D=D?[_].concat(D):[_]}return new or(C,O,w,E,D)}function g(C,O){let w=l.fork(),E=0,k=0,A=0,D=w.end-n,_={size:0,start:0,skip:0};e:for(let F=w.pos-C;w.pos>F;){let T=w.size;if(w.id==O&&T>=0){_.size=E,_.start=k,_.skip=A,A+=4,E+=4,w.next();continue}let R=w.pos-T;if(T<0||R=a?4:0,Q=w.start;for(w.next();w.pos>R;){if(w.size<0)if(w.size==-3)j+=4;else break e;else w.id>=a&&(j+=4);w.next()}k=Q,E+=T,A+=j}return(O<0||E==C)&&(_.size=E,_.start=k,_.skip=A),_.size>4?_:void 0}function y(C,O,w){let{id:E,start:k,end:A,size:D}=l;if(l.next(),D>=0&&E4){let F=l.pos-(D-4);for(;l.pos>F;)w=y(C,O,w)}O[--w]=_,O[--w]=A-C,O[--w]=k-C,O[--w]=E}else D==-3?u=E:D==-4&&(c=E);return w}let v=[],x=[];for(;l.pos>0;)p(r.start||0,r.bufferStart||0,v,x,-1,0);let S=(e=r.length)!==null&&e!==void 0?e:v.length?x[0]+v[0].length:0;return new or(o[r.topID],v.reverse(),x.reverse(),S)}var XC=new WeakMap;function ou(r,e){if(!r.isAnonymous||e instanceof Is||e.type!=r)return 1;let t=XC.get(e);if(t==null){t=1;for(let s of e.children){if(s.type!=r||!(s instanceof or)){t=1;break}t+=ou(r,s)}XC.set(e,t)}return t}function Gp(r,e,t,s,n,i,a,l,o){let u=0;for(let d=s;d=c)break;O+=w}if(x==S+1){if(O>c){let w=d[S];f(w.children,w.positions,0,w.children.length,m[S]+v);continue}p.push(d[S])}else{let w=m[x-1]+d[x-1].length-C;p.push(Gp(r,d,m,S,x,C,w,null,o))}h.push(C+v-i)}}return f(e,t,s,n,0),(l||o)(p,h,a)}var uu=class{constructor(){this.map=new WeakMap}setBuffer(e,t,s){let n=this.map.get(e);n||this.map.set(e,n=new Map),n.set(t,s)}getBuffer(e,t){let s=this.map.get(e);return s&&s.get(t)}set(e,t){e instanceof ci?this.setBuffer(e.context.buffer,e.index,t):e instanceof ln&&this.map.set(e.tree,t)}get(e){return e instanceof ci?this.getBuffer(e.context.buffer,e.index):e instanceof ln?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},fi=class r{constructor(e,t,s,n,i=!1,a=!1){this.from=e,this.to=t,this.tree=s,this.offset=n,this.open=(i?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],s=!1){let n=[new r(0,e.length,e,0,!1,s)];for(let i of t)i.to>e.length&&n.push(i);return n}static applyChanges(e,t,s=128){if(!t.length)return e;let n=[],i=1,a=e.length?e[0]:null;for(let l=0,o=0,u=0;;l++){let c=l=s)for(;a&&a.from=h.from||p<=h.to||u){let f=Math.max(h.from,o)-u,d=Math.min(h.to,p)-u;h=f>=d?null:new r(f,d,h.tree,h.offset+u,l>0,!!c)}if(h&&n.push(h),a.to>p)break;a=inew Eo(n.from,n.to)):[new Eo(0,0)]:[new Eo(0,e.length)],this.createParse(e,t||[],s)}parse(e,t,s){let n=this.startParse(e,t,s);for(;;){let i=n.advance();if(i)return i}}},Zp=class{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)}};var YX=new kt({perNode:!0});var Wj=0,vn=class r{constructor(e,t,s,n){this.name=e,this.set=t,this.base=s,this.modified=n,this.id=Wj++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let s=typeof e=="string"?e:"?";if(e instanceof r&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let n=new r(s,[],null,[]);if(n.set.push(n),t)for(let i of t.set)n.set.push(i);return n}static defineModifier(e){let t=new hu(e);return s=>s.modified.indexOf(t)>-1?s:hu.get(s.base||s,s.modified.concat(t).sort((n,i)=>n.id-i.id))}},Gj=0,hu=class r{constructor(e){this.name=e,this.instances=[],this.id=Gj++}static get(e,t){if(!t.length)return e;let s=t[0].instances.find(l=>l.base==e&&Xj(t,l.modified));if(s)return s;let n=[],i=new vn(e.name,n,e,t);for(let l of t)l.instances.push(i);let a=Yj(t);for(let l of e.set)if(!l.modified.length)for(let o of a)n.push(r.get(l,o));return i}};function Xj(r,e){return r.length==e.length&&r.every((t,s)=>t==e[s])}function Yj(r){let e=[[]];for(let t=0;ts.length-t.length)}function du(r){let e=Object.create(null);for(let t in r){let s=r[t];Array.isArray(s)||(s=[s]);for(let n of t.split(" "))if(n){let i=[],a=2,l=n;for(let p=0;;){if(l=="..."&&p>0&&p+3==n.length){a=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!h)throw new RangeError("Invalid path: "+n);if(i.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),p+=h[0].length,p==n.length)break;let f=n[p++];if(p==n.length&&f=="!"){a=0;break}if(f!="/")throw new RangeError("Invalid path: "+n);l=n.slice(p)}let o=i.length-1,u=i[o];if(!u)throw new RangeError("Invalid path: "+n);let c=new ra(s,a,o>0?i.slice(0,o):null);e[u]=c.sort(e[u])}}return ew.add(e)}var ew=new kt,ra=class{constructor(e,t,s,n){this.tags=e,this.mode=t,this.context=s,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let a=n;for(let l of i)for(let o of l.set){let u=t[o.id];if(u){a=a?a+" "+u:u;break}}return a},scope:s}}function Hj(r,e){let t=null;for(let s of r){let n=s.style(e);n&&(t=t?t+" "+n:n)}return t}function tw(r,e,t,s=0,n=r.length){let i=new Yp(s,Array.isArray(e)?e:[e],t);i.highlightRange(r.cursor(),s,n,"",i.highlighters),i.flush(n)}var Yp=class{constructor(e,t,s){this.at=e,this.highlighters=t,this.span=s,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,s,n,i){let{type:a,from:l,to:o}=e;if(l>=s||o<=t)return;a.isTop&&(i=this.highlighters.filter(f=>!f.scope||f.scope(a)));let u=n,c=Kj(e)||ra.empty,p=Hj(i,c.tags);if(p&&(u&&(u+=" "),u+=p,c.mode==1&&(n+=(n?" ":"")+p)),this.startSpan(Math.max(t,l),u),c.opaque)return;let h=e.tree&&e.tree.prop(kt.mounted);if(h&&h.overlay){let f=e.node.enter(h.overlay[0].from+l,1),d=this.highlighters.filter(g=>!g.scope||g.scope(h.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let v=g=x||!e.nextSibling())););if(!v||x>s)break;y=v.to+l,y>t&&(this.highlightRange(f.cursor(),Math.max(t,v.from+l),Math.min(s,y),"",d),this.startSpan(Math.min(s,y),u))}m&&e.parent()}else if(e.firstChild()){h&&(n="");do if(!(e.to<=t)){if(e.from>=s)break;this.highlightRange(e,t,s,n,i),this.startSpan(Math.min(s,e.to),u)}while(e.nextSibling());e.parent()}}};function Kj(r){let e=r.type.prop(ew);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}var lt=vn.define,cu=lt(),Rs=lt(),KC=lt(Rs),JC=lt(Rs),Fs=lt(),fu=lt(Fs),Xp=lt(Fs),Vn=lt(),pi=lt(Vn),qn=lt(),Qn=lt(),Hp=lt(),Ao=lt(Hp),pu=lt(),we={comment:cu,lineComment:lt(cu),blockComment:lt(cu),docComment:lt(cu),name:Rs,variableName:lt(Rs),typeName:KC,tagName:lt(KC),propertyName:JC,attributeName:lt(JC),className:lt(Rs),labelName:lt(Rs),namespace:lt(Rs),macroName:lt(Rs),literal:Fs,string:fu,docString:lt(fu),character:lt(fu),attributeValue:lt(fu),number:Xp,integer:lt(Xp),float:lt(Xp),bool:lt(Fs),regexp:lt(Fs),escape:lt(Fs),color:lt(Fs),url:lt(Fs),keyword:qn,self:lt(qn),null:lt(qn),atom:lt(qn),unit:lt(qn),modifier:lt(qn),operatorKeyword:lt(qn),controlKeyword:lt(qn),definitionKeyword:lt(qn),moduleKeyword:lt(qn),operator:Qn,derefOperator:lt(Qn),arithmeticOperator:lt(Qn),logicOperator:lt(Qn),bitwiseOperator:lt(Qn),compareOperator:lt(Qn),updateOperator:lt(Qn),definitionOperator:lt(Qn),typeOperator:lt(Qn),controlOperator:lt(Qn),punctuation:Hp,separator:lt(Hp),bracket:Ao,angleBracket:lt(Ao),squareBracket:lt(Ao),paren:lt(Ao),brace:lt(Ao),content:Vn,heading:pi,heading1:lt(pi),heading2:lt(pi),heading3:lt(pi),heading4:lt(pi),heading5:lt(pi),heading6:lt(pi),contentSeparator:lt(Vn),list:lt(Vn),quote:lt(Vn),emphasis:lt(Vn),strong:lt(Vn),link:lt(Vn),monospace:lt(Vn),strikethrough:lt(Vn),inserted:lt(),deleted:lt(),changed:lt(),invalid:lt(),meta:pu,documentMeta:lt(pu),annotation:lt(pu),processingInstruction:lt(pu),definition:vn.defineModifier("definition"),constant:vn.defineModifier("constant"),function:vn.defineModifier("function"),standard:vn.defineModifier("standard"),local:vn.defineModifier("local"),special:vn.defineModifier("special")};for(let r in we){let e=we[r];e instanceof vn&&(e.name=r)}var JX=Kp([{tag:we.link,class:"tok-link"},{tag:we.heading,class:"tok-heading"},{tag:we.emphasis,class:"tok-emphasis"},{tag:we.strong,class:"tok-strong"},{tag:we.keyword,class:"tok-keyword"},{tag:we.atom,class:"tok-atom"},{tag:we.bool,class:"tok-bool"},{tag:we.url,class:"tok-url"},{tag:we.labelName,class:"tok-labelName"},{tag:we.inserted,class:"tok-inserted"},{tag:we.deleted,class:"tok-deleted"},{tag:we.literal,class:"tok-literal"},{tag:we.string,class:"tok-string"},{tag:we.number,class:"tok-number"},{tag:[we.regexp,we.escape,we.special(we.string)],class:"tok-string2"},{tag:we.variableName,class:"tok-variableName"},{tag:we.local(we.variableName),class:"tok-variableName tok-local"},{tag:we.definition(we.variableName),class:"tok-variableName tok-definition"},{tag:we.special(we.variableName),class:"tok-variableName2"},{tag:we.definition(we.propertyName),class:"tok-propertyName tok-definition"},{tag:we.typeName,class:"tok-typeName"},{tag:we.namespace,class:"tok-namespace"},{tag:we.className,class:"tok-className"},{tag:we.macroName,class:"tok-macroName"},{tag:we.propertyName,class:"tok-propertyName"},{tag:we.operator,class:"tok-operator"},{tag:we.comment,class:"tok-comment"},{tag:we.meta,class:"tok-meta"},{tag:we.invalid,class:"tok-invalid"},{tag:we.punctuation,class:"tok-punctuation"}]);var Jp,na=new kt;function ch(r){return ut.define({combine:r?e=>e.concat(r):void 0})}var yu=new kt,Yr=class{constructor(e,t,s=[],n=""){this.data=e,this.name=n,Vt.prototype.hasOwnProperty("tree")||Object.defineProperty(Vt.prototype,"tree",{get(){return pr(this)}}),this.parser=t,this.extension=[sa.of(this),Vt.languageData.of((i,a,l)=>{let o=rw(i,a,l),u=o.type.prop(na);if(!u)return[];let c=i.facet(u),p=o.type.prop(yu);if(p){let h=o.resolve(a-o.from,l);for(let f of p)if(f.test(h,i)){let d=i.facet(f.facet);return f.type=="replace"?d:d.concat(c)}}return c})].concat(s)}isActiveAt(e,t,s=-1){return rw(e,t,s).type.prop(na)==this.data}findRegions(e){let t=e.facet(sa);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let s=[],n=(i,a)=>{if(i.prop(na)==this.data){s.push({from:a,to:a+i.length});return}let l=i.prop(kt.mounted);if(l){if(l.tree.prop(na)==this.data){if(l.overlay)for(let o of l.overlay)s.push({from:o.from+a,to:o.to+a});else s.push({from:a,to:a+i.length});return}else if(l.overlay){let o=s.length;if(n(l.tree,l.overlay[0].from+a),s.length>o)return}}for(let o=0;os.isTop?t:void 0)]}),e.name)}configure(e,t){return new r(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function pr(r){let e=r.field(Yr.state,!1);return e?e.tree:or.empty}var nh=class{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 s=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-s,t-s)}},Po=null,sh=class r{constructor(e,t,s=[],n,i,a,l,o){this.parser=e,this.state=t,this.fragments=s,this.tree=n,this.treeLen=i,this.viewport=a,this.skipped=l,this.scheduleOn=o,this.parse=null,this.tempSkipped=[]}static create(e,t,s){return new r(e,t,[],or.empty,0,s,[],null)}startParse(){return this.parser.startParse(new nh(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=or.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var s;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||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(fi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Po;Po=this;try{return e()}finally{Po=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=nw(e,t.from,t.to);return e}changes(e,t){let{fragments:s,tree:n,treeLen:i,viewport:a,skipped:l}=this;if(this.takeTree(),!e.empty){let o=[];if(e.iterChangedRanges((u,c,p,h)=>o.push({fromA:u,toA:c,fromB:p,toB:h})),s=fi.applyChanges(s,o),n=or.empty,i=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),p=e.mapPos(u.to,-1);ce.from&&(this.fragments=nw(this.fragments,n,i),this.skipped.splice(s--,1))}return this.skipped.length>=t?!1:(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 ta{createParse(t,s,n){let i=n[0].from,a=n[n.length-1].to;return{parsedPos:i,advance(){let o=Po;if(o){for(let u of n)o.tempSkipped.push(u);e&&(o.scheduleOn=o.scheduleOn?Promise.all([o.scheduleOn,e]):e)}return this.parsedPos=a,new or(Ar.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Po}};function nw(r,e,t){return fi.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}var To=class r{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),s=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,s)||t.takeTree(),new r(t)}static init(e){let t=Math.min(3e3,e.doc.length),s=sh.create(e.facet(sa).parser,e,{from:0,to:t});return s.work(20,t)||s.takeTree(),new r(s)}};Yr.state=Yt.define({create:To.init,update(r,e){for(let t of e.effects)if(t.is(Yr.setState))return t.value;return e.startState.facet(sa)!=e.state.facet(sa)?To.init(e.state):r.apply(e)}});var ow=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(ow=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var eh=typeof navigator<"u"&&(!((Jp=navigator.scheduling)===null||Jp===void 0)&&Jp.isInputPending)?()=>navigator.scheduling.isInputPending():null,Jj=rr.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(Yr.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(Yr.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=ow(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,o=i.context.work(()=>eh&&eh()||Date.now()>a,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(o||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Yr.setState.of(new To(i.context))})),this.chunkBudget>0&&!(o&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>yr(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),sa=ut.define({combine(r){return r.length?r[0]:null},enables:r=>[Yr.state,Jj,at.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]}),gu=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var eq=ut.define(),aa=ut.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function Do(r){let e=r.facet(aa);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function oa(r,e){let t="",s=r.tabSize,n=r.facet(aa)[0];if(n==" "){for(;e>=s;)t+=" ",e-=s;n=" "}for(let i=0;i=e?tq(r,t,e):null}var hi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Do(e)}lineAt(e,t=1){let s=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:i}=this.options;return n!=null&&n>=s.from&&n<=s.to?i&&n==e?{text:"",from:e}:(t<0?n-1&&(i+=a-this.countColumn(s,s.search(/\S|$/))),i}countColumn(e,t=e.length){return os(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:s,from:n}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let a=i(n);if(a>-1)return a}return this.countColumn(s,s.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},fh=new kt;function tq(r,e,t){let s=e.resolveStack(t),n=s.node.enterUnfinishedNodesBefore(t);if(n!=s.node){let i=[];for(let a=n;a!=s.node;a=a.parent)i.push(a);for(let a=i.length-1;a>=0;a--)s={node:i[a],next:s}}return lw(s,r,t)}function lw(r,e,t){for(let s=r;s;s=s.next){let n=nq(s.node);if(n)return n(ih.create(e,t,s))}return 0}function rq(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function nq(r){let e=r.type.prop(fh);if(e)return e;let t=r.firstChild,s;if(t&&(s=t.type.prop(kt.closedBy))){let n=r.lastChild,i=n&&s.indexOf(n.name)>-1;return a=>cw(a,!0,1,void 0,i&&!rq(a)?n.from:void 0)}return r.parent==null?sq:null}function sq(){return 0}var ih=class r extends hi{constructor(e,t,s){super(e.state,e.options),this.base=e,this.pos=t,this.context=s}get node(){return this.context.node}static create(e,t,s){return new r(e,t,s)}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 s=e.resolve(t.from);for(;s.parent&&s.parent.from==s.from;)s=s.parent;if(iq(s,e))break;t=this.state.doc.lineAt(s.from)}return this.lineIndent(t.from)}continue(){return lw(this.context.next,this.base,this.pos)}};function iq(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function aq(r){let e=r.node,t=e.childAfter(e.from),s=e.lastChild;if(!t)return null;let n=r.options.simulateBreak,i=r.state.doc.lineAt(t.from),a=n==null||n<=i.from?i.to:Math.min(i.to,n);for(let l=t.to;;){let o=e.childAfter(l);if(!o||o==s)return null;if(!o.type.isSkipped){if(o.from>=a)return null;let u=/^ */.exec(i.text.slice(t.to-i.from))[0].length;return{from:t.from,to:t.to+u}}l=o.to}}function uw({closing:r,align:e=!0,units:t=1}){return s=>cw(s,e,t,r)}function cw(r,e,t,s,n){let i=r.textAfter,a=i.match(/^\s*/)[0].length,l=s&&i.slice(a,a+s.length)==s||n==r.pos+a,o=e?aq(r):null;return o?l?r.column(o.from):r.column(o.to):r.baseIndent+(l?0:r.unit*t)}var fw=r=>r.baseIndent;function vu({except:r,units:e=1}={}){return t=>{let s=r&&r.test(t.textAfter);return t.baseIndent+(s?0:e*t.unit)}}var oq=200;function pw(){return Vt.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let e=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!e.length)return r;let t=r.newDoc,{head:s}=r.newSelection.main,n=t.lineAt(s);if(s>n.from+oq)return r;let i=t.sliceString(n.from,s);if(!e.some(u=>u.test(i)))return r;let{state:a}=r,l=-1,o=[];for(let{head:u}of a.selection.ranges){let c=a.doc.lineAt(u);if(c.from==l)continue;l=c.from;let p=bu(a,c.from);if(p==null)continue;let h=/^\s*/.exec(c.text)[0],f=oa(a,p);h!=f&&o.push({from:c.from,to:c.from+h.length,insert:f})}return o.length?[r,{changes:o,sequential:!0}]:r})}var hw=new kt;function dw(r){let e=r.firstChild,t=r.lastChild;return e&&e.tol.prop(na)==a.data:a?l=>l==a:void 0,this.style=Kp(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:i}).style,this.module=s?new nn(s):null,this.themeType=t.themeType}static define(e,t){return new r(e,t||{})}},ah=ut.define(),mw=ut.define({combine(r){return r.length?[r[0]]:null}});function th(r){let e=r.facet(ah);return e.length?e:r.facet(mw)}function xu(r,e){let t=[lq],s;return r instanceof ia&&(r.module&&t.push(at.styleModule.of(r.module)),s=r.themeType),e?.fallback?t.push(mw.of(r)):s?t.push(ah.computeN([at.darkTheme],n=>n.facet(at.darkTheme)==(s=="dark")?[r]:[])):t.push(ah.of(r)),t}var oh=class{constructor(e){this.markCache=Object.create(null),this.tree=pr(e.state),this.decorations=this.buildDeco(e,th(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=pr(e.state),s=th(e.state),n=s!=th(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,s),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return yt.none;let s=new Fn;for(let{from:n,to:i}of e.visibleRanges)tw(this.tree,t,(a,l,o)=>{s.add(a,l,this.markCache[o]||(this.markCache[o]=yt.mark({class:o})))},n,i);return s.finish()}},lq=rn.high(rr.fromClass(oh,{decorations:r=>r.decorations})),gw=ia.define([{tag:we.meta,color:"#404740"},{tag:we.link,textDecoration:"underline"},{tag:we.heading,textDecoration:"underline",fontWeight:"bold"},{tag:we.emphasis,fontStyle:"italic"},{tag:we.strong,fontWeight:"bold"},{tag:we.strikethrough,textDecoration:"line-through"},{tag:we.keyword,color:"#708"},{tag:[we.atom,we.bool,we.url,we.contentSeparator,we.labelName],color:"#219"},{tag:[we.literal,we.inserted],color:"#164"},{tag:[we.string,we.deleted],color:"#a11"},{tag:[we.regexp,we.escape,we.special(we.string)],color:"#e40"},{tag:we.definition(we.variableName),color:"#00f"},{tag:we.local(we.variableName),color:"#30a"},{tag:[we.typeName,we.namespace],color:"#085"},{tag:we.className,color:"#167"},{tag:[we.special(we.variableName),we.macroName],color:"#256"},{tag:we.definition(we.propertyName),color:"#00c"},{tag:we.comment,color:"#940"},{tag:we.invalid,color:"#f00"}]),uq=at.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),yw=1e4,bw="()[]{}",vw=ut.define({combine(r){return kr(r,{afterCursor:!0,brackets:bw,maxScanDistance:yw,renderMatch:pq})}}),cq=yt.mark({class:"cm-matchingBracket"}),fq=yt.mark({class:"cm-nonmatchingBracket"});function pq(r){let e=[],t=r.matched?cq:fq;return e.push(t.range(r.start.from,r.start.to)),r.end&&e.push(t.range(r.end.from,r.end.to)),e}var hq=Yt.define({create(){return yt.none},update(r,e){if(!e.docChanged&&!e.selection)return r;let t=[],s=e.state.facet(vw);for(let n of e.state.selection.ranges){if(!n.empty)continue;let i=xn(e.state,n.head,-1,s)||n.head>0&&xn(e.state,n.head-1,1,s)||s.afterCursor&&(xn(e.state,n.head,1,s)||n.headat.decorations.from(r)}),dq=[hq,uq];function xw(r={}){return[vw.of(r),dq]}var mq=new kt;function lh(r,e,t){let s=r.prop(e<0?kt.openedBy:kt.closedBy);if(s)return s;if(r.name.length==1){let n=t.indexOf(r.name);if(n>-1&&n%2==(e<0?1:0))return[t[n+e]]}return null}function uh(r){let e=r.type.prop(mq);return e?e(r.node):r}function xn(r,e,t,s={}){let n=s.maxScanDistance||yw,i=s.brackets||bw,a=pr(r),l=a.resolveInner(e,t);for(let o=l;o;o=o.parent){let u=lh(o.type,t,i);if(u&&o.from0?e>=c.from&&ec.from&&e<=c.to))return gq(r,e,t,o,c,u,i)}}return yq(r,e,t,a,l.type,n,i)}function gq(r,e,t,s,n,i,a){let l=s.parent,o={from:n.from,to:n.to},u=0,c=l?.cursor();if(c&&(t<0?c.childBefore(s.from):c.childAfter(s.to)))do if(t<0?c.to<=s.from:c.from>=s.to){if(u==0&&i.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:t<0?e-1:e,to:t>0?e+1:e},c=r.doc.iterRange(e,t>0?r.doc.length:0),p=0;for(let h=0;!c.next().done&&h<=i;){let f=c.value;t<0&&(h+=f.length);let d=e+h*t;for(let m=t>0?0:f.length-1,g=t>0?f.length:-1;m!=g;m+=t){let y=a.indexOf(f[m]);if(!(y<0||s.resolveInner(d+m,1).type!=n))if(y%2==0==t>0)p++;else{if(p==1)return{start:u,end:{from:d+m,to:d+m+1},matched:y>>1==o>>1};p--}}t>0&&(h+=f.length)}return c.done?{start:u,matched:!1}:null}var bq=Object.create(null),sw=[Ar.none];var iw=[],aw=Object.create(null),vq=Object.create(null);for(let[r,e]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"]])vq[r]=xq(bq,e);function rh(r,e){iw.indexOf(r)>-1||(iw.push(r),console.warn(e))}function xq(r,e){let t=[];for(let l of e.split(" ")){let o=[];for(let u of l.split(".")){let c=r[u]||we[u];c?typeof c=="function"?o.length?o=o.map(c):rh(u,`Modifier ${u} used at start of tag`):o.length?rh(u,`Tag ${u} used as modifier`):o=Array.isArray(c)?c:[c]:rh(u,`Unknown highlighting tag ${u}`)}for(let u of o)t.push(u)}if(!t.length)return 0;let s=e.replace(/ /g,"_"),n=s+" "+t.map(l=>l.id),i=aw[n];if(i)return i.id;let a=aw[n]=Ar.define({id:sw.length,name:s,props:[du({[s]:t})]});return sw.push(a),a.id}var oY={rtl:yt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Zt.RTL}),ltr:yt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Zt.LTR}),auto:yt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var gh=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),s=bh(r.state,t.from);return s.line?Oq(r):s.block?Eq(r):!1};function yh(r,e){return({state:t,dispatch:s})=>{if(t.readOnly)return!1;let n=r(e,t);return n?(s(t.update(n)),!0):!1}}var Oq=yh(kq,0);var Sq=yh(Tw,0);var Eq=yh((r,e)=>Tw(r,e,wq(e)),0);function bh(r,e){let t=r.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var _o=50;function Cq(r,{open:e,close:t},s,n){let i=r.sliceDoc(s-_o,s),a=r.sliceDoc(n,n+_o),l=/\s*$/.exec(i)[0].length,o=/^\s*/.exec(a)[0].length,u=i.length-l;if(i.slice(u-e.length,u)==e&&a.slice(o,o+t.length)==t)return{open:{pos:s-l,margin:l&&1},close:{pos:n+o,margin:o&&1}};let c,p;n-s<=2*_o?c=p=r.sliceDoc(s,n):(c=r.sliceDoc(s,s+_o),p=r.sliceDoc(n-_o,n));let h=/^\s*/.exec(c)[0].length,f=/\s*$/.exec(p)[0].length,d=p.length-f-t.length;return c.slice(h,h+e.length)==e&&p.slice(d,d+t.length)==t?{open:{pos:s+h+e.length,margin:/\s/.test(c.charAt(h+e.length))?1:0},close:{pos:n-f-t.length,margin:/\s/.test(p.charAt(d-1))?1:0}}:null}function wq(r){let e=[];for(let t of r.selection.ranges){let s=r.doc.lineAt(t.from),n=t.to<=s.to?s:r.doc.lineAt(t.to);n.from>s.from&&n.from==t.to&&(n=t.to==s.to+1?s:r.doc.lineAt(t.to-1));let i=e.length-1;i>=0&&e[i].to>s.from?e[i].to=n.to:e.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:n.to})}return e}function Tw(r,e,t=e.selection.ranges){let s=t.map(i=>bh(e,i.from).block);if(!s.every(i=>i))return null;let n=t.map((i,a)=>Cq(e,s[a],i.from,i.to));if(r!=2&&!n.every(i=>i))return{changes:e.changes(t.map((i,a)=>n[a]?[]:[{from:i.from,insert:s[a].open+" "},{from:i.to,insert:" "+s[a].close}]))};if(r!=1&&n.some(i=>i)){let i=[];for(let a=0,l;an&&(i==a||a>p.from)){n=p.from;let h=/^\s*/.exec(p.text)[0].length,f=h==p.length,d=p.text.slice(h,h+u.length)==u?h:-1;hi.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:l,token:o,indent:u,empty:c,single:p}of s)(p||!c)&&i.push({from:l.from+u,insert:o+" "});let a=e.changes(i);return{changes:a,selection:e.selection.map(a,1)}}else if(r!=1&&s.some(i=>i.comment>=0)){let i=[];for(let{line:a,comment:l,token:o}of s)if(l>=0){let u=a.from+l,c=u+o.length;a.text[c-a.from]==" "&&c++,i.push({from:u,to:c})}return{changes:i}}return null}var hh=Mr.define(),Aq=Mr.define(),Pq=ut.define(),Dw=ut.define({combine(r){return kr(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(s,n)=>e(s,n)||t(s,n)})}}),_w=Yt.define({create(){return di.empty},update(r,e){let t=e.state.facet(Dw),s=e.annotation(hh);if(s){let o=On.fromTransaction(e,s.selection),u=s.side,c=u==0?r.undone:r.done;return o?c=Su(c,c.length,t.minDepth,o):c=Fw(c,e.startState.selection),new di(u==0?s.rest:c,u==0?c:s.rest)}let n=e.annotation(Aq);if((n=="full"||n=="before")&&(r=r.isolate()),e.annotation(lr.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let i=On.fromTransaction(e),a=e.annotation(lr.time),l=e.annotation(lr.userEvent);return i?r=r.addChanges(i,a,l,t,e):e.selection&&(r=r.addSelection(e.startState.selection,a,l,t.newGroupDelay)),(n=="full"||n=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new di(r.done.map(On.fromJSON),r.undone.map(On.fromJSON))}});function Iw(r={}){return[_w,Dw.of(r),at.domEventHandlers({beforeinput(e,t){let s=e.inputType=="historyUndo"?Cu:e.inputType=="historyRedo"?Io:null;return s?(e.preventDefault(),s(t)):!1}})]}function Eu(r,e){return function({state:t,dispatch:s}){if(!e&&t.readOnly)return!1;let n=t.field(_w,!1);if(!n)return!1;let i=n.pop(r,t,e);return i?(s(i),!0):!1}}var Cu=Eu(0,!1),Io=Eu(1,!1),Tq=Eu(0,!0),Dq=Eu(1,!0);var On=class r{constructor(e,t,s,n,i){this.changes=e,this.effects=t,this.mapped=s,this.startSelection=n,this.selectionsAfter=i}setSelAfter(e){return new r(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,s;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(s=this.startSelection)===null||s===void 0?void 0:s.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new r(e.changes&&Dr.fromJSON(e.changes),[],e.mapped&&as.fromJSON(e.mapped),e.startSelection&&Ze.fromJSON(e.startSelection),e.selectionsAfter.map(Ze.fromJSON))}static fromTransaction(e,t){let s=un;for(let n of e.startState.facet(Pq)){let i=n(e);i.length&&(s=s.concat(i))}return!s.length&&e.changes.empty?null:new r(e.changes.invert(e.startState.doc),s,void 0,t||e.startState.selection,un)}static selection(e){return new r(void 0,un,void 0,void 0,e)}};function Su(r,e,t,s){let n=e+1>t+20?e-t-1:0,i=r.slice(n,e);return i.push(s),i}function _q(r,e){let t=[],s=!1;return r.iterChangedRanges((n,i)=>t.push(n,i)),e.iterChangedRanges((n,i,a,l)=>{for(let o=0;o=u&&a<=c&&(s=!0)}}),s}function Iq(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((t,s)=>t.empty!=e.ranges[s].empty).length===0}function Rw(r,e){return r.length?e.length?r.concat(e):r:e}var un=[],Rq=200;function Fw(r,e){if(r.length){let t=r[r.length-1],s=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Rq));return s.length&&s[s.length-1].eq(e)?r:(s.push(e),Su(r,r.length-1,1e9,t.setSelAfter(s)))}else return[On.selection([e])]}function Fq(r){let e=r[r.length-1],t=r.slice();return t[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function ph(r,e){if(!r.length)return r;let t=r.length,s=un;for(;t;){let n=Bq(r[t-1],e,s);if(n.changes&&!n.changes.empty||n.effects.length){let i=r.slice(0,t);return i[t-1]=n,i}else e=n.mapped,t--,s=n.selectionsAfter}return s.length?[On.selection(s)]:un}function Bq(r,e,t){let s=Rw(r.selectionsAfter.length?r.selectionsAfter.map(l=>l.map(e)):un,t);if(!r.changes)return On.selection(s);let n=r.changes.map(e),i=e.mapDesc(r.changes,!0),a=r.mapped?r.mapped.composeDesc(i):i;return new On(n,Et.mapEffects(r.effects,e),a,r.startSelection.map(i),s)}var Lq=/^(input\.type|delete)($|\.)/,di=class r{constructor(e,t,s=0,n=void 0){this.done=e,this.undone=t,this.prevTime=s,this.prevUserEvent=n}isolate(){return this.prevTime?new r(this.done,this.undone):this}addChanges(e,t,s,n,i){let a=this.done,l=a[a.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!s||Lq.test(s))&&(!l.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?r.moveByChar(t,e):wu(t,e))}function Pr(r){return r.textDirectionAt(r.state.selection.main.head)==Zt.LTR}var Nw=r=>Lw(r,!Pr(r)),$w=r=>Lw(r,Pr(r));function Mw(r,e){return Sn(r,t=>t.empty?r.moveByGroup(t,e):wu(t,e))}var Nq=r=>Mw(r,!Pr(r)),$q=r=>Mw(r,Pr(r));var dY=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Mq(r,e,t){if(e.type.prop(t))return!0;let s=e.to-e.from;return s&&(s>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function ku(r,e,t){let s=pr(r).resolveInner(e.head),n=t?kt.closedBy:kt.openedBy;for(let o=e.head;;){let u=t?s.childAfter(o):s.childBefore(o);if(!u)break;Mq(r,u,n)?s=u:o=t?u.to:u.from}let i=s.type.prop(n),a,l;return i&&(a=t?xn(r,s.from,1):xn(r,s.to,-1))&&a.matched?l=t?a.end.to:a.end.from:l=t?s.to:s.from,Ze.cursor(l,t?-1:1)}var jq=r=>Sn(r,e=>ku(r.state,e,!Pr(r))),qq=r=>Sn(r,e=>ku(r.state,e,Pr(r)));function jw(r,e){return Sn(r,t=>{if(!t.empty)return wu(t,e);let s=r.moveVertically(t,e);return s.head!=t.head?s:r.moveToLineBoundary(t,e)})}var qw=r=>jw(r,!1),Qw=r=>jw(r,!0);function Vw(r){let e=r.scrollDOM.clientHeighta.empty?r.moveVertically(a,e,t.height):wu(a,e));if(n.eq(s.selection))return!1;let i;if(t.selfScroll){let a=r.coordsAtPos(s.selection.main.head),l=r.scrollDOM.getBoundingClientRect(),o=l.top+t.marginTop,u=l.bottom-t.marginBottom;a&&a.top>o&&a.bottomUw(r,!1),dh=r=>Uw(r,!0);function Bs(r,e,t){let s=r.lineBlockAt(e.head),n=r.moveToLineBoundary(e,t);if(n.head==e.head&&n.head!=(t?s.to:s.from)&&(n=r.moveToLineBoundary(e,t,!1)),!t&&n.head==s.from&&s.length){let i=/^\s*/.exec(r.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;i&&e.head!=s.from+i&&(n=Ze.cursor(s.from+i))}return n}var Qq=r=>Sn(r,e=>Bs(r,e,!0)),Vq=r=>Sn(r,e=>Bs(r,e,!1)),Uq=r=>Sn(r,e=>Bs(r,e,!Pr(r))),zq=r=>Sn(r,e=>Bs(r,e,Pr(r))),Zq=r=>Sn(r,e=>Ze.cursor(r.lineBlockAt(e.head).from,1)),Wq=r=>Sn(r,e=>Ze.cursor(r.lineBlockAt(e.head).to,-1));function Gq(r,e,t){let s=!1,n=la(r.selection,i=>{let a=xn(r,i.head,-1)||xn(r,i.head,1)||i.head>0&&xn(r,i.head-1,1)||i.headGq(r,e,!1);function cn(r,e){let t=la(r.state.selection,s=>{let n=e(s);return Ze.range(s.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return t.eq(r.state.selection)?!1:(r.dispatch(Un(r.state,t)),!0)}function zw(r,e){return cn(r,t=>r.moveByChar(t,e))}var Zw=r=>zw(r,!Pr(r)),Ww=r=>zw(r,Pr(r));function Gw(r,e){return cn(r,t=>r.moveByGroup(t,e))}var Yq=r=>Gw(r,!Pr(r)),Hq=r=>Gw(r,Pr(r));var Kq=r=>cn(r,e=>ku(r.state,e,!Pr(r))),Jq=r=>cn(r,e=>ku(r.state,e,Pr(r)));function Xw(r,e){return cn(r,t=>r.moveVertically(t,e))}var Yw=r=>Xw(r,!1),Hw=r=>Xw(r,!0);function Kw(r,e){return cn(r,t=>r.moveVertically(t,e,Vw(r).height))}var Sw=r=>Kw(r,!1),Ew=r=>Kw(r,!0),eQ=r=>cn(r,e=>Bs(r,e,!0)),tQ=r=>cn(r,e=>Bs(r,e,!1)),rQ=r=>cn(r,e=>Bs(r,e,!Pr(r))),nQ=r=>cn(r,e=>Bs(r,e,Pr(r))),sQ=r=>cn(r,e=>Ze.cursor(r.lineBlockAt(e.head).from)),iQ=r=>cn(r,e=>Ze.cursor(r.lineBlockAt(e.head).to)),Cw=({state:r,dispatch:e})=>(e(Un(r,{anchor:0})),!0),ww=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.doc.length})),!0),kw=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.selection.main.anchor,head:0})),!0),Aw=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),vh=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),aQ=({state:r,dispatch:e})=>{let t=Au(r).map(({from:s,to:n})=>Ze.range(s,Math.min(n+1,r.doc.length)));return e(r.update({selection:Ze.create(t),userEvent:"select"})),!0},oQ=({state:r,dispatch:e})=>{let t=la(r.selection,s=>{let n=pr(r),i=n.resolveStack(s.from,1);if(s.empty){let a=n.resolveStack(s.from,-1);a.node.from>=i.node.from&&a.node.to<=i.node.to&&(i=a)}for(let a=i;a;a=a.next){let{node:l}=a;if((l.from=s.to||l.to>s.to&&l.from<=s.from)&&a.next)return Ze.range(l.to,l.from)}return s});return t.eq(r.selection)?!1:(e(Un(r,t)),!0)},lQ=({state:r,dispatch:e})=>{let t=r.selection,s=null;return t.ranges.length>1?s=Ze.create([t.main]):t.main.empty||(s=Ze.create([Ze.cursor(t.main.head)])),s?(e(Un(r,s)),!0):!1};function Ro(r,e){if(r.state.readOnly)return!1;let t="delete.selection",{state:s}=r,n=s.changeByRange(i=>{let{from:a,to:l}=i;if(a==l){let o=e(i);oa&&(t="delete.forward",o=Ou(r,o,!0)),a=Math.min(a,o),l=Math.max(l,o)}else a=Ou(r,a,!1),l=Ou(r,l,!0);return a==l?{range:i}:{changes:{from:a,to:l},range:Ze.cursor(a,an(r)))s.between(e,e,(n,i)=>{ne&&(e=t?i:n)});return e}var Jw=(r,e,t)=>Ro(r,s=>{let n=s.from,{state:i}=r,a=i.doc.lineAt(n),l,o;if(t&&!e&&n>a.from&&nJw(r,!1,!0);var ek=r=>Jw(r,!0,!1),tk=(r,e)=>Ro(r,t=>{let s=t.head,{state:n}=r,i=n.doc.lineAt(s),a=n.charCategorizer(s);for(let l=null;;){if(s==(e?i.to:i.from)){s==t.head&&i.number!=(e?n.doc.lines:1)&&(s+=e?1:-1);break}let o=ur(i.text,s-i.from,e)+i.from,u=i.text.slice(Math.min(s,o)-i.from,Math.max(s,o)-i.from),c=a(u);if(l!=null&&c!=l)break;(u!=" "||s!=t.head)&&(l=c),s=o}return s}),rk=r=>tk(r,!1),uQ=r=>tk(r,!0),cQ=r=>Ro(r,e=>{let t=r.lineBlockAt(e.head).to;return e.headRo(r,e=>{let t=r.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),pQ=r=>Ro(r,e=>{let t=r.moveToLineBoundary(e,!0).head;return e.head{if(r.readOnly)return!1;let t=r.changeByRange(s=>({changes:{from:s.from,to:s.to,insert:It.of(["",""])},range:Ze.cursor(s.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},dQ=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(s=>{if(!s.empty||s.from==0||s.from==r.doc.length)return{range:s};let n=s.from,i=r.doc.lineAt(n),a=n==i.from?n-1:ur(i.text,n-i.from,!1)+i.from,l=n==i.to?n+1:ur(i.text,n-i.from,!0)+i.from;return{changes:{from:a,to:l,insert:r.doc.slice(n,l).append(r.doc.slice(a,n))},range:Ze.cursor(l)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Au(r){let e=[],t=-1;for(let s of r.selection.ranges){let n=r.doc.lineAt(s.from),i=r.doc.lineAt(s.to);if(!s.empty&&s.to==i.from&&(i=r.doc.lineAt(s.to-1)),t>=n.number){let a=e[e.length-1];a.to=i.to,a.ranges.push(s)}else e.push({from:n.from,to:i.to,ranges:[s]});t=i.number+1}return e}function nk(r,e,t){if(r.readOnly)return!1;let s=[],n=[];for(let i of Au(r)){if(t?i.to==r.doc.length:i.from==0)continue;let a=r.doc.lineAt(t?i.to+1:i.from-1),l=a.length+1;if(t){s.push({from:i.to,to:a.to},{from:i.from,insert:a.text+r.lineBreak});for(let o of i.ranges)n.push(Ze.range(Math.min(r.doc.length,o.anchor+l),Math.min(r.doc.length,o.head+l)))}else{s.push({from:a.from,to:i.from},{from:i.to,insert:r.lineBreak+a.text});for(let o of i.ranges)n.push(Ze.range(o.anchor-l,o.head-l))}}return s.length?(e(r.update({changes:s,scrollIntoView:!0,selection:Ze.create(n,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}var mQ=({state:r,dispatch:e})=>nk(r,e,!1),gQ=({state:r,dispatch:e})=>nk(r,e,!0);function sk(r,e,t){if(r.readOnly)return!1;let s=[];for(let n of Au(r))t?s.push({from:n.from,insert:r.doc.slice(n.from,n.to)+r.lineBreak}):s.push({from:n.to,insert:r.lineBreak+r.doc.slice(n.from,n.to)});return e(r.update({changes:s,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var yQ=({state:r,dispatch:e})=>sk(r,e,!1),bQ=({state:r,dispatch:e})=>sk(r,e,!0),vQ=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(Au(e).map(({from:n,to:i})=>(n>0?n--:i{let i;if(r.lineWrapping){let a=r.lineBlockAt(n.head),l=r.coordsAtPos(n.head,n.assoc||1);l&&(i=a.bottom+r.documentTop-l.bottom+r.defaultLineHeight/2)}return r.moveVertically(n,!0,i)}).map(t);return r.dispatch({changes:t,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0};function xQ(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=pr(r).resolveInner(e),s=t.childBefore(e),n=t.childAfter(e),i;return s&&n&&s.to<=e&&n.from>=e&&(i=s.type.prop(kt.closedBy))&&i.indexOf(n.name)>-1&&r.doc.lineAt(s.to).from==r.doc.lineAt(n.from).from&&!/\S/.test(r.sliceDoc(s.to,n.from))?{from:s.to,to:n.from}:null}var Pw=ik(!1),OQ=ik(!0);function ik(r){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=e.changeByRange(n=>{let{from:i,to:a}=n,l=e.doc.lineAt(i),o=!r&&i==a&&xQ(e,i);r&&(i=a=(a<=l.to?l:e.doc.lineAt(a)).to);let u=new hi(e,{simulateBreak:i,simulateDoubleBreak:!!o}),c=bu(u,i);for(c==null&&(c=os(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));al.from&&i{let n=[];for(let a=s.from;a<=s.to;){let l=r.doc.lineAt(a);l.number>t&&(s.empty||s.to>l.from)&&(e(l,n,s),t=l.number),a=l.to+1}let i=r.changes(n);return{changes:n,range:Ze.range(i.mapPos(s.anchor,1),i.mapPos(s.head,1))}})}var SQ=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=Object.create(null),s=new hi(r,{overrideIndentation:i=>{let a=t[i];return a??-1}}),n=xh(r,(i,a,l)=>{let o=bu(s,i.from);if(o==null)return;/\S/.test(i.text)||(o=0);let u=/^\s*/.exec(i.text)[0],c=oa(r,o);(u!=c||l.fromr.readOnly?!1:(e(r.update(xh(r,(t,s)=>{s.push({from:t.from,insert:r.facet(aa)})}),{userEvent:"input.indent"})),!0),ak=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(xh(r,(t,s)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let i=os(n,r.tabSize),a=0,l=oa(r,Math.max(0,i-Do(r)));for(;a(r.setTabFocusMode(),!0);var CQ=[{key:"Ctrl-b",run:Nw,shift:Zw,preventDefault:!0},{key:"Ctrl-f",run:$w,shift:Ww},{key:"Ctrl-p",run:qw,shift:Yw},{key:"Ctrl-n",run:Qw,shift:Hw},{key:"Ctrl-a",run:Zq,shift:sQ},{key:"Ctrl-e",run:Wq,shift:iQ},{key:"Ctrl-d",run:ek},{key:"Ctrl-h",run:mh},{key:"Ctrl-k",run:cQ},{key:"Ctrl-Alt-h",run:rk},{key:"Ctrl-o",run:hQ},{key:"Ctrl-t",run:dQ},{key:"Ctrl-v",run:dh}],wQ=[{key:"ArrowLeft",run:Nw,shift:Zw,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Nq,shift:Yq,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Uq,shift:rQ,preventDefault:!0},{key:"ArrowRight",run:$w,shift:Ww,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:$q,shift:Hq,preventDefault:!0},{mac:"Cmd-ArrowRight",run:zq,shift:nQ,preventDefault:!0},{key:"ArrowUp",run:qw,shift:Yw,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Cw,shift:kw},{mac:"Ctrl-ArrowUp",run:Ow,shift:Sw},{key:"ArrowDown",run:Qw,shift:Hw,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ww,shift:Aw},{mac:"Ctrl-ArrowDown",run:dh,shift:Ew},{key:"PageUp",run:Ow,shift:Sw},{key:"PageDown",run:dh,shift:Ew},{key:"Home",run:Vq,shift:tQ,preventDefault:!0},{key:"Mod-Home",run:Cw,shift:kw},{key:"End",run:Qq,shift:eQ,preventDefault:!0},{key:"Mod-End",run:ww,shift:Aw},{key:"Enter",run:Pw,shift:Pw},{key:"Mod-a",run:vh},{key:"Backspace",run:mh,shift:mh},{key:"Delete",run:ek},{key:"Mod-Backspace",mac:"Alt-Backspace",run:rk},{key:"Mod-Delete",mac:"Alt-Delete",run:uQ},{mac:"Mod-Backspace",run:fQ},{mac:"Mod-Delete",run:pQ}].concat(CQ.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),ok=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:jq,shift:Kq},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:qq,shift:Jq},{key:"Alt-ArrowUp",run:mQ},{key:"Shift-Alt-ArrowUp",run:yQ},{key:"Alt-ArrowDown",run:gQ},{key:"Shift-Alt-ArrowDown",run:bQ},{key:"Escape",run:lQ},{key:"Mod-Enter",run:OQ},{key:"Alt-l",mac:"Ctrl-l",run:aQ},{key:"Mod-i",run:oQ,preventDefault:!0},{key:"Mod-[",run:ak},{key:"Mod-]",run:Pu},{key:"Mod-Alt-\\",run:SQ},{key:"Shift-Mod-k",run:vQ},{key:"Shift-Mod-\\",run:Xq},{key:"Mod-/",run:gh},{key:"Alt-A",run:Sq},{key:"Ctrl-m",mac:"Shift-Alt-m",run:EQ}].concat(wQ),lk={key:"Tab",run:Pu,shift:ak};function Ut(){var r=arguments[0];typeof r=="string"&&(r=document.createElement(r));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){var n=t[s];typeof n=="string"?r.setAttribute(s,n):n!=null&&(r[s]=n)}e++}for(;er.normalize("NFKD"):r=>r,Ns=class{constructor(e,t,s=0,n=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(s,n),this.bufferStart=s,this.normalize=i?l=>i(ck(l)):ck,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 gr(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=Ka(e),s=this.bufferStart+this.bufferPos;this.bufferPos+=$r(e);let n=this.normalize(t);for(let i=0,a=s;;i++){let l=n.charCodeAt(i),o=this.match(l,a,this.bufferPos+this.bufferStart);if(i==n.length-1){if(o)return this.value=o,this;break}a==s&&ithis.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 s=this.curLineStart+t.index,n=s+t[0].length;if(this.matchPos=Fu(this.text,n+(s==n?1:0)),s==this.curLineStart+this.curLine.length&&this.nextLine(),(sthis.value.to)&&(!this.test||this.test(s,n,t)))return this.value={from:s,to:n,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=s||n.to<=t){let l=new r(t,e.sliceString(t,s));return Oh.set(e,l),l}if(n.from==t&&n.to==s)return n;let{text:i,from:a}=n;return a>t&&(i=e.sliceString(t,a)+i,a=t),n.to=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 s=this.flat.from+t.index,n=s+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(s,n,t)))return this.value={from:s,to:n,match:t},this.matchPos=Fu(this.text,n+(s==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Iu.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(_u.prototype[Symbol.iterator]=Ru.prototype[Symbol.iterator]=function(){return this});function kQ(r){try{return new RegExp(r,Ah),!0}catch{return!1}}function Fu(r,e){if(e>=r.length)return e;let t=r.lineAt(e),s;for(;e=56320&&s<57344;)e++;return e}function Sh(r){let e=String(r.state.doc.lineAt(r.state.selection.main.head).number),t=Ut("input",{class:"cm-textfield",name:"line",value:e}),s=Ut("form",{class:"cm-gotoLine",onkeydown:i=>{i.keyCode==27?(i.preventDefault(),r.dispatch({effects:Bu.of(!1)}),r.focus()):i.keyCode==13&&(i.preventDefault(),n())},onsubmit:i=>{i.preventDefault(),n()}},Ut("label",r.state.phrase("Go to line"),": ",t)," ",Ut("button",{class:"cm-button",type:"submit"},r.state.phrase("go")));function n(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!i)return;let{state:a}=r,l=a.doc.lineAt(a.selection.main.head),[,o,u,c,p]=i,h=c?+c.slice(1):0,f=u?+u:l.number;if(u&&p){let g=f/100;o&&(g=g*(o=="-"?-1:1)+l.number/a.doc.lines),f=Math.round(a.doc.lines*g)}else u&&o&&(f=f*(o=="-"?-1:1)+l.number);let d=a.doc.line(Math.max(1,Math.min(a.doc.lines,f))),m=Ze.cursor(d.from+Math.max(0,Math.min(h,d.length)));r.dispatch({effects:[Bu.of(!1),at.scrollIntoView(m.from,{y:"center"})],selection:m}),r.focus()}return{dom:s}}var Bu=Et.define(),fk=Yt.define({create(){return!0},update(r,e){for(let t of e.effects)t.is(Bu)&&(r=t.value);return r},provide:r=>ui.from(r,e=>e?Sh:null)}),AQ=r=>{let e=Ji(r,Sh);if(!e){let t=[Bu.of(!0)];r.state.field(fk,!1)==null&&t.push(Et.appendConfig.of([fk,PQ])),r.dispatch({effects:t}),e=Ji(r,Sh)}return e&&e.dom.querySelector("input").select(),!0},PQ=at.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),TQ={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},mk=ut.define({combine(r){return kr(r,TQ,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function gk(r){let e=[FQ,RQ];return r&&e.push(mk.of(r)),e}var DQ=yt.mark({class:"cm-selectionMatch"}),_Q=yt.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function pk(r,e,t,s){return(t==0||r(e.sliceDoc(t-1,t))!=zt.Word)&&(s==e.doc.length||r(e.sliceDoc(s,s+1))!=zt.Word)}function IQ(r,e,t,s){return r(e.sliceDoc(t,t+1))==zt.Word&&r(e.sliceDoc(s-1,s))==zt.Word}var RQ=rr.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.selectionSet||r.docChanged||r.viewportChanged)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=r.state.facet(mk),{state:t}=r,s=t.selection;if(s.ranges.length>1)return yt.none;let n=s.main,i,a=null;if(n.empty){if(!e.highlightWordAroundCursor)return yt.none;let o=t.wordAt(n.head);if(!o)return yt.none;a=t.charCategorizer(n.head),i=t.sliceDoc(o.from,o.to)}else{let o=n.to-n.from;if(o200)return yt.none;if(e.wholeWords){if(i=t.sliceDoc(n.from,n.to),a=t.charCategorizer(n.head),!(pk(a,t,n.from,n.to)&&IQ(a,t,n.from,n.to)))return yt.none}else if(i=t.sliceDoc(n.from,n.to),!i)return yt.none}let l=[];for(let o of r.visibleRanges){let u=new Ns(t.doc,i,o.from,o.to);for(;!u.next().done;){let{from:c,to:p}=u.value;if((!a||pk(a,t,c,p))&&(n.empty&&c<=n.from&&p>=n.to?l.push(_Q.range(c,p)):(c>=n.to||p<=n.from)&&l.push(DQ.range(c,p)),l.length>e.maxMatches))return yt.none}}return yt.set(l)}},{decorations:r=>r.decorations}),FQ=at.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),BQ=({state:r,dispatch:e})=>{let{selection:t}=r,s=Ze.create(t.ranges.map(n=>r.wordAt(n.head)||Ze.cursor(n.head)),t.mainIndex);return s.eq(t)?!1:(e(r.update({selection:s})),!0)};function LQ(r,e){let{main:t,ranges:s}=r.selection,n=r.wordAt(t.head),i=n&&n.from==t.from&&n.to==t.to;for(let a=!1,l=new Ns(r.doc,e,s[s.length-1].to);;)if(l.next(),l.done){if(a)return null;l=new Ns(r.doc,e,0,Math.max(0,s[s.length-1].from-1)),a=!0}else{if(a&&s.some(o=>o.from==l.value.from))continue;if(i){let o=r.wordAt(l.value.from);if(!o||o.from!=l.value.from||o.to!=l.value.to)continue}return l.value}}var NQ=({state:r,dispatch:e})=>{let{ranges:t}=r.selection;if(t.some(i=>i.from===i.to))return BQ({state:r,dispatch:e});let s=r.sliceDoc(t[0].from,t[0].to);if(r.selection.ranges.some(i=>r.sliceDoc(i.from,i.to)!=s))return!1;let n=LQ(r,s);return n?(e(r.update({selection:r.selection.addRange(Ze.range(n.from,n.to),!1),effects:at.scrollIntoView(n.to)})),!0):!1},fa=ut.define({combine(r){return kr(r,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new kh(e),scrollToMatch:e=>at.scrollIntoView(e)})}});var Lu=class{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||kQ(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,s)=>s=="n"?` `:s=="r"?"\r":s=="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 Ch(this):new Eh(this)}getCursor(e,t=0,s){let n=e.doc?e:Vt.create({doc:e});return s==null&&(s=n.doc.length),this.regexp?ca(this,n,t,s):ua(this,n,t,s)}},Nu=class{constructor(e){this.spec=e}};function ua(r,e,t,s){return new Ns(e.doc,r.unquoted,t,s,r.caseSensitive?void 0:n=>n.toLowerCase(),r.wholeWord?$Q(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function $Q(r,e){return(t,s,n,i)=>((i>t||i+n.length=t)return null;n.push(s.value)}return n}highlight(e,t,s,n){let i=ua(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(s+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)n(i.value.from,i.value.to)}};function ca(r,e,t,s){return new _u(e.doc,r.search,{ignoreCase:!r.caseSensitive,test:r.wholeWord?MQ(e.charCategorizer(e.selection.main.head)):void 0},t,s)}function $u(r,e){return r.slice(ur(r,e,!1),e)}function Mu(r,e){return r.slice(e,ur(r,e))}function MQ(r){return(e,t,s)=>!s[0].length||(r($u(s.input,s.index))!=zt.Word||r(Mu(s.input,s.index))!=zt.Word)&&(r(Mu(s.input,s.index+s[0].length))!=zt.Word||r($u(s.input,s.index+s[0].length))!=zt.Word)}var Ch=class extends Nu{nextMatch(e,t,s){let n=ca(this.spec,e,s,e.doc.length).next();return n.done&&(n=ca(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,s){for(let n=1;;n++){let i=Math.max(t,s-n*1e4),a=ca(this.spec,e,i,s),l=null;for(;!a.next().done;)l=a.value;if(l&&(i==t||l.from>i+10))return l;if(i==t)return null}}prevMatch(e,t,s){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,s,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,s)=>s=="$"?"$":s=="&"?e.match[0]:s!="0"&&+s=t)return null;n.push(s.value)}return n}highlight(e,t,s,n){let i=ca(this.spec,e,Math.max(0,t-250),Math.min(s+250,e.doc.length));for(;!i.next().done;)n(i.value.from,i.value.to)}},Bo=Et.define(),Ph=Et.define(),Ls=Yt.define({create(r){return new Fo(wh(r).create(),null)},update(r,e){for(let t of e.effects)t.is(Bo)?r=new Fo(t.value.create(),r.panel):t.is(Ph)&&(r=new Fo(r.query,t.value?Th:null));return r},provide:r=>ui.from(r,e=>e.panel)});var Fo=class{constructor(e,t){this.query=e,this.panel=t}},jQ=yt.mark({class:"cm-searchMatch"}),qQ=yt.mark({class:"cm-searchMatch cm-searchMatch-selected"}),QQ=rr.fromClass(class{constructor(r){this.view=r,this.decorations=this.highlight(r.state.field(Ls))}update(r){let e=r.state.field(Ls);(e!=r.startState.field(Ls)||r.docChanged||r.selectionSet||r.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:r,panel:e}){if(!e||!r.spec.valid)return yt.none;let{view:t}=this,s=new Fn;for(let n=0,i=t.visibleRanges,a=i.length;ni[n+1].from-2*250;)o=i[++n].to;r.highlight(t.state,l,o,(u,c)=>{let p=t.state.selection.ranges.some(h=>h.from==u&&h.to==c);s.add(u,c,p?qQ:jQ)})}return s.finish()}},{decorations:r=>r.decorations});function Lo(r){return e=>{let t=e.state.field(Ls,!1);return t&&t.query.spec.valid?r(e,t):Qu(e)}}var ju=Lo((r,{query:e})=>{let{to:t}=r.state.selection.main,s=e.nextMatch(r.state,t,t);if(!s)return!1;let n=Ze.single(s.from,s.to),i=r.state.facet(fa);return r.dispatch({selection:n,effects:[Dh(r,s),i.scrollToMatch(n.main,r)],userEvent:"select.search"}),bk(r),!0}),qu=Lo((r,{query:e})=>{let{state:t}=r,{from:s}=t.selection.main,n=e.prevMatch(t,s,s);if(!n)return!1;let i=Ze.single(n.from,n.to),a=r.state.facet(fa);return r.dispatch({selection:i,effects:[Dh(r,n),a.scrollToMatch(i.main,r)],userEvent:"select.search"}),bk(r),!0}),VQ=Lo((r,{query:e})=>{let t=e.matchAll(r.state,1e3);return!t||!t.length?!1:(r.dispatch({selection:Ze.create(t.map(s=>Ze.range(s.from,s.to))),userEvent:"select.search.matches"}),!0)}),UQ=({state:r,dispatch:e})=>{let t=r.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:s,to:n}=t.main,i=[],a=0;for(let l=new Ns(r.doc,r.sliceDoc(s,n));!l.next().done;){if(i.length>1e3)return!1;l.value.from==s&&(a=i.length),i.push(Ze.range(l.value.from,l.value.to))}return e(r.update({selection:Ze.create(i,a),userEvent:"select.search.matches"})),!0},hk=Lo((r,{query:e})=>{let{state:t}=r,{from:s,to:n}=t.selection.main;if(t.readOnly)return!1;let i=e.nextMatch(t,s,s);if(!i)return!1;let a=[],l,o,u=[];if(i.from==s&&i.to==n&&(o=t.toText(e.getReplacement(i)),a.push({from:i.from,to:i.to,insert:o}),i=e.nextMatch(t,i.from,i.to),u.push(at.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(s).number)+"."))),i){let c=a.length==0||a[0].from>=i.to?0:i.to-i.from-o.length;l=Ze.single(i.from-c,i.to-c),u.push(Dh(r,i)),u.push(t.facet(fa).scrollToMatch(l.main,r))}return r.dispatch({changes:a,selection:l,effects:u,userEvent:"input.replace"}),!0}),zQ=Lo((r,{query:e})=>{if(r.state.readOnly)return!1;let t=e.matchAll(r.state,1e9).map(n=>{let{from:i,to:a}=n;return{from:i,to:a,insert:e.getReplacement(n)}});if(!t.length)return!1;let s=r.state.phrase("replaced $ matches",t.length)+".";return r.dispatch({changes:t,effects:at.announce.of(s),userEvent:"input.replace.all"}),!0});function Th(r){return r.state.facet(fa).createPanel(r)}function wh(r,e){var t,s,n,i,a;let l=r.selection.main,o=l.empty||l.to>l.from+100?"":r.sliceDoc(l.from,l.to);if(e&&!o)return e;let u=r.facet(fa);return new Lu({search:((t=e?.literal)!==null&&t!==void 0?t:u.literal)?o:o.replace(/\n/g,"\\n"),caseSensitive:(s=e?.caseSensitive)!==null&&s!==void 0?s:u.caseSensitive,literal:(n=e?.literal)!==null&&n!==void 0?n:u.literal,regexp:(i=e?.regexp)!==null&&i!==void 0?i:u.regexp,wholeWord:(a=e?.wholeWord)!==null&&a!==void 0?a:u.wholeWord})}function yk(r){let e=Ji(r,Th);return e&&e.dom.querySelector("[main-field]")}function bk(r){let e=yk(r);e&&e==r.root.activeElement&&e.select()}var Qu=r=>{let e=r.state.field(Ls,!1);if(e&&e.panel){let t=yk(r);if(t&&t!=r.root.activeElement){let s=wh(r.state,e.query.spec);s.valid&&r.dispatch({effects:Bo.of(s)}),t.focus(),t.select()}}else r.dispatch({effects:[Ph.of(!0),e?Bo.of(wh(r.state,e.query.spec)):Et.appendConfig.of(WQ)]});return!0},vk=r=>{let e=r.state.field(Ls,!1);if(!e||!e.panel)return!1;let t=Ji(r,Th);return t&&t.dom.contains(r.root.activeElement)&&r.focus(),r.dispatch({effects:Ph.of(!1)}),!0},xk=[{key:"Mod-f",run:Qu,scope:"editor search-panel"},{key:"F3",run:ju,shift:qu,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ju,shift:qu,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:vk,scope:"editor search-panel"},{key:"Mod-Shift-l",run:UQ},{key:"Mod-Alt-g",run:AQ},{key:"Mod-d",run:NQ,preventDefault:!0}],kh=class{constructor(e){this.view=e;let t=this.query=e.state.field(Ls).query.spec;this.commit=this.commit.bind(this),this.searchField=Ut("input",{value:t.search,placeholder:Hr(e,"Find"),"aria-label":Hr(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ut("input",{value:t.replace,placeholder:Hr(e,"Replace"),"aria-label":Hr(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ut("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Ut("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Ut("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function s(n,i,a){return Ut("button",{class:"cm-button",name:n,onclick:i,type:"button"},a)}this.dom=Ut("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,s("next",()=>ju(e),[Hr(e,"next")]),s("prev",()=>qu(e),[Hr(e,"previous")]),s("select",()=>VQ(e),[Hr(e,"all")]),Ut("label",null,[this.caseField,Hr(e,"match case")]),Ut("label",null,[this.reField,Hr(e,"regexp")]),Ut("label",null,[this.wordField,Hr(e,"by word")]),...e.state.readOnly?[]:[Ut("br"),this.replaceField,s("replace",()=>hk(e),[Hr(e,"replace")]),s("replaceAll",()=>zQ(e),[Hr(e,"replace all")])],Ut("button",{name:"close",onclick:()=>vk(e),"aria-label":Hr(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new Lu({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:Bo.of(e)}))}keydown(e){PC(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?qu:ju)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),hk(this.view))}update(e){for(let t of e.transactions)for(let s of t.effects)s.is(Bo)&&!s.value.eq(this.query)&&this.setQuery(s.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(fa).top}};function Hr(r,e){return r.state.phrase(e)}var Tu=30,Du=/[\s\.,:;?!]/;function Dh(r,{from:e,to:t}){let s=r.state.doc.lineAt(e),n=r.state.doc.lineAt(t).to,i=Math.max(s.from,e-Tu),a=Math.min(n,t+Tu),l=r.state.sliceDoc(i,a);if(i!=s.from){for(let o=0;ol.length-Tu;o--)if(!Du.test(l[o-1])&&Du.test(l[o])){l=l.slice(0,o);break}}return at.announce.of(`${r.state.phrase("current match")}. ${l} ${r.state.phrase("on line")} ${s.number}.`)}var ZQ=at.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"}}),WQ=[Ls,rn.low(QQ),ZQ];var Uu=class{constructor(e,t,s,n){this.state=e,this.pos=t,this.explicit=s,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=pr(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),s=Math.max(t.from,this.pos-250),n=t.text.slice(s-t.from,this.pos-t.from),i=n.search(_k(e,!1));return i<0?null:{from:s+i,to:this.pos,text:n.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,s){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),s&&s.onDocChange&&(this.abortOnDocChange=!0))}};function Ok(r){let e=Object.keys(r).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function GQ(r){let e=Object.create(null),t=Object.create(null);for(let{label:n}of r){e[n[0]]=!0;for(let i=1;itypeof n=="string"?{label:n}:n),[t,s]=e.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:GQ(e);return n=>{let i=n.matchBefore(s);return i||n.explicit?{from:i?i.from:n.pos,options:e,validFor:t}:null}}function Dk(r,e){return t=>{for(let s=pr(t.state).resolveInner(t.pos,-1);s;s=s.parent){if(r.indexOf(s.name)>-1)return null;if(s.type.isTop)break}return e(t)}}var zu=class{constructor(e,t,s,n){this.completion=e,this.source=t,this.match=s,this.score=n}};function $s(r){return r.selection.main.from}function _k(r,e){var t;let{source:s}=r,n=e&&s[0]!="^",i=s[s.length-1]!="$";return!n&&!i?r:new RegExp(`${n?"^":""}(?:${s})${i?"$":""}`,(t=r.flags)!==null&&t!==void 0?t:r.ignoreCase?"i":"")}var Vh=Mr.define();function XQ(r,e,t,s){let{main:n}=r.selection,i=t-n.from,a=s-n.from;return Object.assign(Object.assign({},r.changeByRange(l=>{if(l!=n&&t!=s&&r.sliceDoc(l.from+i,l.from+a)!=r.sliceDoc(t,s))return{range:l};let o=r.toText(e);return{changes:{from:l.from+i,to:s==n.from?l.to:l.from+a,insert:o},range:Ze.cursor(l.from+i+o.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}var Sk=new WeakMap;function YQ(r){if(!Array.isArray(r))return r;let e=Sk.get(r);return e||Sk.set(r,e=Qh(r)),e}var Zu=Et.define(),No=Et.define(),Rh=class{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=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(O=Ka(C))!=O.toLowerCase()?1:O!=O.toUpperCase()?2:0;(!v||w==1&&g||S==0&&w!=0)&&(t[p]==C||s[p]==C&&(h=!0)?a[p++]=v:a.length&&(y=!1)),S=w,v+=$r(C)}return p==o&&a[0]==0&&y?this.result(-100+(h?-200:0),a,e):f==o&&d==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):f==o?this.ret(-900-e.length,[d,m]):p==o?this.result(-100+(h?-200:0)+-700+(y?0:-1100),a,e):t.length==2?null:this.result((n[0]?-700:0)+-200+-1100,n,e)}result(e,t,s){let n=[],i=0;for(let a of t){let l=a+(this.astral?$r(gr(s,a)):1);i&&n[i-1]==a?n[i-1]=l:(n[i++]=a,n[i++]=l)}return this.ret(e-s.length,n)}},Fh=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:HQ,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>s=>Ek(e(s),t(s)),optionClass:(e,t)=>s=>Ek(e(s),t(s)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Ek(r,e){return r?e?r+" "+e:r:e}function HQ(r,e,t,s,n,i){let a=r.textDirection==Zt.RTL,l=a,o=!1,u="top",c,p,h=e.left-n.left,f=n.right-e.right,d=s.right-s.left,m=s.bottom-s.top;if(l&&h=m||v>e.top?c=t.bottom-e.top:(u="bottom",c=e.bottom-t.top)}let g=(e.bottom-e.top)/i.offsetHeight,y=(e.right-e.left)/i.offsetWidth;return{style:`${u}: ${c/g}px; max-width: ${p/y}px`,class:"cm-completionInfo-"+(o?a?"left-narrow":"right-narrow":l?"left":"right")}}function KQ(r){let e=r.addToOptions.slice();return r.icons&&e.push({render(t){let s=document.createElement("div");return s.classList.add("cm-completionIcon"),t.type&&s.classList.add(...t.type.split(/\s+/g).map(n=>"cm-completionIcon-"+n)),s.setAttribute("aria-hidden","true"),s},position:20}),e.push({render(t,s,n,i){let a=document.createElement("span");a.className="cm-completionLabel";let l=t.displayLabel||t.label,o=0;for(let u=0;uo&&a.appendChild(document.createTextNode(l.slice(o,c)));let h=a.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(l.slice(c,p))),h.className="cm-completionMatchedText",o=p}return ot.position-s.position).map(t=>t.render)}function _h(r,e,t){if(r<=t)return{from:0,to:r};if(e<0&&(e=0),e<=r>>1){let n=Math.floor(e/t);return{from:n*t,to:(n+1)*t}}let s=Math.floor((r-e)/t);return{from:r-(s+1)*t,to:r-s*t}}var Bh=class{constructor(e,t,s){this.view=e,this.stateField=t,this.applyCompletion=s,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:o=>this.placeInfo(o),key:this},this.space=null,this.currentClass="";let n=e.state.field(t),{options:i,selected:a}=n.open,l=e.state.facet(Sr);this.optionContent=KQ(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=_h(i.length,a,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",o=>{let{options:u}=e.state.field(t).open;for(let c=o.target,p;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(p=/-(\d+)$/.exec(c.id))&&+p[1]{let u=e.state.field(this.stateField,!1);u&&u.tooltip&&e.state.facet(Sr).closeOnBlur&&o.relatedTarget!=e.contentDOM&&e.dispatch({effects:No.of(null)})}),this.showOptions(i,n.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let s=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),s!=n){let{options:i,selected:a,disabled:l}=s.open;(!n.open||n.open.options!=i)&&(this.range=_h(i.length,a,e.state.facet(Sr).maxRenderedOptions),this.showOptions(i,s.id)),this.updateSel(),l!=((t=n.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let s of this.currentClass.split(" "))s&&this.dom.classList.remove(s);for(let s of t.split(" "))s&&this.dom.classList.add(s);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.to)&&(this.range=_h(t.options.length,t.selected,this.view.state.facet(Sr).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:n}=s;if(!n)return;let i=typeof n=="string"?document.createTextNode(n):n(s);if(!i)return;"then"in i?i.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,s)}).catch(a=>yr(this.view.state,a,"completion info")):this.addInfoPane(i,s)}}addInfoPane(e,t){this.destroyInfo();let s=this.info=document.createElement("div");if(s.className="cm-tooltip cm-completionInfo",e.nodeType!=null)s.appendChild(e),this.infoDestroy=null;else{let{dom:n,destroy:i}=e;s.appendChild(n),this.infoDestroy=i||null}this.dom.appendChild(s),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let s=this.list.firstChild,n=this.range.from;s;s=s.nextSibling,n++)s.nodeName!="LI"||!s.id?n--:n==e?s.hasAttribute("aria-selected")||(s.setAttribute("aria-selected","true"),t=s):s.hasAttribute("aria-selected")&&s.removeAttribute("aria-selected");return t&&e5(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),s=this.info.getBoundingClientRect(),n=e.getBoundingClientRect(),i=this.space;if(!i){let a=this.dom.ownerDocument.defaultView||window;i={left:0,top:0,right:a.innerWidth,bottom:a.innerHeight}}return n.top>Math.min(i.bottom,t.bottom)-10||n.bottoms.from||s.from==0))if(i=h,typeof u!="string"&&u.header)n.appendChild(u.header(u));else{let f=n.appendChild(document.createElement("completion-section"));f.textContent=h}}let c=n.appendChild(document.createElement("li"));c.id=t+"-"+a,c.setAttribute("role","option");let p=this.optionClass(l);p&&(c.className=p);for(let h of this.optionContent){let f=h(l,this.view.state,this.view,o);f&&c.appendChild(f)}}return s.from&&n.classList.add("cm-completionListIncompleteTop"),s.tonew Bh(t,r,e)}function e5(r,e){let t=r.getBoundingClientRect(),s=e.getBoundingClientRect(),n=t.height/r.offsetHeight;s.topt.bottom&&(r.scrollTop+=(s.bottom-t.bottom)/n)}function Ck(r){return(r.boost||0)*100+(r.apply?10:0)+(r.info?5:0)+(r.type?1:0)}function t5(r,e){let t=[],s=null,n=u=>{t.push(u);let{section:c}=u.completion;if(c){s||(s=[]);let p=typeof c=="string"?c:c.name;s.some(h=>h.name==p)||s.push(typeof c=="string"?{name:p}:c)}},i=e.facet(Sr);for(let u of r)if(u.hasResult()){let c=u.result.getMatch;if(u.result.filter===!1)for(let p of u.result.options)n(new zu(p,u.source,c?c(p):[],1e9-t.length));else{let p=e.sliceDoc(u.from,u.to),h,f=i.filterStrict?new Fh(p):new Rh(p);for(let d of u.result.options)if(h=f.match(d.label)){let m=d.displayLabel?c?c(d,h.matched):[]:h.matched;n(new zu(d,u.source,m,h.score+(d.boost||0)))}}}if(s){let u=Object.create(null),c=0,p=(h,f)=>{var d,m;return((d=h.rank)!==null&&d!==void 0?d:1e9)-((m=f.rank)!==null&&m!==void 0?m:1e9)||(h.namep.score-c.score||o(c.completion,p.completion))){let c=u.completion;!l||l.label!=c.label||l.detail!=c.detail||l.type!=null&&c.type!=null&&l.type!=c.type||l.apply!=c.apply||l.boost!=c.boost?a.push(u):Ck(u.completion)>Ck(l)&&(a[a.length-1]=u),l=u.completion}return a}var Lh=class r{constructor(e,t,s,n,i,a){this.options=e,this.attrs=t,this.tooltip=s,this.timestamp=n,this.selected=i,this.disabled=a}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new r(this.options,wk(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,s,n,i){let a=t5(e,t);if(!a.length)return n&&e.some(o=>o.state==1)?new r(n.options,n.attrs,n.tooltip,n.timestamp,n.selected,!0):null;let l=t.facet(Sr).selectOnOpen?0:-1;if(n&&n.selected!=l&&n.selected!=-1){let o=n.options[n.selected].completion;for(let u=0;uu.hasResult()?Math.min(o,u.from):o,1e8),create:o5,above:i.aboveCursor},n?n.timestamp:Date.now(),l,!1)}map(e){return new r(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}},Nh=class r{constructor(e,t,s){this.active=e,this.id=t,this.open=s}static start(){return new r(i5,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,s=t.facet(Sr),i=(s.override||t.languageDataAt("autocomplete",$s(t)).map(YQ)).map(l=>(this.active.find(u=>u.source==l)||new us(l,this.active.some(u=>u.state!=0)?1:0)).update(e,s));i.length==this.active.length&&i.every((l,o)=>l==this.active[o])&&(i=this.active);let a=this.open;a&&e.docChanged&&(a=a.map(e.changes)),e.selection||i.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!r5(i,this.active)?a=Lh.build(i,t,this.id,a,s):a&&a.disabled&&!i.some(l=>l.state==1)&&(a=null),!a&&i.every(l=>l.state!=1)&&i.some(l=>l.hasResult())&&(i=i.map(l=>l.hasResult()?new us(l.source,0):l));for(let l of e.effects)l.is(Fk)&&(a=a&&a.setSelected(l.value,this.id));return i==this.active&&a==this.open?this:new r(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?n5:s5}};function r5(r,e){if(r==e)return!0;for(let t=0,s=0;;){for(;t-1&&(t["aria-activedescendant"]=r+"-"+e),t}var i5=[];function Ik(r,e){if(r.isUserEvent("input.complete")){let s=r.annotation(Vh);if(s&&e.activateOnCompletion(s))return 12}let t=r.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:r.isUserEvent("delete.backward")?2:r.selection?8:r.docChanged?16:0}var us=class r{constructor(e,t,s=-1){this.source=e,this.state=t,this.explicitPos=s}hasResult(){return!1}update(e,t){let s=Ik(e,t),n=this;(s&8||s&16&&this.touches(e))&&(n=new r(n.source,0)),s&4&&n.state==0&&(n=new r(this.source,1)),n=n.updateFor(e,s);for(let i of e.effects)if(i.is(Zu))n=new r(n.source,1,i.value?$s(e.state):-1);else if(i.is(No))n=new r(n.source,0);else if(i.is(Rk))for(let a of i.value)a.source==n.source&&(n=a);return n}updateFor(e,t){return this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new r(this.source,this.state,e.mapPos(this.explicitPos))}touches(e){return e.changes.touchesRange($s(e.state))}},Wu=class r extends us{constructor(e,t,s,n,i){super(e,2,t),this.result=s,this.from=n,this.to=i}hasResult(){return!0}updateFor(e,t){var s;if(!(t&3))return this.map(e.changes);let n=this.result;n.map&&!e.changes.empty&&(n=n.map(n,e.changes));let i=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),l=$s(e.state);if((this.explicitPos<0?l<=i:la||!n||t&2&&$s(e.startState)==this.from)return new us(this.source,t&4?1:0);let o=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return a5(n.validFor,e.state,i,a)?new r(this.source,o,n,i,a):n.update&&(n=n.update(n,i,a,new Uu(e.state,l,o>=0)))?new r(this.source,o,n,n.from,(s=n.to)!==null&&s!==void 0?s:$s(e.state)):new us(this.source,1,o)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new r(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new us(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function a5(r,e,t,s){if(!r)return!1;let n=e.sliceDoc(t,s);return typeof r=="function"?r(n,t,s,e):_k(r,!0).test(n)}var Rk=Et.define({map(r,e){return r.map(t=>t.map(e))}}),Fk=Et.define(),qr=Yt.define({create(){return Nh.start()},update(r,e){return r.update(e)},provide:r=>[Ki.from(r,e=>e.tooltip),at.contentAttributes.from(r,e=>e.attrs)]});function Uh(r,e){let t=e.completion.apply||e.completion.label,s=r.state.field(qr).active.find(n=>n.source==e.source);return s instanceof Wu?(typeof t=="string"?r.dispatch(Object.assign(Object.assign({},XQ(r.state,t,s.from,s.to)),{annotations:Vh.of(e.completion)})):t(r,e.completion,s.from,s.to),!0):!1}var o5=JQ(qr,Uh);function Vu(r,e="option"){return t=>{let s=t.state.field(qr,!1);if(!s||!s.open||s.open.disabled||Date.now()-s.open.timestamp-1?s.open.selected+n*(r?1:-1):r?0:a-1;return l<0?l=e=="page"?0:a-1:l>=a&&(l=e=="page"?a-1:0),t.dispatch({effects:Fk.of(l)}),!0}}var l5=r=>{let e=r.state.field(qr,!1);return r.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampr.state.field(qr,!1)?(r.dispatch({effects:Zu.of(!0)}),!0):!1,u5=r=>{let e=r.state.field(qr,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(r.dispatch({effects:No.of(null)}),!0)},$h=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},c5=50,f5=1e3,p5=rr.fromClass(class{constructor(r){this.view=r,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of r.state.field(qr).active)e.state==1&&this.startQuery(e)}update(r){let e=r.state.field(qr),t=r.state.facet(Sr);if(!r.selectionSet&&!r.docChanged&&r.startState.field(qr)==e)return;let s=r.transactions.some(i=>{let a=Ik(i,t);return a&8||(i.selection||i.docChanged)&&!(a&3)});for(let i=0;ic5&&Date.now()-a.time>f5){for(let l of a.context.abortListeners)try{l()}catch(o){yr(this.view.state,o)}a.context.abortListeners=null,this.running.splice(i--,1)}else a.updates.push(...r.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),r.transactions.some(i=>i.effects.some(a=>a.is(Zu)))&&(this.pendingStart=!0);let n=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(i=>i.state==1&&!this.running.some(a=>a.active.source==i.source))?setTimeout(()=>this.startUpdate(),n):-1,this.composing!=0)for(let i of r.transactions)i.isUserEvent("input.type")?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:r}=this.view,e=r.field(qr);for(let t of e.active)t.state==1&&!this.running.some(s=>s.active.source==t.source)&&this.startQuery(t)}startQuery(r){let{state:e}=this.view,t=$s(e),s=new Uu(e,t,r.explicitPos==t,this.view),n=new $h(r,s);this.running.push(n),Promise.resolve(r.source(s)).then(i=>{n.context.aborted||(n.done=i||null,this.scheduleAccept())},i=>{this.view.dispatch({effects:No.of(null)}),yr(this.view.state,i)})}scheduleAccept(){this.running.every(r=>r.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Sr).updateSyncTime))}accept(){var r;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Sr);for(let s=0;sa.source==n.active.source);if(i&&i.state==1)if(n.done==null){let a=new us(n.active.source,0);for(let l of n.updates)a=a.update(l,t);a.state!=1&&e.push(a)}else this.startQuery(i)}e.length&&this.view.dispatch({effects:Rk.of(e)})}},{eventHandlers:{blur(r){let e=this.view.state.field(qr,!1);if(e&&e.tooltip&&this.view.state.facet(Sr).closeOnBlur){let t=e.open&&jp(this.view,e.open.tooltip);(!t||!t.dom.contains(r.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:No.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Zu.of(!1)}),20),this.composing=0}}}),h5=typeof navigator=="object"&&/Win/.test(navigator.platform),d5=rn.highest(at.domEventHandlers({keydown(r,e){let t=e.state.field(qr,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||r.key.length>1||r.ctrlKey&&!(h5&&r.altKey)||r.metaKey)return!1;let s=t.open.options[t.open.selected],n=t.active.find(a=>a.source==s.source),i=s.completion.commitCharacters||n.result.commitCharacters;return i&&i.indexOf(r.key)>-1&&Uh(e,s),!1}})),Bk=at.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",whiteSpace:"pre-line"},".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:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Mh=class{constructor(e,t,s,n){this.field=e,this.line=t,this.from=s,this.to=n}},jh=class r{constructor(e,t,s){this.field=e,this.from=t,this.to=s}map(e){let t=e.mapPos(this.from,-1,fr.TrackDel),s=e.mapPos(this.to,1,fr.TrackDel);return t==null||s==null?null:new r(this.field,t,s)}},qh=class r{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let s=[],n=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let o of this.lines){if(s.length){let u=a,c=/^\t*/.exec(o)[0].length;for(let p=0;pnew jh(o.field,n[o.line]+o.from,n[o.line]+o.to));return{text:s,ranges:l}}static parse(e){let t=[],s=[],n=[],i;for(let a of e.split(/\r\n?|\n/)){for(;i=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(a);){let l=i[1]?+i[1]:null,o=i[2]||i[3]||"",u=-1,c=o.replace(/\\[{}]/g,p=>p[1]);for(let p=0;p=u&&h.field++}n.push(new Mh(u,s.length,i.index,i.index+c.length)),a=a.slice(0,i.index)+o+a.slice(i.index+i[0].length)}a=a.replace(/\\([{}])/g,(l,o,u)=>{for(let c of n)c.line==s.length&&c.from>u&&(c.from--,c.to--);return o}),s.push(a)}return new r(s,n)}},m5=yt.widget({widget:new class extends an{toDOM(){let r=document.createElement("span");return r.className="cm-snippetFieldPosition",r}ignoreEvent(){return!1}}}),g5=yt.mark({class:"cm-snippetField"}),pa=class r{constructor(e,t){this.ranges=e,this.active=t,this.deco=yt.set(e.map(s=>(s.from==s.to?m5:g5).range(s.from,s.to)))}map(e){let t=[];for(let s of this.ranges){let n=s.map(e);if(!n)return null;t.push(n)}return new r(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(s=>s.field==this.active&&s.from<=t.from&&s.to>=t.to))}},Mo=Et.define({map(r,e){return r&&r.map(e)}}),y5=Et.define(),$o=Yt.define({create(){return null},update(r,e){for(let t of e.effects){if(t.is(Mo))return t.value;if(t.is(y5)&&r)return new pa(r.ranges,t.value)}return r&&e.docChanged&&(r=r.map(e.changes)),r&&e.selection&&!r.selectionInsideField(e.selection)&&(r=null),r},provide:r=>at.decorations.from(r,e=>e?e.deco:yt.none)});function zh(r,e){return Ze.create(r.filter(t=>t.field==e).map(t=>Ze.range(t.from,t.to)))}function b5(r){let e=qh.parse(r);return(t,s,n,i)=>{let{text:a,ranges:l}=e.instantiate(t.state,n),o={changes:{from:n,to:i,insert:It.of(a)},scrollIntoView:!0,annotations:s?[Vh.of(s),lr.userEvent.of("input.complete")]:void 0};if(l.length&&(o.selection=zh(l,0)),l.some(u=>u.field>0)){let u=new pa(l,0),c=o.effects=[Mo.of(u)];t.state.field($o,!1)===void 0&&c.push(Et.appendConfig.of([$o,E5,C5,Bk]))}t.dispatch(t.state.update(o))}}function Lk(r){return({state:e,dispatch:t})=>{let s=e.field($o,!1);if(!s||r<0&&s.active==0)return!1;let n=s.active+r,i=r>0&&!s.ranges.some(a=>a.field==n+r);return t(e.update({selection:zh(s.ranges,n),effects:Mo.of(i?null:new pa(s.ranges,n)),scrollIntoView:!0})),!0}}var v5=({state:r,dispatch:e})=>r.field($o,!1)?(e(r.update({effects:Mo.of(null)})),!0):!1,x5=Lk(1),O5=Lk(-1);var S5=[{key:"Tab",run:x5,shift:O5},{key:"Escape",run:v5}],Ak=ut.define({combine(r){return r.length?r[0]:S5}}),E5=rn.highest(_s.compute([Ak],r=>r.facet(Ak)));function Rr(r,e){return Object.assign(Object.assign({},e),{apply:b5(r)})}var C5=at.domEventHandlers({mousedown(r,e){let t=e.state.field($o,!1),s;if(!t||(s=e.posAtCoords({x:r.clientX,y:r.clientY}))==null)return!1;let n=t.ranges.find(i=>i.from<=s&&i.to>=s);return!n||n.field==t.active?!1:(e.dispatch({selection:zh(t.ranges,n.field),effects:Mo.of(t.ranges.some(i=>i.field>n.field)?new pa(t.ranges,n.field):null),scrollIntoView:!0}),!0)}});var Gu={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},mi=Et.define({map(r,e){let t=e.mapPos(r,-1,fr.TrackAfter);return t??void 0}}),Zh=new class extends yn{};Zh.startSide=1;Zh.endSide=-1;var Nk=Yt.define({create(){return Mt.empty},update(r,e){if(r=r.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);r=r.update({filter:s=>s>=t.from&&s<=t.to})}for(let t of e.effects)t.is(mi)&&(r=r.update({add:[Zh.range(t.value,t.value+1)]}));return r}});function $k(){return[P5,Nk]}var Ih="()[]{}<>";function w5(r){for(let e=0;e{if((A5?r.composing:r.compositionStarted)||r.state.readOnly)return!1;let n=r.state.selection.main;if(s.length>2||s.length==2&&$r(gr(s,0))==1||e!=n.from||t!=n.to)return!1;let i=T5(r.state,s);return i?(r.dispatch(i),!0):!1});function T5(r,e){let t=k5(r,r.selection.main.head),s=t.brackets||Gu.brackets;for(let n of s){let i=w5(gr(n,0));if(e==n)return i==n?I5(r,n,s.indexOf(n+n+n)>-1,t):D5(r,n,i,t.before||Gu.before);if(e==i&&Mk(r,r.selection.main.from))return _5(r,n,i)}return null}function Mk(r,e){let t=!1;return r.field(Nk).between(0,r.doc.length,s=>{s==e&&(t=!0)}),t}function Wh(r,e){let t=r.sliceString(e,e+2);return t.slice(0,$r(gr(t,0)))}function D5(r,e,t,s){let n=null,i=r.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:t,from:a.to}],effects:mi.of(a.to+e.length),range:Ze.range(a.anchor+e.length,a.head+e.length)};let l=Wh(r.doc,a.head);return!l||/\s/.test(l)||s.indexOf(l)>-1?{changes:{insert:e+t,from:a.head},effects:mi.of(a.head+e.length),range:Ze.cursor(a.head+e.length)}:{range:n=a}});return n?null:r.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function _5(r,e,t){let s=null,n=r.changeByRange(i=>i.empty&&Wh(r.doc,i.head)==t?{changes:{from:i.head,to:i.head+t.length,insert:t},range:Ze.cursor(i.head+t.length)}:s={range:i});return s?null:r.update(n,{scrollIntoView:!0,userEvent:"input.type"})}function I5(r,e,t,s){let n=s.stringPrefixes||Gu.stringPrefixes,i=null,a=r.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:mi.of(l.to+e.length),range:Ze.range(l.anchor+e.length,l.head+e.length)};let o=l.head,u=Wh(r.doc,o),c;if(u==e){if(Pk(r,o))return{changes:{insert:e+e,from:o},effects:mi.of(o+e.length),range:Ze.cursor(o+e.length)};if(Mk(r,o)){let h=t&&r.sliceDoc(o,o+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:o,to:o+h.length,insert:h},range:Ze.cursor(o+h.length)}}}else{if(t&&r.sliceDoc(o-2*e.length,o)==e+e&&(c=Tk(r,o-2*e.length,n))>-1&&Pk(r,c))return{changes:{insert:e+e+e+e,from:o},effects:mi.of(o+e.length),range:Ze.cursor(o+e.length)};if(r.charCategorizer(o)(u)!=zt.Word&&Tk(r,o,n)>-1&&!R5(r,o,e,n))return{changes:{insert:e+e,from:o},effects:mi.of(o+e.length),range:Ze.cursor(o+e.length)}}return{range:i=l}});return i?null:r.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Pk(r,e){let t=pr(r).resolveInner(e+1);return t.parent&&t.from==e}function R5(r,e,t,s){let n=pr(r).resolveInner(e,-1),i=s.reduce((a,l)=>Math.max(a,l.length),0);for(let a=0;a<5;a++){let l=r.sliceDoc(n.from,Math.min(n.to,n.from+t.length+i)),o=l.indexOf(t);if(!o||o>-1&&s.indexOf(l.slice(0,o))>-1){let c=n.firstChild;for(;c&&c.from==n.from&&c.to-c.from>t.length+o;){if(r.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let u=n.to==e&&n.parent;if(!u)break;n=u}return!1}function Tk(r,e,t){let s=r.charCategorizer(e);if(s(r.sliceDoc(e-1,e))!=zt.Word)return e;for(let n of t){let i=e-n.length;if(r.sliceDoc(i,e)==n&&s(r.sliceDoc(i-1,i))!=zt.Word)return i}return-1}function jk(r={}){return[d5,qr,Sr.of(r),p5,B5,Bk]}var F5=[{key:"Ctrl-Space",run:kk},{mac:"Alt-`",run:kk},{key:"Escape",run:u5},{key:"ArrowDown",run:Vu(!0)},{key:"ArrowUp",run:Vu(!1)},{key:"PageDown",run:Vu(!0,"page")},{key:"PageUp",run:Vu(!1,"page")},{key:"Enter",run:l5}],B5=rn.highest(_s.computeN([Sr],r=>r.facet(Sr).defaultKeymap?[F5]:[]));var Gh=class{constructor(e,t,s){this.from=e,this.to=t,this.diagnostic=s}},gi=class r{constructor(e,t,s){this.diagnostics=e,this.panel=t,this.selected=s}static init(e,t,s){let n=e,i=s.facet(zn).markerFilter;i&&(n=i(n,s));let a=yt.set(n.map(l=>l.from==l.to||l.from==l.to-1&&s.doc.lineAt(l.from).to==l.from?yt.widget({widget:new Xh(l),diagnostic:l}).range(l.from):yt.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new r(a,t,ha(a))}};function ha(r,e=null,t=0){let s=null;return r.between(t,1e9,(n,i,{spec:a})=>{if(!(e&&a.diagnostic!=e))return s=new Gh(n,i,a.diagnostic),!1}),s}function Vk(r,e){let t=e.pos,s=e.end||t,n=r.state.facet(zn).hideOn(r,t,s);if(n!=null)return n;let i=r.startState.doc.lineAt(e.pos);return!!(r.effects.some(a=>a.is(ec))||r.changes.touchesRange(i.from,Math.max(i.to,s)))}function L5(r,e){return r.field(En,!1)?e:e.concat(Et.appendConfig.of(Hk))}function N5(r,e){return{effects:L5(r,[ec.of(e)])}}var ec=Et.define(),Uk=Et.define(),zk=Et.define(),En=Yt.define({create(){return new gi(yt.none,null,null)},update(r,e){if(e.docChanged&&r.diagnostics.size){let t=r.diagnostics.map(e.changes),s=null,n=r.panel;if(r.selected){let i=e.changes.mapPos(r.selected.from,1);s=ha(t,r.selected.diagnostic,i)||ha(t,null,i)}!t.size&&n&&e.state.facet(zn).autoPanel&&(n=null),r=new gi(t,n,s)}for(let t of e.effects)if(t.is(ec)){let s=e.state.facet(zn).autoPanel?t.value.length?Ku.open:null:r.panel;r=gi.init(t.value,s,e.state)}else t.is(Uk)?r=new gi(r.diagnostics,t.value?Ku.open:null,r.selected):t.is(zk)&&(r=new gi(r.diagnostics,r.panel,t.value));return r},provide:r=>[ui.from(r,e=>e.panel),at.decorations.from(r,e=>e.diagnostics)]});var $5=yt.mark({class:"cm-lintRange cm-lintRange-active"});function M5(r,e,t){let{diagnostics:s}=r.state.field(En),n=[],i=2e8,a=0;s.between(e-(t<0?1:0),e+(t>0?1:0),(o,u,{spec:c})=>{e>=o&&e<=u&&(o==u||(e>o||t>0)&&(eXk(r,t,!1)))}var qk=r=>{let e=r.state.field(En,!1);return!e||!e.panel?!1:(r.dispatch({effects:Uk.of(!1)}),!0)};var j5=rr.fromClass(class{constructor(r){this.view=r,this.timeout=-1,this.set=!0;let{delay:e}=r.state.facet(zn);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let r=Date.now();if(rPromise.resolve(s(this.view))),s=>{this.view.state.doc==e.doc&&this.view.dispatch(N5(this.view.state,s.reduce((n,i)=>n.concat(i))))},s=>{yr(this.view.state,s)})}}update(r){let e=r.state.facet(zn);(r.docChanged||e!=r.startState.facet(zn)||e.needsRefresh&&e.needsRefresh(r))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function q5(r,e,t){let s=[],n=-1;for(let i of r)i.then(a=>{s.push(a),clearTimeout(n),s.length==r.length?e(s):setTimeout(()=>e(s),200)},t)}var zn=ut.define({combine(r){return Object.assign({sources:r.map(e=>e.source).filter(e=>e!=null)},kr(r.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?s=>e(s)||t(s):e:t}))}});function Wk(r,e={}){return[zn.of({source:r,config:e}),j5,Hk]}function Gk(r){let e=[];if(r)e:for(let{name:t}of r){for(let s=0;si.toLowerCase()==n.toLowerCase())){e.push(n);continue e}}e.push("")}return e}function Xk(r,e,t){var s;let n=t?Gk(e.actions):[];return Ut("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Ut("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(r):e.message),(s=e.actions)===null||s===void 0?void 0:s.map((i,a)=>{let l=!1,o=h=>{if(h.preventDefault(),l)return;l=!0;let f=ha(r.state.field(En).diagnostics,e);f&&i.apply(r,f.from,f.to)},{name:u}=i,c=n[a]?u.indexOf(n[a]):-1,p=c<0?u:[u.slice(0,c),Ut("u",u.slice(c,c+1)),u.slice(c+1)];return Ut("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${u}${c<0?"":` (access key "${n[a]})"`}.`},p)}),e.source&&Ut("div",{class:"cm-diagnosticSource"},e.source))}var Xh=class extends an{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return Ut("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},Hu=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Xk(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Ku=class r{constructor(e){this.view=e,this.items=[];let t=n=>{if(n.keyCode==27)qk(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:i}=this.items[this.selectedIndex],a=Gk(i.actions);for(let l=0;l{for(let i=0;iqk(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(En).selected;if(!e)return-1;for(let t=0;t{let u=-1,c;for(let p=s;ps&&(this.items.splice(s,u-s),n=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),i=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),s++});s({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let o=l.height/this.list.offsetHeight;a.topl.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/o)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function t(){let s=e;e=s.nextSibling,s.remove()}for(let s of this.items)if(s.dom.parentNode==this.list){for(;e!=s.dom;)t();e=s.dom.nextSibling}else this.list.insertBefore(s.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(En),s=ha(t.diagnostics,this.items[e].diagnostic);s&&this.view.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0,effects:zk.of(s)})}static open(e){return new r(e)}};function Yu(r,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(r)}')`}function Xu(r){return Yu(``,'width="6" height="3"')}var Q5=at.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:Xu("#d11")},".cm-lintRange-warning":{backgroundImage:Xu("orange")},".cm-lintRange-info":{backgroundImage:Xu("#999")},".cm-lintRange-hint":{backgroundImage:Xu("#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}}});function Qk(r){return r=="error"?4:r=="warning"?3:r=="info"?2:1}var Ju=class extends Xr{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce((t,s)=>Qk(t)U5(e,t,s)),t}};function V5(r,e){let t=s=>{let n=e.getBoundingClientRect();if(!(s.clientX>n.left-10&&s.clientXn.top-10&&s.clientYe.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,V5(r,e)}let{hoverTime:n}=r.state.facet(tc),i=setTimeout(s,n);e.onmouseout=()=>{clearTimeout(i),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(i),i=setTimeout(s,n)}}function z5(r,e){let t=Object.create(null);for(let n of e){let i=r.lineAt(n.from);(t[i.from]||(t[i.from]=[])).push(n)}let s=[];for(let n in t)s.push(new Ju(t[n]).range(+n));return Mt.of(s,!0)}var Z5=qp({class:"cm-gutter-lint",markers:r=>r.state.field(Yh),widgetMarker:(r,e,t)=>{let s=[];return r.state.field(Yh).between(t.from,t.to,(n,i,a)=>{s.push(...a.diagnostics)}),s.length?new Ju(s):null}}),Yh=Yt.define({create(){return Mt.empty},update(r,e){r=r.map(e.changes);let t=e.state.facet(tc).markerFilter;for(let s of e.effects)if(s.is(ec)){let n=s.value;t&&(n=t(n||[],e.state)),r=z5(e.state.doc,n.slice(0))}return r}}),Hh=Et.define(),Yk=Yt.define({create(){return null},update(r,e){return r&&e.docChanged&&(r=Vk(e,r)?null:Object.assign(Object.assign({},r),{pos:e.changes.mapPos(r.pos)})),e.effects.reduce((t,s)=>s.is(Hh)?s.value:t,r)},provide:r=>Ki.from(r)}),W5=at.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Yu('')},".cm-lint-marker-warning":{content:Yu('')},".cm-lint-marker-error":{content:Yu('')}}),Hk=[En,at.decorations.compute([En],r=>{let{selected:e,panel:t}=r.field(En);return!e||!t||e.from==e.to?yt.none:yt.set([$5.range(e.from,e.to)])}),QC(M5,{hideOn:Vk}),Q5],tc=ut.define({combine(r){return kr(r,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function Kk(r={}){return[tc.of(r),Yh,Z5,W5,Yk]}var ed=class r{constructor(e,t,s,n,i,a,l,o,u,c=0,p){this.p=e,this.stack=t,this.state=s,this.reducePos=n,this.pos=i,this.score=a,this.buffer=l,this.bufferBase=o,this.curContext=u,this.lookAhead=c,this.parent=p}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,s=0){let n=e.parser.context;return new r(e,[],t,s,s,0,[],0,n?new rc(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let s=e>>19,n=e&65535,{parser:i}=this.p,a=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[n])===null||t===void 0)&&t.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizeo;)this.stack.pop();this.reduceContext(n,u)}storeNode(e,t,s,n=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&a.buffer[l-4]==0&&a.buffer[l-1]>-1){if(t==s)return;if(a.buffer[l-2]>=t){a.buffer[l-2]=s;return}}}if(!i||this.pos==s)this.buffer.push(e,t,s,n);else{let a=this.buffer.length;if(a>0&&this.buffer[a-4]!=0){let l=!1;for(let o=a;o>0&&this.buffer[o-2]>s;o-=4)if(this.buffer[o-1]>=0){l=!0;break}if(l)for(;a>0&&this.buffer[a-2]>s;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,n>4&&(n-=4)}this.buffer[a]=e,this.buffer[a+1]=t,this.buffer[a+2]=s,this.buffer[a+3]=n}}shift(e,t,s,n){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=n,this.shiftContext(t,s),t<=this.p.parser.maxNode&&this.buffer.push(t,s,n,4);else{let i=e,{parser:a}=this.p;(n>this.pos||t<=a.maxNode)&&(this.pos=n,a.stateFlag(i,1)||(this.reducePos=n)),this.pushState(i,s),this.shiftContext(t,s),t<=a.maxNode&&this.buffer.push(t,s,n,4)}}apply(e,t,s,n){e&65536?this.reduce(e):this.shift(e,t,s,n)}useNode(e,t){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=e)&&(this.p.reused.push(e),s++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(s,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let s=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new r(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let s=e<=this.p.parser.maxNode;s&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,s?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new td(this);;){let s=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(s==0)return!1;if(!(s&65536))return!0;t.reduce(s)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let i=0,a;io&1&&l==a)||n.push(t[i],a)}t=n}let s=[];for(let n=0;n>19,n=t&65535,i=this.stack.length-s*3;if(i<0||e.getGoto(this.stack[i],n,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;t=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],s=(n,i)=>{if(!t.includes(n))return t.push(n),e.allActions(n,a=>{if(!(a&393216))if(a&65536){let l=(a>>19)-i;if(l>1){let o=a&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],o,!1)>=0)return l<<19|65536|o}}else{let l=s(a,i+1);if(l!=null)return l}})};return s(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},rc=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},td=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,s=e>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=n}},rd=class r{constructor(e,t,s){this.stack=e,this.pos=t,this.index=s,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new r(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}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]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new r(this.stack,this.pos,this.index)}};function jo(r,e=Uint16Array){if(typeof r!="string")return r;let t=null;for(let s=0,n=0;s=92&&a--,a>=34&&a--;let o=a-32;if(o>=46&&(o-=46,l=!0),i+=o,l)break;i*=46}t?t[n++]=i:t=new e(i)}return t}var da=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},Jk=new da,nd=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Jk,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let s=this.range,n=this.rangeIndex,i=this.pos+e;for(;is.to:i>=s.to;){if(n==this.ranges.length-1)return null;let a=this.ranges[++n];i+=a.from-s.to,s=a}return i}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,s,n;if(t>=0&&t=this.chunk2Pos&&sl.to&&(this.chunk2=this.chunk2.slice(0,l.to-s)),n=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),n}acceptToken(e,t=0){let s=t?this.resolveOffset(t,-1):this.pos;if(s==null||s=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Jk,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let s="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(s+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return s}},Ms=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:s}=t.p;sA(this.data,e,t,this.id,s.data,s.tokenPrecTable)}};Ms.prototype.contextual=Ms.prototype.fallback=Ms.prototype.extend=!1;var ma=class{constructor(e,t,s){this.precTable=t,this.elseToken=s,this.data=typeof e=="string"?jo(e):e}token(e,t){let s=e.pos,n=0;for(;;){let i=e.next<0,a=e.resolveOffset(1,1);if(sA(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(i||n++,a==null)break;e.reset(a,e.token)}n&&(e.reset(s,e.token),e.acceptToken(this.elseToken,n))}};ma.prototype.contextual=Ms.prototype.fallback=Ms.prototype.extend=!1;var js=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function sA(r,e,t,s,n,i){let a=0,l=1<0){let d=r[f];if(o.allows(d)&&(e.token.value==-1||e.token.value==d||X5(d,e.token.value,n,i))){e.acceptToken(d);break}}let c=e.next,p=0,h=r[a+2];if(e.next<0&&h>p&&r[u+h*3-3]==65535){a=r[u+h*3-1];continue e}for(;p>1,d=u+f+(f<<1),m=r[d],g=r[d+1]||65536;if(c=g)p=f+1;else{a=r[d+2],e.advance();continue e}}break}}function eA(r,e,t){for(let s=e,n;(n=r[s])!=65535;s++)if(n==t)return s-e;return-1}function X5(r,e,t,s){let n=eA(t,s,e);return n<0||eA(t,s,r)e)&&!s.type.isError)return t<0?Math.max(0,Math.min(s.to-1,e-25)):Math.min(r.length,Math.max(s.from+1,e+25));if(t<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return t<0?0:r.length}}var sd=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?tA(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?tA(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=a,null;if(i instanceof or){if(a==e){if(a=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},id=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(s=>new da)}getActions(e){let t=0,s=null,{parser:n}=e.p,{tokenizers:i}=n,a=n.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,o=0;for(let u=0;up.end+25&&(o=Math.max(p.lookAhead,o)),p.value!=0)){let h=t;if(p.extended>-1&&(t=this.addActions(e,p.extended,p.end,t)),t=this.addActions(e,p.value,p.end,t),!c.extend&&(s=p,t>h))break}}for(;this.actions.length>t;)this.actions.pop();return o&&e.setLookAhead(o),!s&&e.pos==this.stream.end&&(s=new da,s.value=e.p.parser.eofTerm,s.start=s.end=e.pos,t=this.addActions(e,s.value,s.end,t)),this.mainToken=s,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new da,{pos:s,p:n}=e;return t.start=s,t.end=Math.min(s+1,n.stream.end),t.value=s==n.stream.end?n.parser.eofTerm:0,t}updateCachedToken(e,t,s){let n=this.stream.clipPos(s.pos);if(t.token(this.stream.reset(n,e),s),e.value>-1){let{parser:i}=s.p;for(let a=0;a=0&&s.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(n+1)}putAction(e,t,s,n){for(let i=0;ie.bufferLength*4?new sd(s,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,s=this.stacks=[],n,i;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;at)s.push(l);else{if(this.advanceStack(l,s,e))continue;{n||(n=[],i=[]),n.push(l);let o=this.tokens.getMainToken(l);i.push(o.value,o.end)}}break}}if(!s.length){let a=n&&Y5(n);if(a)return Kr&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw Kr&&n&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&n){let a=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,i,s);if(a)return Kr&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(s.length>a)for(s.sort((l,o)=>o.score-l.score);s.length>a;)s.pop();s.some(l=>l.reducePos>t)&&this.recovering--}else if(s.length>1){e:for(let a=0;a500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)s.splice(o--,1);else{s.splice(a--,1);continue e}}}s.length>12&&s.splice(12,s.length-12)}this.minStackPos=s[0].pos;for(let a=1;a ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let p=this.fragments.nodeAt(n);p;){let h=this.parser.nodeSet.types[p.type.id]==p.type?i.getGoto(e.state,p.type.id):-1;if(h>-1&&p.length&&(!u||(p.prop(kt.contextHash)||0)==c))return e.useNode(p,h),Kr&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(p.type.id)})`),!0;if(!(p instanceof or)||p.children.length==0||p.positions[0]>0)break;let f=p.children[0];if(f instanceof or&&p.positions[0]==0)p=f;else break}}let l=i.stateSlot(e.state,4);if(l>0)return e.reduce(l),Kr&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let o=this.tokens.getActions(e);for(let u=0;un?t.push(d):s.push(d)}return!1}advanceFully(e,t){let s=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>s)return rA(e,t),!0}}runRecovery(e,t,s){let n=null,i=!1;for(let a=0;a ":"";if(l.deadEnd&&(i||(i=!0,l.restart(),Kr&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,s))))continue;let p=l.split(),h=c;for(let f=0;p.forceReduce()&&f<10&&(Kr&&console.log(h+this.stackID(p)+" (via force-reduce)"),!this.advanceFully(p,s));f++)Kr&&(h=this.stackID(p)+" -> ");for(let f of l.recoverByInsert(o))Kr&&console.log(c+this.stackID(f)+" (via recover-insert)"),this.advanceFully(f,s);this.stream.end>l.pos?(u==l.pos&&(u++,o=0),l.recoverByDelete(o,u),Kr&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(o)})`),rA(l,s)):(!n||n.scorer,nc=class{constructor(e){this.start=e.start,this.shift=e.shift||Jh,this.reduce=e.reduce||Jh,this.reuse=e.reuse||Jh,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},sc=class r extends ta{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;le.topRules[l][1]),n=[];for(let l=0;l=0)i(c,o,l[u++]);else{let p=l[u+-c];for(let h=-c;h>0;h--)i(l[u++],o,p);u++}}}this.nodeSet=new Co(t.map((l,o)=>Ar.define({name:o>=this.minRepeatTerm?void 0:l,id:o,props:n[o],top:s.indexOf(o)>-1,error:o==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(o)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let a=jo(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Ms(a,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,s){let n=new ad(this,e,t,s);for(let i of this.wrappers)n=i(n,e,t,s);return n}getGoto(e,t,s=!1){let n=this.goto;if(t>=n[0])return-1;for(let i=n[t+1];;){let a=n[i++],l=a&1,o=n[i++];if(l&&s)return o;for(let u=i+(a>>1);i0}validAction(e,t){return!!this.allActions(e,s=>s==t?!0:null)}allActions(e,t){let s=this.stateSlot(e,4),n=s?t(s):void 0;for(let i=this.stateSlot(e,1);n==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=cs(this.data,i+2);else break;n=t(cs(this.data,i+1))}return n}nextStates(e){let t=[];for(let s=this.stateSlot(e,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=cs(this.data,s+2);else break;if(!(this.data[s+2]&1)){let n=this.data[s+1];t.some((i,a)=>a&1&&i==n)||t.push(this.data[s],n)}}return t}configure(e){let t=Object.assign(Object.create(r.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let s=this.topRules[e.top];if(!s)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=s}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(s=>{let n=e.tokenizers.find(i=>i.from==s);return n?n.to:s})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((s,n)=>{let i=e.specializers.find(l=>l.from==s.external);if(!i)return s;let a=Object.assign(Object.assign({},s),{external:i.to});return t.specializers[n]=nA(a),a})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),s=t.map(()=>!1);if(e)for(let i of e.split(" ")){let a=t.indexOf(i);a>=0&&(s[a]=!0)}let n=null;for(let i=0;is)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scorer.external(t,s)<<1|e}return r.get}var H5=312,K5=313,iA=1,J5=2,e6=3,t6=4,r6=314,n6=316,s6=317,i6=5,a6=6,o6=0,ud=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],aA=125,l6=59,cd=47,u6=42,c6=43,f6=45,p6=60,h6=44,d6=63,m6=46,g6=91,y6=new nc({start:!1,shift(r,e){return e==i6||e==a6||e==n6?r:e==s6},strict:!1}),b6=new js((r,e)=>{let{next:t}=r;(t==aA||t==-1||e.context)&&r.acceptToken(r6)},{contextual:!0,fallback:!0}),v6=new js((r,e)=>{let{next:t}=r,s;ud.indexOf(t)>-1||t==cd&&((s=r.peek(1))==cd||s==u6)||t!=aA&&t!=l6&&t!=-1&&!e.context&&r.acceptToken(H5)},{contextual:!0}),x6=new js((r,e)=>{r.next==g6&&!e.context&&r.acceptToken(K5)},{contextual:!0}),O6=new js((r,e)=>{let{next:t}=r;if(t==c6||t==f6){if(r.advance(),t==r.next){r.advance();let s=!e.context&&e.canShift(iA);r.acceptToken(s?iA:J5)}}else t==d6&&r.peek(1)==m6&&(r.advance(),r.advance(),(r.next<48||r.next>57)&&r.acceptToken(e6))},{contextual:!0});function ld(r,e){return r>=65&&r<=90||r>=97&&r<=122||r==95||r>=192||!e&&r>=48&&r<=57}var S6=new js((r,e)=>{if(r.next!=p6||!e.dialectEnabled(o6)||(r.advance(),r.next==cd))return;let t=0;for(;ud.indexOf(r.next)>-1;)r.advance(),t++;if(ld(r.next,!0)){for(r.advance(),t++;ld(r.next,!1);)r.advance(),t++;for(;ud.indexOf(r.next)>-1;)r.advance(),t++;if(r.next==h6)return;for(let s=0;;s++){if(s==7){if(!ld(r.next,!0))return;break}if(r.next!="extends".charCodeAt(s))break;r.advance(),t++}}r.acceptToken(t6,-t)}),E6=du({"get set async static":we.modifier,"for while do if else switch try catch finally return throw break continue default case":we.controlKeyword,"in of await yield void typeof delete instanceof":we.operatorKeyword,"let var const using function class extends":we.definitionKeyword,"import export from":we.moduleKeyword,"with debugger as new":we.keyword,TemplateString:we.special(we.string),super:we.atom,BooleanLiteral:we.bool,this:we.self,null:we.null,Star:we.modifier,VariableName:we.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":we.function(we.variableName),VariableDefinition:we.definition(we.variableName),Label:we.labelName,PropertyName:we.propertyName,PrivatePropertyName:we.special(we.propertyName),"CallExpression/MemberExpression/PropertyName":we.function(we.propertyName),"FunctionDeclaration/VariableDefinition":we.function(we.definition(we.variableName)),"ClassDeclaration/VariableDefinition":we.definition(we.className),PropertyDefinition:we.definition(we.propertyName),PrivatePropertyDefinition:we.definition(we.special(we.propertyName)),UpdateOp:we.updateOperator,"LineComment Hashbang":we.lineComment,BlockComment:we.blockComment,Number:we.number,String:we.string,Escape:we.escape,ArithOp:we.arithmeticOperator,LogicOp:we.logicOperator,BitOp:we.bitwiseOperator,CompareOp:we.compareOperator,RegExp:we.regexp,Equals:we.definitionOperator,Arrow:we.function(we.punctuation),": Spread":we.punctuation,"( )":we.paren,"[ ]":we.squareBracket,"{ }":we.brace,"InterpolationStart InterpolationEnd":we.special(we.brace),".":we.derefOperator,", ;":we.separator,"@":we.meta,TypeName:we.typeName,TypeDefinition:we.definition(we.typeName),"type enum interface implements namespace module declare":we.definitionKeyword,"abstract global Privacy readonly override":we.modifier,"is keyof unique infer":we.operatorKeyword,JSXAttributeValue:we.attributeValue,JSXText:we.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":we.angleBracket,"JSXIdentifier JSXNameSpacedName":we.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":we.attributeName,"JSXBuiltin/JSXIdentifier":we.standard(we.tagName)}),C6={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,extends:54,this:58,true:66,false:66,null:78,void:82,typeof:86,super:102,new:136,delete:148,yield:157,await:161,class:166,public:229,private:229,protected:229,readonly:231,instanceof:250,satisfies:253,in:254,const:256,import:290,keyof:345,unique:349,infer:355,is:391,abstract:411,implements:413,type:415,let:418,var:420,using:423,interface:429,enum:433,namespace:439,module:441,declare:445,global:449,for:468,of:477,while:480,with:484,do:488,if:492,else:494,switch:498,case:504,try:510,catch:514,finally:518,return:522,throw:526,break:530,continue:534,debugger:538},w6={__proto__:null,async:123,get:125,set:127,declare:189,public:191,private:191,protected:191,static:193,abstract:195,override:197,readonly:203,accessor:205,new:395},k6={__proto__:null,"<":187},oA=sc.deserialize({version:14,states:"$CdQ%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#D^O.QQlO'#DdO.bQlO'#DoO%[QlO'#DwO0fQlO'#EPOOQ!0Lf'#EX'#EXO1PQ`O'#EUOOQO'#Em'#EmOOQO'#Ih'#IhO1XQ`O'#GpO1dQ`O'#ElO1iQ`O'#ElO3hQ!0MxO'#JnO6[Q!0MxO'#JoO6uQ`O'#F[O6zQ,UO'#FsOOQ!0Lf'#Fe'#FeO7VO7dO'#FeO7eQMhO'#FzO9RQ`O'#FyOOQ!0Lf'#Jo'#JoOOQ!0Lb'#Jn'#JnO9WQ`O'#GtOOQ['#K['#K[O9cQ`O'#IUO9hQ!0LrO'#IVOOQ['#J['#J[OOQ['#IZ'#IZQ`QlOOQ`QlOOO9pQ!L^O'#DsO9wQlO'#D{O:OQlO'#D}O9^Q`O'#GpO:VQMhO'#CoO:eQ`O'#EkO:pQ`O'#EvO:uQMhO'#FdO;dQ`O'#GpOOQO'#K]'#K]O;iQ`O'#K]O;wQ`O'#GxO;wQ`O'#GyO;wQ`O'#G{O9^Q`O'#HOOVQ`O'#CeO>gQ`O'#H_O>oQ`O'#HeO>oQ`O'#HgO`QlO'#HiO>oQ`O'#HkO>oQ`O'#HnO>tQ`O'#HtO>yQ!0LsO'#HzO%[QlO'#H|O?UQ!0LsO'#IOO?aQ!0LsO'#IQO9hQ!0LrO'#ISO?lQ!0MxO'#CiO@nQpO'#DiQOQ`OOO%[QlO'#D}OAUQ`O'#EQO:VQMhO'#EkOAaQ`O'#EkOAlQ!bO'#FdOOQ['#Cg'#CgOOQ!0Lb'#Dn'#DnOOQ!0Lb'#Jr'#JrO%[QlO'#JrOOQO'#Ju'#JuOOQO'#Id'#IdOBlQpO'#EdOOQ!0Lb'#Ec'#EcOOQ!0Lb'#Jy'#JyOChQ!0MSO'#EdOCrQpO'#ETOOQO'#Jt'#JtODWQpO'#JuOEeQpO'#ETOCrQpO'#EdPErO&2DjO'#CbPOOO)CDy)CDyOOOO'#I['#I[OE}O#tO,59UOOQ!0Lh,59U,59UOOOO'#I]'#I]OF]O&jO,59UOFkQ!L^O'#D`OOOO'#I_'#I_OFrO#@ItO,59xOOQ!0Lf,59x,59xOGQQlO'#I`OGeQ`O'#JpOIdQ!fO'#JpO+}QlO'#JpOIkQ`O,5:OOJRQ`O'#EmOJ`Q`O'#KPOJkQ`O'#KOOJkQ`O'#KOOJsQ`O,5;ZOJxQ`O'#J}OOQ!0Ln,5:Z,5:ZOKPQlO,5:ZOL}Q!0MxO,5:cOMnQ`O,5:kONXQ!0LrO'#J|ON`Q`O'#J{O9WQ`O'#J{ONtQ`O'#J{ON|Q`O,5;YO! RQ`O'#J{O!#WQ!fO'#JoOOQ!0Lh'#Ci'#CiO%[QlO'#EPO!#vQ!fO,5:pOOQS'#Jv'#JvOOQO-EpOOQ['#Jd'#JdOOQ[,5>q,5>qOOQ[-E[Q!0MxO,5:gO%[QlO,5:gO!@rQ!0MxO,5:iOOQO,5@w,5@wO!AcQMhO,5=[O!AqQ!0LrO'#JeO9RQ`O'#JeO!BSQ!0LrO,59ZO!B_QpO,59ZO!BgQMhO,59ZO:VQMhO,59ZO!BrQ`O,5;WO!BzQ`O'#H^O!C`Q`O'#KaO%[QlO,5;|O!9fQpO,5tQ`O'#HTO9^Q`O'#HVO!DwQ`O'#HVO:VQMhO'#HXO!D|Q`O'#HXOOQ[,5=m,5=mO!ERQ`O'#HYO!EdQ`O'#CoO!EiQ`O,59PO!EsQ`O,59PO!GxQlO,59POOQ[,59P,59PO!HYQ!0LrO,59PO%[QlO,59PO!JeQlO'#HaOOQ['#Hb'#HbOOQ['#Hc'#HcO`QlO,5=yO!J{Q`O,5=yO`QlO,5>PO`QlO,5>RO!KQQ`O,5>TO`QlO,5>VO!KVQ`O,5>YO!K[QlO,5>`OOQ[,5>f,5>fO%[QlO,5>fO9hQ!0LrO,5>hOOQ[,5>j,5>jO# fQ`O,5>jOOQ[,5>l,5>lO# fQ`O,5>lOOQ[,5>n,5>nO#!SQpO'#D[O%[QlO'#JrO#!uQpO'#JrO##PQpO'#DjO##bQpO'#DjO#%sQlO'#DjO#%zQ`O'#JqO#&SQ`O,5:TO#&XQ`O'#EqO#&gQ`O'#KQO#&oQ`O,5;[O#&tQpO'#DjO#'RQpO'#ESOOQ!0Lf,5:l,5:lO%[QlO,5:lO#'YQ`O,5:lO>tQ`O,5;VO!B_QpO,5;VO!BgQMhO,5;VO:VQMhO,5;VO#'bQ`O,5@^O#'gQ07dO,5:pOOQO-EzO+}QlO,5>zOOQO,5?Q,5?QO#*oQlO'#I`OOQO-E<^-E<^O#*|Q`O,5@[O#+UQ!fO,5@[O#+]Q`O,5@jOOQ!0Lf1G/j1G/jO%[QlO,5@kO#+eQ`O'#IfOOQO-EoQ`O1G3oO$4WQlO1G3qO$8[QlO'#HpOOQ[1G3t1G3tO$8iQ`O'#HvO>tQ`O'#HxOOQ[1G3z1G3zO$8qQlO1G3zO9hQ!0LrO1G4QOOQ[1G4S1G4SOOQ!0Lb'#G]'#G]O9hQ!0LrO1G4UO9hQ!0LrO1G4WO$tQ`O,5:UO!(vQlO,5:UO!B_QpO,5:UO$<}Q?MtO,5:UOOQO,5;],5;]O$=XQpO'#IaO$=oQ`O,5@]OOQ!0Lf1G/o1G/oO$=wQpO'#IgO$>RQ`O,5@lOOQ!0Lb1G0v1G0vO##bQpO,5:UOOQO'#Ic'#IcO$>ZQpO,5:nOOQ!0Ln,5:n,5:nO#']Q`O1G0WOOQ!0Lf1G0W1G0WO%[QlO1G0WOOQ!0Lf1G0q1G0qO>tQ`O1G0qO!B_QpO1G0qO!BgQMhO1G0qOOQ!0Lb1G5x1G5xO!BSQ!0LrO1G0ZOOQO1G0j1G0jO%[QlO1G0jO$>bQ!0LrO1G0jO$>mQ!0LrO1G0jO!B_QpO1G0ZOCrQpO1G0ZO$>{Q!0LrO1G0jOOQO1G0Z1G0ZO$?aQ!0MxO1G0jPOOO-EzO$?}Q`O1G5vO$@VQ`O1G6UO$@_Q!fO1G6VO9WQ`O,5?QO$@iQ!0MxO1G6SO%[QlO1G6SO$@yQ!0LrO1G6SO$A[Q`O1G6RO$A[Q`O1G6RO9WQ`O1G6RO$AdQ`O,5?TO9WQ`O,5?TOOQO,5?T,5?TO$AxQ`O,5?TO$)QQ`O,5?TOOQO-E[OOQ[,5>[,5>[O%[QlO'#HqO%<{Q`O'#HsOOQ[,5>b,5>bO9WQ`O,5>bOOQ[,5>d,5>dOOQ[7+)f7+)fOOQ[7+)l7+)lOOQ[7+)p7+)pOOQ[7+)r7+)rO%=QQpO1G5xO%=lQ?MtO1G0wO%=vQ`O1G0wOOQO1G/p1G/pO%>RQ?MtO1G/pO>tQ`O1G/pO!(vQlO'#DjOOQO,5>{,5>{OOQO-E<_-E<_OOQO,5?R,5?ROOQO-EtQ`O7+&]O!B_QpO7+&]OOQO7+%u7+%uO$?aQ!0MxO7+&UOOQO7+&U7+&UO%[QlO7+&UO%>]Q!0LrO7+&UO!BSQ!0LrO7+%uO!B_QpO7+%uO%>hQ!0LrO7+&UO%>vQ!0MxO7++nO%[QlO7++nO%?WQ`O7++mO%?WQ`O7++mOOQO1G4o1G4oO9WQ`O1G4oO%?`Q`O1G4oOOQS7+%z7+%zO#']Q`O<|O%[QlO,5>|OOQO-E<`-E<`O%KlQ`O1G5yOOQ!0Lf<]OOQ[,5>_,5>_O&;hQ`O1G3|O9WQ`O7+&cO!(vQlO7+&cOOQO7+%[7+%[O&;mQ?MtO1G6VO>tQ`O7+%[OOQ!0Lf<tQ`O<tQ`O7+)hO'+dQ`O<{AN>{O%[QlOAN?[OOQO<{Oh%VOk+bO![']O%f+aO~O!d+dOa(XX![(XX'v(XX!Y(XX~Oa%lO![XO'v%lO~Oh%VO!i%cO~Oh%VO!i%cO(P%eO~O!d#vO#h(uO~Ob+oO%g+pO(P+lO(RTO(UUO!Z)UP~O!Y+qO`)TX~O[+uO~O`+vO~O![%}O(P%eO(Q!lO`)TP~Oh%VO#]+{O~Oh%VOk,OO![$|O~O![,QO~O},SO![XO~O%k%tO~O!u,XO~Oe,^O~Ob,_O(P#nO(RTO(UUO!Z)SP~Oe%{O~O%g!QO(P&WO~P=RO[,dO`,cO~OPYOQYOSfOdzOeyOmkOoYOpkOqkOwkOyYO{YO!PWO!TkO!UkO!fuO!iZO!lYO!mYO!nYO!pvO!uxO!y]O%e}O(RTO(UUO(]VO(k[O(ziO~O![!eO!r!gO$V!kO(P!dO~P!E{O`,cOa%lO'v%lO~OPYOQYOSfOd!jOe!iOmkOoYOpkOqkOwkOyYO{YO!PWO!TkO!UkO![!eO!fuO!iZO!lYO!mYO!nYO!pvO!u!hO$V!kO(P!dO(RTO(UUO(]VO(k[O(ziO~Oa,iO!rwO#t!OO%i!OO%j!OO%k!OO~P!HeO!i&lO~O&Y,oO~O![,qO~O&k,sO&m,tOP&haQ&haS&haY&haa&had&hae&ham&hao&hap&haq&haw&hay&ha{&ha!P&ha!T&ha!U&ha![&ha!f&ha!i&ha!l&ha!m&ha!n&ha!p&ha!r&ha!u&ha!y&ha#t&ha$V&ha%e&ha%g&ha%i&ha%j&ha%k&ha%n&ha%p&ha%s&ha%t&ha%v&ha&S&ha&Y&ha&[&ha&^&ha&`&ha&c&ha&i&ha&o&ha&q&ha&s&ha&u&ha&w&ha's&ha(P&ha(R&ha(U&ha(]&ha(k&ha(z&ha!Z&ha&a&hab&ha&f&ha~O(P,yO~Oh!bX!Y!OX!Z!OX!d!OX!d!bX!i!bX#]!OX~O!Y!bX!Z!bX~P# kO!d-OO#],}Oh(fX!Y#eX!Z#eX!d(fX!i(fX~O!Y(fX!Z(fX~P#!^Oh%VO!d-QO!i%cO!Y!^X!Z!^X~Op!nO!P!oO(RTO(UUO(a!mO~OP;jOQ;jOSfOd=fOe!iOmkOo;jOpkOqkOwkOy;jO{;jO!PWO!TkO!UkO![!eO!f;mO!iZO!l;jO!m;jO!n;jO!p;nO!r;qO!u!hO$V!kO(RTO(UUO(]VO(k[O(z=dO~O(P{Og'XX!Y'XX~P!+oO!Y.xOg(la~OSfO![3vO$c3wO~O!Z3{O~Os3|O~P#.uOa$lq!Y$lq'v$lq's$lq!V$lq!h$lqs$lq![$lq%f$lq!d$lq~P!9}O!V4OO~P!&fO!P4PO~O}){O'u)|O(v%POk'ea(u'ea!Y'ea#]'ea~Og'ea#}'ea~P%+ZO}){O'u)|Ok'ga(u'ga(v'ga!Y'ga#]'ga~Og'ga#}'ga~P%+|O(n$YO~P#.uO!VfX!V$xX!YfX!Y$xX!d%PX#]fX~P!/nO(PU#>[#>|#?`#?f#?l#?z#@a#BQ#B`#Bg#C}#D]#Ey#FX#F_#Fe#Fk#Fu#F{#GR#G]#Go#GuPPPPPPPPPPP#G{PPPPPPP#Hp#Kw#Ma#Mh#MpPPP$%OP$%X$(Q$.k$.n$.q$/p$/s$/z$0SP$0Y$0]P$0y$0}$1u$3T$3Y$3pPP$3u$3{$4PP$4S$4W$4[$5W$5o$6W$6[$6_$6b$6h$6k$6o$6sR!|RoqOXst!Z#d%k&o&q&r&t,l,q1}2QY!vQ']-^1b5iQ%rvQ%zyQ&R|Q&g!VS'T!e-UQ'c!iS'i!r!yU*g$|*W*kQ+j%{Q+w&TQ,]&aQ-['[Q-f'dQ-n'jQ0S*mQ1l,^R < TypeParamList TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in const CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:377,context:y6,nodeProps:[["isolate",-8,5,6,14,34,36,48,50,52,""],["group",-26,9,17,19,65,204,208,212,213,215,218,221,231,233,239,241,243,245,248,254,260,262,264,266,268,270,271,"Statement",-34,13,14,29,32,33,39,48,51,52,54,59,67,69,73,77,79,81,82,107,108,117,118,135,138,140,141,142,143,144,146,147,166,167,169,"Expression",-23,28,30,34,38,40,42,171,173,175,176,178,179,180,182,183,184,186,187,188,198,200,202,203,"Type",-3,85,100,106,"ClassItem"],["openedBy",23,"<",35,"InterpolationStart",53,"[",57,"{",70,"(",159,"JSXStartCloseTag"],["closedBy",24,">",37,"InterpolationEnd",47,"]",58,"}",71,")",164,"JSXEndTag"]],propSources:[E6],skippedNodes:[0,5,6,274],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$h&j(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$h&j(V!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(V!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$h&j(SpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(SpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Sp(V!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$h&j(Sp(V!b'x0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(T#S$h&j'y0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$h&j(Sp(V!b'y0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$h&j!m),Q(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#u(Ch$h&j(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#u(Ch$h&j(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(R':f$h&j(V!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$h&j(V!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$h&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$c`$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$c``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$c`$h&j(V!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(V!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$c`(V!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$h&j(Sp(V!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$h&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(V!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$h&j(SpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(SpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Sp(V!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$h&j!U7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!U7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!U7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$h&j(V!b!U7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(V!b!U7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(V!b!U7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(V!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$h&j(V!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$h&j(Sp(V!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$h&j(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$h&j(Sp(V!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$h&j(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$h&j(Sp(V!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$h&j(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$h&j(Sp(V!bp'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!d$b$h&j#})Lv(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$h&j(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#O-v$?V_!Z(CdsBr$h&j(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!n7`$h&j(Sp(V!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$h&j(Sp(V!b'x0/l$[#t(P,2j(a$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$h&j(Sp(V!b'y0/l$[#t(P,2j(a$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[v6,x6,O6,S6,2,3,4,5,6,7,8,9,10,11,12,13,14,b6,new ma("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOu~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!R~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(_~~",141,336),new ma("j~RQYZXz{^~^O'|~~aP!P!Qd~iO'}~~",25,319)],topRules:{Script:[0,7],SingleExpression:[1,272],SingleClassItem:[2,273]},dialects:{jsx:0,ts:14980},dynamicPrecedences:{77:1,79:1,91:1,167:1,196:1},specialized:[{term:323,get:r=>C6[r]||-1},{term:339,get:r=>w6[r]||-1},{term:92,get:r=>k6[r]||-1}],tokenPrec:15004});var pA=[Rr("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Rr("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Rr("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Rr("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Rr("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Rr(`try { \${} } catch (\${error}) { @@ -184,7 +184,7 @@ function draw() { cls(bg) // clear the screen circfill(posx, posy, radius, color) // draw a circle } -`;function YO(r){let e=r.matchBefore(/\w*/);return e.from==e.to&&!r.explicit?null:{from:e.from,options:[{label:"CANVAS",type:"constant",info:"game canvas HTML element"},{label:"WIDTH",type:"variable",info:"width of the game screen"},{label:"HEIGHT",type:"variable",info:"height of the game screen"},{label:"ELAPSED",type:"variable",info:"seconds since the game started"},{label:"FPS",type:"variable",info:"frames per second"},{label:"CENTERX",type:"variable",info:"middle X of the game screen"},{label:"CENTERY",type:"variable",info:"middle Y of the game screen"},{label:"MOUSEX",type:"variable"},{label:"MOUSEY",type:"variable"},{label:"DEFAULT_SFX",type:"variable"},{label:"PI",type:"constant"},{label:"TWO_PI",type:"constant"},{label:"HALF_PI",type:"constant"},{label:"litecanvas",type:"function",apply:"litecanvas({})",detail:"(settings?: object)",info:"initialize a litecanvas instance"},{label:"cls",type:"function",apply:"cls(",detail:"(color?: number)",info:"clear the game screen"},{label:"rect",type:"function",apply:"rect(",detail:"(x, y, width, height, color=0, radii?)"},{label:"rectfill",type:"function",apply:"rectfill(",detail:"(x, y, width, height, color=0, radii?)"},{label:"circ",type:"function",apply:"circ(",detail:"(x, y, radius, color=0)"},{label:"circfill",type:"function",apply:"circfill(",detail:"(x, y, radius, color=0)"},{label:"line",type:"function",apply:"line(",detail:"(x1, y1, x2, y2, color=0)"},{label:"linewidth",type:"function",apply:"linewidth(",detail:"(value)"},{label:"linedash",type:"function",apply:"linedash(",detail:"(pattern, ofsset)"},{label:"text",type:"function",apply:"text(",detail:"(x, y, text, color=3)"},{label:"textfont",type:"function",apply:"textfont(",detail:"(fontName)",info:"default font: 'sans-serif'"},{label:"textsize",type:"function",apply:"textsize(",detail:"(size)",info:"default font size: 32"},{label:"textalign",type:"function",apply:"textalign(",detail:"(align, baseline)"},{label:"textstyle",type:"function",apply:"textstyle(",detail:"(style)"},{label:"textmetrics",type:"function",apply:"textmetrics(",detail:"(text, [size])"},{label:"image",type:"function",apply:"image(",detail:"(x, y, image)"},{label:"paint",type:"function",apply:"paint(",detail:"(width, height, callback|array, options)",info:"Creates a offscreen canvas to draw on it"},{label:"transform",type:"function",apply:"transform(",detail:"(a, b, c, d, e, f, reset=true)"},{label:"translate",type:"function",apply:"translate(",detail:"(x, y)"},{label:"scale",type:"function",apply:"scale(",detail:"(x, y)"},{label:"rotate",type:"function",apply:"rotate(",detail:"(radians)"},{label:"alpha",type:"function",apply:"alpha(",detail:"(value)"},{label:"fill",type:"function",apply:"fill(",detail:"(color, path?)"},{label:"stroke",type:"function",apply:"stroke(",detail:"(color, path?)"},{label:"path",type:"function",apply:"path()",detail:"(arg?: string|Path2D)"},{label:"push",type:"function",apply:"push()",detail:"",info:"save the rendering context"},{label:"pop",type:"function",apply:"pop()",detail:"",info:"restore the rendering context"},{label:"ctx",type:"function",apply:"ctx(value?)",info:"set or get the canvas context"},{label:"cliprect",type:"function",apply:"cliprect(",detail:"(x, y, width, height)",info:"create a rectagular clipping region"},{label:"clipcirc",type:"function",apply:"clipcirc(",detail:"(x, y, radius)",info:"create a circular clipping region"},{label:"sfx",type:"function",apply:"sfx()",detail:"(zzfxParams?, pitchSlide?, volumeFactor?)",info:"play a ZzFX sound"},{label:"volume",type:"function",apply:"volume(",detail:"(value)",info:"set the ZzFX global volume"},{label:"iskeydown",type:"function",apply:"iskeydown(",detail:"(key)"},{label:"seed",type:"function",apply:"seed(",detail:"(value?)",info:"initialize the RNG with a seed value"},{label:"rand",type:"function",apply:"rand()",detail:"(min=0.0, max=1.0)",info:"get a pseudo-random float between min (inclusive) and max (exclusive)"},{label:"randi",type:"function",apply:"randi()",detail:"(min=0, max=1)",info:"get a pseudo-random integer between min (inclusive) and max (inclusive)"},{label:"map",type:"function",apply:"map(",detail:"(val, min1, max1, min2, max2, withinBounds=false)"},{label:"norm",type:"function",apply:"norm(",detail:"(val, min, max)"},{label:"diff",type:"function",apply:"diff(",detail:"(a, b)"},{label:"clamp",type:"function",apply:"clamp(",detail:"(value, min, max)"},{label:"wrap",type:"function",apply:"wrap(",detail:"(value, min, max)"},{label:"lerp",type:"function",apply:"lerp(",detail:"(start, end, t)",info:"linear interpolation from `start` to `end` over `t`%."},{label:"deg2rad",type:"function",apply:"deg2rad(",detail:"(degrees)"},{label:"rad2deg",type:"function",apply:"rad2deg(",detail:"(radians)"},{label:"sin",type:"function",apply:"sin(",detail:"(radians)"},{label:"cos",type:"function",apply:"cos(",detail:"(radians)"},{label:"tan",type:"function",apply:"tan(",detail:"(radians)"},{label:"abs",type:"function",apply:"abs(",detail:"(value)"},{label:"ceil",type:"function",apply:"ceil(",detail:"(value)"},{label:"round",type:"function",apply:"round(",detail:"(value)"},{label:"floor",type:"function",apply:"floor(",detail:"(value)"},{label:"trunc",type:"function",apply:"trunc(",detail:"(value)"},{label:"min",type:"function",apply:"min(",detail:"(...values)"},{label:"max",type:"function",apply:"max(",detail:"(...values)"},{label:"pow",type:"function",apply:"pow(",detail:"(a, b)"},{label:"sqrt",type:"function",apply:"sqrt(",detail:"(value)"},{label:"sign",type:"function",apply:"sign(",detail:"(value)"},{label:"atan2",type:"function",apply:"atan2(",detail:"(y, x)"},{label:"hypot",type:"function",apply:"hypot(",detail:"(...values)"},{label:"exp",type:"function",apply:"exp(",detail:"(x)"},{label:"colrect",type:"function",apply:"colrect(",detail:"(x1, y1, w1, h1, x2, y2, w2, h2)",info:"Check collision between 2 rectangles"},{label:"colcirc",type:"function",apply:"colcirc(",detail:"(x1, y1, r1, x2, y2, r2)",info:"Check collision between 2 circles"},{label:"timescale",type:"function",apply:"timescale(",detail:"(value)",info:"Sets the scale of the game's delta time (dt)"},{label:"use",type:"function",apply:"use(",detail:"(callback)",info:"Loads a plugin to extend the litecanvas engine"},{label:"setvar",type:"function",apply:"setvar(",detail:"(name, value)"},{label:"getcolor",type:"function",apply:"getcolor(",detail:"(index)"},{label:"listen",type:"function",apply:"listen(",detail:"(event, callback)"},{label:"emit",type:"function",apply:"emit(",detail:"(event, a1, a2, a3, a4)"},{label:"resize",type:"function",apply:"resize(",detail:"(width, height)",info:"resizes the game canvas"},{label:"loadScript",type:"function",apply:"loadScript(",detail:"(url, callback)",info:"Load a JavaScript file"},{label:"loadImage",type:"function",apply:"loadImage(",detail:"(url, callback)",info:"Load a image"},{label:"loadFont",type:"function",apply:"loadFont(",detail:"(name, url, callback)",info:"Load a font"},{label:"LOADING",type:"variable",info:"return the amount of assets that are loading"}]}}function HO(r){let e=visualViewport;if(!e)return;let t=u(),s=document.querySelector(".editor .code"),n=0,i=[{name:"indent",label:'',callback:Pu},{name:"toggle comment",label:"//",callback:gh},{name:"undo",label:'',callback:Cu},{name:"redo",label:'',callback:Io},{name:"select all",label:"[A]",callback:vh},{name:"search (and replace)",label:'',callback:Qu,focus:!1}],a=document.createElement("div");a.classList.add("mobile-buttons"),a.style.display="none";for(let h of i){let f=document.createElement("button"),d=h.focus==null?!0:h.focus;f.innerHTML=h.label,f.setAttribute("title",h.name),f.setAttribute("aria-label",h.name),f.setAttribute("data-focus",d?"true":"false"),f.addEventListener("click",m=>{m.preventDefault(),h.callback(r),d&&r.contentDOM.focus()}),a.appendChild(f)}s.appendChild(a),requestAnimationFrame(o);function l(){n&&cancelAnimationFrame(n),n=requestAnimationFrame(o)}e.addEventListener("resize",l),e.addEventListener("scroll",l);function o(){n=!1;let h=a.getBoundingClientRect(),f=e.offsetLeft,d=e.height+e.offsetTop-h.height;a.style.transform=`translate(${f}px, ${d}px)`,Math.abs(e.height-t.height)>100?p():c()}r.contentDOM.addEventListener("click",()=>{p()}),r.contentDOM.addEventListener("focus",()=>{p()});function u(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function c(){a.style.display="none"}function p(){a.style.display=""}}var ka={autosave:!0,autosaveInterval:5e3,codeChanged:!1},Bc=new URL(location.href);Bc.searchParams.get("reset")!==null&&(DX(),window.location=location.origin);var SX=!["0","false"].includes(Bc.searchParams.get("autoplay")),tl=Bc.searchParams.get("c");tl!==null&&(tl=PX(tl),tl&&(ka.autosave=!1,An("#changing-shared-code").style.display=""));document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"&&ka.autosave&&IL()});window.addEventListener("beforeunload",r=>{ka.autosave||(r.preventDefault(),r.returnValue=!0)});var TL=[],DL=An(".code"),KO=An(".game"),Aa=An("#play"),JO=An("#stop"),EX=An("#share"),CX=An("#copy"),Us=An("#frame"),Kn=An("#frame-overlay"),Lc=innerWidth<1024,wX=navigator.userAgent.match(/android|iphone|ipad/i)!==null;Aa.addEventListener("click",()=>{Vs(DL),Hn(KO),Vs(Aa),Hn(JO),Nc(),Lc?(Us.focus(),Vs(Kn)):Hn(Kn)});JO.addEventListener("click",_L);document.addEventListener("backbutton",_L);function _L(r){r.preventDefault(),Hn(DL),Vs(KO),Hn(Aa),Vs(JO),Us.contentDocument.body.innerHTML=""}EX.addEventListener("click",r=>{if(!navigator.clipboard)return alert("Your browser not support this feature. Consider installing Firefox or Chrome.");let e=codeEditor.state.doc.toString(),t=location.origin+"?c="+encodeURIComponent(AX(e));if(t.length>2048)return alert("Code too long to encode in URL");navigator.clipboard.writeText(t).then(()=>{alert("Your shareable url was copied to clipboard!")},s=>{alert("Error: Unable to generate your shareable url!"),console.error("Error on copying text to clipboard:",s)})});CX.addEventListener("click",r=>{if(!navigator.clipboard)return alert("Your browser not support this feature. Consider installing Firefox or Chrome.");let e=codeEditor.state.doc.toString();navigator.clipboard.writeText(e).then(()=>{},t=>{alert("Error: Unable to generate your shareable url!"),console.error("Error on copying text to clipboard:",t)})});function Nc(){Us.src="preview.html"}Us.addEventListener("load",()=>{let r=codeEditor.state.doc.toString();Us.contentDocument.querySelector("#code").innerHTML=r});if(!Lc){let t=function(s){s.docChanged&&(r&&(clearTimeout(r),r=0),r=setTimeout(Nc,e))},r=0,e=1e3;TL.push(at.updateListener.of(t))}var kX=Vt.create({doc:tl||TX()||PL(),extensions:[AL(),_s.of([lk,{key:"Ctrl-s",run(){return Nc(),!0}}]),kA,vA(),Kk(),Wk(xA(new kL,{languageOptions:{ecmaVersion:"latest",sourceType:"script"},rules:{}})),Zn.data.of({autocomplete:YO}),at.theme({"&":{height:"100%",fontSize:Lc?"16px":"18px"},".cm-scroller":{overflow:"auto"}}),at.lineWrapping,at.updateListener.of(r=>{r.docChanged&&(ka.codeChanged=!0)}),$C(),...TL]});window.codeEditor=new at({state:kX,parent:An(".code .cm-container")});Kn.onmousedown=Kn.ontouchstart=r=>{if(r.preventDefault(),r.target!==Us&&r.target!==Aa&&r.target===Kn){Vs(Kn),Us.focus();return}};window.addEventListener("click",r=>{r.target!==Kn&&r.target!==Aa&&(Hn(Kn),Us.blur())});window.addEventListener("blur",r=>{document.body!==document.activeElement&&Hn(Kn)});function AX(r){return btoa(String.fromCharCode.apply(null,Array.from(yf.deflate(r))))}function PX(r){let e=null,t=0;for(;t<2;)try{t===1&&(r=decodeURIComponent(r),r=r.replace(/ /g,"+")),e=yf.inflate(new Uint8Array(atob(r).split("").map(s=>s.charCodeAt(0))),{to:"string"}),console.log("Playground url decoded successfully!");break}catch(s){console.error(`Failed decode the playground url (${t+1}/2). Error:`,s),console.log("Trying to decode again (fixing some characters)..."),e=null,t++}return e||alert("Invalid playground url."),e}ka.autosave&&setInterval(()=>{document.visibilityState==="visible"&&IL()},ka.autosaveInterval);function IL(){localStorage.setItem("litecanvas_code",codeEditor.state.doc.toString())}function TX(){return localStorage.getItem("litecanvas_code")}function DX(){localStorage.clear()}wX&&HO(codeEditor);window.isUpdateAvailable=new Promise(function(r){(Bc.searchParams.get("test_service_worker")==="on"||"serviceWorker"in navigator&&location.hostname.indexOf("127.0.0")===-1)&&(navigator.serviceWorker.register("sw.js").then(e=>{e.onupdatefound=()=>{let t=e.installing;t.onstatechange=()=>{switch(t.state){case"installed":navigator.serviceWorker.controller?r(!0):r(!1);break}}}}).catch(e=>console.error("[SW ERROR]",e)),navigator.serviceWorker.ready.then(e=>{e.active.postMessage({type:"GET_VERSION"})}),navigator.serviceWorker.addEventListener("message",e=>{e.data.type==="GET_VERSION"&&console.log("litecanvas playground version:",e.data.res)}))});window.isUpdateAvailable.then(r=>{r&&alert("New Update available! Reload the webapp to see the latest changes.")});Lc?(Hn(Aa),Vs(KO)):(Hn(Kn),SX&&Nc());})(); +`;function YO(r){let e=r.matchBefore(/\w*/);return e.from==e.to&&!r.explicit?null:{from:e.from,options:[{label:"CANVAS",type:"constant",info:"game canvas HTML element"},{label:"WIDTH",type:"variable",info:"width of the game screen"},{label:"HEIGHT",type:"variable",info:"height of the game screen"},{label:"ELAPSED",type:"variable",info:"seconds since the game started"},{label:"FPS",type:"variable",info:"frames per second"},{label:"CENTERX",type:"variable",info:"middle X of the game screen"},{label:"CENTERY",type:"variable",info:"middle Y of the game screen"},{label:"MOUSEX",type:"variable"},{label:"MOUSEY",type:"variable"},{label:"DEFAULT_SFX",type:"variable"},{label:"PI",type:"constant"},{label:"TWO_PI",type:"constant"},{label:"HALF_PI",type:"constant"},{label:"litecanvas",type:"function",apply:"litecanvas({})",detail:"(settings?: object)",info:"initialize a litecanvas instance"},{label:"cls",type:"function",apply:"cls(",detail:"(color?: number)",info:"clear the game screen"},{label:"rect",type:"function",apply:"rect(",detail:"(x, y, width, height, color=0, radii?)"},{label:"rectfill",type:"function",apply:"rectfill(",detail:"(x, y, width, height, color=0, radii?)"},{label:"circ",type:"function",apply:"circ(",detail:"(x, y, radius, color=0)"},{label:"circfill",type:"function",apply:"circfill(",detail:"(x, y, radius, color=0)"},{label:"line",type:"function",apply:"line(",detail:"(x1, y1, x2, y2, color=0)"},{label:"linewidth",type:"function",apply:"linewidth(",detail:"(value)"},{label:"linedash",type:"function",apply:"linedash(",detail:"(pattern, ofsset)"},{label:"text",type:"function",apply:"text(",detail:"(x, y, text, color=3)"},{label:"textfont",type:"function",apply:"textfont(",detail:"(fontName)",info:"default font: 'sans-serif'"},{label:"textsize",type:"function",apply:"textsize(",detail:"(size)",info:"default font size: 32"},{label:"textalign",type:"function",apply:"textalign(",detail:"(align, baseline)"},{label:"textstyle",type:"function",apply:"textstyle(",detail:"(style)"},{label:"textmetrics",type:"function",apply:"textmetrics(",detail:"(text, [size])"},{label:"image",type:"function",apply:"image(",detail:"(x, y, image)"},{label:"paint",type:"function",apply:"paint(",detail:"(width, height, callback|array, options)",info:"Creates a offscreen canvas to draw on it"},{label:"transform",type:"function",apply:"transform(",detail:"(a, b, c, d, e, f, reset=true)"},{label:"translate",type:"function",apply:"translate(",detail:"(x, y)"},{label:"scale",type:"function",apply:"scale(",detail:"(x, y)"},{label:"rotate",type:"function",apply:"rotate(",detail:"(radians)"},{label:"alpha",type:"function",apply:"alpha(",detail:"(value)"},{label:"fill",type:"function",apply:"fill(",detail:"(color, path?)"},{label:"stroke",type:"function",apply:"stroke(",detail:"(color, path?)"},{label:"path",type:"function",apply:"path()",detail:"(arg?: string|Path2D)"},{label:"push",type:"function",apply:"push()",detail:"",info:"save the rendering context"},{label:"pop",type:"function",apply:"pop()",detail:"",info:"restore the rendering context"},{label:"ctx",type:"function",apply:"ctx(value?)",info:"set or get the canvas context"},{label:"cliprect",type:"function",apply:"cliprect(",detail:"(x, y, width, height)",info:"create a rectagular clipping region"},{label:"clipcirc",type:"function",apply:"clipcirc(",detail:"(x, y, radius)",info:"create a circular clipping region"},{label:"sfx",type:"function",apply:"sfx()",detail:"(zzfxParams?, pitchSlide?, volumeFactor?)",info:"play a ZzFX sound"},{label:"volume",type:"function",apply:"volume(",detail:"(value)",info:"set the ZzFX global volume"},{label:"iskeydown",type:"function",apply:"iskeydown(",detail:"(key)"},{label:"seed",type:"function",apply:"seed(",detail:"(value?)",info:"initialize the RNG with a seed value"},{label:"rand",type:"function",apply:"rand()",detail:"(min=0.0, max=1.0)",info:"get a pseudo-random float between min (inclusive) and max (exclusive)"},{label:"randi",type:"function",apply:"randi()",detail:"(min=0, max=1)",info:"get a pseudo-random integer between min (inclusive) and max (inclusive)"},{label:"map",type:"function",apply:"map(",detail:"(val, min1, max1, min2, max2, withinBounds=false)"},{label:"norm",type:"function",apply:"norm(",detail:"(val, min, max)"},{label:"diff",type:"function",apply:"diff(",detail:"(a, b)"},{label:"clamp",type:"function",apply:"clamp(",detail:"(value, min, max)"},{label:"wrap",type:"function",apply:"wrap(",detail:"(value, min, max)"},{label:"lerp",type:"function",apply:"lerp(",detail:"(start, end, t)",info:"linear interpolation from `start` to `end` over `t`%."},{label:"deg2rad",type:"function",apply:"deg2rad(",detail:"(degrees)"},{label:"rad2deg",type:"function",apply:"rad2deg(",detail:"(radians)"},{label:"sin",type:"function",apply:"sin(",detail:"(radians)"},{label:"cos",type:"function",apply:"cos(",detail:"(radians)"},{label:"tan",type:"function",apply:"tan(",detail:"(radians)"},{label:"abs",type:"function",apply:"abs(",detail:"(value)"},{label:"ceil",type:"function",apply:"ceil(",detail:"(value)"},{label:"round",type:"function",apply:"round(",detail:"(value)"},{label:"floor",type:"function",apply:"floor(",detail:"(value)"},{label:"trunc",type:"function",apply:"trunc(",detail:"(value)"},{label:"min",type:"function",apply:"min(",detail:"(...values)"},{label:"max",type:"function",apply:"max(",detail:"(...values)"},{label:"pow",type:"function",apply:"pow(",detail:"(a, b)"},{label:"sqrt",type:"function",apply:"sqrt(",detail:"(value)"},{label:"sign",type:"function",apply:"sign(",detail:"(value)"},{label:"atan2",type:"function",apply:"atan2(",detail:"(y, x)"},{label:"hypot",type:"function",apply:"hypot(",detail:"(...values)"},{label:"exp",type:"function",apply:"exp(",detail:"(x)"},{label:"colrect",type:"function",apply:"colrect(",detail:"(x1, y1, w1, h1, x2, y2, w2, h2)",info:"Check collision between 2 rectangles"},{label:"colcirc",type:"function",apply:"colcirc(",detail:"(x1, y1, r1, x2, y2, r2)",info:"Check collision between 2 circles"},{label:"timescale",type:"function",apply:"timescale(",detail:"(value)",info:"Sets the scale of the game's delta time (dt)"},{label:"use",type:"function",apply:"use(",detail:"(callback)",info:"Loads a plugin to extend the litecanvas engine"},{label:"setvar",type:"function",apply:"setvar(",detail:"(name, value)"},{label:"getcolor",type:"function",apply:"getcolor(",detail:"(index)"},{label:"listen",type:"function",apply:"listen(",detail:"(event, callback)"},{label:"emit",type:"function",apply:"emit(",detail:"(event, a1, a2, a3, a4)"},{label:"resize",type:"function",apply:"resize(",detail:"(width, height)",info:"resizes the game canvas"},{label:"setfps",type:"function",apply:"setfps(",detail:"(value)"},{label:"loadScript",type:"function",apply:"loadScript(",detail:"(url, callback)",info:"Load a JavaScript file"},{label:"loadImage",type:"function",apply:"loadImage(",detail:"(url, callback)",info:"Load a image"},{label:"loadFont",type:"function",apply:"loadFont(",detail:"(name, url, callback)",info:"Load a font"},{label:"LOADING",type:"variable",info:"return the amount of assets that are loading"}]}}function HO(r){let e=visualViewport;if(!e)return;let t=u(),s=document.querySelector(".editor .code"),n=0,i=[{name:"indent",label:'',callback:Pu},{name:"toggle comment",label:"//",callback:gh},{name:"undo",label:'',callback:Cu},{name:"redo",label:'',callback:Io},{name:"select all",label:"[A]",callback:vh},{name:"search (and replace)",label:'',callback:Qu,focus:!1}],a=document.createElement("div");a.classList.add("mobile-buttons"),a.style.display="none";for(let h of i){let f=document.createElement("button"),d=h.focus==null?!0:h.focus;f.innerHTML=h.label,f.setAttribute("title",h.name),f.setAttribute("aria-label",h.name),f.setAttribute("data-focus",d?"true":"false"),f.addEventListener("click",m=>{m.preventDefault(),h.callback(r),d&&r.contentDOM.focus()}),a.appendChild(f)}s.appendChild(a),requestAnimationFrame(o);function l(){n&&cancelAnimationFrame(n),n=requestAnimationFrame(o)}e.addEventListener("resize",l),e.addEventListener("scroll",l);function o(){n=!1;let h=a.getBoundingClientRect(),f=e.offsetLeft,d=e.height+e.offsetTop-h.height;a.style.transform=`translate(${f}px, ${d}px)`,Math.abs(e.height-t.height)>100?p():c()}r.contentDOM.addEventListener("click",()=>{p()}),r.contentDOM.addEventListener("focus",()=>{p()});function u(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function c(){a.style.display="none"}function p(){a.style.display=""}}var ka={autosave:!0,autosaveInterval:5e3,codeChanged:!1},Bc=new URL(location.href);Bc.searchParams.get("reset")!==null&&(DX(),window.location=location.origin);var SX=!["0","false"].includes(Bc.searchParams.get("autoplay")),tl=Bc.searchParams.get("c");tl!==null&&(tl=PX(tl),tl&&(ka.autosave=!1,An("#changing-shared-code").style.display=""));document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"&&ka.autosave&&IL()});window.addEventListener("beforeunload",r=>{ka.autosave||(r.preventDefault(),r.returnValue=!0)});var TL=[],DL=An(".code"),KO=An(".game"),Aa=An("#play"),JO=An("#stop"),EX=An("#share"),CX=An("#copy"),Us=An("#frame"),Kn=An("#frame-overlay"),Lc=innerWidth<1024,wX=navigator.userAgent.match(/android|iphone|ipad/i)!==null;Aa.addEventListener("click",()=>{Vs(DL),Hn(KO),Vs(Aa),Hn(JO),Nc(),Lc?(Us.focus(),Vs(Kn)):Hn(Kn)});JO.addEventListener("click",_L);document.addEventListener("backbutton",_L);function _L(r){r.preventDefault(),Hn(DL),Vs(KO),Hn(Aa),Vs(JO),Us.contentDocument.body.innerHTML=""}EX.addEventListener("click",r=>{if(!navigator.clipboard)return alert("Your browser not support this feature. Consider installing Firefox or Chrome.");let e=codeEditor.state.doc.toString(),t=location.origin+"?c="+encodeURIComponent(AX(e));if(t.length>2048)return alert("Code too long to encode in URL");navigator.clipboard.writeText(t).then(()=>{alert("Your shareable url was copied to clipboard!")},s=>{alert("Error: Unable to generate your shareable url!"),console.error("Error on copying text to clipboard:",s)})});CX.addEventListener("click",r=>{if(!navigator.clipboard)return alert("Your browser not support this feature. Consider installing Firefox or Chrome.");let e=codeEditor.state.doc.toString();navigator.clipboard.writeText(e).then(()=>{},t=>{alert("Error: Unable to generate your shareable url!"),console.error("Error on copying text to clipboard:",t)})});function Nc(){Us.src="preview.html"}Us.addEventListener("load",()=>{let r=codeEditor.state.doc.toString();Us.contentDocument.querySelector("#code").innerHTML=r});if(!Lc){let t=function(s){s.docChanged&&(r&&(clearTimeout(r),r=0),r=setTimeout(Nc,e))},r=0,e=1e3;TL.push(at.updateListener.of(t))}var kX=Vt.create({doc:tl||TX()||PL(),extensions:[AL(),_s.of([lk,{key:"Ctrl-s",run(){return Nc(),!0}}]),kA,vA(),Kk(),Wk(xA(new kL,{languageOptions:{ecmaVersion:"latest",sourceType:"script"},rules:{}})),Zn.data.of({autocomplete:YO}),at.theme({"&":{height:"100%",fontSize:Lc?"16px":"18px"},".cm-scroller":{overflow:"auto"}}),at.lineWrapping,at.updateListener.of(r=>{r.docChanged&&(ka.codeChanged=!0)}),$C(),...TL]});window.codeEditor=new at({state:kX,parent:An(".code .cm-container")});Kn.onmousedown=Kn.ontouchstart=r=>{if(r.preventDefault(),r.target!==Us&&r.target!==Aa&&r.target===Kn){Vs(Kn),Us.focus();return}};window.addEventListener("click",r=>{r.target!==Kn&&r.target!==Aa&&(Hn(Kn),Us.blur())});window.addEventListener("blur",r=>{document.body!==document.activeElement&&Hn(Kn)});function AX(r){return btoa(String.fromCharCode.apply(null,Array.from(yf.deflate(r))))}function PX(r){let e=null,t=0;for(;t<2;)try{t===1&&(r=decodeURIComponent(r),r=r.replace(/ /g,"+")),e=yf.inflate(new Uint8Array(atob(r).split("").map(s=>s.charCodeAt(0))),{to:"string"}),console.log("Playground url decoded successfully!");break}catch(s){console.error(`Failed decode the playground url (${t+1}/2). Error:`,s),console.log("Trying to decode again (fixing some characters)..."),e=null,t++}return e||alert("Invalid playground url."),e}ka.autosave&&setInterval(()=>{document.visibilityState==="visible"&&IL()},ka.autosaveInterval);function IL(){localStorage.setItem("litecanvas_code",codeEditor.state.doc.toString())}function TX(){return localStorage.getItem("litecanvas_code")}function DX(){localStorage.clear()}wX&&HO(codeEditor);window.isUpdateAvailable=new Promise(function(r){(Bc.searchParams.get("test_service_worker")==="on"||"serviceWorker"in navigator&&location.hostname.indexOf("127.0.0")===-1)&&(navigator.serviceWorker.register("sw.js").then(e=>{e.onupdatefound=()=>{let t=e.installing;t.onstatechange=()=>{switch(t.state){case"installed":navigator.serviceWorker.controller?r(!0):r(!1);break}}}}).catch(e=>console.error("[SW ERROR]",e)),navigator.serviceWorker.ready.then(e=>{e.active.postMessage({type:"GET_VERSION"})}),navigator.serviceWorker.addEventListener("message",e=>{e.data.type==="GET_VERSION"&&console.log("litecanvas playground version:",e.data.res)}))});window.isUpdateAvailable.then(r=>{r&&alert("New Update available! Reload the webapp to see the latest changes.")});Lc?(Hn(Aa),Vs(KO)):(Hn(Kn),SX&&Nc());})(); /*! Bundled license information: pako/dist/pako.esm.mjs: diff --git a/public/index.html b/public/index.html index bd0eff0..97ecba6 100644 --- a/public/index.html +++ b/public/index.html @@ -30,12 +30,13 @@ > litecanvasLitecanvas - is a lightweight HTML5 canvas engine suitable for small games and - animations for people who enjoy coding: there is no fancy interface, no - visual helpers, no gui tools... just coding. + is a lightweight HTML5 canvas engine suitable for small web games, + prototypes, game jams, animations, creative programming, learning game + programming and game design, etc. Just install our NPM package or + load/download the CDN by adding it as a script tag in your HTML.