import{c as U,A as mo,d as nh,U as zs,V as mu,N as gu,n as sh,g as yt,W as bu,X as yu,Y as xu,i as ve,v as Su,r as zt,o as xt,y as js,f as ce,e as Ae,w as B,D as jt,F as rl,B as ol,b as vi,R as ll,C as qe,t as Es,z as Qu,p as wu,j as ku,_ as Pu}from"./index-bed2942a.js";import{C as vu}from"./CusNavigation-b2e56c9f.js";import{p as $i}from"./index-d139c558.js";var $u={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M719.4 499.1l-296.1-215A15.9 15.9 0 00398 297v430c0 13.1 14.8 20.5 25.3 12.9l296.1-215a15.9 15.9 0 000-25.8zm-257.6 134V390.9L628.5 512 461.8 633.1z"}}]},name:"play-circle",theme:"outlined"};const Zu=$u;function al(n){for(var e=1;ethis.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=pi(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),rt.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=pi(this,e,t);let i=[];return this.decompose(e,t,i,0),rt.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new Ei(this),r=new Ei(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new Ei(this,e)}iterRange(e,t=this.length){return new rh(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new oh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?_.empty:e.length<=32?new ie(e):rt.from(ie.split(e,[]))}}class ie extends _{constructor(e,t=zu(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new ju(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new ie(fl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=_n(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new ie(l,o.length+r.length));else{let a=l.length>>1;i.push(new ie(l.slice(0,a)),new ie(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof ie))return super.replace(e,t,i);[e,t]=pi(this,e,t);let s=_n(this.text,_n(i.text,fl(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new ie(s,r):rt.from(ie.split(s,[]),r)}sliceString(e,t=this.length,i=` `){[e,t]=pi(this,e,t);let s="";for(let r=0,o=0;r<=t&&oe&&o&&(s+=i),er&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new ie(i,s)),i=[],s=-1);return s>-1&&t.push(new ie(i,s)),t}}class rt extends _{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r=o){let h=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=pi(this,e,t),i.lines=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines>5-1&&a.lines>h>>5+1){let c=this.children.slice();return c[s]=a,new rt(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` `){[e,t]=pi(this,e,t);let s="";for(let r=0,o=0;re&&r&&(s+=i),eo&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof rt))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let O of e)O.flatten(d);return new ie(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,h=-1,c=[];function f(d){let O;if(d.lines>r&&d instanceof rt)for(let p of d.children)f(p);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof ie&&a&&(O=c[c.length-1])instanceof ie&&d.lines+O.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new ie(O.text.concat(d.text),O.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:rt.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new rt(l,t)}}_.empty=new ie([""],0);function zu(n){let e=-1;for(let t of n)e+=t.length+1;return e}function _n(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r=t&&(a>i&&(l=l.slice(0,i-s)),s0?1:(e instanceof ie?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof ie?s.text.length:s.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(s instanceof ie){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ie?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class rh{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Ei(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class oh{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(_.prototype[Symbol.iterator]=function(){return this.iter()},Ei.prototype[Symbol.iterator]=rh.prototype[Symbol.iterator]=oh.prototype[Symbol.iterator]=function(){return this});class ju{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function pi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}let ai="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(n=>n?parseInt(n,36):1);for(let n=1;nn)return ai[e-1]<=n;return!1}function ul(n){return n>=127462&&n<=127487}const dl=8205;function ge(n,e,t=!0,i=!0){return(t?lh:Vu)(n,e,i)}function lh(n,e,t){if(e==n.length)return e;e&&ah(n.charCodeAt(e))&&hh(n.charCodeAt(e-1))&&e--;let i=de(n,e);for(e+=Ue(i);e=0&&ul(de(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Vu(n,e,t){for(;e>0;){let i=lh(n,e-2,t);if(i=56320&&n<57344}function hh(n){return n>=55296&&n<56320}function de(n,e){let t=n.charCodeAt(e);if(!hh(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return ah(i)?(t-55296<<10)+(i-56320)+65536:t}function xo(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Ue(n){return n<65536?1:2}const gr=/\r\n?|\n/;var pe=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(pe||(pe={}));class ct{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-s);r+=l}else{if(i!=pe.Simple&&h>=e&&(i==pe.TrackDel&&se||i==pe.TrackBefore&&se))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i=0&&s<=t&&l>=e)return st?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ct(e)}static create(e){return new ct(e)}}class le extends ct{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return br(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return yr(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length0&&kt(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;ou||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let O=d?typeof d=="string"?_.of(d.split(i||gr)):d:_.empty,p=O.length;if(f==u&&p==0)return;fo&&xe(s,f-o,-1),xe(s,u-f,p),kt(r,s,O),o=u}}return h(e),a(!l),l}static empty(e){return new le(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;sl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length=0&&t<=0&&t==n[s+1]?n[s]+=e:e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function kt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,c,f),s=h,r=c}}}function yr(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Ii(n),l=new Ii(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);xe(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Ii{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?_.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?_.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Bt{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Bt(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return y.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return y.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return y.range(e.anchor,e.head)}static create(e,t,i){return new Bt(e,t,i)}}class y{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:y.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new y(e.ranges.map(t=>Bt.fromJSON(t)),e.main)}static single(e,t=e){return new y([y.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;se?8:0)|r)}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;sr.head?y.range(a,l):y.range(l,a))}}return new y(e,t)}}function fh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let So=0;class Z{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=So++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new Z(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Qo),!!e.static,e.enables)}of(e){return new Un([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Un(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Un(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Qo(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Un{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=So++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||xr(f,c)){let d=i(f);if(l?!Ol(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,O=u.config.address[r];if(O!=null){let p=es(u,O);if(this.dependencies.every(m=>m instanceof Z?u.facet(m)===f.facet(m):m instanceof fe?u.field(m,!1)==f.field(m,!1):!0)||(l?Ol(d=i(f),p,s):s(d=i(f),p)))return f.values[o]=p,0}else d=i(f);return f.values[o]=d,1}}}}function Ol(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;ci===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(pl).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,pl.of({field:this,create:e})]}get extension(){return this}}const Vt={lowest:4,low:3,default:2,high:1,highest:0};function Zi(n){return e=>new uh(e,n)}const Yt={highest:Zi(Vt.highest),high:Zi(Vt.high),default:Zi(Vt.default),low:Zi(Vt.low),lowest:Zi(Vt.lowest)};class uh{constructor(e,t){this.inner=e,this.prec=t}}class hn{of(e){return new Sr(this,e)}reconfigure(e){return hn.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Sr{constructor(e,t){this.compartment=e,this.inner=t}}class Jn{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of Uu(e,t,o))u instanceof fe?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],O=d[0].facet,p=c&&c[u]||[];if(d.every(m=>m.type==0))if(l[O.id]=a.length<<1|1,Qo(p,d))a.push(i.facet(O));else{let m=O.combine(d.map(b=>b.value));a.push(i&&O.compare(m,i.facet(O))?i.facet(O):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=h.length<<1,h.push(b=>m.dynamicSlot(b)));l[O.id]=h.length<<1,h.push(m=>_u(m,O,d))}}let f=h.map(u=>u(l));return new Jn(e,o,f,l,a,r)}}function Uu(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Sr&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof Sr){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof uh)r(o.inner,o.prec);else if(o instanceof fe)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Un)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Vt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(n,Vt.default),i.reduce((o,l)=>o.concat(l))}function Vi(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function es(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const dh=Z.define(),Qr=Z.define({combine:n=>n.some(e=>e),static:!0}),Oh=Z.define({combine:n=>n.length?n[0]:void 0,static:!0}),ph=Z.define(),mh=Z.define(),gh=Z.define(),bh=Z.define({combine:n=>n.length?n[0]:!1});class bt{constructor(e,t){this.type=e,this.value=t}static define(){return new Bu}}class Bu{of(e){return new bt(this,e)}}class Lu{constructor(e){this.map=e}of(e){return new W(this,e)}}class W{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new W(this.type,t)}is(e){return this.type==e}static define(e={}){return new Lu(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}W.reconfigure=W.define();W.appendConfig=W.define();class se{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&fh(i,t.newLength),r.some(l=>l.type==se.time)||(this.annotations=r.concat(se.time.of(Date.now())))}static create(e,t,i,s,r,o){return new se(e,t,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(se.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}se.time=bt.define();se.userEvent=bt.define();se.addToHistory=bt.define();se.remote=bt.define();function Iu(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i=n[i]))r=n[i++],o=n[i++];else if(s=0;s--){let r=i[s](n);r instanceof se?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof se?n=r[0]:n=xh(e,hi(r),!1)}return n}function Gu(n){let e=n.startState,t=e.facet(gh),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=yh(i,wr(e,r,n.changes.newLength),!0))}return i==n?n:se.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const Fu=[];function hi(n){return n==null?Fu:Array.isArray(n)?n:[n]}var ee=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(ee||(ee={}));const Hu=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let kr;try{kr=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(n){}function Ku(n){if(kr)return kr.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||Hu.test(t)))return!0}return!1}function Ju(n){return e=>{if(!/\S/.test(e))return ee.Space;if(Ku(e))return ee.Word;for(let t=0;t-1)return ee.Word;return ee.Other}}class z{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;ls.set(h,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(W.reconfigure)?(t=null,i=l.value):l.is(W.appendConfig)&&(t=null,i=hi(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Jn.resolve(i,s,this),r=new z(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Qr)?e.newSelection:e.newSelection.asSingle();new z(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:y.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=hi(i.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return z.create({doc:e.doc,selection:y.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Jn.resolve(e.extensions||[],new Map),i=e.doc instanceof _?e.doc:_.of((e.doc||"").split(t.staticFacet(z.lineSeparator)||gr)),s=e.selection?e.selection instanceof y?e.selection:y.single(e.selection.anchor,e.selection.head):y.single(0);return fh(s,i.length),t.staticFacet(Qr)||(s=s.asSingle()),new z(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(z.tabSize)}get lineBreak(){return this.facet(z.lineSeparator)||` `}get readOnly(){return this.facet(bh)}phrase(e,...t){for(let i of this.facet(z.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let s=[];for(let r of this.facet(dh))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){return Ju(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=ge(t,o,!1);if(r(t.slice(a,o))!=ee.Word)break;o=a}for(;ln.length?n[0]:4});z.lineSeparator=Oh;z.readOnly=bh;z.phrases=Z.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(s=>n[s]==e[s])}});z.languageData=dh;z.changeFilter=ph;z.transactionFilter=mh;z.transactionExtender=gh;hn.reconfigure=W.define();function ft(n,e,t={}){let i={};for(let s of n)for(let r of Object.keys(s)){let o=s[r],l=i[r];if(l===void 0)i[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))i[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)i[s]===void 0&&(i[s]=e[s]);return i}class Gt{eq(e){return this==e}range(e,t=e){return Pr.create(e,t,this)}}Gt.prototype.startSide=Gt.prototype.endSide=0;Gt.prototype.point=!1;Gt.prototype.mapMode=pe.TrackDel;let Pr=class Sh{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Sh(e,t,i)}};function vr(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class wo{constructor(e,t,i,s){this.from=e,this.to=t,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,s=0){let r=i?this.to:this.from;for(let o=s,l=r.length;;){if(o==l)return o;let a=o+l>>1,h=r[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);rd||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,d-u)),i.push(h),s.push(u-o),r.push(d-o))}return{mapped:i.length?new wo(s,r,i,l):null,pos:o}}}class V{constructor(e,t,i,s){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=s}static create(e,t,i,s){return new V(e,t,i,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(vr)),this.isEmpty)return t.length?V.of(t):this;let l=new Qh(this,null,-1).goto(0),a=0,h=[],c=new Tt;for(;l.value||a=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||rl.to||r=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Ni.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ni.from(e).goto(t)}static compare(e,t,i,s,r=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),a=ml(o,l,i),h=new Ci(o,a,r),c=new Ci(l,a,r);i.iterGaps((f,u,d)=>gl(h,f,c,u,d,s)),i.empty&&i.length==0&&gl(h,0,c,0,0,s)}static eq(e,t,i=0,s){s==null&&(s=1e9-1);let r=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=ml(r,o),a=new Ci(r,l,0).goto(i),h=new Ci(o,l,0).goto(i);for(;;){if(a.to!=h.to||!$r(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>s)return!0;a.next(),h.next()}}static spans(e,t,i,s,r=-1){let o=new Ci(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(s.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Tt;for(let s of e instanceof Pr?[e]:t?ed(e):e)i.add(s.from,s.to,s.value);return i.finish()}static join(e){if(!e.length)return V.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let s=e[i];s!=V.empty;s=s.nextLayer)t=new V(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}V.empty=new V([],[],null,-1);function ed(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(vr);e=i}return n}V.empty.nextLayer=V.empty;class Tt{finishChunk(e){this.chunks.push(new wo(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Tt)).add(e,t,i)}addInner(e,t,i){let s=e-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(V.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=V.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function ml(n,e,t){let i=new Map;for(let r of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&s.push(new Qh(o,t,i,r));return s.length==1?s[0]:new Ni(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Vs(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Vs(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Vs(this.heap,0)}}}function Vs(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let s=n[i];if(i+1=0&&(s=n[i+1],i++),t.compare(s)<0)break;n[i]=t,n[e]=s,e=i}}class Ci{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ni.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){yn(this.active,e),yn(this.activeTo,e),yn(this.activeRank,e),this.minActive=bl(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:s,rank:r}=this.cursor;for(;t0;)t++;xn(this.active,t,i),xn(this.activeTo,t,s),xn(this.activeRank,t,r),e&&xn(e,t,this.cursor.from),this.minActive=bl(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&yn(i,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[s]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function gl(n,e,t,i,s,r){n.goto(e),t.goto(i);let o=i+s,l=i,a=i-e;for(;;){let h=n.to+a-t.to||n.endSide-t.endSide,c=h<0?n.to+a:t.to,f=Math.min(c,o);if(n.point||t.point?n.point&&t.point&&(n.point==t.point||n.point.eq(t.point))&&$r(n.activeForPoint(n.to),t.activeForPoint(t.to))||r.comparePoint(l,f,n.point,t.point):f>l&&!$r(n.active,t.active)&&r.compareRange(l,f,n.active,t.active),c>o)break;l=c,h<=0&&n.next(),h>=0&&t.next()}}function $r(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function bl(n,e){let t=-1,i=1e9;for(let s=0;s=e)return s;if(s==n.length)break;r+=n.charCodeAt(s)==9?t-r%t:1,s=ge(n,s)}return i===!0?-1:n.length}const Cr="ͼ",yl=typeof Symbol>"u"?"__"+Cr:Symbol.for(Cr),Tr=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),xl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Rt{constructor(e,t){this.rules=[];let{finish:i}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let O=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(p=>o.map(m=>p.replace(/&/,m))).reduce((p,m)=>p.concat(m)),O,a);else if(O&&typeof O=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),O,c,u)}else O!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,p=>"-"+p.toLowerCase())+": "+O+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=xl[yl]||1;return xl[yl]=e+1,Cr+e.toString(36)}static mount(e,t,i){let s=e[Tr],r=i&&i.nonce;s?r&&s.setNonce(r):s=new td(e,r),s.mount(Array.isArray(t)?t:[t],e)}}let Sl=new Map;class td{constructor(e,t){let i=e.ownerDocument||e,s=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=Sl.get(i);if(r)return e[Tr]=r;this.sheet=new s.CSSStyleSheet,Sl.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Tr]=this}mount(e,t){let i=this.sheet,s=0,r=0;for(let o=0;o-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),i)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},id=typeof navigator<"u"&&/Mac/.test(navigator.platform),nd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Oe=0;Oe<10;Oe++)At[48+Oe]=At[96+Oe]=String(Oe);for(var Oe=1;Oe<=24;Oe++)At[Oe+111]="F"+Oe;for(var Oe=65;Oe<=90;Oe++)At[Oe]=String.fromCharCode(Oe+32),Gi[Oe]=String.fromCharCode(Oe);for(var _s in At)Gi.hasOwnProperty(_s)||(Gi[_s]=At[_s]);function sd(n){var e=id&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||nd&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Gi:At)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function ts(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Rr(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function rd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Bn(n,e){if(!e.anchorNode)return!1;try{return Rr(n,e.anchorNode)}catch(t){return!1}}function mi(n){return n.nodeType==3?Ht(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function _i(n,e,t,i){return t?Ql(n,e,t,i,-1)||Ql(n,e,t,i,1):!1}function Ft(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function is(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function Ql(n,e,t,i,s){for(;;){if(n==t&&e==i)return!0;if(e==(s<0?0:pt(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;e=Ft(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=s<0?pt(n):0}else return!1}}function pt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ks(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function od(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function wh(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function ld(n,e,t,i,s,r,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,d=c==a.body,O=1,p=1;if(d)u=od(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let x=c.getBoundingClientRect();({scaleX:O,scaleY:p}=wh(c,x)),u={left:x.left,right:x.left+c.clientWidth*O,top:x.top,bottom:x.top+c.clientHeight*p}}let m=0,b=0;if(s=="nearest")e.top0&&e.bottom>u.bottom+b&&(b=e.bottom-u.bottom+b+o)):e.bottom>u.bottom&&(b=e.bottom-u.bottom+o,t<0&&e.top-b0&&e.right>u.right+m&&(m=e.right-u.right+m+r)):e.right>u.right&&(m=e.right-u.right+r,t<0&&e.leftt.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}class hd{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?pt(t):0),i,Math.min(e.focusOffset,i?pt(i):0))}set(e,t,i,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=s}}let ti=null;function kh(n){if(n.setActive)return n.setActive();if(ti)return n.focus(ti);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(ti==null?{get preventScroll(){return ti={preventScroll:!0},!0}}:void 0),!ti){ti=!1;for(let t=0;tMath.max(1,n.scrollHeight-n.clientHeight-4)}function $h(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=pt(t)}else if(t.parentNode&&!is(t))i=Ft(t),t=t.parentNode;else return null}}function Zh(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&it)return f.domBoundsAround(e,t,h);if(u>=e&&s==-1&&(s=a,r=h),h>t&&f.dom.parentNode==this.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:r,to:l<0?i+this.length:l,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=ko){this.markDirty();for(let s=e;sthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Th(n,e,t,i,s,r,o,l,a){let{children:h}=n,c=h.length?h[e]:null,f=r.length?r[r.length-1]:null,u=f?f.breakAfter:o;if(!(e==i&&c&&!o&&!u&&r.length<2&&c.merge(t,s,r.length?f:null,t==0,l,a))){if(i0&&(!o&&r.length&&c.merge(t,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(t2);var C={mac:$l||/Mac/.test(Ve.platform),windows:/Win/.test(Ve.platform),linux:/Linux|X11/.test(Ve.platform),ie:Ps,ie_version:Ah?Ar.documentMode||6:Wr?+Wr[1]:Mr?+Mr[1]:0,gecko:Pl,gecko_version:Pl?+(/Firefox\/(\d+)/.exec(Ve.userAgent)||[0,0])[1]:0,chrome:!!Us,chrome_version:Us?+Us[1]:0,ios:$l,android:/Android\b/.test(Ve.userAgent),webkit:vl,safari:Mh,webkit_version:vl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Ar.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const ud=256;class Fe extends N{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return this.flags&8||i&&(!(i instanceof Fe)||this.length-(t-e)+i.length>ud||i.flags&8)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new Fe(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Se(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return dd(this.dom,e,t)}}class mt extends N{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let s of t)s.setParent(this)}setAttrs(e){if(Ph(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,s,r,o){return i&&(!(i instanceof mt&&i.mark.eq(this.mark))||e&&r<=0||te&&t.push(i=e&&(s=r),i=a,r++}let o=this.length-e;return this.length=e,s>-1&&(this.children.length=s,this.markDirty()),new mt(this.mark,t,o)}domAtPos(e){return Wh(this,e)}coordsAt(e,t){return Yh(this,e,t)}}function dd(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let s=e,r=e,o=0;e==0&&t<0||e==i&&t>=0?C.chrome||C.gecko||(e?(s--,o=1):r=0)?0:l.length-1];return C.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?ks(a,o<0):a||null}class Pt extends N{static create(e,t,i){return new Pt(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=Pt.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,i,s,r,o){return i&&(!(i instanceof Pt)||!this.widget.compare(i.widget)||e>0&&r<=0||t0)?Se.before(this.dom):Se.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let s=this.dom.getClientRects(),r=null;if(!s.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?s.length-1:0;r=s[l],!(e>0?l==0:l==s.length-1||r.top0?Se.before(this.dom):Se.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return _.empty}get isHidden(){return!0}}Fe.prototype.children=Pt.prototype.children=gi.prototype.children=ko;function Wh(n,e){let t=n.dom,{children:i}=n,s=0;for(let r=0;sr&&e0;r--){let o=i[r-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let r=s;r0&&e instanceof mt&&s.length&&(i=s[s.length-1])instanceof mt&&i.mark.eq(e.mark)?Xh(i,e.children[0],t-1):(s.push(e),e.setParent(n)),n.length+=e.length}function Yh(n,e,t){let i=null,s=-1,r=null,o=-1;function l(h,c){for(let f=0,u=0;f=c&&(d.children.length?l(d,c-u):(!r||r.isHidden&&t>0)&&(O>c||u==O&&d.getSide()>0)?(r=d,o=c-u):(u-1?1:0)!=s.length-(t&&s.indexOf(t)>-1?1:0))return!1;for(let r of i)if(r!=t&&(s.indexOf(r)==-1||n[r]!==e[r]))return!1;return!0}function Yr(n,e,t){let i=!1;if(e)for(let s in e)t&&s in t||(i=!0,s=="style"?n.style.cssText="":n.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(i=!0,s=="style"?n.style.cssText=t[s]:n.setAttribute(s,t[s]));return i}function pd(n){let e=Object.create(null);for(let t=0;t0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Po(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Xh(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=Xr(t,this.attrs||{})),i&&(this.attrs=Xr({class:i},this.attrs||{}))}domAtPos(e){return Wh(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(Ph(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Yr(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let s=this.dom.lastChild;for(;s&&N.get(s)instanceof mt;)s=s.lastChild;if(!s||!this.length||s.nodeName!="BR"&&((i=N.get(s))===null||i===void 0?void 0:i.isEditable)==!1&&(!C.ios||!this.children.some(r=>r instanceof Fe))){let r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof Fe)||/[^ -~]/.test(i.text))return null;let s=mi(i.dom);if(s.length!=1)return null;e+=s[0].width,t=s[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=Yh(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:s}=this.parent.view.viewState,r=i.bottom-i.top;if(Math.abs(r-s.lineHeight)<2&&s.textHeight=t){if(r instanceof oe)return r;if(o>t)break}s=o+r.breakAfter}return null}}class $t extends N{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,s,r,o){return i&&(!(i instanceof $t)||!this.widget.compare(i.widget)||e>0&&r<=0||t0}}class ut{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var Ce=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(Ce||(Ce={}));class T extends Gt{constructor(e,t,i,s){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(e){return new cn(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Mt(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,s;if(e.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=Dh(e,t);i=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Mt(e,i,s,t,e.widget||null,!0)}static line(e){return new fn(e)}static set(e,t=!1){return V.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}T.none=V.empty;class cn extends T{constructor(e){let{start:t,end:i}=Dh(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof cn&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((i=e.attrs)===null||i===void 0?void 0:i.class))&&Po(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}cn.prototype.point=!1;class fn extends T{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof fn&&this.spec.class==e.spec.class&&Po(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}fn.prototype.mapMode=pe.TrackBefore;fn.prototype.point=!0;class Mt extends T{constructor(e,t,i,s,r,o){super(t,i,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?pe.TrackBefore:pe.TrackAfter:pe.TrackDel}get type(){return this.startSide!=this.endSide?Ce.WidgetRange:this.startSide<=0?Ce.WidgetBefore:Ce.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Mt&&md(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Mt.prototype.point=!0;function Dh(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t!=null?t:e,end:i!=null?i:e}}function md(n,e){return n==e||!!(n&&e&&n.compare(e))}function Dr(n,e,t,i=0){let s=t.length-1;s>=0&&t[s]+i>=n?t[s]=Math.max(t[s],e):t.push(n,e)}class Ui{constructor(e,t,i,s){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof $t&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new oe),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Sn(new gi(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof $t)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:r,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=r,this.textOff=0}let s=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(Sn(new Fe(this.text.slice(this.textOff,this.textOff+s)),t),i),this.atCursorPos=!0,this.textOff+=s,e-=s,i=0}}span(e,t,i,s){this.buildText(t-e,i,s),this.pos=t,this.openStart<0&&(this.openStart=s)}point(e,t,i,s,r,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Mt){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(i instanceof Mt)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new $t(i.widget||bi.block,l,i));else{let a=Pt.create(i.widget||bi.inline,l,l?0:i.startSide),h=this.atCursorPos&&!a.isEditable&&r<=s.length&&(e0),c=!a.isEditable&&(es.length||i.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!h&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(s),h&&(f.append(Sn(new gi(1),s),r),r=s.length+Math.max(0,r-s.length)),f.append(Sn(a,s),r),this.atCursorPos=c,this.pendingBuffer=c?es.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,i,s,r){let o=new Ui(e,t,i,r);return o.openEnd=V.spans(s,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Sn(n,e){for(let t of e)n=new mt(t,[n],n.length);return n}class bi extends ut{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}bi.inline=new bi("span");bi.block=new bi("div");var J=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(J||(J={}));const Kt=J.LTR,vo=J.RTL;function qh(n){let e=[];for(let t=0;t=t){if(l.level==i)return o;(r<0||(s!=0?s<0?l.fromt:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function jh(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;p-=3)if(et[p+1]==-d){let m=et[p+2],b=m&2?s:m&4?m&1?r:s:0;b&&(I[f]=I[et[p]]=b),l=p;break}}else{if(et.length==189)break;et[l++]=f,et[l++]=u,et[l++]=a}else if((O=I[f])==2||O==1){let p=O==s;a=p?0:1;for(let m=l-3;m>=0;m-=3){let b=et[m+2];if(b&2)break;if(p)et[m+2]|=2;else{if(b&4)break;et[m+2]|=4}}}}}function Qd(n,e,t,i){for(let s=0,r=i;s<=t.length;s++){let o=s?t[s-1].to:n,l=sa;)O==m&&(O=t[--p].from,m=p?t[p-1].to:n),I[--O]=d;a=c}else r=h,a++}}}function zr(n,e,t,i,s,r,o){let l=i%2?2:1;if(i%2==s%2)for(let a=e,h=0;aa&&o.push(new vt(a,p.from,d));let m=p.direction==Kt!=!(d%2);jr(n,m?i+1:i,s,p.inner,p.from,p.to,o),a=p.to}O=p.to}else{if(O==t||(c?I[O]!=l:I[O]==l))break;O++}u?zr(n,a,O,i+1,s,u,o):ae;){let c=!0,f=!1;if(!h||a>r[h-1].to){let p=I[a-1];p!=l&&(c=!1,f=p==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,O=a;e:for(;;)if(h&&O==r[h-1].to){if(f)break e;let p=r[--h];if(!c)for(let m=p.from,b=h;;){if(m==e)break e;if(b&&r[b-1].to==m)m=r[--b].from;else{if(I[m-1]==l)break e;break}}if(u)u.push(p);else{p.toI.length;)I[I.length]=256;let i=[],s=e==Kt?0:1;return jr(n,s,s,t,0,n.length,i),i}function Eh(n){return[new vt(0,n,0)]}let Vh="";function kd(n,e,t,i,s){var r;let o=i.head-n.from,l=vt.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=e[l],h=a.side(s,t);if(o==h){let u=l+=s?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!s,t),h=a.side(s,t)}let c=ge(n.text,o,a.forward(s,t));(ca.to)&&(c=h),Vh=n.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f&&c==h&&f.level+(s?0:1)n.some(e=>e)}),Fh=Z.define({combine:n=>n.some(e=>e)}),Hh=Z.define();class fi{constructor(e,t="nearest",i="nearest",s=5,r=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new fi(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new fi(y.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Qn=W.define({map:(n,e)=>n.map(e)});function We(n,e,t){let i=n.facet(Lh);i.length?i[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}const vs=Z.define({combine:n=>n.length?n[0]:!0});let vd=0;const Xi=Z.define();class ne{constructor(e,t,i,s,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=s,this.extension=r(this)}static define(e,t){const{eventHandlers:i,eventObservers:s,provide:r,decorations:o}=t||{};return new ne(vd++,e,i,s,l=>{let a=[Xi.of(l)];return o&&a.push(Fi.of(h=>{let c=h.plugin(l);return c?o(c):T.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return ne.define(i=>new e(i),t)}}class Bs{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(We(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(s){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){We(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){We(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Kh=Z.define(),$o=Z.define(),Fi=Z.define(),Jh=Z.define(),Zo=Z.define(),ec=Z.define();function Cl(n,e){let t=n.state.facet(ec);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(n):r),s=[];return V.spans(i,e.from,e.to,{point(){},span(r,o,l,a){let h=r-e.from,c=o-e.from,f=s;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,O;if(d==null&&(d=Pd(e.text,h,c)),a>0&&f.length&&(O=f[f.length-1]).to==h&&O.direction==d)O.to=c,f=O.inner;else{let p={from:h,to:c,direction:d,inner:[]};f.push(p),f=p.inner}}}}),s}const tc=Z.define();function ic(n){let e=0,t=0,i=0,s=0;for(let r of n.state.facet(tc)){let o=r(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:i,bottom:s}}const Yi=Z.define();class Le{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new Le(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>i.toA)){if(s.toAc)break;r+=2}if(!a)return i;new Le(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}}class ns{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=le.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,l,a)=>s.push(new Le(r,o,l,a))),this.changedRanges=s}static create(e,t,i){return new ns(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class Tl extends N{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new oe],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Le(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:c})=>cthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let s=-1;this.view.inputState.composing>=0&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!Md(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?Zd(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:c}=this.hasComposition;i=new Le(h,c,e.changes.mapPos(h,-1),e.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(C.ie||C.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=Rd(o,l,e.changes);return i=Le.extendWithRanges(i,a),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:s}=this.view;s.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=C.chrome||C.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||s.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to=0?s[o]:null;if(!l)break;let{fromA:a,toA:h,fromB:c,toB:f}=l,u,d,O,p;if(i&&i.range.fromBc){let Q=Ui.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),S=Ui.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);d=Q.breakAtStart,O=Q.openStart,p=S.openEnd;let v=this.compositionView(i);S.breakAtStart?v.breakAfter=1:S.content.length&&v.merge(v.length,v.length,S.content[0],!1,S.openStart,0)&&(v.breakAfter=S.content[0].breakAfter,S.content.shift()),Q.content.length&&v.merge(0,0,Q.content[Q.content.length-1],!0,0,Q.openEnd)&&Q.content.pop(),u=Q.content.concat(v).concat(S.content)}else({content:u,breakAtStart:d,openStart:O,openEnd:p}=Ui.build(this.view.state.doc,c,f,this.decorations,this.dynamicDecorationMap));let{i:m,off:b}=r.findPos(h,1),{i:x,off:P}=r.findPos(a,-1);Th(this,x,P,m,b,u,d,O,p)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new Fe(e.text.nodeValue);t.flags|=8;for(let{deco:s}of e.marks)t=new mt(s,[t],t.length);let i=new oe;return i.append(t,0),i}fixCompositionDOM(e){let t=(r,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=N.get(r);l&&l!=o&&(l.dom=null),o.setDOM(r)},i=this.childPos(e.range.fromB,1),s=this.children[i.i];t(e.line,s);for(let r=e.marks.length-1;r>=-1;r--)i=s.childPos(i.off,1),s=s.children[i.i],t(r>=0?e.marks[r].node:e.text,s)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,s=i==this.dom,r=!s&&Bn(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(s||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),h=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(C.gecko&&l.empty&&!this.hasComposition&&$d(a)){let f=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(f,a.node.childNodes[a.offset]||null)),a=h=new Se(f,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||(!_i(a.node,a.offset,c.anchorNode,c.anchorOffset)||!_i(h.node,h.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,l))&&(this.view.observer.ignore(()=>{C.android&&C.chrome&&this.dom.contains(c.focusNode)&&Ad(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=ts(this.view.root);if(f)if(l.empty){if(C.gecko){let u=Cd(a.node,a.offset);if(u&&u!=3){let d=(u==1?$h:Zh)(a.node,a.offset);d&&(a=new Se(d.node,d.offset))}}f.collapse(a.node,a.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(a.node,a.offset);try{f.extend(h.node,h.offset)}catch(u){}}else{let u=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),u.setEnd(h.node,h.offset),u.setStart(a.node,a.offset),f.removeAllRanges(),f.addRange(u)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new Se(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new Se(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&_i(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=ts(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=oe.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(s,r)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let s=e.offset;!i&&s=0;s--){let r=N.get(t.childNodes[s]);r instanceof oe&&(i=r.domAtPos(r.length))}return i?new Se(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=N.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t=0;o--){let l=this.children[o],a=r-l.breakAfter,h=a-l.length;if(ae||l.covers(1))&&(!i||l instanceof oe&&!(i instanceof oe&&t>=0))&&(i=l,s=h),r=h}return i?i.coordsAt(e-s,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),s=this.children[t];if(!(s instanceof oe))return null;for(;s.children.length;){let{i:l,off:a}=s.childPos(i,1);for(;;l++){if(l==s.children.length)return null;if((s=s.children[l]).length)break}i=a}if(!(s instanceof Fe))return null;let r=ge(s.text,i);if(r==i)return null;let o=Ht(s.dom,i,r).getClientRects();for(let l=0;lMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==J.LTR;for(let h=0,c=0;cs)break;if(h>=i){let d=f.dom.getBoundingClientRect();if(t.push(d.height),o){let O=f.dom.lastChild,p=O?mi(O):[];if(p.length){let m=p[p.length-1],b=a?m.right-d.left:d.right-m.left;b>l&&(l=b,this.minWidth=r,this.minWidthFrom=h,this.minWidthTo=u)}}}h=u+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?J.RTL:J.LTR}measureTextSize(){for(let r of this.children)if(r instanceof oe){let o=r.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,s;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=mi(e.firstChild)[0];t=e.getBoundingClientRect().height,i=r?r.width/27:7,s=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:s}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Ch(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(T.replace({widget:new Rl(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return T.set(e)}updateDeco(){let e=0,t=this.view.state.facet(Fi).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,s=this.view.state.facet(Jh).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=i,t.push(V.join(s))),this.decorations=[...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];et.anchor?-1:1),s;if(!i)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let r=ic(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;ld(this.view.scrollDOM,o,t.head{ie.from&&(t=!0)}),t}function Wd(n,e,t=1){let i=n.charCategorizer(e),s=n.doc.lineAt(e),r=e-s.from;if(s.length==0)return y.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,l=r;t<0?o=ge(s.text,r,!1):l=ge(s.text,r);let a=i(s.text.slice(o,l));for(;o>0;){let h=ge(s.text,o,!1);if(i(s.text.slice(h,o))!=a)break;o=h}for(;ln?e.left-n:Math.max(0,n-e.right)}function Yd(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function Ls(n,e){return n.tope.top+1}function Al(n,e){return en.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function Vr(n,e,t){let i,s,r,o,l=!1,a,h,c,f;for(let O=n.firstChild;O;O=O.nextSibling){let p=mi(O);for(let m=0;mP||o==P&&r>x){i=O,s=b,r=x,o=P;let Q=P?t0?m0)}x==0?t>b.bottom&&(!c||c.bottomb.top)&&(h=O,f=b):c&&Ls(c,b)?c=Ml(c,b.bottom):f&&Ls(f,b)&&(f=Al(f,b.top))}}if(c&&c.bottom>=t?(i=a,s=c):f&&f.top<=t&&(i=h,s=f),!i)return{node:n,offset:0};let u=Math.max(s.left,Math.min(s.right,e));if(i.nodeType==3)return Wl(i,u,t);if(l&&i.contentEditable!="false")return Vr(i,u,t);let d=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(s.left+s.right)/2?1:0);return{node:n,offset:d}}function Wl(n,e,t){let i=n.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;lt?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&f=(c.left+c.right)/2,d=u;if((C.chrome||C.gecko)&&Ht(n,l).getBoundingClientRect().left==c.right&&(d=!u),f<=0)return{node:n,offset:l+(d?1:0)};s=l+(d?1:0),r=f}}}return{node:n,offset:s>-1?s:o>0?n.nodeValue.length:0}}function sc(n,e,t,i=-1){var s,r;let o=n.contentDOM.getBoundingClientRect(),l=o.top+n.viewState.paddingTop,a,{docHeight:h}=n.viewState,{x:c,y:f}=e,u=f-l;if(u<0)return 0;if(u>h)return n.state.doc.length;for(let Q=n.viewState.heightOracle.textHeight/2,S=!1;a=n.elementAtHeight(u),a.type!=Ce.Text;)for(;u=i>0?a.bottom+Q:a.top-Q,!(u>=0&&u<=h);){if(S)return t?null:0;S=!0,i=-i}f=l+u;let d=a.from;if(dn.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:Xl(n,o,a,c,f);let O=n.dom.ownerDocument,p=n.root.elementFromPoint?n.root:O,m=p.elementFromPoint(c,f);m&&!n.contentDOM.contains(m)&&(m=null),m||(c=Math.max(o.left+1,Math.min(o.right-1,c)),m=p.elementFromPoint(c,f),m&&!n.contentDOM.contains(m)&&(m=null));let b,x=-1;if(m&&((s=n.docView.nearest(m))===null||s===void 0?void 0:s.isEditable)!=!1){if(O.caretPositionFromPoint){let Q=O.caretPositionFromPoint(c,f);Q&&({offsetNode:b,offset:x}=Q)}else if(O.caretRangeFromPoint){let Q=O.caretRangeFromPoint(c,f);Q&&({startContainer:b,startOffset:x}=Q,(!n.contentDOM.contains(b)||C.safari&&Dd(b,x,c)||C.chrome&&qd(b,x,c))&&(b=void 0))}}if(!b||!n.docView.dom.contains(b)){let Q=oe.find(n.docView,d);if(!Q)return u>a.top+a.height/2?a.to:a.from;({node:b,offset:x}=Vr(Q.dom,c,f))}let P=n.docView.nearest(b);if(!P)return null;if(P.isWidget&&((r=P.dom)===null||r===void 0?void 0:r.nodeType)==1){let Q=P.dom.getBoundingClientRect();return e.yn.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((s-t.top-(n.defaultLineHeight-l)*.5)/l);r+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Zr(o,r,n.state.tabSize)}function Dd(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let s=n.nextSibling;s;s=s.nextSibling)if(s.nodeType!=1||s.nodeName!="BR")return!1;return Ht(n,i-1,i).getBoundingClientRect().left>t}function qd(n,e,t){if(e!=0)return!1;for(let s=n;;){let r=s.parentNode;if(!r||r.nodeType!=1||r.firstChild!=s)return!1;if(r.classList.contains("cm-line"))break;s=r}let i=n.nodeType==1?n.getBoundingClientRect():Ht(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function _r(n,e){let t=n.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==Ce.Text))return i}return t}function zd(n,e,t,i){let s=_r(n,e.head),r=!i||s.type!=Ce.Text||!(n.lineWrapping||s.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(s.from),a=n.posAtCoords({x:t==(l==J.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return y.cursor(a,t?-1:1)}return y.cursor(t?s.to:s.from,t?-1:1)}function Yl(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let l=e,a=null;;){let h=kd(s,r,o,l,t),c=Vh;if(!h){if(s.number==(t?n.state.doc.lines:1))return l;c=` `,s=n.state.doc.line(s.number+(t?1:-1)),r=n.bidiSpans(s),h=n.visualLineSide(s,!t)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function jd(n,e,t){let i=n.state.charCategorizer(e),s=i(t);return r=>{let o=i(r);return s==ee.Space&&(s=o),s==o}}function Ed(n,e,t,i){let s=e.head,r=t?1:-1;if(s==(t?n.state.doc.length:0))return y.cursor(s,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(s,e.assoc||-1),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let d=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(s-d.from))),l=(r<0?d.top:d.bottom)+c}let f=a.left+o,u=i!=null?i:n.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let O=l+(u+d)*r,p=sc(n,{x:f,y:O},!1,r);if(Oa.bottom||(r<0?ps)){let m=n.docView.coordsForChar(p),b=!m||O{if(e>r&&es(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:y.cursor(i,inull),C.gecko&&sO(e.contentDOM.ownerDocument)}handleEvent(e){!Fd(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let s of i.observers)s(this.view,t);for(let s of i.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=_d(e),i=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(s.removeEventListener(r,this.handleEvent),l=null),l||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()i.keyCode==e.keyCode))&&!e.ctrlKey||Ud.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:C.safari&&!C.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.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 Dl(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(s){We(t.state,s)}}}function _d(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let s=i.spec;if(s&&s.domEventHandlers)for(let r in s.domEventHandlers){let o=s.domEventHandlers[r];o&&t(r).handlers.push(Dl(i.value,o))}if(s&&s.domEventObservers)for(let r in s.domEventObservers){let o=s.domEventObservers[r];o&&t(r).observers.push(Dl(i.value,o))}}for(let i in He)t(i).handlers.push(He[i]);for(let i in Ie)t(i).observers.push(Ie[i]);return e}const rc=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Ud="dthko",oc=[16,17,18,20,91,92,224,225],wn=6;function kn(n){return Math.max(0,n)*.7+8}function Bd(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class Ld{constructor(e,t,i,s){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=ad(e.contentDOM),this.atoms=e.state.facet(Zo).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(z.allowMultipleSelections)&&Id(e,t),this.dragging=Gd(e,t)&&cc(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Bd(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,s=0,r=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=ic(this.view);e.clientX-o.left<=r.left+wn?i=-kn(r.left-e.clientX):e.clientX+o.right>=r.right-wn&&(i=kn(e.clientX-r.right)),e.clientY-o.top<=r.top+wn?s=-kn(r.top-e.clientY):e.clientY+o.bottom>=r.bottom-wn&&(s=kn(e.clientY-r.bottom)),this.setScrollSpeed(i,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(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;ithis.select(this.lastEvent),20)}}function Id(n,e){let t=n.state.facet(_h);return t.length?t[0](e):C.mac?e.metaKey:e.ctrlKey}function Nd(n,e){let t=n.state.facet(Uh);return t.length?t[0](e):C.mac?!e.altKey:!e.ctrlKey}function Gd(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=ts(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Fd(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=N.get(t))&&i.ignoreEvent(e))return!1;return!0}const He=Object.create(null),Ie=Object.create(null),lc=C.ie&&C.ie_version<15||C.ios&&C.webkit_version<604;function Hd(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),ac(n,t.value)},50)}function ac(n,e){let{state:t}=n,i,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Ur!=null&&t.selection.ranges.every(a=>a.empty)&&Ur==r.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:y.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=r.line(s++);return{changes:{from:a.from,to:a.to,insert:h.text},range:y.cursor(a.from+h.length)}}):i=t.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Ie.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};He.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);Ie.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};Ie.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};He.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(Bh))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=eO(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new Ld(n,e,t,i)),i&&n.observer.ignore(()=>kh(n.contentDOM));let s=n.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}return!1};function ql(n,e,t,i){if(i==1)return y.cursor(e,t);if(i==2)return Wd(n.state,e,t);{let s=oe.find(n.docView,e),r=n.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return ln>=e.top&&n<=e.bottom,zl=(n,e,t)=>hc(e,t)&&n>=t.left&&n<=t.right;function Kd(n,e,t,i){let s=oe.find(n.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(r==0)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&zl(t,i,o))return-1;let l=s.coordsAt(r,1);return l&&zl(t,i,l)?1:o&&hc(i,o)?-1:1}function jl(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:Kd(n,t,e.clientX,e.clientY)}}const Jd=C.ie&&C.ie_version<=11;let El=null,Vl=0,_l=0;function cc(n){if(!Jd)return n.detail;let e=El,t=_l;return El=n,_l=Date.now(),Vl=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(Vl+1)%3:1}function eO(n,e){let t=jl(n,e),i=cc(e),s=n.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,l){let a=jl(n,r),h,c=ql(n,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let f=ql(n,t.pos,t.bias,i),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u1&&(h=tO(s,a.pos))?h:l?s.addRange(c):y.create([c])}}}function tO(n,e){for(let t=0;t=e)return y.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}He.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let s=n.docView.nearest(e.target);if(s&&s.isWidget){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=y.range(r,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",n.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove"),!1};He.dragend=n=>(n.inputState.draggedContent=null,!1);function Ul(n,e,t,i){if(!t)return;let s=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=n.inputState,o=i&&r&&Nd(n,e)?{from:r.from,to:r.to}:null,l={from:s,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}He.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),s=0,r=()=>{++s==t.length&&Ul(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Ul(n,e,i,!0),!0}return!1};He.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=lc?null:e.clipboardData;return t?(ac(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Hd(n),!1)};function iO(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function nO(n){let e=[],t=[],i=!1;for(let s of n.selection.ranges)s.empty||(e.push(n.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}let Ur=null;He.copy=He.cut=(n,e)=>{let{text:t,ranges:i,linewise:s}=nO(n.state);if(!t&&!s)return!1;Ur=s?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=lc?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(iO(n,t),!1)};const fc=bt.define();function uc(n,e){let t=[];for(let i of n.facet(Nh)){let s=i(n,e);s&&t.push(s)}return t?n.update({effects:t,annotations:fc.of(!0)}):null}function dc(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=uc(n.state,e);t?n.dispatch(t):n.update([])}},10)}Ie.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),dc(n)};Ie.blur=n=>{n.observer.clearSelectionRange(),dc(n)};Ie.compositionstart=Ie.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};Ie.compositionend=n=>{n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,C.chrome&&C.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};Ie.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};He.beforeinput=(n,e)=>{var t;let i;if(C.chrome&&C.android&&(i=rc.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var r;(((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return C.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),C.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>Ie.compositionend(n,e),20),!1};const Bl=new Set;function sO(n){Bl.has(n)||(Bl.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const Ll=["pre-wrap","normal","pre-line","break-spaces"];class rO{constructor(e){this.lineWrapping=e,this.doc=_.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}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 Ll.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>In&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return Te.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let r=this,o=i.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=s[l],u=r.lineAt(a,K.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:r.lineAt(h,K.ByPosNoHeight,i,0,0);for(f+=d.to-h,h=d.to;l>0&&u.from<=s[l-1].toA;)a=s[l-1].fromA,c=s[l-1].fromB,l--,ar*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),i+=1+l.break,s-=l.size}else if(r>s*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(s=r&&o(this.blockAt(0,i,s,r))}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(e,s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ee extends Oc{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,s){return new ot(s,this.length,i,this.height,this.breaks)}replace(e,t,i){let s=i[0];return i.length==1&&(s instanceof Ee||s instanceof ue&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof ue?s=new Ee(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):Te.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setHeight(e,s.heights[s.index++]):(i||this.outdated)&&this.setHeight(e,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:""})`}}class ue extends Te{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:s,perLine:o,perChar:l}}blockAt(e,t,i,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let h=s+(e0){let r=i[i.length-1];r instanceof ue?i[i.length-1]=new ue(r.length+s):i.push(null,new ue(s-1))}if(e>0){let r=i[0];r instanceof ue?i[0]=new ue(e+r.length):i.unshift(new ue(e-1),null)}return Te.of(i)}decomposeLeft(e,t){t.push(new ue(e-1),null)}decomposeRight(e,t){t.push(null,new ue(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1;for(s.from>t&&o.push(new ue(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=s.heights[s.index++];a==-1?a=f:Math.abs(f-a)>=In&&(a=-2);let u=new Ee(c,f);u.outdated=!1,o.push(u),l+=c+1}l<=r&&o.push(null,new ue(r-l).updateHeight(e,l));let h=Te.of(o);return(a<0||Math.abs(h.height-this.height)>=In||Math.abs(a-this.heightMetrics(e,t).perLine)>=In)&&(e.heightChanged=!0),h}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class lO extends Te{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,s){let r=i+this.left.height;return el))return h;let c=t==K.ByPosNoHeight?K.ByPosNoHeight:K.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,s,r).join(h)}forEachLine(e,t,i,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,K.ByPos,i,s,r);e=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let s=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&Il(r,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e2*t.size||t.size>2*e.size?Te.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=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,i=!1,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,i,s):r.updateHeight(e,t,i),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,i,s):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Il(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof ue&&(i=n[e+1])instanceof ue&&n.splice(e-1,3,new ue(t.length+1+i.length))}const aO=5;class Co{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 i=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Ee?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Ee(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=aO)&&this.addLineDeco(s,r,o)}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 Ee(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new ue(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ee)return e;let t=new Ee(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,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ee)&&!this.isCovered?this.nodes.push(new Ee(0,-1)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=h==n.parentNode?u.bottom:Math.min(a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function uO(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Ns{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new rO(t),this.stateDeco=e.facet(Fi).filter(i=>typeof i!="function"),this.heightMap=Te.empty().applyChanges(this.stateDeco,_.empty,this.heightOracle.setDoc(e.doc),[new Le(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=T.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new Pn(r,o))}}this.viewports=e.sort((i,s)=>i.from-s.from),this.scaler=this.heightMap.height<=7e6?Gl:new mO(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:Di(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Fi).filter(c=>typeof c!="function");let s=e.changedRanges,r=Le.extendWithRanges(s,hO(i,this.stateDeco,e?e.changes:le.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=o&&(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 a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),h&&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(Fh)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?J.RTL:J.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:Q,scaleY:S}=wh(t,l);(Q>.005&&Math.abs(this.scaleX-Q)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=Q,this.scaleY=S,h|=8,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=vh(e.scrollDOM);let O=(this.printing?uO:fO)(t,this.paddingTop),p=O.top-this.pixelViewport.top,m=O.bottom-this.pixelViewport.bottom;this.pixelViewport=O;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let x=l.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let Q=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(Q)&&(o=!0),o||s.lineWrapping&&Math.abs(x-this.contentDOMWidth)>s.charWidth){let{lineHeight:S,charWidth:v,textHeight:w}=e.docView.measureTextSize();o=S>0&&s.refresh(r,S,v,w,x/v,Q),o&&(e.docView.minWidth=0,h|=8)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),s.heightChanged=!1;for(let S of this.viewports){let v=S.from==this.viewport.from?Q:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?Te.empty().applyChanges(this.stateDeco,_.empty,this.heightOracle,[new Le(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new oO(S.from,v))}s.heightChanged&&(h|=2)}let P=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return P&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(h&2||P)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Pn(s.lineAt(o-i*1e3,K.ByHeight,r,0,0).from,s.lineAt(l+(1-i)*1e3,K.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(ha.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=s.lineAt(h,K.ByPos,r,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h=l+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r>1,o=s<<1;if(this.defaultTextDirection!=J.LTR&&!i)return[];let l=[],a=(h,c,f,u)=>{if(c-hh&&mm.from>=f.from&&m.to<=f.to&&Math.abs(m.from-h)m.fromb));if(!p){if(cm.from<=c&&m.to>=c)){let m=t.moveToLineBoundary(y.cursor(c),!1,!0).head;m>h&&(c=m)}p=new Ns(h,c,this.gapSize(f,h,c,u))}l.push(p)};for(let h of this.viewportLines){if(h.lengthh.from&&a(h.from,u,h,c),dt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];V.spans(e,this.viewport.from,this.viewport.to,{span(s,r){t.push({from:s,to:r})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((s,r)=>s.from!=t[r].from||s.to!=t[r].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Di(this.heightMap.lineAt(e,K.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return Di(this.heightMap.lineAt(this.scaler.fromDOM(e),K.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 Di(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}}class Pn{constructor(e,t){this.from=e,this.to=t}}function OO(n,e,t){let i=[],s=n,r=0;return V.spans(t,n,e,{span(){},point(o,l){o>s&&(i.push({from:s,to:o}),r+=o-s),s=l}},20),s=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(i<=l)return r+i;i-=l}}function $n(n,e){let t=0;for(let{from:i,to:s}of n.ranges){if(e<=s){t+=e-i;break}t+=s-i}return t/n.total}function pO(n,e){for(let t of n)if(e(t))return t}const Gl={toDOM(n){return n},fromDOM(n){return n},scale:1};class mO{constructor(e,t,i){let s=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,K.ByPos,e,0,0).top,c=t.lineAt(a,K.ByPos,e,0,0).bottom;return s+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,s=0;;t++){let r=tDi(s,e)):n._content)}const Zn=Z.define({combine:n=>n.join(" ")}),Br=Z.define({combine:n=>n.indexOf(!0)>-1}),Lr=Rt.newName(),pc=Rt.newName(),mc=Rt.newName(),gc={"&light":"."+pc,"&dark":"."+mc};function Ir(n,e,t){return new Rt(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):n+" "+i}})}const gO=Ir("."+Lr,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},gc),qi="￿";class bO{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(z.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=qi}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let s=e;;){this.findPointBefore(i,s);let r=this.text.length;this.readNode(s);let o=s.nextSibling;if(o==t)break;let l=N.get(s),a=N.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:is(s))||is(o)&&(s.nodeName!="BR"||s.cmIgnore)&&this.text.length>r)&&this.lineBreak(),s=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=s.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){if(e.cmIgnore)return;let t=N.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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 i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(yO(e,i.node,i.offset)?t:0))}}function yO(n,e,t){for(;;){if(!e||t-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=r||o?[]:wO(e),a=new bO(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=kO(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!Rr(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Rr(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),c=e.viewport;if((C.ios||C.chrome)&&e.state.selection.main.empty&&a!=h&&(c.from>0||c.toDate.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=s.from,h=null;(r===8||C.android&&e.text.length=s.from&&t.to<=s.to&&(t.from!=s.from||t.to!=s.to)&&s.to-s.from-(t.to-t.from)<=4?t={from:s.from,to:s.to,insert:n.state.doc.slice(s.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,s.to))}:(C.mac||C.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=y.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:_.of([" "])}):C.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==` `&&n.lineWrapping&&(i&&(i=y.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:_.of([" "])}),t){if(C.ios&&n.inputState.flushIOSKey(t)||C.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&n.state.sliceDoc(t.from,s.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&ci(n.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&t.insert.length==0||r==8&&t.insert.lengths.head)&&ci(n.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&t.insert.length==0&&ci(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let l,a=()=>l||(l=SO(n,t,i));return n.state.facet(Ih).some(h=>h(n,t.from,t.to,o,a))||n.dispatch(a()),!0}else if(i&&!i.main.eq(s)){let o=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),l=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function SO(n,e,t){let i,s=n.state,r=s.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=r.frome.to?s.sliceDoc(e.to,r.to):"";i=s.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+a))}else{let l=s.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(s.selection.ranges.length>1&&n.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let h=n.state.sliceDoc(e.from,e.to),c,f=t&&nc(n,t.main.head);if(f){let O=e.insert.length-(e.to-e.from);c={from:f.from,to:f.to-O}}else c=n.state.doc.lineAt(r.head);let u=r.to-e.to,d=r.to-r.from;i=s.changeByRange(O=>{if(O.from==r.from&&O.to==r.to)return{changes:l,range:a||O.map(l)};let p=O.to-u,m=p-h.length;if(O.to-O.from!=d||n.state.sliceDoc(m,p)!=h||O.to>=c.from&&O.from<=c.to)return{range:O};let b=s.changes({from:m,to:p,insert:e.insert}),x=O.to-r.to;return{changes:b,range:a?y.range(Math.max(0,a.anchor+x),Math.max(0,a.head+x)):O.map(b)}})}else i={changes:l,selection:a&&s.selection.replaceRange(a)}}let o="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,o+=".compose",n.inputState.compositionFirstChange&&(o+=".start",n.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:o,scrollIntoView:!0})}function QO(n,e,t,i){let s=Math.min(n.length,e.length),r=0;for(;r0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function wO(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new Fl(t,i)),(s!=t||r!=i)&&e.push(new Fl(s,r))),e}function kO(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?y.single(t+e,i+e):null}const PO={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Gs=C.ie&&C.ie_version<=11;class vO{constructor(e){this.view=e,this.active=!1,this.selectionRange=new hd,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 i of t)this.queue.push(i);(C.ie&&C.ie_version<=11||C.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Gs&&(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.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){e.type=="change"&&!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,i)=>t!=e[i]))){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:i}=this,s=this.selectionRange;if(i.state.facet(vs)?i.root.activeElement!=this.dom:!Bn(i.dom,s))return;let r=s.anchorNode&&i.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(C.ie&&C.ie_version<=11||C.android&&C.chrome)&&!i.state.selection.main.empty&&s.focusNode&&_i(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=ts(e.root);if(!t)return!1;let i=C.safari&&e.root.nodeType==11&&rd(this.dom.ownerDocument)==this.dom&&$O(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let s=Bn(this.dom,i);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&ci(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!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,i=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:s}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),s=this.selectionChanged&&Bn(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new xO(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}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 i=this.view.state,s=bc(this.view,t);return this.view.state==i&&this.view.update([]),s}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 i=Hl(t,e.previousSibling||e.target.previousSibling,-1),s=Hl(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):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("change",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("change",this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Hl(n,e,t){for(;e;){let i=N.get(e);if(i&&i.parent==n)return i;let s=e.parentNode;e=s!=n.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function Kl(n,e){let t=e.startContainer,i=e.startOffset,s=e.endContainer,r=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor);return _i(o.node,o.offset,s,r)&&([t,i,s,r]=[s,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}}function $O(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Kl(n,s)}let t=null;function i(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Kl(n,t):null}class ${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={}){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:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(i=>i.forEach(s=>t(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||cd(e.parent)||document,this.viewState=new Nl(e.state||z.create(e)),e.scrollTo&&e.scrollTo.is(Qn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Xi).map(i=>new Bs(i));for(let i of this.plugins)i.update(this);this.observer=new vO(this),this.inputState=new Vd(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Tl(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let t=e.length==1&&e[0]instanceof se?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,i=!1,s,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(fc))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=uc(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(z.phrases)!=this.state.facet(z.phrases))return this.setState(r);s=ns.create(this,r,e),s.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;f=new fi(d.empty?d:y.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(Qn)&&(f=d.value.clip(this.state))}this.viewState.update(s,f),this.bidiCache=ss.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(Yi)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Zn)!=s.state.facet(Zn)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let u of this.state.facet(Er))try{u(s)}catch(d){We(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!bc(this,c)&&h.force&&ci(this.contentDOM,h.key,h.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 i of this.plugins)i.destroy(this);this.viewState=new Nl(e),this.plugins=e.facet(Xi).map(i=>new Bs(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Tl(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(Xi),i=e.state.facet(Xi);if(t!=i){let s=[];for(let r of i){let o=t.indexOf(r);if(o<0)s.push(new Bs(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-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,i=this.scrollDOM,s=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(vh(i))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);r=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!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 h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(d=>{try{return d.read(this)}catch(O){return We(this.state,O),Jl}}),f=ns.create(this,this.state,[]),u=!1;f.flags|=a,t?t.flags|=a:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f),u&&this.docViewUpdate());for(let d=0;d1||O<-1){s=s+O,i.scrollTop=s/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Er))l(t)}get themeClasses(){return Lr+" "+(this.state.facet(Br)?mc:pc)+" "+this.state.facet(Zn)}updateAttrs(){let e=ea(this,Kh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(vs)?"true":"false",class:"cm-content",style:`${C.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),ea(this,$o,t);let i=this.observer.ignore(()=>{let s=Yr(this.contentDOM,this.contentAttrs,t),r=Yr(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let s of i.effects)if(s.is($.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Yi);let e=this.state.facet($.cspNonce);Rt.mount(this.root,this.styleModules.concat(gO).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;ti.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,i){return Is(this,e,Yl(this,e,t,i))}moveByGroup(e,t){return Is(this,e,Yl(this,e,t,i=>jd(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return y.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,i=!0){return zd(this,e,t,i)}moveVertically(e,t,i){return Is(this,e,Ed(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),sc(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(e),r=this.bidiSpans(s),o=r[vt.find(r,e-s.from,-1,t)];return ks(i,o.dir==J.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(Gh)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ZO)return Eh(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||jh(r.isolates,i=Cl(this,e))))return r.order;i||(i=Cl(this,e));let s=wd(e.text,t,i);return this.bidiCache.push(new ss(e.from,e.to,t,i,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||C.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{kh(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(){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 Qn.of(new fi(typeof e=="number"?y.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Qn.of(new fi(y.cursor(i.from),"start","start",i.top-e,t,!0))}static domEventHandlers(e){return ne.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ne.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Rt.newName(),s=[Zn.of(i),Yi.of(Ir(`.${i}`,e))];return t&&t.dark&&s.push(Br.of(!0)),s}static baseTheme(e){return Yt.lowest(Yi.of(Ir("."+Lr,e,gc)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&N.get(i)||N.get(e);return((t=s==null?void 0:s.rootView)===null||t===void 0?void 0:t.view)||null}}$.styleModule=Yi;$.inputHandler=Ih;$.scrollHandler=Hh;$.focusChangeEffect=Nh;$.perLineTextDirection=Gh;$.exceptionSink=Lh;$.updateListener=Er;$.editable=vs;$.mouseSelectionStyle=Bh;$.dragMovesSelection=Uh;$.clickAddsSelectionRange=_h;$.decorations=Fi;$.outerDecorations=Jh;$.atomicRanges=Zo;$.bidiIsolatedRanges=ec;$.scrollMargins=tc;$.darkTheme=Br;$.cspNonce=Z.define({combine:n=>n.length?n[0]:""});$.contentAttributes=$o;$.editorAttributes=Kh;$.lineWrapping=$.contentAttributes.of({class:"cm-lineWrapping"});$.announce=W.define();const ZO=4096,Jl={};class ss{constructor(e,t,i,s,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],s=e.length?e[e.length-1].dir:J.LTR;for(let r=Math.max(0,e.length-10);r=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&Xr(o,t)}return t}const CO=C.mac?"mac":C.windows?"win":C.linux?"linux":"key";function TO(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let s,r,o,l;for(let a=0;ai.concat(s),[]))),t}function AO(n,e,t){return xc(yc(n.state),e,n,t)}let wt=null;const MO=4e3;function WO(n,e=CO){let t=Object.create(null),i=Object.create(null),s=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,h,c)=>{var f,u;let d=t[o]||(t[o]=Object.create(null)),O=l.split(/ (?!$)/).map(b=>TO(b,e));for(let b=1;b{let Q=wt={view:P,prefix:x,scope:o};return setTimeout(()=>{wt==Q&&(wt=null)},MO),!0}]})}let p=O.join(" ");s(p,!1);let m=d[p]||(d[p]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&m.run.push(a),h&&(m.preventDefault=!0),c&&(m.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let f in c)c[f].run.push(o.any)}let a=o[e]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}function xc(n,e,t,i){let s=sd(e),r=de(s,0),o=Ue(r)==s.length&&s!=" ",l="",a=!1,h=!1,c=!1;wt&&wt.view==t&&wt.scope==i&&(l=wt.prefix+" ",oc.indexOf(e.keyCode)<0&&(h=!0,wt=null));let f=new Set,u=m=>{if(m){for(let b of m.run)if(!f.has(b)&&(f.add(b),b(t,e)))return m.stopPropagation&&(c=!0),!0;m.preventDefault&&(m.stopPropagation&&(c=!0),h=!0)}return!1},d=n[i],O,p;return d&&(u(d[l+Cn(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(C.windows&&e.ctrlKey&&e.altKey)&&(O=At[e.keyCode])&&O!=s?(u(d[l+Cn(O,e,!0)])||e.shiftKey&&(p=Gi[e.keyCode])!=s&&p!=O&&u(d[l+Cn(p,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+Cn(s,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),a}class dn{constructor(e,t,i,s,r){this.className=e,this.left=t,this.top=i,this.width=s,this.height=r}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,i){if(i.empty){let s=e.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let r=Sc(e);return[new dn(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return XO(e,t,i)}}function Sc(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==J.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function ia(n,e,t){let i=y.cursor(e);return{from:Math.max(t.from,n.moveToLineBoundary(i,!1,!0).from),to:Math.min(t.to,n.moveToLineBoundary(i,!0,!0).from),type:Ce.Text}}function XO(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),s=Math.min(t.to,n.viewport.to),r=n.textDirection==J.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=Sc(n),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),d=_r(n,i),O=_r(n,s),p=d.type==Ce.Text?d:null,m=O.type==Ce.Text?O:null;if(p&&(n.lineWrapping||d.widgetLineBreaks)&&(p=ia(n,i,p)),m&&(n.lineWrapping||O.widgetLineBreaks)&&(m=ia(n,s,m)),p&&m&&p.from==m.from)return x(P(t.from,t.to,p));{let S=p?P(t.from,null,p):Q(d,!1),v=m?P(null,t.to,m):Q(O,!0),w=[];return(p||d).to<(m||O).from-(p&&m?1:0)||d.widgetLineBreaks>1&&S.bottom+n.defaultLineHeight/2D&&E.from=be)break;G>H&&Y(Math.max(A,H),S==null&&A<=D,Math.min(G,be),v==null&&G>=L,R.dir)}if(H=ye.to+1,H>=be)break}return q.length==0&&Y(D,S==null,L,v==null,n.textDirection),{top:M,bottom:X,horizontal:q}}function Q(S,v){let w=l.top+(v?S.top:S.bottom);return{top:w,bottom:w,horizontal:[]}}}function YO(n,e){return n.constructor==e.constructor&&n.eq(e)}class DO{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(Nn)!=e.state.facet(Nn)&&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,i=e.facet(Nn);for(;t!YO(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[i].constructor&&s.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Nn=Z.define();function Qc(n){return[ne.define(e=>new DO(e,n)),Nn.of(n)]}const wc=!C.ios,Hi=Z.define({combine(n){return ft(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function qO(n={}){return[Hi.of(n),zO,jO,EO,Fh.of(!0)]}function kc(n){return n.startState.facet(Hi)!=n.state.facet(Hi)}const zO=Qc({above:!0,markers(n){let{state:e}=n,t=e.facet(Hi),i=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty?!r||wc:t.drawRangeCursor){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=s.empty?s:y.cursor(s.head,s.head>s.anchor?-1:1);for(let a of dn.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=kc(n);return t&&na(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){na(e.state,n)},class:"cm-cursorLayer"});function na(n,e){e.style.animationDuration=n.facet(Hi).cursorBlinkRate+"ms"}const jO=Qc({above:!1,markers(n){return n.state.selection.ranges.map(e=>e.empty?[]:dn.forRange(n,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||kc(n)},class:"cm-selectionLayer"}),Nr={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};wc&&(Nr[".cm-line"].caretColor="transparent !important",Nr[".cm-content"]={caretColor:"transparent !important"});const EO=Yt.highest($.theme(Nr)),Pc=W.define({map(n,e){return n==null?null:e.mapPos(n)}}),zi=fe.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(Pc)?i.value:t,n)}}),VO=ne.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(zi);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"),(n.startState.field(zi)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(zi),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(zi)!=n&&this.view.dispatch({effects:Pc.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function _O(){return[zi,VO]}function sa(n,e,t,i,s){e.lastIndex=0;for(let r=n.iterRange(t,i),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,l)}function UO(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:s,to:r}of t)s=Math.max(n.state.doc.lineAt(s).from,s-e),r=Math.min(n.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}class BO{constructor(e){const{regexp:t,decoration:i,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(l,a,h,c)=>s(c,h,h+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,h,c)=>{let f=i(l,a,h);f&&c(h,h+l[0].length,f)};else if(i)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new Tt,i=t.add.bind(t);for(let{from:s,to:r}of UO(e,this.maxLength))sa(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>e.view.viewport.from&&l1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),i,s):t}updateRange(e,t,i,s){for(let r of e.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,s);if(l>o){let a=e.state.doc.lineAt(o),h=a.toa.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;lu.push(b.range(p,m));if(a==h)for(this.regexp.lastIndex=c-a.from;(d=this.regexp.exec(a.text))&&d.indexthis.addMatch(m,e,p,O));t=t.update({filterFrom:c,filterTo:f,filter:(p,m)=>pf,add:u})}}return t}}const Gr=/x/.unicode!=null?"gu":"g",LO=new RegExp(`[\0-\b --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Gr),IO={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Fs=null;function NO(){var n;if(Fs==null&&typeof document<"u"&&document.body){let e=document.body.style;Fs=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Fs||!1}const Gn=Z.define({combine(n){let e=ft(n,{render:null,specialChars:LO,addSpecialChars:null});return(e.replaceTabs=!NO())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Gr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Gr)),e}});function GO(n={}){return[Gn.of(n),FO()]}let ra=null;function FO(){return ra||(ra=ne.fromClass(class{constructor(n){this.view=n,this.decorations=T.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Gn)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new BO({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=de(e[0],0);if(r==9){let o=s.lineAt(i),l=t.state.tabSize,a=Qi(o.text,l,i-o.from);return T.replace({widget:new ep((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=T.replace({widget:new JO(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Gn);n.startState.facet(Gn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const HO="•";function KO(n){return n>=32?HO:n==10?"␤":String.fromCharCode(9216+n)}class JO extends ut{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=KO(this.code),i=e.state.phrase("Control character")+" "+(IO[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class ep extends ut{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}}function tp(){return np}const ip=T.line({class:"cm-activeLine"}),np=ne.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let s=n.lineBlockAt(i.head);s.from>e&&(t.push(ip.range(s.from)),e=s.from)}return T.set(t)}},{decorations:n=>n.decorations});class sp extends ut{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}coordsAt(e){let t=e.firstChild?mi(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),s=ks(t[0],i.direction!="rtl"),r=parseInt(i.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}}function rp(n){return ne.fromClass(class{constructor(e){this.view=e,this.placeholder=n?T.set([T.widget({widget:new sp(n),side:1}).range(0)]):T.none}get decorations(){return this.view.state.doc.length?T.none:this.placeholder}},{decorations:e=>e.decorations})}const Fr=2e3;function op(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>Fr||t.off>Fr||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=s;a++){let h=n.doc.line(a);h.length<=l&&r.push(y.range(h.from+o,h.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=s;a++){let h=n.doc.line(a),c=Zr(h.text,o,n.tabSize,!0);if(c<0)r.push(y.cursor(h.to));else{let f=Zr(h.text,l,n.tabSize);r.push(y.range(h.from+c,h.from+f))}}}return r}function lp(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function oa(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>Fr?-1:s==i.length?lp(n,e.clientX):Qi(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function ap(n,e){let t=oa(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let l=oa(n,s);if(!l)return i;let a=op(n.state,t,l);return a.length?o?y.create(a.concat(i.ranges)):y.create(a):i}}:null}function hp(n){let e=(n==null?void 0:n.eventFilter)||(t=>t.altKey&&t.button==0);return $.mouseSelectionStyle.of((t,i)=>e(i)?ap(t,i):null)}const cp={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},fp={style:"cursor: crosshair"};function up(n={}){let[e,t]=cp[n.key||"Alt"],i=ne.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[i,$.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?fp:null})]}const Ti="-10000px";class vc{constructor(e,t,i,s){this.facet=t,this.createTooltipView=i,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(e,t){var i;let s=e.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;at[h]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function dp(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const Hs=Z.define({combine:n=>{var e,t,i;return{position:C.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||dp}}}),la=new WeakMap,To=ne.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Hs);this.position=e.position,this.parent=e.parent,this.classes=n.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 vc(n,Ro,(t,i)=>this.createTooltip(t,i),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(),n.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 n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Hs);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=Ti,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);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 n=this.view.dom.getBoundingClientRect(),e=1,t=1,i=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(C.gecko)i=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==Ti&&s.style.left=="0px"){let r=s.getBoundingClientRect();i=Math.abs(r.top+1e4)>1||Math.abs(r.left)>1}}if(i||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(e=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((s,r)=>{let o=this.manager.tooltipViews[r];return o.getCoords?o.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Hs).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{editor:t,space:i,scaleX:s,scaleY:r}=n,o=[];for(let l=0;l=Math.min(t.bottom,i.bottom)||f.rightMath.min(t.right,i.right)+.1){c.style.top=Ti;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,O=d?7:0,p=u.right-u.left,m=(e=la.get(h))!==null&&e!==void 0?e:u.bottom-u.top,b=h.offset||pp,x=this.view.textDirection==J.LTR,P=u.width>i.right-i.left?x?i.left:i.right-u.width:x?Math.min(f.left-(d?14:0)+b.x,i.right-p):Math.max(i.left,f.left-p+(d?14:0)-b.x),Q=this.above[l];!a.strictSide&&(Q?f.top-(u.bottom-u.top)-b.yi.bottom)&&Q==i.bottom-f.bottom>f.top-i.top&&(Q=this.above[l]=!Q);let S=(Q?f.top-i.top:i.bottom-f.bottom)-O;if(SP&&M.topv&&(v=Q?M.top-m-2-O:M.bottom+O+2);if(this.position=="absolute"?(c.style.top=(v-n.parent.top)/r+"px",c.style.left=(P-n.parent.left)/s+"px"):(c.style.top=v/r+"px",c.style.left=P/s+"px"),d){let M=f.left+(x?b.x:-b.x)-(P+14-7);d.style.left=M/s+"px"}h.overlap!==!0&&o.push({left:P,top:v,right:w,bottom:v+m}),c.classList.toggle("cm-tooltip-above",Q),c.classList.toggle("cm-tooltip-below",!Q),h.positioned&&h.positioned(n.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 n of this.manager.tooltipViews)n.dom.style.top=Ti}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Op=$.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"}}}),pp={x:0,y:0},Ro=Z.define({enables:[To,Op]}),rs=Z.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class $s{static create(e){return new $s(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new vc(e,rs,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}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 i of this.manager.tooltipViews){let s=i[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)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")}}const mp=Ro.compute([rs],n=>{let e=n.facet(rs);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:$s.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class gp{constructor(e,t,i,s,r){this.view=e,this.source=t,this.field=i,this.setHover=s,this.hoverTime=r,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 a=e.bidiSpans(e.state.doc.lineAt(s)).find(c=>c.from<=s&&c.to>=s),h=a&&a.dir==J.RTL?-1:1;r=t.x{this.pending==l&&(this.pending=null,a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>We(e.state,a,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(To),t=e?e.manager.tooltips.findIndex(i=>i.create==$s.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;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:s,tooltip:r}=this;if(s.length&&r&&!bp(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(i=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!yp(this.view,o,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:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(i.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)}}const Tn=4;function bp(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-Tn&&e.clientX<=t.right+Tn&&e.clientY>=t.top-Tn&&e.clientY<=t.bottom+Tn}function yp(n,e,t,i,s,r){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.rights||Math.min(o.bottom,l)=e&&a<=t}function xp(n,e={}){let t=W.define(),i=fe.define({create(){return[]},update(s,r){if(s.length&&(e.hideOnChange&&(r.docChanged||r.selection)?s=[]:e.hideOn&&(s=s.filter(o=>!e.hideOn(r,o))),r.docChanged)){let o=[];for(let l of s){let a=r.changes.mapPos(l.pos,-1,pe.TrackDel);if(a!=null){let h=Object.assign(Object.create(null),l);h.pos=a,h.end!=null&&(h.end=r.changes.mapPos(h.end)),o.push(h)}}s=o}for(let o of r.effects)o.is(t)&&(s=o.value),o.is(Sp)&&(s=[]);return s},provide:s=>rs.from(s)});return[i,ne.define(s=>new gp(s,n,i,t,e.hoverTime||300)),mp]}function $c(n,e){let t=n.plugin(To);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const Sp=W.define(),aa=Z.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Ki(n,e){let t=n.plugin(Zc),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Zc=ne.fromClass(class{constructor(n){this.input=n.state.facet(Ji),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(aa);this.top=new Rn(n,!0,e.topContainer),this.bottom=new Rn(n,!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(n){let e=n.state.facet(aa);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Rn(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Rn(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Ji);if(t!=this.input){let i=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(n.view),l.push(c)):(c=this.panels[h],c.update&&c.update(n)),s.push(c),(c.top?r:o).push(c)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>$.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Rn{constructor(e,t,i){this.view=e,this.top=t,this.container=i,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=ha(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=ha(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 ha(n){let e=n.nextSibling;return n.remove(),e}const Ji=Z.define({enables:Zc});class gt extends Gt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}gt.prototype.elementClass="";gt.prototype.toDOM=void 0;gt.prototype.mapMode=pe.TrackBefore;gt.prototype.startSide=gt.prototype.endSide=-1;gt.prototype.point=!0;const Fn=Z.define(),Qp={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>V.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Bi=Z.define();function wp(n){return[Cc(),Bi.of(Object.assign(Object.assign({},Qp),n))]}const Hr=Z.define({combine:n=>n.some(e=>e)});function Cc(n){let e=[kp];return n&&n.fixed===!1&&e.push(Hr.of(!0)),e}const kp=ne.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.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=n.state.facet(Bi).map(e=>new fa(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(Hr),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(Hr)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=V.iter(this.view.state.facet(Fn),this.view.viewport.from),i=[],s=this.gutters.map(r=>new Pp(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==Ce.Text&&o){Kr(t,i,l.from);for(let a of s)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==Ce.Text){Kr(t,i,r.from);for(let o of s)o.line(this.view,r,i)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(Bi),t=n.state.facet(Bi),i=n.docChanged||n.heightChanged||n.viewportChanged||!V.eq(n.startState.facet(Fn),n.state.facet(Fn),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new fa(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>$.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==J.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function ca(n){return Array.isArray(n)?n:[n]}function Kr(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class Pp{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=V.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let l=new Tc(e,o,r,i);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];Kr(this.cursor,s,t.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t);i&&this.addElement(e,t,[i])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class fa{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 i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,s)&&s.preventDefault()});this.markers=ca(t.markers(e)),t.initialSpacer&&(this.spacer=new Tc(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=ca(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!V.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Tc{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),vp(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=rr(l,a,h)||o(l,a,h):o}return i}})}});class Ks extends gt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Js(n,e){return n.state.facet(ri).formatNumber(e,n.state)}const Zp=Bi.compute([ri],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet($p)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new Ks(Js(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(ri)!=e.state.facet(ri),initialSpacer(e){return new Ks(Js(e,ua(e.state.doc.lines)))},updateSpacer(e,t){let i=Js(t.view,ua(t.view.state.doc.lines));return i==e.number?e:new Ks(i)},domEventHandlers:n.facet(ri).domEventHandlers}));function Cp(n={}){return[ri.of(n),Cc(),Zp]}function ua(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head).from;s>t&&(t=s,e.push(Tp.range(s)))}return V.of(e)});function Ap(){return Rp}const Rc=1024;let Mp=0;class er{constructor(e,t){this.from=e,this.to=t}}class j{constructor(e={}){this.id=Mp++,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=De.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}j.closedBy=new j({deserialize:n=>n.split(" ")});j.openedBy=new j({deserialize:n=>n.split(" ")});j.group=new j({deserialize:n=>n.split(" ")});j.isolate=new j({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});j.contextHash=new j({perNode:!0});j.lookAhead=new j({perNode:!0});j.mounted=new j({perNode:!0});class os{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[j.mounted.id]}}const Wp=Object.create(null);class De{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):Wp,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new De(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}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(j.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let s of i.split(" "))t[s]=e[i];return i=>{for(let s=i.prop(j.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?i.name:s[r]];if(o)return o}}}}De.none=new De("",Object.create(null),0,8);class Ao{constructor(e){this.types=e;for(let t=0;t0;for(let a=this.cursor(o|ae.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!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:Xo(De.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,s)=>new re(this.type,t,i,s,this.propValues),e.makeTree||((t,i,s)=>new re(De.none,t,i,s)))}static build(e){return qp(e)}}re.empty=new re(De.none,[],[],0);class Mo{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 Mo(this.buffer,this.index)}}class Wt{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return De.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,i){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function en(n,e,t,i){for(var s;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from;if(Ac(s,i,f,f+c.length)){if(c instanceof Wt){if(r&ae.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,i-f,s);if(u>-1)return new lt(new Xp(o,c,e,f),null,u)}else if(r&ae.IncludeAnonymous||!c.type.isAnonymous||Wo(c)){let u;if(!(r&ae.IgnoreMounts)&&(u=os.get(c))&&!u.overlay)return new Ye(u.tree,f,e,o);let d=new Ye(c,f,e,o);return r&ae.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?c.children.length-1:0,t,i,s)}}}if(r&ae.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let s;if(!(i&ae.IgnoreOverlays)&&(s=os.get(this._tree))&&s.overlay){let r=e-this.from;for(let{from:o,to:l}of s.overlay)if((t>0?o<=r:o=r:l>r))return new Ye(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}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 Oa(n,e,t,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=s.type.is(t),!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function Jr(n,e,t=e.length-1){for(let i=n.parent;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class Xp{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class lt extends Mc{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,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new lt(this.context,this,r)}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,i=0){if(i&ae.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new lt(this.context,this,r)}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 lt(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 lt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];e.push(i.slice(s,r,o)),t.push(0)}return new re(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Wc(n){if(!n.length)return null;let e=0,t=n[0];for(let r=1;rt.from||o.to=e){let l=new Ye(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[i])).push(en(l,e,t,!1))}}return s?Wc(s):i}class eo{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 Ye)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.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:i,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return e?e instanceof Ye?(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,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}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,i=this.mode){return this.buffer?i&ae.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ae.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ae.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,i=this.stack.length-1;if(e<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<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,i,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&ae.IncludeAnonymous||l instanceof Wt||!l.type.isAnonymous||Wo(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 o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,i=r+1;break e}s=this.stack[--r]}for(let s=i;s=0;r--){if(r<0)return Jr(this.node,e,s);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function Wo(n){return n.children.some(e=>e instanceof Wt||!e.type.isAnonymous||Wo(e))}function qp(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:s=Rc,reused:r=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Mo(t,t.length):t,a=i.types,h=0,c=0;function f(S,v,w,M,X,q){let{id:Y,start:D,end:L,size:E}=l,H=c;for(;E<0;)if(l.next(),E==-1){let G=r[Y];w.push(G),M.push(D-S);return}else if(E==-3){h=Y;return}else if(E==-4){c=Y;return}else throw new RangeError(`Unrecognized record size: ${E}`);let be=a[Y],ye,R,A=D-S;if(L-D<=s&&(R=m(l.pos-v,X))){let G=new Uint16Array(R.size-R.skip),we=l.pos-R.size,ke=G.length;for(;l.pos>we;)ke=b(R.start,G,ke);ye=new Wt(G,L-R.start,i),A=R.start-S}else{let G=l.pos-E;l.next();let we=[],ke=[],Je=Y>=o?Y:-1,Pe=0,qt=L;for(;l.pos>G;)Je>=0&&l.id==Je&&l.size>=0?(l.end<=qt-s&&(O(we,ke,D,Pe,l.end,qt,Je,H),Pe=we.length,qt=l.end),l.next()):q>2500?u(D,G,we,ke):f(D,G,we,ke,Je,q+1);if(Je>=0&&Pe>0&&Pe-1&&Pe>0){let ei=d(be);ye=Xo(be,we,ke,0,we.length,0,L-D,ei,ei)}else ye=p(be,we,ke,L-D,H-L)}w.push(ye),M.push(A)}function u(S,v,w,M){let X=[],q=0,Y=-1;for(;l.pos>v;){let{id:D,start:L,end:E,size:H}=l;if(H>4)l.next();else{if(Y>-1&&L=0;E-=3)D[H++]=X[E],D[H++]=X[E+1]-L,D[H++]=X[E+2]-L,D[H++]=H;w.push(new Wt(D,X[2]-L,i)),M.push(L-S)}}function d(S){return(v,w,M)=>{let X=0,q=v.length-1,Y,D;if(q>=0&&(Y=v[q])instanceof re){if(!q&&Y.type==S&&Y.length==M)return Y;(D=Y.prop(j.lookAhead))&&(X=w[q]+Y.length+D)}return p(S,v,w,M,X)}}function O(S,v,w,M,X,q,Y,D){let L=[],E=[];for(;S.length>M;)L.push(S.pop()),E.push(v.pop()+w-X);S.push(p(i.types[Y],L,E,q-X,D-q)),v.push(X-w)}function p(S,v,w,M,X=0,q){if(h){let Y=[j.contextHash,h];q=q?[Y].concat(q):[Y]}if(X>25){let Y=[j.lookAhead,X];q=q?[Y].concat(q):[Y]}return new re(S,v,w,M,q)}function m(S,v){let w=l.fork(),M=0,X=0,q=0,Y=w.end-s,D={size:0,start:0,skip:0};e:for(let L=w.pos-S;w.pos>L;){let E=w.size;if(w.id==v&&E>=0){D.size=M,D.start=X,D.skip=q,q+=4,M+=4,w.next();continue}let H=w.pos-E;if(E<0||H=o?4:0,ye=w.start;for(w.next();w.pos>H;){if(w.size<0)if(w.size==-3)be+=4;else break e;else w.id>=o&&(be+=4);w.next()}X=ye,M+=E,q+=be}return(v<0||M==S)&&(D.size=M,D.start=X,D.skip=q),D.size>4?D:void 0}function b(S,v,w){let{id:M,start:X,end:q,size:Y}=l;if(l.next(),Y>=0&&M4){let L=l.pos-(Y-4);for(;l.pos>L;)w=b(S,v,w)}v[--w]=D,v[--w]=q-S,v[--w]=X-S,v[--w]=M}else Y==-3?h=M:Y==-4&&(c=M);return w}let x=[],P=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,x,P,-1,0);let Q=(e=n.length)!==null&&e!==void 0?e:x.length?P[0]+x[0].length:0;return new re(a[n.topID],x.reverse(),P.reverse(),Q)}const pa=new WeakMap;function Hn(n,e){if(!n.isAnonymous||e instanceof Wt||e.type!=n)return 1;let t=pa.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof re)){t=1;break}t+=Hn(n,i)}pa.set(e,t)}return t}function Xo(n,e,t,i,s,r,o,l,a){let h=0;for(let O=i;O=c)break;v+=w}if(P==Q+1){if(v>c){let w=O[Q];d(w.children,w.positions,0,w.children.length,p[Q]+x);continue}f.push(O[Q])}else{let w=p[P-1]+O[P-1].length-S;f.push(Xo(n,O,p,Q,P,S,w,null,a))}u.push(S+x-r)}}return d(e,t,i,s,0),(l||a)(f,u,o)}class zp{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof lt?this.setBuffer(e.context.buffer,e.index,t):e instanceof Ye&&this.map.set(e.tree,t)}get(e){return e instanceof lt?this.getBuffer(e.context.buffer,e.index):e instanceof Ye?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class It{constructor(e,t,i,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let s=[new It(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l=i)for(;o&&o.from=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,O=Math.min(u.to,f)-h;u=d>=O?null:new It(d,O,u.tree,u.offset+h,l>0,!!c)}if(u&&s.push(u),o.to>f)break;o=rnew er(s.from,s.to)):[new er(0,0)]:[new er(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let r=s.advance();if(r)return r}}}class jp{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new j({perNode:!0});let Ep=0;class st{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=Ep++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new st([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new ls;return t=>t.modified.indexOf(e)>-1?t:ls.get(t.base||t,t.modified.concat(e).sort((i,s)=>i.id-s.id))}}let Vp=0;class ls{constructor(){this.instances=[],this.id=Vp++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&_p(t,l.modified));if(i)return i;let s=[],r=new st(s,e,t);for(let l of t)l.instances.push(r);let o=Up(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(ls.get(l,a));return r}}function _p(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function Up(n){let e=[[]];for(let t=0;ti.length-t.length)}function Yo(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let f=0;;){if(l=="..."&&f>0&&f+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==s.length)break;let d=s[f++];if(f==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(f)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+s);let c=new as(i,o,a>0?r.slice(0,a):null);e[h]=c.sort(e[h])}}return Yc.add(e)}const Yc=new j;class as{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=s;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Bp(n,e){let t=null;for(let i of n){let s=i.style(e);s&&(t=t?t+" "+s:s)}return t}function Lp(n,e,t,i=0,s=n.length){let r=new Ip(i,Array.isArray(e)?e:[e],t);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}class Ip{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,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,i,s,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=s,c=Np(e)||as.empty,f=Bp(r,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(s+=(s?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(j.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),O=this.highlighters.filter(m=>!m.scope||m.scope(u.tree.type)),p=e.firstChild();for(let m=0,b=l;;m++){let x=m=P||!e.nextSibling())););if(!x||P>i)break;b=x.to+l,b>t&&(this.highlightRange(d.cursor(),Math.max(t,x.from+l),Math.min(i,b),"",O),this.startSpan(Math.min(i,b),h))}p&&e.parent()}else if(e.firstChild()){u&&(s="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function Np(n){let e=n.type.prop(Yc);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const k=st.define,Mn=k(),St=k(),ma=k(St),ga=k(St),Qt=k(),Wn=k(Qt),tr=k(Qt),nt=k(),Et=k(nt),tt=k(),it=k(),to=k(),Ri=k(to),Xn=k(),g={comment:Mn,lineComment:k(Mn),blockComment:k(Mn),docComment:k(Mn),name:St,variableName:k(St),typeName:ma,tagName:k(ma),propertyName:ga,attributeName:k(ga),className:k(St),labelName:k(St),namespace:k(St),macroName:k(St),literal:Qt,string:Wn,docString:k(Wn),character:k(Wn),attributeValue:k(Wn),number:tr,integer:k(tr),float:k(tr),bool:k(Qt),regexp:k(Qt),escape:k(Qt),color:k(Qt),url:k(Qt),keyword:tt,self:k(tt),null:k(tt),atom:k(tt),unit:k(tt),modifier:k(tt),operatorKeyword:k(tt),controlKeyword:k(tt),definitionKeyword:k(tt),moduleKeyword:k(tt),operator:it,derefOperator:k(it),arithmeticOperator:k(it),logicOperator:k(it),bitwiseOperator:k(it),compareOperator:k(it),updateOperator:k(it),definitionOperator:k(it),typeOperator:k(it),controlOperator:k(it),punctuation:to,separator:k(to),bracket:Ri,angleBracket:k(Ri),squareBracket:k(Ri),paren:k(Ri),brace:k(Ri),content:nt,heading:Et,heading1:k(Et),heading2:k(Et),heading3:k(Et),heading4:k(Et),heading5:k(Et),heading6:k(Et),contentSeparator:k(nt),list:k(nt),quote:k(nt),emphasis:k(nt),strong:k(nt),link:k(nt),monospace:k(nt),strikethrough:k(nt),inserted:k(),deleted:k(),changed:k(),invalid:k(),meta:Xn,documentMeta:k(Xn),annotation:k(Xn),processingInstruction:k(Xn),definition:st.defineModifier(),constant:st.defineModifier(),function:st.defineModifier(),standard:st.defineModifier(),local:st.defineModifier(),special:st.defineModifier()};Dc([{tag:g.link,class:"tok-link"},{tag:g.heading,class:"tok-heading"},{tag:g.emphasis,class:"tok-emphasis"},{tag:g.strong,class:"tok-strong"},{tag:g.keyword,class:"tok-keyword"},{tag:g.atom,class:"tok-atom"},{tag:g.bool,class:"tok-bool"},{tag:g.url,class:"tok-url"},{tag:g.labelName,class:"tok-labelName"},{tag:g.inserted,class:"tok-inserted"},{tag:g.deleted,class:"tok-deleted"},{tag:g.literal,class:"tok-literal"},{tag:g.string,class:"tok-string"},{tag:g.number,class:"tok-number"},{tag:[g.regexp,g.escape,g.special(g.string)],class:"tok-string2"},{tag:g.variableName,class:"tok-variableName"},{tag:g.local(g.variableName),class:"tok-variableName tok-local"},{tag:g.definition(g.variableName),class:"tok-variableName tok-definition"},{tag:g.special(g.variableName),class:"tok-variableName2"},{tag:g.definition(g.propertyName),class:"tok-propertyName tok-definition"},{tag:g.typeName,class:"tok-typeName"},{tag:g.namespace,class:"tok-namespace"},{tag:g.className,class:"tok-className"},{tag:g.macroName,class:"tok-macroName"},{tag:g.propertyName,class:"tok-propertyName"},{tag:g.operator,class:"tok-operator"},{tag:g.comment,class:"tok-comment"},{tag:g.meta,class:"tok-meta"},{tag:g.invalid,class:"tok-invalid"},{tag:g.punctuation,class:"tok-punctuation"}]);var ir;const oi=new j;function qc(n){return Z.define({combine:n?e=>e.concat(n):void 0})}const Do=new j;class Ge{constructor(e,t,i=[],s=""){this.data=e,this.name=s,z.prototype.hasOwnProperty("tree")||Object.defineProperty(z.prototype,"tree",{get(){return he(this)}}),this.parser=t,this.extension=[Xt.of(this),z.languageData.of((r,o,l)=>{let a=ba(r,o,l),h=a.type.prop(oi);if(!h)return[];let c=r.facet(h),f=a.type.prop(Do);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,r)){let O=r.facet(d.facet);return d.type=="replace"?O:O.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return ba(e,t,i).type.prop(oi)==this.data}findRegions(e){let t=e.facet(Xt);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(oi)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(j.mounted);if(l){if(l.tree.prop(oi)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;ai.isTop?t:void 0)]}),e.name)}configure(e,t){return new tn(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function he(n){let e=n.field(Ge.state,!1);return e?e.tree:re.empty}class Gp{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 i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let Ai=null;class hs{constructor(e,t,i=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new hs(e,t,[],re.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Gp(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=re.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}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(It.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Ai;Ai=this;try{return e()}finally{Ai=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ya(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=It.applyChanges(i,a),s=re.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);ce.from&&(this.fragments=ya(this.fragments,s,r),this.skipped.splice(i--,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 Xc{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=Ai;if(a){for(let h of s)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new re(De.none,[],[],o-r)},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 Ai}}function ya(n,e,t){return It.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class yi{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),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new yi(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=hs.create(e.facet(Xt).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new yi(i)}}Ge.state=fe.define({create:yi.init,update(n,e){for(let t of e.effects)if(t.is(Ge.setState))return t.value;return e.startState.facet(Xt)!=e.state.facet(Xt)?yi.init(e.state):n.apply(e)}});let zc=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(zc=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:500-100})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const nr=typeof navigator<"u"&&(!((ir=navigator.scheduling)===null||ir===void 0)&&ir.isInputPending)?()=>navigator.scheduling.isInputPending():null,Fp=ne.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(Ge.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(Ge.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=zc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnds+1e3,a=r.context.work(()=>nr&&nr()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Ge.setState.of(new yi(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>We(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()}}}),Xt=Z.define({combine(n){return n.length?n[0]:null},enables:n=>[Ge.state,Fp,$.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class jc{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Hp=Z.define(),On=Z.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function cs(n){let e=n.facet(On);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function nn(n,e){let t="",i=n.tabSize,s=n.facet(On)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let r=0;r=e?Kp(n,t,e):null}class Zs{constructor(e,t={}){this.state=e,this.options=t,this.unit=cs(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return Qi(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const zo=new j;function Kp(n,e,t){let i=e.resolveStack(t),s=i.node.enterUnfinishedNodesBefore(t);if(s!=i.node){let r=[];for(let o=s;o!=i.node;o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return Ec(i,n,t)}function Ec(n,e,t){for(let i=n;i;i=i.next){let s=em(i.node);if(s)return s(jo.create(e,t,i))}return 0}function Jp(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function em(n){let e=n.type.prop(zo);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(j.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>Vc(o,!0,1,void 0,r&&!Jp(o)?s.from:void 0)}return n.parent==null?tm:null}function tm(){return 0}class jo extends Zs{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new jo(e,t,i)}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 i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(im(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Ec(this.context.next,this.base,this.pos)}}function im(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function nm(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped)return a.fromVc(i,e,t,n)}function Vc(n,e,t,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||s==n.pos+o,a=e?nm(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}const rm=n=>n.baseIndent;function Li({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const om=200;function lm(){return z.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+om)return n;let r=t.sliceString(s.from,i);if(!e.some(h=>h.test(r)))return n;let{state:o}=n,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=qo(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=nn(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const am=Z.define(),Eo=new j;function _c(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(r&&l.from=e&&h.to>t&&(r=h)}}return r}function cm(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function fs(n,e,t){for(let i of n.facet(am)){let s=i(n,e,t);if(s)return s}return hm(n,e,t)}function Uc(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const Cs=W.define({map:Uc}),pn=W.define({map:Uc});function Bc(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const Jt=fe.define({create(){return T.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)if(t.is(Cs)&&!fm(n,t.value.from,t.value.to)){let{preparePlaceholder:i}=e.state.facet(Vo),s=i?T.replace({widget:new bm(i(e.state,t.value))}):xa;n=n.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(pn)&&(n=n.update({filter:(i,s)=>t.value.from!=i||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;n.between(i,i,(s,r)=>{si&&(t=!0)}),t&&(n=n.update({filterFrom:i,filterTo:i,filter:(s,r)=>r<=i||s>=i}))}return n},provide:n=>$.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{(!s||s.from>r)&&(s={from:r,to:o})}),s}function fm(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function Lc(n,e){return n.field(Jt,!1)?e:e.concat(W.appendConfig.of(Nc()))}const um=n=>{for(let e of Bc(n)){let t=fs(n.state,e.from,e.to);if(t)return n.dispatch({effects:Lc(n.state,[Cs.of(t),Ic(n,t)])}),!0}return!1},dm=n=>{if(!n.state.field(Jt,!1))return!1;let e=[];for(let t of Bc(n)){let i=us(n.state,t.from,t.to);i&&e.push(pn.of(i),Ic(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function Ic(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return $.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}const Om=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(Jt,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push(pn.of({from:i,to:s}))}),n.dispatch({effects:t}),!0},mm=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:um},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:dm},{key:"Ctrl-Alt-[",run:Om},{key:"Ctrl-Alt-]",run:pm}],gm={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Vo=Z.define({combine(n){return ft(n,gm)}});function Nc(n){let e=[Jt,Sm];return n&&e.push(Vo.of(n)),e}function Gc(n,e){let{state:t}=n,i=t.facet(Vo),s=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=us(n.state,l.from,l.to);a&&n.dispatch({effects:pn.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,s,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const xa=T.replace({widget:new class extends ut{toDOM(n){return Gc(n,null)}}});class bm extends ut{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Gc(e,this.value)}}const ym={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class sr extends gt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function xm(n={}){let e=Object.assign(Object.assign({},ym),n),t=new sr(e,!0),i=new sr(e,!1),s=ne.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Xt)!=o.state.facet(Xt)||o.startState.field(Jt,!1)!=o.state.field(Jt,!1)||he(o.startState)!=he(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Tt;for(let a of o.viewportLineBlocks){let h=us(o.state,a.from,a.to)?i:fs(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:r}=e;return[s,wp({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||V.empty},initialSpacer(){return new sr(e,!1)},domEventHandlers:Object.assign(Object.assign({},r),{click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let h=us(o.state,l.from,l.to);if(h)return o.dispatch({effects:pn.of(h)}),!0;let c=fs(o.state,l.from,l.to);return c?(o.dispatch({effects:Cs.of(c)}),!0):!1}})}),Nc()]}const Sm=$.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Ts{constructor(e,t){this.specs=e;let i;function s(l){let a=Rt.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof Ge?l=>l.prop(oi)==o.data:o?l=>l==o:void 0,this.style=Dc(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new Rt(i):null,this.themeType=t.themeType}static define(e,t){return new Ts(e,t||{})}}const io=Z.define(),Fc=Z.define({combine(n){return n.length?[n[0]]:null}});function rr(n){let e=n.facet(io);return e.length?e:n.facet(Fc)}function Qm(n,e){let t=[km],i;return n instanceof Ts&&(n.module&&t.push($.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(Fc.of(n)):i?t.push(io.computeN([$.darkTheme],s=>s.facet($.darkTheme)==(i=="dark")?[n]:[])):t.push(io.of(n)),t}class wm{constructor(e){this.markCache=Object.create(null),this.tree=he(e.state),this.decorations=this.buildDeco(e,rr(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=he(e.state),i=rr(e.state),s=i!=rr(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return T.none;let i=new Tt;for(let{from:s,to:r}of e.visibleRanges)Lp(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=T.mark({class:a})))},s,r);return i.finish()}}const km=Yt.high(ne.fromClass(wm,{decorations:n=>n.decorations})),Pm=Ts.define([{tag:g.meta,color:"#404740"},{tag:g.link,textDecoration:"underline"},{tag:g.heading,textDecoration:"underline",fontWeight:"bold"},{tag:g.emphasis,fontStyle:"italic"},{tag:g.strong,fontWeight:"bold"},{tag:g.strikethrough,textDecoration:"line-through"},{tag:g.keyword,color:"#708"},{tag:[g.atom,g.bool,g.url,g.contentSeparator,g.labelName],color:"#219"},{tag:[g.literal,g.inserted],color:"#164"},{tag:[g.string,g.deleted],color:"#a11"},{tag:[g.regexp,g.escape,g.special(g.string)],color:"#e40"},{tag:g.definition(g.variableName),color:"#00f"},{tag:g.local(g.variableName),color:"#30a"},{tag:[g.typeName,g.namespace],color:"#085"},{tag:g.className,color:"#167"},{tag:[g.special(g.variableName),g.macroName],color:"#256"},{tag:g.definition(g.propertyName),color:"#00c"},{tag:g.comment,color:"#940"},{tag:g.invalid,color:"#f00"}]),vm=$.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Hc=1e4,Kc="()[]{}",Jc=Z.define({combine(n){return ft(n,{afterCursor:!0,brackets:Kc,maxScanDistance:Hc,renderMatch:Cm})}}),$m=T.mark({class:"cm-matchingBracket"}),Zm=T.mark({class:"cm-nonmatchingBracket"});function Cm(n){let e=[],t=n.matched?$m:Zm;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}const Tm=fe.define({create(){return T.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(Jc);for(let s of e.state.selection.ranges){if(!s.empty)continue;let r=at(e.state,s.head,-1,i)||s.head>0&&at(e.state,s.head-1,1,i)||i.afterCursor&&(at(e.state,s.head,1,i)||s.head$.decorations.from(n)}),Rm=[Tm,vm];function Am(n={}){return[Jc.of(n),Rm]}const Mm=new j;function no(n,e,t){let i=n.prop(e<0?j.openedBy:j.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function so(n){let e=n.type.prop(Mm);return e?e(n.node):n}function at(n,e,t,i={}){let s=i.maxScanDistance||Hc,r=i.brackets||Kc,o=he(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=no(a.type,t,r);if(h&&a.from0?e>=c.from&&ec.from&&e<=c.to))return Wm(n,e,t,a,c,h,r)}}return Xm(n,e,t,o,l.type,s,r)}function Wm(n,e,t,i,s,r,o){let l=i.parent,a={from:s.from,to:s.to},h=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&r.indexOf(c.type.name)>-1&&c.from0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=r;){let d=c.value;t<0&&(u+=d.length);let O=e+u*t;for(let p=t>0?0:d.length-1,m=t>0?d.length:-1;p!=m;p+=t){let b=o.indexOf(d[p]);if(!(b<0||i.resolveInner(O+p,1).type!=s))if(b%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:O+p,to:O+p+1},matched:b>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}const Ym=Object.create(null),Sa=[De.none],Qa=[],wa=Object.create(null),Dm=Object.create(null);for(let[n,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"]])Dm[n]=qm(Ym,e);function or(n,e){Qa.indexOf(n)>-1||(Qa.push(n),console.warn(e))}function qm(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||g[h];c?typeof c=="function"?a.length?a=a.map(c):or(h,`Modifier ${h} used at start of tag`):a.length?or(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:or(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+t.map(l=>l.id),r=wa[s];if(r)return r.id;let o=wa[s]=De.define({id:Sa.length,name:i,props:[Yo({[i]:t})]});return Sa.push(o),o.id}J.RTL,J.LTR;const zm=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Uo(n.state,t.from);return i.line?jm(n):i.block?Vm(n):!1};function _o(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const jm=_o(Bm,0),Em=_o(ef,0),Vm=_o((n,e)=>ef(n,e,Um(e)),0);function Uo(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const Mi=50;function _m(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-Mi,i),o=n.sliceDoc(s,s+Mi),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let c,f;s-i<=2*Mi?c=f=n.sliceDoc(i,s):(c=n.sliceDoc(i,i+Mi),f=n.sliceDoc(s-Mi,s));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,O=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(O,O+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(f.charAt(O-1))?1:0}}:null}function Um(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to),r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function ef(n,e,t=e.selection.ranges){let i=t.map(r=>Uo(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>_m(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;os&&(r==o||o>f.from)){s=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,O=f.text.slice(u,u+h.length)==h?u:-1;ur.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,r.push({from:h,to:c})}return{changes:r}}return null}const ro=bt.define(),Lm=bt.define(),Im=Z.define(),tf=Z.define({combine(n){return ft(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),nf=fe.define({create(){return ht.empty},update(n,e){let t=e.state.facet(tf),i=e.annotation(ro);if(i){let a=Xe.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=ds(c,c.length,t.minDepth,a):c=of(c,e.startState.selection),new ht(h==0?i.rest:c,h==0?c:i.rest)}let s=e.annotation(Lm);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(se.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=Xe.fromTransaction(e),o=e.annotation(se.time),l=e.annotation(se.userEvent);return r?n=n.addChanges(r,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new ht(n.done.map(Xe.fromJSON),n.undone.map(Xe.fromJSON))}});function Nm(n={}){return[nf,tf.of(n),$.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?sf:e.inputType=="historyRedo"?oo:null;return i?(e.preventDefault(),i(t)):!1}})]}function Rs(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(nf,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const sf=Rs(0,!1),oo=Rs(1,!1),Gm=Rs(0,!0),Fm=Rs(1,!0);class Xe{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new Xe(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;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:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new Xe(e.changes&&le.fromJSON(e.changes),[],e.mapped&&ct.fromJSON(e.mapped),e.startSelection&&y.fromJSON(e.startSelection),e.selectionsAfter.map(y.fromJSON))}static fromTransaction(e,t){let i=Be;for(let s of e.startState.facet(Im)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new Xe(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Be)}static selection(e){return new Xe(void 0,Be,void 0,void 0,e)}}function ds(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function Hm(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a=h&&o<=c&&(i=!0)}}),i}function Km(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function rf(n,e){return n.length?e.length?n.concat(e):n:e}const Be=[],Jm=200;function of(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Jm));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),ds(n,n.length-1,1e9,t.setSelAfter(i)))}else return[Xe.selection([e])]}function eg(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function lr(n,e){if(!n.length)return n;let t=n.length,i=Be;for(;t;){let s=tg(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[Xe.selection(i)]:Be}function tg(n,e,t){let i=rf(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Be,t);if(!n.changes)return Xe.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new Xe(s,W.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const ig=/^(input\.type|delete)($|\.)/;class ht{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new ht(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||ig.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):As(t,e))}function Qe(n){return n.textDirectionAt(n.state.selection.main.head)==J.LTR}const af=n=>lf(n,!Qe(n)),hf=n=>lf(n,Qe(n));function cf(n,e){return Ke(n,t=>t.empty?n.moveByGroup(t,e):As(t,e))}const sg=n=>cf(n,!Qe(n)),rg=n=>cf(n,Qe(n));function og(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Ms(n,e,t){let i=he(n).resolveInner(e.head),s=t?j.closedBy:j.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;og(n,h,s)?i=h:a=t?h.to:h.from}let r=i.type.prop(s),o,l;return r&&(o=t?at(n,i.from,1):at(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,y.cursor(l,t?-1:1)}const lg=n=>Ke(n,e=>Ms(n.state,e,!Qe(n))),ag=n=>Ke(n,e=>Ms(n.state,e,Qe(n)));function ff(n,e){return Ke(n,t=>{if(!t.empty)return As(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const uf=n=>ff(n,!1),df=n=>ff(n,!0);function Of(n){let e=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,e,t.height):As(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottompf(n,!1),lo=n=>pf(n,!0);function Dt(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=y.cursor(i.from+r))}return s}const hg=n=>Ke(n,e=>Dt(n,e,!0)),cg=n=>Ke(n,e=>Dt(n,e,!1)),fg=n=>Ke(n,e=>Dt(n,e,!Qe(n))),ug=n=>Ke(n,e=>Dt(n,e,Qe(n))),dg=n=>Ke(n,e=>y.cursor(n.lineBlockAt(e.head).from,1)),Og=n=>Ke(n,e=>y.cursor(n.lineBlockAt(e.head).to,-1));function pg(n,e,t){let i=!1,s=wi(n.selection,r=>{let o=at(n,r.head,-1)||at(n,r.head,1)||r.head>0&&at(n,r.head-1,1)||r.headpg(n,e,!1);function Ne(n,e){let t=wi(n.state.selection,i=>{let s=e(i);return y.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(dt(n.state,t)),!0)}function mf(n,e){return Ne(n,t=>n.moveByChar(t,e))}const gf=n=>mf(n,!Qe(n)),bf=n=>mf(n,Qe(n));function yf(n,e){return Ne(n,t=>n.moveByGroup(t,e))}const gg=n=>yf(n,!Qe(n)),bg=n=>yf(n,Qe(n)),yg=n=>Ne(n,e=>Ms(n.state,e,!Qe(n))),xg=n=>Ne(n,e=>Ms(n.state,e,Qe(n)));function xf(n,e){return Ne(n,t=>n.moveVertically(t,e))}const Sf=n=>xf(n,!1),Qf=n=>xf(n,!0);function wf(n,e){return Ne(n,t=>n.moveVertically(t,e,Of(n).height))}const Pa=n=>wf(n,!1),va=n=>wf(n,!0),Sg=n=>Ne(n,e=>Dt(n,e,!0)),Qg=n=>Ne(n,e=>Dt(n,e,!1)),wg=n=>Ne(n,e=>Dt(n,e,!Qe(n))),kg=n=>Ne(n,e=>Dt(n,e,Qe(n))),Pg=n=>Ne(n,e=>y.cursor(n.lineBlockAt(e.head).from)),vg=n=>Ne(n,e=>y.cursor(n.lineBlockAt(e.head).to)),$a=({state:n,dispatch:e})=>(e(dt(n,{anchor:0})),!0),Za=({state:n,dispatch:e})=>(e(dt(n,{anchor:n.doc.length})),!0),Ca=({state:n,dispatch:e})=>(e(dt(n,{anchor:n.selection.main.anchor,head:0})),!0),Ta=({state:n,dispatch:e})=>(e(dt(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),$g=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Zg=({state:n,dispatch:e})=>{let t=Ws(n).map(({from:i,to:s})=>y.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:y.create(t),userEvent:"select"})),!0},Cg=({state:n,dispatch:e})=>{let t=wi(n.selection,i=>{var s;let r=he(n).resolveStack(i.from,1);for(let o=r;o;o=o.next){let{node:l}=o;if((l.from=i.to||l.to>i.to&&l.from<=i.from)&&(!((s=l.parent)===null||s===void 0)&&s.parent))return y.range(l.to,l.from)}return i});return e(dt(n,t)),!0},Tg=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=y.create([t.main]):t.main.empty||(i=y.create([y.cursor(t.main.head)])),i?(e(dt(n,i)),!0):!1};function mn(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);ao&&(t="delete.forward",a=Yn(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Yn(n,o,!1),l=Yn(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:y.cursor(o,os(n)))i.between(e,e,(s,r)=>{se&&(e=t?r:s)});return e}const kf=(n,e,t)=>mn(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&skf(n,!1,!0),Pf=n=>kf(n,!0,!1),vf=(n,e)=>mn(n,t=>{let i=t.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=ge(r.text,i-r.from,e)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),$f=n=>vf(n,!1),Rg=n=>vf(n,!0),Ag=n=>mn(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headmn(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Wg=n=>mn(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:_.of(["",""])},range:y.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Yg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:ge(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:ge(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:y.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ws(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function Zf(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of Ws(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(y.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(y.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:y.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Dg=({state:n,dispatch:e})=>Zf(n,e,!1),qg=({state:n,dispatch:e})=>Zf(n,e,!0);function Cf(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of Ws(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const zg=({state:n,dispatch:e})=>Cf(n,e,!1),jg=({state:n,dispatch:e})=>Cf(n,e,!0),Eg=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Ws(e).map(({from:s,to:r})=>(s>0?s--:r{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),l=n.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Vg(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=he(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(j.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const _g=Tf(!1),Ug=Tf(!0);function Tf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&Vg(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new Zs(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=qo(h,r);for(c==null&&(c=Qi(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));ol.from&&r{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:y.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Bg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Zs(n,{overrideIndentation:r=>{let o=t[r];return o==null?-1:o}}),s=Bo(n,(r,o,l)=>{let a=qo(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],c=nn(n,a);(h!=c||l.fromn.readOnly?!1:(e(n.update(Bo(n,(t,i)=>{i.push({from:t.from,insert:n.facet(On)})}),{userEvent:"input.indent"})),!0),Af=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Bo(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=Qi(s,n.tabSize),o=0,l=nn(n,Math.max(0,r-cs(n)));for(;o({mac:n.key,run:n.run,shift:n.shift}))),Ng=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:lg,shift:yg},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:ag,shift:xg},{key:"Alt-ArrowUp",run:Dg},{key:"Shift-Alt-ArrowUp",run:zg},{key:"Alt-ArrowDown",run:qg},{key:"Shift-Alt-ArrowDown",run:jg},{key:"Escape",run:Tg},{key:"Mod-Enter",run:Ug},{key:"Alt-l",mac:"Ctrl-l",run:Zg},{key:"Mod-i",run:Cg,preventDefault:!0},{key:"Mod-[",run:Af},{key:"Mod-]",run:Rf},{key:"Mod-Alt-\\",run:Bg},{key:"Shift-Mod-k",run:Eg},{key:"Shift-Mod-\\",run:mg},{key:"Mod-/",run:zm},{key:"Alt-A",run:Em}].concat(Ig),Gg={key:"Tab",run:Rf,shift:Af};function F(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;en.normalize("NFKD"):n=>n;class xi{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?l=>r(Ra(l)):Ra,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 de(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=xo(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Ue(e);let s=this.normalize(t);for(let r=0,o=i;;r++){let l=s.charCodeAt(r),a=this.match(l,o,this.bufferPos+this.bufferStart);if(r==s.length-1){if(a)return this.value=a,this;break}o==i&&rthis.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 i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=Os(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||s.to<=t){let l=new ui(t,e.sliceString(t,i));return ar.set(e,l),l}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.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 i=this.flat.from+t.index,s=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,match:t},this.matchPos=Os(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ui.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Xf.prototype[Symbol.iterator]=Yf.prototype[Symbol.iterator]=function(){return this});function Fg(n){try{return new RegExp(n,Lo),!0}catch(e){return!1}}function Os(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}function ho(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=F("input",{class:"cm-textfield",name:"line",value:e}),i=F("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),n.dispatch({effects:ps.of(!1)}),n.focus()):r.keyCode==13&&(r.preventDefault(),s())},onsubmit:r=>{r.preventDefault(),s()}},F("label",n.state.phrase("Go to line"),": ",t)," ",F("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!r)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,h,c,f]=r,u=c?+c.slice(1):0,d=h?+h:l.number;if(h&&f){let m=d/100;a&&(m=m*(a=="-"?-1:1)+l.number/o.doc.lines),d=Math.round(o.doc.lines*m)}else h&&a&&(d=d*(a=="-"?-1:1)+l.number);let O=o.doc.line(Math.max(1,Math.min(o.doc.lines,d))),p=y.cursor(O.from+Math.max(0,Math.min(u,O.length)));n.dispatch({effects:[ps.of(!1),$.scrollIntoView(p.from,{y:"center"})],selection:p}),n.focus()}return{dom:i}}const ps=W.define(),Aa=fe.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(ps)&&(n=t.value);return n},provide:n=>Ji.from(n,e=>e?ho:null)}),Hg=n=>{let e=Ki(n,ho);if(!e){let t=[ps.of(!0)];n.state.field(Aa,!1)==null&&t.push(W.appendConfig.of([Aa,Kg])),n.dispatch({effects:t}),e=Ki(n,ho)}return e&&e.dom.querySelector("input").select(),!0},Kg=$.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Jg={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Df=Z.define({combine(n){return ft(n,Jg,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function e0(n){let e=[r0,s0];return n&&e.push(Df.of(n)),e}const t0=T.mark({class:"cm-selectionMatch"}),i0=T.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Ma(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=ee.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=ee.Word)}function n0(n,e,t,i){return n(e.sliceDoc(t,t+1))==ee.Word&&n(e.sliceDoc(i-1,i))==ee.Word}const s0=ne.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Df),{state:t}=n,i=t.selection;if(i.ranges.length>1)return T.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return T.none;let a=t.wordAt(s.head);if(!a)return T.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a200)return T.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(Ma(o,t,s.from,s.to)&&n0(o,t,s.from,s.to)))return T.none}else if(r=t.sliceDoc(s.from,s.to),!r)return T.none}let l=[];for(let a of n.visibleRanges){let h=new xi(t.doc,r,a.from,a.to);for(;!h.next().done;){let{from:c,to:f}=h.value;if((!o||Ma(o,t,c,f))&&(s.empty&&c<=s.from&&f>=s.to?l.push(i0.range(c,f)):(c>=s.to||f<=s.from)&&l.push(t0.range(c,f)),l.length>e.maxMatches))return T.none}}return T.set(l)}},{decorations:n=>n.decorations}),r0=$.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),o0=({state:n,dispatch:e})=>{let{selection:t}=n,i=y.create(t.ranges.map(s=>n.wordAt(s.head)||y.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function l0(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new xi(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new xi(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const a0=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return o0({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=l0(n,i);return s?(e(n.update({selection:n.selection.addRange(y.range(s.from,s.to),!1),effects:$.scrollIntoView(s.to)})),!0):!1},ki=Z.define({combine(n){return ft(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new x0(e),scrollToMatch:e=>$.scrollIntoView(e)})}});class qf{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||Fg(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?` `:i=="r"?"\r":i=="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 u0(this):new c0(this)}getCursor(e,t=0,i){let s=e.doc?e:z.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?ni(this,s,t,i):ii(this,s,t,i)}}class zf{constructor(e){this.spec=e}}function ii(n,e,t,i){return new xi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase(),n.wholeWord?h0(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function h0(n,e){return(t,i,s,r)=>((r>t||r+s.length=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=ii(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function ni(n,e,t,i){return new Xf(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?f0(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function ms(n,e){return n.slice(ge(n,e,!1),e)}function gs(n,e){return n.slice(e,ge(n,e))}function f0(n){return(e,t,i)=>!i[0].length||(n(ms(i.input,i.index))!=ee.Word||n(gs(i.input,i.index))!=ee.Word)&&(n(gs(i.input,i.index+i[0].length))!=ee.Word||n(ms(i.input,i.index+i[0].length))!=ee.Word)}class u0 extends zf{nextMatch(e,t,i){let s=ni(this.spec,e,i,e.doc.length).next();return s.done&&(s=ni(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=ni(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=ni(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const sn=W.define(),Io=W.define(),Zt=fe.define({create(n){return new hr(co(n).create(),null)},update(n,e){for(let t of e.effects)t.is(sn)?n=new hr(t.value.create(),n.panel):t.is(Io)&&(n=new hr(n.query,t.value?No:null));return n},provide:n=>Ji.from(n,e=>e.panel)});class hr{constructor(e,t){this.query=e,this.panel=t}}const d0=T.mark({class:"cm-searchMatch"}),O0=T.mark({class:"cm-searchMatch cm-searchMatch-selected"}),p0=ne.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Zt))}update(n){let e=n.state.field(Zt);(e!=n.startState.field(Zt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return T.none;let{view:t}=this,i=new Tt;for(let s=0,r=t.visibleRanges,o=r.length;sr[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?O0:d0)})}return i.finish()}},{decorations:n=>n.decorations});function gn(n){return e=>{let t=e.state.field(Zt,!1);return t&&t.query.spec.valid?n(e,t):Vf(e)}}const bs=gn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=y.single(i.from,i.to),r=n.state.facet(ki);return n.dispatch({selection:s,effects:[Go(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Ef(n),!0}),ys=gn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=y.single(s.from,s.to),o=n.state.facet(ki);return n.dispatch({selection:r,effects:[Go(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Ef(n),!0}),m0=gn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:y.create(t.map(i=>y.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),g0=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new xi(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(y.range(l.value.from,l.value.to))}return e(n.update({selection:y.create(r,o),userEvent:"select.search.matches"})),!0},Wa=gn((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=[],l,a,h=[];if(r.from==i&&r.to==s&&(a=t.toText(e.getReplacement(r)),o.push({from:r.from,to:r.to,insert:a}),r=e.nextMatch(t,r.from,r.to),h.push($.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),r){let c=o.length==0||o[0].from>=r.to?0:r.to-r.from-a.length;l=y.single(r.from-c,r.to-c),h.push(Go(n,r)),h.push(t.facet(ki).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),!0}),b0=gn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:$.announce.of(i),userEvent:"input.replace.all"}),!0});function No(n){return n.state.facet(ki).createPanel(n)}function co(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=n.facet(ki);return new qf({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:h.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function jf(n){let e=Ki(n,No);return e&&e.dom.querySelector("[main-field]")}function Ef(n){let e=jf(n);e&&e==n.root.activeElement&&e.select()}const Vf=n=>{let e=n.state.field(Zt,!1);if(e&&e.panel){let t=jf(n);if(t&&t!=n.root.activeElement){let i=co(n.state,e.query.spec);i.valid&&n.dispatch({effects:sn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Io.of(!0),e?sn.of(co(n.state,e.query.spec)):W.appendConfig.of(Q0)]});return!0},_f=n=>{let e=n.state.field(Zt,!1);if(!e||!e.panel)return!1;let t=Ki(n,No);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Io.of(!1)}),!0},y0=[{key:"Mod-f",run:Vf,scope:"editor search-panel"},{key:"F3",run:bs,shift:ys,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:bs,shift:ys,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:_f,scope:"editor search-panel"},{key:"Mod-Shift-l",run:g0},{key:"Mod-Alt-g",run:Hg},{key:"Mod-d",run:a0,preventDefault:!0}];class x0{constructor(e){this.view=e;let t=this.query=e.state.field(Zt).query.spec;this.commit=this.commit.bind(this),this.searchField=F("input",{value:t.search,placeholder:ze(e,"Find"),"aria-label":ze(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=F("input",{value:t.replace,placeholder:ze(e,"Replace"),"aria-label":ze(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=F("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=F("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=F("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return F("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=F("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>bs(e),[ze(e,"next")]),i("prev",()=>ys(e),[ze(e,"previous")]),i("select",()=>m0(e),[ze(e,"all")]),F("label",null,[this.caseField,ze(e,"match case")]),F("label",null,[this.reField,ze(e,"regexp")]),F("label",null,[this.wordField,ze(e,"by word")]),...e.state.readOnly?[]:[F("br"),this.replaceField,i("replace",()=>Wa(e),[ze(e,"replace")]),i("replaceAll",()=>b0(e),[ze(e,"replace all")])],F("button",{name:"close",onclick:()=>_f(e),"aria-label":ze(e,"close"),type:"button"},["×"])])}commit(){let e=new qf({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:sn.of(e)}))}keydown(e){AO(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ys:bs)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Wa(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(sn)&&!i.value.eq(this.query)&&this.setQuery(i.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(ki).top}}function ze(n,e){return n.state.phrase(e)}const Dn=30,qn=/[\s\.,:;?!]/;function Go(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-Dn),o=Math.min(s,t+Dn),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;al.length-Dn;a--)if(!qn.test(l[a-1])&&qn.test(l[a])){l=l.slice(0,a);break}}return $.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const S0=$.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"}}),Q0=[Zt,Yt.low(p0),S0];class Uf{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=he(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),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(Lf(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}}function Xa(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function w0(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;rtypeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:w0(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function k0(n,e){return t=>{for(let i=he(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class Ya{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function Ct(n){return n.selection.main.from}function Lf(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const Fo=bt.define();function P0(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return Object.assign(Object.assign({},n.changeByRange(l=>l!=s&&t!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(t,i)?{range:l}:{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:e},range:y.cursor(l.from+r+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const Da=new WeakMap;function v0(n){if(!Array.isArray(n))return n;let e=Da.get(n);return e||Da.set(n,e=Bf(n)),e}const xs=W.define(),rn=W.define();class $0{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&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(v=xo(S))!=v.toLowerCase()?1:v!=v.toUpperCase()?2:0;(!x||w==1&&m||Q==0&&w!=0)&&(t[f]==S||i[f]==S&&(u=!0)?o[f++]=x:o.length&&(b=!1)),Q=w,x+=Ue(S)}return f==a&&o[0]==0&&b?this.result(-100+(u?-200:0),o,e):d==a&&O==0?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-200+-700-e.length,[O,p]):f==a?this.result(-100+(u?-200:0)+-700+(b?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let l=o+(this.astral?Ue(de(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-i.length,s)}}class Z0{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:C0,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)=>i=>qa(e(i),t(i)),optionClass:(e,t)=>i=>qa(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function qa(n,e){return n?e?n+" "+e:n:e}function C0(n,e,t,i,s,r){let o=n.textDirection==J.RTL,l=o,a=!1,h="top",c,f,u=e.left-s.left,d=s.right-e.right,O=i.right-i.left,p=i.bottom-i.top;if(l&&u=p||x>e.top?c=t.bottom-e.top:(h="bottom",c=e.bottom-t.top)}let m=(e.bottom-e.top)/r.offsetHeight,b=(e.right-e.left)/r.offsetWidth;return{style:`${h}: ${c/m}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function T0(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;ha&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,f))),u.className="cm-completionMatchedText",a=f}return at.position-i.position).map(t=>t.render)}function cr(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class R0{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(me);this.optionContent=T0(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=cr(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=e.state.field(t).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(me).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:rn.of(null)})}),this.showOptions(r,s.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 i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=cr(r.length,o,e.state.facet(me).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=s.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 i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);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=cr(t.options.length,t.selected,this.view.state.facet(me).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,i)}).catch(o=>We(this.view.state,o,"completion info")):this.addInfoPane(r,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&M0(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.defaultView||window;r={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottomi.from||i.from==0))if(r=u,typeof h!="string"&&h.header)s.appendChild(h.header(h));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}const c=s.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.tonew R0(t,n,e)}function M0(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function za(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function W0(n,e){let t=[],i=null,s=h=>{t.push(h);let{section:c}=h.completion;if(c){i||(i=[]);let f=typeof c=="string"?c:c.name;i.some(u=>u.name==f)||i.push(typeof c=="string"?{name:f}:c)}},r=e.facet(me);for(let h of n)if(h.hasResult()){let c=h.result.getMatch;if(h.result.filter===!1)for(let f of h.result.options)s(new Ya(f,h.source,c?c(f):[],1e9-t.length));else{let f=e.sliceDoc(h.from,h.to),u,d=r.filterStrict?new Z0(f):new $0(f);for(let O of h.result.options)if(u=d.match(O.label)){let p=O.displayLabel?c?c(O,u.matched):[]:u.matched;s(new Ya(O,h.source,p,u.score+(O.boost||0)))}}}if(i){let h=Object.create(null),c=0,f=(u,d)=>{var O,p;return((O=u.rank)!==null&&O!==void 0?O:1e9)-((p=d.rank)!==null&&p!==void 0?p:1e9)||(u.namef.score-c.score||a(c.completion,f.completion))){let c=h.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?o.push(h):za(h.completion)>za(l)&&(o[o.length-1]=h),l=h.completion}return o}class li{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new li(this.options,ja(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r){let o=W0(e,t);if(!o.length)return s&&e.some(a=>a.state==1)?new li(s.options,s.attrs,s.tooltip,s.timestamp,s.selected,!0):null;let l=t.facet(me).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let a=s.options[s.selected].completion;for(let h=0;hh.hasResult()?Math.min(a,h.from):a,1e8),create:z0,above:r.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(e){return new li(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class Ss{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Ss(D0,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(me),r=(i.override||t.languageDataAt("autocomplete",Ct(t)).map(v0)).map(l=>(this.active.find(h=>h.source==l)||new $e(l,this.active.some(h=>h.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((l,a)=>l==this.active[a])&&(r=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!X0(r,this.active)?o=li.build(r,t,this.id,o,i):o&&o.disabled&&!r.some(l=>l.state==1)&&(o=null),!o&&r.every(l=>l.state!=1)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new $e(l.source,0):l));for(let l of e.effects)l.is(Nf)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new Ss(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:Y0}}function X0(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const D0=[];function fo(n,e){if(n.isUserEvent("input.complete")){let t=n.annotation(Fo);if(t&&e.activateOnCompletion(t))return"input"}return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}class $e{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=fo(e,t),s=this;i?s=s.handleUserEvent(e,i,t):e.docChanged?s=s.handleChange(e):e.selection&&s.state!=0&&(s=new $e(s.source,0));for(let r of e.effects)if(r.is(xs))s=new $e(s.source,1,r.value?Ct(e.state):-1);else if(r.is(rn))s=new $e(s.source,0);else if(r.is(If))for(let o of r.value)o.source==s.source&&(s=o);return s}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new $e(this.source,1)}handleChange(e){return e.changes.touchesRange(Ct(e.startState))?new $e(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new $e(this.source,this.state,e.mapPos(this.explicitPos))}}class di extends $e{constructor(e,t,i,s,r){super(e,2,t),this.result=i,this.from=s,this.to=r}hasResult(){return!0}handleUserEvent(e,t,i){var s;let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let o=e.changes.mapPos(this.from),l=e.changes.mapPos(this.to,1),a=Ct(e.state);if((this.explicitPos<0?a<=o:al||!r||t=="delete"&&Ct(e.startState)==this.from)return new $e(this.source,t=="input"&&i.activateOnTyping?1:0);let h=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return q0(r.validFor,e.state,o,l)?new di(this.source,h,r,o,l):r.update&&(r=r.update(r,o,l,new Uf(e.state,a,h>=0)))?new di(this.source,h,r,r.from,(s=r.to)!==null&&s!==void 0?s:Ct(e.state)):new $e(this.source,1,h)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new $e(this.source,0):this.map(e.changes)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new di(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new $e(this.source,0)}}function q0(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):Lf(n,!0).test(s)}const If=W.define({map(n,e){return n.map(t=>t.map(e))}}),Nf=W.define(),Me=fe.define({create(){return Ss.start()},update(n,e){return n.update(e)},provide:n=>[Ro.from(n,e=>e.tooltip),$.contentAttributes.from(n,e=>e.attrs)]});function Ho(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(Me).active.find(s=>s.source==e.source);return i instanceof di?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},P0(n.state,t,i.from,i.to)),{annotations:Fo.of(e.completion)})):t(n,e.completion,i.from,i.to),!0):!1}const z0=A0(Me,Ho);function zn(n,e="option"){return t=>{let i=t.state.field(Me,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Nf.of(l)}),!0}}const j0=n=>{let e=n.state.field(Me,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(Me,!1)?(n.dispatch({effects:xs.of(!0)}),!0):!1,V0=n=>{let e=n.state.field(Me,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:rn.of(null)}),!0)};class _0{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const U0=50,B0=1e3,L0=ne.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(Me).active)e.state==1&&this.startQuery(e)}update(n){let e=n.state.field(Me),t=n.state.facet(me);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Me)==e)return;let i=n.transactions.some(r=>(r.selection||r.docChanged)&&!fo(r,t));for(let r=0;rU0&&Date.now()-o.time>B0){for(let l of o.context.abortListeners)try{l()}catch(a){We(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(xs)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.state==1&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)fo(r,t)=="input"?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(Me);for(let t of e.active)t.state==1&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t)}startQuery(n){let{state:e}=this.view,t=Ct(e),i=new Uf(e,t,n.explicitPos==t),s=new _0(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:rn.of(null)}),We(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(me).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(me);for(let i=0;io.source==s.active.source);if(r&&r.state==1)if(s.done==null){let o=new $e(s.active.source,0);for(let l of s.updates)o=o.update(l,t);o.state!=1&&e.push(o)}else this.startQuery(r)}e.length&&this.view.dispatch({effects:If.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(Me,!1);if(e&&e.tooltip&&this.view.state.facet(me).closeOnBlur){let t=e.open&&$c(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:rn.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:xs.of(!1)}),20),this.composing=0}}}),I0=typeof navigator=="object"&&/Win/.test(navigator.platform),N0=Yt.highest($.domEventHandlers({keydown(n,e){let t=e.state.field(Me,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(I0&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],s=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&Ho(e,i),!1}})),Gf=$.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:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class G0{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class Ko{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,pe.TrackDel),i=e.mapPos(this.to,1,pe.TrackDel);return t==null||i==null?null:new Ko(this.field,t,i)}}class Jo{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let h=o,c=/^\t*/.exec(a)[0].length;for(let f=0;fnew Ko(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",h=-1;for(let c=0;c=h&&f.field++}s.push(new G0(h,i.length,r.index,r.index+a.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}for(let l;l=/\\([{}])/.exec(o);){o=o.slice(0,l.index)+l[1]+o.slice(l.index+l[0].length);for(let a of s)a.line==i.length&&a.from>l.index&&(a.from--,a.to--)}i.push(o)}return new Jo(i,s)}}let F0=T.widget({widget:new class extends ut{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),H0=T.mark({class:"cm-snippetField"});class Pi{constructor(e,t){this.ranges=e,this.active=t,this.deco=T.set(e.map(i=>(i.from==i.to?F0:H0).range(i.from,i.to)))}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new Pi(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const bn=W.define({map(n,e){return n&&n.map(e)}}),K0=W.define(),on=fe.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(bn))return t.value;if(t.is(K0)&&n)return new Pi(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>$.decorations.from(n,e=>e?e.deco:T.none)});function el(n,e){return y.create(n.filter(t=>t.field==e).map(t=>y.range(t.from,t.to)))}function J0(n){let e=Jo.parse(n);return(t,i,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),a={changes:{from:s,to:r,insert:_.of(o)},scrollIntoView:!0,annotations:i?[Fo.of(i),se.userEvent.of("input.complete")]:void 0};if(l.length&&(a.selection=el(l,0)),l.some(h=>h.field>0)){let h=new Pi(l,0),c=a.effects=[bn.of(h)];t.state.field(on,!1)===void 0&&c.push(W.appendConfig.of([on,s1,r1,Gf]))}t.dispatch(t.state.update(a))}}function Ff(n){return({state:e,dispatch:t})=>{let i=e.field(on,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:el(i.ranges,s),effects:bn.of(r?null:new Pi(i.ranges,s)),scrollIntoView:!0})),!0}}const e1=({state:n,dispatch:e})=>n.field(on,!1)?(e(n.update({effects:bn.of(null)})),!0):!1,t1=Ff(1),i1=Ff(-1),n1=[{key:"Tab",run:t1,shift:i1},{key:"Escape",run:e1}],Ea=Z.define({combine(n){return n.length?n[0]:n1}}),s1=Yt.highest(un.compute([Ea],n=>n.facet(Ea)));function Re(n,e){return Object.assign(Object.assign({},e),{apply:J0(n)})}const r1=$.domEventHandlers({mousedown(n,e){let t=e.state.field(on,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:el(t.ranges,s.field),effects:bn.of(t.ranges.some(r=>r.field>s.field)?new Pi(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),ln={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Lt=W.define({map(n,e){let t=e.mapPos(n,-1,pe.TrackAfter);return t==null?void 0:t}}),tl=new class extends Gt{};tl.startSide=1;tl.endSide=-1;const Hf=fe.define({create(){return V.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Lt)&&(n=n.update({add:[tl.range(t.value,t.value+1)]}));return n}});function o1(){return[a1,Hf]}const fr="()[]{}<>";function Kf(n){for(let e=0;e{if((l1?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&Ue(de(i,0))==1||e!=s.from||t!=s.to)return!1;let r=f1(n.state,i);return r?(n.dispatch(r),!0):!1}),h1=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=Jf(n,n.selection.main.head).brackets||ln.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=u1(n.doc,o.head);for(let a of i)if(a==l&&Xs(n.doc,o.head)==Kf(de(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:y.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},c1=[{key:"Backspace",run:h1}];function f1(n,e){let t=Jf(n,n.selection.main.head),i=t.brackets||ln.brackets;for(let s of i){let r=Kf(de(s,0));if(e==s)return r==s?p1(n,s,i.indexOf(s+s+s)>-1,t):d1(n,s,r,t.before||ln.before);if(e==r&&eu(n,n.selection.main.from))return O1(n,s,r)}return null}function eu(n,e){let t=!1;return n.field(Hf).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Xs(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Ue(de(t,0)))}function u1(n,e){let t=n.sliceString(e-2,e);return Ue(de(t,0))==t.length?t:t.slice(1)}function d1(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Lt.of(o.to+e.length),range:y.range(o.anchor+e.length,o.head+e.length)};let l=Xs(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Lt.of(o.head+e.length),range:y.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function O1(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&Xs(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:y.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function p1(n,e,t,i){let s=i.stringPrefixes||ln.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Lt.of(l.to+e.length),range:y.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Xs(n.doc,a),c;if(h==e){if(Va(n,a))return{changes:{insert:e+e,from:a},effects:Lt.of(a+e.length),range:y.cursor(a+e.length)};if(eu(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:y.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=_a(n,a-2*e.length,s))>-1&&Va(n,c))return{changes:{insert:e+e+e+e,from:a},effects:Lt.of(a+e.length),range:y.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=ee.Word&&_a(n,a,s)>-1&&!m1(n,a,e,s))return{changes:{insert:e+e,from:a},effects:Lt.of(a+e.length),range:y.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Va(n,e){let t=he(n).resolveInner(e+1);return t.parent&&t.from==e}function m1(n,e,t,i){let s=he(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=s.firstChild;for(;c&&c.from==s.from&&c.to-c.from>t.length+a;){if(n.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=s.to==e&&s.parent;if(!h)break;s=h}return!1}function _a(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=ee.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=ee.Word)return r}return-1}function g1(n={}){return[N0,Me,me.of(n),L0,b1,Gf]}const tu=[{key:"Ctrl-Space",run:E0},{key:"Escape",run:V0},{key:"ArrowDown",run:zn(!0)},{key:"ArrowUp",run:zn(!1)},{key:"PageDown",run:zn(!0,"page")},{key:"PageUp",run:zn(!1,"page")},{key:"Enter",run:j0}],b1=Yt.highest(un.computeN([me],n=>n.facet(me).defaultKeymap?[tu]:[]));class y1{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class _t{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=e,r=i.facet(nl).markerFilter;r&&(s=r(s,i));let o=T.set(s.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?T.widget({widget:new Z1(l),diagnostic:l}).range(l.from):T.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l,inclusive:!0}).range(l.from,l.to)),!0);return new _t(o,t,Si(o))}}function Si(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new y1(s,r,o.diagnostic),!1}),i}function x1(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(nl).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(iu))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function S1(n,e){return n.field(_e,!1)?e:e.concat(W.appendConfig.of(R1))}const iu=W.define(),il=W.define(),nu=W.define(),_e=fe.define({create(){return new _t(T.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let s=e.changes.mapPos(n.selected.from,1);i=Si(t,n.selected.diagnostic,s)||Si(t,null,s)}n=new _t(t,n.panel,i)}for(let t of e.effects)t.is(iu)?n=_t.init(t.value,n.panel,e.state):t.is(il)?n=new _t(n.diagnostics,t.value?Ys.open:null,n.selected):t.is(nu)&&(n=new _t(n.diagnostics,n.panel,t.value));return n},provide:n=>[Ji.from(n,e=>e.panel),$.decorations.from(n,e=>e.diagnostics)]}),Q1=T.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function w1(n,e,t){let{diagnostics:i}=n.state.field(_e),s=[],r=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{e>=a&&e<=h&&(a==h||(e>a||t>0)&&(eru(n,t,!1)))}const P1=n=>{let e=n.state.field(_e,!1);(!e||!e.panel)&&n.dispatch({effects:S1(n.state,[il.of(!0)])});let t=Ki(n,Ys.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Ua=n=>{let e=n.state.field(_e,!1);return!e||!e.panel?!1:(n.dispatch({effects:il.of(!1)}),!0)},v1=n=>{let e=n.state.field(_e,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},$1=[{key:"Mod-Shift-m",run:P1,preventDefault:!0},{key:"F8",run:v1}],nl=Z.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},ft(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function su(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;ir.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function ru(n,e,t){var i;let s=t?su(e.actions):[];return F("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},F("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let d=Si(n.state.field(_e).diagnostics,e);d&&r.apply(n,d.from,d.to)},{name:h}=r,c=s[o]?h.indexOf(s[o]):-1,f=c<0?h:[h.slice(0,c),F("u",h.slice(c,c+1)),h.slice(c+1)];return F("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&F("div",{class:"cm-diagnosticSource"},e.source))}class Z1 extends ut{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return F("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Ba{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=ru(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Ys{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)Ua(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=su(r.actions);for(let l=0;l{for(let r=0;rUa(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(_e).selected;if(!e)return-1;for(let t=0;t{let h=-1,c;for(let f=i;fi&&(this.items.splice(i,h-i),s=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),r=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.topl.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(_e),i=Si(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:nu.of(i)})}static open(e){return new Ys(e)}}function C1(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function jn(n){return C1(``,'width="6" height="3"')}const T1=$.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:jn("#d11")},".cm-lintRange-warning":{backgroundImage:jn("orange")},".cm-lintRange-info":{backgroundImage:jn("#999")},".cm-lintRange-hint":{backgroundImage:jn("#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}}}),R1=[_e,$.decorations.compute([_e],n=>{let{selected:e,panel:t}=n.field(_e);return!e||!t||e.from==e.to?T.none:T.set([Q1.range(e.from,e.to)])}),xp(w1,{hideOn:x1}),T1],A1=(()=>[Cp(),Ap(),GO(),Nm(),xm(),qO(),_O(),z.allowMultipleSelections.of(!0),lm(),Qm(Pm,{fallback:!0}),Am(),o1(),g1(),hp(),up(),tp(),e0(),un.of([...c1,...Ng,...y0,...ng,...mm,...tu,...$1])])();/*! * VueCodemirror v6.1.1 * Copyright (c) Surmon. All rights reserved. * Released under the MIT License. * Surmon */var M1=Object.freeze({autofocus:!1,disabled:!1,indentWithTab:!0,tabSize:2,placeholder:"",autoDestroy:!0,extensions:[A1]}),W1=Symbol("vue-codemirror-global-config"),Ze,X1=function(n){var e=n.onUpdate,t=n.onChange,i=n.onFocus,s=n.onBlur,r=function(o,l){var a={};for(var h in o)Object.prototype.hasOwnProperty.call(o,h)&&l.indexOf(h)<0&&(a[h]=o[h]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function"){var c=0;for(h=Object.getOwnPropertySymbols(o);ct%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let s=e.parser.context;return new Qs(e,[],t,i,i,0,[],0,s?new Ia(s,s.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 i=e>>19,s=e&65535,{parser:r}=this.p,o=r.dynamicPrecedence(s);if(o&&(this.score+=o),i==0){this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizel;)this.stack.pop();this.reduceContext(s,a)}storeNode(e,t,i,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==i)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,s);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(e,t,i,s){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=s,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,s,4);else{let r=e,{parser:o}=this.p;(s>this.pos||t<=o.maxNode)&&(this.pos=s,o.stateFlag(r,1)||(this.reducePos=s)),this.pushState(r,i),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,s,4)}}apply(e,t,i,s){e&65536?this.reduce(e):this.shift(e,t,i,s)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,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 i=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new Qs(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new E1(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if(!(i&65536))return!0;t.reduce(i)}}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 s=[];for(let r=0,o;ra&1&&l==o)||s.push(t[r],o)}t=s}let i=[];for(let s=0;s>19,s=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}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=[],i=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&e.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+1);if(l!=null)return l}})};return i(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()}}class Ia{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class E1{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class ws{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new ws(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 ws(this.stack,this.pos,this.index)}}function ji(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,s=0;i=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[s++]=r:t=new e(r)}return t}class Kn{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Na=new Kn;class V1{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Na,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 i=this.range,s=this.rangeIndex,r=this.pos+e;for(;ri.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,s;if(t>=0&&t=this.chunk2Pos&&il.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=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=Na,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 i="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}}class Oi{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;lu(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}Oi.prototype.contextual=Oi.prototype.fallback=Oi.prototype.extend=!1;class uo{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?ji(e):e}token(e,t){let i=e.pos,s=0;for(;;){let r=e.next<0,o=e.resolveOffset(1,1);if(lu(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(r||s++,o==null)break;e.reset(o,e.token)}s&&(e.reset(i,e.token),e.acceptToken(this.elseToken,s))}}uo.prototype.contextual=Oi.prototype.fallback=Oi.prototype.extend=!1;class Ds{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function lu(n,e,t,i,s,r){let o=0,l=1<0){let O=n[d];if(a.allows(O)&&(e.token.value==-1||e.token.value==O||_1(O,e.token.value,s,r))){e.acceptToken(O);break}}let c=e.next,f=0,u=n[o+2];if(e.next<0&&u>f&&n[h+u*3-3]==65535){o=n[h+u*3-1];continue e}for(;f>1,O=h+d+(d<<1),p=n[O],m=n[O+1]||65536;if(c=m)f=d+1;else{o=n[O+2],e.advance();continue e}}break}}function Ga(n,e,t){for(let i=e,s;(s=n[i])!=65535;i++)if(s==t)return i-e;return-1}function _1(n,e,t,i){let s=Ga(t,i,e);return s<0||Ga(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class U1{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?Fa(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Fa(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=o,null;if(r instanceof re){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class B1{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new Kn)}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;hf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let u=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!c.extend&&(i=f,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new Kn,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Kn,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){let s=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(s,e),i),e.value>-1){let{parser:r}=i.p;for(let o=0;o=0&&i.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(s+1)}putAction(e,t,i,s){for(let r=0;re.bufferLength*4?new U1(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],s,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)i.push(l);else{if(this.advanceStack(l,i,e))continue;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=s&&G1(s);if(o)return je&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw je&&s&&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&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return je&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&i.splice(12,i.length-12)}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let f=this.fragments.nodeAt(s);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?r.getGoto(e.state,f.type.id):-1;if(u>-1&&f.length&&(!h||(f.prop(j.contextHash)||0)==c))return e.useNode(f,u),je&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(f.type.id)})`),!0;if(!(f instanceof re)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof re&&f.positions[0]==0)f=d;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),je&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;hs?t.push(O):i.push(O)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Ha(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let o=0;o ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),je&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let f=l.split(),u=c;for(let d=0;f.forceReduce()&&d<10&&(je&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)je&&(u=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))je&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),je&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Ha(l,i)):(!s||s.scoren;class N1{constructor(e){this.start=e.start,this.shift=e.shift||dr,this.reduce=e.reduce||dr,this.reuse=e.reuse||dr,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class an extends Xc{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]),s=[];for(let l=0;l=0)r(c,a,l[h++]);else{let f=l[h+-c];for(let u=-c;u>0;u--)r(l[h++],a,f);h++}}}this.nodeSet=new Ao(t.map((l,a)=>De.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Rc;let o=ji(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 Oi(o,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,i){let s=new L1(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&i)return a;for(let h=r+(o>>1);r0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),s=i?t(i):void 0;for(let r=this.stateSlot(e,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Ot(this.data,r+2);else break;s=t(Ot(this.data,r+1))}return s}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Ot(this.data,i+2);else break;if(!(this.data[i+2]&1)){let s=this.data[i+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[i],s)}}return t}configure(e){let t=Object.assign(Object.create(an.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let s=e.tokenizers.find(r=>r.from==i);return s?s.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,s)=>{let r=e.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[s]=Ka(o),o})),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),i=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;ri)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const F1=312,Ja=1,H1=2,K1=3,J1=4,eb=313,tb=315,ib=316,nb=5,sb=6,rb=0,Oo=[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],au=125,ob=59,po=47,lb=42,ab=43,hb=45,cb=60,fb=44,ub=63,db=46,Ob=new N1({start:!1,shift(n,e){return e==nb||e==sb||e==tb?n:e==ib},strict:!1}),pb=new Ds((n,e)=>{let{next:t}=n;(t==au||t==-1||e.context)&&n.acceptToken(eb)},{contextual:!0,fallback:!0}),mb=new Ds((n,e)=>{let{next:t}=n,i;Oo.indexOf(t)>-1||t==po&&((i=n.peek(1))==po||i==lb)||t!=au&&t!=ob&&t!=-1&&!e.context&&n.acceptToken(F1)},{contextual:!0}),gb=new Ds((n,e)=>{let{next:t}=n;if(t==ab||t==hb){if(n.advance(),t==n.next){n.advance();let i=!e.context&&e.canShift(Ja);n.acceptToken(i?Ja:H1)}}else t==ub&&n.peek(1)==db&&(n.advance(),n.advance(),(n.next<48||n.next>57)&&n.acceptToken(K1))},{contextual:!0});function Or(n,e){return n>=65&&n<=90||n>=97&&n<=122||n==95||n>=192||!e&&n>=48&&n<=57}const bb=new Ds((n,e)=>{if(n.next!=cb||!e.dialectEnabled(rb)||(n.advance(),n.next==po))return;let t=0;for(;Oo.indexOf(n.next)>-1;)n.advance(),t++;if(Or(n.next,!0)){for(n.advance(),t++;Or(n.next,!1);)n.advance(),t++;for(;Oo.indexOf(n.next)>-1;)n.advance(),t++;if(n.next==fb)return;for(let i=0;;i++){if(i==7){if(!Or(n.next,!0))return;break}if(n.next!="extends".charCodeAt(i))break;n.advance(),t++}}n.acceptToken(J1,-t)}),yb=Yo({"get set async static":g.modifier,"for while do if else switch try catch finally return throw break continue default case":g.controlKeyword,"in of await yield void typeof delete instanceof":g.operatorKeyword,"let var const using function class extends":g.definitionKeyword,"import export from":g.moduleKeyword,"with debugger as new":g.keyword,TemplateString:g.special(g.string),super:g.atom,BooleanLiteral:g.bool,this:g.self,null:g.null,Star:g.modifier,VariableName:g.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":g.function(g.variableName),VariableDefinition:g.definition(g.variableName),Label:g.labelName,PropertyName:g.propertyName,PrivatePropertyName:g.special(g.propertyName),"CallExpression/MemberExpression/PropertyName":g.function(g.propertyName),"FunctionDeclaration/VariableDefinition":g.function(g.definition(g.variableName)),"ClassDeclaration/VariableDefinition":g.definition(g.className),PropertyDefinition:g.definition(g.propertyName),PrivatePropertyDefinition:g.definition(g.special(g.propertyName)),UpdateOp:g.updateOperator,"LineComment Hashbang":g.lineComment,BlockComment:g.blockComment,Number:g.number,String:g.string,Escape:g.escape,ArithOp:g.arithmeticOperator,LogicOp:g.logicOperator,BitOp:g.bitwiseOperator,CompareOp:g.compareOperator,RegExp:g.regexp,Equals:g.definitionOperator,Arrow:g.function(g.punctuation),": Spread":g.punctuation,"( )":g.paren,"[ ]":g.squareBracket,"{ }":g.brace,"InterpolationStart InterpolationEnd":g.special(g.brace),".":g.derefOperator,", ;":g.separator,"@":g.meta,TypeName:g.typeName,TypeDefinition:g.definition(g.typeName),"type enum interface implements namespace module declare":g.definitionKeyword,"abstract global Privacy readonly override":g.modifier,"is keyof unique infer":g.operatorKeyword,JSXAttributeValue:g.attributeValue,JSXText:g.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":g.angleBracket,"JSXIdentifier JSXNameSpacedName":g.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":g.attributeName,"JSXBuiltin/JSXIdentifier":g.standard(g.tagName)}),xb={__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},Sb={__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},Qb={__proto__:null,"<":187},wb=an.deserialize({version:14,states:"$=dO%TQ^OOO%[Q^OOO'_Q`OOP(lOWOOO*zQ?NdO'#CiO+RO!bO'#CjO+aO#tO'#CjO+oO!0LbO'#D^O.QQ^O'#DdO.bQ^O'#DoO%[Q^O'#DwO0fQ^O'#EPOOQ?Mr'#EX'#EXO1PQWO'#EUOOQO'#Em'#EmOOQO'#Ih'#IhO1XQWO'#GpO1dQWO'#ElO1iQWO'#ElO3hQ?NdO'#JmO6[Q?NdO'#JnO6uQWO'#F[O6zQ&jO'#FsOOQ?Mr'#Fe'#FeO7VO,YO'#FeO7eQ7[O'#FzO9RQWO'#FyOOQ?Mr'#Jn'#JnOOQ?Mp'#Jm'#JmO9WQWO'#GtOOQU'#KZ'#KZO9cQWO'#IUO9hQ?MxO'#IVOOQU'#JZ'#JZOOQU'#IZ'#IZQ`Q^OOO`Q^OOO9pQMnO'#DsO9wQ^O'#D{O:OQ^O'#D}O9^QWO'#GpO:VQ7[O'#CoO:eQWO'#EkO:pQWO'#EvO:uQ7[O'#FdO;dQWO'#GpOOQO'#K['#K[O;iQWO'#K[O;wQWO'#GxO;wQWO'#GyO;wQWO'#G{O9^QWO'#HOOVQWO'#CeO>gQWO'#H_O>oQWO'#HeO>oQWO'#HgO`Q^O'#HiO>oQWO'#HkO>oQWO'#HnO>tQWO'#HtO>yQ?MyO'#HzO%[Q^O'#H|O?UQ?MyO'#IOO?aQ?MyO'#IQO9hQ?MxO'#ISO?lQ?NdO'#CiO@nQ`O'#DiQOQWOOO%[Q^O'#D}OAUQWO'#EQO:VQ7[O'#EkOAaQWO'#EkOAlQpO'#FdOOQU'#Cg'#CgOOQ?Mp'#Dn'#DnOOQ?Mp'#Jq'#JqO%[Q^O'#JqOOQO'#Jt'#JtOOQO'#Id'#IdOBlQ`O'#EdOOQ?Mp'#Ec'#EcOOQ?Mp'#Jx'#JxOChQ?NQO'#EdOCrQ`O'#ETOOQO'#Js'#JsODWQ`O'#JtOEeQ`O'#ETOCrQ`O'#EdPErO#@ItO'#CbPOOO)CDx)CDxOOOO'#I['#I[OE}O!bO,59UOOQ?Mr,59U,59UOOOO'#I]'#I]OF]O#tO,59UO%[Q^O'#D`OOOO'#I_'#I_OFkO!0LbO,59xOOQ?Mr,59x,59xOFyQ^O'#I`OG^QWO'#JoOI]QrO'#JoO+}Q^O'#JoOIdQWO,5:OOIzQWO'#EmOJXQWO'#KOOJdQWO'#J}OJdQWO'#J}OJlQWO,5;ZOJqQWO'#J|OOQ?Mv,5:Z,5:ZOJxQ^O,5:ZOLvQ?NdO,5:cOMgQWO,5:kONQQ?MxO'#J{ONXQWO'#JzO9WQWO'#JzONmQWO'#JzONuQWO,5;YONzQWO'#JzO!#PQrO'#JnOOQ?Mr'#Ci'#CiO%[Q^O'#EPO!#oQrO,5:pOOQQ'#Ju'#JuOOQO-EpOOQU'#Jc'#JcOOQU,5>q,5>qOOQU-EtQWO'#HTO9^QWO'#HVO!DgQWO'#HVO:VQ7[O'#HXO!DlQWO'#HXOOQU,5=m,5=mO!DqQWO'#HYO!ESQWO'#CoO!EXQWO,59PO!EcQWO,59PO!GhQ^O,59POOQU,59P,59PO!GxQ?MxO,59PO%[Q^O,59PO!JTQ^O'#HaOOQU'#Hb'#HbOOQU'#Hc'#HcO`Q^O,5=yO!JkQWO,5=yO`Q^O,5>PO`Q^O,5>RO!JpQWO,5>TO`Q^O,5>VO!JuQWO,5>YO!JzQ^O,5>`OOQU,5>f,5>fO%[Q^O,5>fO9hQ?MxO,5>hOOQU,5>j,5>jO# UQWO,5>jOOQU,5>l,5>lO# UQWO,5>lOOQU,5>n,5>nO# rQ`O'#D[O%[Q^O'#JqO# |Q`O'#JqO#!kQ`O'#DjO#!|Q`O'#DjO#%_Q^O'#DjO#%fQWO'#JpO#%nQWO,5:TO#%sQWO'#EqO#&RQWO'#KPO#&ZQWO,5;[O#&`Q`O'#DjO#&mQ`O'#ESOOQ?Mr,5:l,5:lO%[Q^O,5:lO#&tQWO,5:lO>tQWO,5;VO!A}Q`O,5;VO!BVQ7[O,5;VO:VQ7[O,5;VO#&|QWO,5@]O#'RQ(CYO,5:pOOQO-EzO+}Q^O,5>zOOQO,5?Q,5?QO#*ZQ^O'#I`OOQO-E<^-E<^O#*hQWO,5@ZO#*pQrO,5@ZO#*wQWO,5@iOOQ?Mr1G/j1G/jO%[Q^O,5@jO#+PQWO'#IfOOQO-EoQWO1G3oO$4tQ^O1G3qO$8xQ^O'#HpOOQU1G3t1G3tO$9VQWO'#HvO>tQWO'#HxOOQU1G3z1G3zO$9_Q^O1G3zO9hQ?MxO1G4QOOQU1G4S1G4SOOQ?Mp'#G]'#G]O9hQ?MxO1G4UO9hQ?MxO1G4WO$=fQWO,5@]O!(oQ^O,5;]O9WQWO,5;]O>tQWO,5:UO!(oQ^O,5:UO!A}Q`O,5:UO$=kQ07bO,5:UOOQO,5;],5;]O$=uQ`O'#IaO$>]QWO,5@[OOQ?Mr1G/o1G/oO$>eQ`O'#IgO$>oQWO,5@kOOQ?Mp1G0v1G0vO#!|Q`O,5:UOOQO'#Ic'#IcO$>wQ`O,5:nOOQ?Mv,5:n,5:nO#&wQWO1G0WOOQ?Mr1G0W1G0WO%[Q^O1G0WOOQ?Mr1G0q1G0qO>tQWO1G0qO!A}Q`O1G0qO!BVQ7[O1G0qOOQ?Mp1G5w1G5wO!ArQ?MxO1G0ZOOQO1G0j1G0jO%[Q^O1G0jO$?OQ?MxO1G0jO$?ZQ?MxO1G0jO!A}Q`O1G0ZOCrQ`O1G0ZO$?iQ?MxO1G0jOOQO1G0Z1G0ZO$?}Q?NdO1G0jPOOO-EzO$@kQWO1G5uO$@sQWO1G6TO$@{QrO1G6UO9WQWO,5?QO$AVQ?NdO1G6RO%[Q^O1G6RO$AgQ?MxO1G6RO$AxQWO1G6QO$AxQWO1G6QO9WQWO1G6QO$BQQWO,5?TO9WQWO,5?TOOQO,5?T,5?TO$BfQWO,5?TO$)nQWO,5?TOOQO-E[OOQU,5>[,5>[O%[Q^O'#HqO%:PQWO'#HsOOQU,5>b,5>bO9WQWO,5>bOOQU,5>d,5>dOOQU7+)f7+)fOOQU7+)l7+)lOOQU7+)p7+)pOOQU7+)r7+)rO%:UQ`O1G5wO%:jQ07bO1G0wO%:tQWO1G0wOOQO1G/p1G/pO%;PQ07bO1G/pO>tQWO1G/pO!(oQ^O'#DjOOQO,5>{,5>{OOQO-E<_-E<_OOQO,5?R,5?ROOQO-EtQWO7+&]O!A}Q`O7+&]OOQO7+%u7+%uO$?}Q?NdO7+&UOOQO7+&U7+&UO%[Q^O7+&UO%;ZQ?MxO7+&UO!ArQ?MxO7+%uO!A}Q`O7+%uO%;fQ?MxO7+&UO%;tQ?NdO7++mO%[Q^O7++mO%|O%[Q^O,5>|OOQO-E<`-E<`O%HZQWO1G5xOOQ?Mr<]OOQU,5>_,5>_O&;mQWO1G3|O9WQWO7+&cO!(oQ^O7+&cOOQO7+%[7+%[O&;rQ07bO1G6UO>tQWO7+%[OOQ?Mr<tQWO<tQWO7+)hO'){QWO<{AN>{O%[Q^OAN?[OOQO<]Q7[OG27QOOQO<mQ07bO7+*jOOQUG27iG27iO&:OQWOG27iO!&_Q7[OG27iOOQUG27kG27kO9hQ?MxOG27kOOQUG27sG27sO'>wQ07bOG25TOOQOLD*bLD*bOOQU!$(!Y!$(!YO#&wQWO!$(!YO!&_Q7[O!$(!YO'?RQ?NdOG27QOOQ?MpG26uG26uOOQULD-TLD-TO&:OQWOLD-TOOQULD-VLD-VOOQU!)9Et!)9EtO#&wQWO!)9EtOOQU!$(!o!$(!oOOQU!.K;`!.K;`O'AaQ07bOG27QO!(oQ^O'#DwO1PQWO'#EUO'CSQrO'#JmO'CZQMnO'#DsO'CbQ^O'#D{O'CiQrO'#CiO'FPQrO'#CiO!(oQ^O'#D}O'FaQ^O,5;WO!(oQ^O,5;bO!(oQ^O,5;bO!(oQ^O,5;bO!(oQ^O,5;bO!(oQ^O,5;bO!(oQ^O,5;bO!(oQ^O,5;bO!(oQ^O,5;bO!(oQ^O,5;bO!(oQ^O,5;bO!(oQ^O,5;bO!(oQ^O'#IlO'HdQWO,5kOh%WOk+aO![']O%f+`O~O!d+cOa(WX![(WX'u(WX!Y(WX~Oa%lO![XO'u%lO~Oh%WO!i%cO~Oh%WO!i%cO(O%eO~O!d#vO#h(tO~Ob+nO%g+oO(O+kO(QTO(TUO!Z)TP~O!Y+pO`)SX~O[+tO~O`+uO~O![%}O(O%eO(P!lO`)SP~Oh%WO#]+zO~Oh%WOk+}O![$}O~O![,PO~O},RO![XO~O%k%tO~O!u,WO~Oe,]O~Ob,^O(O#nO(QTO(TUO!Z)RP~Oe%{O~O%g!QO(O&WO~P=RO[,cO`,bO~OPYOQYOSfOdzOeyOmkOoYOpkOqkOwkOyYO{YO!PWO!TkO!UkO!fuO!iZO!lYO!mYO!nYO!pvO!uxO!y]O%e}O(QTO(TUO([VO(j[O(yiO~O![!eO!r!gO$V!kO(O!dO~P!EkO`,bOa%lO'u%lO~OPYOQYOSfOd!jOe!iOmkOoYOpkOqkOwkOyYO{YO!PWO!TkO!UkO![!eO!fuO!iZO!lYO!mYO!nYO!pvO!u!hO$V!kO(O!dO(QTO(TUO([VO(j[O(yiO~Oa,hO!rwO#t!OO%i!OO%j!OO%k!OO~P!HTO!i&lO~O&Y,nO~O![,pO~O&k,rO&m,sOP&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(O&ha(Q&ha(T&ha([&ha(j&ha(y&ha!Z&ha&a&hab&ha&f&ha~O(O,xO~Oh!bX!Y!OX!Z!OX!d!OX!d!bX!i!bX#]!OX~O!Y!bX!Z!bX~P# ZO!d,}O#],|Oh(eX!Y#eX!Y(eX!Z#eX!Z(eX!d(eX!i(eX~Oh%WO!d-PO!i%cO!Y!^X!Z!^X~Op!nO!P!oO(QTO(TUO(`!mO~OP:kOQ:kOSfOdkOg'XX!Y'XX~P!+hO!Y.wOg(ka~OSfO![3uO$c3vO~O!Z3zO~Os3{O~P#.aOa$lq!Y$lq'u$lq's$lq!V$lq!h$lqs$lq![$lq%f$lq!d$lq~P!9mO!V3|O~P#.aO}){O!P)|O(u%QOk'ea(t'ea!Y'ea#]'ea~Og'ea#}'ea~P%+]O}){O!P)|Ok'ga(t'ga(u'ga!Y'ga#]'ga~Og'ga#}'ga~P%,OO(m$ZO~P#.aO!VfX!V$xX!YfX!Y$xX!d%PX#]fX~P!/gO(O;lO~P!1_OmkO(O4OO~P.iO!P%fO!X4QO![%gO(O%eO!Y'aX!h'aX~O!Y/hO!h(za~O!Y/hO!d#vO!h(za~O!Y/hO!d#vO(m'mO!h(za~Og$zi!Y$zi#]$zi#}$zi~P!0pO!X4YO!V'cX!Y'cX~P!3^O!Y/pO!V({a~O!Y/pO!V({a~P#.aO!d#vO#s4bO~Oo4eO!d#vO(m'mO~O(t%OOk%^i}%^i!P%^i(u%^i!Y%^i#]%^i~Og%^i#}%^i~P%0^O(u%QOk%`i}%`i!P%`i(t%`i!Y%`i#]%`i~Og%`i#}%`i~P%1POg(Yi!Y(Yi~P!0pO#]4lOg(Yi!Y(Yi~P!0pO!h4oO~Oa$mq!Y$mq'u$mq's$mq!V$mq!h$mqs$mq![$mq%f$mq!d$mq~P!9mO!V4sO~O!Y4tO![(|X~P#.aOa$xX![$xX%Z]X'u$xX!Y$xX~P!/gO%Z4wOalXklX}lX!PlX![lX'ulX(tlX(ulX!YlX~O%Z4wO~Ob4}O%g5OO(O+kO(QTO(TUO!Y'pX!Z'pX~O!Y0wO!Z)Ta~O[5SO~O`5TO~Oa%lO'u%lO~P#.aO![$}O~P#.aO!Y5]O#]5_O!Z)QX~O!Z5`O~Op!nO!P5aO!_!yO!`!vO!a!vO!y:lO#Q!pO#R!pO#S!pO#T!pO#U!pO#X5fO#Y!zO(P!lO(QTO(TUO(`!mO(j!sO~O!Z5eO~P%6ZOk5kO![1aO%f5jO~Oh%WOk5kO![1aO%f5jO~Ob5rO(O#nO(QTO(TUO!Y'oX!Z'oX~O!Y1lO!Z)Ra~O(QTO(TUO(`5tO~O`5xO~O#s5{O&W5|O~PMlO!h5}O~P%[Oa6PO~Oa6PO~P%[Ob2SO!Z6UO&f2RO~P`O!d6WO~O!d6YOh(ei!Y(ei!Z(ei!d(ei!i(ei~O!Y#ei!Z#ei~P#D_O#]6ZO!Y#ei!Z#ei~O!Y!^i!Z!^i~P#D_Oa%lO#]6dO'u%lO~Oa%lO!d#vO#]6dO'u%lO~O!Y(oq!h(oqa(oq'u(oq~P!9mO!Y(fO!h(nq~O!P%fO![%gO#g6kO(O%eO~O![']O%f6nO~Ok6rO![']O%f6nO~O#h'eaP'eaR'ea['eaa'eao'ea!i'ea!m'ea#O'ea#k'ea#l'ea#m'ea#n'ea#o'ea#p'ea#q'ea#r'ea#s'ea#u'ea#w'ea#y'ea#z'ea'u'ea(['ea(m'ea!h'ea!V'ea's'eas'ea!['ea%f'ea!d'ea~P%+]O#h'gaP'gaR'ga['gaa'gao'ga!i'ga!m'ga#O'ga#k'ga#l'ga#m'ga#n'ga#o'ga#p'ga#q'ga#r'ga#s'ga#u'ga#w'ga#y'ga#z'ga'u'ga(['ga(m'ga!h'ga!V'ga's'gas'ga!['ga%f'ga!d'ga~P%,OO#h$ziP$ziR$zi[$zia$zio$zi!Y$zi!i$zi!m$zi#O$zi#k$zi#l$zi#m$zi#n$zi#o$zi#p$zi#q$zi#r$zi#s$zi#u$zi#w$zi#y$zi#z$zi'u$zi([$zi(m$zi!h$zi!V$zi's$zi#]$zis$zi![$zi%f$zi!d$zi~P#.aO#h%^iP%^iR%^i[%^ia%^io%^i!i%^i!m%^i#O%^i#k%^i#l%^i#m%^i#n%^i#o%^i#p%^i#q%^i#r%^i#s%^i#u%^i#w%^i#y%^i#z%^i'u%^i([%^i(m%^i!h%^i!V%^i's%^is%^i![%^i%f%^i!d%^i~P%0^O#h%`iP%`iR%`i[%`ia%`io%`i!i%`i!m%`i#O%`i#k%`i#l%`i#m%`i#n%`i#o%`i#p%`i#q%`i#r%`i#s%`i#u%`i#w%`i#y%`i#z%`i'u%`i([%`i(m%`i!h%`i!V%`i's%`is%`i![%`i%f%`i!d%`i~P%1PO!Y'Ua!h'Ua~P!9mO!Y.lO!h(fi~O#}#`i!Y#`i!Z#`i~P#D_OP$]OR#zO}#yO!P#{O!i#xO!m$]O([VO[#jio#ji#O#ji#l#ji#m#ji#n#ji#o#ji#p#ji#q#ji#r#ji#s#ji#u#ji#w#ji#y#ji#z#ji#}#ji(m#ji(t#ji(u#ji!Y#ji!Z#ji~O#k#ji~P%HpO#k:tO~P%HpOP$]OR#zO}#yO!P#{O!i#xO!m$]O#k:tO#l:uO#m:uO#n:uO([VO[#ji#O#ji#o#ji#p#ji#q#ji#r#ji#s#ji#u#ji#w#ji#y#ji#z#ji#}#ji(m#ji(t#ji(u#ji!Y#ji!Z#ji~Oo#ji~P%JxOo:vO~P%JxOP$]OR#zOo:vO}#yO!P#{O!i#xO!m$]O#k:tO#l:uO#m:uO#n:uO#o:wO([VO#u#ji#w#ji#y#ji#z#ji#}#ji(m#ji(t#ji(u#ji!Y#ji!Z#ji~O[#ji#O#ji#p#ji#q#ji#r#ji#s#ji~P%MQO[;SO#O:xO#p:xO#q:xO#r;RO#s:xO~P%MQOP$]OR#zO[;SOo:vO}#yO!P#{O!i#xO!m$]O#O:xO#k:tO#l:uO#m:uO#n:uO#o:wO#p:xO#q:xO#r;RO#s:xO#u:yO([VO(u#}O#y#ji#z#ji#}#ji(m#ji(t#ji!Y#ji!Z#ji~O#w:{O~P& iO#w#ji~P& iOP$]OR#zO[;SOo:vO}#yO!P#{O!i#xO!m$]O#O:xO#k:tO#l:uO#m:uO#n:uO#o:wO#p:xO#q:xO#r;RO#s:xO#u:yO([VO#y#ji#z#ji#}#ji(m#ji!Y#ji!Z#ji~O#w#ji(t#ji(u#ji~P&#qO#w:{O(t#|O(u#}O~P&#qOP$]OR#zO[;SOo:vO}#yO!P#{O!i#xO!m$]O#O:xO#k:tO#l:uO#m:uO#n:uO#o:wO#p:xO#q:xO#r;RO#s:xO#u:yO#w:{O#y:}O([VO(t#|O(u#}O~O#z#ji#}#ji(m#ji!Y#ji!Z#ji~P&&POa#{y!Y#{y'u#{y's#{y!V#{y!h#{ys#{y![#{y%f#{y!d#{y~P!9mOk < 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:376,context:Ob,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:[yb],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(Rp(U!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(U!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(U!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$h&j(RpOY(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(RpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Rp(U!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(Rp(U!b'w0/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(S#S$h&j'x0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$h&j(Rp(U!b'x0/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(Rp(U!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(Rp(U!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(Rp(U!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_(Q':f$h&j(U!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$h&j(U!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(U!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(U!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$c`(U!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$h&j(Rp(U!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(U!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(RpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(RpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Rp(U!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(U!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(U!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(U!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(U!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(U!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(Rp(U!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(Rp(U!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(Rp(U!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(Rp(U!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(Rp(U!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(Rp(U!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(Rp(U!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(Rp(U!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(Rp(U!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-xb[n]||-1},{term:338,get:n=>Sb[n]||-1},{term:92,get:n=>Qb[n]||-1}],tokenPrec:14793}),hu=[Re("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Re("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Re("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Re("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Re("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Re(`try { \${} } catch (\${error}) { \${} }`,{label:"try",detail:"/ catch block",type:"keyword"}),Re("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Re(`if (\${}) { \${} } else { \${} }`,{label:"if",detail:"/ else block",type:"keyword"}),Re(`class \${name} { constructor(\${params}) { \${} } }`,{label:"class",detail:"definition",type:"keyword"}),Re('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Re('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],kb=hu.concat([Re("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Re("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Re("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),eh=new zp,cu=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Wi(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const Pb=["FunctionDeclaration"],vb={FunctionDeclaration:Wi("function"),ClassDeclaration:Wi("class"),ClassExpression:()=>!0,EnumDeclaration:Wi("constant"),TypeAliasDeclaration:Wi("type"),NamespaceDeclaration:Wi("namespace"),VariableDefinition(n,e){n.matchContext(Pb)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function fu(n,e){let t=eh.get(e);if(t)return t;let i=[],s=!0;function r(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(ae.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let l=vb[o.name];if(l&&l(o,r)||cu.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of fu(n,o.node))i.push(l);return!1}}),eh.set(e,i),i}const th=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,uu=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function $b(n){let e=he(n.state).resolveInner(n.pos,-1);if(uu.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&th.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let s=e;s;s=s.parent)cu.has(s.name)&&(i=i.concat(fu(n.state.doc,s)));return{options:i,from:t?e.from:n.pos,validFor:th}}const Nt=tn.define({name:"javascript",parser:wb.configure({props:[zo.add({IfStatement:Li({except:/^\s*({|else\b)/}),TryStatement:Li({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:rm,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:sm({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Li({except:/^{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Eo.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":_c,BlockComment(n){return{from:n.from+2,to:n.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),du={test:n=>/^JSX/.test(n.name),facet:qc({commentTokens:{block:{open:"{/*",close:"*/}"}}})},Zb=Nt.configure({dialect:"ts"},"typescript"),Cb=Nt.configure({dialect:"jsx",props:[Do.add(n=>n.isTop?[du]:void 0)]}),Tb=Nt.configure({dialect:"jsx ts",props:[Do.add(n=>n.isTop?[du]:void 0)]},"typescript");let Ou=n=>({label:n,type:"keyword"});const pu="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Ou),Rb=pu.concat(["declare","implements","private","protected","public"].map(Ou));function pr(n={}){let e=n.jsx?n.typescript?Tb:Cb:n.typescript?Zb:Nt,t=n.typescript?kb.concat(Rb):hu.concat(pu);return new jc(e,[Nt.data.of({autocomplete:k0(uu,Bf(t))}),Nt.data.of({autocomplete:$b}),n.jsx?Wb:[]])}function Ab(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function ih(n,e,t=n.length){for(let i=e==null?void 0:e.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const Mb=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Wb=$.inputHandler.of((n,e,t,i,s)=>{if((Mb?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!Nt.isActiveAt(n.state,e,-1))return!1;let r=s(),{state:o}=r,l=o.changeByRange(a=>{var h;let{head:c}=a,f=he(o).resolveInner(c-1,-1),u;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(c-1,c)!=i||f.name=="JSXAttributeValue"&&f.to>c)){if(i==">"&&f.name=="JSXFragmentTag")return{range:a,changes:{from:c,insert:""}};if(i=="/"&&f.name=="JSXStartCloseTag"){let d=f.parent,O=d.parent;if(O&&d.from==c-2&&((u=ih(o.doc,O.firstChild,c))||((h=O.firstChild)===null||h===void 0?void 0:h.name)=="JSXFragmentTag")){let p=`${u}>`;return{range:y.cursor(c+p.length,-1),changes:{from:c,insert:p}}}}else if(i==">"){let d=Ab(f);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(c,c+2))&&(u=ih(o.doc,d,c)))return{range:a,changes:{from:c,insert:``}}}}return{range:a}});return l.changes.empty?!1:(n.dispatch([r,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Xb=Yo({String:g.string,Number:g.number,"True False":g.bool,PropertyName:g.propertyName,Null:g.null,",":g.separator,"[ ]":g.squareBracket,"{ }":g.brace}),Yb=an.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",stateData:"#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",goto:"!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",12,"["],["closedBy",8,"}",13,"]"]],propSources:[Xb],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oc~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Oe~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zOh~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yOg~~'OO]~~'TO[~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),Db=tn.define({name:"json",parser:Yb.configure({props:[zo.add({Object:Li({except:/^\s*\}/}),Array:Li({except:/^\s*\]/})}),Eo.add({"Object Array":_c})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function mr(){return new jc(Db)}const sl=n=>(wu("data-v-215c20bb"),n=n(),ku(),n),qb={class:"cus-animation",style:{height:"100%",width:"100%",padding:"16px 20px",display:"flex","flex-direction":"column"}},zb={class:"card-container",style:{"flex-grow":"5",height:"0px"}},jb={style:{height:"100%",display:"flex"}},Eb={style:{"border-left":"1px solid #eee"}},Vb={style:{height:"100%","flex-grow":"1"}},_b={style:{height:"100%",display:"flex"}},Ub={style:{"border-left":"1px solid #eee"}},Bb={style:{height:"100%","flex-grow":"1"}},Lb=sl(()=>Ae("div",{style:{"margin-right":"5px"}},[Ae("span",null,"JavaScript")],-1)),Ib={class:"card-container2",style:{"flex-grow":"3",height:"0px",overflow:"hidden"}},Nb={style:{"margin-right":"0px"}},Gb=sl(()=>Ae("span",{style:{"margin-right":"0px"}},"输入类型:",-1)),Fb=sl(()=>Ae("span",{style:{"margin-left":"40px"}},"处理步骤:",-1)),Hb={style:{padding:"16px 0px 10px 44px"}},Kb=nh({__name:"Index",setup(n){const e=ve(null),t=Su({x:1300}),i=pr(),s=[pr()],r=R=>{q.value=!1;const A=f.value[0];R!=c.value[parseInt(A)].code?c.value[parseInt(A)].isChange=!0:c.value[parseInt(A)].isChange=!1},o=ve(!1),l=()=>{d.value==X.value?o.value=!0:o.value=!1},a=mr(),h=[mr()],c=ve([]),f=ve(["0"]),u=ve(0),d=ve(""),O=ve("mqtt"),p=ve("web"),m=ve(""),b=ve(""),x=function(){$i({url:"/script/get-code",data:{type:"test"}},R=>{if(console.log(R),R.code==0){c.value=R.data;for(let A=0;A{console.log(G),G.code==0?(jt.success("保存成功"),c.value[parseInt(R)].code=d.value,c.value[parseInt(R)].isChange=!1):jt.error(G.data)})},Q=function(R){const A=R.key;c.value[u.value].draft=d.value,c.value[u.value].draft!=c.value[u.value].code&&(c.value[u.value].isChange=!0),u.value=A,d.value=c.value[A].draft},S=ve(1),v=function(){if(m.value==""){jt.error("模拟输入不能为空");return}$i({url:"/script/test",data:{from:O.value,to:p.value,input:m.value}},R=>{console.log(R),console.log(typeof R.data),typeof R.data=="object"?b.value=JSON.stringify(R.data,null,2):b.value=R.data+"",S.value=2,(p.value=="web"||p.value=="pc")&&(q.value=!0)},R=>{console.log(R),b.value=R.msg,S.value=2})},w=ve([]),M=ve(["0"]),X=ve(""),q=ve(!1),Y=function(){$i({url:"/script/get-code",data:{type:"prod"}},R=>{console.log(R),R.code==0?(w.value=R.data,X.value=w.value[0].code):jt.error(R.data),l()})},D=function(){$i({url:"/script/publish"},R=>{console.log(R),R.code==0?(jt.success("发布成功"),Y()):jt.error(R.data),q.value=!1})},L=function(R){console.log(R.key),X.value=w.value[R.key].code},E=function(R){console.log(R),R==2&&!X.value&&Y()},H=()=>{P()},be=()=>{v()},ye=()=>{console.log("prod"),D()};return sh(()=>{var R;console.log("device onMounted..."),t.y=((R=e.value)==null?void 0:R.clientHeight)-113,x(),Y()}),(R,A)=>{const G=zt("a-menu-item"),we=zt("a-menu"),ke=zt("a-tab-pane"),Je=zt("a-tabs"),Pe=zt("a-select-option"),qt=zt("a-select"),ei=zt("a-button");return xt(),js("div",qb,[U(ce(vu),{title:"脚本管理"}),Ae("div",zb,[U(Je,{type:"card",onChange:E},{rightExtra:B(()=>[Lb]),default:B(()=>[U(ke,{key:"1",tab:"草稿版"},{default:B(()=>[Ae("div",jb,[Ae("div",Eb,[U(we,{selectedKeys:f.value,"onUpdate:selectedKeys":A[0]||(A[0]=te=>f.value=te),style:{width:"160px"},mode:"vertical",onSelect:Q},{default:B(()=>[(xt(!0),js(rl,null,ol(c.value,(te,qs)=>(xt(),vi(G,{key:qs+""},{icon:B(()=>[U(ce(ll))]),default:B(()=>[qe(" "+Es(te.fileName)+" "+Es(te.isChange?"*":""),1)]),_:2},1024))),128))]),_:1},8,["selectedKeys"])]),Ae("div",Vb,[U(ce(Vn),{style:{height:"100%"},modelValue:d.value,"onUpdate:modelValue":A[1]||(A[1]=te=>d.value=te),lang:ce(i),extensions:s,onChange:r},null,8,["modelValue","lang"])])])]),_:1}),U(ke,{key:"2",tab:"发布版","force-render":!1},{default:B(()=>[Ae("div",_b,[Ae("div",Ub,[U(we,{selectedKeys:M.value,"onUpdate:selectedKeys":A[2]||(A[2]=te=>M.value=te),style:{width:"160px"},mode:"vertical",onSelect:L},{default:B(()=>[(xt(!0),js(rl,null,ol(w.value,(te,qs)=>(xt(),vi(G,{key:qs+""},{icon:B(()=>[U(ce(ll))]),default:B(()=>[qe(" "+Es(te.fileName),1)]),_:2},1024))),128))]),_:1},8,["selectedKeys"])]),Ae("div",Bb,[U(ce(Vn),{style:{height:"100%"},modelValue:X.value,"onUpdate:modelValue":A[3]||(A[3]=te=>X.value=te),lang:ce(i),extensions:[ce(pr)(),ce(z).readOnly.of(!0)]},null,8,["modelValue","lang","extensions"])])])]),_:1})]),_:1})]),Ae("div",Ib,[U(Je,{type:"card",activeKey:S.value,"onUpdate:activeKey":A[8]||(A[8]=te=>S.value=te)},{rightExtra:B(()=>[Ae("div",Nb,[Gb,U(qt,{ref:"select",value:O.value,"onUpdate:value":A[6]||(A[6]=te=>O.value=te),size:"default",bordered:!1,style:{width:"120px"}},{default:B(()=>[U(Pe,{value:"mqtt"},{default:B(()=>[qe("MQTT数据")]),_:1}),U(Pe,{value:"tcp"},{default:B(()=>[qe("TCP数据")]),_:1})]),_:1},8,["value"]),Fb,U(qt,{ref:"select",value:p.value,"onUpdate:value":A[7]||(A[7]=te=>p.value=te),size:"default",bordered:!1,style:{width:"210px"}},{default:B(()=>[O.value=="tcp"?(xt(),vi(Pe,{key:0,value:"stick"},{default:B(()=>[qe("粘包处理")]),_:1})):Qu("",!0),U(Pe,{value:"analy"},{default:B(()=>[qe("解析(第一步)")]),_:1}),U(Pe,{value:"will_zhenghe"},{default:B(()=>[qe("待整合(第二步)")]),_:1}),U(Pe,{value:"zhenghe"},{default:B(()=>[qe("整合(第二步)")]),_:1}),U(Pe,{value:"web"},{default:B(()=>[qe("发送到Web端(第三步)")]),_:1}),U(Pe,{value:"pc"},{default:B(()=>[qe("发送到PC端(第三步)")]),_:1})]),_:1},8,["value"])])]),default:B(()=>[(xt(),vi(ke,{key:1,tab:"模拟输入"},{default:B(()=>[U(ce(Vn),{style:{height:"100%"},modelValue:m.value,"onUpdate:modelValue":A[4]||(A[4]=te=>m.value=te),lang:ce(a),extensions:h},null,8,["modelValue","lang"])]),_:1})),(xt(),vi(ke,{key:2,tab:"运行结果","force-render":""},{default:B(()=>[U(ce(Vn),{style:{height:"100%"},modelValue:b.value,"onUpdate:modelValue":A[5]||(A[5]=te=>b.value=te),lang:ce(a),extensions:[ce(mr)(),ce(z).readOnly.of(!0)]},null,8,["modelValue","lang","extensions"])]),_:1}))]),_:1},8,["activeKey"]),Ae("div",Hb,[U(ei,{type:"default",size:"default",style:{"margin-right":"16px"},onClick:H},{icon:B(()=>[U(ce(Wu))]),default:B(()=>[qe(" 保存 ")]),_:1}),U(ei,{type:"primary",size:"default",style:{"margin-right":"16px"},onClick:be},{icon:B(()=>[U(ce(Tu))]),default:B(()=>[qe(" 运行 ")]),_:1}),U(ei,{type:"primary",size:"default",disabled:!q.value,onClick:ye},{icon:B(()=>[U(ce(qu))]),default:B(()=>[qe(" 发布 ")]),_:1},8,["disabled"])])])])}}});const sy=Pu(Kb,[["__scopeId","data-v-215c20bb"]]);export{sy as default};